Added extremely basic multi-role support

This commit is contained in:
Isaac (eartharoid) 2020-09-20 22:01:10 +01:00
parent 8f585b8c76
commit 1c226e8f7e
11 changed files with 32 additions and 15 deletions

View File

@ -9,6 +9,7 @@
const { MessageEmbed } = require('discord.js');
const ChildLogger = require('leekslazylogger').ChildLogger;
const log = new ChildLogger();
const utils = require('../modules/utils');
module.exports = {
name: 'add',
@ -52,7 +53,7 @@ module.exports = {
}
}
if(message.author.id !== ticket.creator && !message.member.roles.cache.has(config.staff_role))
if(message.author.id !== ticket.creator && !utils.isStaff(message.member))
return message.channel.send(
new MessageEmbed()
.setColor(config.err_colour)

View File

@ -13,6 +13,7 @@ const {
} = require('discord.js');
const fs = require('fs');
const archive = require('../modules/archive');
const utils = require('../modules/utils');
module.exports = {
name: 'close',
@ -66,7 +67,7 @@ module.exports = {
return message.channel.send(notTicket);
}
if (message.author.id !== ticket.creator && !message.member.roles.cache.has(config.staff_role))
if (message.author.id !== ticket.creator && !utils.isStaff(message.member))
return channel.send(
new MessageEmbed()
.setColor(config.err_colour)

View File

@ -65,7 +65,7 @@ module.exports = {
return message.channel.send(notTicket);
}
if (message.author.id !== ticket.creator && !message.member.roles.cache.has(config.staff_role))
if (message.author.id !== ticket.creator && !utils.isStaff(message.member))
return channel.send(
new MessageEmbed()
.setColor(config.err_colour)

View File

@ -22,13 +22,13 @@ module.exports = {
const guild = client.guilds.cache.get(config.guild);
const supportRole = guild.roles.cache.get(config.staff_role);
const supportRole = guild.roles.cache.get(config.staff_roles[0]);
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_role}\``)
.setDescription(`${config.name} has not been set up correctly. Could not find a 'support team' role with the id \`${config.staff_roles[0]}\``)
.setFooter(guild.name, guild.iconURL())
);
@ -140,7 +140,7 @@ module.exports = {
let ping;
switch (config.tickets.ping) {
case 'staff':
ping = `<@&${config.staff_role}>,\n`;
ping = `<@&${config.staff_roles[0]}>,\n`;
break;
case false:
ping = '';

View File

@ -9,6 +9,7 @@
const { MessageEmbed } = require('discord.js');
const ChildLogger = require('leekslazylogger').ChildLogger;
const log = new ChildLogger();
const utils = require('../modules/utils');
module.exports = {
name: 'remove',
@ -52,7 +53,7 @@ module.exports = {
}
}
if(message.author.id !== ticket.creator && !message.member.roles.cache.has(config.staff_role))
if(message.author.id !== ticket.creator && !utils.isStaff(message.member))
return message.channel.send(
new MessageEmbed()
.setColor(config.err_colour)

View File

@ -8,6 +8,7 @@
const { MessageEmbed } = require('discord.js');
const fs = require('fs');
const utils = require('../modules/utils');
module.exports = {
name: 'tickets',
@ -20,13 +21,13 @@ module.exports = {
const guild = client.guilds.cache.get(config.guild);
const supportRole = guild.roles.cache.get(config.staff_role);
const supportRole = guild.roles.cache.get(config.staff_roles[0]);
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_role}\``)
.setDescription(`${config.name} has not been set up correctly. Could not find a 'support team' role with the id \`${config.staff_roles[0]}\``)
.setFooter(guild.name, guild.iconURL())
);
@ -34,7 +35,7 @@ module.exports = {
let user = message.mentions.users.first() || guild.members.cache.get(args[0]);
if(user) {
if(!message.member.roles.cache.has(config.staff_role))
if(!utils.isStaff(message.member))
return message.channel.send(
new MessageEmbed()
.setColor(config.err_colour)

View File

@ -10,6 +10,7 @@ const fs = require('fs');
const {
MessageEmbed
} = require('discord.js');
const utils = require('../modules/utils');
module.exports = {
name: 'transcript',
@ -41,7 +42,7 @@ module.exports = {
.setFooter(guild.name, guild.iconURL())
);
if (message.author.id !== ticket.creator && !message.member.roles.cache.has(config.staff_role))
if (message.author.id !== ticket.creator && !utils.isStaff(message.member))
return message.channel.send(
new MessageEmbed()
.setColor(config.err_colour)

View File

@ -34,13 +34,13 @@ module.exports = {
let channel = r.message.channel;
const supportRole = channel.guild.roles.cache.get(config.staff_role);
const supportRole = channel.guild.roles.cache.get(config.staff_roles[0]);
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_role}\``)
.setDescription(`${config.name} has not been set up correctly. Could not find a 'support team' role with the id \`${config.staff_roles[0]}\``)
.setFooter(channel.guild.name, channel.guild.iconURL())
);
@ -144,7 +144,7 @@ module.exports = {
let ping;
switch (config.tickets.ping) {
case 'staff':
ping = `<@&${config.staff_role}>,\n`;
ping = `<@&${config.staff_roles[0]}>,\n`;
break;
case false:
ping = '';

View File

@ -23,6 +23,7 @@ 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');

View File

@ -14,5 +14,16 @@ 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;
}
};

View File

@ -36,7 +36,7 @@ module.exports = {
cooldown: 3,
guild: '', // ID of your guild
staff_role: '', // ID of your Support Team role
staff_roles: [''], // ID of your Support Team role
tickets: {
category: '', // ID of your tickets category