Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
saiteja-madha committed Nov 29, 2021
1 parent ec6607c commit 36daa7f
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 25 deletions.
12 changes: 6 additions & 6 deletions src/commands/admin/greeting/farewell.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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
Expand All @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions src/commands/admin/greeting/welcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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
Expand All @@ -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);
Expand Down
11 changes: 7 additions & 4 deletions src/commands/admin/ticket/ticket.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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);
}
};

Expand Down Expand Up @@ -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 }) {
Expand Down
3 changes: 2 additions & 1 deletion src/commands/economy/bank.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

//
Expand Down
2 changes: 1 addition & 1 deletion src/commands/fun/flip.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ module.exports = class FlipCommand extends Command {
}

// else
await message.reply("Incorrect command usage");
else await message.reply("Incorrect command usage");
}

/**
Expand Down
18 changes: 15 additions & 3 deletions src/commands/utility/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand All @@ -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");
}

/**
Expand All @@ -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);
Expand All @@ -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");
}
};

Expand Down Expand Up @@ -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 = [];
Expand Down Expand Up @@ -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: [] });
});
};
Expand Down
8 changes: 4 additions & 4 deletions src/events/message/messageDelete.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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] });
Expand Down

0 comments on commit 36daa7f

Please sign in to comment.