diff --git a/src/commands/admin/greeting/farewell.js b/src/commands/admin/greeting/farewell.js index 6c3eada1d..8a91de47c 100644 --- a/src/commands/admin/greeting/farewell.js +++ b/src/commands/admin/greeting/farewell.js @@ -176,8 +176,8 @@ module.exports = class Farewell extends Command { // status if (type === "status") { - const status = args[1].toLowerCase(); - if (!status || !["on", "off"].includes(status)) return message.reply("Invalid status. Value must be `on/off`"); + const status = args[1]?.toUpperCase(); + if (!status || !["ON", "OFF"].includes(status)) return message.reply("Invalid status. Value must be `on/off`"); response = await setStatus(settings, status); } @@ -196,9 +196,9 @@ module.exports = class Farewell extends Command { // thumbnail if (type === "thumbnail") { - const status = args[1].toLowerCase(); - if (!status || !["on", "off"].includes(status)) return message.reply("Invalid status. Value must be `on/off`"); - response = await setThumbnail(message, status); + const status = args[1]?.toUpperCase(); + if (!status || !["ON", "OFF"].includes(status)) return message.reply("Invalid status. Value must be `on/off`"); + response = await setThumbnail(settings, status); } // color @@ -212,7 +212,7 @@ module.exports = class Farewell extends Command { if (type === "footer") { if (args.length < 2) return message.reply("Insufficient arguments! Please provide valid content"); const content = args.slice(1).join(" "); - response = await setFooter(message, content); + response = await setFooter(settings, content); } return message.reply(response); diff --git a/src/commands/admin/greeting/welcome.js b/src/commands/admin/greeting/welcome.js index 9332074b5..6059ab9a5 100644 --- a/src/commands/admin/greeting/welcome.js +++ b/src/commands/admin/greeting/welcome.js @@ -176,8 +176,8 @@ module.exports = class Welcome extends Command { // status if (type === "status") { - const status = args[1].toLowerCase(); - if (!status || !["on", "off"].includes(status)) return message.reply("Invalid status. Value must be `on/off`"); + const status = args[1]?.toUpperCase(); + if (!status || !["ON", "OFF"].includes(status)) return message.reply("Invalid status. Value must be `on/off`"); response = await setStatus(settings, status); } @@ -196,9 +196,9 @@ module.exports = class Welcome extends Command { // thumbnail if (type === "thumbnail") { - const status = args[1].toLowerCase(); - if (!status || !["on", "off"].includes(status)) return message.reply("Invalid status. Value must be `on/off`"); - response = await setThumbnail(message, status); + const status = args[1]?.toUpperCase(); + if (!status || !["ON", "OFF"].includes(status)) return message.reply("Invalid status. Value must be `on/off`"); + response = await setThumbnail(settings, status); } // color @@ -212,7 +212,7 @@ module.exports = class Welcome extends Command { if (type === "footer") { if (args.length < 2) return message.reply("Insufficient arguments! Please provide valid content"); const content = args.slice(1).join(" "); - response = await setFooter(message, content); + response = await setFooter(settings, content); } return message.reply(response); diff --git a/src/commands/admin/ticket/ticket.js b/src/commands/admin/ticket/ticket.js index b44df0c28..9dda5783a 100644 --- a/src/commands/admin/ticket/ticket.js +++ b/src/commands/admin/ticket/ticket.js @@ -195,6 +195,7 @@ module.exports = class Ticket extends Command { // Close ticket else if (input === "close") { response = await close(message, message.author); + if (!response) return; } // Close all tickets @@ -229,7 +230,7 @@ module.exports = class Ticket extends Command { return message.reply("Incorrect command usage"); } - await message.reply(response); + if (response) await message.reply(response); } /** @@ -296,7 +297,7 @@ module.exports = class Ticket extends Command { response = await removeFromTicket(interaction, user.id); } - await interaction.followUp(response); + if (response) await interaction.followUp(response); } }; @@ -411,10 +412,12 @@ async function setupLimit({ guild }, limit) { return `Configuration saved. You can now have a maximum of \`${limit}\` open tickets`; } -async function close({ channel, author }) { +async function close({ channel }, author) { if (!isTicketChannel(channel)) return "This command can only be used in ticket channels"; const status = await closeTicket(channel, author, "Closed by a moderator"); - if (!status.success) return status.message; + if (status === "MISSING_PERMISSIONS") return "I do not have permission to close tickets"; + if (status === "ERROR") return "An error occurred while closing the ticket"; + return null; } async function closeAll({ guild }) { diff --git a/src/commands/economy/bank.js b/src/commands/economy/bank.js index 243ee8a8a..388b33aa5 100644 --- a/src/commands/economy/bank.js +++ b/src/commands/economy/bank.js @@ -110,7 +110,8 @@ module.exports = class BankCommand extends Command { let response; if (sub === "balance") { - response = await balance(message.author); + const resolved = (await resolveMember(message, args[1])) || message.member; + response = await balance(resolved.user); } // diff --git a/src/commands/fun/flip.js b/src/commands/fun/flip.js index 1cb08b670..28705ef59 100644 --- a/src/commands/fun/flip.js +++ b/src/commands/fun/flip.js @@ -84,7 +84,7 @@ module.exports = class FlipCommand extends Command { } // else - await message.reply("Incorrect command usage"); + else await message.reply("Incorrect command usage"); } /** diff --git a/src/commands/utility/help.js b/src/commands/utility/help.js index 1b89c7bc6..1e1bb8395 100644 --- a/src/commands/utility/help.js +++ b/src/commands/utility/help.js @@ -10,7 +10,8 @@ const { } = require("discord.js"); const CMDS_PER_PAGE = 5; -const IDLE_TIMEOUT = 20; +const IDLE_TIMEOUT = 30; +const cache = {}; module.exports = class HelpCommand extends Command { constructor(client) { @@ -48,6 +49,9 @@ module.exports = class HelpCommand extends Command { // !help if (!trigger) { + if (cache[`${message.guildId}|${message.author.id}`]) { + return message.reply("You are already viewing the help menu."); + } const response = await getHelpMenu(message); const sentMsg = await message.reply(response); return waiter(sentMsg, message.author.id, prefix); @@ -58,7 +62,7 @@ module.exports = class HelpCommand extends Command { if (cmd) return cmd.sendUsage(message.channel, prefix, trigger); // No matching command/category found - message.reply("No matching command found"); + await message.reply("No matching command found"); } /** @@ -69,6 +73,9 @@ module.exports = class HelpCommand extends Command { // !help if (!cmdName) { + if (cache[`${interaction.guildId}|${interaction.user.id}`]) { + return interaction.followUp("You are already viewing the help menu."); + } const response = await getHelpMenu(interaction); const sentMsg = await interaction.followUp(response); return waiter(sentMsg, interaction.user.id); @@ -82,7 +89,7 @@ module.exports = class HelpCommand extends Command { } // No matching command/category found - return interaction.followUp("No matching command found"); + await interaction.followUp("No matching command found"); } }; @@ -140,10 +147,14 @@ async function getHelpMenu({ client, guild }) { * @param {string} prefix */ const waiter = (msg, userId, prefix) => { + // Add to cache + cache[`${msg.guildId}|${userId}`] = Date.now(); + const collector = msg.channel.createMessageComponentCollector({ filter: (reactor) => reactor.user.id === userId, idle: IDLE_TIMEOUT * 1000, dispose: true, + time: 5 * 60 * 1000, }); let arrEmbeds = []; @@ -181,6 +192,7 @@ const waiter = (msg, userId, prefix) => { }); collector.on("end", () => { + if (cache[`${msg.guildId}|${userId}`]) delete cache[`${msg.guildId}|${userId}`]; return msg.edit({ components: [] }); }); }; diff --git a/src/events/message/messageDelete.js b/src/events/message/messageDelete.js index 1f34de5b0..1078bd9b6 100644 --- a/src/events/message/messageDelete.js +++ b/src/events/message/messageDelete.js @@ -11,7 +11,7 @@ module.exports = async (client, message) => { if (message.author.bot || !message.guild) return; const settings = await getSettings(message.guild); - if (!settings.anti_ghostping || !settings.modlog_channel) return; + if (!settings.automod.anti_ghostping || !settings.modlog_channel) return; const { members, roles, everyone } = message.mentions; // Check message if it contains mentions @@ -26,9 +26,9 @@ module.exports = async (client, message) => { `**Author:** ${message.author.tag} \`${message.author.id}\`\n` + `**Channel:** ${message.channel.toString()}` ) - .addField("Members", members.size, true) - .addField("Roles", roles.size, true) - .addField("Everyone?", everyone, true) + .addField("Members", members.size.toString(), true) + .addField("Roles", roles.size.toString(), true) + .addField("Everyone?", everyone.toString(), true) .setFooter(`Sent at: ${message.createdAt}`); sendMessage(logChannel, { embeds: [embed] });