Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const db = require('quick.db')
- client.on('message', message => {
- if (!message.content.startsWith(prefix) || message.author.bot) return;
- const args = message.content.slice(prefix.length).trim().split(/ +/);
- const command = args.shift().toLowerCase();
- const autorole = message.guild.roles.cache.find(r => r.name === args[0])
- if(command === 'set-autorole') {
- if(message.channel.type === 'dm') return;
- if(!message.member.hasPermission('MANAGE_ROLES')) return;
- if(!args[0]) return message.channel.send("please type role name after the command")
- if(!autorole) return message.channel.send("role not found")
- message.channel.send(`set autorole to **${autorole.name}**`)
- db.set(`guilds_${message.guild.id}`, autorole.id)
- }
- if(command === 'remove-autorole') {
- if(!message.member.hasPermission('MANAGE_ROLES')) return;
- if(!args[0]) return message.channel.send("please type role name after the command")
- if(!autorole) return message.channel.send("role not found")
- message.channel.send(`removed autorole which was **${autorole.name}**`)
- db.delete(`guilds_${message.guild.id}`, autorole.id)
- }
- });
- client.on('guildMemberAdd', async(member) => {
- let autoroles = await db.fetch(`guilds_${member.guild.id}`);
- if(db.has(`guilds_${member.guild.id}`)) {
- member.roles.add(autoroles)
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement