From e2be29159e51fd3831adc153db4f32adbd86f540 Mon Sep 17 00:00:00 2001 From: Sai Teja Madha <42540377+saiteja-madha@users.noreply.github.com> Date: Fri, 3 Dec 2021 21:25:29 +0530 Subject: [PATCH 01/14] Fixes #57 --- src/structures/Command.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/structures/Command.js b/src/structures/Command.js index 3ec6e0f90..76d321334 100644 --- a/src/structures/Command.js +++ b/src/structures/Command.js @@ -158,7 +158,7 @@ class Command { try { await this.messageRun(message, args, invoke, prefix); } catch (ex) { - await message.reply("Oops! An error occurred while running the command"); + await message.channel.send("Oops! An error occurred while running the command"); this.client.logger.error("messageRun", ex); } finally { this.applyCooldown(message.author.id); From c4f163ae455228b2bb2d7409ad0257618a526d2c Mon Sep 17 00:00:00 2001 From: Sai Teja Madha <42540377+saiteja-madha@users.noreply.github.com> Date: Fri, 3 Dec 2021 22:27:10 +0530 Subject: [PATCH 02/14] Fix #58 --- src/commands/admin/ticket/ticket.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/admin/ticket/ticket.js b/src/commands/admin/ticket/ticket.js index 9dda5783a..6e5ea3296 100644 --- a/src/commands/admin/ticket/ticket.js +++ b/src/commands/admin/ticket/ticket.js @@ -181,7 +181,7 @@ module.exports = class Ticket extends Command { if (args.length < 2) return message.reply("Please provide a channel where ticket logs must be sent"); const target = getMatchingChannel(message.guild, args[1]); if (target.length === 0) return message.reply("Could not find any matching channel"); - response = await setupLogChannel(message, target); + response = await setupLogChannel(message, target[0]); } // Set limit From 290b72f58f4d51d3199ed3821e4013388bffffa6 Mon Sep 17 00:00:00 2001 From: Sai Teja Madha <42540377+saiteja-madha@users.noreply.github.com> Date: Tue, 7 Dec 2021 22:38:19 +0530 Subject: [PATCH 03/14] Possibly fixes #59 --- src/events/guild/guildDelete.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/events/guild/guildDelete.js b/src/events/guild/guildDelete.js index 53620cdce..dc51c57cf 100644 --- a/src/events/guild/guildDelete.js +++ b/src/events/guild/guildDelete.js @@ -6,7 +6,6 @@ const { getSettings } = require("@schemas/Guild"); * @param {import('discord.js').Guild} guild */ module.exports = async (client, guild) => { - if (!guild.members.cache.has(guild.ownerId)) await guild.fetchOwner({ cache: true }); client.logger.log(`Guild Left: ${guild.name} Members: ${guild.memberCount}`); const settings = await getSettings(guild); @@ -15,13 +14,14 @@ module.exports = async (client, guild) => { if (!client.joinLeaveWebhook) return; + const owner = await client.users.fetch(guild.ownerId); const embed = new MessageEmbed() .setTitle("Guild Left") .setThumbnail(guild.iconURL()) .setColor(client.config.EMBED_COLORS.ERROR) .addField("Name", guild.name, false) .addField("ID", guild.id, false) - .addField("Owner", `${client.users.cache.get(guild.ownerId).tag} [\`${guild.ownerId}\`]`, false) + .addField("Owner", `${owner.username}#${owner.discriminator} [\`${owner.id}\`]`, false) .addField("Members", `\`\`\`yaml\n${guild.memberCount}\`\`\``, false) .setFooter(`Guild #${client.guilds.cache.size}`); From 7798aca19b48bc91f843e7b34241bec592d01687 Mon Sep 17 00:00:00 2001 From: Sai Teja Madha <42540377+saiteja-madha@users.noreply.github.com> Date: Tue, 7 Dec 2021 22:42:38 +0530 Subject: [PATCH 04/14] Fixes #62 --- src/utils/botUtils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/botUtils.js b/src/utils/botUtils.js index 7cfe93c77..6da91656f 100644 --- a/src/utils/botUtils.js +++ b/src/utils/botUtils.js @@ -75,7 +75,7 @@ async function sendMessage(channel, content, seconds) { if (content.embeds && content.embeds.length > 0) perms.push("EMBED_LINKS"); if (channel.type !== "DM" && !channel.permissionsFor(channel.guild.me).has(perms)) return; try { - if (!seconds) return channel.send(content); + if (!seconds) return await channel.send(content); const reply = await channel.send(content); setTimeout(() => reply.deletable && reply.delete().catch((ex) => {}), seconds * 1000); } catch (ex) { @@ -92,7 +92,7 @@ async function safeDM(user, message, seconds) { if (!user || !message) return; try { const dm = await user.createDM(); - if (!seconds) return dm.send(message); + if (!seconds) return await dm.send(message); const reply = await dm.send(message); setTimeout(() => reply.deletable && reply.delete().catch((ex) => {}), seconds * 1000); } catch (ex) { From fa502cdab5b0c4aeccd448872e6f3857db5aaba6 Mon Sep 17 00:00:00 2001 From: Sai Teja Madha <42540377+saiteja-madha@users.noreply.github.com> Date: Tue, 7 Dec 2021 23:00:50 +0530 Subject: [PATCH 05/14] fixes #60 --- src/events/voice/voiceStateUpdate.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/events/voice/voiceStateUpdate.js b/src/events/voice/voiceStateUpdate.js index 3b9b0c7f1..eb2263c0a 100644 --- a/src/events/voice/voiceStateUpdate.js +++ b/src/events/voice/voiceStateUpdate.js @@ -10,12 +10,12 @@ module.exports = async (client, oldState, newState) => { if (oldState.channelId !== guild.me.voice.channelId || newState.channel) return; // otherwise, check how many people are in the channel now - if (!oldState.channel.members.size - 1) { + if (oldState.channel.members.size === 1) { setTimeout(() => { // if 1 (you), wait 1 minute if (!oldState.channel.members.size - 1) // if there's still 1 member, client.musicManager.get(guild.id) && client.musicManager.get(guild.id).destroy(); - }, 1 * 60 * 1000); // (check and disconnect after 1 min) + }, 0.2 * 60 * 1000); // (check and disconnect after 1 min) } }; From f2cbb0f9914914e2c153d95eae7721c58180854a Mon Sep 17 00:00:00 2001 From: Sai Teja Madha <42540377+saiteja-madha@users.noreply.github.com> Date: Tue, 7 Dec 2021 23:02:56 +0530 Subject: [PATCH 06/14] configurable idle time --- src/events/voice/voiceStateUpdate.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/events/voice/voiceStateUpdate.js b/src/events/voice/voiceStateUpdate.js index eb2263c0a..a47600849 100644 --- a/src/events/voice/voiceStateUpdate.js +++ b/src/events/voice/voiceStateUpdate.js @@ -1,3 +1,5 @@ +const { MUSIC } = require("@root/config"); + /** * @param {import('@src/structures').BotClient} client * @param {import('discord.js').VoiceState} oldState @@ -16,6 +18,6 @@ module.exports = async (client, oldState, newState) => { if (!oldState.channel.members.size - 1) // if there's still 1 member, client.musicManager.get(guild.id) && client.musicManager.get(guild.id).destroy(); - }, 0.2 * 60 * 1000); // (check and disconnect after 1 min) + }, MUSIC.IDLE_TIME * 1000); } }; From 43af709a5d2e8dc45e7b060425d0f458c5eedef6 Mon Sep 17 00:00:00 2001 From: Sai Teja Madha <42540377+saiteja-madha@users.noreply.github.com> Date: Tue, 7 Dec 2021 23:23:53 +0530 Subject: [PATCH 07/14] Fixes #63 --- src/commands/utility/help.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/commands/utility/help.js b/src/commands/utility/help.js index 1e1bb8395..8b3afd689 100644 --- a/src/commands/utility/help.js +++ b/src/commands/utility/help.js @@ -171,21 +171,21 @@ const waiter = (msg, userId, prefix) => { arrEmbeds = prefix ? getMsgCategoryEmbeds(msg.client, cat, prefix) : getSlashCategoryEmbeds(msg.client, cat); currentPage = 0; buttonsRow.components.forEach((button) => button.setDisabled(arrEmbeds.length > 1 ? false : true)); - await msg.edit({ embeds: [arrEmbeds[currentPage]], components: [menuRow, buttonsRow] }); + msg.editable && (await msg.edit({ embeds: [arrEmbeds[currentPage]], components: [menuRow, buttonsRow] })); break; } case "previousBtn": if (currentPage !== 0) { --currentPage; - await msg.edit({ embeds: [arrEmbeds[currentPage]], components: [menuRow, buttonsRow] }); + msg.editable && (await msg.edit({ embeds: [arrEmbeds[currentPage]], components: [menuRow, buttonsRow] })); } break; case "nextBtn": if (currentPage < arrEmbeds.length - 1) { currentPage++; - await msg.edit({ embeds: [arrEmbeds[currentPage]], components: [menuRow, buttonsRow] }); + msg.editable && (await msg.edit({ embeds: [arrEmbeds[currentPage]], components: [menuRow, buttonsRow] })); } break; } @@ -193,7 +193,7 @@ const waiter = (msg, userId, prefix) => { collector.on("end", () => { if (cache[`${msg.guildId}|${userId}`]) delete cache[`${msg.guildId}|${userId}`]; - return msg.edit({ components: [] }); + return msg.editable && msg.edit({ components: [] }); }); }; From d3de1e53ab66b17d49bd38308efd70b2ca58297f Mon Sep 17 00:00:00 2001 From: Sai Teja Madha <42540377+saiteja-madha@users.noreply.github.com> Date: Tue, 7 Dec 2021 23:34:24 +0530 Subject: [PATCH 08/14] fixes #64 --- src/helpers/logger.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/helpers/logger.js b/src/helpers/logger.js index 57355111e..4cb017531 100644 --- a/src/helpers/logger.js +++ b/src/helpers/logger.js @@ -15,10 +15,13 @@ simpleLogger.setLevel("debug"); const errorWebhook = process.env.ERROR_LOGS ? new WebhookClient({ url: process.env.ERROR_LOGS }) : undefined; const sendWebhook = (content, err) => { + if (!content && !err) return; + const errString = err?.stack || err; + const embed = new MessageEmbed() .setColor(config.EMBED_COLORS.ERROR) .setAuthor(err?.name || "Error") - .setDescription("```js\n" + err?.stack || err + "```"); + .setDescription("```js\n" + (errString.length > 4096 ? `${errString.substr(0, 4000)}...` : errString) + "\n```"); if (err?.description) embed.addField("Description", content); if (err?.message) embed.addField("Message", err?.message); From 3f3424c523cfe4694081e7002c9f5f7e25b66a13 Mon Sep 17 00:00:00 2001 From: Sai Teja Madha <42540377+saiteja-madha@users.noreply.github.com> Date: Wed, 8 Dec 2021 11:38:26 +0530 Subject: [PATCH 09/14] Fix #65 --- src/events/ready.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/events/ready.js b/src/events/ready.js index 282647f82..ff62f3951 100644 --- a/src/events/ready.js +++ b/src/events/ready.js @@ -1,6 +1,7 @@ const { counterHandler, inviteHandler } = require("@src/handlers"); const { cacheReactionRoles } = require("@schemas/Message"); const { getSettings } = require("@schemas/Guild"); +const { updateCounterChannels } = require("@src/handlers/counter"); /** * @param {import('@src/structures').BotClient} client @@ -38,6 +39,8 @@ module.exports = async (client) => { inviteHandler.cacheGuildInvites(guild); } } + + setInterval(() => updateCounterChannels(client), 10 * 60 * 1000); }; /** From efda693de407fb2794f4508fbebace1d6abc3181 Mon Sep 17 00:00:00 2001 From: Sai Teja Madha <42540377+saiteja-madha@users.noreply.github.com> Date: Wed, 8 Dec 2021 11:52:53 +0530 Subject: [PATCH 10/14] permissions null check --- dashboard/utils.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dashboard/utils.js b/dashboard/utils.js index 09371f21f..926b72cae 100644 --- a/dashboard/utils.js +++ b/dashboard/utils.js @@ -11,9 +11,9 @@ async function fetchGuild(guildID, client, guilds) { async function fetchUser(userData, client, query) { if (userData.guilds) { userData.guilds.forEach((guild) => { - const perms = new Discord.Permissions(BigInt(guild.permissions)); - if (perms.has("MANAGE_GUILD")) { - guild.admin = true; + if (guild.permissions) { + const perms = new Discord.Permissions(BigInt(guild.permissions)); + if (perms.has("MANAGE_GUILD")) guild.admin = true; } guild.settingsUrl = client.guilds.cache.get(guild.id) ? `/manage/${guild.id}/` From 64b1cd05472a81128421bd536389d0c82bd05195 Mon Sep 17 00:00:00 2001 From: Sai Teja Madha <42540377+saiteja-madha@users.noreply.github.com> Date: Wed, 8 Dec 2021 13:22:35 +0530 Subject: [PATCH 11/14] fixes #66 --- src/commands/admin/greeting/farewell.js | 3 --- src/commands/admin/greeting/welcome.js | 3 --- 2 files changed, 6 deletions(-) diff --git a/src/commands/admin/greeting/farewell.js b/src/commands/admin/greeting/farewell.js index 8a91de47c..3d771aae4 100644 --- a/src/commands/admin/greeting/farewell.js +++ b/src/commands/admin/greeting/farewell.js @@ -303,10 +303,7 @@ async function setDescription(settings, desc) { async function setThumbnail(settings, status) { settings.farewell.embed.thumbnail = status.toUpperCase() === "ON" ? true : false; - - settings.farewell.embed.thumbnail = null; await settings.save(); - return "Configuration saved! Farewell message updated"; } diff --git a/src/commands/admin/greeting/welcome.js b/src/commands/admin/greeting/welcome.js index 6059ab9a5..b8c8f8d0c 100644 --- a/src/commands/admin/greeting/welcome.js +++ b/src/commands/admin/greeting/welcome.js @@ -303,10 +303,7 @@ async function setDescription(settings, desc) { async function setThumbnail(settings, status) { settings.welcome.embed.thumbnail = status.toUpperCase() === "ON" ? true : false; - - settings.welcome.embed.thumbnail = null; await settings.save(); - return "Configuration saved! Welcome message updated"; } From 9751d5f0ffea947efded420ced2d7fe0c59662bd Mon Sep 17 00:00:00 2001 From: Sai Teja Madha <42540377+saiteja-madha@users.noreply.github.com> Date: Wed, 8 Dec 2021 14:23:14 +0530 Subject: [PATCH 12/14] Fix #67 --- src/commands/fun/facts.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/commands/fun/facts.js b/src/commands/fun/facts.js index 8a29644ae..1cee7933c 100644 --- a/src/commands/fun/facts.js +++ b/src/commands/fun/facts.js @@ -17,6 +17,7 @@ module.exports = class FactCommand extends Command { command: { enabled: true, usage: "", + aliases: ["fact"], minArgsCount: 1, }, slashCommand: { @@ -61,10 +62,12 @@ async function getFact(user, choice) { const response = await getJson(`${BASE_URL}/${choice}`); if (!response.success) return MESSAGES.API_ERROR; - const imageUrl = response.data?.fact; + const fact = response.data?.fact; + const imageUrl = response.data?.image; const embed = new MessageEmbed() .setColor(EMBED_COLORS.TRANSPARENT) - .setImage(imageUrl) + .setThumbnail(imageUrl) + .setDescription(fact) .setFooter(`Requested by ${user.tag}`); return { embeds: [embed] }; From b29560b9883d9f4d06d8d64eaaa4d593b9f0bb48 Mon Sep 17 00:00:00 2001 From: Sai Teja Madha <42540377+saiteja-madha@users.noreply.github.com> Date: Wed, 8 Dec 2021 14:24:23 +0530 Subject: [PATCH 13/14] Incorrect category --- src/commands/information/ping.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/information/ping.js b/src/commands/information/ping.js index 9b29fe19a..05d1bc389 100644 --- a/src/commands/information/ping.js +++ b/src/commands/information/ping.js @@ -6,9 +6,9 @@ module.exports = class PingCommand extends Command { super(client, { name: "ping", description: "shows the current ping from the bot to the discord servers", + category: "INFORMATION", command: { enabled: true, - category: "INFORMATION", }, slashCommand: { enabled: true, From a2b98c8bf1324f052c9a8e4f1ba95e1f2a6ae860 Mon Sep 17 00:00:00 2001 From: Sai Teja Madha <42540377+saiteja-madha@users.noreply.github.com> Date: Wed, 8 Dec 2021 23:03:09 +0530 Subject: [PATCH 14/14] missing idle time --- config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/config.js b/config.js index 13b7925e5..6c319b1d2 100644 --- a/config.js +++ b/config.js @@ -29,6 +29,7 @@ module.exports = { BASE_API: "https://image-api.strangebot.xyz", }, MUSIC: { + IDLE_TIME: 60, // Time in seconds before the bot disconnects from the voice channel MAX_SEARCH_RESULTS: 5, NODES: [ {