Better finds

This commit is contained in:
Noah committed 2021-11-21 18:42:18 -06:00
1 parent 02394e310d
commit 7eb949f109
7 files changed
+98 -126

No files matched your search

+12 -13
View File
@@ -32,19 +32,18 @@ module.exports = new Command({
permission: "SEND_MESSAGES", permission: "SEND_MESSAGES",
async run(interaction) { async run(interaction) {
let SupportStaff = let SupportStaff = interaction.guild.roles.cache.find(
interaction.guild.roles.cache.find( (SupportTeam) =>
(SupportTeam) => SupportTeam.name === supportbot.Staff SupportTeam.name == supportbot.Staff ||
) || SupportTeam.id == supportbot.Staff
interaction.guild.roles.cache.find( );
(SupportTeam) => SupportTeam.id === supportbot.Staff let Admins = interaction.guild.roles.cache.find(
); (AdminUser) =>
let Admins = AdminUser.name == supportbot.Admin || AdminUser.id == supportbot.Admin
interaction.guild.roles.cache.find( );
(AdminUser) => AdminUser.name === supportbot.Admin if (!SupportStaff || !Admins)
) || return interaction.reply(
interaction.guild.roles.cache.find( "Some roles seem to be missing!\nPlease check for errors when starting the bot."
(AdminUser) => AdminUser.id === supportbot.Admin
); );
const NoPerms = new Discord.MessageEmbed() const NoPerms = new Discord.MessageEmbed()
+10 -14
View File
@@ -63,13 +63,11 @@ module.exports = new Command({
} }
) )
.then((collected) => { .then((collected) => {
let logChannel = let logChannel = interaction.guild.channels.cache.find(
interaction.guild.channels.cache.find( (channel) =>
(channel) => channel.name === supportbot.TranscriptLog channel.name === supportbot.TranscriptLog ||
) || channel.id === supportbot.TranscriptLog
interaction.guild.channels.cache.find( );
(channel) => channel.id === supportbot.TranscriptLog
);
let user = interaction.user; let user = interaction.user;
let reason = let reason =
interaction.options.getString("reason") || interaction.options.getString("reason") ||
@@ -149,13 +147,11 @@ module.exports = new Command({
} }
if (!supportbot.CloseConfirmation) { if (!supportbot.CloseConfirmation) {
let logChannel = let logChannel = interaction.guild.channels.cache.find(
interaction.guild.channels.cache.find( (channel) =>
(channel) => channel.name === supportbot.TranscriptLog channel.name === supportbot.TranscriptLog ||
) || channel.id === supportbot.TranscriptLog
interaction.guild.channels.cache.find( );
(channel) => channel.id === supportbot.TranscriptLog
);
let user = interaction.user; let user = interaction.user;
let reason = let reason =
(await interaction.options.getString("reason")) || (await interaction.options.getString("reason")) ||
+13 -14
View File
@@ -31,21 +31,20 @@ module.exports = new Command({
permission: "SEND_MESSAGES", permission: "SEND_MESSAGES",
async run(interaction) { async run(interaction) {
let SupportStaff = let SupportStaff = interaction.guild.roles.cache.find(
interaction.guild.roles.cache.find( (SupportTeam) =>
(SupportTeam) => SupportTeam.name === supportbot.Staff SupportTeam.name === supportbot.Staff ||
) || SupportTeam.id === supportbot.Staff
interaction.guild.roles.cache.find( );
(SupportTeam) => SupportTeam.id === supportbot.Staff let Admins = interaction.guild.roles.cache.find(
); (AdminUser) =>
let Admins = AdminUser.name === supportbot.Admin || AdminUser.id === supportbot.Admin
interaction.guild.roles.cache.find( );
(AdminUser) => AdminUser.name === supportbot.Admin
) ||
interaction.guild.roles.cache.find(
(AdminUser) => 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() const NoPerms = new Discord.MessageEmbed()
.setTitle("Invalid Permissions!") .setTitle("Invalid Permissions!")
.setDescription( .setDescription(
+11 -14
View File
@@ -25,21 +25,18 @@ module.exports = new Command({
permission: "SEND_MESSAGES", permission: "SEND_MESSAGES",
async run(interaction) { async run(interaction) {
let SupportStaff = let SupportStaff = interaction.guild.roles.cache.find(
interaction.guild.roles.cache.find( (adminRole) =>
(adminRole) => adminRole.name === supportbot.Staff adminRole.name === supportbot.Staff || staffRole.id === supportbot.Staff
) || );
interaction.guild.roles.cache.find( let AdminStaff = interaction.guild.roles.cache.find(
(staffRole) => staffRole.id === supportbot.Staff (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 = ""; let botCommands = "";
botCommands += `**/${cmdconfig.HelpCommand}** ${cmdconfig.HelpCommandDesc}\n`; botCommands += `**/${cmdconfig.HelpCommand}** ${cmdconfig.HelpCommandDesc}\n`;
botCommands += `**/${cmdconfig.InfoCommand}** ${cmdconfig.InfoCommandDesc}\n`; botCommands += `**/${cmdconfig.InfoCommand}** ${cmdconfig.InfoCommandDesc}\n`;
+12 -13
View File
@@ -32,19 +32,18 @@ module.exports = new Command({
permission: "SEND_MESSAGES", permission: "SEND_MESSAGES",
async run(interaction) { async run(interaction) {
let SupportStaff = let SupportStaff = interaction.guild.roles.cache.find(
interaction.guild.roles.cache.find( (SupportTeam) =>
(SupportTeam) => SupportTeam.name === supportbot.Staff SupportTeam.name == supportbot.Staff ||
) || SupportTeam.id == supportbot.Staff
interaction.guild.roles.cache.find( );
(SupportTeam) => SupportTeam.id === supportbot.Staff let Admins = interaction.guild.roles.cache.find(
); (AdminUser) =>
let Admins = AdminUser.name == supportbot.Admin || AdminUser.id == supportbot.Admin
interaction.guild.roles.cache.find( );
(AdminUser) => AdminUser.name === supportbot.Admin if (!SupportStaff || !Admins)
) || return interaction.reply(
interaction.guild.roles.cache.find( "Some roles seem to be missing!\nPlease check for errors when starting the bot."
(AdminUser) => AdminUser.id === supportbot.Admin
); );
const NoPerms = new Discord.MessageEmbed() const NoPerms = new Discord.MessageEmbed()
+5 -7
View File
@@ -25,13 +25,11 @@ module.exports = new Command({
permission: "SEND_MESSAGES", permission: "SEND_MESSAGES",
async run(interaction) { async run(interaction) {
const suggestChannel = const suggestChannel = interaction.guild.channels.cache.find(
interaction.guild.channels.cache.find( (channel) =>
(channel) => channel.name === supportbot.SuggestionChannel channel.name === supportbot.SuggestionChannel ||
) || channel.id === supportbot.SuggestionChannel
interaction.guild.channels.cache.find( );
(channel) => channel.id === supportbot.SuggestionChannel
);
const NoChannel = new Discord.MessageEmbed() const NoChannel = new Discord.MessageEmbed()
.setTitle("Missing Channel!") .setTitle("Missing Channel!")
+35 -51
View File
@@ -36,10 +36,9 @@ module.exports = new Command({
if ( if (
reactionUser.roles.cache.find( reactionUser.roles.cache.find(
(role) => role.name === supportbot.TicketBlackListRole (role) =>
) || role.name == supportbot.TicketBlackListRole ||
reactionUser.roles.cache.find( role.id == supportbot.TicketBlackListRole
(role) => role.id === supportbot.TicketBlackListRole
) )
) { ) {
return interaction return interaction
@@ -70,46 +69,33 @@ module.exports = new Command({
) { ) {
return interaction.reply({ embeds: [TicketExists] }); return interaction.reply({ embeds: [TicketExists] });
} }
const Staff = const Staff = interaction.guild.roles.cache.find(
interaction.guild.roles.cache.find( (SupportTeam) =>
(SupportTeam) => SupportTeam.name === supportbot.Staff SupportTeam.name === supportbot.Staff ||
) || SupportTeam.id === supportbot.Staff
interaction.guild.roles.cache.find( );
(SupportTeam) => SupportTeam.id === supportbot.Staff const Admins = interaction.guild.roles.cache.find(
); (AdminUser) =>
const Admins = AdminUser.name === supportbot.Admin || AdminUser.id === supportbot.Admin
interaction.guild.roles.cache.find( );
(AdminUser) => AdminUser.name === supportbot.Admin const DeptRole1 = interaction.guild.roles.cache.find(
) || (DepartmentRole) =>
interaction.guild.roles.cache.find( DepartmentRole.name === supportbot.DepartmentRole_1 ||
(AdminUser) => AdminUser.id === supportbot.Admin DepartmentRole.id === supportbot.DepartmentRole_1
); );
const DeptRole1 = const DeptRole2 = interaction.guild.roles.cache.find(
interaction.guild.roles.cache.find( (DepartmentRole) =>
(DepartmentRole) => DepartmentRole.name === supportbot.DepartmentRole_2 ||
DepartmentRole.name === `${supportbot.DepartmentRole_1}` DepartmentRole.id === supportbot.DepartmentRole_2
) || );
interaction.guild.roles.cache.find( const DeptRole3 = interaction.guild.roles.cache.find(
(DepartmentRole) => (DepartmentRole) =>
DepartmentRole.id === `${supportbot.DepartmentRole_1}` DepartmentRole.name === supportbot.DepartmentRole_3 ||
); DepartmentRole.id === supportbot.DepartmentRole_3
const DeptRole2 = );
interaction.guild.roles.cache.find( if (!Staff || !Admins || !DeptRole1 || !DeptRole2 || !DeptRole3)
(DepartmentRole) => return interaction.reply(
DepartmentRole.name === `${supportbot.DepartmentRole_2}` "Some roles seem to be missing!\nPlease check for errors when starting the bot."
) ||
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 Author = interaction.user; const Author = interaction.user;
const Everyone = interaction.guild.id; const Everyone = interaction.guild.id;
@@ -158,13 +144,11 @@ module.exports = new Command({
ticketChannel.permissionOverwrites.create(index, { VIEW_CHANNEL: false }); ticketChannel.permissionOverwrites.create(index, { VIEW_CHANNEL: false });
}); });
let TicketCategory = let TicketCategory = interaction.guild.channels.cache.find(
interaction.guild.channels.cache.find( (category) =>
(category) => category.name === supportbot.TicketCategory category.name === supportbot.TicketCategory ||
) || category.id === supportbot.TicketCategory
interaction.guild.channels.cache.find( );
(category) => category.id === supportbot.TicketCategory
);
if (TicketCategory) { if (TicketCategory) {
ticketChannel.setParent(TicketCategory.id); ticketChannel.setParent(TicketCategory.id);
} }