From 585be0e7d5227132a2a0efc3ace309af8226e76e Mon Sep 17 00:00:00 2001 From: "Isaac (eartharoid)" Date: Sun, 20 Sep 2020 22:01:10 +0100 Subject: [PATCH] Revert "Added extremely basic multi-role support" This reverts commit 1c226e8f7ebccbb3d0e512e7eb5ca4e90193e457. --- src/commands/add.js | 3 +-- src/commands/close.js | 3 +-- src/commands/delete.js | 2 +- src/commands/new.js | 6 +++--- src/commands/remove.js | 3 +-- src/commands/tickets.js | 7 +++---- src/commands/transcript.js | 3 +-- src/events/messageReactionAdd.js | 6 +++--- src/index.js | 1 - src/modules/utils.js | 11 ----------- user/config.js | 2 +- 11 files changed, 15 insertions(+), 32 deletions(-) diff --git a/src/commands/add.js b/src/commands/add.js index 7b96afa..dc500d7 100644 --- a/src/commands/add.js +++ b/src/commands/add.js @@ -9,7 +9,6 @@ const { MessageEmbed } = require('discord.js'); const ChildLogger = require('leekslazylogger').ChildLogger; const log = new ChildLogger(); -const utils = require('../modules/utils'); module.exports = { name: 'add', @@ -53,7 +52,7 @@ module.exports = { } } - if(message.author.id !== ticket.creator && !utils.isStaff(message.member)) + if(message.author.id !== ticket.creator && !message.member.roles.cache.has(config.staff_role)) return message.channel.send( new MessageEmbed() .setColor(config.err_colour) diff --git a/src/commands/close.js b/src/commands/close.js index f16d223..3bd2841 100644 --- a/src/commands/close.js +++ b/src/commands/close.js @@ -13,7 +13,6 @@ const { } = require('discord.js'); const fs = require('fs'); const archive = require('../modules/archive'); -const utils = require('../modules/utils'); module.exports = { name: 'close', @@ -67,7 +66,7 @@ module.exports = { return message.channel.send(notTicket); } - if (message.author.id !== ticket.creator && !utils.isStaff(message.member)) + if (message.author.id !== ticket.creator && !message.member.roles.cache.has(config.staff_role)) return channel.send( new MessageEmbed() .setColor(config.err_colour) diff --git a/src/commands/delete.js b/src/commands/delete.js index ff2c988..d06a51e 100644 --- a/src/commands/delete.js +++ b/src/commands/delete.js @@ -65,7 +65,7 @@ module.exports = { return message.channel.send(notTicket); } - if (message.author.id !== ticket.creator && !utils.isStaff(message.member)) + if (message.author.id !== ticket.creator && !message.member.roles.cache.has(config.staff_role)) return channel.send( new MessageEmbed() .setColor(config.err_colour) diff --git a/src/commands/new.js b/src/commands/new.js index 0ccf5ee..162d7aa 100644 --- a/src/commands/new.js +++ b/src/commands/new.js @@ -22,13 +22,13 @@ module.exports = { const guild = client.guilds.cache.get(config.guild); - const supportRole = guild.roles.cache.get(config.staff_roles[0]); + const supportRole = guild.roles.cache.get(config.staff_role); if (!supportRole) return message.channel.send( new MessageEmbed() .setColor(config.err_colour) .setTitle(':x: **Error**') - .setDescription(`${config.name} has not been set up correctly. Could not find a 'support team' role with the id \`${config.staff_roles[0]}\``) + .setDescription(`${config.name} has not been set up correctly. Could not find a 'support team' role with the id \`${config.staff_role}\``) .setFooter(guild.name, guild.iconURL()) ); @@ -140,7 +140,7 @@ module.exports = { let ping; switch (config.tickets.ping) { case 'staff': - ping = `<@&${config.staff_roles[0]}>,\n`; + ping = `<@&${config.staff_role}>,\n`; break; case false: ping = ''; diff --git a/src/commands/remove.js b/src/commands/remove.js index 31f4f38..48b2de3 100644 --- a/src/commands/remove.js +++ b/src/commands/remove.js @@ -9,7 +9,6 @@ const { MessageEmbed } = require('discord.js'); const ChildLogger = require('leekslazylogger').ChildLogger; const log = new ChildLogger(); -const utils = require('../modules/utils'); module.exports = { name: 'remove', @@ -53,7 +52,7 @@ module.exports = { } } - if(message.author.id !== ticket.creator && !utils.isStaff(message.member)) + if(message.author.id !== ticket.creator && !message.member.roles.cache.has(config.staff_role)) return message.channel.send( new MessageEmbed() .setColor(config.err_colour) diff --git a/src/commands/tickets.js b/src/commands/tickets.js index 624fd42..d125865 100644 --- a/src/commands/tickets.js +++ b/src/commands/tickets.js @@ -8,7 +8,6 @@ const { MessageEmbed } = require('discord.js'); const fs = require('fs'); -const utils = require('../modules/utils'); module.exports = { name: 'tickets', @@ -21,13 +20,13 @@ module.exports = { const guild = client.guilds.cache.get(config.guild); - const supportRole = guild.roles.cache.get(config.staff_roles[0]); + const supportRole = guild.roles.cache.get(config.staff_role); if (!supportRole) return message.channel.send( new MessageEmbed() .setColor(config.err_colour) .setTitle(':x: **Error**') - .setDescription(`${config.name} has not been set up correctly. Could not find a 'support team' role with the id \`${config.staff_roles[0]}\``) + .setDescription(`${config.name} has not been set up correctly. Could not find a 'support team' role with the id \`${config.staff_role}\``) .setFooter(guild.name, guild.iconURL()) ); @@ -35,7 +34,7 @@ module.exports = { let user = message.mentions.users.first() || guild.members.cache.get(args[0]); if(user) { - if(!utils.isStaff(message.member)) + if(!message.member.roles.cache.has(config.staff_role)) return message.channel.send( new MessageEmbed() .setColor(config.err_colour) diff --git a/src/commands/transcript.js b/src/commands/transcript.js index d0cefde..5c6be40 100644 --- a/src/commands/transcript.js +++ b/src/commands/transcript.js @@ -10,7 +10,6 @@ const fs = require('fs'); const { MessageEmbed } = require('discord.js'); -const utils = require('../modules/utils'); module.exports = { name: 'transcript', @@ -42,7 +41,7 @@ module.exports = { .setFooter(guild.name, guild.iconURL()) ); - if (message.author.id !== ticket.creator && !utils.isStaff(message.member)) + if (message.author.id !== ticket.creator && !message.member.roles.cache.has(config.staff_role)) return message.channel.send( new MessageEmbed() .setColor(config.err_colour) diff --git a/src/events/messageReactionAdd.js b/src/events/messageReactionAdd.js index 310745e..a1c212e 100644 --- a/src/events/messageReactionAdd.js +++ b/src/events/messageReactionAdd.js @@ -34,13 +34,13 @@ module.exports = { let channel = r.message.channel; - const supportRole = channel.guild.roles.cache.get(config.staff_roles[0]); + const supportRole = channel.guild.roles.cache.get(config.staff_role); if (!supportRole) return channel.send( new MessageEmbed() .setColor(config.err_colour) .setTitle(':x: **Error**') - .setDescription(`${config.name} has not been set up correctly. Could not find a 'support team' role with the id \`${config.staff_roles[0]}\``) + .setDescription(`${config.name} has not been set up correctly. Could not find a 'support team' role with the id \`${config.staff_role}\``) .setFooter(channel.guild.name, channel.guild.iconURL()) ); @@ -144,7 +144,7 @@ module.exports = { let ping; switch (config.tickets.ping) { case 'staff': - ping = `<@&${config.staff_roles[0]}>,\n`; + ping = `<@&${config.staff_role}>,\n`; break; case false: ping = ''; diff --git a/src/index.js b/src/index.js index 7095916..744d890 100644 --- a/src/index.js +++ b/src/index.js @@ -23,7 +23,6 @@ const client = new Discord.Client({ client.events = new Discord.Collection(); client.commands = new Discord.Collection(); client.cooldowns = new Discord.Collection(); -client.config = config; const utils = require('./modules/utils'); const leeks = require('leeks.js'); diff --git a/src/modules/utils.js b/src/modules/utils.js index 19118c4..d86de48 100644 --- a/src/modules/utils.js +++ b/src/modules/utils.js @@ -14,16 +14,5 @@ module.exports = { */ plural(word, num) { return num !== 1 ? word + 's' : word; - }, - - isStaff(member) { - let staff = false; - - member.client.config.staff_roles.forEach(id => { - if (member.roles.cache.has(id)) - staff = true; - }); - - return staff; } }; \ No newline at end of file diff --git a/user/config.js b/user/config.js index e8d96cd..ead0ac6 100644 --- a/user/config.js +++ b/user/config.js @@ -36,7 +36,7 @@ module.exports = { cooldown: 3, guild: '', // ID of your guild - staff_roles: [''], // ID of your Support Team role + staff_role: '', // ID of your Support Team role tickets: { category: '', // ID of your tickets category