diff --git a/Commands/add.js b/Commands/add.js index 5aee916..6fef2da 100644 --- a/Commands/add.js +++ b/Commands/add.js @@ -32,19 +32,18 @@ module.exports = new Command({ permission: "SEND_MESSAGES", async run(interaction) { - let SupportStaff = - interaction.guild.roles.cache.find( - (SupportTeam) => SupportTeam.name === supportbot.Staff - ) || - interaction.guild.roles.cache.find( - (SupportTeam) => SupportTeam.id === supportbot.Staff - ); - let Admins = - interaction.guild.roles.cache.find( - (AdminUser) => AdminUser.name === supportbot.Admin - ) || - interaction.guild.roles.cache.find( - (AdminUser) => AdminUser.id === supportbot.Admin + let SupportStaff = interaction.guild.roles.cache.find( + (SupportTeam) => + SupportTeam.name == supportbot.Staff || + SupportTeam.id == supportbot.Staff + ); + let Admins = interaction.guild.roles.cache.find( + (AdminUser) => + AdminUser.name == supportbot.Admin || AdminUser.id == supportbot.Admin + ); + if (!SupportStaff || !Admins) + return interaction.reply( + "Some roles seem to be missing!\nPlease check for errors when starting the bot." ); const NoPerms = new Discord.MessageEmbed() diff --git a/Commands/close.js b/Commands/close.js index 2a29c8a..5b8da65 100644 --- a/Commands/close.js +++ b/Commands/close.js @@ -63,13 +63,11 @@ module.exports = new Command({ } ) .then((collected) => { - let logChannel = - interaction.guild.channels.cache.find( - (channel) => channel.name === supportbot.TranscriptLog - ) || - interaction.guild.channels.cache.find( - (channel) => channel.id === supportbot.TranscriptLog - ); + let logChannel = interaction.guild.channels.cache.find( + (channel) => + channel.name === supportbot.TranscriptLog || + channel.id === supportbot.TranscriptLog + ); let user = interaction.user; let reason = interaction.options.getString("reason") || @@ -149,13 +147,11 @@ module.exports = new Command({ } if (!supportbot.CloseConfirmation) { - let logChannel = - interaction.guild.channels.cache.find( - (channel) => channel.name === supportbot.TranscriptLog - ) || - interaction.guild.channels.cache.find( - (channel) => channel.id === supportbot.TranscriptLog - ); + let logChannel = interaction.guild.channels.cache.find( + (channel) => + channel.name === supportbot.TranscriptLog || + channel.id === supportbot.TranscriptLog + ); let user = interaction.user; let reason = (await interaction.options.getString("reason")) || diff --git a/Commands/embed.js b/Commands/embed.js index 9bff3a8..278a777 100644 --- a/Commands/embed.js +++ b/Commands/embed.js @@ -31,21 +31,20 @@ module.exports = new Command({ permission: "SEND_MESSAGES", async run(interaction) { - let SupportStaff = - interaction.guild.roles.cache.find( - (SupportTeam) => SupportTeam.name === supportbot.Staff - ) || - interaction.guild.roles.cache.find( - (SupportTeam) => SupportTeam.id === supportbot.Staff - ); - let Admins = - interaction.guild.roles.cache.find( - (AdminUser) => AdminUser.name === supportbot.Admin - ) || - interaction.guild.roles.cache.find( - (AdminUser) => AdminUser.id === supportbot.Admin - ); + let SupportStaff = interaction.guild.roles.cache.find( + (SupportTeam) => + SupportTeam.name === supportbot.Staff || + SupportTeam.id === supportbot.Staff + ); + let Admins = interaction.guild.roles.cache.find( + (AdminUser) => + AdminUser.name === supportbot.Admin || AdminUser.id === supportbot.Admin + ); + if (!SupportStaff || !Admins) + return interaction.reply( + "Some roles seem to be missing!\nPlease check for errors when starting the bot." + ); const NoPerms = new Discord.MessageEmbed() .setTitle("Invalid Permissions!") .setDescription( diff --git a/Commands/help.js b/Commands/help.js index f6fc373..416bb68 100644 --- a/Commands/help.js +++ b/Commands/help.js @@ -25,21 +25,18 @@ module.exports = new Command({ permission: "SEND_MESSAGES", async run(interaction) { - let SupportStaff = - interaction.guild.roles.cache.find( - (adminRole) => adminRole.name === supportbot.Staff - ) || - interaction.guild.roles.cache.find( - (staffRole) => staffRole.id === supportbot.Staff + let SupportStaff = interaction.guild.roles.cache.find( + (adminRole) => + adminRole.name === supportbot.Staff || staffRole.id === supportbot.Staff + ); + let AdminStaff = interaction.guild.roles.cache.find( + (adminRole) => + adminRole.name === supportbot.Admin || adminRole.id === supportbot.Admin + ); + if (!SupportStaff || !Admins) + return interaction.reply( + "Some roles seem to be missing!\nPlease check for errors when starting the bot." ); - let AdminStaff = - interaction.guild.roles.cache.find( - (adminRole) => adminRole.name === supportbot.Admin - ) || - interaction.guild.roles.cache.find( - (adminRole) => adminRole.id === supportbot.Admin - ); - let botCommands = ""; botCommands += `**/${cmdconfig.HelpCommand}** ${cmdconfig.HelpCommandDesc}\n`; botCommands += `**/${cmdconfig.InfoCommand}** ${cmdconfig.InfoCommandDesc}\n`; diff --git a/Commands/remove.js b/Commands/remove.js index d062584..c90e0a1 100644 --- a/Commands/remove.js +++ b/Commands/remove.js @@ -32,19 +32,18 @@ module.exports = new Command({ permission: "SEND_MESSAGES", async run(interaction) { - let SupportStaff = - interaction.guild.roles.cache.find( - (SupportTeam) => SupportTeam.name === supportbot.Staff - ) || - interaction.guild.roles.cache.find( - (SupportTeam) => SupportTeam.id === supportbot.Staff - ); - let Admins = - interaction.guild.roles.cache.find( - (AdminUser) => AdminUser.name === supportbot.Admin - ) || - interaction.guild.roles.cache.find( - (AdminUser) => AdminUser.id === supportbot.Admin + let SupportStaff = interaction.guild.roles.cache.find( + (SupportTeam) => + SupportTeam.name == supportbot.Staff || + SupportTeam.id == supportbot.Staff + ); + let Admins = interaction.guild.roles.cache.find( + (AdminUser) => + AdminUser.name == supportbot.Admin || AdminUser.id == supportbot.Admin + ); + if (!SupportStaff || !Admins) + return interaction.reply( + "Some roles seem to be missing!\nPlease check for errors when starting the bot." ); const NoPerms = new Discord.MessageEmbed() diff --git a/Commands/suggest.js b/Commands/suggest.js index 99a99bc..f06db63 100644 --- a/Commands/suggest.js +++ b/Commands/suggest.js @@ -25,13 +25,11 @@ module.exports = new Command({ permission: "SEND_MESSAGES", async run(interaction) { - const suggestChannel = - interaction.guild.channels.cache.find( - (channel) => channel.name === supportbot.SuggestionChannel - ) || - interaction.guild.channels.cache.find( - (channel) => channel.id === supportbot.SuggestionChannel - ); + const suggestChannel = interaction.guild.channels.cache.find( + (channel) => + channel.name === supportbot.SuggestionChannel || + channel.id === supportbot.SuggestionChannel + ); const NoChannel = new Discord.MessageEmbed() .setTitle("Missing Channel!") diff --git a/Commands/ticket.js b/Commands/ticket.js index 27329fd..4c62663 100644 --- a/Commands/ticket.js +++ b/Commands/ticket.js @@ -36,10 +36,9 @@ module.exports = new Command({ if ( reactionUser.roles.cache.find( - (role) => role.name === supportbot.TicketBlackListRole - ) || - reactionUser.roles.cache.find( - (role) => role.id === supportbot.TicketBlackListRole + (role) => + role.name == supportbot.TicketBlackListRole || + role.id == supportbot.TicketBlackListRole ) ) { return interaction @@ -70,46 +69,33 @@ module.exports = new Command({ ) { return interaction.reply({ embeds: [TicketExists] }); } - const Staff = - interaction.guild.roles.cache.find( - (SupportTeam) => SupportTeam.name === supportbot.Staff - ) || - interaction.guild.roles.cache.find( - (SupportTeam) => SupportTeam.id === supportbot.Staff - ); - const Admins = - interaction.guild.roles.cache.find( - (AdminUser) => AdminUser.name === supportbot.Admin - ) || - interaction.guild.roles.cache.find( - (AdminUser) => AdminUser.id === supportbot.Admin - ); - const DeptRole1 = - interaction.guild.roles.cache.find( - (DepartmentRole) => - DepartmentRole.name === `${supportbot.DepartmentRole_1}` - ) || - interaction.guild.roles.cache.find( - (DepartmentRole) => - DepartmentRole.id === `${supportbot.DepartmentRole_1}` - ); - const DeptRole2 = - interaction.guild.roles.cache.find( - (DepartmentRole) => - DepartmentRole.name === `${supportbot.DepartmentRole_2}` - ) || - interaction.guild.roles.cache.find( - (DepartmentRole) => - DepartmentRole.id === `${supportbot.DepartmentRole_2}` - ); - const DeptRole3 = - interaction.guild.roles.cache.find( - (DepartmentRole) => - DepartmentRole.name === `${supportbot.DepartmentRole_3}` - ) || - interaction.guild.roles.cache.find( - (DepartmentRole) => - DepartmentRole.id === `${supportbot.DepartmentRole_3}` + const Staff = interaction.guild.roles.cache.find( + (SupportTeam) => + SupportTeam.name === supportbot.Staff || + SupportTeam.id === supportbot.Staff + ); + const Admins = interaction.guild.roles.cache.find( + (AdminUser) => + AdminUser.name === supportbot.Admin || AdminUser.id === supportbot.Admin + ); + const DeptRole1 = interaction.guild.roles.cache.find( + (DepartmentRole) => + DepartmentRole.name === supportbot.DepartmentRole_1 || + DepartmentRole.id === supportbot.DepartmentRole_1 + ); + const DeptRole2 = interaction.guild.roles.cache.find( + (DepartmentRole) => + DepartmentRole.name === supportbot.DepartmentRole_2 || + DepartmentRole.id === supportbot.DepartmentRole_2 + ); + const DeptRole3 = interaction.guild.roles.cache.find( + (DepartmentRole) => + DepartmentRole.name === supportbot.DepartmentRole_3 || + DepartmentRole.id === supportbot.DepartmentRole_3 + ); + if (!Staff || !Admins || !DeptRole1 || !DeptRole2 || !DeptRole3) + return interaction.reply( + "Some roles seem to be missing!\nPlease check for errors when starting the bot." ); const Author = interaction.user; const Everyone = interaction.guild.id; @@ -158,13 +144,11 @@ module.exports = new Command({ ticketChannel.permissionOverwrites.create(index, { VIEW_CHANNEL: false }); }); - let TicketCategory = - interaction.guild.channels.cache.find( - (category) => category.name === supportbot.TicketCategory - ) || - interaction.guild.channels.cache.find( - (category) => category.id === supportbot.TicketCategory - ); + let TicketCategory = interaction.guild.channels.cache.find( + (category) => + category.name === supportbot.TicketCategory || + category.id === supportbot.TicketCategory + ); if (TicketCategory) { ticketChannel.setParent(TicketCategory.id); }