From a2e5f1545ad7d7c15256783adeb5e6edd54f6b4d Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sun, 17 Apr 2022 23:05:13 +0200 Subject: [PATCH 001/142] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20remove=20shop=20ro?= =?UTF-8?q?les=20if=20rMember=20or=20rRole=20not=20found?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/schedules/jobs/shopRoles.ts | 51 ++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/src/schedules/jobs/shopRoles.ts b/src/schedules/jobs/shopRoles.ts index 877e3f1..fae3889 100644 --- a/src/schedules/jobs/shopRoles.ts +++ b/src/schedules/jobs/shopRoles.ts @@ -57,11 +57,45 @@ export default async (client: Client) => { if (!rRole) { logger.error(`Role ${roleId} not found for shop role ${roleId}.`); + await shopRoleSchema + .deleteOne({ + userId, + roleId, + guildId, + }) + .then(async () => { + logger.verbose( + `Shop role document ${roleId} has been deleted from user ${userId}.` + ); + }) + .catch(async (error) => { + logger.error( + `Error deleting shop role document ${roleId} from user ${userId}.`, + error + ); + }); return; } if (!rMember) { logger.error(`Member ${userId} not found for shop role ${roleId}.`); + await shopRoleSchema + .deleteOne({ + userId, + roleId, + guildId, + }) + .then(async () => { + logger.verbose( + `Shop role document ${roleId} has been deleted from user ${userId}.` + ); + }) + .catch(async (error) => { + logger.error( + `Error deleting shop role document ${roleId} from user ${userId}.`, + error + ); + }); return; } @@ -79,23 +113,6 @@ export default async (client: Client) => { if (!rMember) { logger.error(`Member ${userId} not found for shop role ${roleId}.`); - await shopRoleSchema - .deleteOne({ - userId, - roleId, - guildId, - }) - .then(async () => { - logger.verbose( - `Shop role document ${roleId} has been deleted from user ${userId}.` - ); - }) - .catch(async (error) => { - logger.error( - `Error deleting shop role document ${roleId} from user ${userId}.`, - error - ); - }); return; } From acaf0b4dcb77034e78747f772ff78676ea4c37ec Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sun, 17 Apr 2022 23:12:14 +0200 Subject: [PATCH 002/142] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20fix=20code=20smell?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/events/guildMemberAdd/audits.ts | 49 +++++++++++++--------- src/events/guildMemberRemove/audits.ts | 43 ++++++++++++------- src/events/interactionCreate/audits.ts | 43 ++++++++++++------- src/events/messageDelete/audits.ts | 47 +++++++++++++-------- src/events/messageUpdate/audits.ts | 47 +++++++++++++-------- src/plugins/settings/guild/modules/shop.ts | 1 - src/schedules/jobs/shopRoles.ts | 24 +---------- 7 files changed, 143 insertions(+), 111 deletions(-) diff --git a/src/events/guildMemberAdd/audits.ts b/src/events/guildMemberAdd/audits.ts index 6d76893..af99a77 100644 --- a/src/events/guildMemberAdd/audits.ts +++ b/src/events/guildMemberAdd/audits.ts @@ -20,24 +20,35 @@ export default { if (channel === null) return; - (channel as TextChannel).send({ - embeds: [ - new MessageEmbed() - .setColor(successColor) - .setAuthor({ - name: "Member Joined", - iconURL: member.user.displayAvatarURL(), - }) - .setDescription(`${member.user} ${member.user.tag}`) - .addFields([ - { name: "Account Age", value: `${member.user.createdAt}` }, - ]) - .setTimestamp() - .setFooter({ - text: footerText, - iconURL: footerIcon, - }), - ], - }); + (channel as TextChannel) + .send({ + embeds: [ + new MessageEmbed() + .setColor(successColor) + .setAuthor({ + name: "Member Joined", + iconURL: member.user.displayAvatarURL(), + }) + .setDescription(`${member.user} ${member.user.tag}`) + .addFields([ + { name: "Account Age", value: `${member.user.createdAt}` }, + ]) + .setTimestamp() + .setFooter({ + text: footerText, + iconURL: footerIcon, + }), + ], + }) + .then(async () => { + logger.info( + `Audit log sent for event guildMemberAdd in guild ${member.guild.name} (${member.guild.id})` + ); + }) + .catch(async () => { + logger.error( + `Audit log failed to send for event guildMemberAdd in guild ${member.guild.name} (${member.guild.id})` + ); + }); }, }; diff --git a/src/events/guildMemberRemove/audits.ts b/src/events/guildMemberRemove/audits.ts index e096814..3bbd8aa 100644 --- a/src/events/guildMemberRemove/audits.ts +++ b/src/events/guildMemberRemove/audits.ts @@ -20,21 +20,32 @@ export default { if (channel === null) return; - (channel as TextChannel).send({ - embeds: [ - new MessageEmbed() - .setColor(errorColor) - .setAuthor({ - name: "Member Left", - iconURL: member.user.displayAvatarURL(), - }) - .setDescription(`${member.user} ${member.user.tag}`) - .setTimestamp() - .setFooter({ - text: footerText, - iconURL: footerIcon, - }), - ], - }); + (channel as TextChannel) + .send({ + embeds: [ + new MessageEmbed() + .setColor(errorColor) + .setAuthor({ + name: "Member Left", + iconURL: member.user.displayAvatarURL(), + }) + .setDescription(`${member.user} ${member.user.tag}`) + .setTimestamp() + .setFooter({ + text: footerText, + iconURL: footerIcon, + }), + ], + }) + .then(async () => { + logger.info( + `Audit log sent for event guildMemberRemove in guild ${member.guild.name} (${member.guild.id})` + ); + }) + .catch(async () => { + logger.error( + `Audit log failed to send for event guildMemberRemove in guild ${member.guild.name} (${member.guild.id})` + ); + }); }, }; diff --git a/src/events/interactionCreate/audits.ts b/src/events/interactionCreate/audits.ts index 5fe29e6..d91348e 100644 --- a/src/events/interactionCreate/audits.ts +++ b/src/events/interactionCreate/audits.ts @@ -26,23 +26,34 @@ export default { if (channel === null) return; - (channel as TextChannel).send({ - embeds: [ - new MessageEmbed() - .setColor(successColor) - .setDescription( - ` + (channel as TextChannel) + .send({ + embeds: [ + new MessageEmbed() + .setColor(successColor) + .setDescription( + ` **Interaction created by** ${interaction.user.username} **in** ${interaction.channel} ` - ) - .setThumbnail(interaction.user.displayAvatarURL()) - .addFields([{ name: "Event", value: "interactionCreate" }]) - .setTimestamp() - .setFooter({ - text: footerText, - iconURL: footerIcon, - }), - ], - }); + ) + .setThumbnail(interaction.user.displayAvatarURL()) + .addFields([{ name: "Event", value: "interactionCreate" }]) + .setTimestamp() + .setFooter({ + text: footerText, + iconURL: footerIcon, + }), + ], + }) + .then(async () => { + logger.info( + `Audit log sent for event interactionCreate in guild ${interaction?.guild?.name} (${interaction?.guild?.id})` + ); + }) + .catch(async () => { + logger.error( + `Audit log failed to send for event interactionCreate in guild ${interaction?.guild?.name} (${interaction?.guild?.id})` + ); + }); }, }; diff --git a/src/events/messageDelete/audits.ts b/src/events/messageDelete/audits.ts index f7f0ed1..d35cf37 100644 --- a/src/events/messageDelete/audits.ts +++ b/src/events/messageDelete/audits.ts @@ -26,26 +26,37 @@ export default { if (channel === null) return; - (channel as TextChannel).send({ - embeds: [ - new MessageEmbed() - .setColor(successColor) - .setAuthor({ - name: message.author.username, - iconURL: message.author.displayAvatarURL(), - }) - .setDescription( - ` + (channel as TextChannel) + .send({ + embeds: [ + new MessageEmbed() + .setColor(successColor) + .setAuthor({ + name: message.author.username, + iconURL: message.author.displayAvatarURL(), + }) + .setDescription( + ` **Message sent by** ${message.author} **deleted in** ${message.channel} ${message.content} ` - ) - .setTimestamp() - .setFooter({ - text: footerText, - iconURL: footerIcon, - }), - ], - }); + ) + .setTimestamp() + .setFooter({ + text: footerText, + iconURL: footerIcon, + }), + ], + }) + .then(async () => { + logger.info( + `Audit log sent for event messageDelete in guild ${message?.guild?.name} (${message?.guild?.id})` + ); + }) + .catch(async () => { + logger.error( + `Audit log failed to send for event messageDelete in guild ${message?.guild?.name} (${message?.guild?.id})` + ); + }); }, }; diff --git a/src/events/messageUpdate/audits.ts b/src/events/messageUpdate/audits.ts index 50c76b5..b7f2726 100644 --- a/src/events/messageUpdate/audits.ts +++ b/src/events/messageUpdate/audits.ts @@ -29,25 +29,36 @@ export default { if (channel === null) return; - (channel as TextChannel).send({ - embeds: [ - new MessageEmbed() - .setColor(successColor) - .setAuthor({ - name: newMessage.author.username, - iconURL: newMessage.author.displayAvatarURL(), - }) - .setDescription( - ` + (channel as TextChannel) + .send({ + embeds: [ + new MessageEmbed() + .setColor(successColor) + .setAuthor({ + name: newMessage.author.username, + iconURL: newMessage.author.displayAvatarURL(), + }) + .setDescription( + ` **Message edited in** ${newMessage.channel} [jump to message](https://discord.com/channels/${newMessage.guild.id}/${newMessage.channel.id}/${newMessage.id}) ` - ) - .setTimestamp() - .setFooter({ - text: footerText, - iconURL: footerIcon, - }), - ], - }); + ) + .setTimestamp() + .setFooter({ + text: footerText, + iconURL: footerIcon, + }), + ], + }) + .then(async () => { + logger.info( + `Audit log sent for event messageUpdate in guild ${newMessage?.guild?.name} (${newMessage?.guild?.id})` + ); + }) + .catch(async () => { + logger.error( + `Audit log failed to send for event messageUpdate in guild ${newMessage?.guild?.name} (${newMessage?.guild?.id})` + ); + }); }, }; diff --git a/src/plugins/settings/guild/modules/shop.ts b/src/plugins/settings/guild/modules/shop.ts index 5c633a0..2b20d87 100644 --- a/src/plugins/settings/guild/modules/shop.ts +++ b/src/plugins/settings/guild/modules/shop.ts @@ -10,7 +10,6 @@ import logger from "@logger"; // Models import guildSchema from "@schemas/guild"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; -import { ChannelType } from "discord-api-types/v10"; // Function export default { diff --git a/src/schedules/jobs/shopRoles.ts b/src/schedules/jobs/shopRoles.ts index fae3889..be1767b 100644 --- a/src/schedules/jobs/shopRoles.ts +++ b/src/schedules/jobs/shopRoles.ts @@ -55,29 +55,7 @@ export default async (client: Client) => { const rRole = rMember.roles.cache.get(roleId); - if (!rRole) { - logger.error(`Role ${roleId} not found for shop role ${roleId}.`); - await shopRoleSchema - .deleteOne({ - userId, - roleId, - guildId, - }) - .then(async () => { - logger.verbose( - `Shop role document ${roleId} has been deleted from user ${userId}.` - ); - }) - .catch(async (error) => { - logger.error( - `Error deleting shop role document ${roleId} from user ${userId}.`, - error - ); - }); - return; - } - - if (!rMember) { + if (!rMember || !rRole) { logger.error(`Member ${userId} not found for shop role ${roleId}.`); await shopRoleSchema .deleteOne({ From 055e2a5d88a05b149cdcea8ef8c5313281365f3f Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Mon, 18 Apr 2022 13:06:14 +0200 Subject: [PATCH 003/142] =?UTF-8?q?=F0=9F=9A=B8=20set=20shop=20role=20opti?= =?UTF-8?q?ons=20required?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/locale/index.ts | 120 ++--------------------- src/plugins/shop/roles/modules/buy.ts | 2 + src/plugins/shop/roles/modules/cancel.ts | 5 +- 3 files changed, 13 insertions(+), 114 deletions(-) diff --git a/src/locale/index.ts b/src/locale/index.ts index a3eb2df..577646f 100644 --- a/src/locale/index.ts +++ b/src/locale/index.ts @@ -4,130 +4,24 @@ import logger from "@logger"; export default async () => { await i18next .init({ - lng: "en", // if you're using a language detector, do not define the lng option + // lng: "en", // if you're using a language detector, do not define the lng option // debug: true, fallbackLng: "en", resources: { en: { - general: { not_available: "Not Available" }, - commands: { + plugins: { credits: { - general: { - credits_one: "{{count}} credit", - credits_other: "{{count}} credits", - }, - addons: { - balance: { embed: { title: "Credits" } }, - gift: { embed: { title: "Gift" } }, - }, - }, - reputation: { - addons: { - give: { - version01: { - embed: { - title: ":medal: Reputation", - description: - "You have given reputation within the last day, you can not repute now!", - }, - }, - version02: { - embed: { - title: ":medal: Reputation", - description: - "You have given {{user}} a {{type}} reputation!", - }, - }, - version03: { - embed: { - title: ":medal: Reputation", - description: "You can not repute yourself.", - }, - }, - }, - }, - }, - profile: { - addons: { - view: { - embed: { - title: "Profile", - reputation: "Reputation (Global)", - level: "Level (Guild)", - points: "Points (Guild)", - credits: "Credits (Guild)", - language_code: "Language Code (Global)", - }, - }, - settings: { - embed: { - title: "Profile", - description: "Following settings is set", - fields: { language: "Language" }, - }, - }, + modules: { + balance: { general: { title: "[:dollar:] Credits (Balance)" } }, }, }, }, }, sv: { - general: { not_available: "Otillgänglig" }, - commands: { + plugins: { credits: { - general: { - credits_one: "{{count}} krona", - credits_other: "{{count}} kronor", - }, - addons: { - balance: { embed: { title: "Krediter" } }, - gift: { embed: { title: "Gåva" } }, - }, - }, - reputation: { - addons: { - give: { - version01: { - embed: { - title: ":medal: Omdöme", - description: - "Du har redan gett omdöme inom den senaste dagen, du kan inte ge ett omdöme just nu!", - }, - }, - version02: { - embed: { - title: ":medal: Omdöme", - description: "Du har gett {{user}} ett {{type}} omdöme!", - }, - }, - version03: { - embed: { - title: ":medal: Omdöme", - description: "Du kan inte ge dig själv ett omdöme.", - }, - }, - }, - }, - }, - - profile: { - addons: { - view: { - embed: { - title: "Profil", - reputation: "Omdöme (Globalt)", - level: "Nivå (Server)", - points: "Poäng (Server)", - credits: "Krediter (Server)", - language_code: "Språkkod (Globalt)", - }, - }, - settings: { - embed: { - title: "Profil", - description: "Följande inställningar är satta", - fields: { language: "Språk" }, - }, - }, + modules: { + balance: { general: { title: "[:dollar:] Krediter (Balans)" } }, }, }, }, diff --git a/src/plugins/shop/roles/modules/buy.ts b/src/plugins/shop/roles/modules/buy.ts index 0baf7ed..4fa2980 100644 --- a/src/plugins/shop/roles/modules/buy.ts +++ b/src/plugins/shop/roles/modules/buy.ts @@ -33,11 +33,13 @@ export default { option .setName("name") .setDescription("Name of the role you wish to buy.") + .setRequired(true) ) .addStringOption((option) => option .setName("color") .setDescription("Color of the role you wish to buy.") + .setRequired(true) ); }, execute: async (interaction: CommandInteraction) => { diff --git a/src/plugins/shop/roles/modules/cancel.ts b/src/plugins/shop/roles/modules/cancel.ts index 359d79c..380ac42 100644 --- a/src/plugins/shop/roles/modules/cancel.ts +++ b/src/plugins/shop/roles/modules/cancel.ts @@ -25,7 +25,10 @@ export default { .setName("cancel") .setDescription("Cancel a purchase.") .addRoleOption((option) => - option.setName("role").setDescription("Role you wish to cancel.") + option + .setName("role") + .setDescription("Role you wish to cancel.") + .setRequired(true) ); }, execute: async (interaction: CommandInteraction) => { From b91743dc5c5223235d5739e935d62871ac7c6d5a Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 22 Apr 2022 09:19:40 +0200 Subject: [PATCH 004/142] Update source file plugins.json --- lang/en/plugins.json | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lang/en/plugins.json b/lang/en/plugins.json index 24e05e9..21f42ad 100644 --- a/lang/en/plugins.json +++ b/lang/en/plugins.json @@ -1,3 +1,11 @@ { - "test":"test" + "credits": { + "modules": { + "balance": { + "general": { + "title": "[:dollar:] Credits (Balance)" + } + } + } + } } From 4ebcd7f6ccf8a66e27738919bd8ec6f6c8863e59 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 22 Apr 2022 09:19:41 +0200 Subject: [PATCH 005/142] New translations plugins.json (Swedish) --- lang/sv/plugins.json | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 lang/sv/plugins.json diff --git a/lang/sv/plugins.json b/lang/sv/plugins.json new file mode 100644 index 0000000..3a69f9b --- /dev/null +++ b/lang/sv/plugins.json @@ -0,0 +1,11 @@ +{ + "credits": { + "modules": { + "balance": { + "general": { + "title": "[:dollar:] Krediter (Saldo)" + } + } + } + } +} From 6266d2f6dc6c597763edc5f6c10cdf40ccfbcad5 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 22 Apr 2022 09:19:43 +0200 Subject: [PATCH 006/142] New translations plugins.json (Acholi) --- lang/ach/plugins.json | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 lang/ach/plugins.json diff --git a/lang/ach/plugins.json b/lang/ach/plugins.json new file mode 100644 index 0000000..b08515b --- /dev/null +++ b/lang/ach/plugins.json @@ -0,0 +1,11 @@ +{ + "credits": { + "modules": { + "balance": { + "general": { + "title": "crwdns118:0:dollar:crwdne118:0" + } + } + } + } +} From 4026d3566410e0302318127a0c506913512c1ded Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 22 Apr 2022 10:24:33 +0200 Subject: [PATCH 007/142] Update source file plugins.json --- lang/en/plugins.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lang/en/plugins.json b/lang/en/plugins.json index 21f42ad..239dba9 100644 --- a/lang/en/plugins.json +++ b/lang/en/plugins.json @@ -4,6 +4,12 @@ "balance": { "general": { "title": "[:dollar:] Credits (Balance)" + }, + "user_has_amount_credits": "{{user}} has {{amount}} credits" + }, + "gift": { + "general": { + "title": "[:dollar:] Credits (Gift)" } } } From 060d9b71980a24045bfcce1904d4bec6ea377fcf Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 22 Apr 2022 10:24:34 +0200 Subject: [PATCH 008/142] New translations plugins.json (Swedish) --- lang/sv/plugins.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lang/sv/plugins.json b/lang/sv/plugins.json index 3a69f9b..3765a00 100644 --- a/lang/sv/plugins.json +++ b/lang/sv/plugins.json @@ -4,6 +4,12 @@ "balance": { "general": { "title": "[:dollar:] Krediter (Saldo)" + }, + "user_has_amount_credits": "{{user}} har {{amount}} krediter" + }, + "gift": { + "general": { + "title": "[:dollar:] Krediter (Gåva)" } } } From 3b7f30dc6cdc75edd7b7db61a734e6e204e5d3d8 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 22 Apr 2022 10:24:36 +0200 Subject: [PATCH 009/142] New translations plugins.json (German) --- lang/de/plugins.json | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 lang/de/plugins.json diff --git a/lang/de/plugins.json b/lang/de/plugins.json new file mode 100644 index 0000000..239dba9 --- /dev/null +++ b/lang/de/plugins.json @@ -0,0 +1,17 @@ +{ + "credits": { + "modules": { + "balance": { + "general": { + "title": "[:dollar:] Credits (Balance)" + }, + "user_has_amount_credits": "{{user}} has {{amount}} credits" + }, + "gift": { + "general": { + "title": "[:dollar:] Credits (Gift)" + } + } + } + } +} From b227213d8d86723e2b6d230583ec20c4918cf043 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 22 Apr 2022 14:14:42 +0200 Subject: [PATCH 010/142] Create source file errors.json --- lang/en/errors.json | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 lang/en/errors.json diff --git a/lang/en/errors.json b/lang/en/errors.json new file mode 100644 index 0000000..196a85f --- /dev/null +++ b/lang/en/errors.json @@ -0,0 +1,5 @@ +{ + "errors": { + "guildOnly": "You can only use this command in a guild!" + } +} From e0babcacf36db03b5ebf2e33446545c46a227791 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 22 Apr 2022 14:14:42 +0200 Subject: [PATCH 011/142] Update source file plugins.json --- lang/en/plugins.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lang/en/plugins.json b/lang/en/plugins.json index 239dba9..7233cc3 100644 --- a/lang/en/plugins.json +++ b/lang/en/plugins.json @@ -5,7 +5,10 @@ "general": { "title": "[:dollar:] Credits (Balance)" }, - "user_has_amount_credits": "{{user}} has {{amount}} credits" + "user_has_amount_credits": "{{user}} has {{amount}} credits", + "error01": { + "description": "{{user}} has no credits!" + } }, "gift": { "general": { From e16a665ee60acf266db8e6f574c186e538c25e76 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 22 Apr 2022 14:14:45 +0200 Subject: [PATCH 012/142] New translations plugins.json (Swedish) --- lang/sv/plugins.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lang/sv/plugins.json b/lang/sv/plugins.json index 3765a00..6027eb1 100644 --- a/lang/sv/plugins.json +++ b/lang/sv/plugins.json @@ -5,7 +5,10 @@ "general": { "title": "[:dollar:] Krediter (Saldo)" }, - "user_has_amount_credits": "{{user}} har {{amount}} krediter" + "user_has_amount_credits": "{{user}} har {{amount}} krediter", + "error01": { + "description": "{{user}} har inga krediter!" + } }, "gift": { "general": { From 087fd4e1b5e27e9f15103fc2881dc5c2361e0963 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 22 Apr 2022 14:14:46 +0200 Subject: [PATCH 013/142] New translations plugins.json (German) --- lang/de/plugins.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lang/de/plugins.json b/lang/de/plugins.json index 239dba9..7233cc3 100644 --- a/lang/de/plugins.json +++ b/lang/de/plugins.json @@ -5,7 +5,10 @@ "general": { "title": "[:dollar:] Credits (Balance)" }, - "user_has_amount_credits": "{{user}} has {{amount}} credits" + "user_has_amount_credits": "{{user}} has {{amount}} credits", + "error01": { + "description": "{{user}} has no credits!" + } }, "gift": { "general": { From 59370d14b4030495c309bd124c4e220560f48040 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 22 Apr 2022 15:11:16 +0200 Subject: [PATCH 014/142] =?UTF-8?q?=F0=9F=94=90=20locale=20distribution=20?= =?UTF-8?q?key?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 + src/locale/index.ts | 119 +++++++++----------------------------------- 2 files changed, 26 insertions(+), 95 deletions(-) diff --git a/package.json b/package.json index b5ca226..cf5c0d8 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "email": "vermium@zyner.org" }, "dependencies": { + "@crowdin/ota-client": "^0.7.0", "@discordjs/builders": "^0.12.0", "@discordjs/rest": "^0.4.0", "axios": "^0.26.0", @@ -36,6 +37,7 @@ "discord-api-types": "^0.31.0", "discord.js": "^13.6.0", "i18next": "^21.6.13", + "i18next-resources-to-backend": "^1.0.0", "mongoose": "^6.2.3", "node-schedule": "^2.1.0", "ts-node": "^10.7.0", diff --git a/src/locale/index.ts b/src/locale/index.ts index 133f11b..29d6f78 100644 --- a/src/locale/index.ts +++ b/src/locale/index.ts @@ -1,99 +1,28 @@ +import otaClient, { LanguageStrings } from "@crowdin/ota-client"; import i18next from "i18next"; -import logger from "@logger"; + +const client = new otaClient("ffd2068395f215046cc01f8lfji"); + +export interface translation { + [key: string]: string; +} export default async () => { - await i18next - .init({ - // lng: "en", // if you're using a language detector, do not define the lng option - // debug: true, - fallbackLng: "en", - resources: { - en: { - plugins: { - credits: { - modules: { - balance: { general: { title: "[:dollar:] Credits (Balance)" } }, - }, - }, - }, - }, - sv: { - plugins: { - credits: { - modules: { - balance: { general: { title: "[:dollar:] Krediter (Balans)" } }, - }, - }, - }, - }, - de: { - general: { not_available: "Nicht verfügbar" }, - commands: { - credits: { - general: { - credits_one: "{{count}} Guthaben", - credits_other: "{{count}} Guthaben", - }, - addons: { - balance: { embed: { title: "Guthaben" } }, - gift: { embed: { title: "Geschenk" } }, - }, - }, - reputation: { - addons: { - give: { - version01: { - embed: { - title: ":medal: Ruf", - description: - "Du hast dir am letzten Tag einen Ruf verschafft, den du jetzt nicht rühmen kannst!", - }, - }, - version02: { - embed: { - title: ":medal: Ruf", - description: - "Du hast {{user}} einen {{type}} Ruf gegeben!", - }, - }, - version03: { - embed: { - title: ":medal: Ruf", - description: "Du kannst dich nicht selbst rühmen.", - }, - }, - }, - }, - }, - profile: { - addons: { - view: { - embed: { - title: "Profil", - reputation: "Ruf (Weltweit)", - level: "Level (Gilde)", - points: "Punkte (Gilde)", - credits: "Guthaben (Gilde)", - language_code: "Sprachcode (Weltweit)", - }, - }, - settings: { - embed: { - title: "Profile", - description: "Folgende Einstellungen werden vorgenommen", - fields: { language: "Sprache" }, - }, - }, - }, - }, - }, - }, - }, - }) - .then(async () => { - logger.debug(`i18next initialized`); - }) - .catch(async (error) => { - logger.error(`i18next failed to initialize: ${error}`); - }); + //load needed information from Crowdin distribution + const languages = await client.listLanguages(); + const translations = await client.getStrings(); + const resources = {} as LanguageStrings; + + // eslint-disable-next-line no-loops/no-loops + for (const lngCode in translations) { + resources[lngCode] = translations[lngCode]; + } + //initialize i18next + await i18next.init({ + lng: languages[0], + supportedLngs: languages, + resources, + }); + //i18next now can be used to translate your application + console.log(i18next.store.data); }; From 4fb241bc9745e3f5e58ca56ff65eac9f8c9e5a58 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 22 Apr 2022 15:11:39 +0200 Subject: [PATCH 015/142] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20credit=20module=20?= =?UTF-8?q?handler?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/credits/index.ts | 43 +++++++++++++++--------------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/src/plugins/credits/index.ts b/src/plugins/credits/index.ts index 4566feb..e73aeb5 100644 --- a/src/plugins/credits/index.ts +++ b/src/plugins/credits/index.ts @@ -1,44 +1,37 @@ -// Dependencies import { SlashCommandBuilder } from "@discordjs/builders"; import { CommandInteraction } from "discord.js"; - import logger from "@logger"; -// Modules -import modules from "@root/plugins/credits/modules"; +import modules from "@plugins/credits/modules"; export default { - metadata: { author: "Zyner" }, data: new SlashCommandBuilder() .setName("credits") .setDescription("Manage your credits.") + .addSubcommand(modules.balance.data) .addSubcommand(modules.gift.data) .addSubcommand(modules.top.data) .addSubcommand(modules.work.data), + async execute(interaction: CommandInteraction) { const { options } = interaction; - if (options?.getSubcommand() === "balance") { - logger?.verbose(`Executing balance subcommand`); - return modules.balance.execute(interaction); + switch (options.getSubcommand()) { + case "balance": + await modules.balance.execute(interaction); + break; + case "gift": + await modules.gift.execute(interaction); + break; + case "top": + await modules.top.execute(interaction); + break; + case "work": + await modules.work.execute(interaction); + break; + default: + logger.verbose(`Unknown subcommand ${options.getSubcommand()}`); } - - if (options?.getSubcommand() === "gift") { - logger?.verbose(`Executing gift subcommand`); - return modules.gift.execute(interaction); - } - - if (options?.getSubcommand() === "top") { - logger?.verbose(`Executing top command`); - return modules.top.execute(interaction); - } - - if (options?.getSubcommand() === "work") { - logger?.verbose(`Executing work command`); - return modules.work.execute(interaction); - } - - logger?.verbose(`Unknown subcommand ${options?.getSubcommand()}`); }, }; From 2f76c7c7a7e42c2f066891027df04ee37fa728df Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 22 Apr 2022 15:11:58 +0200 Subject: [PATCH 016/142] =?UTF-8?q?=F0=9F=8C=90=20locale=20support=20for?= =?UTF-8?q?=20top=20module?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/credits/modules/top/index.ts | 78 +++++++++++++++++------- 1 file changed, 57 insertions(+), 21 deletions(-) diff --git a/src/plugins/credits/modules/top/index.ts b/src/plugins/credits/modules/top/index.ts index c27f4df..b580204 100644 --- a/src/plugins/credits/modules/top/index.ts +++ b/src/plugins/credits/modules/top/index.ts @@ -1,48 +1,84 @@ -// Dependencies -import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import { + successColor, + errorColor, + footerText, + footerIcon, +} from "@config/embed"; + +import i18next from "i18next"; import { CommandInteraction, MessageEmbed } from "discord.js"; +import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import logger from "@logger"; -import userSchema from "@schemas/user"; - -// Configurations -import { successColor, footerText, footerIcon } from "@config/embed"; - -// Helpers -import pluralize from "@helpers/pluralize"; +import userSchema, { IUser } from "@schemas/user"; export default { data: (command: SlashCommandSubcommandBuilder) => { return command.setName("top").setDescription(`View the top users`); }, execute: async (interaction: CommandInteraction) => { - // Get all users in the guild + const { locale, guild } = interaction; - const usersDB = await userSchema.find({ guildId: interaction?.guild?.id }); + const embed = new MessageEmbed() + .setTitle( + i18next.t("credits:modules:top:general:title", { + lng: locale, + ns: "plugins", + }) + ) + .setTimestamp(new Date()) + .setFooter({ text: footerText, iconURL: footerIcon }); + + if (guild === null) { + logger.verbose(`Guild is null`); + + return interaction.editReply({ + embeds: [ + embed + .setDescription( + i18next.t("guildOnly", { + lng: locale, + ns: "errors", + }) + ) + .setColor(errorColor), + ], + }); + } + + const usersDB = await userSchema.find({ guildId: guild.id }); const topTen = usersDB // Sort them after credits amount (ascending) - .sort((a, b) => (a?.credits > b?.credits ? -1 : 1)) + .sort((a, b) => (a.credits > b.credits ? -1 : 1)) // Return the top 10 .slice(0, 10); // Create entry object - const entry = (x: any, index: number) => - `${index + 1}. <@${x?.userId}> - ${pluralize(x?.credits, "credit")}`; + const entry = (x: IUser, index: number) => + i18next.t("credits:modules:top:entry", { + lng: locale, + ns: "plugins", + index: index + 1, + user: x.userId, + amount: x.credits, + }); return interaction.editReply({ embeds: [ - new MessageEmbed() - .setTitle("[:dollar:] Credits (Top)") + embed .setDescription( - `Top 10 users with the most credits. + ` ${i18next.t("credits:modules:top:success01:description", { + lng: locale, + ns: "plugins", + })} - ${topTen.map(entry).join("\n")}` + ${topTen.map(entry).join("\n")} + ` ) - .setTimestamp(new Date()) - .setColor(successColor) - .setFooter({ text: footerText, iconURL: footerIcon }), + .setColor(successColor), ], }); }, From 3421732618194579846d08c81089a5e0f232f1a8 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 22 Apr 2022 15:12:10 +0200 Subject: [PATCH 017/142] =?UTF-8?q?=F0=9F=8C=90=20locale=20support=20for?= =?UTF-8?q?=20gift=20module?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/credits/modules/gift/index.ts | 208 ++++++++++++---------- 1 file changed, 117 insertions(+), 91 deletions(-) diff --git a/src/plugins/credits/modules/gift/index.ts b/src/plugins/credits/modules/gift/index.ts index 2ce6a62..5434dcb 100644 --- a/src/plugins/credits/modules/gift/index.ts +++ b/src/plugins/credits/modules/gift/index.ts @@ -18,6 +18,7 @@ import saveUser from "@helpers/saveUser"; // Models import fetchUser from "@helpers/fetchUser"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import i18next from "i18next"; // Function export default { @@ -42,38 +43,52 @@ export default { ); }, execute: async (interaction: CommandInteraction) => { - const { options, user, guild, client } = interaction; + const { options, user, guild, client, locale } = interaction; - const optionUser = options?.getUser("user"); - const optionAmount = options?.getInteger("amount"); - const optionReason = options?.getString("reason"); + const optionUser = options.getUser("user"); + const optionAmount = options.getInteger("amount"); + const optionReason = options.getString("reason"); + + const embed = new MessageEmbed() + .setTitle( + i18next.t("credits:modules:gift:general:title", { + lng: locale, + ns: "plugins", + }) + ) + .setTimestamp(new Date()) + .setFooter({ text: footerText, iconURL: footerIcon }); if (guild === null) { - logger?.verbose(`Guild is null`); + logger.verbose(`Guild is null`); return interaction.editReply({ embeds: [ - new MessageEmbed() - .setTitle("[:dollar:] Credits (Gift)") - .setDescription(`We can not find your guild!`) - .setTimestamp(new Date()) - .setColor(errorColor) - .setFooter({ text: footerText, iconURL: footerIcon }), + embed + .setDescription( + i18next.t("guildOnly", { + lng: locale, + ns: "errors", + }) + ) + .setColor(errorColor), ], }); } if (optionUser === null) { - logger?.verbose(`User not found`); + logger.verbose(`User not found`); return interaction.editReply({ embeds: [ - new MessageEmbed() - .setTitle("[:dollar:] Credits (Gift)") - .setDescription(`We can not find your requested user!`) - .setTimestamp(new Date()) - .setColor(errorColor) - .setFooter({ text: footerText, iconURL: footerIcon }), + embed + .setDescription( + i18next.t("userNotFound", { + lng: locale, + ns: "errors", + }) + ) + .setColor(errorColor), ], }); } @@ -85,119 +100,126 @@ export default { const toUserDB = await fetchUser(optionUser, guild); if (fromUserDB === null) { - logger?.verbose(`User not found`); + logger.verbose(`User not found`); return interaction.editReply({ embeds: [ - new MessageEmbed() - .setTitle("[:dollar:] Credits (Gift)") + embed .setDescription( - `We can not find your requested from user in our database!` + i18next.t("userNotFound", { + lng: locale, + ns: "errors", + }) ) - .setTimestamp(new Date()) - .setColor(errorColor) - .setFooter({ text: footerText, iconURL: footerIcon }), + .setColor(errorColor), ], }); } if (toUserDB === null) { - logger?.verbose(`User not found`); + logger.verbose(`User not found`); return interaction.editReply({ embeds: [ - new MessageEmbed() - .setTitle("[:dollar:] Credits (Gift)") + embed .setDescription( - `We can not find your requested to user in our database!` + i18next.t("userNotFound", { + lng: locale, + ns: "errors", + }) ) - .setTimestamp(new Date()) - .setColor(errorColor) - .setFooter({ text: footerText, iconURL: footerIcon }), + .setColor(errorColor), ], }); } // If receiver is same as sender - if (optionUser?.id === user?.id) { - logger?.verbose(`User is same as sender`); + if (optionUser.id === user.id) { + logger.verbose(`User is same as sender`); return interaction.editReply({ embeds: [ - new MessageEmbed() - .setTitle("[:dollar:] Credits (Gift)") - .setDescription(`You can not pay yourself!`) - .setTimestamp(new Date()) - .setColor(errorColor) - .setFooter({ text: footerText, iconURL: footerIcon }), + embed + .setDescription( + i18next.t("credits:modules:gift:error01:description", { + lng: locale, + ns: "plugins", + }) + ) + .setColor(errorColor), ], }); } // If amount is null if (optionAmount === null) { - logger?.verbose(`Amount is null`); + logger.verbose(`Amount is null`); return interaction.editReply({ embeds: [ - new MessageEmbed() - .setTitle("[:dollar:] Credits (Gift)") - .setDescription(`We could not read your requested amount!`) - .setTimestamp(new Date()) - .setColor(errorColor) - .setFooter({ text: footerText, iconURL: footerIcon }), + embed + .setDescription( + i18next.t("amountNotFound", { + lng: locale, + ns: "errors", + }) + ) + .setColor(errorColor), ], }); } // If amount is zero or below if (optionAmount <= 0) { - logger?.verbose(`Amount is zero or below`); + logger.verbose(`Amount is zero or below`); return interaction.editReply({ embeds: [ - new MessageEmbed() - .setTitle("[:dollar:] Credits (Gift)") - .setDescription(`You can't gift zero or below!`) - .setTimestamp(new Date()) - .setColor(errorColor) - .setFooter({ text: footerText, iconURL: footerIcon }), + embed + .setDescription( + i18next.t("credits:modules:gift:error02:description", { + lng: locale, + ns: "plugins", + }) + ) + .setColor(errorColor), ], }); } // If user has below gifting amount - if (fromUserDB?.credits < optionAmount) { - logger?.verbose(`User has below gifting amount`); + if (fromUserDB.credits < optionAmount) { + logger.verbose(`User has below gifting amount`); return interaction.editReply({ embeds: [ - new MessageEmbed() - .setTitle("[:dollar:] Credits (Gift)") + embed .setDescription( - `You have insufficient credits. Your balance is ${fromUserDB?.credits}!` + i18next.t("credits:modules:gift:error03:description", { + lng: locale, + ns: "plugins", + amount: fromUserDB.credits, + }) ) - .setTimestamp(new Date()) - .setColor(errorColor) - .setFooter({ text: footerText, iconURL: footerIcon }), + .setColor(errorColor), ], }); } // If toUserDB has no credits if (toUserDB === null) { - logger?.verbose(`User has no credits`); + logger.verbose(`User has no credits`); return interaction.editReply({ embeds: [ - new MessageEmbed() - .setTitle("[:dollar:] Credits (Gift)") + embed .setDescription( - `We can not find your requested to user in our database!` + i18next.t("userNotFound", { + lng: locale, + ns: "errors", + }) ) - .setTimestamp(new Date()) - .setColor(errorColor) - .setFooter({ text: footerText, iconURL: footerIcon }), + .setColor(errorColor), ], }); } @@ -209,46 +231,50 @@ export default { toUserDB.credits += optionAmount; // Save users - await saveUser(fromUserDB, toUserDB)?.then(async () => { + await saveUser(fromUserDB, toUserDB).then(async () => { // Get DM user object - const dmUser = client?.users?.cache?.get(optionUser?.id); + const dmUser = client.users.cache.get(optionUser.id); + + if (dmUser == null) return; // Send DM to user await dmUser - ?.send({ + .send({ embeds: [ - new MessageEmbed() - .setTitle("[:dollar:] Credits (Gift)") + embed .setDescription( - `You have received ${optionAmount} credits from ${ - user?.tag - } with reason ${ - optionReason ? ` with reason: ${optionReason}` : "" - }!` + i18next.t("credits:modules:gift:error03:description", { + lng: locale, + ns: "plugins", + user: user.tag, + amount: optionAmount, + reason: optionReason || "unspecified", + }) ) - .setTimestamp(new Date()) - .setColor(successColor) - .setFooter({ text: footerText, iconURL: footerIcon }), + .setColor(successColor), ], }) .catch(async (error) => - logger?.error(`[Gift] Error sending DM to user: ${error}`) + logger.error(`[Gift] Error sending DM to user: ${error}`) ); - logger?.verbose( - `[Gift] Successfully gifted ${optionAmount} credits to ${optionUser?.tag}` + logger.verbose( + `[Gift] Successfully gifted ${optionAmount} credits to ${optionUser.tag}` ); return interaction.editReply({ embeds: [ - new MessageEmbed() - .setTitle("[:dollar:] Credits (Gift)") + embed .setDescription( - `Successfully gifted ${optionAmount} credits to ${optionUser?.tag}!` + i18next.t("credits:modules:gift:success02:description", { + lng: locale, + ns: "plugins", + user: user, + amount: optionAmount, + reason: optionReason || "unspecified", + }) ) - .setTimestamp(new Date()) - .setColor(successColor) - .setFooter({ text: footerText, iconURL: footerIcon }), + .setColor(successColor), ], }); }); From 9963438e31337a0ad2653aeb22580c5c8e4f3e2a Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 22 Apr 2022 15:12:35 +0200 Subject: [PATCH 018/142] =?UTF-8?q?=F0=9F=8C=90=20locale=20support=20for?= =?UTF-8?q?=20balance=20module?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/credits/modules/balance/index.ts | 125 ++++++++++--------- 1 file changed, 67 insertions(+), 58 deletions(-) diff --git a/src/plugins/credits/modules/balance/index.ts b/src/plugins/credits/modules/balance/index.ts index 0c4f2c2..f292056 100644 --- a/src/plugins/credits/modules/balance/index.ts +++ b/src/plugins/credits/modules/balance/index.ts @@ -1,10 +1,3 @@ -// Dependencies -import { CommandInteraction, MessageEmbed } from "discord.js"; -import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; - -import logger from "@logger"; - -// Configurations import { errorColor, successColor, @@ -12,41 +5,52 @@ import { footerIcon, } from "@config/embed"; -// Helpers -import pluralize from "@helpers/pluralize"; +import i18next from "i18next"; +import { CommandInteraction, MessageEmbed } from "discord.js"; +import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import logger from "@logger"; + import fetchUser from "@helpers/fetchUser"; export default { data: (command: SlashCommandSubcommandBuilder) => { - return ( - command - .setName("balance") - .setDescription(`View a user's balance`) - - // User - .addUserOption((option) => - option - .setName("user") - .setDescription(`The user whose balance you want to view`) - ) - ); + return command + .setName("balance") + .setDescription(`View a user's balance`) + .addUserOption((option) => + option + .setName("user") + .setDescription(`The user whose balance you want to view`) + ); }, execute: async (interaction: CommandInteraction) => { - const { options, user, guild } = interaction; + const { options, user, guild, locale } = interaction; - const discordUser = options?.getUser("user"); + const discordUser = options.getUser("user"); + + const embed = new MessageEmbed() + .setTitle( + i18next.t("credits:modules:balance:general:title", { + lng: locale, + ns: "plugins", + }) + ) + .setTimestamp(new Date()) + .setFooter({ text: footerText, iconURL: footerIcon }); if (guild === null) { - logger?.verbose(`Guild is null`); + logger.verbose(`Guild is null`); - return interaction?.editReply({ + return interaction.editReply({ embeds: [ - new MessageEmbed() - .setTitle("[:dollar:] Credits (Balance)") - .setDescription(`You can only use this command in a guild!`) - .setTimestamp(new Date()) - .setColor(errorColor) - .setFooter({ text: footerText, iconURL: footerIcon }), + embed + .setDescription( + i18next.t("guildOnly", { + lng: locale, + ns: "errors", + }) + ) + .setColor(errorColor), ], }); } @@ -54,50 +58,55 @@ export default { const userObj = await fetchUser(discordUser || user, guild); if (userObj === null) { - logger?.verbose(`User not found`); + logger.verbose(`User not found`); - return interaction?.editReply({ + return interaction.editReply({ embeds: [ - new MessageEmbed() - .setTitle("[:dollar:] Credits (Balance)") - .setDescription(`Could not find user ${discordUser || user}`) - .setTimestamp(new Date()) - .setColor(errorColor) - .setFooter({ text: footerText, iconURL: footerIcon }), + embed + .setDescription( + i18next.t("userNotFound", { + lng: locale, + ns: "errors", + user: discordUser || user, + }) + ) + .setColor(errorColor), ], }); } if (userObj.credits === null) { - logger?.verbose(`User has no credits`); + logger.verbose(`User has no credits`); - return interaction?.editReply({ + return interaction.editReply({ embeds: [ - new MessageEmbed() - .setTitle("[:dollar:] Credits (Balance)") - .setDescription(`${discordUser || user} has no credits!`) - .setTimestamp(new Date()) - .setColor(errorColor) - .setFooter({ text: footerText, iconURL: footerIcon }), + embed + .setDescription( + i18next.t("credits:modules:balance:error01:description", { + lng: locale, + ns: "plugins", + user: discordUser || user, + }) + ) + .setColor(errorColor), ], }); } - logger?.verbose(`Found user ${discordUser || user}`); + logger.verbose(`Found user ${discordUser || user}`); - return interaction?.editReply({ + return interaction.editReply({ embeds: [ - new MessageEmbed() - .setTitle("[:dollar:] Credits (Balance)") + embed .setDescription( - `${discordUser || user} has ${pluralize( - userObj.credits, - `credit` - )}!` + i18next.t("credits:modules:balance:success01:description", { + lng: locale, + ns: "plugins", + user: discordUser || user, + amount: userObj.credits, + }) ) - .setTimestamp(new Date()) - .setColor(successColor) - .setFooter({ text: footerText, iconURL: footerIcon }), + .setColor(successColor), ], }); }, From b5dc34e8726e0be12564bff6a780ec19c1d6c7c9 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 22 Apr 2022 15:12:48 +0200 Subject: [PATCH 019/142] =?UTF-8?q?=F0=9F=9A=9A=20use=20@plugins?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/credits/modules/index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/credits/modules/index.ts b/src/plugins/credits/modules/index.ts index 20edcaf..9b144f2 100644 --- a/src/plugins/credits/modules/index.ts +++ b/src/plugins/credits/modules/index.ts @@ -1,6 +1,6 @@ -import balance from "./balance"; -import gift from "./gift"; -import top from "./top"; -import work from "./work"; +import balance from "@plugins/credits/modules/balance"; +import gift from "@plugins/credits/modules/gift"; +import top from "@plugins/credits/modules/top"; +import work from "@plugins/credits/modules/work"; export default { balance, gift, top, work }; From 85e17a8a039c0780960f4ae852211aef0c8af30c Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 22 Apr 2022 15:15:10 +0200 Subject: [PATCH 020/142] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20locale=20use=20log?= =?UTF-8?q?ger?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/locale/index.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/locale/index.ts b/src/locale/index.ts index 29d6f78..82c76b6 100644 --- a/src/locale/index.ts +++ b/src/locale/index.ts @@ -1,12 +1,10 @@ -import otaClient, { LanguageStrings } from "@crowdin/ota-client"; import i18next from "i18next"; +import otaClient, { LanguageStrings } from "@crowdin/ota-client"; + +import logger from "@logger"; const client = new otaClient("ffd2068395f215046cc01f8lfji"); -export interface translation { - [key: string]: string; -} - export default async () => { //load needed information from Crowdin distribution const languages = await client.listLanguages(); @@ -24,5 +22,5 @@ export default async () => { resources, }); //i18next now can be used to translate your application - console.log(i18next.store.data); + logger.silly(i18next.store.data); }; From 05624fa5dcb657eaa1dd7999c9e9a7cb6a671517 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 22 Apr 2022 15:39:38 +0200 Subject: [PATCH 021/142] Create source file errors.json --- lang/en/errors.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lang/en/errors.json b/lang/en/errors.json index 196a85f..225d04b 100644 --- a/lang/en/errors.json +++ b/lang/en/errors.json @@ -1,5 +1,7 @@ { "errors": { - "guildOnly": "You can only use this command in a guild!" + "guildOnly": "You can only use this command in a guild!", + "userNotFound": "Could not find user <@{{user}}>.", + "amountNotFound": "We could not read your requested amount!" } } From e5db8d2ec51cd53db2849a979f0d8d2bca95eacd Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 22 Apr 2022 15:39:38 +0200 Subject: [PATCH 022/142] Update source file plugins.json --- lang/en/plugins.json | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/lang/en/plugins.json b/lang/en/plugins.json index 7233cc3..95b30cf 100644 --- a/lang/en/plugins.json +++ b/lang/en/plugins.json @@ -5,14 +5,41 @@ "general": { "title": "[:dollar:] Credits (Balance)" }, - "user_has_amount_credits": "{{user}} has {{amount}} credits", + "user_has_amount_credits": "<@{{user}}> has {{amount}} credits", "error01": { - "description": "{{user}} has no credits!" + "description": "<@{{user}}> has no credits!" + }, + "success01": { + "description": "<@{{user}}> has {{amount}} credits!\n" } }, "gift": { "general": { "title": "[:dollar:] Credits (Gift)" + }, + "error01": { + "description": "You can not pay yourself!" + }, + "error02": { + "description": "You can't gift zero or below!" + }, + "error03": { + "description": "You have insufficient credits. Your balance is {{amount}}!" + }, + "success01": { + "description": "You have received {{amount}} credits from {{user}} with reason {{reason}}!" + }, + "success02": { + "description": "Successfully gifted {{amount}} credits to <@{{user}}> with reason {{reason}}!" + } + }, + "top": { + "entry": "{{index}}. <@{{user}}> - {{amount}}", + "success01": { + "description": "Top 10 users with the most credits." + }, + "general": { + "title": "[:dollar:] Credits (Top)" } } } From 343885c565795b97b95ead8e03e79a7a66cc67d2 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 22 Apr 2022 15:39:39 +0200 Subject: [PATCH 023/142] New translations plugins.json (Swedish) --- lang/sv/plugins.json | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/lang/sv/plugins.json b/lang/sv/plugins.json index 6027eb1..c515e3b 100644 --- a/lang/sv/plugins.json +++ b/lang/sv/plugins.json @@ -5,14 +5,41 @@ "general": { "title": "[:dollar:] Krediter (Saldo)" }, - "user_has_amount_credits": "{{user}} har {{amount}} krediter", + "user_has_amount_credits": "<@{{user}}> har {{amount}} krediter", "error01": { - "description": "{{user}} har inga krediter!" + "description": "<@{{user}} har inga krediter!" + }, + "success01": { + "description": "<@{{user}}> har {{amount}} krediter!\n" } }, "gift": { "general": { "title": "[:dollar:] Krediter (Gåva)" + }, + "error01": { + "description": "Du kan inte betala själv!" + }, + "error02": { + "description": "Du kan inte ge noll eller nedan!" + }, + "error03": { + "description": "Du har otillräckliga krediter. Ditt saldo är {{amount}}!" + }, + "success01": { + "description": "Du har fått {{amount}} krediter från {{user}} med anledning av {{reason}}!" + }, + "success02": { + "description": "Successfully gifted {{amount}} credits to <@{{user}}> with reason {{reason}}!" + } + }, + "top": { + "entry": "{{index}}. <@{{user}}> - {{amount}}", + "success01": { + "description": "Top 10 users with the most credits." + }, + "general": { + "title": "[:dollar:] Credits (Top)" } } } From 76b98025c3c1c5bab6d6c504a9da142f202f507b Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 22 Apr 2022 15:39:40 +0200 Subject: [PATCH 024/142] New translations plugins.json (English) --- lang/en/plugins.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lang/en/plugins.json b/lang/en/plugins.json index 95b30cf..80ed00f 100644 --- a/lang/en/plugins.json +++ b/lang/en/plugins.json @@ -5,7 +5,7 @@ "general": { "title": "[:dollar:] Credits (Balance)" }, - "user_has_amount_credits": "<@{{user}}> has {{amount}} credits", + "user_has_amount_credits": "{{user}} has {{amount}} credits", "error01": { "description": "<@{{user}}> has no credits!" }, From 6e73e9766c6056eb85f7357ee670dbd1eb2a5ac3 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 22 Apr 2022 15:39:41 +0200 Subject: [PATCH 025/142] New translations plugins.json (German) --- lang/de/plugins.json | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/lang/de/plugins.json b/lang/de/plugins.json index 7233cc3..95b30cf 100644 --- a/lang/de/plugins.json +++ b/lang/de/plugins.json @@ -5,14 +5,41 @@ "general": { "title": "[:dollar:] Credits (Balance)" }, - "user_has_amount_credits": "{{user}} has {{amount}} credits", + "user_has_amount_credits": "<@{{user}}> has {{amount}} credits", "error01": { - "description": "{{user}} has no credits!" + "description": "<@{{user}}> has no credits!" + }, + "success01": { + "description": "<@{{user}}> has {{amount}} credits!\n" } }, "gift": { "general": { "title": "[:dollar:] Credits (Gift)" + }, + "error01": { + "description": "You can not pay yourself!" + }, + "error02": { + "description": "You can't gift zero or below!" + }, + "error03": { + "description": "You have insufficient credits. Your balance is {{amount}}!" + }, + "success01": { + "description": "You have received {{amount}} credits from {{user}} with reason {{reason}}!" + }, + "success02": { + "description": "Successfully gifted {{amount}} credits to <@{{user}}> with reason {{reason}}!" + } + }, + "top": { + "entry": "{{index}}. <@{{user}}> - {{amount}}", + "success01": { + "description": "Top 10 users with the most credits." + }, + "general": { + "title": "[:dollar:] Credits (Top)" } } } From 4ec45ed190444e6e5ba8d45bac1f8f207221d95f Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 22 Apr 2022 15:43:39 +0200 Subject: [PATCH 026/142] =?UTF-8?q?=F0=9F=A5=85=20now=20also=20catches=20T?= =?UTF-8?q?ypeerrors?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/handlers/commands.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/handlers/commands.ts b/src/handlers/commands.ts index dd4df30..db65603 100644 --- a/src/handlers/commands.ts +++ b/src/handlers/commands.ts @@ -15,19 +15,14 @@ export default async (client: Client) => { plugins.map(async (pluginName) => { const plugin = await import(`../plugins/${pluginName}`); - await client?.commands?.set( - plugin?.default?.data?.name, - plugin?.default - ); - - logger.verbose(`Loaded plugin: ${pluginName}`); + await client.commands.set(plugin.default.data.name, plugin.default); }) ) .then(async () => { logger.debug("Successfully loaded plugins."); }) .catch(async (err) => { - logger.error(err); + logger.error(`${err}`); }); }); }; From f0dec606875df7743a0b6524a9903f1c022b0ec2 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 22 Apr 2022 15:45:19 +0200 Subject: [PATCH 027/142] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20Fixed=20@discordjs?= =?UTF-8?q?/builders=20v.13?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/plugins/counters/modules/view/index.ts | 2 +- .../manage/groups/counters/modules/create/index.ts | 2 +- .../manage/groups/counters/modules/delete/index.ts | 2 +- src/plugins/reputation/modules/give.ts | 9 +++++++-- src/plugins/settings/guild/modules/audits.ts | 2 +- src/plugins/settings/guild/modules/welcome.ts | 6 ++++-- 7 files changed, 16 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index cf5c0d8..240f783 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ }, "dependencies": { "@crowdin/ota-client": "^0.7.0", - "@discordjs/builders": "^0.12.0", + "@discordjs/builders": "^0.13.0", "@discordjs/rest": "^0.4.0", "axios": "^0.26.0", "chance": "^1.1.8", diff --git a/src/plugins/counters/modules/view/index.ts b/src/plugins/counters/modules/view/index.ts index e7635c2..66f46c9 100644 --- a/src/plugins/counters/modules/view/index.ts +++ b/src/plugins/counters/modules/view/index.ts @@ -25,7 +25,7 @@ export default { `The channel that contains the counter you want to view` ) .setRequired(true) - .addChannelType(ChannelType.GuildText as number) + .addChannelTypes(ChannelType.GuildText) ); }, execute: async (interaction: CommandInteraction) => { diff --git a/src/plugins/manage/groups/counters/modules/create/index.ts b/src/plugins/manage/groups/counters/modules/create/index.ts index 32c83fb..495f57a 100644 --- a/src/plugins/manage/groups/counters/modules/create/index.ts +++ b/src/plugins/manage/groups/counters/modules/create/index.ts @@ -28,7 +28,7 @@ export default { .setName("channel") .setDescription("The channel to send the counter to.") .setRequired(true) - .addChannelType(ChannelType.GuildText as number) + .addChannelTypes(ChannelType.GuildText) ) .addStringOption((option) => option diff --git a/src/plugins/manage/groups/counters/modules/delete/index.ts b/src/plugins/manage/groups/counters/modules/delete/index.ts index 67bd222..0d8f1d4 100644 --- a/src/plugins/manage/groups/counters/modules/delete/index.ts +++ b/src/plugins/manage/groups/counters/modules/delete/index.ts @@ -28,7 +28,7 @@ export default { .setName("channel") .setDescription("The channel to delete the counter from.") .setRequired(true) - .addChannelType(ChannelType.GuildText as number) + .addChannelTypes(ChannelType.GuildText) ); }, execute: async (interaction: CommandInteraction) => { diff --git a/src/plugins/reputation/modules/give.ts b/src/plugins/reputation/modules/give.ts index 4da08db..13f2162 100644 --- a/src/plugins/reputation/modules/give.ts +++ b/src/plugins/reputation/modules/give.ts @@ -36,8 +36,13 @@ export default { .setName("type") .setDescription("What type of reputation you want to repute") .setRequired(true) - .addChoice("Positive", "positive") - .addChoice("Negative", "negative") + .addChoices( + { name: "Positive", value: "positive" }, + { + name: "Negative", + value: "negative", + } + ) ); }, execute: async (interaction: CommandInteraction) => { diff --git a/src/plugins/settings/guild/modules/audits.ts b/src/plugins/settings/guild/modules/audits.ts index f04ff97..d9d789c 100644 --- a/src/plugins/settings/guild/modules/audits.ts +++ b/src/plugins/settings/guild/modules/audits.ts @@ -25,7 +25,7 @@ export default { option .setName("channel") .setDescription("Channel for audit messages.") - .addChannelType(ChannelType.GuildText as number) + .addChannelTypes(ChannelType.GuildText) ); }, execute: async (interaction: CommandInteraction) => { diff --git a/src/plugins/settings/guild/modules/welcome.ts b/src/plugins/settings/guild/modules/welcome.ts index d45b642..c8c8325 100644 --- a/src/plugins/settings/guild/modules/welcome.ts +++ b/src/plugins/settings/guild/modules/welcome.ts @@ -25,14 +25,16 @@ export default { option .setName("join-channel") .setDescription("Channel for join messages.") - .addChannelType(ChannelType.GuildText as number) + .addChannelTypes(ChannelType.GuildText) ) + .addChannelOption((option) => option .setName("leave-channel") .setDescription("Channel for leave messages.") - .addChannelType(ChannelType.GuildText as number) + .addChannelTypes(ChannelType.GuildText) ) + .addStringOption((option) => option .setName("leave-message") From bc0bce4419f4de5bbd553f928a7cd9aea5f9a26e Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 22 Apr 2022 16:00:35 +0200 Subject: [PATCH 028/142] =?UTF-8?q?=F0=9F=92=A5=20user=20language=20is=20n?= =?UTF-8?q?ow=20presented=20via=20discord=20lang?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/settings/index.ts | 11 +--- src/plugins/settings/user/index.ts | 41 ------------- .../settings/user/modules/appearance.ts | 61 ------------------- 3 files changed, 2 insertions(+), 111 deletions(-) delete mode 100644 src/plugins/settings/user/index.ts delete mode 100644 src/plugins/settings/user/modules/appearance.ts diff --git a/src/plugins/settings/index.ts b/src/plugins/settings/index.ts index 682fc30..a490fd2 100644 --- a/src/plugins/settings/index.ts +++ b/src/plugins/settings/index.ts @@ -4,7 +4,6 @@ import { CommandInteraction } from "discord.js"; // Groups import guildGroup from "./guild"; -import userGroup from "./user"; // Handlers import logger from "@logger"; @@ -15,8 +14,8 @@ export default { data: new SlashCommandBuilder() .setName("settings") .setDescription("Manage settings.") - .addSubcommandGroup(guildGroup.data) - .addSubcommandGroup(userGroup.data), + + .addSubcommandGroup(guildGroup.data), async execute(interaction: CommandInteraction) { const { options } = interaction; @@ -27,12 +26,6 @@ export default { return guildGroup.execute(interaction); } - if (options.getSubcommandGroup() === "user") { - logger.verbose(`Executing user subcommand`); - - return userGroup.execute(interaction); - } - logger.verbose(`No subcommand group found`); }, }; diff --git a/src/plugins/settings/user/index.ts b/src/plugins/settings/user/index.ts deleted file mode 100644 index e3c572f..0000000 --- a/src/plugins/settings/user/index.ts +++ /dev/null @@ -1,41 +0,0 @@ -// Dependencies -import { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders"; -import { CommandInteraction } from "discord.js"; - -// Handlers -import logger from "@logger"; - -// Modules -import appearance from "./modules/appearance"; - -// Function -export default { - data: (group: SlashCommandSubcommandGroupBuilder) => { - return group - .setName("user") - .setDescription("User settings.") - .addSubcommand((command) => - command - .setName("appearance") - .setDescription("User appearance settings.") - .addStringOption((option) => - option - .setName("language") - .setDescription("Set the language.") - .addChoice("English", "en") - .addChoice("Swedish", "sv") - ) - ); - }, - execute: async (interaction: CommandInteraction) => { - const { options } = interaction; - - if (options?.getSubcommand() === "appearance") { - logger?.verbose(`Executing appearance subcommand`); - - await appearance(interaction); - } - - logger?.verbose(`No subcommand found`); - }, -}; diff --git a/src/plugins/settings/user/modules/appearance.ts b/src/plugins/settings/user/modules/appearance.ts deleted file mode 100644 index bf0a4eb..0000000 --- a/src/plugins/settings/user/modules/appearance.ts +++ /dev/null @@ -1,61 +0,0 @@ -// Dependencies -import { CommandInteraction } from "discord.js"; - -// Configurations -import { successColor, footerText, footerIcon } from "@config/embed"; - -// Handlers -import logger from "@logger"; - -// Models -import fetchUser from "@helpers/fetchUser"; - -// Function -export default async (interaction: CommandInteraction) => { - // Destructure member - const { options, user, guild } = interaction; - - // Get options - const language = options?.getString("language"); - - if (guild === null) { - return logger?.verbose(`Guild is null`); - } - - // Get user object - const userDB = await fetchUser(user, guild); - - if (userDB === null) { - return logger?.verbose(`User is null`); - } - - // Modify values - userDB.language = language !== null ? language : userDB?.language; - - // Save guild - await userDB?.save()?.then(async () => { - logger?.verbose(`Updated user language.`); - - return interaction?.editReply({ - embeds: [ - { - title: ":hammer: Settings - User [Appearance]", - description: "Successfully updated user settings.", - color: successColor, - fields: [ - { - name: "🏳️‍🌈 Language", - value: `${userDB?.language}`, - inline: true, - }, - ], - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, - }, - ], - }); - }); -}; From 52f5ae36c520c275dcd7ce42813954453e9cde78 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 22 Apr 2022 16:00:56 +0200 Subject: [PATCH 029/142] :sparkles: utilities plugin avatar module --- src/plugins/utilities/index.ts | 42 +++++++++----------- src/plugins/utilities/modules/avatar.ts | 51 +++++++++++++++++++++++++ src/plugins/utilities/modules/index.ts | 11 ++++++ 3 files changed, 80 insertions(+), 24 deletions(-) create mode 100644 src/plugins/utilities/modules/avatar.ts create mode 100644 src/plugins/utilities/modules/index.ts diff --git a/src/plugins/utilities/index.ts b/src/plugins/utilities/index.ts index 23c43c3..1311dac 100644 --- a/src/plugins/utilities/index.ts +++ b/src/plugins/utilities/index.ts @@ -3,9 +3,7 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { CommandInteraction } from "discord.js"; // Modules -import lookup from "./modules/lookup"; -import about from "./modules/about"; -import stats from "./modules/stats"; +import modules from "@plugins/utilities/modules"; // Handlers import logger from "../../logger"; @@ -16,30 +14,26 @@ export default { data: new SlashCommandBuilder() .setName("utilities") .setDescription("Common utilities.") - .addSubcommand(lookup.data) - .addSubcommand(about.data) - .addSubcommand(stats.data), + + .addSubcommand(modules.lookup.data) + .addSubcommand(modules.about.data) + .addSubcommand(modules.stats.data) + .addSubcommand(modules.avatar.data), + async execute(interaction: CommandInteraction) { const { options } = interaction; - if (options?.getSubcommand() === "lookup") { - logger.verbose(`Executing lookup subcommand`); - - return lookup.execute(interaction); + switch (options.getSubcommand()) { + case "lookup": + return modules.lookup.execute(interaction); + case "about": + return modules.about.execute(interaction); + case "stats": + return modules.stats.execute(interaction); + case "avatar": + return modules.avatar.execute(interaction); + default: + logger.error(`Unknown subcommand ${options.getSubcommand()}`); } - - if (options?.getSubcommand() === "about") { - logger.verbose(`Executing about subcommand`); - - return about.execute(interaction); - } - - if (options?.getSubcommand() === "stats") { - logger.verbose(`Executing stats subcommand`); - - return stats.execute(interaction); - } - - logger.verbose(`No subcommand found.`); }, }; diff --git a/src/plugins/utilities/modules/avatar.ts b/src/plugins/utilities/modules/avatar.ts new file mode 100644 index 0000000..dad96df --- /dev/null +++ b/src/plugins/utilities/modules/avatar.ts @@ -0,0 +1,51 @@ +import { successColor, footerText, footerIcon } from "@config/embed"; +import { hosterName, hosterUrl } from "@config/other"; + +import i18next from "i18next"; +import { CommandInteraction, MessageEmbed } from "discord.js"; +import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; + +export default { + data: (command: SlashCommandSubcommandBuilder) => { + return command + .setName("avatar") + .setDescription("Check someones avatar!)") + .addUserOption((option) => + option + .setName("user") + .setDescription("The user whose avatar you want to check") + ); + }, + execute: async (interaction: CommandInteraction) => { + const { locale } = interaction; + + const userOption = interaction.options.getUser("user"); + + const targetUser = userOption || interaction.user; + + const embed = new MessageEmbed() + .setTitle( + i18next.t("utilities:modules:avatar:general:title", { + lng: locale, + ns: "plugins", + }) + ) + .setTimestamp(new Date()) + .setFooter({ text: footerText, iconURL: footerIcon }); + + return interaction.editReply({ + embeds: [ + embed + .setDescription( + i18next.t("utilities:modules:avatar:success01:description", { + lng: locale, + ns: "plugins", + user: targetUser, + }) + ) + .setThumbnail(targetUser.displayAvatarURL()) + .setColor(successColor), + ], + }); + }, +}; diff --git a/src/plugins/utilities/modules/index.ts b/src/plugins/utilities/modules/index.ts new file mode 100644 index 0000000..b8f2365 --- /dev/null +++ b/src/plugins/utilities/modules/index.ts @@ -0,0 +1,11 @@ +import avatar from "@plugins/utilities/modules/avatar"; +import about from "@plugins/utilities/modules/about"; +import lookup from "@plugins/utilities/modules/lookup"; +import stats from "@plugins/utilities/modules/stats"; + +export default { + avatar, + about, + lookup, + stats, +}; From 7837a24a5745d8d0dff334674879da49fa9fac1a Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 22 Apr 2022 16:01:23 +0200 Subject: [PATCH 030/142] =?UTF-8?q?=E2=9A=B0=EF=B8=8F=20unused=20config=20?= =?UTF-8?q?in=20avatar=20module?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/utilities/modules/avatar.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plugins/utilities/modules/avatar.ts b/src/plugins/utilities/modules/avatar.ts index dad96df..4a6be1f 100644 --- a/src/plugins/utilities/modules/avatar.ts +++ b/src/plugins/utilities/modules/avatar.ts @@ -1,5 +1,4 @@ import { successColor, footerText, footerIcon } from "@config/embed"; -import { hosterName, hosterUrl } from "@config/other"; import i18next from "i18next"; import { CommandInteraction, MessageEmbed } from "discord.js"; From b924ab9f3d3a0791387aa2364e02654b4de61e79 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 22 Apr 2022 16:13:05 +0200 Subject: [PATCH 031/142] =?UTF-8?q?=E2=9C=A8=20add=20plugin=20fun=20and=20?= =?UTF-8?q?module=20meme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/plugins/fun/index.ts | 25 +++++++++++++++++++++++ src/plugins/fun/modules/index.ts | 5 +++++ src/plugins/fun/modules/meme.ts | 35 ++++++++++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 src/plugins/fun/index.ts create mode 100644 src/plugins/fun/modules/index.ts create mode 100644 src/plugins/fun/modules/meme.ts diff --git a/package.json b/package.json index 240f783..7dcc8e3 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "@crowdin/ota-client": "^0.7.0", "@discordjs/builders": "^0.13.0", "@discordjs/rest": "^0.4.0", - "axios": "^0.26.0", + "axios": "^0.26.1", "chance": "^1.1.8", "common": "^0.2.5", "crypto": "^1.0.1", diff --git a/src/plugins/fun/index.ts b/src/plugins/fun/index.ts new file mode 100644 index 0000000..06a9e0b --- /dev/null +++ b/src/plugins/fun/index.ts @@ -0,0 +1,25 @@ +import { SlashCommandBuilder } from "@discordjs/builders"; +import { CommandInteraction } from "discord.js"; +import logger from "@logger"; + +import modules from "@plugins/fun/modules"; + +export default { + data: new SlashCommandBuilder() + .setName("fun") + .setDescription("Fun commands.") + + .addSubcommand(modules.meme.data), + + async execute(interaction: CommandInteraction) { + const { options } = interaction; + + switch (options.getSubcommand()) { + case "meme": + await modules.meme.execute(interaction); + break; + default: + logger.verbose(`Unknown subcommand ${options.getSubcommand()}`); + } + }, +}; diff --git a/src/plugins/fun/modules/index.ts b/src/plugins/fun/modules/index.ts new file mode 100644 index 0000000..2b59097 --- /dev/null +++ b/src/plugins/fun/modules/index.ts @@ -0,0 +1,5 @@ +import meme from "@plugins/fun/modules/meme"; + +export default { + meme, +}; diff --git a/src/plugins/fun/modules/meme.ts b/src/plugins/fun/modules/meme.ts new file mode 100644 index 0000000..c263fe6 --- /dev/null +++ b/src/plugins/fun/modules/meme.ts @@ -0,0 +1,35 @@ +import { successColor, footerText, footerIcon } from "@config/embed"; + +import axios from "axios"; +import { CommandInteraction, MessageEmbed } from "discord.js"; +import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import logger from "@logger"; + +export default { + data: (command: SlashCommandSubcommandBuilder) => { + return command.setName("meme").setDescription("Get a meme from r/memes)"); + }, + execute: async (interaction: CommandInteraction) => { + await axios + .get("https://www.reddit.com/r/memes/random/.json") + .then(async (res) => { + const response = res.data[0].data.children; + const content = response[0].data; + + const embed = new MessageEmbed() + .setTitle(content.title) + .setTimestamp(new Date()) + .setImage(content.url) + .setFooter({ + text: `👍 ${content.ups}︱👎 ${content.downs}\n${footerText}`, + iconURL: footerIcon, + }) + .setColor(successColor); + + return interaction.editReply({ embeds: [embed] }); + }) + .catch((error) => { + logger.error(`${error}`); + }); + }, +}; From c19264eb65981f9f6f79ffcce6a4a3add3ccd354 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 22 Apr 2022 16:16:31 +0200 Subject: [PATCH 032/142] =?UTF-8?q?=F0=9F=9A=9A=20utilities=20is=20now=20u?= =?UTF-8?q?tility?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/utilities/modules/index.ts | 11 ----------- src/plugins/{utilities => utility}/index.ts | 6 +++--- src/plugins/{utilities => utility}/modules/about.ts | 0 src/plugins/{utilities => utility}/modules/avatar.ts | 4 ++-- src/plugins/utility/modules/index.ts | 11 +++++++++++ src/plugins/{utilities => utility}/modules/lookup.ts | 0 src/plugins/{utilities => utility}/modules/stats.ts | 0 7 files changed, 16 insertions(+), 16 deletions(-) delete mode 100644 src/plugins/utilities/modules/index.ts rename src/plugins/{utilities => utility}/index.ts (89%) rename src/plugins/{utilities => utility}/modules/about.ts (100%) rename src/plugins/{utilities => utility}/modules/avatar.ts (90%) create mode 100644 src/plugins/utility/modules/index.ts rename src/plugins/{utilities => utility}/modules/lookup.ts (100%) rename src/plugins/{utilities => utility}/modules/stats.ts (100%) diff --git a/src/plugins/utilities/modules/index.ts b/src/plugins/utilities/modules/index.ts deleted file mode 100644 index b8f2365..0000000 --- a/src/plugins/utilities/modules/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -import avatar from "@plugins/utilities/modules/avatar"; -import about from "@plugins/utilities/modules/about"; -import lookup from "@plugins/utilities/modules/lookup"; -import stats from "@plugins/utilities/modules/stats"; - -export default { - avatar, - about, - lookup, - stats, -}; diff --git a/src/plugins/utilities/index.ts b/src/plugins/utility/index.ts similarity index 89% rename from src/plugins/utilities/index.ts rename to src/plugins/utility/index.ts index 1311dac..ccb2128 100644 --- a/src/plugins/utilities/index.ts +++ b/src/plugins/utility/index.ts @@ -3,7 +3,7 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { CommandInteraction } from "discord.js"; // Modules -import modules from "@plugins/utilities/modules"; +import modules from "@plugins/utility/modules"; // Handlers import logger from "../../logger"; @@ -12,8 +12,8 @@ import logger from "../../logger"; export default { metadata: { author: "Zyner" }, data: new SlashCommandBuilder() - .setName("utilities") - .setDescription("Common utilities.") + .setName("utility") + .setDescription("Common utility.") .addSubcommand(modules.lookup.data) .addSubcommand(modules.about.data) diff --git a/src/plugins/utilities/modules/about.ts b/src/plugins/utility/modules/about.ts similarity index 100% rename from src/plugins/utilities/modules/about.ts rename to src/plugins/utility/modules/about.ts diff --git a/src/plugins/utilities/modules/avatar.ts b/src/plugins/utility/modules/avatar.ts similarity index 90% rename from src/plugins/utilities/modules/avatar.ts rename to src/plugins/utility/modules/avatar.ts index 4a6be1f..81112ff 100644 --- a/src/plugins/utilities/modules/avatar.ts +++ b/src/plugins/utility/modules/avatar.ts @@ -24,7 +24,7 @@ export default { const embed = new MessageEmbed() .setTitle( - i18next.t("utilities:modules:avatar:general:title", { + i18next.t("utility:modules:avatar:general:title", { lng: locale, ns: "plugins", }) @@ -36,7 +36,7 @@ export default { embeds: [ embed .setDescription( - i18next.t("utilities:modules:avatar:success01:description", { + i18next.t("utility:modules:avatar:success01:description", { lng: locale, ns: "plugins", user: targetUser, diff --git a/src/plugins/utility/modules/index.ts b/src/plugins/utility/modules/index.ts new file mode 100644 index 0000000..80c5a64 --- /dev/null +++ b/src/plugins/utility/modules/index.ts @@ -0,0 +1,11 @@ +import avatar from "@plugins/utility/modules/avatar"; +import about from "@plugins/utility/modules/about"; +import lookup from "@plugins/utility/modules/lookup"; +import stats from "@plugins/utility/modules/stats"; + +export default { + avatar, + about, + lookup, + stats, +}; diff --git a/src/plugins/utilities/modules/lookup.ts b/src/plugins/utility/modules/lookup.ts similarity index 100% rename from src/plugins/utilities/modules/lookup.ts rename to src/plugins/utility/modules/lookup.ts diff --git a/src/plugins/utilities/modules/stats.ts b/src/plugins/utility/modules/stats.ts similarity index 100% rename from src/plugins/utilities/modules/stats.ts rename to src/plugins/utility/modules/stats.ts From 757cb2ef48012c6757ea49869bb44da8f96fc78c Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 22 Apr 2022 16:45:51 +0200 Subject: [PATCH 033/142] Update source file plugins.json --- lang/en/plugins.json | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lang/en/plugins.json b/lang/en/plugins.json index 80ed00f..35daf97 100644 --- a/lang/en/plugins.json +++ b/lang/en/plugins.json @@ -5,7 +5,7 @@ "general": { "title": "[:dollar:] Credits (Balance)" }, - "user_has_amount_credits": "{{user}} has {{amount}} credits", + "user_has_amount_credits": "<@{{user}}> has {{amount}} credits", "error01": { "description": "<@{{user}}> has no credits!" }, @@ -43,5 +43,17 @@ } } } + }, + "utility": { + "modules": { + "avatar": { + "general": { + "title": "[:hammer:] Utility (Avatar)" + }, + "success01": { + "description": "Here you have <@{{user}}> avatar!" + } + } + } } } From d56dbc1952efcc2ab96065491fad4bb36499a819 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 22 Apr 2022 16:45:52 +0200 Subject: [PATCH 034/142] New translations plugins.json (Swedish) --- lang/sv/plugins.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lang/sv/plugins.json b/lang/sv/plugins.json index c515e3b..da84d21 100644 --- a/lang/sv/plugins.json +++ b/lang/sv/plugins.json @@ -43,5 +43,17 @@ } } } + }, + "utility": { + "modules": { + "avatar": { + "general": { + "title": "[:hammer:] Utility (Avatar)" + }, + "success01": { + "description": "Here you have <@{{user}}> avatar!" + } + } + } } } From ddb418facd9eb49e9a2edaad819724e02c507f6d Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 22 Apr 2022 16:45:53 +0200 Subject: [PATCH 035/142] New translations plugins.json (English) --- lang/en/plugins.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lang/en/plugins.json b/lang/en/plugins.json index 35daf97..b3249da 100644 --- a/lang/en/plugins.json +++ b/lang/en/plugins.json @@ -5,7 +5,7 @@ "general": { "title": "[:dollar:] Credits (Balance)" }, - "user_has_amount_credits": "<@{{user}}> has {{amount}} credits", + "user_has_amount_credits": "{{user}} has {{amount}} credits", "error01": { "description": "<@{{user}}> has no credits!" }, From b1f7ce0c7cae6449b91dcc1c4d62a0dbb91643ae Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 22 Apr 2022 16:45:54 +0200 Subject: [PATCH 036/142] New translations plugins.json (German) --- lang/de/plugins.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lang/de/plugins.json b/lang/de/plugins.json index 95b30cf..35daf97 100644 --- a/lang/de/plugins.json +++ b/lang/de/plugins.json @@ -43,5 +43,17 @@ } } } + }, + "utility": { + "modules": { + "avatar": { + "general": { + "title": "[:hammer:] Utility (Avatar)" + }, + "success01": { + "description": "Here you have <@{{user}}> avatar!" + } + } + } } } From 112def7c53c70b25b86fff44d0ec2c1b1645b3aa Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 22 Apr 2022 17:47:09 +0200 Subject: [PATCH 037/142] =?UTF-8?q?=E2=9C=A8=20sub=20command=20custom=20op?= =?UTF-8?q?tions,=20such=20as=20permissions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../interactionCreate/components/isCommand.ts | 83 +++++++++++- src/handlers/commands.ts | 6 +- src/plugins/counters/index.ts | 9 +- src/plugins/counters/modules/index.ts | 2 +- src/plugins/counters/modules/view/index.ts | 17 +-- src/plugins/credits/index.ts | 2 + src/plugins/credits/modules/balance/index.ts | 1 + src/plugins/credits/modules/gift/index.ts | 2 + src/plugins/credits/modules/top/index.ts | 2 + src/plugins/credits/modules/work/index.ts | 2 + src/plugins/fun/index.ts | 2 + src/plugins/fun/modules/meme.ts | 2 + src/plugins/manage/groups/counters/index.ts | 14 +- .../groups/counters/modules/create/index.ts | 8 +- .../groups/counters/modules/delete/index.ts | 8 +- .../manage/groups/counters/modules/index.ts | 4 + src/plugins/manage/groups/credits/index.ts | 60 ++++----- .../groups/credits/modules/give/index.ts | 8 +- .../manage/groups/credits/modules/index.ts | 6 + .../groups/credits/modules/set/index.ts | 8 +- .../groups/credits/modules/take/index.ts | 8 +- .../groups/credits/modules/transfer/index.ts | 8 +- src/plugins/manage/groups/index.ts | 4 + src/plugins/manage/index.ts | 30 ++--- src/plugins/profile/index.ts | 18 +-- src/plugins/profile/modules/index.ts | 3 + src/plugins/profile/modules/view.ts | 122 ++++++++++-------- src/plugins/reputation/index.ts | 8 +- src/plugins/reputation/modules/give.ts | 2 + src/plugins/reputation/modules/index.ts | 3 + src/plugins/settings/groups/guild/index.ts | 63 +++++++++ .../{ => groups}/guild/modules/audits.ts | 8 +- .../{ => groups}/guild/modules/credits.ts | 8 +- .../settings/groups/guild/modules/index.ts | 8 ++ .../{ => groups}/guild/modules/points.ts | 8 +- .../{ => groups}/guild/modules/pterodactyl.ts | 8 +- .../{ => groups}/guild/modules/shop.ts | 8 +- .../{ => groups}/guild/modules/welcome.ts | 8 +- src/plugins/settings/groups/index.ts | 3 + src/plugins/settings/guild/index.ts | 94 -------------- src/plugins/settings/index.ts | 9 +- src/plugins/shop/groups/index.ts | 3 + src/plugins/shop/{ => groups}/roles/index.ts | 15 ++- .../shop/{ => groups}/roles/modules/buy.ts | 2 + .../shop/{ => groups}/roles/modules/cancel.ts | 2 + .../shop/groups/roles/modules/index.ts | 7 + src/plugins/shop/index.ts | 16 ++- src/plugins/shop/modules/index.ts | 3 + src/plugins/shop/modules/pterodactyl.ts | 2 + src/plugins/utility/index.ts | 3 +- src/plugins/utility/modules/about.ts | 2 + src/plugins/utility/modules/avatar.ts | 2 + src/plugins/utility/modules/lookup.ts | 2 + src/plugins/utility/modules/stats.ts | 2 + 54 files changed, 462 insertions(+), 276 deletions(-) create mode 100644 src/plugins/manage/groups/counters/modules/index.ts create mode 100644 src/plugins/manage/groups/credits/modules/index.ts create mode 100644 src/plugins/manage/groups/index.ts create mode 100644 src/plugins/profile/modules/index.ts create mode 100644 src/plugins/reputation/modules/index.ts create mode 100644 src/plugins/settings/groups/guild/index.ts rename src/plugins/settings/{ => groups}/guild/modules/audits.ts (93%) rename src/plugins/settings/{ => groups}/guild/modules/credits.ts (95%) create mode 100644 src/plugins/settings/groups/guild/modules/index.ts rename src/plugins/settings/{ => groups}/guild/modules/points.ts (94%) rename src/plugins/settings/{ => groups}/guild/modules/pterodactyl.ts (91%) rename src/plugins/settings/{ => groups}/guild/modules/shop.ts (93%) rename src/plugins/settings/{ => groups}/guild/modules/welcome.ts (95%) create mode 100644 src/plugins/settings/groups/index.ts delete mode 100644 src/plugins/settings/guild/index.ts create mode 100644 src/plugins/shop/groups/index.ts rename src/plugins/shop/{ => groups}/roles/index.ts (84%) rename src/plugins/shop/{ => groups}/roles/modules/buy.ts (98%) rename src/plugins/shop/{ => groups}/roles/modules/cancel.ts (98%) create mode 100644 src/plugins/shop/groups/roles/modules/index.ts create mode 100644 src/plugins/shop/modules/index.ts diff --git a/src/events/interactionCreate/components/isCommand.ts b/src/events/interactionCreate/components/isCommand.ts index ac1e19d..b763bb0 100644 --- a/src/events/interactionCreate/components/isCommand.ts +++ b/src/events/interactionCreate/components/isCommand.ts @@ -4,16 +4,93 @@ import { CommandInteraction, MessageEmbed } from "discord.js"; import logger from "@logger"; import { errorColor, footerText, footerIcon } from "@config/embed"; +import i18next from "i18next"; export default async (interaction: CommandInteraction) => { if (!interaction.isCommand()) return; - const { client, guild, commandName, user } = interaction; + const { client, guild, commandName, user, memberPermissions } = interaction; const currentCommand = client.commands.get(commandName); - if (!currentCommand) return; + if (!currentCommand) { + logger.verbose(`Command ${commandName} not found`); + } - await interaction.deferReply({ ephemeral: true }); + // logger.warn(currentCommand.modules[interaction.options.getSubcommand()].meta); + + // const meta = { ephemeral: false, guildOnly: false }; + + let meta; + + if (!interaction.options.getSubcommandGroup(false)) { + meta = currentCommand.modules[interaction.options.getSubcommand()].meta; + } else { + meta = + currentCommand.groups[interaction.options.getSubcommandGroup()].modules[ + interaction.options.getSubcommand() + ].meta; + } + + await interaction.deferReply({ ephemeral: meta?.ephemeral || false }); + + if ( + meta.permissions && + meta.guildOnly && + !memberPermissions?.has(meta.permissions) + ) { + return interaction?.editReply({ + embeds: [ + new MessageEmbed() + .setTitle("[:toolbox:] Manage") + .setDescription(`You do not have the permission to manage the bot.`) + .setTimestamp(new Date()) + .setColor(errorColor) + .setFooter({ text: footerText, iconURL: footerIcon }), + ], + }); + } + + if (meta.guildOnly) { + if (!guild) { + logger.verbose(`Guild is null`); + + return interaction.editReply({ + embeds: [ + new MessageEmbed() + .setDescription( + i18next.t("guildOnly", { + lng: interaction.locale, + ns: "errors", + }) + ) + .setColor(errorColor) + .setTimestamp(new Date()) + .setFooter({ text: footerText, iconURL: footerIcon }), + ], + }); + } + } + + if (meta.dmOnly) { + if (guild) { + logger.verbose(`Guild exist`); + + return interaction.editReply({ + embeds: [ + new MessageEmbed() + .setDescription( + i18next.t("dmOnly", { + lng: interaction.locale, + ns: "errors", + }) + ) + .setColor(errorColor) + .setTimestamp(new Date()) + .setFooter({ text: footerText, iconURL: footerIcon }), + ], + }); + } + } await currentCommand .execute(interaction) diff --git a/src/handlers/commands.ts b/src/handlers/commands.ts index db65603..f5cfed0 100644 --- a/src/handlers/commands.ts +++ b/src/handlers/commands.ts @@ -15,7 +15,11 @@ export default async (client: Client) => { plugins.map(async (pluginName) => { const plugin = await import(`../plugins/${pluginName}`); - await client.commands.set(plugin.default.data.name, plugin.default); + await client.commands.set( + plugin.default.data.name, + plugin.default, + plugin.default.meta + ); }) ) .then(async () => { diff --git a/src/plugins/counters/index.ts b/src/plugins/counters/index.ts index 4da895c..1bd7c7b 100644 --- a/src/plugins/counters/index.ts +++ b/src/plugins/counters/index.ts @@ -1,17 +1,18 @@ -// Dependencies import { CommandInteraction } from "discord.js"; import { SlashCommandBuilder } from "@discordjs/builders"; - import logger from "@logger"; -import modules from "@root/plugins/counters/modules"; +import modules from "@plugins/counters/modules"; export default { - metadata: { author: "Zyner" }, + modules, + data: new SlashCommandBuilder() .setName("counters") .setDescription("View guild counters") + .addSubcommand(modules.view.data), + async execute(interaction: CommandInteraction) { const { options } = interaction; diff --git a/src/plugins/counters/modules/index.ts b/src/plugins/counters/modules/index.ts index dc539f8..8c5ea76 100644 --- a/src/plugins/counters/modules/index.ts +++ b/src/plugins/counters/modules/index.ts @@ -1,3 +1,3 @@ -import view from "./view"; +import view from "@plugins/counters/modules/view"; export default { view }; diff --git a/src/plugins/counters/modules/view/index.ts b/src/plugins/counters/modules/view/index.ts index 66f46c9..7dd8d52 100644 --- a/src/plugins/counters/modules/view/index.ts +++ b/src/plugins/counters/modules/view/index.ts @@ -1,11 +1,3 @@ -// Dependencies -import { CommandInteraction, MessageEmbed } from "discord.js"; -import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; -import { ChannelType } from "discord-api-types/v10"; - -import counterSchema from "@schemas/counter"; - -// Configuration import { errorColor, successColor, @@ -13,7 +5,15 @@ import { footerIcon, } from "@config/embed"; +import { CommandInteraction, MessageEmbed } from "discord.js"; +import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import { ChannelType } from "discord-api-types/v10"; + +import counterSchema from "@schemas/counter"; + export default { + meta: { guildOnly: true, ephemeral: false }, + data: (command: SlashCommandSubcommandBuilder) => { return command .setName("view") @@ -28,6 +28,7 @@ export default { .addChannelTypes(ChannelType.GuildText) ); }, + execute: async (interaction: CommandInteraction) => { const { options, guild } = interaction; diff --git a/src/plugins/credits/index.ts b/src/plugins/credits/index.ts index e73aeb5..2ec3c92 100644 --- a/src/plugins/credits/index.ts +++ b/src/plugins/credits/index.ts @@ -5,6 +5,8 @@ import logger from "@logger"; import modules from "@plugins/credits/modules"; export default { + modules, + data: new SlashCommandBuilder() .setName("credits") .setDescription("Manage your credits.") diff --git a/src/plugins/credits/modules/balance/index.ts b/src/plugins/credits/modules/balance/index.ts index f292056..44ac45a 100644 --- a/src/plugins/credits/modules/balance/index.ts +++ b/src/plugins/credits/modules/balance/index.ts @@ -13,6 +13,7 @@ import logger from "@logger"; import fetchUser from "@helpers/fetchUser"; export default { + meta: { guildOnly: true, ephemeral: true }, data: (command: SlashCommandSubcommandBuilder) => { return command .setName("balance") diff --git a/src/plugins/credits/modules/gift/index.ts b/src/plugins/credits/modules/gift/index.ts index 5434dcb..82b6a28 100644 --- a/src/plugins/credits/modules/gift/index.ts +++ b/src/plugins/credits/modules/gift/index.ts @@ -22,6 +22,8 @@ import i18next from "i18next"; // Function export default { + meta: { guildOnly: true, ephemeral: true }, + data: (command: SlashCommandSubcommandBuilder) => { return command .setName("gift") diff --git a/src/plugins/credits/modules/top/index.ts b/src/plugins/credits/modules/top/index.ts index b580204..1656c59 100644 --- a/src/plugins/credits/modules/top/index.ts +++ b/src/plugins/credits/modules/top/index.ts @@ -13,6 +13,8 @@ import logger from "@logger"; import userSchema, { IUser } from "@schemas/user"; export default { + meta: { guildOnly: true, ephemeral: false }, + data: (command: SlashCommandSubcommandBuilder) => { return command.setName("top").setDescription(`View the top users`); }, diff --git a/src/plugins/credits/modules/work/index.ts b/src/plugins/credits/modules/work/index.ts index 2ffb20d..4ad9d13 100644 --- a/src/plugins/credits/modules/work/index.ts +++ b/src/plugins/credits/modules/work/index.ts @@ -17,6 +17,8 @@ import fetchUser from "@helpers/fetchUser"; import fetchGuild from "@helpers/fetchGuild"; export default { + meta: { guildOnly: true, ephemeral: true }, + data: (command: SlashCommandSubcommandBuilder) => { return command.setName("work").setDescription(`Work to earn credits`); }, diff --git a/src/plugins/fun/index.ts b/src/plugins/fun/index.ts index 06a9e0b..0d727dc 100644 --- a/src/plugins/fun/index.ts +++ b/src/plugins/fun/index.ts @@ -5,6 +5,8 @@ import logger from "@logger"; import modules from "@plugins/fun/modules"; export default { + modules, + data: new SlashCommandBuilder() .setName("fun") .setDescription("Fun commands.") diff --git a/src/plugins/fun/modules/meme.ts b/src/plugins/fun/modules/meme.ts index c263fe6..40d5cdb 100644 --- a/src/plugins/fun/modules/meme.ts +++ b/src/plugins/fun/modules/meme.ts @@ -6,6 +6,8 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import logger from "@logger"; export default { + meta: { guildOnly: false, ephemeral: false }, + data: (command: SlashCommandSubcommandBuilder) => { return command.setName("meme").setDescription("Get a meme from r/memes)"); }, diff --git a/src/plugins/manage/groups/counters/index.ts b/src/plugins/manage/groups/counters/index.ts index dc3c255..fec6a1d 100644 --- a/src/plugins/manage/groups/counters/index.ts +++ b/src/plugins/manage/groups/counters/index.ts @@ -5,31 +5,33 @@ import { CommandInteraction } from "discord.js"; import logger from "@logger"; // Modules -import moduleCreate from "./modules/create"; -import moduleDelete from "./modules/delete"; +import modules from "./modules"; // Function export default { + modules, + data: (group: SlashCommandSubcommandGroupBuilder) => { return group .setName("counters") .setDescription("Manage guild counters.") - .addSubcommand(moduleCreate.data) - .addSubcommand(moduleDelete.data); + .addSubcommand(modules.create.data) + .addSubcommand(modules.delete_.data); }, + execute: async (interaction: CommandInteraction) => { const { options } = interaction; if (options?.getSubcommand() === "create") { logger?.verbose(`Executing create subcommand`); - return moduleCreate.execute(interaction); + return modules.create.execute(interaction); } if (options?.getSubcommand() === "delete") { logger?.verbose(`Executing delete subcommand`); - return moduleDelete.execute(interaction); + return modules.delete_.execute(interaction); } logger?.verbose(`Unknown subcommand ${options?.getSubcommand()}`); diff --git a/src/plugins/manage/groups/counters/modules/create/index.ts b/src/plugins/manage/groups/counters/modules/create/index.ts index 495f57a..f23723c 100644 --- a/src/plugins/manage/groups/counters/modules/create/index.ts +++ b/src/plugins/manage/groups/counters/modules/create/index.ts @@ -1,5 +1,5 @@ // Dependencies -import { MessageEmbed, CommandInteraction } from "discord.js"; +import { MessageEmbed, CommandInteraction, Permissions } from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChannelType } from "discord-api-types/v10"; @@ -19,6 +19,12 @@ import counterSchema from "@schemas/counter"; // Function export default { + meta: { + guildOnly: true, + ephemeral: true, + permissions: [Permissions.FLAGS.MANAGE_GUILD], + }, + data: (command: SlashCommandSubcommandBuilder) => { return command .setName("create") diff --git a/src/plugins/manage/groups/counters/modules/delete/index.ts b/src/plugins/manage/groups/counters/modules/delete/index.ts index 0d8f1d4..3035fa8 100644 --- a/src/plugins/manage/groups/counters/modules/delete/index.ts +++ b/src/plugins/manage/groups/counters/modules/delete/index.ts @@ -1,5 +1,5 @@ // Dependencies -import { CommandInteraction, MessageEmbed } from "discord.js"; +import { CommandInteraction, MessageEmbed, Permissions } from "discord.js"; // Configurations import { @@ -19,6 +19,12 @@ import { ChannelType } from "discord-api-types/v10"; // Function export default { + meta: { + guildOnly: true, + ephemeral: true, + permissions: [Permissions.FLAGS.MANAGE_GUILD], + }, + data: (command: SlashCommandSubcommandBuilder) => { return command .setName("delete") diff --git a/src/plugins/manage/groups/counters/modules/index.ts b/src/plugins/manage/groups/counters/modules/index.ts new file mode 100644 index 0000000..37cb7aa --- /dev/null +++ b/src/plugins/manage/groups/counters/modules/index.ts @@ -0,0 +1,4 @@ +import create from "@plugins/manage/groups/counters/modules/create"; +import delete_ from "@plugins/manage/groups/counters/modules/delete"; + +export default { create, delete_ }; diff --git a/src/plugins/manage/groups/credits/index.ts b/src/plugins/manage/groups/credits/index.ts index 9209f8a..fc0839c 100644 --- a/src/plugins/manage/groups/credits/index.ts +++ b/src/plugins/manage/groups/credits/index.ts @@ -1,53 +1,43 @@ -// Dependencies import { CommandInteraction } from "discord.js"; import { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders"; - import logger from "@logger"; -// Modules -import moduleGive from "./modules/give"; -import moduleSet from "./modules/set"; -import moduleTake from "./modules/take"; -import moduleTransfer from "./modules/transfer"; +import modules from "./modules"; -// Function export default { + modules, + data: (group: SlashCommandSubcommandGroupBuilder) => { return group .setName("credits") .setDescription("Manage the credits of a user.") - .addSubcommand(moduleGive.data) - .addSubcommand(moduleSet.data) - .addSubcommand(moduleTake.data) - .addSubcommand(moduleTransfer.data); + .addSubcommand(modules.give.data) + .addSubcommand(modules.set.data) + .addSubcommand(modules.take.data) + .addSubcommand(modules.transfer.data); }, execute: async (interaction: CommandInteraction) => { const { options } = interaction; - if (options?.getSubcommand() === "give") { - logger?.verbose(`Executing give subcommand`); + switch (options.getSubcommand()) { + case "give": + logger.verbose(`Executing give subcommand`); - return moduleGive.execute(interaction); + return modules.give.execute(interaction); + case "set": + logger.verbose(`Executing set subcommand`); + + return modules.set.execute(interaction); + case "take": + logger.verbose(`Executing take subcommand`); + + return modules.take.execute(interaction); + case "transfer": + logger.verbose(`Executing transfer subcommand`); + + return modules.transfer.execute(interaction); + default: + logger.verbose(`Unknown subcommand ${options.getSubcommand()}`); } - - if (options?.getSubcommand() === "set") { - logger?.verbose(`Executing set subcommand`); - - return moduleSet.execute(interaction); - } - - if (options?.getSubcommand() === "take") { - logger?.verbose(`Executing take subcommand`); - - return moduleTake.execute(interaction); - } - - if (options?.getSubcommand() === "transfer") { - logger?.verbose(`Executing transfer subcommand`); - - return moduleTransfer.execute(interaction); - } - - logger?.verbose(`No subcommand found`); }, }; diff --git a/src/plugins/manage/groups/credits/modules/give/index.ts b/src/plugins/manage/groups/credits/modules/give/index.ts index 2345852..38e272c 100644 --- a/src/plugins/manage/groups/credits/modules/give/index.ts +++ b/src/plugins/manage/groups/credits/modules/give/index.ts @@ -1,5 +1,5 @@ // Dependencies -import { CommandInteraction, MessageEmbed } from "discord.js"; +import { CommandInteraction, MessageEmbed, Permissions } from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Configurations @@ -21,6 +21,12 @@ import fetchUser from "@helpers/fetchUser"; // Function export default { + meta: { + guildOnly: true, + ephemeral: true, + permissions: [Permissions.FLAGS.MANAGE_GUILD], + }, + data: (command: SlashCommandSubcommandBuilder) => { return command .setName("give") diff --git a/src/plugins/manage/groups/credits/modules/index.ts b/src/plugins/manage/groups/credits/modules/index.ts new file mode 100644 index 0000000..4065a60 --- /dev/null +++ b/src/plugins/manage/groups/credits/modules/index.ts @@ -0,0 +1,6 @@ +import give from "@plugins/manage/groups/credits/modules/give"; +import set from "@plugins/manage/groups/credits/modules/set"; +import take from "@plugins/manage/groups/credits/modules/take"; +import transfer from "@plugins/manage/groups/credits/modules/transfer"; + +export default { give, set, take, transfer }; diff --git a/src/plugins/manage/groups/credits/modules/set/index.ts b/src/plugins/manage/groups/credits/modules/set/index.ts index 53103a4..a2b8e18 100644 --- a/src/plugins/manage/groups/credits/modules/set/index.ts +++ b/src/plugins/manage/groups/credits/modules/set/index.ts @@ -1,5 +1,5 @@ // Dependencies -import { CommandInteraction, MessageEmbed } from "discord.js"; +import { CommandInteraction, MessageEmbed, Permissions } from "discord.js"; // Configurations import { @@ -20,6 +20,12 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Function export default { + meta: { + guildOnly: true, + ephemeral: true, + permissions: [Permissions.FLAGS.MANAGE_GUILD], + }, + data: (command: SlashCommandSubcommandBuilder) => { return command .setName("set") diff --git a/src/plugins/manage/groups/credits/modules/take/index.ts b/src/plugins/manage/groups/credits/modules/take/index.ts index 40e74bb..53b2864 100644 --- a/src/plugins/manage/groups/credits/modules/take/index.ts +++ b/src/plugins/manage/groups/credits/modules/take/index.ts @@ -1,5 +1,5 @@ // Dependencies -import { CommandInteraction, MessageEmbed } from "discord.js"; +import { CommandInteraction, MessageEmbed, Permissions } from "discord.js"; // Configurations import { @@ -21,6 +21,12 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Function export default { + meta: { + guildOnly: true, + ephemeral: true, + permissions: [Permissions.FLAGS.MANAGE_GUILD], + }, + data: (command: SlashCommandSubcommandBuilder) => { return command .setName("take") diff --git a/src/plugins/manage/groups/credits/modules/transfer/index.ts b/src/plugins/manage/groups/credits/modules/transfer/index.ts index 0dbd07d..4423ca5 100644 --- a/src/plugins/manage/groups/credits/modules/transfer/index.ts +++ b/src/plugins/manage/groups/credits/modules/transfer/index.ts @@ -1,5 +1,5 @@ // Dependencies -import { CommandInteraction, MessageEmbed } from "discord.js"; +import { CommandInteraction, MessageEmbed, Permissions } from "discord.js"; // Configurations import { @@ -21,6 +21,12 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Function export default { + meta: { + guildOnly: true, + ephemeral: true, + permissions: [Permissions.FLAGS.MANAGE_GUILD], + }, + data: (command: SlashCommandSubcommandBuilder) => { return command .setName("transfer") diff --git a/src/plugins/manage/groups/index.ts b/src/plugins/manage/groups/index.ts new file mode 100644 index 0000000..6b928fe --- /dev/null +++ b/src/plugins/manage/groups/index.ts @@ -0,0 +1,4 @@ +import counters from "@plugins/manage/groups/counters"; +import credits from "@plugins/manage/groups/credits"; + +export default { counters, credits }; diff --git a/src/plugins/manage/index.ts b/src/plugins/manage/index.ts index 32d066d..aecedf5 100644 --- a/src/plugins/manage/index.ts +++ b/src/plugins/manage/index.ts @@ -6,47 +6,33 @@ import { CommandInteraction, Permissions, MessageEmbed } from "discord.js"; import { errorColor, footerText, footerIcon } from "@config/embed"; // Groups -import credits from "./groups/credits"; -import counters from "./groups/counters"; +import groups from "@plugins/manage/groups"; import logger from "@logger"; // Function export default { - metadata: { author: "Zyner" }, + groups, + data: new SlashCommandBuilder() .setName("manage") .setDescription("Manage the bot.") - .addSubcommandGroup(counters.data) - .addSubcommandGroup(credits.data), + .addSubcommandGroup(groups.counters.data) + .addSubcommandGroup(groups.credits.data), async execute(interaction: CommandInteraction) { // Destructure - const { memberPermissions, options } = interaction; - - // Check permission - if (!memberPermissions?.has(Permissions?.FLAGS?.MANAGE_GUILD)) { - return interaction?.editReply({ - embeds: [ - new MessageEmbed() - .setTitle("[:toolbox:] Manage") - .setDescription(`You do not have the permission to manage the bot.`) - .setTimestamp(new Date()) - .setColor(errorColor) - .setFooter({ text: footerText, iconURL: footerIcon }), - ], - }); - } + const { options } = interaction; if (options?.getSubcommandGroup() === "credits") { logger?.verbose(`Subcommand group is credits`); - return credits.execute(interaction); + return groups.credits.execute(interaction); } if (options?.getSubcommandGroup() === "counters") { logger?.verbose(`Subcommand group is counters`); - return counters.execute(interaction); + return groups.counters.execute(interaction); } logger?.verbose(`Subcommand group is not credits or counters`); diff --git a/src/plugins/profile/index.ts b/src/plugins/profile/index.ts index a255a7a..1908543 100644 --- a/src/plugins/profile/index.ts +++ b/src/plugins/profile/index.ts @@ -3,34 +3,26 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { CommandInteraction } from "discord.js"; // Modules -import view from "./modules/view"; +import modules from "@plugins/profile/modules"; // Handlers import logger from "@logger"; // Function export default { - metadata: { author: "Zyner" }, + modules, + data: new SlashCommandBuilder() .setName("profile") .setDescription("Check a profile.") - .addSubcommand((subcommand) => - subcommand - .setName("view") - .setDescription("View a profile.") - .addUserOption((option) => - option - .setName("target") - .setDescription("The profile you wish to view") - ) - ), + .addSubcommand(modules.view.data), async execute(interaction: CommandInteraction) { const { options } = interaction; if (options?.getSubcommand() === "view") { logger?.verbose(`Executing view subcommand`); - return view(interaction); + return modules.view.execute(interaction); } logger?.verbose(`No subcommand found`); diff --git a/src/plugins/profile/modules/index.ts b/src/plugins/profile/modules/index.ts new file mode 100644 index 0000000..1dc8e1b --- /dev/null +++ b/src/plugins/profile/modules/index.ts @@ -0,0 +1,3 @@ +import view from "@plugins/profile/modules/view"; + +export default { view }; diff --git a/src/plugins/profile/modules/view.ts b/src/plugins/profile/modules/view.ts index 6e05df5..81bfc52 100644 --- a/src/plugins/profile/modules/view.ts +++ b/src/plugins/profile/modules/view.ts @@ -8,68 +8,82 @@ import { successColor, footerText, footerIcon } from "@config/embed"; import fetchUser from "@helpers/fetchUser"; import logger from "@logger"; +import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Function -export default async (interaction: CommandInteraction) => { - // Destructure - const { client, options, user, guild } = interaction; +export default { + meta: { guildOnly: true, ephemeral: false }, - // Target information - const target = options?.getUser("target"); + data: (command: SlashCommandSubcommandBuilder) => { + return command + .setName("view") + .setDescription("View a profile.") + .addUserOption((option) => + option.setName("target").setDescription("The profile you wish to view") + ); + }, - // Discord User Information - const discordUser = await client?.users?.fetch( - `${target ? target?.id : user?.id}` - ); + execute: async (interaction: CommandInteraction) => { + // Destructure + const { client, options, user, guild } = interaction; - if (guild === null) { - return logger?.verbose(`Guild is null`); - } + // Target information + const target = options?.getUser("target"); - // User Information - const userObj = await fetchUser(discordUser, guild); + // Discord User Information + const discordUser = await client?.users?.fetch( + `${target ? target?.id : user?.id}` + ); - // Embed object - const embed = { - author: { - name: `${discordUser?.username}#${discordUser?.discriminator}`, - icon_url: discordUser?.displayAvatarURL(), - }, - color: successColor, - fields: [ - { - name: `:dollar: Credits`, - value: `${userObj?.credits || "Not found"}`, - inline: true, + if (guild === null) { + return logger?.verbose(`Guild is null`); + } + + // User Information + const userObj = await fetchUser(discordUser, guild); + + // Embed object + const embed = { + author: { + name: `${discordUser?.username}#${discordUser?.discriminator}`, + icon_url: discordUser?.displayAvatarURL(), }, - { - name: `:squeeze_bottle: Level`, - value: `${userObj?.level || "Not found"}`, - inline: true, + color: successColor, + fields: [ + { + name: `:dollar: Credits`, + value: `${userObj?.credits || "Not found"}`, + inline: true, + }, + { + name: `:squeeze_bottle: Level`, + value: `${userObj?.level || "Not found"}`, + inline: true, + }, + { + name: `:squeeze_bottle: Points`, + value: `${userObj?.points || "Not found"}`, + inline: true, + }, + { + name: `:loudspeaker: Reputation`, + value: `${userObj?.reputation || "Not found"}`, + inline: true, + }, + { + name: `:rainbow_flag: Language`, + value: `${userObj?.language || "Not found"}`, + inline: true, + }, + ], + timestamp: new Date(), + footer: { + iconURL: footerIcon, + text: footerText, }, - { - name: `:squeeze_bottle: Points`, - value: `${userObj?.points || "Not found"}`, - inline: true, - }, - { - name: `:loudspeaker: Reputation`, - value: `${userObj?.reputation || "Not found"}`, - inline: true, - }, - { - name: `:rainbow_flag: Language`, - value: `${userObj?.language || "Not found"}`, - inline: true, - }, - ], - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, - }; + }; - // Return interaction reply - return interaction?.editReply({ embeds: [embed] }); + // Return interaction reply + return interaction?.editReply({ embeds: [embed] }); + }, }; diff --git a/src/plugins/reputation/index.ts b/src/plugins/reputation/index.ts index 4908641..7fd5218 100644 --- a/src/plugins/reputation/index.ts +++ b/src/plugins/reputation/index.ts @@ -3,25 +3,25 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { CommandInteraction } from "discord.js"; // Modules -import give from "./modules/give"; +import modules from "./modules"; // Handlers import logger from "@logger"; // Function export default { - metadata: { author: "Zyner" }, + modules, data: new SlashCommandBuilder() .setName("reputation") .setDescription("Manage reputation.") - .addSubcommand(give.data), + .addSubcommand(modules.give.data), async execute(interaction: CommandInteraction) { const { options } = interaction; if (options?.getSubcommand() === "give") { logger?.verbose(`Executing give subcommand`); - await give.execute(interaction); + await modules.give.execute(interaction); } logger?.verbose(`No subcommand found`); diff --git a/src/plugins/reputation/modules/give.ts b/src/plugins/reputation/modules/give.ts index 13f2162..c3cdf3c 100644 --- a/src/plugins/reputation/modules/give.ts +++ b/src/plugins/reputation/modules/give.ts @@ -21,6 +21,8 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Function export default { + meta: { guildOnly: true, ephemeral: true }, + data: (command: SlashCommandSubcommandBuilder) => { return command .setName("give") diff --git a/src/plugins/reputation/modules/index.ts b/src/plugins/reputation/modules/index.ts new file mode 100644 index 0000000..f6746fd --- /dev/null +++ b/src/plugins/reputation/modules/index.ts @@ -0,0 +1,3 @@ +import give from "@plugins/reputation/modules/give"; + +export default { give }; diff --git a/src/plugins/settings/groups/guild/index.ts b/src/plugins/settings/groups/guild/index.ts new file mode 100644 index 0000000..cfd2fe6 --- /dev/null +++ b/src/plugins/settings/groups/guild/index.ts @@ -0,0 +1,63 @@ +// Dependencies +import { Permissions, CommandInteraction } from "discord.js"; + +// Configurations +import { errorColor, footerText, footerIcon } from "@config/embed"; + +// Handlers +import logger from "@logger"; + +// Modules +import modules from "./modules"; + +import { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders"; + +// Function +export default { + modules, + + data: (group: SlashCommandSubcommandGroupBuilder) => { + return group + .setName("guild") + .setDescription("Guild settings.") + .addSubcommand(modules.pterodactyl.data) + .addSubcommand(modules.credits.data) + .addSubcommand(modules.points.data) + .addSubcommand(modules.welcome.data) + .addSubcommand(modules.audits.data) + .addSubcommand(modules.shop.data); + }, + execute: async (interaction: CommandInteraction) => { + // Destructure member + const { options } = interaction; + + switch (options?.getSubcommand()) { + case "pterodactyl": + logger?.verbose(`Subcommand is pterodactyl`); + + return modules.pterodactyl.execute(interaction); + case "credits": + logger?.verbose(`Subcommand is credits`); + + return modules.credits.execute(interaction); + case "points": + logger?.verbose(`Subcommand is points`); + + return modules.points.execute(interaction); + case "welcome": + logger?.verbose(`Subcommand is welcome`); + + return modules.welcome.execute(interaction); + case "audits": + logger?.verbose(`Subcommand is audits`); + + return modules.audits.execute(interaction); + case "shop": + logger?.verbose(`Subcommand is shop`); + + return modules.shop.execute(interaction); + default: + logger?.verbose(`Subcommand is not found`); + } + }, +}; diff --git a/src/plugins/settings/guild/modules/audits.ts b/src/plugins/settings/groups/guild/modules/audits.ts similarity index 93% rename from src/plugins/settings/guild/modules/audits.ts rename to src/plugins/settings/groups/guild/modules/audits.ts index d9d789c..c54b4c2 100644 --- a/src/plugins/settings/guild/modules/audits.ts +++ b/src/plugins/settings/groups/guild/modules/audits.ts @@ -1,5 +1,5 @@ // Dependencies -import { CommandInteraction } from "discord.js"; +import { CommandInteraction, Permissions } from "discord.js"; // Configurations import { successColor, footerText, footerIcon } from "@config/embed"; @@ -14,6 +14,12 @@ import { ChannelType } from "discord-api-types/v10"; // Function export default { + meta: { + guildOnly: true, + ephemeral: true, + permissions: [Permissions.FLAGS.MANAGE_GUILD], + }, + data: (command: SlashCommandSubcommandBuilder) => { return command .setName("audits") diff --git a/src/plugins/settings/guild/modules/credits.ts b/src/plugins/settings/groups/guild/modules/credits.ts similarity index 95% rename from src/plugins/settings/guild/modules/credits.ts rename to src/plugins/settings/groups/guild/modules/credits.ts index f7bd893..11589ab 100644 --- a/src/plugins/settings/guild/modules/credits.ts +++ b/src/plugins/settings/groups/guild/modules/credits.ts @@ -1,5 +1,5 @@ // Dependencies -import { CommandInteraction } from "discord.js"; +import { CommandInteraction, Permissions } from "discord.js"; // Configurations import { successColor, footerText, footerIcon } from "@config/embed"; @@ -13,6 +13,12 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Function export default { + meta: { + guildOnly: true, + ephemeral: true, + permissions: [Permissions.FLAGS.MANAGE_GUILD], + }, + data: (command: SlashCommandSubcommandBuilder) => { return command .setName("credits") diff --git a/src/plugins/settings/groups/guild/modules/index.ts b/src/plugins/settings/groups/guild/modules/index.ts new file mode 100644 index 0000000..9a5fcd6 --- /dev/null +++ b/src/plugins/settings/groups/guild/modules/index.ts @@ -0,0 +1,8 @@ +import audits from "@plugins/settings/groups/guild/modules/audits"; +import credits from "@plugins/settings/groups/guild/modules/credits"; +import points from "@plugins/settings/groups/guild/modules/points"; +import pterodactyl from "@plugins/settings/groups/guild/modules/pterodactyl"; +import shop from "@plugins/settings/groups/guild/modules/shop"; +import welcome from "@plugins/settings/groups/guild/modules/welcome"; + +export default { audits, credits, points, pterodactyl, shop, welcome }; diff --git a/src/plugins/settings/guild/modules/points.ts b/src/plugins/settings/groups/guild/modules/points.ts similarity index 94% rename from src/plugins/settings/guild/modules/points.ts rename to src/plugins/settings/groups/guild/modules/points.ts index f484f22..75ea6a7 100644 --- a/src/plugins/settings/guild/modules/points.ts +++ b/src/plugins/settings/groups/guild/modules/points.ts @@ -1,5 +1,5 @@ // Dependencies -import { CommandInteraction } from "discord.js"; +import { CommandInteraction, Permissions } from "discord.js"; // Configurations import { successColor, footerText, footerIcon } from "@config/embed"; @@ -13,6 +13,12 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Function export default { + meta: { + guildOnly: true, + ephemeral: true, + permissions: [Permissions.FLAGS.MANAGE_GUILD], + }, + data: (command: SlashCommandSubcommandBuilder) => { return command .setName("points") diff --git a/src/plugins/settings/guild/modules/pterodactyl.ts b/src/plugins/settings/groups/guild/modules/pterodactyl.ts similarity index 91% rename from src/plugins/settings/guild/modules/pterodactyl.ts rename to src/plugins/settings/groups/guild/modules/pterodactyl.ts index 14b0bf4..b595b80 100644 --- a/src/plugins/settings/guild/modules/pterodactyl.ts +++ b/src/plugins/settings/groups/guild/modules/pterodactyl.ts @@ -1,5 +1,5 @@ // Dependencies -import { CommandInteraction } from "discord.js"; +import { CommandInteraction, Permissions } from "discord.js"; // Configurations import { successColor, footerText, footerIcon } from "@config/embed"; @@ -14,6 +14,12 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Function export default { + meta: { + guildOnly: true, + ephemeral: true, + permissions: [Permissions.FLAGS.MANAGE_GUILD], + }, + data: (command: SlashCommandSubcommandBuilder) => { return command .setName("pterodactyl") diff --git a/src/plugins/settings/guild/modules/shop.ts b/src/plugins/settings/groups/guild/modules/shop.ts similarity index 93% rename from src/plugins/settings/guild/modules/shop.ts rename to src/plugins/settings/groups/guild/modules/shop.ts index 2b20d87..785c161 100644 --- a/src/plugins/settings/guild/modules/shop.ts +++ b/src/plugins/settings/groups/guild/modules/shop.ts @@ -1,5 +1,5 @@ // Dependencies -import { CommandInteraction } from "discord.js"; +import { CommandInteraction, Permissions } from "discord.js"; // Configurations import { successColor, footerText, footerIcon } from "@config/embed"; @@ -13,6 +13,12 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Function export default { + meta: { + guildOnly: true, + ephemeral: true, + permissions: [Permissions.FLAGS.MANAGE_GUILD], + }, + data: (command: SlashCommandSubcommandBuilder) => { return command .setName("shop") diff --git a/src/plugins/settings/guild/modules/welcome.ts b/src/plugins/settings/groups/guild/modules/welcome.ts similarity index 95% rename from src/plugins/settings/guild/modules/welcome.ts rename to src/plugins/settings/groups/guild/modules/welcome.ts index c8c8325..ad0c05b 100644 --- a/src/plugins/settings/guild/modules/welcome.ts +++ b/src/plugins/settings/groups/guild/modules/welcome.ts @@ -1,5 +1,5 @@ // Dependencies -import { CommandInteraction } from "discord.js"; +import { CommandInteraction, Permissions } from "discord.js"; // Configurations import { successColor, footerText, footerIcon } from "@config/embed"; @@ -14,6 +14,12 @@ import { ChannelType } from "discord-api-types/v10"; // Function export default { + meta: { + guildOnly: true, + ephemeral: true, + permissions: [Permissions.FLAGS.MANAGE_GUILD], + }, + data: (command: SlashCommandSubcommandBuilder) => { return command .setName("welcome") diff --git a/src/plugins/settings/groups/index.ts b/src/plugins/settings/groups/index.ts new file mode 100644 index 0000000..3271a99 --- /dev/null +++ b/src/plugins/settings/groups/index.ts @@ -0,0 +1,3 @@ +import guild from "@plugins/settings/groups/guild"; + +export default { guild }; diff --git a/src/plugins/settings/guild/index.ts b/src/plugins/settings/guild/index.ts deleted file mode 100644 index 37218bd..0000000 --- a/src/plugins/settings/guild/index.ts +++ /dev/null @@ -1,94 +0,0 @@ -// Dependencies -import { Permissions, CommandInteraction } from "discord.js"; - -// Configurations -import { errorColor, footerText, footerIcon } from "@config/embed"; - -// Handlers -import logger from "@logger"; - -// Modules -import pterodactyl from "./modules/pterodactyl"; -import credits from "./modules/credits"; -import points from "./modules/points"; -import welcome from "./modules/welcome"; -import audits from "./modules/audits"; -import shop from "./modules/shop"; -import { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders"; - -// Function -export default { - data: (group: SlashCommandSubcommandGroupBuilder) => { - return group - .setName("guild") - .setDescription("Guild settings.") - .addSubcommand(pterodactyl.data) - .addSubcommand(credits.data) - .addSubcommand(points.data) - .addSubcommand(welcome.data) - .addSubcommand(audits.data) - .addSubcommand(shop.data); - }, - execute: async (interaction: CommandInteraction) => { - // Destructure member - const { memberPermissions, options } = interaction; - - // Check permission - if (!memberPermissions?.has(Permissions?.FLAGS?.MANAGE_GUILD)) { - logger?.verbose(`User does not have permission to execute command.`); - - return interaction?.editReply({ - embeds: [ - { - title: ":tools: Settings - Guild", - color: errorColor, - description: "You do not have permission to use this command.", - timestamp: new Date(), - footer: { - iconURL: footerIcon as string, - text: footerText as string, - }, - }, - ], - }); - } - - if (options?.getSubcommand() === "pterodactyl") { - logger?.verbose(`Executing pterodactyl subcommand`); - - return pterodactyl.execute(interaction); - } - - if (options?.getSubcommand() === "credits") { - logger?.verbose(`Executing credits subcommand`); - - return credits.execute(interaction); - } - - if (options?.getSubcommand() === "points") { - logger?.verbose(`Executing points subcommand`); - - return points.execute(interaction); - } - - if (options?.getSubcommand() === "welcome") { - logger?.verbose(`Executing welcome subcommand`); - - return welcome.execute(interaction); - } - - if (options?.getSubcommand() === "audits") { - logger?.verbose(`Executing audit subcommand`); - - return audits.execute(interaction); - } - - if (options?.getSubcommand() === "shop") { - logger?.verbose(`Executing shop subcommand`); - - return shop.execute(interaction); - } - - logger?.verbose(`No subcommand found`); - }, -}; diff --git a/src/plugins/settings/index.ts b/src/plugins/settings/index.ts index a490fd2..c657e43 100644 --- a/src/plugins/settings/index.ts +++ b/src/plugins/settings/index.ts @@ -3,19 +3,20 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { CommandInteraction } from "discord.js"; // Groups -import guildGroup from "./guild"; +import groups from "./groups"; // Handlers import logger from "@logger"; // Function export default { - metadata: { author: "Zyner" }, + groups, + data: new SlashCommandBuilder() .setName("settings") .setDescription("Manage settings.") - .addSubcommandGroup(guildGroup.data), + .addSubcommandGroup(groups.guild.data), async execute(interaction: CommandInteraction) { const { options } = interaction; @@ -23,7 +24,7 @@ export default { if (options.getSubcommandGroup() === "guild") { logger.verbose(`Executing guild subcommand`); - return guildGroup.execute(interaction); + return groups.guild.execute(interaction); } logger.verbose(`No subcommand group found`); diff --git a/src/plugins/shop/groups/index.ts b/src/plugins/shop/groups/index.ts new file mode 100644 index 0000000..c1c25c9 --- /dev/null +++ b/src/plugins/shop/groups/index.ts @@ -0,0 +1,3 @@ +import roles from "./roles"; + +export default { roles }; diff --git a/src/plugins/shop/roles/index.ts b/src/plugins/shop/groups/roles/index.ts similarity index 84% rename from src/plugins/shop/roles/index.ts rename to src/plugins/shop/groups/roles/index.ts index 96ae1ca..26135e6 100644 --- a/src/plugins/shop/roles/index.ts +++ b/src/plugins/shop/groups/roles/index.ts @@ -3,24 +3,25 @@ import { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders"; import { CommandInteraction } from "discord.js"; // Handlers -import logger from "../../../logger"; +import logger from "@logger"; import { errorColor, footerText, footerIcon } from "@config/embed"; // Modules -import buy from "./modules/buy"; -import cancel from "./modules/cancel"; +import modules from "./modules"; import guildSchema from "@schemas/guild"; // Function export default { + modules, + data: (group: SlashCommandSubcommandGroupBuilder) => { return group .setName("roles") .setDescription("Shop for custom roles.") - .addSubcommand(buy.data) - .addSubcommand(cancel.data); + .addSubcommand(modules.buy.data) + .addSubcommand(modules.cancel.data); }, execute: async (interaction: CommandInteraction) => { const { options, guild } = interaction; @@ -53,13 +54,13 @@ export default { if (options?.getSubcommand() === "buy") { logger.verbose(`Executing buy subcommand`); - await buy.execute(interaction); + await modules.buy.execute(interaction); } if (options?.getSubcommand() === "cancel") { logger.verbose(`Executing cancel subcommand`); - await cancel.execute(interaction); + await modules.cancel.execute(interaction); } }, }; diff --git a/src/plugins/shop/roles/modules/buy.ts b/src/plugins/shop/groups/roles/modules/buy.ts similarity index 98% rename from src/plugins/shop/roles/modules/buy.ts rename to src/plugins/shop/groups/roles/modules/buy.ts index 4fa2980..1f8c54b 100644 --- a/src/plugins/shop/roles/modules/buy.ts +++ b/src/plugins/shop/groups/roles/modules/buy.ts @@ -25,6 +25,8 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Function export default { + meta: { guildOnly: true, ephemeral: true }, + data: (command: SlashCommandSubcommandBuilder) => { return command .setName("buy") diff --git a/src/plugins/shop/roles/modules/cancel.ts b/src/plugins/shop/groups/roles/modules/cancel.ts similarity index 98% rename from src/plugins/shop/roles/modules/cancel.ts rename to src/plugins/shop/groups/roles/modules/cancel.ts index 380ac42..b35ef16 100644 --- a/src/plugins/shop/roles/modules/cancel.ts +++ b/src/plugins/shop/groups/roles/modules/cancel.ts @@ -20,6 +20,8 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Function export default { + meta: { guildOnly: true, ephemeral: true }, + data: (command: SlashCommandSubcommandBuilder) => { return command .setName("cancel") diff --git a/src/plugins/shop/groups/roles/modules/index.ts b/src/plugins/shop/groups/roles/modules/index.ts new file mode 100644 index 0000000..b9e1626 --- /dev/null +++ b/src/plugins/shop/groups/roles/modules/index.ts @@ -0,0 +1,7 @@ +import buy from "./buy"; +import cancel from "./cancel"; + +export default { + buy, + cancel, +}; diff --git a/src/plugins/shop/index.ts b/src/plugins/shop/index.ts index 7d222a8..f9af6d4 100644 --- a/src/plugins/shop/index.ts +++ b/src/plugins/shop/index.ts @@ -3,35 +3,37 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { CommandInteraction } from "discord.js"; // Modules -import pterodactyl from "./modules/pterodactyl"; +import modules from "./modules"; // Groups -import roles from "./roles"; +import groups from "./groups"; // Handlers import logger from "../../logger"; // Function export default { - metadata: { author: "Zyner" }, + modules, + groups, + data: new SlashCommandBuilder() .setName("shop") .setDescription("Shop for credits and custom roles.") - .addSubcommand(pterodactyl.data) - .addSubcommandGroup(roles.data), + .addSubcommand(modules.pterodactyl.data) + .addSubcommandGroup(groups.roles.data), async execute(interaction: CommandInteraction) { const { options } = interaction; if (options?.getSubcommand() === "pterodactyl") { logger.verbose(`Executing pterodactyl subcommand`); - return pterodactyl.execute(interaction); + return modules.pterodactyl.execute(interaction); } if (options?.getSubcommandGroup() === "roles") { logger?.verbose(`Subcommand group is roles`); - return roles.execute(interaction); + return groups.roles.execute(interaction); } logger?.verbose(`No subcommand found.`); diff --git a/src/plugins/shop/modules/index.ts b/src/plugins/shop/modules/index.ts new file mode 100644 index 0000000..bc33df3 --- /dev/null +++ b/src/plugins/shop/modules/index.ts @@ -0,0 +1,3 @@ +import pterodactyl from "@plugins/shop/modules/pterodactyl"; + +export default { pterodactyl }; diff --git a/src/plugins/shop/modules/pterodactyl.ts b/src/plugins/shop/modules/pterodactyl.ts index 01cd120..9ada9fb 100644 --- a/src/plugins/shop/modules/pterodactyl.ts +++ b/src/plugins/shop/modules/pterodactyl.ts @@ -25,6 +25,8 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Function export default { + meta: { guildOnly: true, ephemeral: true }, + data: (command: SlashCommandSubcommandBuilder) => { return command .setName("pterodactyl") diff --git a/src/plugins/utility/index.ts b/src/plugins/utility/index.ts index ccb2128..69e6268 100644 --- a/src/plugins/utility/index.ts +++ b/src/plugins/utility/index.ts @@ -10,7 +10,8 @@ import logger from "../../logger"; // Function export default { - metadata: { author: "Zyner" }, + modules, + data: new SlashCommandBuilder() .setName("utility") .setDescription("Common utility.") diff --git a/src/plugins/utility/modules/about.ts b/src/plugins/utility/modules/about.ts index f618149..cfeb44e 100644 --- a/src/plugins/utility/modules/about.ts +++ b/src/plugins/utility/modules/about.ts @@ -9,6 +9,8 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Function export default { + meta: { guildOnly: false, ephemeral: false }, + data: (command: SlashCommandSubcommandBuilder) => { return command.setName("about").setDescription("About this bot!)"); }, diff --git a/src/plugins/utility/modules/avatar.ts b/src/plugins/utility/modules/avatar.ts index 81112ff..9f57fb3 100644 --- a/src/plugins/utility/modules/avatar.ts +++ b/src/plugins/utility/modules/avatar.ts @@ -5,6 +5,8 @@ import { CommandInteraction, MessageEmbed } from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; export default { + meta: { guildOnly: false, ephemeral: false }, + data: (command: SlashCommandSubcommandBuilder) => { return command .setName("avatar") diff --git a/src/plugins/utility/modules/lookup.ts b/src/plugins/utility/modules/lookup.ts index 6175418..73eb0bc 100644 --- a/src/plugins/utility/modules/lookup.ts +++ b/src/plugins/utility/modules/lookup.ts @@ -17,6 +17,8 @@ import logger from "@logger"; // Function export default { + meta: { guildOnly: false, ephemeral: false }, + data: (command: SlashCommandSubcommandBuilder) => { return command .setName("lookup") diff --git a/src/plugins/utility/modules/stats.ts b/src/plugins/utility/modules/stats.ts index 277f670..3b02684 100644 --- a/src/plugins/utility/modules/stats.ts +++ b/src/plugins/utility/modules/stats.ts @@ -2,6 +2,8 @@ import { successColor, footerText, footerIcon } from "@config/embed"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { CommandInteraction } from "discord.js"; export default { + meta: { guildOnly: false, ephemeral: false }, + data: (command: SlashCommandSubcommandBuilder) => { return command.setName("stats").setDescription("Check bot statistics!)"); }, From 8b9ab82e042edd5f80fb0404ac7478a5b34968c6 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 22 Apr 2022 17:57:09 +0200 Subject: [PATCH 038/142] Update source file plugins.json --- lang/en/plugins.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lang/en/plugins.json b/lang/en/plugins.json index b3249da..35daf97 100644 --- a/lang/en/plugins.json +++ b/lang/en/plugins.json @@ -5,7 +5,7 @@ "general": { "title": "[:dollar:] Credits (Balance)" }, - "user_has_amount_credits": "{{user}} has {{amount}} credits", + "user_has_amount_credits": "<@{{user}}> has {{amount}} credits", "error01": { "description": "<@{{user}}> has no credits!" }, From 494a90bfd54857174b895fe0055b085630c94b71 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 22 Apr 2022 17:57:10 +0200 Subject: [PATCH 039/142] New translations plugins.json (Swedish) --- lang/sv/plugins.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lang/sv/plugins.json b/lang/sv/plugins.json index da84d21..1b16acc 100644 --- a/lang/sv/plugins.json +++ b/lang/sv/plugins.json @@ -30,16 +30,16 @@ "description": "Du har fått {{amount}} krediter från {{user}} med anledning av {{reason}}!" }, "success02": { - "description": "Successfully gifted {{amount}} credits to <@{{user}}> with reason {{reason}}!" + "description": "Du har fått {{amount}} krediter från {{user}} med anledning {{reason}}!" } }, "top": { "entry": "{{index}}. <@{{user}}> - {{amount}}", "success01": { - "description": "Top 10 users with the most credits." + "description": "Topp 10 användare med flest krediter." }, "general": { - "title": "[:dollar:] Credits (Top)" + "title": "[:dollar:] Krediter (Topp)" } } } @@ -48,10 +48,10 @@ "modules": { "avatar": { "general": { - "title": "[:hammer:] Utility (Avatar)" + "title": "[:hammer:] Verktyg (Avatar)" }, "success01": { - "description": "Here you have <@{{user}}> avatar!" + "description": "Här har du <@{{user}}> avatar!" } } } From a8af4582ade342580cbfb6e4492ada527e65d691 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 22 Apr 2022 19:07:08 +0200 Subject: [PATCH 040/142] =?UTF-8?q?=F0=9F=8C=90=20counters=20&=20credits?= =?UTF-8?q?=20&=20manage=20localization?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../interactionCreate/components/isCommand.ts | 11 ++-- src/plugins/counters/modules/view/index.ts | 51 +++++++++++------- src/plugins/credits/modules/work/index.ts | 52 ++++++++++++++----- .../groups/counters/modules/create/index.ts | 49 ++++++++++++----- .../groups/counters/modules/delete/index.ts | 47 ++++++++++++----- 5 files changed, 148 insertions(+), 62 deletions(-) diff --git a/src/events/interactionCreate/components/isCommand.ts b/src/events/interactionCreate/components/isCommand.ts index b763bb0..2f602f5 100644 --- a/src/events/interactionCreate/components/isCommand.ts +++ b/src/events/interactionCreate/components/isCommand.ts @@ -22,12 +22,17 @@ export default async (interaction: CommandInteraction) => { let meta; + const subcommand = + interaction.options.getSubcommand() === "delete" + ? "delete_" + : interaction.options.getSubcommand(); + if (!interaction.options.getSubcommandGroup(false)) { - meta = currentCommand.modules[interaction.options.getSubcommand()].meta; + meta = currentCommand.modules[subcommand].meta; } else { meta = currentCommand.groups[interaction.options.getSubcommandGroup()].modules[ - interaction.options.getSubcommand() + subcommand ].meta; } @@ -100,7 +105,7 @@ export default async (interaction: CommandInteraction) => { ); }) .catch(async (error: any) => { - logger?.error(error); + logger?.error(`${error}`); return interaction.editReply({ embeds: [ diff --git a/src/plugins/counters/modules/view/index.ts b/src/plugins/counters/modules/view/index.ts index 7dd8d52..7f4d1e0 100644 --- a/src/plugins/counters/modules/view/index.ts +++ b/src/plugins/counters/modules/view/index.ts @@ -10,6 +10,7 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChannelType } from "discord-api-types/v10"; import counterSchema from "@schemas/counter"; +import i18next from "i18next"; export default { meta: { guildOnly: true, ephemeral: false }, @@ -30,10 +31,23 @@ export default { }, execute: async (interaction: CommandInteraction) => { - const { options, guild } = interaction; + const { options, guild, locale } = interaction; const discordChannel = options?.getChannel("channel"); + const embed = new MessageEmbed() + .setTitle( + i18next.t("counters:modules:view:general:title", { + lng: locale, + ns: "plugins", + }) + ) + .setTimestamp(new Date()) + .setFooter({ + text: footerText, + iconURL: footerIcon, + }); + const counter = await counterSchema?.findOne({ guildId: guild?.id, channelId: discordChannel?.id, @@ -42,32 +56,31 @@ export default { if (counter === null) { return interaction?.editReply({ embeds: [ - new MessageEmbed() - .setTitle("[:1234:] Counters (View)") - .setDescription(`No counter found for channel ${discordChannel}!`) - .setTimestamp(new Date()) - .setColor(errorColor) - .setFooter({ - text: footerText, - iconURL: footerIcon, - }), + embed + .setDescription( + i18next.t("counters:modules:view:error01:description", { + lng: locale, + ns: "plugins", + channel: discordChannel, + }) + ) + .setColor(errorColor), ], }); } return interaction?.editReply({ embeds: [ - new MessageEmbed() - .setTitle("[:1234:] Counters (View)") + embed .setDescription( - `Viewing counter for channel ${discordChannel} with count ${counter.counter}.` + i18next.t("counters:modules:view:success01:description", { + lng: locale, + ns: "plugins", + channel: discordChannel, + amount: counter.counter, + }) ) - .setTimestamp(new Date()) - .setColor(successColor) - .setFooter({ - text: footerText, - iconURL: footerIcon, - }), + .setColor(successColor), ], }); }, diff --git a/src/plugins/credits/modules/work/index.ts b/src/plugins/credits/modules/work/index.ts index 4ad9d13..37d743c 100644 --- a/src/plugins/credits/modules/work/index.ts +++ b/src/plugins/credits/modules/work/index.ts @@ -4,7 +4,12 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import Chance from "chance"; // Configurations -import { successColor, footerText, footerIcon } from "@config/embed"; +import { + successColor, + errorColor, + footerText, + footerIcon, +} from "@config/embed"; // Handlers import logger from "@logger"; @@ -15,6 +20,7 @@ import timeoutSchema from "@schemas/timeout"; // Helpers import fetchUser from "@helpers/fetchUser"; import fetchGuild from "@helpers/fetchGuild"; +import i18next from "i18next"; export default { meta: { guildOnly: true, ephemeral: true }, @@ -24,7 +30,20 @@ export default { }, execute: async (interaction: CommandInteraction) => { // Destructure member - const { guild, user } = interaction; + const { guild, user, locale } = interaction; + + const embed = new MessageEmbed() + .setTitle( + i18next.t("credits:modules:work:general:title", { + lng: locale, + ns: "plugins", + }) + ) + .setTimestamp(new Date()) + .setFooter({ + text: footerText, + iconURL: footerIcon, + }); // Chance module const chance = new Chance(); @@ -48,14 +67,15 @@ export default { return interaction.editReply({ embeds: [ - new MessageEmbed() - .setTitle("[:dollar:] Credits (Work)") + embed .setDescription( - `You can not work while on timeout, please wait ${guildDB?.credits.workTimeout} seconds.` + i18next.t("credits:modules:work:error01:description", { + lng: locale, + ns: "plugins", + time: guildDB?.credits.workTimeout, + }) ) - .setTimestamp(new Date()) - .setColor(successColor) - .setFooter({ text: footerText, iconURL: footerIcon }), + .setColor(errorColor), ], }); } @@ -80,12 +100,16 @@ export default { return interaction.editReply({ embeds: [ - new MessageEmbed() - .setTitle("[:dollar:] Credits (Work)") - .setDescription(`You worked and earned ${creditsEarned} credits`) - .setTimestamp(new Date()) - .setColor(successColor) - .setFooter({ text: footerText, iconURL: footerIcon }), + embed + .setDescription( + i18next.t("credits:modules:work:success01:description", { + lng: locale, + ns: "plugins", + time: guildDB?.credits.workTimeout, + amount: creditsEarned, + }) + ) + .setColor(successColor), ], }); }); diff --git a/src/plugins/manage/groups/counters/modules/create/index.ts b/src/plugins/manage/groups/counters/modules/create/index.ts index f23723c..c641764 100644 --- a/src/plugins/manage/groups/counters/modules/create/index.ts +++ b/src/plugins/manage/groups/counters/modules/create/index.ts @@ -16,6 +16,7 @@ import logger from "@logger"; // Models import counterSchema from "@schemas/counter"; +import i18next from "i18next"; // Function export default { @@ -49,12 +50,22 @@ export default { ); }, execute: async (interaction: CommandInteraction) => { - const { options, guild } = interaction; + const { options, guild, locale } = interaction; const discordChannel = options?.getChannel("channel"); const countingWord = options?.getString("word"); const startValue = options?.getNumber("start"); + const embed = new MessageEmbed() + .setTitle( + i18next.t("manage:groups:counters:modules:create:general:title", { + lng: locale, + ns: "plugins", + }) + ) + .setTimestamp(new Date()) + .setFooter({ text: footerText, iconURL: footerIcon }); + const counter = await counterSchema?.findOne({ guildId: guild?.id, channelId: discordChannel?.id, @@ -63,12 +74,18 @@ export default { if (counter) { return interaction?.editReply({ embeds: [ - new MessageEmbed() - .setTitle("[:toolbox:] Manage - Counters (Create)") - .setDescription(`A counter already exists for this channel.`) - .setTimestamp(new Date()) - .setColor(errorColor) - .setFooter({ text: footerText, iconURL: footerIcon }), + embed + .setDescription( + i18next.t( + "manage:groups:counters:modules:create:error01:description", + { + lng: locale, + ns: "plugins", + channel: discordChannel, + } + ) + ) + .setColor(errorColor), ], }); } @@ -85,12 +102,18 @@ export default { return interaction?.editReply({ embeds: [ - new MessageEmbed() - .setTitle("[:toolbox:] Manage - Counters (Create)") - .setDescription(`Created counter for ${discordChannel}`) - .setTimestamp(new Date()) - .setColor(successColor) - .setFooter({ text: footerText, iconURL: footerIcon }), + embed + .setDescription( + i18next.t( + "manage:groups:counters:modules:create:success01:description", + { + lng: locale, + ns: "plugins", + channel: discordChannel, + } + ) + ) + .setColor(successColor), ], }); }); diff --git a/src/plugins/manage/groups/counters/modules/delete/index.ts b/src/plugins/manage/groups/counters/modules/delete/index.ts index 3035fa8..989b1ec 100644 --- a/src/plugins/manage/groups/counters/modules/delete/index.ts +++ b/src/plugins/manage/groups/counters/modules/delete/index.ts @@ -16,6 +16,7 @@ import logger from "@logger"; import counterSchema from "@schemas/counter"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChannelType } from "discord-api-types/v10"; +import i18next from "i18next"; // Function export default { @@ -38,10 +39,20 @@ export default { ); }, execute: async (interaction: CommandInteraction) => { - const { options, guild } = interaction; + const { options, guild, locale } = interaction; const discordChannel = options?.getChannel("channel"); + const embed = new MessageEmbed() + .setTitle( + i18next.t("manage:groups:counters:modules:delete:general:title", { + lng: locale, + ns: "plugins", + }) + ) + .setTimestamp(new Date()) + .setFooter({ text: footerText, iconURL: footerIcon }); + const counter = await counterSchema?.findOne({ guildId: guild?.id, channelId: discordChannel?.id, @@ -52,12 +63,17 @@ export default { return interaction?.editReply({ embeds: [ - new MessageEmbed() - .setTitle("[:toolbox:] Manage - Counters (Delete)") - .setDescription(`The counter for this channel does not exist.`) - .setTimestamp(new Date()) - .setColor(errorColor) - .setFooter({ text: footerText, iconURL: footerIcon }), + embed + .setDescription( + i18next.t( + "manage:groups:counters:modules:delete:error01:description", + { + lng: locale, + ns: "plugins", + } + ) + ) + .setColor(errorColor), ], }); } @@ -72,12 +88,17 @@ export default { return interaction?.editReply({ embeds: [ - new MessageEmbed() - .setTitle("[:toolbox:] Manage - Counters (Delete)") - .setDescription(`The counter for this channel has been deleted.`) - .setTimestamp(new Date()) - .setColor(successColor) - .setFooter({ text: footerText, iconURL: footerIcon }), + embed + .setDescription( + i18next.t( + "manage:groups:counters:modules:delete:success01:description", + { + lng: locale, + ns: "plugins", + } + ) + ) + .setColor(successColor), ], }); }) From 700a5c37982ccb45db15e032cdde3489f7c38492 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 22 Apr 2022 19:11:01 +0200 Subject: [PATCH 041/142] Update source file plugins.json --- lang/en/plugins.json | 56 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/lang/en/plugins.json b/lang/en/plugins.json index 35daf97..45bd203 100644 --- a/lang/en/plugins.json +++ b/lang/en/plugins.json @@ -41,6 +41,17 @@ "general": { "title": "[:dollar:] Credits (Top)" } + }, + "work": { + "general": { + "title": "[:dollar:] Credits (Work)" + }, + "error01": { + "description": "You can not work while on timeout, please wait {{time}} seconds." + }, + "success01": { + "description": "You worked and earned {{amount}} credits" + } } } }, @@ -55,5 +66,50 @@ } } } + }, + "counters": { + "modules": { + "view": { + "general": { + "title": "[:1234:] Counters (View)" + }, + "error01": { + "description": "No counter found for channel <#{{channel}}>!" + }, + "success01": { + "description": "Viewing counter for channel <#{{channel}} with count {{amount}}." + } + } + } + }, + "manage": { + "groups": { + "counters": { + "modules": { + "create": { + "general": { + "title": "[:toolbox:] Manage - Counters (Create)" + }, + "success01": { + "description": "Created counter for <#{{channel}}>." + }, + "error01": { + "description": "A counter already exists for this channel." + } + }, + "delete": { + "general": { + "title": "[:toolbox:] Manage - Counters (Delete)" + }, + "error01": { + "description": "The counter for this channel does not exist." + }, + "success01": { + "description": "The counter for this channel has been deleted." + } + } + } + } + } } } From 9f20ecb8f0c2157fe10321f41a7c6c5bf5dc3550 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 22 Apr 2022 19:11:02 +0200 Subject: [PATCH 042/142] New translations plugins.json (Swedish) --- lang/sv/plugins.json | 56 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/lang/sv/plugins.json b/lang/sv/plugins.json index 1b16acc..9aadec8 100644 --- a/lang/sv/plugins.json +++ b/lang/sv/plugins.json @@ -41,6 +41,17 @@ "general": { "title": "[:dollar:] Krediter (Topp)" } + }, + "work": { + "general": { + "title": "[:dollar:] Krediter (Arbeta)" + }, + "error01": { + "description": "Du kan inte arbeta under tiden du har paus, vänta {{time}} sekunder." + }, + "success01": { + "description": "Du arbetade och tjänade {{amount}} krediter" + } } } }, @@ -55,5 +66,50 @@ } } } + }, + "counters": { + "modules": { + "view": { + "general": { + "title": "[:1234:] Räknare (Visa)" + }, + "error01": { + "description": "Ingen räknare hittades för kanal <#{{channel}}>!" + }, + "success01": { + "description": "Visar räknaren för kanal <#{{channel}} med antal {{amount}}." + } + } + } + }, + "manage": { + "groups": { + "counters": { + "modules": { + "create": { + "general": { + "title": "[:toolbox:] Hantera - Räknare (Skapa)" + }, + "success01": { + "description": "Skapade räknare för <#{{channel}}>." + }, + "error01": { + "description": "En räknare finns redan för denna kanal." + } + }, + "delete": { + "general": { + "title": "[:toolbox:] Hantera - Räknare (Ta bort)" + }, + "error01": { + "description": "Räknaren för denna kanal finns inte." + }, + "success01": { + "description": "Räknaren för denna kanal har tagits bort." + } + } + } + } + } } } From b04d015edaa218e27fe91188447696714cae984b Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 22 Apr 2022 19:11:02 +0200 Subject: [PATCH 043/142] New translations plugins.json (English) --- lang/en/plugins.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lang/en/plugins.json b/lang/en/plugins.json index 45bd203..1a11db8 100644 --- a/lang/en/plugins.json +++ b/lang/en/plugins.json @@ -5,7 +5,7 @@ "general": { "title": "[:dollar:] Credits (Balance)" }, - "user_has_amount_credits": "<@{{user}}> has {{amount}} credits", + "user_has_amount_credits": "{{user}} has {{amount}} credits", "error01": { "description": "<@{{user}}> has no credits!" }, From 71329c5ecafd213feb6baa0d7f7f34e35054b9f8 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 22 Apr 2022 19:11:03 +0200 Subject: [PATCH 044/142] New translations plugins.json (German) --- lang/de/plugins.json | 56 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/lang/de/plugins.json b/lang/de/plugins.json index 35daf97..45bd203 100644 --- a/lang/de/plugins.json +++ b/lang/de/plugins.json @@ -41,6 +41,17 @@ "general": { "title": "[:dollar:] Credits (Top)" } + }, + "work": { + "general": { + "title": "[:dollar:] Credits (Work)" + }, + "error01": { + "description": "You can not work while on timeout, please wait {{time}} seconds." + }, + "success01": { + "description": "You worked and earned {{amount}} credits" + } } } }, @@ -55,5 +66,50 @@ } } } + }, + "counters": { + "modules": { + "view": { + "general": { + "title": "[:1234:] Counters (View)" + }, + "error01": { + "description": "No counter found for channel <#{{channel}}>!" + }, + "success01": { + "description": "Viewing counter for channel <#{{channel}} with count {{amount}}." + } + } + } + }, + "manage": { + "groups": { + "counters": { + "modules": { + "create": { + "general": { + "title": "[:toolbox:] Manage - Counters (Create)" + }, + "success01": { + "description": "Created counter for <#{{channel}}>." + }, + "error01": { + "description": "A counter already exists for this channel." + } + }, + "delete": { + "general": { + "title": "[:toolbox:] Manage - Counters (Delete)" + }, + "error01": { + "description": "The counter for this channel does not exist." + }, + "success01": { + "description": "The counter for this channel has been deleted." + } + } + } + } + } } } From 951a59dbeab968082ae843b80ce328ccf94dd636 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Fri, 22 Apr 2022 21:56:07 +0000 Subject: [PATCH 045/142] Update dependency eslint to v8.14.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b5ca226..913135d 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@types/uuid": "^8.3.4", "@typescript-eslint/eslint-plugin": "^5.15.0", "@typescript-eslint/parser": "^5.15.0", - "eslint": "8.13.0", + "eslint": "8.14.0", "eslint-config-airbnb-base": "15.0.0", "eslint-config-prettier": "8.5.0", "eslint-plugin-import": "2.26.0", From 50fbcd8d0b1544409f3f3d051af309e380dec220 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sat, 23 Apr 2022 00:00:04 +0200 Subject: [PATCH 046/142] Update source file plugins.json --- lang/en/plugins.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lang/en/plugins.json b/lang/en/plugins.json index 1a11db8..45bd203 100644 --- a/lang/en/plugins.json +++ b/lang/en/plugins.json @@ -5,7 +5,7 @@ "general": { "title": "[:dollar:] Credits (Balance)" }, - "user_has_amount_credits": "{{user}} has {{amount}} credits", + "user_has_amount_credits": "<@{{user}}> has {{amount}} credits", "error01": { "description": "<@{{user}}> has no credits!" }, From b8fbefadc94b5de0ad772fee44f856316598351a Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Mon, 25 Apr 2022 12:57:23 +0000 Subject: [PATCH 047/142] Update dependency jest to v28 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b5ca226..814d8e3 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "eslint-plugin-no-loops": "^0.3.0", "eslint-plugin-prettier": "^4.0.0", "husky": "^7.0.0", - "jest": "^27.5.1", + "jest": "28.0.0", "lint-staged": "^12.3.7", "prettier": "^2.6.0" }, From bb046e3c8b76d740100c2eb357475e0a4f204bc9 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Mon, 25 Apr 2022 15:40:21 +0000 Subject: [PATCH 048/142] Update dependency discord-api-types to ^0.32.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b5ca226..ac3ef1d 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "chance": "^1.1.8", "common": "^0.2.5", "crypto": "^1.0.1", - "discord-api-types": "^0.31.0", + "discord-api-types": "^0.32.0", "discord.js": "^13.6.0", "i18next": "^21.6.13", "mongoose": "^6.2.3", From 50e3b480c9e2bd63a1a25a32b0b951cf0d054585 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Mon, 25 Apr 2022 18:25:08 +0000 Subject: [PATCH 049/142] Update dependency axios to ^0.27.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b5ca226..86c75ac 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "dependencies": { "@discordjs/builders": "^0.12.0", "@discordjs/rest": "^0.4.0", - "axios": "^0.26.0", + "axios": "^0.27.0", "chance": "^1.1.8", "common": "^0.2.5", "crypto": "^1.0.1", From adef2257300636eb3640459a59028413a3211f39 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Tue, 26 Apr 2022 12:01:18 +0200 Subject: [PATCH 050/142] Update isCommand.ts --- src/events/interactionCreate/components/isCommand.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/events/interactionCreate/components/isCommand.ts b/src/events/interactionCreate/components/isCommand.ts index 2f602f5..2070c49 100644 --- a/src/events/interactionCreate/components/isCommand.ts +++ b/src/events/interactionCreate/components/isCommand.ts @@ -16,10 +16,6 @@ export default async (interaction: CommandInteraction) => { logger.verbose(`Command ${commandName} not found`); } - // logger.warn(currentCommand.modules[interaction.options.getSubcommand()].meta); - - // const meta = { ephemeral: false, guildOnly: false }; - let meta; const subcommand = From 04e155e41480706be49cdf48e1b6df4a0f11b0ac Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Tue, 26 Apr 2022 12:02:17 +0200 Subject: [PATCH 051/142] Update index.ts --- src/plugins/manage/index.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/plugins/manage/index.ts b/src/plugins/manage/index.ts index aecedf5..4fb4165 100644 --- a/src/plugins/manage/index.ts +++ b/src/plugins/manage/index.ts @@ -1,9 +1,6 @@ //Dependencies import { SlashCommandBuilder } from "@discordjs/builders"; -import { CommandInteraction, Permissions, MessageEmbed } from "discord.js"; - -// Configurations -import { errorColor, footerText, footerIcon } from "@config/embed"; +import { CommandInteraction } from "discord.js"; // Groups import groups from "@plugins/manage/groups"; From 13891d9f80fa8888f6a66c0056ae67f7098e46bd Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Tue, 26 Apr 2022 12:03:22 +0200 Subject: [PATCH 052/142] Update index.ts --- src/plugins/settings/groups/guild/index.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/plugins/settings/groups/guild/index.ts b/src/plugins/settings/groups/guild/index.ts index cfd2fe6..b1344e1 100644 --- a/src/plugins/settings/groups/guild/index.ts +++ b/src/plugins/settings/groups/guild/index.ts @@ -1,8 +1,5 @@ // Dependencies -import { Permissions, CommandInteraction } from "discord.js"; - -// Configurations -import { errorColor, footerText, footerIcon } from "@config/embed"; +import { CommandInteraction } from "discord.js"; // Handlers import logger from "@logger"; From aeb0415d0000bf944a4372f5f4e5c0acf0c35f1a Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Tue, 26 Apr 2022 12:17:22 +0200 Subject: [PATCH 053/142] Create source file errors.json --- lang/en/errors.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 lang/en/errors.json diff --git a/lang/en/errors.json b/lang/en/errors.json new file mode 100644 index 0000000..225d04b --- /dev/null +++ b/lang/en/errors.json @@ -0,0 +1,7 @@ +{ + "errors": { + "guildOnly": "You can only use this command in a guild!", + "userNotFound": "Could not find user <@{{user}}>.", + "amountNotFound": "We could not read your requested amount!" + } +} From 89b500ff2cb46e4bf7789262fd115ff6c8b051f1 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Tue, 26 Apr 2022 12:17:22 +0200 Subject: [PATCH 054/142] Update source file plugins.json --- lang/en/plugins.json | 114 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 113 insertions(+), 1 deletion(-) diff --git a/lang/en/plugins.json b/lang/en/plugins.json index 24e05e9..45bd203 100644 --- a/lang/en/plugins.json +++ b/lang/en/plugins.json @@ -1,3 +1,115 @@ { - "test":"test" + "credits": { + "modules": { + "balance": { + "general": { + "title": "[:dollar:] Credits (Balance)" + }, + "user_has_amount_credits": "<@{{user}}> has {{amount}} credits", + "error01": { + "description": "<@{{user}}> has no credits!" + }, + "success01": { + "description": "<@{{user}}> has {{amount}} credits!\n" + } + }, + "gift": { + "general": { + "title": "[:dollar:] Credits (Gift)" + }, + "error01": { + "description": "You can not pay yourself!" + }, + "error02": { + "description": "You can't gift zero or below!" + }, + "error03": { + "description": "You have insufficient credits. Your balance is {{amount}}!" + }, + "success01": { + "description": "You have received {{amount}} credits from {{user}} with reason {{reason}}!" + }, + "success02": { + "description": "Successfully gifted {{amount}} credits to <@{{user}}> with reason {{reason}}!" + } + }, + "top": { + "entry": "{{index}}. <@{{user}}> - {{amount}}", + "success01": { + "description": "Top 10 users with the most credits." + }, + "general": { + "title": "[:dollar:] Credits (Top)" + } + }, + "work": { + "general": { + "title": "[:dollar:] Credits (Work)" + }, + "error01": { + "description": "You can not work while on timeout, please wait {{time}} seconds." + }, + "success01": { + "description": "You worked and earned {{amount}} credits" + } + } + } + }, + "utility": { + "modules": { + "avatar": { + "general": { + "title": "[:hammer:] Utility (Avatar)" + }, + "success01": { + "description": "Here you have <@{{user}}> avatar!" + } + } + } + }, + "counters": { + "modules": { + "view": { + "general": { + "title": "[:1234:] Counters (View)" + }, + "error01": { + "description": "No counter found for channel <#{{channel}}>!" + }, + "success01": { + "description": "Viewing counter for channel <#{{channel}} with count {{amount}}." + } + } + } + }, + "manage": { + "groups": { + "counters": { + "modules": { + "create": { + "general": { + "title": "[:toolbox:] Manage - Counters (Create)" + }, + "success01": { + "description": "Created counter for <#{{channel}}>." + }, + "error01": { + "description": "A counter already exists for this channel." + } + }, + "delete": { + "general": { + "title": "[:toolbox:] Manage - Counters (Delete)" + }, + "error01": { + "description": "The counter for this channel does not exist." + }, + "success01": { + "description": "The counter for this channel has been deleted." + } + } + } + } + } + } } From c486ea6e9143f2b75df103ff661c0ab63da7afbe Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Tue, 26 Apr 2022 12:39:25 +0200 Subject: [PATCH 055/142] Update isCommand.ts --- src/events/interactionCreate/components/isCommand.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/events/interactionCreate/components/isCommand.ts b/src/events/interactionCreate/components/isCommand.ts index 2070c49..5646d70 100644 --- a/src/events/interactionCreate/components/isCommand.ts +++ b/src/events/interactionCreate/components/isCommand.ts @@ -18,10 +18,7 @@ export default async (interaction: CommandInteraction) => { let meta; - const subcommand = - interaction.options.getSubcommand() === "delete" - ? "delete_" - : interaction.options.getSubcommand(); + const subcommand = interaction.options.getSubcommand() if (!interaction.options.getSubcommandGroup(false)) { meta = currentCommand.modules[subcommand].meta; From 3515f501aeb53c614fe6499c272327039018919c Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Tue, 26 Apr 2022 12:40:10 +0200 Subject: [PATCH 056/142] Update and rename src/plugins/manage/groups/counters/modules/create/index.ts to src/plugins/manage/groups/counters/modules/add/index.ts --- .../manage/groups/counters/modules/{create => add}/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename src/plugins/manage/groups/counters/modules/{create => add}/index.ts (94%) diff --git a/src/plugins/manage/groups/counters/modules/create/index.ts b/src/plugins/manage/groups/counters/modules/add/index.ts similarity index 94% rename from src/plugins/manage/groups/counters/modules/create/index.ts rename to src/plugins/manage/groups/counters/modules/add/index.ts index c641764..5320937 100644 --- a/src/plugins/manage/groups/counters/modules/create/index.ts +++ b/src/plugins/manage/groups/counters/modules/add/index.ts @@ -28,7 +28,7 @@ export default { data: (command: SlashCommandSubcommandBuilder) => { return command - .setName("create") + .setName("add") .setDescription("Add a counter to your guild.") .addChannelOption((option) => option @@ -58,7 +58,7 @@ export default { const embed = new MessageEmbed() .setTitle( - i18next.t("manage:groups:counters:modules:create:general:title", { + i18next.t("manage:groups:counters:modules:add:general:title", { lng: locale, ns: "plugins", }) @@ -77,7 +77,7 @@ export default { embed .setDescription( i18next.t( - "manage:groups:counters:modules:create:error01:description", + "manage:groups:counters:modules:add:error01:description", { lng: locale, ns: "plugins", From b31d5970ced35f89bc22da4cc7891fb34c9b2b8b Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Tue, 26 Apr 2022 12:41:17 +0200 Subject: [PATCH 057/142] Update and rename src/plugins/manage/groups/counters/modules/delete/index.ts to src/plugins/manage/groups/counters/modules/remove/index.ts --- .../groups/counters/modules/{delete => remove}/index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) rename src/plugins/manage/groups/counters/modules/{delete => remove}/index.ts (92%) diff --git a/src/plugins/manage/groups/counters/modules/delete/index.ts b/src/plugins/manage/groups/counters/modules/remove/index.ts similarity index 92% rename from src/plugins/manage/groups/counters/modules/delete/index.ts rename to src/plugins/manage/groups/counters/modules/remove/index.ts index 989b1ec..b707b45 100644 --- a/src/plugins/manage/groups/counters/modules/delete/index.ts +++ b/src/plugins/manage/groups/counters/modules/remove/index.ts @@ -28,7 +28,7 @@ export default { data: (command: SlashCommandSubcommandBuilder) => { return command - .setName("delete") + .setName("remove") .setDescription(`Delete a counter from your guild.`) .addChannelOption((option) => option @@ -45,7 +45,7 @@ export default { const embed = new MessageEmbed() .setTitle( - i18next.t("manage:groups:counters:modules:delete:general:title", { + i18next.t("manage:groups:counters:modules:remove:general:title", { lng: locale, ns: "plugins", }) @@ -66,7 +66,7 @@ export default { embed .setDescription( i18next.t( - "manage:groups:counters:modules:delete:error01:description", + "manage:groups:counters:modules:remove:error01:description", { lng: locale, ns: "plugins", @@ -91,7 +91,7 @@ export default { embed .setDescription( i18next.t( - "manage:groups:counters:modules:delete:success01:description", + "manage:groups:counters:modules:remove:success01:description", { lng: locale, ns: "plugins", From 14efd19978b00a5f8766d91cda401ef745d1783f Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Tue, 26 Apr 2022 12:41:33 +0200 Subject: [PATCH 058/142] Update index.ts --- src/plugins/manage/groups/counters/modules/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/manage/groups/counters/modules/index.ts b/src/plugins/manage/groups/counters/modules/index.ts index 37cb7aa..e623f48 100644 --- a/src/plugins/manage/groups/counters/modules/index.ts +++ b/src/plugins/manage/groups/counters/modules/index.ts @@ -1,4 +1,4 @@ -import create from "@plugins/manage/groups/counters/modules/create"; -import delete_ from "@plugins/manage/groups/counters/modules/delete"; +import add from "@plugins/manage/groups/counters/modules/add"; +import remove from "@plugins/manage/groups/counters/modules/remove"; -export default { create, delete_ }; +export default { add, remove }; From 20822764853ebe76055709d32351a41fdaad8a56 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Tue, 26 Apr 2022 12:42:04 +0200 Subject: [PATCH 059/142] Update index.ts --- src/plugins/manage/groups/counters/index.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/plugins/manage/groups/counters/index.ts b/src/plugins/manage/groups/counters/index.ts index fec6a1d..2a16b04 100644 --- a/src/plugins/manage/groups/counters/index.ts +++ b/src/plugins/manage/groups/counters/index.ts @@ -15,23 +15,23 @@ export default { return group .setName("counters") .setDescription("Manage guild counters.") - .addSubcommand(modules.create.data) - .addSubcommand(modules.delete_.data); + .addSubcommand(modules.add.data) + .addSubcommand(modules.remove.data); }, execute: async (interaction: CommandInteraction) => { const { options } = interaction; - if (options?.getSubcommand() === "create") { + if (options?.getSubcommand() === "add") { logger?.verbose(`Executing create subcommand`); - return modules.create.execute(interaction); + return modules.add.execute(interaction); } - if (options?.getSubcommand() === "delete") { + if (options?.getSubcommand() === "remove") { logger?.verbose(`Executing delete subcommand`); - return modules.delete_.execute(interaction); + return modules.remove.execute(interaction); } logger?.verbose(`Unknown subcommand ${options?.getSubcommand()}`); From be6518524c9bbd0a2ca82d806a7ad68f6d963d36 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sat, 30 Apr 2022 15:12:40 +0200 Subject: [PATCH 060/142] =?UTF-8?q?=F0=9F=8C=90=20now=20loading=20from=20j?= =?UTF-8?q?son=20files?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 + src/events/guildCreate/index.ts | 3 ++- src/events/guildDelete/index.ts | 3 ++- src/events/guildMemberAdd/index.ts | 1 - src/events/guildMemberRemove/index.ts | 1 - src/events/interactionCreate/index.ts | 1 - src/events/messageCreate/index.ts | 1 - src/events/messageDelete/index.ts | 1 - src/events/messageUpdate/index.ts | 1 - src/events/ready/index.ts | 1 - src/handlers/events.ts | 4 ++-- src/locale/index.ts | 26 ++++++++++---------------- 12 files changed, 17 insertions(+), 27 deletions(-) diff --git a/package.json b/package.json index 7dcc8e3..f81a6c7 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "discord-api-types": "^0.31.0", "discord.js": "^13.6.0", "i18next": "^21.6.13", + "i18next-async-backend": "^2.0.0", "i18next-resources-to-backend": "^1.0.0", "mongoose": "^6.2.3", "node-schedule": "^2.1.0", diff --git a/src/events/guildCreate/index.ts b/src/events/guildCreate/index.ts index a55d9d5..31e87b2 100644 --- a/src/events/guildCreate/index.ts +++ b/src/events/guildCreate/index.ts @@ -7,7 +7,6 @@ import fetchGuild from "@helpers/fetchGuild"; import logger from "@logger"; export default { - name: "guildCreate", async execute(guild: Guild) { const { client } = guild; @@ -15,5 +14,7 @@ export default { await fetchGuild(guild); await updatePresence(client); + + logger.silly(`guildCreate: ${guild}`); }, }; diff --git a/src/events/guildDelete/index.ts b/src/events/guildDelete/index.ts index 9a0ceec..6da6f4a 100644 --- a/src/events/guildDelete/index.ts +++ b/src/events/guildDelete/index.ts @@ -7,7 +7,6 @@ import dropGuild from "@helpers/dropGuild"; import logger from "@logger"; export default { - name: "guildDelete", async execute(guild: Guild) { const { client } = guild; @@ -15,5 +14,7 @@ export default { await dropGuild(guild); await updatePresence(client); + + logger.silly(`guildDelete: ${guild}`); }, }; diff --git a/src/events/guildMemberAdd/index.ts b/src/events/guildMemberAdd/index.ts index 4b2cbe0..b99d7ad 100644 --- a/src/events/guildMemberAdd/index.ts +++ b/src/events/guildMemberAdd/index.ts @@ -9,7 +9,6 @@ import joinMessage from "../guildMemberAdd/joinMessage"; import audits from "../guildMemberAdd/audits"; export default { - name: "guildMemberAdd", async execute(member: GuildMember) { const { client, user, guild } = member; diff --git a/src/events/guildMemberRemove/index.ts b/src/events/guildMemberRemove/index.ts index e2fe667..332f143 100644 --- a/src/events/guildMemberRemove/index.ts +++ b/src/events/guildMemberRemove/index.ts @@ -9,7 +9,6 @@ import leaveMessage from "./leaveMessage"; import audits from "./audits"; export default { - name: "guildMemberRemove", async execute(member: GuildMember) { const { client, user, guild } = member; diff --git a/src/events/interactionCreate/index.ts b/src/events/interactionCreate/index.ts index fb35bc9..befd29f 100644 --- a/src/events/interactionCreate/index.ts +++ b/src/events/interactionCreate/index.ts @@ -7,7 +7,6 @@ import logger from "@logger"; import audits from "./audits"; export default { - name: "interactionCreate", async execute(interaction: CommandInteraction) { const { guild, id } = interaction; diff --git a/src/events/messageCreate/index.ts b/src/events/messageCreate/index.ts index 029568a..004ca71 100644 --- a/src/events/messageCreate/index.ts +++ b/src/events/messageCreate/index.ts @@ -2,7 +2,6 @@ import { Message } from "discord.js"; import modules from "@events/messageCreate/modules"; export default { - name: "messageCreate", async execute(message: Message) { await modules.credits.execute(message); await modules.points.execute(message); diff --git a/src/events/messageDelete/index.ts b/src/events/messageDelete/index.ts index 286c99a..77223d2 100644 --- a/src/events/messageDelete/index.ts +++ b/src/events/messageDelete/index.ts @@ -3,7 +3,6 @@ import audits from "@events/messageDelete/audits"; import counter from "./modules/counter"; export default { - name: "messageDelete", async execute(message: Message) { await audits.execute(message); await counter(message); diff --git a/src/events/messageUpdate/index.ts b/src/events/messageUpdate/index.ts index 2ea1e42..0ff405e 100644 --- a/src/events/messageUpdate/index.ts +++ b/src/events/messageUpdate/index.ts @@ -8,7 +8,6 @@ import counter from "./modules/counter"; import audits from "./audits"; export default { - name: "messageUpdate", async execute(oldMessage: Message, newMessage: Message) { const { author, guild } = newMessage; diff --git a/src/events/ready/index.ts b/src/events/ready/index.ts index b840bb3..4e7684f 100644 --- a/src/events/ready/index.ts +++ b/src/events/ready/index.ts @@ -8,7 +8,6 @@ import deployCommands from "@handlers/deployCommands"; import devMode from "@handlers/devMode"; export default { - name: "ready", once: true, async execute(client: Client) { logger.info(`${client.user?.tag} (${client.user?.id}) is ready`); diff --git a/src/handlers/events.ts b/src/handlers/events.ts index 1428325..4c7d778 100644 --- a/src/handlers/events.ts +++ b/src/handlers/events.ts @@ -15,12 +15,12 @@ export default async (client: Client) => { logger.verbose(`Loaded event: ${eventName}`); if (event.once) { - return client.once(event.default.name, async (...args) => + return client.once(eventName, async (...args) => event.default.execute(...args) ); } - return client.on(event.default.name, async (...args) => + return client.on(eventName, async (...args) => event.default.execute(...args) ); }) diff --git a/src/locale/index.ts b/src/locale/index.ts index 82c76b6..e5e13bc 100644 --- a/src/locale/index.ts +++ b/src/locale/index.ts @@ -1,26 +1,20 @@ import i18next from "i18next"; -import otaClient, { LanguageStrings } from "@crowdin/ota-client"; +import AsyncBackend from "i18next-async-backend"; import logger from "@logger"; -const client = new otaClient("ffd2068395f215046cc01f8lfji"); +const resources = { + en: { + errors: () => import("@root/lang/en/errors.json"), + plugins: () => import("@root/lang/en/plugins.json"), + }, +}; export default async () => { - //load needed information from Crowdin distribution - const languages = await client.listLanguages(); - const translations = await client.getStrings(); - const resources = {} as LanguageStrings; - - // eslint-disable-next-line no-loops/no-loops - for (const lngCode in translations) { - resources[lngCode] = translations[lngCode]; - } - //initialize i18next - await i18next.init({ - lng: languages[0], - supportedLngs: languages, - resources, + await i18next.use(AsyncBackend).init({ + backend: { resources }, }); + //i18next now can be used to translate your application logger.silly(i18next.store.data); }; From 1dddcd0251e316336ea5c370516640708f760828 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sat, 30 Apr 2022 15:31:22 +0200 Subject: [PATCH 061/142] =?UTF-8?q?=F0=9F=92=A5=20removing=20language=20su?= =?UTF-8?q?pport?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lang/en/plugins.json | 3 --- package.json | 1 + src/locale/index.ts | 20 -------------------- tsconfig.json | 1 + 4 files changed, 2 insertions(+), 23 deletions(-) delete mode 100644 lang/en/plugins.json delete mode 100644 src/locale/index.ts diff --git a/lang/en/plugins.json b/lang/en/plugins.json deleted file mode 100644 index 24e05e9..0000000 --- a/lang/en/plugins.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "test":"test" -} diff --git a/package.json b/package.json index f81a6c7..e395078 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "discord.js": "^13.6.0", "i18next": "^21.6.13", "i18next-async-backend": "^2.0.0", + "i18next-http-backend": "^1.4.0", "i18next-resources-to-backend": "^1.0.0", "mongoose": "^6.2.3", "node-schedule": "^2.1.0", diff --git a/src/locale/index.ts b/src/locale/index.ts deleted file mode 100644 index e5e13bc..0000000 --- a/src/locale/index.ts +++ /dev/null @@ -1,20 +0,0 @@ -import i18next from "i18next"; -import AsyncBackend from "i18next-async-backend"; - -import logger from "@logger"; - -const resources = { - en: { - errors: () => import("@root/lang/en/errors.json"), - plugins: () => import("@root/lang/en/plugins.json"), - }, -}; - -export default async () => { - await i18next.use(AsyncBackend).init({ - backend: { resources }, - }); - - //i18next now can be used to translate your application - logger.silly(i18next.store.data); -}; diff --git a/tsconfig.json b/tsconfig.json index 93449a5..6fda632 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,6 +12,7 @@ "moduleResolution": "node", "isolatedModules": true, "outDir": "./build", + "resolveJsonModule": true, "baseUrl": "./src", "typeRoots": ["/types/common", "./node_modules/@types"], "paths": { From 4af0cf7250f377ad2bf71e7949fe49c9f253650f Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sat, 30 Apr 2022 16:55:58 +0200 Subject: [PATCH 062/142] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20making=20changes?= =?UTF-8?q?=20to=20improve=20codeclimate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../interactionCreate/components/isCommand.ts | 22 +-- src/helpers/deferReply.ts | 22 +++ src/helpers/embedBuilder.ts | 9 + src/helpers/getCommandMeta.ts | 12 ++ src/index.ts | 2 - src/plugins/utility/modules/lookup.ts | 184 ++++++++---------- 6 files changed, 136 insertions(+), 115 deletions(-) create mode 100644 src/helpers/deferReply.ts create mode 100644 src/helpers/embedBuilder.ts create mode 100644 src/helpers/getCommandMeta.ts diff --git a/src/events/interactionCreate/components/isCommand.ts b/src/events/interactionCreate/components/isCommand.ts index 5646d70..93902fe 100644 --- a/src/events/interactionCreate/components/isCommand.ts +++ b/src/events/interactionCreate/components/isCommand.ts @@ -5,6 +5,8 @@ import logger from "@logger"; import { errorColor, footerText, footerIcon } from "@config/embed"; import i18next from "i18next"; +import deferReply from "@root/helpers/deferReply"; +import getCommandMeta from "@root/helpers/getCommandMeta"; export default async (interaction: CommandInteraction) => { if (!interaction.isCommand()) return; @@ -12,24 +14,14 @@ export default async (interaction: CommandInteraction) => { const { client, guild, commandName, user, memberPermissions } = interaction; const currentCommand = client.commands.get(commandName); - if (!currentCommand) { - logger.verbose(`Command ${commandName} not found`); + + if (currentCommand == null) { + logger.silly(`Command ${commandName} not found`); } - let meta; + const meta = await getCommandMeta(interaction, currentCommand); - const subcommand = interaction.options.getSubcommand() - - if (!interaction.options.getSubcommandGroup(false)) { - meta = currentCommand.modules[subcommand].meta; - } else { - meta = - currentCommand.groups[interaction.options.getSubcommandGroup()].modules[ - subcommand - ].meta; - } - - await interaction.deferReply({ ephemeral: meta?.ephemeral || false }); + await deferReply(interaction, meta.ephemeral || false); if ( meta.permissions && diff --git a/src/helpers/deferReply.ts b/src/helpers/deferReply.ts new file mode 100644 index 0000000..378c62e --- /dev/null +++ b/src/helpers/deferReply.ts @@ -0,0 +1,22 @@ +import { CommandInteraction, MessageEmbed } from "discord.js"; +import { waitColor, footerText, footerIcon } from "@config/embed"; + +export default async (interaction: CommandInteraction, ephemeral: boolean) => { + await interaction.deferReply({ + ephemeral, + }); + + await interaction.editReply({ + embeds: [ + new MessageEmbed() + .setFooter({ + text: footerText, + iconURL: footerIcon, + }) + .setTimestamp(new Date()) + .setTitle("Processing your request") + .setColor(waitColor) + .setDescription("Please wait..."), + ], + }); +}; diff --git a/src/helpers/embedBuilder.ts b/src/helpers/embedBuilder.ts new file mode 100644 index 0000000..8d15d90 --- /dev/null +++ b/src/helpers/embedBuilder.ts @@ -0,0 +1,9 @@ +import { footerText, footerIcon } from "@config/embed"; +import { MessageEmbed } from "discord.js"; + +export default new MessageEmbed() + .setFooter({ + text: footerText, + iconURL: footerIcon, + }) + .setTimestamp(new Date()); diff --git a/src/helpers/getCommandMeta.ts b/src/helpers/getCommandMeta.ts new file mode 100644 index 0000000..cba46e3 --- /dev/null +++ b/src/helpers/getCommandMeta.ts @@ -0,0 +1,12 @@ +import { CommandInteraction } from "discord.js"; + +export default async (interaction: CommandInteraction, currentCommand: any) => { + const subcommand = interaction.options.getSubcommand(); + const subcommandGroup = interaction.options.getSubcommandGroup(false); + + if (!subcommandGroup) { + return currentCommand.modules[subcommand].meta; + } + + return currentCommand.groups[subcommandGroup].modules[subcommand].meta; +}; diff --git a/src/index.ts b/src/index.ts index 270ab96..c083eae 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,7 +4,6 @@ import { token, intents } from "@config/discord"; import { Client } from "discord.js"; // discord.js -import locale from "@locale"; import database from "@database"; import schedules from "@schedules"; import events from "@handlers/events"; @@ -15,7 +14,6 @@ async function main() { intents, }); - await locale(); await database(); await schedules(client); diff --git a/src/plugins/utility/modules/lookup.ts b/src/plugins/utility/modules/lookup.ts index 73eb0bc..ac48a4d 100644 --- a/src/plugins/utility/modules/lookup.ts +++ b/src/plugins/utility/modules/lookup.ts @@ -1,8 +1,6 @@ -// Dependencies import axios from "axios"; -import { CommandInteraction } from "discord.js"; +import { CommandInteraction, MessageEmbed } from "discord.js"; -// Configurations import { successColor, errorColor, @@ -12,10 +10,9 @@ import { import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; -// Handlers import logger from "@logger"; +import embedBuilder from "@root/helpers/embedBuilder"; -// Function export default { meta: { guildOnly: false, ephemeral: false }, @@ -33,104 +30,95 @@ export default { ); }, execute: async (interaction: CommandInteraction) => { + const embedTitle = "[:hammer:] Utility (Lookup)"; + + embedBuilder.setTitle(embedTitle); + const { options } = interaction; - // Get lookup query - const query = options?.getString("query"); + const query = options.getString("query"); - // Make API request await axios - // Make a get request - ?.get(`http://ip-api.com/json/${query}`) - - // If successful - ?.then(async (res) => { - // If query failed - if (res?.data?.status === "fail") { - // Create embed object - const embed = { - title: ":hammer: Utilities - Lookup", - description: `${res?.data?.message}: ${res?.data?.query}`, - color: errorColor, - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, - }; - - // Send interaction reply - await interaction?.editReply({ embeds: [embed] }); - } - - // If query is successful - else if (res?.data?.status === "success") { - // Create embed object - const embed = { - title: ":hammer: Utilities - Lookup", - fields: [ - { - name: "AS", - value: `${res?.data?.as || "Not available"}`, - }, - { - name: "Country", - value: `${res?.data?.country || "Not available"}`, - }, - { - name: "Country Code", - value: `${res?.data?.countryCode || "Not available"}`, - }, - { - name: "Region", - value: `${res?.data?.region || "Not available"}`, - }, - { - name: "Region Name", - value: `${res?.data?.regionName || "Not available"}`, - }, - { - name: "City", - value: `${res?.data?.city || "Not available"}`, - }, - { - name: "ZIP Code", - value: `${res?.data?.zip || "Not available"}`, - }, - { - name: "Latitude", - value: `${res?.data?.lat || "Not available"}`, - }, - { - name: "Longitude", - value: `${res?.data?.lon || "Not available"}`, - }, - { - name: "Timezone", - value: `${res?.data?.timezone || "Not available"}`, - }, - { - name: "ISP", - value: `${res?.data?.isp || "Not available"}`, - }, - { - name: "Organization", - value: `${res?.data?.org || "Not available"}`, - }, + .get(`http://ip-api.com/json/${query}`) + .then(async (response) => { + if (response.data.status !== "success") { + await interaction.editReply({ + embeds: [ + embedBuilder + .setColor(errorColor) + .setDescription( + `${response?.data?.message}: ${response?.data?.query}` + ), ], - color: successColor, - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, - }; - - // Send interaction reply - await interaction?.editReply({ embeds: [embed] }); + }); + return; } - }) - .catch(async (e) => { - logger?.error(e); + + await interaction.editReply({ + embeds: [ + embedBuilder.setColor(successColor).setFields([ + { + name: ":classical_building: AS", + value: `${response.data.as || "Unknown"}`, + inline: true, + }, + { + name: ":classical_building: ISP", + value: `${response.data.isp || "Unknown"}`, + inline: true, + }, + { + name: ":classical_building: Organization", + value: `${response.data.org || "Unknown"}`, + inline: true, + }, + { + name: ":compass: Latitude", + value: `${response.data.lat || "Unknown"}`, + inline: true, + }, + { + name: ":compass: Longitude", + value: `${response.data.lon || "Unknown"}`, + inline: true, + }, + { + name: ":clock4: Timezone", + value: `${response.data.timezone || "Unknown"}`, + inline: true, + }, + { + name: ":globe_with_meridians: Country", + value: `${response.data.country || "Unknown"}`, + inline: true, + }, + { + name: ":globe_with_meridians: Region", + value: `${response.data.regionName || "Unknown"}`, + inline: true, + }, + { + name: ":globe_with_meridians: City", + value: `${response.data.city || "Unknown"}`, + inline: true, + }, + { + name: ":globe_with_meridians: Country Code", + value: `${response.data.countryCode || "Unknown"}`, + inline: true, + }, + { + name: ":globe_with_meridians: Region Code", + value: `${response.data.region || "Unknown"}`, + inline: true, + }, + { + name: ":globe_with_meridians: ZIP", + value: `${response.data.zip || "Unknown"}`, + inline: true, + }, + ]), + ], + }); }); }, }; From 5e6e8b3823f045f662aa109f3379534457cdf1f3 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sat, 30 Apr 2022 16:59:58 +0200 Subject: [PATCH 063/142] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20remove=20all=20com?= =?UTF-8?q?ments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/shop/modules/pterodactyl.ts | 26 +------------------------ 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/src/plugins/shop/modules/pterodactyl.ts b/src/plugins/shop/modules/pterodactyl.ts index 9ada9fb..6aeed22 100644 --- a/src/plugins/shop/modules/pterodactyl.ts +++ b/src/plugins/shop/modules/pterodactyl.ts @@ -1,9 +1,7 @@ -// Dependencies import { CommandInteraction } from "discord.js"; import { v4 as uuidv4 } from "uuid"; import axios from "axios"; -// Configurations import { successColor, errorColor, @@ -11,19 +9,15 @@ import { footerIcon, } from "@config/embed"; -// Handlers import logger from "@logger"; import encryption from "@handlers/encryption"; -// Helpers import pluralize from "@helpers/pluralize"; -// Models import apiSchema from "@schemas/api"; import fetchUser from "@helpers/fetchUser"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; -// Function export default { meta: { guildOnly: true, ephemeral: true }, @@ -40,10 +34,8 @@ export default { execute: async (interaction: CommandInteraction) => { const { options, guild, user, client } = interaction; - // Get options const optionAmount = options?.getInteger("amount"); - // If amount is null if (optionAmount === null) { logger?.verbose(`Amount is null.`); @@ -67,17 +59,14 @@ export default { return logger?.verbose(`Guild is null`); } - // Get user object const userDB = await fetchUser(user, guild); if (userDB === null) { return logger?.verbose(`User is null`); } - // Get DM user object const dmUser = client?.users?.cache?.get(user?.id); - // Stop if amount or user credits is below 100 if ((optionAmount || userDB?.credits) < 100) { logger?.verbose(`Amount or user credits is below 100.`); @@ -103,7 +92,6 @@ export default { }); } - // Stop if amount or user credits is above 1.000.000 if ((optionAmount || userDB?.credits) > 1000000) { logger?.verbose(`Amount or user credits is above 1.000.000.`); @@ -130,7 +118,6 @@ export default { }); } - // Stop if user credits is below amount if (userDB?.credits < optionAmount) { logger?.verbose(`User credits is below amount.`); @@ -156,15 +143,12 @@ export default { }); } - // Generate a unique voucher for the user const code = uuidv4(); - // Get api object const apiCredentials = await apiSchema?.findOne({ guildId: guild?.id, }); - // Create a api instance const api = axios?.create({ baseURL: apiCredentials?.url, headers: { @@ -172,13 +156,10 @@ export default { }, }); - // Get shop URL const shopUrl = apiCredentials?.url?.replace("/api", "/store"); - // Make API request await api - // Make a post request to the API ?.post("vouchers", { uses: 1, code, @@ -186,17 +167,14 @@ export default { memo: `${interaction?.createdTimestamp} - ${interaction?.user?.id}`, }) - // If successful ?.then(async () => { logger?.verbose(`Successfully created voucher.`); - // Withdraw amount from user credits userDB.credits -= optionAmount || userDB?.credits; - // Save new credits await userDB ?.save() - // If successful + ?.then(async () => { logger?.verbose(`Successfully saved new credits.`); @@ -239,7 +217,6 @@ export default { }); }) - // If error occurs .catch(async (error) => { logger?.verbose(`Error saving new credits. - ${error}`); @@ -260,7 +237,6 @@ export default { }); }) - // If error occurs .catch(async (error: any) => { logger?.verbose(`Error creating voucher. - ${error}`); From f8d8d7a0f9f27f004f02232d68603133b35c03f4 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Mon, 2 May 2022 23:22:13 +0000 Subject: [PATCH 064/142] Update dependency tsconfig-paths to v4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b5ca226..fc62f85 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "mongoose": "^6.2.3", "node-schedule": "^2.1.0", "ts-node": "^10.7.0", - "tsconfig-paths": "^3.14.1", + "tsconfig-paths": "^4.0.0", "typescript": "^4.6.3", "uuid": "^8.3.2", "winston-daily-rotate-file": "^4.6.1" From 5c343dec0ca2f78a1cde3bd6e941bbadef4f1ef9 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Tue, 3 May 2022 16:21:52 +0000 Subject: [PATCH 065/142] Update dependency @types/node-schedule to v2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b5ca226..0bfd213 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ }, "devDependencies": { "@types/chance": "^1.1.3", - "@types/node-schedule": "^1.3.2", + "@types/node-schedule": "2.1.0", "@types/uuid": "^8.3.4", "@typescript-eslint/eslint-plugin": "^5.15.0", "@typescript-eslint/parser": "^5.15.0", From de6195cf16612a0ccca824fb8d0a992d9dfdb237 Mon Sep 17 00:00:00 2001 From: snyk-bot Date: Sun, 8 May 2022 19:20:39 +0000 Subject: [PATCH 066/142] fix: upgrade @discordjs/builders from 0.12.0 to 0.13.0 Snyk has created this PR to upgrade @discordjs/builders from 0.12.0 to 0.13.0. See this package in npm: https://www.npmjs.com/package/@discordjs/builders See this project in Snyk: https://app.snyk.io/org/zyner/project/4ad0ecd9-b57c-4594-a520-da974699cb93?utm_source=github&utm_medium=referral&page=upgrade-pr --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b5ca226..9596c22 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "email": "vermium@zyner.org" }, "dependencies": { - "@discordjs/builders": "^0.12.0", + "@discordjs/builders": "^0.13.0", "@discordjs/rest": "^0.4.0", "axios": "^0.26.0", "chance": "^1.1.8", From 13727465fa96fc3ad31cc2e32db42c4bbd91a216 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sun, 15 May 2022 07:37:55 +0200 Subject: [PATCH 067/142] =?UTF-8?q?=F0=9F=90=9B=20mongodb=20async,=20fixes?= =?UTF-8?q?=20#273?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/database/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/database/index.ts b/src/database/index.ts index 4fd3870..598a023 100644 --- a/src/database/index.ts +++ b/src/database/index.ts @@ -8,7 +8,7 @@ import logger from "@logger"; import { url } from "@config/database"; export default async () => { - mongoose.connect(url).then(async (connection) => { + await mongoose.connect(url).then(async (connection) => { logger?.info(`Connected to database: ${connection.connection.name}`); }); mongoose.connection.on("error", (error) => { From dfbb7419ae09b8d5f5e6e236242f4aa6a19d355a Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sun, 15 May 2022 07:38:51 +0200 Subject: [PATCH 068/142] =?UTF-8?q?=F0=9F=94=A7=20changed=20start=20script?= =?UTF-8?q?=20to=20work=20"out=20of=20box"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e395078..a6649b1 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "src/index.ts", "scripts": { "test": "jest", - "start": "nodemon | pino-pretty -i pid,hostname -t yyyy-mm-dd HH:MM:s", + "start": "node .", "prettier-format": "prettier \"src/**/*.ts\" --write", "lint": "eslint ./src --ext .ts", "prepare": "husky install" From 12d7b19919ae302a953680734a91472d9420839b Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sun, 15 May 2022 07:42:17 +0200 Subject: [PATCH 069/142] =?UTF-8?q?=F0=9F=8E=A8=20database=20connection?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/database/index.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/database/index.ts b/src/database/index.ts index 598a023..af3b524 100644 --- a/src/database/index.ts +++ b/src/database/index.ts @@ -9,12 +9,14 @@ import { url } from "@config/database"; export default async () => { await mongoose.connect(url).then(async (connection) => { - logger?.info(`Connected to database: ${connection.connection.name}`); + logger.info(`Connected to database: ${connection.connection.name}`); }); - mongoose.connection.on("error", (error) => { - logger?.error(error); + + mongoose.connection.on("error", async (error) => { + logger.error(error); }); - mongoose.connection.on("warn", (warning) => { - logger?.warn(warning); + + mongoose.connection.on("warn", async (warning) => { + logger.warn(warning); }); }; From 06db4d9cab27884c626c181fddc84bee3119c305 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Tue, 17 May 2022 07:37:10 +0000 Subject: [PATCH 070/142] Update dependency eslint to v8.15.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b5ca226..3e736e7 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@types/uuid": "^8.3.4", "@typescript-eslint/eslint-plugin": "^5.15.0", "@typescript-eslint/parser": "^5.15.0", - "eslint": "8.13.0", + "eslint": "8.15.0", "eslint-config-airbnb-base": "15.0.0", "eslint-config-prettier": "8.5.0", "eslint-plugin-import": "2.26.0", From e6ea88f57ee52e919c6d26baada821ee0f7bd5d0 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Tue, 17 May 2022 07:40:28 +0000 Subject: [PATCH 071/142] Update dependency husky to v8 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b5ca226..a468376 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "eslint-plugin-import": "2.26.0", "eslint-plugin-no-loops": "^0.3.0", "eslint-plugin-prettier": "^4.0.0", - "husky": "^7.0.0", + "husky": "8.0.1", "jest": "^27.5.1", "lint-staged": "^12.3.7", "prettier": "^2.6.0" From e83421a3aca71727215d297888e489c523277868 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Tue, 17 May 2022 07:41:52 +0000 Subject: [PATCH 072/142] Update dependency discord-api-types to ^0.33.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b5ca226..ca5fda5 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "chance": "^1.1.8", "common": "^0.2.5", "crypto": "^1.0.1", - "discord-api-types": "^0.31.0", + "discord-api-types": "^0.33.0", "discord.js": "^13.6.0", "i18next": "^21.6.13", "mongoose": "^6.2.3", From f8fd7adefb00d6c72e40958d6047814802944079 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Tue, 17 May 2022 09:43:49 +0200 Subject: [PATCH 073/142] Delete crowdin.yml --- crowdin.yml | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 crowdin.yml diff --git a/crowdin.yml b/crowdin.yml deleted file mode 100644 index 59811b2..0000000 --- a/crowdin.yml +++ /dev/null @@ -1,3 +0,0 @@ -files: - - source: /lang/en/*.json - translation: /lang/%two_letters_code%/%original_file_name% From c23c80b0bf4ccaeefa0d888d53e32ef42d5a468f Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Tue, 17 May 2022 09:43:57 +0200 Subject: [PATCH 074/142] Delete lang directory --- lang/ach/plugins.json | 11 ---- lang/de/plugins.json | 115 ------------------------------------------ lang/en/errors.json | 7 --- lang/en/plugins.json | 115 ------------------------------------------ lang/sv/plugins.json | 115 ------------------------------------------ 5 files changed, 363 deletions(-) delete mode 100644 lang/ach/plugins.json delete mode 100644 lang/de/plugins.json delete mode 100644 lang/en/errors.json delete mode 100644 lang/en/plugins.json delete mode 100644 lang/sv/plugins.json diff --git a/lang/ach/plugins.json b/lang/ach/plugins.json deleted file mode 100644 index b08515b..0000000 --- a/lang/ach/plugins.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "credits": { - "modules": { - "balance": { - "general": { - "title": "crwdns118:0:dollar:crwdne118:0" - } - } - } - } -} diff --git a/lang/de/plugins.json b/lang/de/plugins.json deleted file mode 100644 index 45bd203..0000000 --- a/lang/de/plugins.json +++ /dev/null @@ -1,115 +0,0 @@ -{ - "credits": { - "modules": { - "balance": { - "general": { - "title": "[:dollar:] Credits (Balance)" - }, - "user_has_amount_credits": "<@{{user}}> has {{amount}} credits", - "error01": { - "description": "<@{{user}}> has no credits!" - }, - "success01": { - "description": "<@{{user}}> has {{amount}} credits!\n" - } - }, - "gift": { - "general": { - "title": "[:dollar:] Credits (Gift)" - }, - "error01": { - "description": "You can not pay yourself!" - }, - "error02": { - "description": "You can't gift zero or below!" - }, - "error03": { - "description": "You have insufficient credits. Your balance is {{amount}}!" - }, - "success01": { - "description": "You have received {{amount}} credits from {{user}} with reason {{reason}}!" - }, - "success02": { - "description": "Successfully gifted {{amount}} credits to <@{{user}}> with reason {{reason}}!" - } - }, - "top": { - "entry": "{{index}}. <@{{user}}> - {{amount}}", - "success01": { - "description": "Top 10 users with the most credits." - }, - "general": { - "title": "[:dollar:] Credits (Top)" - } - }, - "work": { - "general": { - "title": "[:dollar:] Credits (Work)" - }, - "error01": { - "description": "You can not work while on timeout, please wait {{time}} seconds." - }, - "success01": { - "description": "You worked and earned {{amount}} credits" - } - } - } - }, - "utility": { - "modules": { - "avatar": { - "general": { - "title": "[:hammer:] Utility (Avatar)" - }, - "success01": { - "description": "Here you have <@{{user}}> avatar!" - } - } - } - }, - "counters": { - "modules": { - "view": { - "general": { - "title": "[:1234:] Counters (View)" - }, - "error01": { - "description": "No counter found for channel <#{{channel}}>!" - }, - "success01": { - "description": "Viewing counter for channel <#{{channel}} with count {{amount}}." - } - } - } - }, - "manage": { - "groups": { - "counters": { - "modules": { - "create": { - "general": { - "title": "[:toolbox:] Manage - Counters (Create)" - }, - "success01": { - "description": "Created counter for <#{{channel}}>." - }, - "error01": { - "description": "A counter already exists for this channel." - } - }, - "delete": { - "general": { - "title": "[:toolbox:] Manage - Counters (Delete)" - }, - "error01": { - "description": "The counter for this channel does not exist." - }, - "success01": { - "description": "The counter for this channel has been deleted." - } - } - } - } - } - } -} diff --git a/lang/en/errors.json b/lang/en/errors.json deleted file mode 100644 index 225d04b..0000000 --- a/lang/en/errors.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "errors": { - "guildOnly": "You can only use this command in a guild!", - "userNotFound": "Could not find user <@{{user}}>.", - "amountNotFound": "We could not read your requested amount!" - } -} diff --git a/lang/en/plugins.json b/lang/en/plugins.json deleted file mode 100644 index 45bd203..0000000 --- a/lang/en/plugins.json +++ /dev/null @@ -1,115 +0,0 @@ -{ - "credits": { - "modules": { - "balance": { - "general": { - "title": "[:dollar:] Credits (Balance)" - }, - "user_has_amount_credits": "<@{{user}}> has {{amount}} credits", - "error01": { - "description": "<@{{user}}> has no credits!" - }, - "success01": { - "description": "<@{{user}}> has {{amount}} credits!\n" - } - }, - "gift": { - "general": { - "title": "[:dollar:] Credits (Gift)" - }, - "error01": { - "description": "You can not pay yourself!" - }, - "error02": { - "description": "You can't gift zero or below!" - }, - "error03": { - "description": "You have insufficient credits. Your balance is {{amount}}!" - }, - "success01": { - "description": "You have received {{amount}} credits from {{user}} with reason {{reason}}!" - }, - "success02": { - "description": "Successfully gifted {{amount}} credits to <@{{user}}> with reason {{reason}}!" - } - }, - "top": { - "entry": "{{index}}. <@{{user}}> - {{amount}}", - "success01": { - "description": "Top 10 users with the most credits." - }, - "general": { - "title": "[:dollar:] Credits (Top)" - } - }, - "work": { - "general": { - "title": "[:dollar:] Credits (Work)" - }, - "error01": { - "description": "You can not work while on timeout, please wait {{time}} seconds." - }, - "success01": { - "description": "You worked and earned {{amount}} credits" - } - } - } - }, - "utility": { - "modules": { - "avatar": { - "general": { - "title": "[:hammer:] Utility (Avatar)" - }, - "success01": { - "description": "Here you have <@{{user}}> avatar!" - } - } - } - }, - "counters": { - "modules": { - "view": { - "general": { - "title": "[:1234:] Counters (View)" - }, - "error01": { - "description": "No counter found for channel <#{{channel}}>!" - }, - "success01": { - "description": "Viewing counter for channel <#{{channel}} with count {{amount}}." - } - } - } - }, - "manage": { - "groups": { - "counters": { - "modules": { - "create": { - "general": { - "title": "[:toolbox:] Manage - Counters (Create)" - }, - "success01": { - "description": "Created counter for <#{{channel}}>." - }, - "error01": { - "description": "A counter already exists for this channel." - } - }, - "delete": { - "general": { - "title": "[:toolbox:] Manage - Counters (Delete)" - }, - "error01": { - "description": "The counter for this channel does not exist." - }, - "success01": { - "description": "The counter for this channel has been deleted." - } - } - } - } - } - } -} diff --git a/lang/sv/plugins.json b/lang/sv/plugins.json deleted file mode 100644 index 9aadec8..0000000 --- a/lang/sv/plugins.json +++ /dev/null @@ -1,115 +0,0 @@ -{ - "credits": { - "modules": { - "balance": { - "general": { - "title": "[:dollar:] Krediter (Saldo)" - }, - "user_has_amount_credits": "<@{{user}}> har {{amount}} krediter", - "error01": { - "description": "<@{{user}} har inga krediter!" - }, - "success01": { - "description": "<@{{user}}> har {{amount}} krediter!\n" - } - }, - "gift": { - "general": { - "title": "[:dollar:] Krediter (Gåva)" - }, - "error01": { - "description": "Du kan inte betala själv!" - }, - "error02": { - "description": "Du kan inte ge noll eller nedan!" - }, - "error03": { - "description": "Du har otillräckliga krediter. Ditt saldo är {{amount}}!" - }, - "success01": { - "description": "Du har fått {{amount}} krediter från {{user}} med anledning av {{reason}}!" - }, - "success02": { - "description": "Du har fått {{amount}} krediter från {{user}} med anledning {{reason}}!" - } - }, - "top": { - "entry": "{{index}}. <@{{user}}> - {{amount}}", - "success01": { - "description": "Topp 10 användare med flest krediter." - }, - "general": { - "title": "[:dollar:] Krediter (Topp)" - } - }, - "work": { - "general": { - "title": "[:dollar:] Krediter (Arbeta)" - }, - "error01": { - "description": "Du kan inte arbeta under tiden du har paus, vänta {{time}} sekunder." - }, - "success01": { - "description": "Du arbetade och tjänade {{amount}} krediter" - } - } - } - }, - "utility": { - "modules": { - "avatar": { - "general": { - "title": "[:hammer:] Verktyg (Avatar)" - }, - "success01": { - "description": "Här har du <@{{user}}> avatar!" - } - } - } - }, - "counters": { - "modules": { - "view": { - "general": { - "title": "[:1234:] Räknare (Visa)" - }, - "error01": { - "description": "Ingen räknare hittades för kanal <#{{channel}}>!" - }, - "success01": { - "description": "Visar räknaren för kanal <#{{channel}} med antal {{amount}}." - } - } - } - }, - "manage": { - "groups": { - "counters": { - "modules": { - "create": { - "general": { - "title": "[:toolbox:] Hantera - Räknare (Skapa)" - }, - "success01": { - "description": "Skapade räknare för <#{{channel}}>." - }, - "error01": { - "description": "En räknare finns redan för denna kanal." - } - }, - "delete": { - "general": { - "title": "[:toolbox:] Hantera - Räknare (Ta bort)" - }, - "error01": { - "description": "Räknaren för denna kanal finns inte." - }, - "success01": { - "description": "Räknaren för denna kanal har tagits bort." - } - } - } - } - } - } -} From 2285401f3d60f9633b039275fa9b1d73d2f068d3 Mon Sep 17 00:00:00 2001 From: DeepSource Bot Date: Tue, 17 May 2022 08:13:07 +0000 Subject: [PATCH 075/142] Add .deepsource.toml --- .deepsource.toml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .deepsource.toml diff --git a/.deepsource.toml b/.deepsource.toml new file mode 100644 index 0000000..1f05ea0 --- /dev/null +++ b/.deepsource.toml @@ -0,0 +1,5 @@ +version = 1 + +[[analyzers]] +name = "shell" +enabled = true \ No newline at end of file From 07d5cdde3c7b50cb863ea0c4501947098ff81d1e Mon Sep 17 00:00:00 2001 From: DeepSource Bot Date: Tue, 17 May 2022 08:14:36 +0000 Subject: [PATCH 076/142] Update .deepsource.toml --- .deepsource.toml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.deepsource.toml b/.deepsource.toml index 1f05ea0..e507163 100644 --- a/.deepsource.toml +++ b/.deepsource.toml @@ -1,5 +1,17 @@ version = 1 +[[analyzers]] +name = "javascript" +enabled = true + [[analyzers]] name = "shell" +enabled = true + +[[transformers]] +name = "standardjs" +enabled = true + +[[transformers]] +name = "prettier" enabled = true \ No newline at end of file From 7386a67c4758dc9166fa68685f6744c093becd34 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Tue, 17 May 2022 08:14:55 +0000 Subject: [PATCH 077/142] Format code with standardjs and prettier This commit fixes the style issues introduced in 07d5cdd according to the output from standardjs and prettier. Details: https://deepsource.io/gh/ZynerOrg/xyter/transform/f4ec6b1e-fdc4-4438-ac17-52efacc4432f/ --- .vscode/extensions.json | 104 ++++++++++++++++++++-------------------- .vscode/settings.json | 52 ++++++++++---------- PRIVACY.md | 50 +++++++++---------- SECURITY.md | 6 +-- 4 files changed, 104 insertions(+), 108 deletions(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 4008731..a17e74d 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,52 +1,52 @@ -{ - // See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations. - // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp - // List of extensions which should be recommended for users of this workspace. - "recommendations": [ - "abrahamwilliam007.es7-javascript-class-snippets", - "christian-kohler.npm-intellisense", - "christian-kohler.path-intellisense", - "dbaeumer.vscode-eslint", - "donjayamanne.githistory", - "eamodio.gitlens", - "esbenp.prettier-vscode", - "github.github-vscode-theme", - "irongeek.vscode-env", - "xabikos.javascriptsnippets", - "wix.vscode-import-cost", - "vscode-icons-team.vscode-icons", - "visualstudioexptteam.vscodeintellicode", - "teledemic.branch-warnings", - "tabnine.tabnine-vscode", - "streetsidesoftware.code-spell-checker", - "seatonjiang.gitmoji-vscode", - "sburg.vscode-javascript-booster", - "kisstkondoros.vscode-codemetrics", - "mgmcdermott.vscode-language-babel", - "mhutchie.git-graph", - "mikestead.dotenv", - "mongodb.mongodb-vscode", - "ms-vscode-remote.remote-wsl-recommender", - "ms-vscode.js-debug", - "ms-vscode.js-debug-companion", - "ms-vscode.references-view", - "ms-vscode.vscode-js-profile-table", - "pflannery.vscode-versionlens", - "adpyke.codesnap", - "anan.devdocstab", - "axosoft.gitkraken-glo", - "gruntfuggly.todo-tree", - "kiteco.kite", - "lkytal.pomodoro", - "wayou.vscode-todo-highlight", - "johnpapa.vscode-peacock", - "stepsize.stepsize", - "nicoespeon.abracadabra", - "sonarsource.sonarlint-vscode", - "nicoespeon.hocus-pocus", - "aaron-bond.better-comments", - "oouo-diogo-perdigao.docthis" - ], - // List of extensions recommended by VS Code that should not be recommended for users of this workspace. - "unwantedRecommendations": [] -} +{ + // See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations. + // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp + // List of extensions which should be recommended for users of this workspace. + "recommendations": [ + "abrahamwilliam007.es7-javascript-class-snippets", + "christian-kohler.npm-intellisense", + "christian-kohler.path-intellisense", + "dbaeumer.vscode-eslint", + "donjayamanne.githistory", + "eamodio.gitlens", + "esbenp.prettier-vscode", + "github.github-vscode-theme", + "irongeek.vscode-env", + "xabikos.javascriptsnippets", + "wix.vscode-import-cost", + "vscode-icons-team.vscode-icons", + "visualstudioexptteam.vscodeintellicode", + "teledemic.branch-warnings", + "tabnine.tabnine-vscode", + "streetsidesoftware.code-spell-checker", + "seatonjiang.gitmoji-vscode", + "sburg.vscode-javascript-booster", + "kisstkondoros.vscode-codemetrics", + "mgmcdermott.vscode-language-babel", + "mhutchie.git-graph", + "mikestead.dotenv", + "mongodb.mongodb-vscode", + "ms-vscode-remote.remote-wsl-recommender", + "ms-vscode.js-debug", + "ms-vscode.js-debug-companion", + "ms-vscode.references-view", + "ms-vscode.vscode-js-profile-table", + "pflannery.vscode-versionlens", + "adpyke.codesnap", + "anan.devdocstab", + "axosoft.gitkraken-glo", + "gruntfuggly.todo-tree", + "kiteco.kite", + "lkytal.pomodoro", + "wayou.vscode-todo-highlight", + "johnpapa.vscode-peacock", + "stepsize.stepsize", + "nicoespeon.abracadabra", + "sonarsource.sonarlint-vscode", + "nicoespeon.hocus-pocus", + "aaron-bond.better-comments", + "oouo-diogo-perdigao.docthis" + ], + // List of extensions recommended by VS Code that should not be recommended for users of this workspace. + "unwantedRecommendations": [] +} diff --git a/.vscode/settings.json b/.vscode/settings.json index 76d8e57..38d1af9 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,26 +1,26 @@ -{ - "editor.bracketPairColorization.enabled": true, - "editor.codeActionsOnSave": ["source.formatDocument", "source.fixAll.eslint"], - "editor.cursorBlinking": "phase", - "editor.cursorSmoothCaretAnimation": true, - "editor.defaultFormatter": "esbenp.prettier-vscode", - "editor.fontFamily": "Cascadia Code", - "editor.fontLigatures": true, - "editor.formatOnSave": true, - "editor.guides.bracketPairs": "active", - "editor.minimap.maxColumn": 200, - "editor.minimap.renderCharacters": false, - "editor.minimap.showSlider": "always", - "editor.tabSize": 2, - "editor.wordWrapColumn": 100, - "files.eol": "\n", - "files.trimTrailingWhitespace": true, - "cSpell.customDictionaries": { - "custom-dictionary-workspace": { - "name": "custom-dictionary-workspace", - "path": "${workspaceFolder:xyter}/.cspell/custom-dictionary-workspace.txt", - "addWords": true, - "scope": "workspace" - } - } -} +{ + "editor.bracketPairColorization.enabled": true, + "editor.codeActionsOnSave": ["source.formatDocument", "source.fixAll.eslint"], + "editor.cursorBlinking": "phase", + "editor.cursorSmoothCaretAnimation": true, + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.fontFamily": "Cascadia Code", + "editor.fontLigatures": true, + "editor.formatOnSave": true, + "editor.guides.bracketPairs": "active", + "editor.minimap.maxColumn": 200, + "editor.minimap.renderCharacters": false, + "editor.minimap.showSlider": "always", + "editor.tabSize": 2, + "editor.wordWrapColumn": 100, + "files.eol": "\n", + "files.trimTrailingWhitespace": true, + "cSpell.customDictionaries": { + "custom-dictionary-workspace": { + "name": "custom-dictionary-workspace", + "path": "${workspaceFolder:xyter}/.cspell/custom-dictionary-workspace.txt", + "addWords": true, + "scope": "workspace" + } + } +} diff --git a/PRIVACY.md b/PRIVACY.md index f07fa94..4bffac4 100644 --- a/PRIVACY.md +++ b/PRIVACY.md @@ -7,54 +7,50 @@ This document entails the privacy policy and agreement that you accept when addi This privacy policy applies to **Xyter**#7721 (949998000401436673) - - - ### Terminology -* **Server Manager** - Anyone who has the ability to add a bot to a server or configure the bot for the server. This is usually an administrator or moderator -* **Server Member** - Anyone who is a member of server to which one of the bots has been added -* **Service User** - Anyone who authorizes an application (logs in) for a scope that provides additional information - +- **Server Manager** - Anyone who has the ability to add a bot to a server or configure the bot for the server. This is usually an administrator or moderator +- **Server Member** - Anyone who is a member of server to which one of the bots has been added +- **Service User** - Anyone who authorizes an application (logs in) for a scope that provides additional information ### Data Collected By Command -The following items may be collected and stored when intentionally provided by a user (usually by means of a command). This data will not be collected automatically. When providing data in this way, you forego any rights to the content of the data provided. -* Server configurations (/settings guild) -* Data and content for automated tasks (/shop roles) -* Locale (/settings user language) -* Reputation (/reputation give) +The following items may be collected and stored when intentionally provided by a user (usually by means of a command). This data will not be collected automatically. When providing data in this way, you forego any rights to the content of the data provided. + +- Server configurations (/settings guild) +- Data and content for automated tasks (/shop roles) +- Locale (/settings user language) +- Reputation (/reputation give) ### Data Collected When Enabled + These items will be automatically collected if a bot is configured to perform certain actions by a server manager. These features are always opt-in, and thus this data will not be collected unless the corresponding feature is enabled. -* API Token & URL (/settings guild pterodactyl) -* Counters (/admin counter) - +- API Token & URL (/settings guild pterodactyl) +- Counters (/admin counter) ### Data Collected Automatically + This data may be collected automatically. This data is used to provide statistics or history data. For any bots that collect this data, it is necessary for features of said bot. -* Username ID (Unique identifier) -* Guild ID (Unique identifier) -* Any data needed for standard operation of Discord bots, such as server permissions -* Credits (/profile view) -* Points (/profile view) -* Levels (/profile view) -* Timestamps (Audit logs and all your data that we store) - +- Username ID (Unique identifier) +- Guild ID (Unique identifier) +- Any data needed for standard operation of Discord bots, such as server permissions +- Credits (/profile view) +- Points (/profile view) +- Levels (/profile view) +- Timestamps (Audit logs and all your data that we store) ### Data Storage + All stored data is kept on protected servers. While storage methods vary, most data is kept within password-protected databases such as [MongoDB Atlas](https://atlas.mongodb.com/). Please keep in mind that even with these protections, no data can ever be 100% secure. All efforts are taken to keep your data secure and private, but its absolute security cannot be guaranteed. - - ### Feedback + Feedback on Xyter bot and service is appreciated. When you submit comments, suggestions, bug reports, and any other forms of feedback, you forego any rights to the content, title, or intent of the provided feedback. Additionally, the feedback may be utilized in any way. - - ### Agreement + By adding Xyter bot to your server or using this bot or service in any way, you are consenting to the policies outlined in this document. In addition, you (the server manager) are agreeing to inform your members of the [Developer Terms of Service](https://discordapp.com/developers/docs/legal) and the contents of this document. If you, the server manager, do not agree to this document, you may remove the bot(s) from the server. If you, the server member, do not agree to this document, you may leave the server that contains the bot(s). If you, the service user, do not agree to this document, you may revoke authorization of the application(s) in your 'Authorized Apps' menu. Changes to This Privacy Policy diff --git a/SECURITY.md b/SECURITY.md index 5ad31c6..4933326 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -2,10 +2,10 @@ ## Supported Versions -| Version | Supported | -| ------- | ------------------ | +| Version | Supported | +| ---------- | ------------------ | | 2022.4.x | :white_check_mark: | -| < 2022.4.x | :x: | +| < 2022.4.x | :x: | ## Reporting a Vulnerability From d4d7019df700573a34ffa83c06212c62a5f60182 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Tue, 17 May 2022 08:14:56 +0000 Subject: [PATCH 078/142] Format code with standardjs and prettier This commit fixes the style issues introduced in 07d5cdd according to the output from standardjs and prettier. Details: https://deepsource.io/gh/ZynerOrg/xyter/transform/8f0d6932-6fff-4855-8ab9-f43355cfadf0/ --- .vscode/extensions.json | 104 ++++++++++++++++++++-------------------- .vscode/settings.json | 52 ++++++++++---------- PRIVACY.md | 50 +++++++++---------- SECURITY.md | 6 +-- 4 files changed, 104 insertions(+), 108 deletions(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 4008731..a17e74d 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,52 +1,52 @@ -{ - // See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations. - // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp - // List of extensions which should be recommended for users of this workspace. - "recommendations": [ - "abrahamwilliam007.es7-javascript-class-snippets", - "christian-kohler.npm-intellisense", - "christian-kohler.path-intellisense", - "dbaeumer.vscode-eslint", - "donjayamanne.githistory", - "eamodio.gitlens", - "esbenp.prettier-vscode", - "github.github-vscode-theme", - "irongeek.vscode-env", - "xabikos.javascriptsnippets", - "wix.vscode-import-cost", - "vscode-icons-team.vscode-icons", - "visualstudioexptteam.vscodeintellicode", - "teledemic.branch-warnings", - "tabnine.tabnine-vscode", - "streetsidesoftware.code-spell-checker", - "seatonjiang.gitmoji-vscode", - "sburg.vscode-javascript-booster", - "kisstkondoros.vscode-codemetrics", - "mgmcdermott.vscode-language-babel", - "mhutchie.git-graph", - "mikestead.dotenv", - "mongodb.mongodb-vscode", - "ms-vscode-remote.remote-wsl-recommender", - "ms-vscode.js-debug", - "ms-vscode.js-debug-companion", - "ms-vscode.references-view", - "ms-vscode.vscode-js-profile-table", - "pflannery.vscode-versionlens", - "adpyke.codesnap", - "anan.devdocstab", - "axosoft.gitkraken-glo", - "gruntfuggly.todo-tree", - "kiteco.kite", - "lkytal.pomodoro", - "wayou.vscode-todo-highlight", - "johnpapa.vscode-peacock", - "stepsize.stepsize", - "nicoespeon.abracadabra", - "sonarsource.sonarlint-vscode", - "nicoespeon.hocus-pocus", - "aaron-bond.better-comments", - "oouo-diogo-perdigao.docthis" - ], - // List of extensions recommended by VS Code that should not be recommended for users of this workspace. - "unwantedRecommendations": [] -} +{ + // See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations. + // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp + // List of extensions which should be recommended for users of this workspace. + "recommendations": [ + "abrahamwilliam007.es7-javascript-class-snippets", + "christian-kohler.npm-intellisense", + "christian-kohler.path-intellisense", + "dbaeumer.vscode-eslint", + "donjayamanne.githistory", + "eamodio.gitlens", + "esbenp.prettier-vscode", + "github.github-vscode-theme", + "irongeek.vscode-env", + "xabikos.javascriptsnippets", + "wix.vscode-import-cost", + "vscode-icons-team.vscode-icons", + "visualstudioexptteam.vscodeintellicode", + "teledemic.branch-warnings", + "tabnine.tabnine-vscode", + "streetsidesoftware.code-spell-checker", + "seatonjiang.gitmoji-vscode", + "sburg.vscode-javascript-booster", + "kisstkondoros.vscode-codemetrics", + "mgmcdermott.vscode-language-babel", + "mhutchie.git-graph", + "mikestead.dotenv", + "mongodb.mongodb-vscode", + "ms-vscode-remote.remote-wsl-recommender", + "ms-vscode.js-debug", + "ms-vscode.js-debug-companion", + "ms-vscode.references-view", + "ms-vscode.vscode-js-profile-table", + "pflannery.vscode-versionlens", + "adpyke.codesnap", + "anan.devdocstab", + "axosoft.gitkraken-glo", + "gruntfuggly.todo-tree", + "kiteco.kite", + "lkytal.pomodoro", + "wayou.vscode-todo-highlight", + "johnpapa.vscode-peacock", + "stepsize.stepsize", + "nicoespeon.abracadabra", + "sonarsource.sonarlint-vscode", + "nicoespeon.hocus-pocus", + "aaron-bond.better-comments", + "oouo-diogo-perdigao.docthis" + ], + // List of extensions recommended by VS Code that should not be recommended for users of this workspace. + "unwantedRecommendations": [] +} diff --git a/.vscode/settings.json b/.vscode/settings.json index 76d8e57..38d1af9 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,26 +1,26 @@ -{ - "editor.bracketPairColorization.enabled": true, - "editor.codeActionsOnSave": ["source.formatDocument", "source.fixAll.eslint"], - "editor.cursorBlinking": "phase", - "editor.cursorSmoothCaretAnimation": true, - "editor.defaultFormatter": "esbenp.prettier-vscode", - "editor.fontFamily": "Cascadia Code", - "editor.fontLigatures": true, - "editor.formatOnSave": true, - "editor.guides.bracketPairs": "active", - "editor.minimap.maxColumn": 200, - "editor.minimap.renderCharacters": false, - "editor.minimap.showSlider": "always", - "editor.tabSize": 2, - "editor.wordWrapColumn": 100, - "files.eol": "\n", - "files.trimTrailingWhitespace": true, - "cSpell.customDictionaries": { - "custom-dictionary-workspace": { - "name": "custom-dictionary-workspace", - "path": "${workspaceFolder:xyter}/.cspell/custom-dictionary-workspace.txt", - "addWords": true, - "scope": "workspace" - } - } -} +{ + "editor.bracketPairColorization.enabled": true, + "editor.codeActionsOnSave": ["source.formatDocument", "source.fixAll.eslint"], + "editor.cursorBlinking": "phase", + "editor.cursorSmoothCaretAnimation": true, + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.fontFamily": "Cascadia Code", + "editor.fontLigatures": true, + "editor.formatOnSave": true, + "editor.guides.bracketPairs": "active", + "editor.minimap.maxColumn": 200, + "editor.minimap.renderCharacters": false, + "editor.minimap.showSlider": "always", + "editor.tabSize": 2, + "editor.wordWrapColumn": 100, + "files.eol": "\n", + "files.trimTrailingWhitespace": true, + "cSpell.customDictionaries": { + "custom-dictionary-workspace": { + "name": "custom-dictionary-workspace", + "path": "${workspaceFolder:xyter}/.cspell/custom-dictionary-workspace.txt", + "addWords": true, + "scope": "workspace" + } + } +} diff --git a/PRIVACY.md b/PRIVACY.md index f07fa94..4bffac4 100644 --- a/PRIVACY.md +++ b/PRIVACY.md @@ -7,54 +7,50 @@ This document entails the privacy policy and agreement that you accept when addi This privacy policy applies to **Xyter**#7721 (949998000401436673) - - - ### Terminology -* **Server Manager** - Anyone who has the ability to add a bot to a server or configure the bot for the server. This is usually an administrator or moderator -* **Server Member** - Anyone who is a member of server to which one of the bots has been added -* **Service User** - Anyone who authorizes an application (logs in) for a scope that provides additional information - +- **Server Manager** - Anyone who has the ability to add a bot to a server or configure the bot for the server. This is usually an administrator or moderator +- **Server Member** - Anyone who is a member of server to which one of the bots has been added +- **Service User** - Anyone who authorizes an application (logs in) for a scope that provides additional information ### Data Collected By Command -The following items may be collected and stored when intentionally provided by a user (usually by means of a command). This data will not be collected automatically. When providing data in this way, you forego any rights to the content of the data provided. -* Server configurations (/settings guild) -* Data and content for automated tasks (/shop roles) -* Locale (/settings user language) -* Reputation (/reputation give) +The following items may be collected and stored when intentionally provided by a user (usually by means of a command). This data will not be collected automatically. When providing data in this way, you forego any rights to the content of the data provided. + +- Server configurations (/settings guild) +- Data and content for automated tasks (/shop roles) +- Locale (/settings user language) +- Reputation (/reputation give) ### Data Collected When Enabled + These items will be automatically collected if a bot is configured to perform certain actions by a server manager. These features are always opt-in, and thus this data will not be collected unless the corresponding feature is enabled. -* API Token & URL (/settings guild pterodactyl) -* Counters (/admin counter) - +- API Token & URL (/settings guild pterodactyl) +- Counters (/admin counter) ### Data Collected Automatically + This data may be collected automatically. This data is used to provide statistics or history data. For any bots that collect this data, it is necessary for features of said bot. -* Username ID (Unique identifier) -* Guild ID (Unique identifier) -* Any data needed for standard operation of Discord bots, such as server permissions -* Credits (/profile view) -* Points (/profile view) -* Levels (/profile view) -* Timestamps (Audit logs and all your data that we store) - +- Username ID (Unique identifier) +- Guild ID (Unique identifier) +- Any data needed for standard operation of Discord bots, such as server permissions +- Credits (/profile view) +- Points (/profile view) +- Levels (/profile view) +- Timestamps (Audit logs and all your data that we store) ### Data Storage + All stored data is kept on protected servers. While storage methods vary, most data is kept within password-protected databases such as [MongoDB Atlas](https://atlas.mongodb.com/). Please keep in mind that even with these protections, no data can ever be 100% secure. All efforts are taken to keep your data secure and private, but its absolute security cannot be guaranteed. - - ### Feedback + Feedback on Xyter bot and service is appreciated. When you submit comments, suggestions, bug reports, and any other forms of feedback, you forego any rights to the content, title, or intent of the provided feedback. Additionally, the feedback may be utilized in any way. - - ### Agreement + By adding Xyter bot to your server or using this bot or service in any way, you are consenting to the policies outlined in this document. In addition, you (the server manager) are agreeing to inform your members of the [Developer Terms of Service](https://discordapp.com/developers/docs/legal) and the contents of this document. If you, the server manager, do not agree to this document, you may remove the bot(s) from the server. If you, the server member, do not agree to this document, you may leave the server that contains the bot(s). If you, the service user, do not agree to this document, you may revoke authorization of the application(s) in your 'Authorized Apps' menu. Changes to This Privacy Policy diff --git a/SECURITY.md b/SECURITY.md index 5ad31c6..4933326 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -2,10 +2,10 @@ ## Supported Versions -| Version | Supported | -| ------- | ------------------ | +| Version | Supported | +| ---------- | ------------------ | | 2022.4.x | :white_check_mark: | -| < 2022.4.x | :x: | +| < 2022.4.x | :x: | ## Reporting a Vulnerability From 0472605a4b04de423e1df7ad5acac6444e24097b Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Tue, 17 May 2022 08:19:10 +0000 Subject: [PATCH 079/142] Adds the appropriate return type for the method or function --- src/handlers/encryption.ts | 4 +++- src/helpers/pluralize.ts | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/handlers/encryption.ts b/src/handlers/encryption.ts index 4624d74..7c81347 100644 --- a/src/handlers/encryption.ts +++ b/src/handlers/encryption.ts @@ -4,7 +4,9 @@ import { secretKey, algorithm } from "@config/encryption"; const iv = crypto.randomBytes(16); -const encrypt = (text: any) => { +const encrypt = (text: any): {iv: error; +content: error; +} => { const cipher = crypto.createCipheriv(algorithm, secretKey, iv); const encrypted = Buffer.concat([cipher.update(text), cipher.final()]); diff --git a/src/helpers/pluralize.ts b/src/helpers/pluralize.ts index c255427..491393b 100644 --- a/src/helpers/pluralize.ts +++ b/src/helpers/pluralize.ts @@ -1,6 +1,6 @@ import logger from "@root/logger"; -export default (count: number, noun: string, suffix?: string) => { +export default (count: number, noun: string, suffix?: string): string => { const result = `${count} ${noun}${count !== 1 ? suffix || "s" : ""}`; logger?.verbose(`Pluralized ${count} to ${result}`); return result; From 6fb549946a5e9dc83ce2789f790123315ba7dd23 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Tue, 17 May 2022 08:19:22 +0000 Subject: [PATCH 080/142] Format code with standardjs and prettier --- src/handlers/encryption.ts | 4 +--- src/helpers/pluralize.ts | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/handlers/encryption.ts b/src/handlers/encryption.ts index 7c81347..5e07d89 100644 --- a/src/handlers/encryption.ts +++ b/src/handlers/encryption.ts @@ -4,9 +4,7 @@ import { secretKey, algorithm } from "@config/encryption"; const iv = crypto.randomBytes(16); -const encrypt = (text: any): {iv: error; -content: error; -} => { +const encrypt = (text: any): { iv: error; content: error } => { const cipher = crypto.createCipheriv(algorithm, secretKey, iv); const encrypted = Buffer.concat([cipher.update(text), cipher.final()]); diff --git a/src/helpers/pluralize.ts b/src/helpers/pluralize.ts index 491393b..c9ad1ad 100644 --- a/src/helpers/pluralize.ts +++ b/src/helpers/pluralize.ts @@ -1,6 +1,6 @@ import logger from "@root/logger"; -export default (count: number, noun: string, suffix?: string): string => { +export default (count: number, noun: string, suffix?: string): string => { const result = `${count} ${noun}${count !== 1 ? suffix || "s" : ""}`; logger?.verbose(`Pluralized ${count} to ${result}`); return result; From 0e17d18141232c4867de4a94de4f82c1a947fb5c Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Tue, 17 May 2022 10:25:31 +0200 Subject: [PATCH 081/142] Update index.ts --- src/index.ts | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/index.ts b/src/index.ts index c083eae..10146ea 100644 --- a/src/index.ts +++ b/src/index.ts @@ -9,18 +9,14 @@ import schedules from "@schedules"; import events from "@handlers/events"; import commands from "@handlers/commands"; -async function main() { const client = new Client({ intents, }); - await database(); - await schedules(client); + database(); + schedules(client); - await commands(client); - await events(client); + commands(client); + events(client); - await client.login(token); -} - -main(); + client.login(token); From adfcfc351ea14227dfd4a5433b9879423ef3d76f Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Tue, 17 May 2022 08:25:43 +0000 Subject: [PATCH 082/142] Format code with standardjs and prettier This commit fixes the style issues introduced in 0e17d18 according to the output from standardjs and prettier. Details: https://deepsource.io/gh/ZynerOrg/xyter/transform/4fb6bb32-c06b-48bd-834b-0bcb329b4e85/ --- src/index.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/index.ts b/src/index.ts index 10146ea..eb0f8fb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -9,14 +9,14 @@ import schedules from "@schedules"; import events from "@handlers/events"; import commands from "@handlers/commands"; - const client = new Client({ - intents, - }); +const client = new Client({ + intents, +}); - database(); - schedules(client); +database(); +schedules(client); - commands(client); - events(client); +commands(client); +events(client); - client.login(token); +client.login(token); From 89a2001b217dc192f52a95ea602cc336bb387cde Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Tue, 17 May 2022 08:27:02 +0000 Subject: [PATCH 083/142] Format code with standardjs and prettier This commit fixes the style issues introduced in 0e17d18 according to the output from standardjs and prettier. Details: https://deepsource.io/gh/ZynerOrg/xyter/transform/5fe95853-443c-42e6-8991-b4f60bc662b9/ --- src/index.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/index.ts b/src/index.ts index 10146ea..eb0f8fb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -9,14 +9,14 @@ import schedules from "@schedules"; import events from "@handlers/events"; import commands from "@handlers/commands"; - const client = new Client({ - intents, - }); +const client = new Client({ + intents, +}); - database(); - schedules(client); +database(); +schedules(client); - commands(client); - events(client); +commands(client); +events(client); - client.login(token); +client.login(token); From 61a6f8c7c3ef929106169a974123e2dc26b7eb25 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Tue, 17 May 2022 10:28:05 +0200 Subject: [PATCH 084/142] Update index.ts --- src/index.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/index.ts b/src/index.ts index 10146ea..b3779fe 100644 --- a/src/index.ts +++ b/src/index.ts @@ -9,6 +9,7 @@ import schedules from "@schedules"; import events from "@handlers/events"; import commands from "@handlers/commands"; +const main = async () => { const client = new Client({ intents, }); @@ -20,3 +21,6 @@ import commands from "@handlers/commands"; events(client); client.login(token); +} + +main().then(async () => {logger.silly("Main process started")}).catch(async (err) => {logger.error(err)}) From 98965cf9525a361e18eee81e2214ec8267579625 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Tue, 17 May 2022 08:28:25 +0000 Subject: [PATCH 085/142] Format code with standardjs and prettier This commit fixes the style issues introduced in 61a6f8c according to the output from standardjs and prettier. Details: https://deepsource.io/gh/ZynerOrg/xyter/transform/3a37bf8c-ce14-4906-aea6-f735b702251d/ --- src/index.ts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/index.ts b/src/index.ts index b3779fe..61a0290 100644 --- a/src/index.ts +++ b/src/index.ts @@ -14,13 +14,19 @@ const main = async () => { intents, }); - database(); - schedules(client); + database(); + schedules(client); - commands(client); - events(client); + commands(client); + events(client); - client.login(token); -} + client.login(token); +}; -main().then(async () => {logger.silly("Main process started")}).catch(async (err) => {logger.error(err)}) +main() + .then(async () => { + logger.silly("Main process started"); + }) + .catch(async (err) => { + logger.error(err); + }); From d78502b373ceb9c2db058ac1a28abbaaae4c2370 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Tue, 17 May 2022 08:29:20 +0000 Subject: [PATCH 086/142] Format code with standardjs and prettier This commit fixes the style issues introduced in 61a6f8c according to the output from standardjs and prettier. Details: https://deepsource.io/gh/ZynerOrg/xyter/transform/5748ec0d-dd21-431e-abe5-6b7058ce1e4d/ --- src/index.ts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/index.ts b/src/index.ts index b3779fe..61a0290 100644 --- a/src/index.ts +++ b/src/index.ts @@ -14,13 +14,19 @@ const main = async () => { intents, }); - database(); - schedules(client); + database(); + schedules(client); - commands(client); - events(client); + commands(client); + events(client); - client.login(token); -} + client.login(token); +}; -main().then(async () => {logger.silly("Main process started")}).catch(async (err) => {logger.error(err)}) +main() + .then(async () => { + logger.silly("Main process started"); + }) + .catch(async (err) => { + logger.error(err); + }); From a2f7331a8b0364ae86c8895c653d60aa053cfbde Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Tue, 17 May 2022 10:29:58 +0200 Subject: [PATCH 087/142] Update index.ts --- src/index.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index b3779fe..c7f3d44 100644 --- a/src/index.ts +++ b/src/index.ts @@ -14,11 +14,14 @@ const main = async () => { intents, }); - database(); - schedules(client); + database().then(async () => {logger.silly("Database process started")}).catch(async (err) => {logger.error(err)}) +schedules(client).then(async () => {logger.silly("Schedules process started")}).catch(async (err) => {logger.error(err)}) + + + commands(client).then(async () => {logger.silly("Commands process started")}).catch(async (err) => {logger.error(err)}) + + events(client).then(async () => {logger.silly("Events process started")}).catch(async (err) => {logger.error(err)}) - commands(client); - events(client); client.login(token); } From 6ad5fb594f89009da1c2bf4019919330ba2c7468 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Tue, 17 May 2022 08:30:10 +0000 Subject: [PATCH 088/142] Format code with standardjs and prettier This commit fixes the style issues introduced in a2f7331 according to the output from standardjs and prettier. Details: https://deepsource.io/gh/ZynerOrg/xyter/transform/6a5bea9d-2373-4948-a812-6408f021af8c/ --- src/index.ts | 46 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/src/index.ts b/src/index.ts index c7f3d44..9e86641 100644 --- a/src/index.ts +++ b/src/index.ts @@ -14,16 +14,44 @@ const main = async () => { intents, }); - database().then(async () => {logger.silly("Database process started")}).catch(async (err) => {logger.error(err)}) -schedules(client).then(async () => {logger.silly("Schedules process started")}).catch(async (err) => {logger.error(err)}) + database() + .then(async () => { + logger.silly("Database process started"); + }) + .catch(async (err) => { + logger.error(err); + }); + schedules(client) + .then(async () => { + logger.silly("Schedules process started"); + }) + .catch(async (err) => { + logger.error(err); + }); + commands(client) + .then(async () => { + logger.silly("Commands process started"); + }) + .catch(async (err) => { + logger.error(err); + }); - commands(client).then(async () => {logger.silly("Commands process started")}).catch(async (err) => {logger.error(err)}) + events(client) + .then(async () => { + logger.silly("Events process started"); + }) + .catch(async (err) => { + logger.error(err); + }); - events(client).then(async () => {logger.silly("Events process started")}).catch(async (err) => {logger.error(err)}) + client.login(token); +}; - - client.login(token); -} - -main().then(async () => {logger.silly("Main process started")}).catch(async (err) => {logger.error(err)}) +main() + .then(async () => { + logger.silly("Main process started"); + }) + .catch(async (err) => { + logger.error(err); + }); From 45d9588c66013652876a7878bc9ae97eadb48699 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Tue, 17 May 2022 08:30:18 +0000 Subject: [PATCH 089/142] Format code with standardjs and prettier This commit fixes the style issues introduced in a2f7331 according to the output from standardjs and prettier. Details: https://deepsource.io/gh/ZynerOrg/xyter/transform/9baf351b-16dd-4add-80de-54a38c3ce023/ --- src/index.ts | 46 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/src/index.ts b/src/index.ts index c7f3d44..9e86641 100644 --- a/src/index.ts +++ b/src/index.ts @@ -14,16 +14,44 @@ const main = async () => { intents, }); - database().then(async () => {logger.silly("Database process started")}).catch(async (err) => {logger.error(err)}) -schedules(client).then(async () => {logger.silly("Schedules process started")}).catch(async (err) => {logger.error(err)}) + database() + .then(async () => { + logger.silly("Database process started"); + }) + .catch(async (err) => { + logger.error(err); + }); + schedules(client) + .then(async () => { + logger.silly("Schedules process started"); + }) + .catch(async (err) => { + logger.error(err); + }); + commands(client) + .then(async () => { + logger.silly("Commands process started"); + }) + .catch(async (err) => { + logger.error(err); + }); - commands(client).then(async () => {logger.silly("Commands process started")}).catch(async (err) => {logger.error(err)}) + events(client) + .then(async () => { + logger.silly("Events process started"); + }) + .catch(async (err) => { + logger.error(err); + }); - events(client).then(async () => {logger.silly("Events process started")}).catch(async (err) => {logger.error(err)}) + client.login(token); +}; - - client.login(token); -} - -main().then(async () => {logger.silly("Main process started")}).catch(async (err) => {logger.error(err)}) +main() + .then(async () => { + logger.silly("Main process started"); + }) + .catch(async (err) => { + logger.error(err); + }); From f02290b065d9c68036623713dee834f63f6d8499 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Tue, 17 May 2022 08:32:29 +0000 Subject: [PATCH 090/142] Format code with standardjs and prettier This commit fixes the style issues introduced in a6bb050 according to the output from standardjs and prettier. Details: https://deepsource.io/gh/ZynerOrg/xyter/transform/8d032216-17f3-4f71-9328-14160eaf3b90/ --- src/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 280fa91..9e86641 100644 --- a/src/index.ts +++ b/src/index.ts @@ -14,7 +14,6 @@ const main = async () => { intents, }); - database() .then(async () => { logger.silly("Database process started"); From c49b8b48379be0cf7a08827e91c0993ef2830ade Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Tue, 17 May 2022 08:33:43 +0000 Subject: [PATCH 091/142] Format code with standardjs and prettier This commit fixes the style issues introduced in 69cbbaa according to the output from standardjs and prettier. Details: https://deepsource.io/gh/ZynerOrg/xyter/transform/a0b957b7-58e0-4541-9efe-b33b6bb3494c/ --- src/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 05c712d..9e86641 100644 --- a/src/index.ts +++ b/src/index.ts @@ -55,4 +55,3 @@ main() .catch(async (err) => { logger.error(err); }); - From 5f74f022bcf0ad2764545fd0f30c6a23c2cec9fb Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Tue, 17 May 2022 08:34:10 +0000 Subject: [PATCH 092/142] Format code with standardjs and prettier This commit fixes the style issues introduced in 5d6017b according to the output from standardjs and prettier. Details: https://deepsource.io/gh/ZynerOrg/xyter/transform/de3cd5ec-d2fa-4fa0-8ed2-9f3abdb3ce43/ --- src/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 05c712d..9e86641 100644 --- a/src/index.ts +++ b/src/index.ts @@ -55,4 +55,3 @@ main() .catch(async (err) => { logger.error(err); }); - From a9938fac69fd376e7449f3c3138ae3ebdf873a26 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Tue, 17 May 2022 08:34:25 +0000 Subject: [PATCH 093/142] Format code with standardjs and prettier This commit fixes the style issues introduced in 390cdc0 according to the output from standardjs and prettier. Details: https://deepsource.io/gh/ZynerOrg/xyter/transform/ff1fb6ca-4dee-478b-a00f-bff5bbe35c82/ --- src/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 9e86641..5429d5e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -47,7 +47,6 @@ const main = async () => { client.login(token); }; - main() .then(async () => { logger.silly("Main process started"); From 9dbe6a83dbddbeb959a4fed74f3b65e0608cf054 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Tue, 17 May 2022 11:32:28 +0200 Subject: [PATCH 094/142] Update lookup.ts --- src/plugins/utility/modules/lookup.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/plugins/utility/modules/lookup.ts b/src/plugins/utility/modules/lookup.ts index ac48a4d..98800b9 100644 --- a/src/plugins/utility/modules/lookup.ts +++ b/src/plugins/utility/modules/lookup.ts @@ -1,16 +1,13 @@ import axios from "axios"; -import { CommandInteraction, MessageEmbed } from "discord.js"; +import { CommandInteraction } from "discord.js"; import { successColor, errorColor, - footerText, - footerIcon, } from "@config/embed"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; -import logger from "@logger"; import embedBuilder from "@root/helpers/embedBuilder"; export default { From 8eec235dfd5a40336e9ecf453fa6969041f5af63 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Tue, 17 May 2022 09:32:40 +0000 Subject: [PATCH 095/142] Format code with standardjs and prettier This commit fixes the style issues introduced in 9dbe6a8 according to the output from standardjs and prettier. Details: https://deepsource.io/gh/ZynerOrg/xyter/transform/ea47e9d9-074f-4db5-af76-2dc328f01aed/ --- src/plugins/utility/modules/lookup.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/plugins/utility/modules/lookup.ts b/src/plugins/utility/modules/lookup.ts index 98800b9..caf97e2 100644 --- a/src/plugins/utility/modules/lookup.ts +++ b/src/plugins/utility/modules/lookup.ts @@ -1,10 +1,7 @@ import axios from "axios"; import { CommandInteraction } from "discord.js"; -import { - successColor, - errorColor, -} from "@config/embed"; +import { successColor, errorColor } from "@config/embed"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; From 64ca8ce1134da61307cc1bb48c83d65998174c09 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Tue, 17 May 2022 09:32:50 +0000 Subject: [PATCH 096/142] Format code with standardjs and prettier This commit fixes the style issues introduced in 9dbe6a8 according to the output from standardjs and prettier. Details: https://deepsource.io/gh/ZynerOrg/xyter/transform/8e972825-22e6-4ab7-8625-e372745483c7/ --- src/plugins/utility/modules/lookup.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/plugins/utility/modules/lookup.ts b/src/plugins/utility/modules/lookup.ts index 98800b9..caf97e2 100644 --- a/src/plugins/utility/modules/lookup.ts +++ b/src/plugins/utility/modules/lookup.ts @@ -1,10 +1,7 @@ import axios from "axios"; import { CommandInteraction } from "discord.js"; -import { - successColor, - errorColor, -} from "@config/embed"; +import { successColor, errorColor } from "@config/embed"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; From bd1381408650112e4fa05a970a96b43742a56356 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Tue, 17 May 2022 11:41:00 +0200 Subject: [PATCH 097/142] Update index.ts --- src/index.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/index.ts b/src/index.ts index 5429d5e..3dee8bb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -9,19 +9,24 @@ import schedules from "@schedules"; import events from "@handlers/events"; import commands from "@handlers/commands"; +// Main process that starts all other sub processes const main = async () => { + // Initiate client object const client = new Client({ intents, }); - database() + // Start database manager + await database() .then(async () => { logger.silly("Database process started"); }) .catch(async (err) => { logger.error(err); }); - schedules(client) + + // Start schedule manager + await schedules(client) .then(async () => { logger.silly("Schedules process started"); }) @@ -29,7 +34,8 @@ const main = async () => { logger.error(err); }); - commands(client) + // Start command handler + await commands(client) .then(async () => { logger.silly("Commands process started"); }) @@ -37,7 +43,8 @@ const main = async () => { logger.error(err); }); - events(client) + // Start event handler + await events(client) .then(async () => { logger.silly("Events process started"); }) @@ -45,7 +52,8 @@ const main = async () => { logger.error(err); }); - client.login(token); + // Authorize with Discord's API + await client.login(token); }; main() .then(async () => { From 2f01a9022531de368128b40f6c63295cea9aad67 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Tue, 17 May 2022 09:41:13 +0000 Subject: [PATCH 098/142] Format code with standardjs and prettier This commit fixes the style issues introduced in bd13814 according to the output from standardjs and prettier. Details: https://deepsource.io/gh/ZynerOrg/xyter/transform/2f4c1179-e251-4872-b1fe-17d9ee58c932/ --- src/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index 3dee8bb..94fd85f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -24,9 +24,9 @@ const main = async () => { .catch(async (err) => { logger.error(err); }); - + // Start schedule manager - await schedules(client) + await schedules(client) .then(async () => { logger.silly("Schedules process started"); }) @@ -53,7 +53,7 @@ const main = async () => { }); // Authorize with Discord's API - await client.login(token); + await client.login(token); }; main() .then(async () => { From 547f66d88bcc799c95c581a46198bbcab0523182 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Tue, 17 May 2022 09:41:19 +0000 Subject: [PATCH 099/142] Format code with standardjs and prettier This commit fixes the style issues introduced in bd13814 according to the output from standardjs and prettier. Details: https://deepsource.io/gh/ZynerOrg/xyter/transform/f64d5a72-4b19-468a-a6b5-84f929d5db74/ --- src/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index 3dee8bb..94fd85f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -24,9 +24,9 @@ const main = async () => { .catch(async (err) => { logger.error(err); }); - + // Start schedule manager - await schedules(client) + await schedules(client) .then(async () => { logger.silly("Schedules process started"); }) @@ -53,7 +53,7 @@ const main = async () => { }); // Authorize with Discord's API - await client.login(token); + await client.login(token); }; main() .then(async () => { From 021e30c382000d9506da881d4f3920839d34a8d1 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Tue, 17 May 2022 11:46:45 +0200 Subject: [PATCH 100/142] Update index.ts --- src/logger/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/logger/index.ts b/src/logger/index.ts index ae96924..45c6fe9 100644 --- a/src/logger/index.ts +++ b/src/logger/index.ts @@ -3,7 +3,7 @@ import "winston-daily-rotate-file"; const { combine, timestamp, printf, colorize, align, json } = winston.format; -export default winston.createLogger({ +export default await winston.createLogger({ level: process.env.LOG_LEVEL || "silly", transports: [ new winston.transports.DailyRotateFile({ From e69f09c9c6a9336c92f9b20052fc800e1a5a9b1e Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Tue, 17 May 2022 11:48:50 +0200 Subject: [PATCH 101/142] Update index.ts --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 94fd85f..46bb504 100644 --- a/src/index.ts +++ b/src/index.ts @@ -19,7 +19,7 @@ const main = async () => { // Start database manager await database() .then(async () => { - logger.silly("Database process started"); + await logger.silly("Database process started"); }) .catch(async (err) => { logger.error(err); From 1bf45ba20d9a7e2a04d640662c4daaea2fb8cb5d Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Tue, 17 May 2022 11:51:25 +0200 Subject: [PATCH 102/142] Update index.ts --- src/logger/index.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/logger/index.ts b/src/logger/index.ts index 45c6fe9..8d95224 100644 --- a/src/logger/index.ts +++ b/src/logger/index.ts @@ -3,7 +3,10 @@ import "winston-daily-rotate-file"; const { combine, timestamp, printf, colorize, align, json } = winston.format; -export default await winston.createLogger({ +module.exports = { + // Logger initialized async-hronously + logger: async () => { +return winston.createLogger({ level: process.env.LOG_LEVEL || "silly", transports: [ new winston.transports.DailyRotateFile({ @@ -24,3 +27,4 @@ export default await winston.createLogger({ }), ], }); + }} From 58e1f3a2bb452c2763d224a34f4ba2fe3a20278a Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Tue, 17 May 2022 09:51:37 +0000 Subject: [PATCH 103/142] Format code with standardjs and prettier This commit fixes the style issues introduced in 1bf45ba according to the output from standardjs and prettier. Details: https://deepsource.io/gh/ZynerOrg/xyter/transform/e72eada3-2ce9-4223-b070-ed543abe2ba9/ --- src/logger/index.ts | 49 ++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/src/logger/index.ts b/src/logger/index.ts index 8d95224..c82f2ae 100644 --- a/src/logger/index.ts +++ b/src/logger/index.ts @@ -4,27 +4,30 @@ import "winston-daily-rotate-file"; const { combine, timestamp, printf, colorize, align, json } = winston.format; module.exports = { - // Logger initialized async-hronously - logger: async () => { -return winston.createLogger({ - level: process.env.LOG_LEVEL || "silly", - transports: [ - new winston.transports.DailyRotateFile({ - filename: "logs/combined-%DATE%.log", - datePattern: "YYYY-MM-DD", - maxFiles: "14d", - format: combine(timestamp(), json()), - }), - new winston.transports.Console({ - format: combine( - colorize({ all: true }), - timestamp({ - format: "YYYY-MM-DD HH:MM:ss", + // Logger initialized async-hronously + logger: async () => { + return winston.createLogger({ + level: process.env.LOG_LEVEL || "silly", + transports: [ + new winston.transports.DailyRotateFile({ + filename: "logs/combined-%DATE%.log", + datePattern: "YYYY-MM-DD", + maxFiles: "14d", + format: combine(timestamp(), json()), }), - align(), - printf((info) => `[${info.timestamp}] ${info.level}: ${info.message}`) - ), - }), - ], -}); - }} + new winston.transports.Console({ + format: combine( + colorize({ all: true }), + timestamp({ + format: "YYYY-MM-DD HH:MM:ss", + }), + align(), + printf( + (info) => `[${info.timestamp}] ${info.level}: ${info.message}` + ) + ), + }), + ], + }); + }, +}; From 017349c59aaceb6c970af2edfda05bd426e6ac53 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Tue, 17 May 2022 09:51:45 +0000 Subject: [PATCH 104/142] Format code with standardjs and prettier This commit fixes the style issues introduced in 1bf45ba according to the output from standardjs and prettier. Details: https://deepsource.io/gh/ZynerOrg/xyter/transform/0e77e7e1-b401-4c59-8430-b16034d661e0/ --- src/logger/index.ts | 49 ++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/src/logger/index.ts b/src/logger/index.ts index 8d95224..c82f2ae 100644 --- a/src/logger/index.ts +++ b/src/logger/index.ts @@ -4,27 +4,30 @@ import "winston-daily-rotate-file"; const { combine, timestamp, printf, colorize, align, json } = winston.format; module.exports = { - // Logger initialized async-hronously - logger: async () => { -return winston.createLogger({ - level: process.env.LOG_LEVEL || "silly", - transports: [ - new winston.transports.DailyRotateFile({ - filename: "logs/combined-%DATE%.log", - datePattern: "YYYY-MM-DD", - maxFiles: "14d", - format: combine(timestamp(), json()), - }), - new winston.transports.Console({ - format: combine( - colorize({ all: true }), - timestamp({ - format: "YYYY-MM-DD HH:MM:ss", + // Logger initialized async-hronously + logger: async () => { + return winston.createLogger({ + level: process.env.LOG_LEVEL || "silly", + transports: [ + new winston.transports.DailyRotateFile({ + filename: "logs/combined-%DATE%.log", + datePattern: "YYYY-MM-DD", + maxFiles: "14d", + format: combine(timestamp(), json()), }), - align(), - printf((info) => `[${info.timestamp}] ${info.level}: ${info.message}`) - ), - }), - ], -}); - }} + new winston.transports.Console({ + format: combine( + colorize({ all: true }), + timestamp({ + format: "YYYY-MM-DD HH:MM:ss", + }), + align(), + printf( + (info) => `[${info.timestamp}] ${info.level}: ${info.message}` + ) + ), + }), + ], + }); + }, +}; From 9780e8c32c3047996d75473d088eabdc7c2f41f1 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Tue, 17 May 2022 11:52:45 +0200 Subject: [PATCH 105/142] Update index.ts --- src/index.ts | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/index.ts b/src/index.ts index 46bb504..01ae110 100644 --- a/src/index.ts +++ b/src/index.ts @@ -22,43 +22,44 @@ const main = async () => { await logger.silly("Database process started"); }) .catch(async (err) => { - logger.error(err); + await logger.error(err); }); // Start schedule manager await schedules(client) .then(async () => { - logger.silly("Schedules process started"); + await logger.silly("Schedules process started"); }) .catch(async (err) => { - logger.error(err); + await logger.error(err); }); // Start command handler await commands(client) .then(async () => { - logger.silly("Commands process started"); + await logger.silly("Commands process started"); }) .catch(async (err) => { - logger.error(err); + await logger.error(err); }); // Start event handler await events(client) .then(async () => { - logger.silly("Events process started"); + await logger.silly("Events process started"); }) .catch(async (err) => { - logger.error(err); + await logger.error(err); }); // Authorize with Discord's API await client.login(token); }; -main() + +await main() .then(async () => { - logger.silly("Main process started"); + await logger.silly("Main process started"); }) .catch(async (err) => { - logger.error(err); + await logger.error(err); }); From 9a528e98fbf08b9cf40501836af989e237c98180 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Tue, 17 May 2022 09:52:56 +0000 Subject: [PATCH 106/142] Format code with standardjs and prettier This commit fixes the style issues introduced in 9780e8c according to the output from standardjs and prettier. Details: https://deepsource.io/gh/ZynerOrg/xyter/transform/dcd0e7f9-fa2c-4994-b383-8bbe416990d2/ --- src/index.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/index.ts b/src/index.ts index 01ae110..07562aa 100644 --- a/src/index.ts +++ b/src/index.ts @@ -31,25 +31,25 @@ const main = async () => { await logger.silly("Schedules process started"); }) .catch(async (err) => { - await logger.error(err); + await logger.error(err); }); // Start command handler await commands(client) .then(async () => { - await logger.silly("Commands process started"); + await logger.silly("Commands process started"); }) .catch(async (err) => { - await logger.error(err); + await logger.error(err); }); // Start event handler await events(client) .then(async () => { - await logger.silly("Events process started"); + await logger.silly("Events process started"); }) .catch(async (err) => { - await logger.error(err); + await logger.error(err); }); // Authorize with Discord's API @@ -58,8 +58,8 @@ const main = async () => { await main() .then(async () => { - await logger.silly("Main process started"); + await logger.silly("Main process started"); }) .catch(async (err) => { - await logger.error(err); + await logger.error(err); }); From dc837ecd974204212c51a9cd3fcf5260ee397145 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Tue, 17 May 2022 09:53:03 +0000 Subject: [PATCH 107/142] Format code with standardjs and prettier This commit fixes the style issues introduced in 9780e8c according to the output from standardjs and prettier. Details: https://deepsource.io/gh/ZynerOrg/xyter/transform/c3aef707-607b-4b3e-a03c-3e84dbc77e7f/ --- src/index.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/index.ts b/src/index.ts index 01ae110..07562aa 100644 --- a/src/index.ts +++ b/src/index.ts @@ -31,25 +31,25 @@ const main = async () => { await logger.silly("Schedules process started"); }) .catch(async (err) => { - await logger.error(err); + await logger.error(err); }); // Start command handler await commands(client) .then(async () => { - await logger.silly("Commands process started"); + await logger.silly("Commands process started"); }) .catch(async (err) => { - await logger.error(err); + await logger.error(err); }); // Start event handler await events(client) .then(async () => { - await logger.silly("Events process started"); + await logger.silly("Events process started"); }) .catch(async (err) => { - await logger.error(err); + await logger.error(err); }); // Authorize with Discord's API @@ -58,8 +58,8 @@ const main = async () => { await main() .then(async () => { - await logger.silly("Main process started"); + await logger.silly("Main process started"); }) .catch(async (err) => { - await logger.error(err); + await logger.error(err); }); From eeac9335e9e05c266224a33faf66878006ec724b Mon Sep 17 00:00:00 2001 From: snyk-bot Date: Wed, 18 May 2022 07:26:30 +0000 Subject: [PATCH 108/142] fix: upgrade @discordjs/builders from 0.12.0 to 0.13.0 Snyk has created this PR to upgrade @discordjs/builders from 0.12.0 to 0.13.0. See this package in npm: https://www.npmjs.com/package/@discordjs/builders See this project in Snyk: https://app.snyk.io/org/zyner/project/4ad0ecd9-b57c-4594-a520-da974699cb93?utm_source=github&utm_medium=referral&page=upgrade-pr --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b5ca226..9596c22 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "email": "vermium@zyner.org" }, "dependencies": { - "@discordjs/builders": "^0.12.0", + "@discordjs/builders": "^0.13.0", "@discordjs/rest": "^0.4.0", "axios": "^0.26.0", "chance": "^1.1.8", From 4dcd031f3b027452285ffac3ba84984647148717 Mon Sep 17 00:00:00 2001 From: snyk-bot Date: Wed, 18 May 2022 07:26:34 +0000 Subject: [PATCH 109/142] fix: upgrade discord-api-types from 0.31.2 to 0.32.0 Snyk has created this PR to upgrade discord-api-types from 0.31.2 to 0.32.0. See this package in npm: https://www.npmjs.com/package/discord-api-types See this project in Snyk: https://app.snyk.io/org/zyner/project/4ad0ecd9-b57c-4594-a520-da974699cb93?utm_source=github&utm_medium=referral&page=upgrade-pr --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b5ca226..ac3ef1d 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "chance": "^1.1.8", "common": "^0.2.5", "crypto": "^1.0.1", - "discord-api-types": "^0.31.0", + "discord-api-types": "^0.32.0", "discord.js": "^13.6.0", "i18next": "^21.6.13", "mongoose": "^6.2.3", From 7f0835813cb94c9faf6b3deea07dc7169efcd2c0 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 18 May 2022 18:18:34 +0200 Subject: [PATCH 110/142] =?UTF-8?q?=F0=9F=8E=A8=20data=20=3D>=20builder?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 3 ++ src/database/index.ts | 2 +- .../interactionCreate/components/isCommand.ts | 16 +++++----- src/handlers/commands.ts | 4 +-- src/handlers/deployCommands.ts | 10 +++---- ...etCommandMeta.ts => getCommandMetadata.ts} | 4 +-- src/plugins/counters/index.ts | 10 +++---- src/plugins/counters/modules/view/index.ts | 29 ++++--------------- src/plugins/credits/index.ts | 10 +++---- src/plugins/credits/modules/balance/index.ts | 4 +-- src/plugins/credits/modules/gift/index.ts | 4 +-- src/plugins/credits/modules/top/index.ts | 4 +-- src/plugins/credits/modules/work/index.ts | 4 +-- src/plugins/fun/index.ts | 4 +-- src/plugins/fun/modules/meme.ts | 4 +-- src/plugins/manage/groups/counters/index.ts | 6 ++-- .../groups/counters/modules/add/index.ts | 4 +-- .../groups/counters/modules/remove/index.ts | 4 +-- src/plugins/manage/groups/credits/index.ts | 10 +++---- .../groups/credits/modules/give/index.ts | 4 +-- .../groups/credits/modules/set/index.ts | 4 +-- .../groups/credits/modules/take/index.ts | 4 +-- .../groups/credits/modules/transfer/index.ts | 4 +-- src/plugins/manage/index.ts | 6 ++-- src/plugins/profile/index.ts | 4 +-- src/plugins/profile/modules/view.ts | 4 +-- src/plugins/reputation/index.ts | 4 +-- src/plugins/reputation/modules/give.ts | 4 +-- src/plugins/settings/groups/guild/index.ts | 14 ++++----- .../settings/groups/guild/modules/audits.ts | 4 +-- .../settings/groups/guild/modules/credits.ts | 4 +-- .../settings/groups/guild/modules/points.ts | 4 +-- .../groups/guild/modules/pterodactyl.ts | 4 +-- .../settings/groups/guild/modules/shop.ts | 4 +-- .../settings/groups/guild/modules/welcome.ts | 4 +-- src/plugins/settings/index.ts | 4 +-- src/plugins/shop/groups/roles/index.ts | 6 ++-- src/plugins/shop/groups/roles/modules/buy.ts | 4 +-- .../shop/groups/roles/modules/cancel.ts | 4 +-- src/plugins/shop/index.ts | 6 ++-- src/plugins/shop/modules/pterodactyl.ts | 4 +-- src/plugins/utility/index.ts | 10 +++---- src/plugins/utility/modules/about.ts | 4 +-- src/plugins/utility/modules/avatar.ts | 4 +-- src/plugins/utility/modules/lookup.ts | 4 +-- src/plugins/utility/modules/stats.ts | 4 +-- 46 files changed, 126 insertions(+), 140 deletions(-) rename src/helpers/{getCommandMeta.ts => getCommandMetadata.ts} (83%) diff --git a/package.json b/package.json index 19e6995..438ae9b 100644 --- a/package.json +++ b/package.json @@ -30,14 +30,17 @@ "@crowdin/ota-client": "^0.7.0", "@discordjs/builders": "^0.13.0", "@discordjs/rest": "^0.4.0", + "@types/i18next-fs-backend": "^1.1.2", "axios": "^0.27.0", "chance": "^1.1.8", "common": "^0.2.5", "crypto": "^1.0.1", "discord-api-types": "^0.33.0", "discord.js": "^13.6.0", + "i18n": "^0.14.2", "i18next": "^21.6.13", "i18next-async-backend": "^2.0.0", + "i18next-fs-backend": "^1.1.4", "i18next-http-backend": "^1.4.0", "i18next-resources-to-backend": "^1.0.0", "mongoose": "^6.2.3", diff --git a/src/database/index.ts b/src/database/index.ts index af3b524..b7dd3b6 100644 --- a/src/database/index.ts +++ b/src/database/index.ts @@ -13,7 +13,7 @@ export default async () => { }); mongoose.connection.on("error", async (error) => { - logger.error(error); + logger.error(`${error}`); }); mongoose.connection.on("warn", async (warning) => { diff --git a/src/events/interactionCreate/components/isCommand.ts b/src/events/interactionCreate/components/isCommand.ts index 93902fe..fa6677b 100644 --- a/src/events/interactionCreate/components/isCommand.ts +++ b/src/events/interactionCreate/components/isCommand.ts @@ -6,7 +6,7 @@ import logger from "@logger"; import { errorColor, footerText, footerIcon } from "@config/embed"; import i18next from "i18next"; import deferReply from "@root/helpers/deferReply"; -import getCommandMeta from "@root/helpers/getCommandMeta"; +import getCommandMetadata from "@root/helpers/getCommandMetadata"; export default async (interaction: CommandInteraction) => { if (!interaction.isCommand()) return; @@ -19,14 +19,14 @@ export default async (interaction: CommandInteraction) => { logger.silly(`Command ${commandName} not found`); } - const meta = await getCommandMeta(interaction, currentCommand); + const metadata = await getCommandMetadata(interaction, currentCommand); - await deferReply(interaction, meta.ephemeral || false); + await deferReply(interaction, metadata.ephemeral || false); if ( - meta.permissions && - meta.guildOnly && - !memberPermissions?.has(meta.permissions) + metadata.permissions && + metadata.guildOnly && + !memberPermissions?.has(metadata.permissions) ) { return interaction?.editReply({ embeds: [ @@ -40,7 +40,7 @@ export default async (interaction: CommandInteraction) => { }); } - if (meta.guildOnly) { + if (metadata.guildOnly) { if (!guild) { logger.verbose(`Guild is null`); @@ -61,7 +61,7 @@ export default async (interaction: CommandInteraction) => { } } - if (meta.dmOnly) { + if (metadata.dmOnly) { if (guild) { logger.verbose(`Guild exist`); diff --git a/src/handlers/commands.ts b/src/handlers/commands.ts index f5cfed0..9c109c4 100644 --- a/src/handlers/commands.ts +++ b/src/handlers/commands.ts @@ -16,9 +16,9 @@ export default async (client: Client) => { const plugin = await import(`../plugins/${pluginName}`); await client.commands.set( - plugin.default.data.name, + plugin.default.builder.name, plugin.default, - plugin.default.meta + plugin.default.metadata ); }) ) diff --git a/src/handlers/deployCommands.ts b/src/handlers/deployCommands.ts index d408886..937447a 100644 --- a/src/handlers/deployCommands.ts +++ b/src/handlers/deployCommands.ts @@ -12,9 +12,9 @@ export default async (client: Client) => { await Promise.all( client.commands.map(async (pluginData: any) => { - pluginList.push(pluginData.data.toJSON()); + pluginList.push(pluginData.builder.toJSON()); logger.verbose( - `${pluginData.data.name} successfully pushed to plugin list.` + `${pluginData.builder.name} successfully pushed to plugin list.` ); }) ) @@ -22,7 +22,7 @@ export default async (client: Client) => { logger.debug("Successfully pushed all plugins to plugin list."); }) .catch(async (error) => { - logger.error(error); + logger.error(`${error}`); }); const rest = new REST({ version: "9" }).setToken(token); @@ -35,7 +35,7 @@ export default async (client: Client) => { logger.debug(`Successfully deployed plugins to Discord`); }) .catch(async (error) => { - logger.error(error); + logger.error(`${error}`); }); if (devMode) { @@ -47,7 +47,7 @@ export default async (client: Client) => { logger.debug(`Successfully deployed guild plugins to Discord`) ) .catch(async (error) => { - logger.error(error); + logger.error(`${error}`); }); } }; diff --git a/src/helpers/getCommandMeta.ts b/src/helpers/getCommandMetadata.ts similarity index 83% rename from src/helpers/getCommandMeta.ts rename to src/helpers/getCommandMetadata.ts index cba46e3..c68efec 100644 --- a/src/helpers/getCommandMeta.ts +++ b/src/helpers/getCommandMetadata.ts @@ -5,8 +5,8 @@ export default async (interaction: CommandInteraction, currentCommand: any) => { const subcommandGroup = interaction.options.getSubcommandGroup(false); if (!subcommandGroup) { - return currentCommand.modules[subcommand].meta; + return currentCommand.modules[subcommand].metadata; } - return currentCommand.groups[subcommandGroup].modules[subcommand].meta; + return currentCommand.groups[subcommandGroup].modules[subcommand].metadata; }; diff --git a/src/plugins/counters/index.ts b/src/plugins/counters/index.ts index 1bd7c7b..b0fe5fb 100644 --- a/src/plugins/counters/index.ts +++ b/src/plugins/counters/index.ts @@ -7,20 +7,20 @@ import modules from "@plugins/counters/modules"; export default { modules, - data: new SlashCommandBuilder() + builder: new SlashCommandBuilder() .setName("counters") .setDescription("View guild counters") - .addSubcommand(modules.view.data), + .addSubcommand(modules.view.builder), async execute(interaction: CommandInteraction) { const { options } = interaction; - if (options?.getSubcommand() === "view") { - logger?.verbose(`Executing view subcommand`); + if (options.getSubcommand() === "view") { + logger.verbose(`Executing view subcommand`); return modules.view.execute(interaction); } - logger?.verbose(`Unknown subcommand ${options?.getSubcommand()}`); + logger.verbose(`Unknown subcommand ${options.getSubcommand()}`); }, }; diff --git a/src/plugins/counters/modules/view/index.ts b/src/plugins/counters/modules/view/index.ts index 7f4d1e0..3697aa2 100644 --- a/src/plugins/counters/modules/view/index.ts +++ b/src/plugins/counters/modules/view/index.ts @@ -10,12 +10,11 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChannelType } from "discord-api-types/v10"; import counterSchema from "@schemas/counter"; -import i18next from "i18next"; export default { - meta: { guildOnly: true, ephemeral: false }, + metadata: { guildOnly: true, ephemeral: false }, - data: (command: SlashCommandSubcommandBuilder) => { + builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("view") .setDescription(`View a guild counter`) @@ -31,17 +30,12 @@ export default { }, execute: async (interaction: CommandInteraction) => { - const { options, guild, locale } = interaction; + const { options, guild } = interaction; const discordChannel = options?.getChannel("channel"); const embed = new MessageEmbed() - .setTitle( - i18next.t("counters:modules:view:general:title", { - lng: locale, - ns: "plugins", - }) - ) + .setTitle("[:1234:] Counters (View)") .setTimestamp(new Date()) .setFooter({ text: footerText, @@ -57,13 +51,7 @@ export default { return interaction?.editReply({ embeds: [ embed - .setDescription( - i18next.t("counters:modules:view:error01:description", { - lng: locale, - ns: "plugins", - channel: discordChannel, - }) - ) + .setDescription(`No counter found for channel ${discordChannel}!`) .setColor(errorColor), ], }); @@ -73,12 +61,7 @@ export default { embeds: [ embed .setDescription( - i18next.t("counters:modules:view:success01:description", { - lng: locale, - ns: "plugins", - channel: discordChannel, - amount: counter.counter, - }) + `Viewing counter for channel ${discordChannel}: ${counter.counter}!` ) .setColor(successColor), ], diff --git a/src/plugins/credits/index.ts b/src/plugins/credits/index.ts index 2ec3c92..ee6e8bd 100644 --- a/src/plugins/credits/index.ts +++ b/src/plugins/credits/index.ts @@ -7,14 +7,14 @@ import modules from "@plugins/credits/modules"; export default { modules, - data: new SlashCommandBuilder() + builder: new SlashCommandBuilder() .setName("credits") .setDescription("Manage your credits.") - .addSubcommand(modules.balance.data) - .addSubcommand(modules.gift.data) - .addSubcommand(modules.top.data) - .addSubcommand(modules.work.data), + .addSubcommand(modules.balance.builder) + .addSubcommand(modules.gift.builder) + .addSubcommand(modules.top.builder) + .addSubcommand(modules.work.builder), async execute(interaction: CommandInteraction) { const { options } = interaction; diff --git a/src/plugins/credits/modules/balance/index.ts b/src/plugins/credits/modules/balance/index.ts index 44ac45a..f0fed23 100644 --- a/src/plugins/credits/modules/balance/index.ts +++ b/src/plugins/credits/modules/balance/index.ts @@ -13,8 +13,8 @@ import logger from "@logger"; import fetchUser from "@helpers/fetchUser"; export default { - meta: { guildOnly: true, ephemeral: true }, - data: (command: SlashCommandSubcommandBuilder) => { + metadata: { guildOnly: true, ephemeral: true }, + builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("balance") .setDescription(`View a user's balance`) diff --git a/src/plugins/credits/modules/gift/index.ts b/src/plugins/credits/modules/gift/index.ts index 82b6a28..6e2dbea 100644 --- a/src/plugins/credits/modules/gift/index.ts +++ b/src/plugins/credits/modules/gift/index.ts @@ -22,9 +22,9 @@ import i18next from "i18next"; // Function export default { - meta: { guildOnly: true, ephemeral: true }, + metadata: { guildOnly: true, ephemeral: true }, - data: (command: SlashCommandSubcommandBuilder) => { + builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("gift") .setDescription(`Gift a user credits`) diff --git a/src/plugins/credits/modules/top/index.ts b/src/plugins/credits/modules/top/index.ts index 1656c59..b21eb11 100644 --- a/src/plugins/credits/modules/top/index.ts +++ b/src/plugins/credits/modules/top/index.ts @@ -13,9 +13,9 @@ import logger from "@logger"; import userSchema, { IUser } from "@schemas/user"; export default { - meta: { guildOnly: true, ephemeral: false }, + metadata: { guildOnly: true, ephemeral: false }, - data: (command: SlashCommandSubcommandBuilder) => { + builder: (command: SlashCommandSubcommandBuilder) => { return command.setName("top").setDescription(`View the top users`); }, execute: async (interaction: CommandInteraction) => { diff --git a/src/plugins/credits/modules/work/index.ts b/src/plugins/credits/modules/work/index.ts index 37d743c..440460a 100644 --- a/src/plugins/credits/modules/work/index.ts +++ b/src/plugins/credits/modules/work/index.ts @@ -23,9 +23,9 @@ import fetchGuild from "@helpers/fetchGuild"; import i18next from "i18next"; export default { - meta: { guildOnly: true, ephemeral: true }, + metadata: { guildOnly: true, ephemeral: true }, - data: (command: SlashCommandSubcommandBuilder) => { + builder: (command: SlashCommandSubcommandBuilder) => { return command.setName("work").setDescription(`Work to earn credits`); }, execute: async (interaction: CommandInteraction) => { diff --git a/src/plugins/fun/index.ts b/src/plugins/fun/index.ts index 0d727dc..c5c26fd 100644 --- a/src/plugins/fun/index.ts +++ b/src/plugins/fun/index.ts @@ -7,11 +7,11 @@ import modules from "@plugins/fun/modules"; export default { modules, - data: new SlashCommandBuilder() + builder: new SlashCommandBuilder() .setName("fun") .setDescription("Fun commands.") - .addSubcommand(modules.meme.data), + .addSubcommand(modules.meme.builder), async execute(interaction: CommandInteraction) { const { options } = interaction; diff --git a/src/plugins/fun/modules/meme.ts b/src/plugins/fun/modules/meme.ts index 40d5cdb..fb0c3c8 100644 --- a/src/plugins/fun/modules/meme.ts +++ b/src/plugins/fun/modules/meme.ts @@ -6,9 +6,9 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import logger from "@logger"; export default { - meta: { guildOnly: false, ephemeral: false }, + metadata: { guildOnly: false, ephemeral: false }, - data: (command: SlashCommandSubcommandBuilder) => { + builder: (command: SlashCommandSubcommandBuilder) => { return command.setName("meme").setDescription("Get a meme from r/memes)"); }, execute: async (interaction: CommandInteraction) => { diff --git a/src/plugins/manage/groups/counters/index.ts b/src/plugins/manage/groups/counters/index.ts index 2a16b04..6d54522 100644 --- a/src/plugins/manage/groups/counters/index.ts +++ b/src/plugins/manage/groups/counters/index.ts @@ -11,12 +11,12 @@ import modules from "./modules"; export default { modules, - data: (group: SlashCommandSubcommandGroupBuilder) => { + builder: (group: SlashCommandSubcommandGroupBuilder) => { return group .setName("counters") .setDescription("Manage guild counters.") - .addSubcommand(modules.add.data) - .addSubcommand(modules.remove.data); + .addSubcommand(modules.add.builder) + .addSubcommand(modules.remove.builder); }, execute: async (interaction: CommandInteraction) => { diff --git a/src/plugins/manage/groups/counters/modules/add/index.ts b/src/plugins/manage/groups/counters/modules/add/index.ts index 5320937..09e1f56 100644 --- a/src/plugins/manage/groups/counters/modules/add/index.ts +++ b/src/plugins/manage/groups/counters/modules/add/index.ts @@ -20,13 +20,13 @@ import i18next from "i18next"; // Function export default { - meta: { + metadata: { guildOnly: true, ephemeral: true, permissions: [Permissions.FLAGS.MANAGE_GUILD], }, - data: (command: SlashCommandSubcommandBuilder) => { + builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("add") .setDescription("Add a counter to your guild.") diff --git a/src/plugins/manage/groups/counters/modules/remove/index.ts b/src/plugins/manage/groups/counters/modules/remove/index.ts index b707b45..72f90e8 100644 --- a/src/plugins/manage/groups/counters/modules/remove/index.ts +++ b/src/plugins/manage/groups/counters/modules/remove/index.ts @@ -20,13 +20,13 @@ import i18next from "i18next"; // Function export default { - meta: { + metadata: { guildOnly: true, ephemeral: true, permissions: [Permissions.FLAGS.MANAGE_GUILD], }, - data: (command: SlashCommandSubcommandBuilder) => { + builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("remove") .setDescription(`Delete a counter from your guild.`) diff --git a/src/plugins/manage/groups/credits/index.ts b/src/plugins/manage/groups/credits/index.ts index fc0839c..c342f7a 100644 --- a/src/plugins/manage/groups/credits/index.ts +++ b/src/plugins/manage/groups/credits/index.ts @@ -7,14 +7,14 @@ import modules from "./modules"; export default { modules, - data: (group: SlashCommandSubcommandGroupBuilder) => { + builder: (group: SlashCommandSubcommandGroupBuilder) => { return group .setName("credits") .setDescription("Manage the credits of a user.") - .addSubcommand(modules.give.data) - .addSubcommand(modules.set.data) - .addSubcommand(modules.take.data) - .addSubcommand(modules.transfer.data); + .addSubcommand(modules.give.builder) + .addSubcommand(modules.set.builder) + .addSubcommand(modules.take.builder) + .addSubcommand(modules.transfer.builder); }, execute: async (interaction: CommandInteraction) => { const { options } = interaction; diff --git a/src/plugins/manage/groups/credits/modules/give/index.ts b/src/plugins/manage/groups/credits/modules/give/index.ts index 38e272c..fd52097 100644 --- a/src/plugins/manage/groups/credits/modules/give/index.ts +++ b/src/plugins/manage/groups/credits/modules/give/index.ts @@ -21,13 +21,13 @@ import fetchUser from "@helpers/fetchUser"; // Function export default { - meta: { + metadata: { guildOnly: true, ephemeral: true, permissions: [Permissions.FLAGS.MANAGE_GUILD], }, - data: (command: SlashCommandSubcommandBuilder) => { + builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("give") .setDescription("Give credits to a user.") diff --git a/src/plugins/manage/groups/credits/modules/set/index.ts b/src/plugins/manage/groups/credits/modules/set/index.ts index a2b8e18..29bd6ab 100644 --- a/src/plugins/manage/groups/credits/modules/set/index.ts +++ b/src/plugins/manage/groups/credits/modules/set/index.ts @@ -20,13 +20,13 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Function export default { - meta: { + metadata: { guildOnly: true, ephemeral: true, permissions: [Permissions.FLAGS.MANAGE_GUILD], }, - data: (command: SlashCommandSubcommandBuilder) => { + builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("set") .setDescription("Set the amount of credits a user has.") diff --git a/src/plugins/manage/groups/credits/modules/take/index.ts b/src/plugins/manage/groups/credits/modules/take/index.ts index 53b2864..21327b3 100644 --- a/src/plugins/manage/groups/credits/modules/take/index.ts +++ b/src/plugins/manage/groups/credits/modules/take/index.ts @@ -21,13 +21,13 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Function export default { - meta: { + metadata: { guildOnly: true, ephemeral: true, permissions: [Permissions.FLAGS.MANAGE_GUILD], }, - data: (command: SlashCommandSubcommandBuilder) => { + builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("take") .setDescription("Take credits from a user.") diff --git a/src/plugins/manage/groups/credits/modules/transfer/index.ts b/src/plugins/manage/groups/credits/modules/transfer/index.ts index 4423ca5..250c015 100644 --- a/src/plugins/manage/groups/credits/modules/transfer/index.ts +++ b/src/plugins/manage/groups/credits/modules/transfer/index.ts @@ -21,13 +21,13 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Function export default { - meta: { + metadata: { guildOnly: true, ephemeral: true, permissions: [Permissions.FLAGS.MANAGE_GUILD], }, - data: (command: SlashCommandSubcommandBuilder) => { + builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("transfer") .setDescription("Transfer credits from one user to another.") diff --git a/src/plugins/manage/index.ts b/src/plugins/manage/index.ts index 4fb4165..4cd2ff2 100644 --- a/src/plugins/manage/index.ts +++ b/src/plugins/manage/index.ts @@ -10,11 +10,11 @@ import logger from "@logger"; export default { groups, - data: new SlashCommandBuilder() + builder: new SlashCommandBuilder() .setName("manage") .setDescription("Manage the bot.") - .addSubcommandGroup(groups.counters.data) - .addSubcommandGroup(groups.credits.data), + .addSubcommandGroup(groups.counters.builder) + .addSubcommandGroup(groups.credits.builder), async execute(interaction: CommandInteraction) { // Destructure diff --git a/src/plugins/profile/index.ts b/src/plugins/profile/index.ts index 1908543..4766d49 100644 --- a/src/plugins/profile/index.ts +++ b/src/plugins/profile/index.ts @@ -12,10 +12,10 @@ import logger from "@logger"; export default { modules, - data: new SlashCommandBuilder() + builder: new SlashCommandBuilder() .setName("profile") .setDescription("Check a profile.") - .addSubcommand(modules.view.data), + .addSubcommand(modules.view.builder), async execute(interaction: CommandInteraction) { const { options } = interaction; diff --git a/src/plugins/profile/modules/view.ts b/src/plugins/profile/modules/view.ts index 81bfc52..aeb8e62 100644 --- a/src/plugins/profile/modules/view.ts +++ b/src/plugins/profile/modules/view.ts @@ -12,9 +12,9 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Function export default { - meta: { guildOnly: true, ephemeral: false }, + metadata: { guildOnly: true, ephemeral: false }, - data: (command: SlashCommandSubcommandBuilder) => { + builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("view") .setDescription("View a profile.") diff --git a/src/plugins/reputation/index.ts b/src/plugins/reputation/index.ts index 7fd5218..9ee66d6 100644 --- a/src/plugins/reputation/index.ts +++ b/src/plugins/reputation/index.ts @@ -11,10 +11,10 @@ import logger from "@logger"; // Function export default { modules, - data: new SlashCommandBuilder() + builder: new SlashCommandBuilder() .setName("reputation") .setDescription("Manage reputation.") - .addSubcommand(modules.give.data), + .addSubcommand(modules.give.builder), async execute(interaction: CommandInteraction) { const { options } = interaction; diff --git a/src/plugins/reputation/modules/give.ts b/src/plugins/reputation/modules/give.ts index c3cdf3c..e3d6dff 100644 --- a/src/plugins/reputation/modules/give.ts +++ b/src/plugins/reputation/modules/give.ts @@ -21,9 +21,9 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Function export default { - meta: { guildOnly: true, ephemeral: true }, + metadata: { guildOnly: true, ephemeral: true }, - data: (command: SlashCommandSubcommandBuilder) => { + builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("give") .setDescription("Give reputation to a user") diff --git a/src/plugins/settings/groups/guild/index.ts b/src/plugins/settings/groups/guild/index.ts index b1344e1..973e678 100644 --- a/src/plugins/settings/groups/guild/index.ts +++ b/src/plugins/settings/groups/guild/index.ts @@ -13,16 +13,16 @@ import { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders"; export default { modules, - data: (group: SlashCommandSubcommandGroupBuilder) => { + builder: (group: SlashCommandSubcommandGroupBuilder) => { return group .setName("guild") .setDescription("Guild settings.") - .addSubcommand(modules.pterodactyl.data) - .addSubcommand(modules.credits.data) - .addSubcommand(modules.points.data) - .addSubcommand(modules.welcome.data) - .addSubcommand(modules.audits.data) - .addSubcommand(modules.shop.data); + .addSubcommand(modules.pterodactyl.builder) + .addSubcommand(modules.credits.builder) + .addSubcommand(modules.points.builder) + .addSubcommand(modules.welcome.builder) + .addSubcommand(modules.audits.builder) + .addSubcommand(modules.shop.builder); }, execute: async (interaction: CommandInteraction) => { // Destructure member diff --git a/src/plugins/settings/groups/guild/modules/audits.ts b/src/plugins/settings/groups/guild/modules/audits.ts index c54b4c2..06a325e 100644 --- a/src/plugins/settings/groups/guild/modules/audits.ts +++ b/src/plugins/settings/groups/guild/modules/audits.ts @@ -14,13 +14,13 @@ import { ChannelType } from "discord-api-types/v10"; // Function export default { - meta: { + metadata: { guildOnly: true, ephemeral: true, permissions: [Permissions.FLAGS.MANAGE_GUILD], }, - data: (command: SlashCommandSubcommandBuilder) => { + builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("audits") .setDescription("Audits") diff --git a/src/plugins/settings/groups/guild/modules/credits.ts b/src/plugins/settings/groups/guild/modules/credits.ts index 11589ab..7c29eda 100644 --- a/src/plugins/settings/groups/guild/modules/credits.ts +++ b/src/plugins/settings/groups/guild/modules/credits.ts @@ -13,13 +13,13 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Function export default { - meta: { + metadata: { guildOnly: true, ephemeral: true, permissions: [Permissions.FLAGS.MANAGE_GUILD], }, - data: (command: SlashCommandSubcommandBuilder) => { + builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("credits") .setDescription(`Credits`) diff --git a/src/plugins/settings/groups/guild/modules/points.ts b/src/plugins/settings/groups/guild/modules/points.ts index 75ea6a7..4379f04 100644 --- a/src/plugins/settings/groups/guild/modules/points.ts +++ b/src/plugins/settings/groups/guild/modules/points.ts @@ -13,13 +13,13 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Function export default { - meta: { + metadata: { guildOnly: true, ephemeral: true, permissions: [Permissions.FLAGS.MANAGE_GUILD], }, - data: (command: SlashCommandSubcommandBuilder) => { + builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("points") .setDescription("Points") diff --git a/src/plugins/settings/groups/guild/modules/pterodactyl.ts b/src/plugins/settings/groups/guild/modules/pterodactyl.ts index b595b80..13345d6 100644 --- a/src/plugins/settings/groups/guild/modules/pterodactyl.ts +++ b/src/plugins/settings/groups/guild/modules/pterodactyl.ts @@ -14,13 +14,13 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Function export default { - meta: { + metadata: { guildOnly: true, ephemeral: true, permissions: [Permissions.FLAGS.MANAGE_GUILD], }, - data: (command: SlashCommandSubcommandBuilder) => { + builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("pterodactyl") .setDescription("Controlpanel.gg") diff --git a/src/plugins/settings/groups/guild/modules/shop.ts b/src/plugins/settings/groups/guild/modules/shop.ts index 785c161..ffa6f4a 100644 --- a/src/plugins/settings/groups/guild/modules/shop.ts +++ b/src/plugins/settings/groups/guild/modules/shop.ts @@ -13,13 +13,13 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Function export default { - meta: { + metadata: { guildOnly: true, ephemeral: true, permissions: [Permissions.FLAGS.MANAGE_GUILD], }, - data: (command: SlashCommandSubcommandBuilder) => { + builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("shop") .setDescription("Shop") diff --git a/src/plugins/settings/groups/guild/modules/welcome.ts b/src/plugins/settings/groups/guild/modules/welcome.ts index ad0c05b..48fdae8 100644 --- a/src/plugins/settings/groups/guild/modules/welcome.ts +++ b/src/plugins/settings/groups/guild/modules/welcome.ts @@ -14,13 +14,13 @@ import { ChannelType } from "discord-api-types/v10"; // Function export default { - meta: { + metadata: { guildOnly: true, ephemeral: true, permissions: [Permissions.FLAGS.MANAGE_GUILD], }, - data: (command: SlashCommandSubcommandBuilder) => { + builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("welcome") .setDescription("Welcome") diff --git a/src/plugins/settings/index.ts b/src/plugins/settings/index.ts index c657e43..c55d10e 100644 --- a/src/plugins/settings/index.ts +++ b/src/plugins/settings/index.ts @@ -12,11 +12,11 @@ import logger from "@logger"; export default { groups, - data: new SlashCommandBuilder() + builder: new SlashCommandBuilder() .setName("settings") .setDescription("Manage settings.") - .addSubcommandGroup(groups.guild.data), + .addSubcommandGroup(groups.guild.builder), async execute(interaction: CommandInteraction) { const { options } = interaction; diff --git a/src/plugins/shop/groups/roles/index.ts b/src/plugins/shop/groups/roles/index.ts index 26135e6..0900764 100644 --- a/src/plugins/shop/groups/roles/index.ts +++ b/src/plugins/shop/groups/roles/index.ts @@ -16,12 +16,12 @@ import guildSchema from "@schemas/guild"; export default { modules, - data: (group: SlashCommandSubcommandGroupBuilder) => { + builder: (group: SlashCommandSubcommandGroupBuilder) => { return group .setName("roles") .setDescription("Shop for custom roles.") - .addSubcommand(modules.buy.data) - .addSubcommand(modules.cancel.data); + .addSubcommand(modules.buy.builder) + .addSubcommand(modules.cancel.builder); }, execute: async (interaction: CommandInteraction) => { const { options, guild } = interaction; diff --git a/src/plugins/shop/groups/roles/modules/buy.ts b/src/plugins/shop/groups/roles/modules/buy.ts index 1f8c54b..ed6a73b 100644 --- a/src/plugins/shop/groups/roles/modules/buy.ts +++ b/src/plugins/shop/groups/roles/modules/buy.ts @@ -25,9 +25,9 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Function export default { - meta: { guildOnly: true, ephemeral: true }, + metadata: { guildOnly: true, ephemeral: true }, - data: (command: SlashCommandSubcommandBuilder) => { + builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("buy") .setDescription("Buy a custom role.") diff --git a/src/plugins/shop/groups/roles/modules/cancel.ts b/src/plugins/shop/groups/roles/modules/cancel.ts index b35ef16..ee5e705 100644 --- a/src/plugins/shop/groups/roles/modules/cancel.ts +++ b/src/plugins/shop/groups/roles/modules/cancel.ts @@ -20,9 +20,9 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Function export default { - meta: { guildOnly: true, ephemeral: true }, + metadata: { guildOnly: true, ephemeral: true }, - data: (command: SlashCommandSubcommandBuilder) => { + builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("cancel") .setDescription("Cancel a purchase.") diff --git a/src/plugins/shop/index.ts b/src/plugins/shop/index.ts index f9af6d4..8c46187 100644 --- a/src/plugins/shop/index.ts +++ b/src/plugins/shop/index.ts @@ -16,11 +16,11 @@ export default { modules, groups, - data: new SlashCommandBuilder() + builder: new SlashCommandBuilder() .setName("shop") .setDescription("Shop for credits and custom roles.") - .addSubcommand(modules.pterodactyl.data) - .addSubcommandGroup(groups.roles.data), + .addSubcommand(modules.pterodactyl.builder) + .addSubcommandGroup(groups.roles.builder), async execute(interaction: CommandInteraction) { const { options } = interaction; diff --git a/src/plugins/shop/modules/pterodactyl.ts b/src/plugins/shop/modules/pterodactyl.ts index 6aeed22..3cde4d1 100644 --- a/src/plugins/shop/modules/pterodactyl.ts +++ b/src/plugins/shop/modules/pterodactyl.ts @@ -19,9 +19,9 @@ import fetchUser from "@helpers/fetchUser"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; export default { - meta: { guildOnly: true, ephemeral: true }, + metadata: { guildOnly: true, ephemeral: true }, - data: (command: SlashCommandSubcommandBuilder) => { + builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("pterodactyl") .setDescription("Buy pterodactyl power.") diff --git a/src/plugins/utility/index.ts b/src/plugins/utility/index.ts index 69e6268..6dc6fff 100644 --- a/src/plugins/utility/index.ts +++ b/src/plugins/utility/index.ts @@ -12,14 +12,14 @@ import logger from "../../logger"; export default { modules, - data: new SlashCommandBuilder() + builder: new SlashCommandBuilder() .setName("utility") .setDescription("Common utility.") - .addSubcommand(modules.lookup.data) - .addSubcommand(modules.about.data) - .addSubcommand(modules.stats.data) - .addSubcommand(modules.avatar.data), + .addSubcommand(modules.lookup.builder) + .addSubcommand(modules.about.builder) + .addSubcommand(modules.stats.builder) + .addSubcommand(modules.avatar.builder), async execute(interaction: CommandInteraction) { const { options } = interaction; diff --git a/src/plugins/utility/modules/about.ts b/src/plugins/utility/modules/about.ts index cfeb44e..35aa0c0 100644 --- a/src/plugins/utility/modules/about.ts +++ b/src/plugins/utility/modules/about.ts @@ -9,9 +9,9 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Function export default { - meta: { guildOnly: false, ephemeral: false }, + metadata: { guildOnly: false, ephemeral: false }, - data: (command: SlashCommandSubcommandBuilder) => { + builder: (command: SlashCommandSubcommandBuilder) => { return command.setName("about").setDescription("About this bot!)"); }, execute: async (interaction: CommandInteraction) => { diff --git a/src/plugins/utility/modules/avatar.ts b/src/plugins/utility/modules/avatar.ts index 9f57fb3..86494c1 100644 --- a/src/plugins/utility/modules/avatar.ts +++ b/src/plugins/utility/modules/avatar.ts @@ -5,9 +5,9 @@ import { CommandInteraction, MessageEmbed } from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; export default { - meta: { guildOnly: false, ephemeral: false }, + metadata: { guildOnly: false, ephemeral: false }, - data: (command: SlashCommandSubcommandBuilder) => { + builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("avatar") .setDescription("Check someones avatar!)") diff --git a/src/plugins/utility/modules/lookup.ts b/src/plugins/utility/modules/lookup.ts index ac48a4d..c3d2e26 100644 --- a/src/plugins/utility/modules/lookup.ts +++ b/src/plugins/utility/modules/lookup.ts @@ -14,9 +14,9 @@ import logger from "@logger"; import embedBuilder from "@root/helpers/embedBuilder"; export default { - meta: { guildOnly: false, ephemeral: false }, + metadata: { guildOnly: false, ephemeral: false }, - data: (command: SlashCommandSubcommandBuilder) => { + builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("lookup") .setDescription( diff --git a/src/plugins/utility/modules/stats.ts b/src/plugins/utility/modules/stats.ts index 3b02684..0014915 100644 --- a/src/plugins/utility/modules/stats.ts +++ b/src/plugins/utility/modules/stats.ts @@ -2,9 +2,9 @@ import { successColor, footerText, footerIcon } from "@config/embed"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { CommandInteraction } from "discord.js"; export default { - meta: { guildOnly: false, ephemeral: false }, + metadata: { guildOnly: false, ephemeral: false }, - data: (command: SlashCommandSubcommandBuilder) => { + builder: (command: SlashCommandSubcommandBuilder) => { return command.setName("stats").setDescription("Check bot statistics!)"); }, execute: async (interaction: CommandInteraction) => { From 21e2edd1f51ba2373297b8d127534f9c3ee8ce03 Mon Sep 17 00:00:00 2001 From: snyk-bot Date: Thu, 19 May 2022 07:51:58 +0000 Subject: [PATCH 111/142] fix: upgrade axios from 0.26.1 to 0.27.2 Snyk has created this PR to upgrade axios from 0.26.1 to 0.27.2. See this package in npm: https://www.npmjs.com/package/axios See this project in Snyk: https://app.snyk.io/org/zyner/project/4ad0ecd9-b57c-4594-a520-da974699cb93?utm_source=github&utm_medium=referral&page=upgrade-pr --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b5ca226..6100a44 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "dependencies": { "@discordjs/builders": "^0.12.0", "@discordjs/rest": "^0.4.0", - "axios": "^0.26.0", + "axios": "^0.27.2", "chance": "^1.1.8", "common": "^0.2.5", "crypto": "^1.0.1", From 209df02ccc1a2d598667b25dbd0d305a5b9be593 Mon Sep 17 00:00:00 2001 From: snyk-bot Date: Fri, 20 May 2022 07:43:38 +0000 Subject: [PATCH 112/142] fix: upgrade @discordjs/builders from 0.12.0 to 0.13.0 Snyk has created this PR to upgrade @discordjs/builders from 0.12.0 to 0.13.0. See this package in npm: https://www.npmjs.com/package/@discordjs/builders See this project in Snyk: https://app.snyk.io/org/zyner/project/4ad0ecd9-b57c-4594-a520-da974699cb93?utm_source=github&utm_medium=referral&page=upgrade-pr --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b5ca226..9596c22 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "email": "vermium@zyner.org" }, "dependencies": { - "@discordjs/builders": "^0.12.0", + "@discordjs/builders": "^0.13.0", "@discordjs/rest": "^0.4.0", "axios": "^0.26.0", "chance": "^1.1.8", From 39099ebaea9302d5ae7a59fdb9e7fec2b2d92a5d Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 20 May 2022 14:42:43 +0200 Subject: [PATCH 113/142] =?UTF-8?q?=F0=9F=8E=A8=20changed=20from=20/groups?= =?UTF-8?q?=20to=20/modules=20for=20plugins.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/events/guildCreate/index.ts | 2 +- src/events/guildDelete/index.ts | 2 +- src/events/guildMemberAdd/index.ts | 2 +- src/events/guildMemberRemove/index.ts | 2 +- src/events/index.ts | 22 ++++ .../interactionCreate/components/isCommand.ts | 23 +--- src/events/interactionCreate/index.ts | 2 +- .../messageCreate/modules/counters/index.ts | 10 +- .../messageCreate/modules/credits/index.ts | 8 +- .../messageCreate/modules/points/index.ts | 10 +- src/events/messageDelete/modules/counter.ts | 6 +- src/events/messageUpdate/index.ts | 5 +- src/events/messageUpdate/modules/counter.ts | 6 +- src/events/ready/index.ts | 4 +- src/handlers/commands.ts | 8 +- src/handlers/deployCommands.ts | 8 +- src/handlers/devMode.ts | 6 +- src/handlers/events.ts | 10 +- src/helpers/dropGuild.ts | 14 +-- src/helpers/dropUser.ts | 2 +- src/helpers/fetchGuild.ts | 2 +- src/helpers/fetchUser.ts | 2 +- src/helpers/getCommandMetadata.ts | 2 +- src/helpers/pluralize.ts | 2 +- src/helpers/saveUser.ts | 4 +- src/helpers/sleep.ts | 2 +- src/helpers/updatePresence.ts | 2 +- src/index.ts | 2 +- src/plugins/counters/index.ts | 4 +- src/plugins/credits/index.ts | 2 +- src/plugins/credits/modules/balance/index.ts | 50 ++------ src/plugins/credits/modules/gift/index.ts | 108 +++++------------- src/plugins/credits/modules/top/index.ts | 30 +---- src/plugins/credits/modules/work/index.ts | 35 ++---- src/plugins/fun/index.ts | 2 +- .../manage/groups/counters/modules/index.ts | 4 - .../manage/groups/credits/modules/index.ts | 6 - src/plugins/manage/groups/index.ts | 4 - src/plugins/manage/index.ts | 18 +-- .../{groups => modules}/counters/index.ts | 6 +- .../counters/modules/add/index.ts | 30 +---- .../manage/modules/counters/modules/index.ts | 4 + .../counters/modules/remove/index.ts | 28 +---- .../{groups => modules}/credits/index.ts | 10 +- .../credits/modules/give/index.ts | 12 +- .../manage/modules/credits/modules/index.ts | 6 + .../credits/modules/set/index.ts | 12 +- .../credits/modules/take/index.ts | 14 +-- .../credits/modules/transfer/index.ts | 18 +-- src/plugins/manage/modules/index.ts | 4 + src/plugins/profile/index.ts | 4 +- src/plugins/profile/modules/view.ts | 2 +- src/plugins/reputation/index.ts | 4 +- src/plugins/reputation/modules/give.ts | 16 +-- .../settings/groups/guild/modules/index.ts | 8 -- src/plugins/settings/groups/index.ts | 3 - src/plugins/settings/index.ts | 14 +-- .../{groups => modules}/guild/index.ts | 14 +-- .../guild/modules/audits.ts | 4 +- .../guild/modules/credits.ts | 4 +- .../settings/modules/guild/modules/index.ts | 8 ++ .../guild/modules/points.ts | 4 +- .../guild/modules/pterodactyl.ts | 2 +- .../{groups => modules}/guild/modules/shop.ts | 4 +- .../guild/modules/welcome.ts | 4 +- src/plugins/settings/modules/index.ts | 3 + src/plugins/shop/groups/index.ts | 3 - src/plugins/shop/index.ts | 14 +-- src/plugins/shop/modules/index.ts | 3 +- src/plugins/shop/modules/pterodactyl.ts | 20 ++-- .../shop/{groups => modules}/roles/index.ts | 6 +- .../{groups => modules}/roles/modules/buy.ts | 12 +- .../roles/modules/cancel.ts | 6 +- .../roles/modules/index.ts | 0 src/plugins/utility/modules/avatar.ts | 18 +-- src/schedules/jobs/shopRoles.ts | 8 +- 76 files changed, 300 insertions(+), 465 deletions(-) create mode 100644 src/events/index.ts delete mode 100644 src/plugins/manage/groups/counters/modules/index.ts delete mode 100644 src/plugins/manage/groups/credits/modules/index.ts delete mode 100644 src/plugins/manage/groups/index.ts rename src/plugins/manage/{groups => modules}/counters/index.ts (81%) rename src/plugins/manage/{groups => modules}/counters/modules/add/index.ts (74%) create mode 100644 src/plugins/manage/modules/counters/modules/index.ts rename src/plugins/manage/{groups => modules}/counters/modules/remove/index.ts (73%) rename src/plugins/manage/{groups => modules}/credits/index.ts (77%) rename src/plugins/manage/{groups => modules}/credits/modules/give/index.ts (94%) create mode 100644 src/plugins/manage/modules/credits/modules/index.ts rename src/plugins/manage/{groups => modules}/credits/modules/set/index.ts (93%) rename src/plugins/manage/{groups => modules}/credits/modules/take/index.ts (93%) rename src/plugins/manage/{groups => modules}/credits/modules/transfer/index.ts (93%) create mode 100644 src/plugins/manage/modules/index.ts delete mode 100644 src/plugins/settings/groups/guild/modules/index.ts delete mode 100644 src/plugins/settings/groups/index.ts rename src/plugins/settings/{groups => modules}/guild/index.ts (79%) rename src/plugins/settings/{groups => modules}/guild/modules/audits.ts (95%) rename src/plugins/settings/{groups => modules}/guild/modules/credits.ts (98%) create mode 100644 src/plugins/settings/modules/guild/modules/index.ts rename src/plugins/settings/{groups => modules}/guild/modules/points.ts (96%) rename src/plugins/settings/{groups => modules}/guild/modules/pterodactyl.ts (97%) rename src/plugins/settings/{groups => modules}/guild/modules/shop.ts (95%) rename src/plugins/settings/{groups => modules}/guild/modules/welcome.ts (97%) create mode 100644 src/plugins/settings/modules/index.ts delete mode 100644 src/plugins/shop/groups/index.ts rename src/plugins/shop/{groups => modules}/roles/index.ts (90%) rename src/plugins/shop/{groups => modules}/roles/modules/buy.ts (91%) rename src/plugins/shop/{groups => modules}/roles/modules/cancel.ts (94%) rename src/plugins/shop/{groups => modules}/roles/modules/index.ts (100%) diff --git a/src/events/guildCreate/index.ts b/src/events/guildCreate/index.ts index 31e87b2..01b70f6 100644 --- a/src/events/guildCreate/index.ts +++ b/src/events/guildCreate/index.ts @@ -10,7 +10,7 @@ export default { async execute(guild: Guild) { const { client } = guild; - logger?.verbose(`Added to guild: ${guild.name} (${guild.id})`); + logger?.silly(`Added to guild: ${guild.name} (${guild.id})`); await fetchGuild(guild); await updatePresence(client); diff --git a/src/events/guildDelete/index.ts b/src/events/guildDelete/index.ts index 6da6f4a..123393c 100644 --- a/src/events/guildDelete/index.ts +++ b/src/events/guildDelete/index.ts @@ -10,7 +10,7 @@ export default { async execute(guild: Guild) { const { client } = guild; - logger?.verbose(`Deleted from guild: ${guild.name} (${guild.id})`); + logger?.silly(`Deleted from guild: ${guild.name} (${guild.id})`); await dropGuild(guild); await updatePresence(client); diff --git a/src/events/guildMemberAdd/index.ts b/src/events/guildMemberAdd/index.ts index b99d7ad..9ece541 100644 --- a/src/events/guildMemberAdd/index.ts +++ b/src/events/guildMemberAdd/index.ts @@ -12,7 +12,7 @@ export default { async execute(member: GuildMember) { const { client, user, guild } = member; - logger?.verbose( + logger?.silly( `New member: ${user.tag} (${user.id}) added to guild: ${guild.name} (${guild.id})` ); diff --git a/src/events/guildMemberRemove/index.ts b/src/events/guildMemberRemove/index.ts index 332f143..3d28c31 100644 --- a/src/events/guildMemberRemove/index.ts +++ b/src/events/guildMemberRemove/index.ts @@ -12,7 +12,7 @@ export default { async execute(member: GuildMember) { const { client, user, guild } = member; - logger?.verbose( + logger?.silly( `Removed member: ${user.tag} (${user.id}) from guild: ${guild.name} (${guild.id})` ); diff --git a/src/events/index.ts b/src/events/index.ts new file mode 100644 index 0000000..b7dd3b6 --- /dev/null +++ b/src/events/index.ts @@ -0,0 +1,22 @@ +// 3rd party dependencies +import mongoose from "mongoose"; + +// Dependencies +import logger from "@logger"; + +// Configuration +import { url } from "@config/database"; + +export default async () => { + await mongoose.connect(url).then(async (connection) => { + logger.info(`Connected to database: ${connection.connection.name}`); + }); + + mongoose.connection.on("error", async (error) => { + logger.error(`${error}`); + }); + + mongoose.connection.on("warn", async (warning) => { + logger.warn(warning); + }); +}; diff --git a/src/events/interactionCreate/components/isCommand.ts b/src/events/interactionCreate/components/isCommand.ts index fa6677b..cb5b716 100644 --- a/src/events/interactionCreate/components/isCommand.ts +++ b/src/events/interactionCreate/components/isCommand.ts @@ -4,7 +4,6 @@ import { CommandInteraction, MessageEmbed } from "discord.js"; import logger from "@logger"; import { errorColor, footerText, footerIcon } from "@config/embed"; -import i18next from "i18next"; import deferReply from "@root/helpers/deferReply"; import getCommandMetadata from "@root/helpers/getCommandMetadata"; @@ -31,7 +30,7 @@ export default async (interaction: CommandInteraction) => { return interaction?.editReply({ embeds: [ new MessageEmbed() - .setTitle("[:toolbox:] Manage") + .setTitle("[:x:] Permission") .setDescription(`You do not have the permission to manage the bot.`) .setTimestamp(new Date()) .setColor(errorColor) @@ -42,17 +41,12 @@ export default async (interaction: CommandInteraction) => { if (metadata.guildOnly) { if (!guild) { - logger.verbose(`Guild is null`); + logger.debug(`Guild is null`); return interaction.editReply({ embeds: [ new MessageEmbed() - .setDescription( - i18next.t("guildOnly", { - lng: interaction.locale, - ns: "errors", - }) - ) + .setDescription("This command is only available for guild") .setColor(errorColor) .setTimestamp(new Date()) .setFooter({ text: footerText, iconURL: footerIcon }), @@ -63,17 +57,12 @@ export default async (interaction: CommandInteraction) => { if (metadata.dmOnly) { if (guild) { - logger.verbose(`Guild exist`); + logger.silly(`Guild exist`); return interaction.editReply({ embeds: [ new MessageEmbed() - .setDescription( - i18next.t("dmOnly", { - lng: interaction.locale, - ns: "errors", - }) - ) + .setDescription("This command is only available in DM.") .setColor(errorColor) .setTimestamp(new Date()) .setFooter({ text: footerText, iconURL: footerIcon }), @@ -85,7 +74,7 @@ export default async (interaction: CommandInteraction) => { await currentCommand .execute(interaction) .then(async () => { - return logger?.verbose( + return logger?.silly( `Command: ${commandName} executed in guild: ${guild?.name} (${guild?.id}) by user: ${user?.tag} (${user?.id})` ); }) diff --git a/src/events/interactionCreate/index.ts b/src/events/interactionCreate/index.ts index befd29f..2848f39 100644 --- a/src/events/interactionCreate/index.ts +++ b/src/events/interactionCreate/index.ts @@ -10,7 +10,7 @@ export default { async execute(interaction: CommandInteraction) { const { guild, id } = interaction; - logger?.verbose( + logger?.silly( `New interaction: ${id} in guild: ${guild?.name} (${guild?.id})` ); diff --git a/src/events/messageCreate/modules/counters/index.ts b/src/events/messageCreate/modules/counters/index.ts index 6f852c7..a65a4db 100644 --- a/src/events/messageCreate/modules/counters/index.ts +++ b/src/events/messageCreate/modules/counters/index.ts @@ -23,7 +23,7 @@ export default { }); if (counter === null) { - logger.verbose( + logger.silly( `No counter found for guild ${guildId} and channel ${channelId}` ); return; @@ -33,7 +33,7 @@ export default { lastMessage?.author.id === author.id && channel.id === counter.channelId ) { - logger.verbose( + logger.silly( `${author.username} sent the last message therefor not allowing again.` ); await message.delete(); @@ -41,7 +41,7 @@ export default { } if (content !== counter.word) { - logger.verbose( + logger.silly( `Counter word ${counter.word} does not match message ${content}` ); @@ -53,7 +53,7 @@ export default { await counter .save() .then(async () => { - logger.verbose( + logger.silly( `Counter for guild ${guildId} and channel ${channelId} is now ${counter.counter}` ); }) @@ -64,7 +64,7 @@ export default { ); }); - logger.verbose( + logger.silly( `Counter word ${counter.word} was found in message ${content} from ${author.tag} (${author.id}) in guild: ${guild?.name} (${guild?.id})` ); }, diff --git a/src/events/messageCreate/modules/credits/index.ts b/src/events/messageCreate/modules/credits/index.ts index e7f4de4..856c308 100644 --- a/src/events/messageCreate/modules/credits/index.ts +++ b/src/events/messageCreate/modules/credits/index.ts @@ -30,7 +30,7 @@ export default { const timeout = await timeouts.findOne(timeoutData); if (timeout) { - logger.verbose( + logger.silly( `User ${userId} in guild ${guildId} is on timeout 2022-04-14-13-51-00` ); return; @@ -41,7 +41,7 @@ export default { await userData .save() .then(async () => { - logger.verbose( + logger.silly( `User ${userId} in guild ${guildId} has ${userData.credits} credits` ); }) @@ -55,7 +55,7 @@ export default { await timeouts .create(timeoutData) .then(async () => { - logger.verbose( + logger.silly( `Timeout 2022-04-14-13-51-00 for user ${userId} in guild ${guildId} has been created` ); }) @@ -70,7 +70,7 @@ export default { await timeouts .deleteOne(timeoutData) .then(async () => { - logger.verbose( + logger.silly( `Timeout 2022-04-14-13-51-00 for user ${userId} in guild ${guildId} has been deleted` ); }) diff --git a/src/events/messageCreate/modules/points/index.ts b/src/events/messageCreate/modules/points/index.ts index f9a45f1..e4d3aa4 100644 --- a/src/events/messageCreate/modules/points/index.ts +++ b/src/events/messageCreate/modules/points/index.ts @@ -30,7 +30,7 @@ export default { const timeout = await timeouts.findOne(timeoutData); if (timeout) { - logger.verbose( + logger.silly( `User ${author.tag} (${author.id}) in guild: ${guild?.name} (${guild?.id} is on timeout 2022-04-14-14-15-00` ); return; @@ -41,7 +41,7 @@ export default { await userData .save() .then(async () => { - logger.verbose( + logger.silly( `Successfully saved user ${author.tag} (${author.id}) in guild: ${guild?.name} (${guild?.id})` ); }) @@ -52,14 +52,14 @@ export default { ); }); - logger.verbose( + logger.silly( `User ${author.tag} (${author.id}) in guild: ${guild?.name} (${guild?.id}) has ${userData.points} points` ); await timeouts .create(timeoutData) .then(async () => { - logger.verbose( + logger.silly( `Successfully created timeout for user ${author.tag} (${author.id}) in guild: ${guild?.name} (${guild?.id})` ); }) @@ -74,7 +74,7 @@ export default { await timeouts .deleteOne(timeoutData) .then(async () => { - logger.verbose( + logger.silly( `Successfully deleted timeout 2022-04-14-14-15-00 for user ${author.tag} (${author.id}) in guild: ${guild?.name} (${guild?.id})` ); }) diff --git a/src/events/messageDelete/modules/counter.ts b/src/events/messageDelete/modules/counter.ts index d2c207e..6169b45 100644 --- a/src/events/messageDelete/modules/counter.ts +++ b/src/events/messageDelete/modules/counter.ts @@ -14,7 +14,7 @@ export default async (message: Message) => { }); if (counter === null) - return logger?.verbose( + return logger?.silly( `No counter found for guild: ${guild?.name} (${guild?.id})` ); const { word } = counter; @@ -29,8 +29,8 @@ export default async (message: Message) => { if (lastMessage.author.id === message.author.id) return; channel?.send(`${author} said **${word}**.`); - logger?.verbose(`${author} said ${word} in ${channel}`); - return logger?.verbose( + logger?.silly(`${author} said ${word} in ${channel}`); + return logger?.silly( `User: ${author?.tag} (${author?.id}) in guild: ${guild?.name} (${guild?.id}) said the counter word: ${word}` ); }; diff --git a/src/events/messageUpdate/index.ts b/src/events/messageUpdate/index.ts index 0ff405e..9238805 100644 --- a/src/events/messageUpdate/index.ts +++ b/src/events/messageUpdate/index.ts @@ -13,12 +13,11 @@ export default { await audits.execute(oldMessage, newMessage); - logger?.verbose( + logger?.silly( `Message update event fired by ${author.tag} (${author.id}) in guild: ${guild?.name} (${guild?.id})` ); - if (author?.bot) - return logger?.verbose(`Message update event fired by bot`); + if (author?.bot) return logger?.silly(`Message update event fired by bot`); await counter(newMessage); }, diff --git a/src/events/messageUpdate/modules/counter.ts b/src/events/messageUpdate/modules/counter.ts index 9c65ab3..465b00a 100644 --- a/src/events/messageUpdate/modules/counter.ts +++ b/src/events/messageUpdate/modules/counter.ts @@ -14,12 +14,12 @@ export default async (message: Message) => { }); if (counter === null) - return logger?.verbose( + return logger?.silly( `No counter found for guild: ${guild?.name} (${guild?.id})` ); const { word } = counter; if (content === word) - return logger?.verbose( + return logger?.silly( `User: ${author?.tag} (${author?.id}) in guild: ${guild?.name} (${guild?.id}) said the counter word: ${word}` ); @@ -27,7 +27,7 @@ export default async (message: Message) => { ?.delete() ?.then(async () => { await channel?.send(`${author} said **${word}**.`); - logger?.verbose(`${author} said ${word} in ${channel}`); + logger?.silly(`${author} said ${word} in ${channel}`); }) ?.catch(async (error: any) => { logger?.error(error); diff --git a/src/events/ready/index.ts b/src/events/ready/index.ts index 4e7684f..b312f73 100644 --- a/src/events/ready/index.ts +++ b/src/events/ready/index.ts @@ -10,14 +10,14 @@ import devMode from "@handlers/devMode"; export default { once: true, async execute(client: Client) { - logger.info(`${client.user?.tag} (${client.user?.id}) is ready`); + logger.info("Ready!"); await updatePresence(client); await devMode(client); await deployCommands(client); client.guilds?.cache.forEach((guild) => { - logger.verbose( + logger.silly( `${client.user?.tag} (${client.user?.id}) is in guild: ${guild.name} (${guild.id}) with member count of ${guild.memberCount}` ); }); diff --git a/src/handlers/commands.ts b/src/handlers/commands.ts index 9c109c4..81b1eeb 100644 --- a/src/handlers/commands.ts +++ b/src/handlers/commands.ts @@ -12,7 +12,7 @@ export default async (client: Client) => { } await Promise.all( - plugins.map(async (pluginName) => { + plugins.map(async (pluginName, index) => { const plugin = await import(`../plugins/${pluginName}`); await client.commands.set( @@ -20,10 +20,14 @@ export default async (client: Client) => { plugin.default, plugin.default.metadata ); + + logger.verbose( + `Loaded plugin ${index + 1}/${plugins.length}: ${pluginName}` + ); }) ) .then(async () => { - logger.debug("Successfully loaded plugins."); + logger.info(`Started all ${plugins.length} plugins.`); }) .catch(async (err) => { logger.error(`${err}`); diff --git a/src/handlers/deployCommands.ts b/src/handlers/deployCommands.ts index 937447a..8af167e 100644 --- a/src/handlers/deployCommands.ts +++ b/src/handlers/deployCommands.ts @@ -14,12 +14,12 @@ export default async (client: Client) => { client.commands.map(async (pluginData: any) => { pluginList.push(pluginData.builder.toJSON()); logger.verbose( - `${pluginData.builder.name} successfully pushed to plugin list.` + `Plugin is ready for deployment: ${pluginData.builder.name}` ); }) ) .then(async () => { - logger.debug("Successfully pushed all plugins to plugin list."); + logger.info("All plugins are ready to be deployed."); }) .catch(async (error) => { logger.error(`${error}`); @@ -32,7 +32,7 @@ export default async (client: Client) => { body: pluginList, }) .then(async () => { - logger.debug(`Successfully deployed plugins to Discord`); + logger.info(`Successfully deployed plugins to Discord's API`); }) .catch(async (error) => { logger.error(`${error}`); @@ -44,7 +44,7 @@ export default async (client: Client) => { body: pluginList, }) .then(async () => - logger.debug(`Successfully deployed guild plugins to Discord`) + logger.info(`Successfully deployed guild plugins to Discord's API`) ) .catch(async (error) => { logger.error(`${error}`); diff --git a/src/handlers/devMode.ts b/src/handlers/devMode.ts index 3d4c78f..53a2cd6 100644 --- a/src/handlers/devMode.ts +++ b/src/handlers/devMode.ts @@ -9,11 +9,9 @@ import { devMode, guildId } from "@config/other"; export default async (client: Client) => { if (!devMode) { return client?.application?.commands?.set([], guildId).then(async () => { - return logger.debug( - `Development commands disabled for guild: ${guildId}` - ); + return logger.verbose(`Development mode is disabled.`); }); } - return logger.debug(`Development commands enabled for guild: ${guildId}`); + return logger.info(`Development mode is enabled.`); }; diff --git a/src/handlers/events.ts b/src/handlers/events.ts index 4c7d778..f7da9c1 100644 --- a/src/handlers/events.ts +++ b/src/handlers/events.ts @@ -9,10 +9,12 @@ export default async (client: Client) => { } await Promise.all( - events.map(async (eventName) => { + events.map(async (eventName, index) => { const event = await import(`../events/${eventName}`); - logger.verbose(`Loaded event: ${eventName}`); + logger.verbose( + `Loaded event ${index + 1}/${events.length}: ${eventName}` + ); if (event.once) { return client.once(eventName, async (...args) => @@ -26,10 +28,10 @@ export default async (client: Client) => { }) ) .then(async () => { - logger.debug("Successfully loaded events."); + logger.info(`Started all ${events.length} events.`); }) .catch(async (err) => { - logger.error(err); + logger.error(`${err}`); }); }); }; diff --git a/src/helpers/dropGuild.ts b/src/helpers/dropGuild.ts index fc17d0a..d69d09b 100644 --- a/src/helpers/dropGuild.ts +++ b/src/helpers/dropGuild.ts @@ -13,7 +13,7 @@ export default async (guild: Guild) => { await guildSchema .deleteMany({ guildId: guild.id }) .then(async () => { - return logger?.verbose(`Deleted guild: ${guild.id}`); + return logger?.silly(`Deleted guild: ${guild.id}`); }) .catch(async (error) => { logger?.error(`Error deleting guild: ${guild.id} - ${error}`); @@ -22,7 +22,7 @@ export default async (guild: Guild) => { await userSchema .deleteMany({ guildId: guild.id }) .then(async () => { - logger?.verbose(`Deleted users for guild: ${guild.id} from database`); + logger?.silly(`Deleted users for guild: ${guild.id} from database`); }) .catch(async (error) => { logger?.error(`Error deleting users for guild: ${guild.id} - ${error}`); @@ -31,7 +31,7 @@ export default async (guild: Guild) => { await apiSchema .deleteMany({ guildId: guild.id }) .then(async () => { - logger?.verbose(`Deleted apis for guild: ${guild.id} from database`); + logger?.silly(`Deleted apis for guild: ${guild.id} from database`); }) .catch(async (error) => { logger?.error(`Error deleting apis for guild: ${guild.id} - ${error}`); @@ -40,7 +40,7 @@ export default async (guild: Guild) => { await counterSchema .deleteMany({ guildId: guild.id }) .then(async () => { - logger?.verbose(`Deleted counters for guild: ${guild.id} from database`); + logger?.silly(`Deleted counters for guild: ${guild.id} from database`); }) .catch(async (error) => { logger?.error( @@ -51,9 +51,7 @@ export default async (guild: Guild) => { await shopRoleSchema .deleteMany({ guildId: guild.id }) .then(async () => { - logger?.verbose( - `Deleted shop roles for guild: ${guild.id} from database` - ); + logger?.silly(`Deleted shop roles for guild: ${guild.id} from database`); }) .catch(async (error) => { logger?.error( @@ -64,7 +62,7 @@ export default async (guild: Guild) => { await timeoutSchema .deleteMany({ guildId: guild.id }) .then(async () => { - logger?.verbose(`Deleted timeouts for guild: ${guild.id} from database`); + logger?.silly(`Deleted timeouts for guild: ${guild.id} from database`); }) .catch(async (error) => { logger?.error( diff --git a/src/helpers/dropUser.ts b/src/helpers/dropUser.ts index 10662c9..8306285 100644 --- a/src/helpers/dropUser.ts +++ b/src/helpers/dropUser.ts @@ -8,7 +8,7 @@ export default async (user: User, guild: Guild) => { await userSchema .deleteOne({ userId: user.id, guildId: guild.id }) .then(async () => { - logger?.verbose(`Deleted user: ${user?.id} from guild: ${guild?.id}`); + logger?.silly(`Deleted user: ${user?.id} from guild: ${guild?.id}`); }) .catch(async (error) => { logger?.error( diff --git a/src/helpers/fetchGuild.ts b/src/helpers/fetchGuild.ts index 6b9c439..4c8f107 100644 --- a/src/helpers/fetchGuild.ts +++ b/src/helpers/fetchGuild.ts @@ -16,7 +16,7 @@ export default async (guild: Guild) => { await newGuildObj .save() .then(async () => { - logger?.verbose(`Created guild: ${guild.id}`); + logger?.silly(`Created guild: ${guild.id}`); }) .catch(async (error) => { logger?.error(`Error creating guild: ${guild.id} - ${error}`); diff --git a/src/helpers/fetchUser.ts b/src/helpers/fetchUser.ts index 98cc927..96386ef 100644 --- a/src/helpers/fetchUser.ts +++ b/src/helpers/fetchUser.ts @@ -22,7 +22,7 @@ export default async (user: User, guild: Guild) => { await newUserObj .save() .then(async () => { - logger?.verbose(`Created user: ${user.id} for guild: ${guild.id}`); + logger?.silly(`Created user: ${user.id} for guild: ${guild.id}`); }) .catch(async (error) => { logger?.error( diff --git a/src/helpers/getCommandMetadata.ts b/src/helpers/getCommandMetadata.ts index c68efec..7894c00 100644 --- a/src/helpers/getCommandMetadata.ts +++ b/src/helpers/getCommandMetadata.ts @@ -8,5 +8,5 @@ export default async (interaction: CommandInteraction, currentCommand: any) => { return currentCommand.modules[subcommand].metadata; } - return currentCommand.groups[subcommandGroup].modules[subcommand].metadata; + return currentCommand.modules[subcommandGroup].modules[subcommand].metadata; }; diff --git a/src/helpers/pluralize.ts b/src/helpers/pluralize.ts index c255427..33bf2fd 100644 --- a/src/helpers/pluralize.ts +++ b/src/helpers/pluralize.ts @@ -2,6 +2,6 @@ import logger from "@root/logger"; export default (count: number, noun: string, suffix?: string) => { const result = `${count} ${noun}${count !== 1 ? suffix || "s" : ""}`; - logger?.verbose(`Pluralized ${count} to ${result}`); + logger?.silly(`Pluralized ${count} to ${result}`); return result; }; diff --git a/src/helpers/saveUser.ts b/src/helpers/saveUser.ts index 48e4a7a..8feb92e 100644 --- a/src/helpers/saveUser.ts +++ b/src/helpers/saveUser.ts @@ -23,7 +23,7 @@ export default async function saveUser(data: any, data2: any) { 50 )}\n${`${_}\n${"=".repeat(50)}`}` ) - : logger?.verbose(`Saved user: ${data.id} (saveUser)`) + : logger?.silly(`Saved user: ${data.id} (saveUser)`) ); if (data2) { data2.save((_: any) => @@ -33,7 +33,7 @@ export default async function saveUser(data: any, data2: any) { 50 )}\n${`${_}\n${"=".repeat(50)}`}` ) - : logger?.verbose(`Saved user: ${data2.id} (saveUser)`) + : logger?.silly(`Saved user: ${data2.id} (saveUser)`) ); } }, diff --git a/src/helpers/sleep.ts b/src/helpers/sleep.ts index bd209e1..5e53d79 100644 --- a/src/helpers/sleep.ts +++ b/src/helpers/sleep.ts @@ -3,6 +3,6 @@ import logger from "@logger"; export default function sleep(milliseconds: any) { return new Promise((resolve) => { setTimeout(resolve, milliseconds); - logger?.verbose(`Sleeping for ${milliseconds} milliseconds`); + logger?.silly(`Sleeping for ${milliseconds} milliseconds`); }); } diff --git a/src/helpers/updatePresence.ts b/src/helpers/updatePresence.ts index b44682b..7f23885 100644 --- a/src/helpers/updatePresence.ts +++ b/src/helpers/updatePresence.ts @@ -10,5 +10,5 @@ export default async (client: Client) => { activities: [{ type: "WATCHING", name: status }], status: "online", }); - logger?.verbose(`Updated client presence to: ${status}`); + logger?.debug(`Updated client presence to: ${status}`); }; diff --git a/src/index.ts b/src/index.ts index c083eae..fe76eaa 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,7 +4,7 @@ import { token, intents } from "@config/discord"; import { Client } from "discord.js"; // discord.js -import database from "@database"; +import database from "@root/events"; import schedules from "@schedules"; import events from "@handlers/events"; import commands from "@handlers/commands"; diff --git a/src/plugins/counters/index.ts b/src/plugins/counters/index.ts index b0fe5fb..ca3fc56 100644 --- a/src/plugins/counters/index.ts +++ b/src/plugins/counters/index.ts @@ -17,10 +17,10 @@ export default { const { options } = interaction; if (options.getSubcommand() === "view") { - logger.verbose(`Executing view subcommand`); + logger.silly(`Executing view subcommand`); return modules.view.execute(interaction); } - logger.verbose(`Unknown subcommand ${options.getSubcommand()}`); + logger.silly(`Unknown subcommand ${options.getSubcommand()}`); }, }; diff --git a/src/plugins/credits/index.ts b/src/plugins/credits/index.ts index ee6e8bd..5e8033f 100644 --- a/src/plugins/credits/index.ts +++ b/src/plugins/credits/index.ts @@ -33,7 +33,7 @@ export default { await modules.work.execute(interaction); break; default: - logger.verbose(`Unknown subcommand ${options.getSubcommand()}`); + logger.silly(`Unknown subcommand ${options.getSubcommand()}`); } }, }; diff --git a/src/plugins/credits/modules/balance/index.ts b/src/plugins/credits/modules/balance/index.ts index f0fed23..412d4b4 100644 --- a/src/plugins/credits/modules/balance/index.ts +++ b/src/plugins/credits/modules/balance/index.ts @@ -5,7 +5,6 @@ import { footerIcon, } from "@config/embed"; -import i18next from "i18next"; import { CommandInteraction, MessageEmbed } from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import logger from "@logger"; @@ -25,33 +24,21 @@ export default { ); }, execute: async (interaction: CommandInteraction) => { - const { options, user, guild, locale } = interaction; + const { options, user, guild } = interaction; const discordUser = options.getUser("user"); const embed = new MessageEmbed() - .setTitle( - i18next.t("credits:modules:balance:general:title", { - lng: locale, - ns: "plugins", - }) - ) + .setTitle("[:dollar:] Balance") .setTimestamp(new Date()) .setFooter({ text: footerText, iconURL: footerIcon }); if (guild === null) { - logger.verbose(`Guild is null`); + logger.silly(`Guild is null`); return interaction.editReply({ embeds: [ - embed - .setDescription( - i18next.t("guildOnly", { - lng: locale, - ns: "errors", - }) - ) - .setColor(errorColor), + embed.setDescription("Guild is not found").setColor(errorColor), ], }); } @@ -59,17 +46,13 @@ export default { const userObj = await fetchUser(discordUser || user, guild); if (userObj === null) { - logger.verbose(`User not found`); + logger.silly(`User not found`); return interaction.editReply({ embeds: [ embed .setDescription( - i18next.t("userNotFound", { - lng: locale, - ns: "errors", - user: discordUser || user, - }) + "User is not found. Please try again with a valid user." ) .setColor(errorColor), ], @@ -77,35 +60,22 @@ export default { } if (userObj.credits === null) { - logger.verbose(`User has no credits`); + logger.silly(`User has no credits`); return interaction.editReply({ embeds: [ - embed - .setDescription( - i18next.t("credits:modules:balance:error01:description", { - lng: locale, - ns: "plugins", - user: discordUser || user, - }) - ) - .setColor(errorColor), + embed.setDescription("Credits not found").setColor(errorColor), ], }); } - logger.verbose(`Found user ${discordUser || user}`); + logger.silly(`Found user ${discordUser || user}`); return interaction.editReply({ embeds: [ embed .setDescription( - i18next.t("credits:modules:balance:success01:description", { - lng: locale, - ns: "plugins", - user: discordUser || user, - amount: userObj.credits, - }) + `${discordUser || user} currently has ${userObj.credits} credits.` ) .setColor(successColor), ], diff --git a/src/plugins/credits/modules/gift/index.ts b/src/plugins/credits/modules/gift/index.ts index 6e2dbea..0590b85 100644 --- a/src/plugins/credits/modules/gift/index.ts +++ b/src/plugins/credits/modules/gift/index.ts @@ -18,7 +18,6 @@ import saveUser from "@helpers/saveUser"; // Models import fetchUser from "@helpers/fetchUser"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; -import i18next from "i18next"; // Function export default { @@ -52,44 +51,27 @@ export default { const optionReason = options.getString("reason"); const embed = new MessageEmbed() - .setTitle( - i18next.t("credits:modules:gift:general:title", { - lng: locale, - ns: "plugins", - }) - ) + .setTitle("[:dollar:] Gift") .setTimestamp(new Date()) .setFooter({ text: footerText, iconURL: footerIcon }); if (guild === null) { - logger.verbose(`Guild is null`); + logger.silly(`Guild is null`); return interaction.editReply({ embeds: [ - embed - .setDescription( - i18next.t("guildOnly", { - lng: locale, - ns: "errors", - }) - ) - .setColor(errorColor), + embed.setDescription("Guild is not found").setColor(errorColor), ], }); } if (optionUser === null) { - logger.verbose(`User not found`); + logger.silly(`User not found`); return interaction.editReply({ embeds: [ embed - .setDescription( - i18next.t("userNotFound", { - lng: locale, - ns: "errors", - }) - ) + .setDescription(`User is not found in this guild`) .setColor(errorColor), ], }); @@ -102,16 +84,13 @@ export default { const toUserDB = await fetchUser(optionUser, guild); if (fromUserDB === null) { - logger.verbose(`User not found`); + logger.silly(`User not found`); return interaction.editReply({ embeds: [ embed .setDescription( - i18next.t("userNotFound", { - lng: locale, - ns: "errors", - }) + "You do not have any credits. Please write something in the chat to get some." ) .setColor(errorColor), ], @@ -119,16 +98,13 @@ export default { } if (toUserDB === null) { - logger.verbose(`User not found`); + logger.silly(`User not found`); return interaction.editReply({ embeds: [ embed .setDescription( - i18next.t("userNotFound", { - lng: locale, - ns: "errors", - }) + "The user you want to gift credits to does not have any credits. Please wait until that user has typed something in the chat to get some." ) .setColor(errorColor), ], @@ -137,16 +113,13 @@ export default { // If receiver is same as sender if (optionUser.id === user.id) { - logger.verbose(`User is same as sender`); + logger.silly(`User is same as sender`); return interaction.editReply({ embeds: [ embed .setDescription( - i18next.t("credits:modules:gift:error01:description", { - lng: locale, - ns: "plugins", - }) + "You can't gift credits to yourself. Please choose a different user." ) .setColor(errorColor), ], @@ -155,16 +128,13 @@ export default { // If amount is null if (optionAmount === null) { - logger.verbose(`Amount is null`); + logger.silly(`Amount is null`); return interaction.editReply({ embeds: [ embed .setDescription( - i18next.t("amountNotFound", { - lng: locale, - ns: "errors", - }) + "Please specify the amount of credits you want to gift." ) .setColor(errorColor), ], @@ -173,16 +143,13 @@ export default { // If amount is zero or below if (optionAmount <= 0) { - logger.verbose(`Amount is zero or below`); + logger.silly(`Amount is zero or below`); return interaction.editReply({ embeds: [ embed .setDescription( - i18next.t("credits:modules:gift:error02:description", { - lng: locale, - ns: "plugins", - }) + "Please specify a valid amount of credits you want to gift." ) .setColor(errorColor), ], @@ -191,17 +158,13 @@ export default { // If user has below gifting amount if (fromUserDB.credits < optionAmount) { - logger.verbose(`User has below gifting amount`); + logger.silly(`User has below gifting amount`); return interaction.editReply({ embeds: [ embed .setDescription( - i18next.t("credits:modules:gift:error03:description", { - lng: locale, - ns: "plugins", - amount: fromUserDB.credits, - }) + "You don't have enough credits to gift that amount. Please try again with a lower amount." ) .setColor(errorColor), ], @@ -210,28 +173,19 @@ export default { // If toUserDB has no credits if (toUserDB === null) { - logger.verbose(`User has no credits`); + logger.silly(`User has no credits`); return interaction.editReply({ embeds: [ embed .setDescription( - i18next.t("userNotFound", { - lng: locale, - ns: "errors", - }) + "The user you want to gift credits to does not have any credits. Please wait until that user has typed something in the chat to get some." ) .setColor(errorColor), ], }); } - // Withdraw amount from fromUserDB - fromUserDB.credits -= optionAmount; - - // Deposit amount to toUserDB - toUserDB.credits += optionAmount; - // Save users await saveUser(fromUserDB, toUserDB).then(async () => { // Get DM user object @@ -245,13 +199,11 @@ export default { embeds: [ embed .setDescription( - i18next.t("credits:modules:gift:error03:description", { - lng: locale, - ns: "plugins", - user: user.tag, - amount: optionAmount, - reason: optionReason || "unspecified", - }) + `${ + user.tag + } has gifted you ${optionAmount} credits with reason: ${ + optionReason || "unspecified" + }` ) .setColor(successColor), ], @@ -260,7 +212,7 @@ export default { logger.error(`[Gift] Error sending DM to user: ${error}`) ); - logger.verbose( + logger.silly( `[Gift] Successfully gifted ${optionAmount} credits to ${optionUser.tag}` ); @@ -268,13 +220,9 @@ export default { embeds: [ embed .setDescription( - i18next.t("credits:modules:gift:success02:description", { - lng: locale, - ns: "plugins", - user: user, - amount: optionAmount, - reason: optionReason || "unspecified", - }) + `Successfully gifted ${optionAmount} credits to ${ + optionUser.tag + } with reason: ${optionReason || "unspecified"}` ) .setColor(successColor), ], diff --git a/src/plugins/credits/modules/top/index.ts b/src/plugins/credits/modules/top/index.ts index b21eb11..a334e0d 100644 --- a/src/plugins/credits/modules/top/index.ts +++ b/src/plugins/credits/modules/top/index.ts @@ -5,7 +5,6 @@ import { footerIcon, } from "@config/embed"; -import i18next from "i18next"; import { CommandInteraction, MessageEmbed } from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import logger from "@logger"; @@ -19,29 +18,21 @@ export default { return command.setName("top").setDescription(`View the top users`); }, execute: async (interaction: CommandInteraction) => { - const { locale, guild } = interaction; + const { guild } = interaction; const embed = new MessageEmbed() - .setTitle( - i18next.t("credits:modules:top:general:title", { - lng: locale, - ns: "plugins", - }) - ) + .setTitle("[:dollar:] Top") .setTimestamp(new Date()) .setFooter({ text: footerText, iconURL: footerIcon }); if (guild === null) { - logger.verbose(`Guild is null`); + logger.silly(`Guild is null`); return interaction.editReply({ embeds: [ embed .setDescription( - i18next.t("guildOnly", { - lng: locale, - ns: "errors", - }) + "Guild is not found. Please try again with a valid guild." ) .setColor(errorColor), ], @@ -60,22 +51,13 @@ export default { // Create entry object const entry = (x: IUser, index: number) => - i18next.t("credits:modules:top:entry", { - lng: locale, - ns: "plugins", - index: index + 1, - user: x.userId, - amount: x.credits, - }); + `${index + 1}. <@${x.userId}> - ${x.credits} credits`; return interaction.editReply({ embeds: [ embed .setDescription( - ` ${i18next.t("credits:modules:top:success01:description", { - lng: locale, - ns: "plugins", - })} + `Below are the top 10 users in this guild. ${topTen.map(entry).join("\n")} ` diff --git a/src/plugins/credits/modules/work/index.ts b/src/plugins/credits/modules/work/index.ts index 440460a..ca863bd 100644 --- a/src/plugins/credits/modules/work/index.ts +++ b/src/plugins/credits/modules/work/index.ts @@ -20,7 +20,6 @@ import timeoutSchema from "@schemas/timeout"; // Helpers import fetchUser from "@helpers/fetchUser"; import fetchGuild from "@helpers/fetchGuild"; -import i18next from "i18next"; export default { metadata: { guildOnly: true, ephemeral: true }, @@ -30,15 +29,10 @@ export default { }, execute: async (interaction: CommandInteraction) => { // Destructure member - const { guild, user, locale } = interaction; + const { guild, user } = interaction; const embed = new MessageEmbed() - .setTitle( - i18next.t("credits:modules:work:general:title", { - lng: locale, - ns: "plugins", - }) - ) + .setTitle("[:dollar:] Work") .setTimestamp(new Date()) .setFooter({ text: footerText, @@ -56,24 +50,20 @@ export default { }); if (guild === null) { - return logger?.verbose(`Guild is null`); + return logger?.silly(`Guild is null`); } const guildDB = await fetchGuild(guild); // If user is not on timeout if (isTimeout) { - logger?.verbose(`User ${user?.id} is on timeout`); + logger?.silly(`User ${user?.id} is on timeout`); return interaction.editReply({ embeds: [ embed .setDescription( - i18next.t("credits:modules:work:error01:description", { - lng: locale, - ns: "plugins", - time: guildDB?.credits.workTimeout, - }) + `You are on timeout, please wait ${guildDB?.credits.workTimeout} seconds.` ) .setColor(errorColor), ], @@ -88,27 +78,20 @@ export default { const userDB = await fetchUser(user, guild); if (userDB === null) { - return logger?.verbose(`User not found`); + return logger?.silly(`User not found`); } userDB.credits += creditsEarned; await userDB?.save()?.then(async () => { - logger?.verbose( + logger?.silly( `User ${userDB?.userId} worked and earned ${creditsEarned} credits` ); return interaction.editReply({ embeds: [ embed - .setDescription( - i18next.t("credits:modules:work:success01:description", { - lng: locale, - ns: "plugins", - time: guildDB?.credits.workTimeout, - amount: creditsEarned, - }) - ) + .setDescription(`You worked and earned ${creditsEarned} credits.`) .setColor(successColor), ], }); @@ -122,7 +105,7 @@ export default { }); setTimeout(async () => { - logger?.verbose(`Removing timeout for user ${user?.id}`); + logger?.silly(`Removing timeout for user ${user?.id}`); // When timeout is out, remove it from the database await timeoutSchema?.deleteOne({ diff --git a/src/plugins/fun/index.ts b/src/plugins/fun/index.ts index c5c26fd..4b89165 100644 --- a/src/plugins/fun/index.ts +++ b/src/plugins/fun/index.ts @@ -21,7 +21,7 @@ export default { await modules.meme.execute(interaction); break; default: - logger.verbose(`Unknown subcommand ${options.getSubcommand()}`); + logger.silly(`Unknown subcommand ${options.getSubcommand()}`); } }, }; diff --git a/src/plugins/manage/groups/counters/modules/index.ts b/src/plugins/manage/groups/counters/modules/index.ts deleted file mode 100644 index e623f48..0000000 --- a/src/plugins/manage/groups/counters/modules/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import add from "@plugins/manage/groups/counters/modules/add"; -import remove from "@plugins/manage/groups/counters/modules/remove"; - -export default { add, remove }; diff --git a/src/plugins/manage/groups/credits/modules/index.ts b/src/plugins/manage/groups/credits/modules/index.ts deleted file mode 100644 index 4065a60..0000000 --- a/src/plugins/manage/groups/credits/modules/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -import give from "@plugins/manage/groups/credits/modules/give"; -import set from "@plugins/manage/groups/credits/modules/set"; -import take from "@plugins/manage/groups/credits/modules/take"; -import transfer from "@plugins/manage/groups/credits/modules/transfer"; - -export default { give, set, take, transfer }; diff --git a/src/plugins/manage/groups/index.ts b/src/plugins/manage/groups/index.ts deleted file mode 100644 index 6b928fe..0000000 --- a/src/plugins/manage/groups/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import counters from "@plugins/manage/groups/counters"; -import credits from "@plugins/manage/groups/credits"; - -export default { counters, credits }; diff --git a/src/plugins/manage/index.ts b/src/plugins/manage/index.ts index 4cd2ff2..993ba9f 100644 --- a/src/plugins/manage/index.ts +++ b/src/plugins/manage/index.ts @@ -3,35 +3,35 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { CommandInteraction } from "discord.js"; // Groups -import groups from "@plugins/manage/groups"; +import modules from "@plugins/manage/modules"; import logger from "@logger"; // Function export default { - groups, + modules, builder: new SlashCommandBuilder() .setName("manage") .setDescription("Manage the bot.") - .addSubcommandGroup(groups.counters.builder) - .addSubcommandGroup(groups.credits.builder), + .addSubcommandGroup(modules.counters.builder) + .addSubcommandGroup(modules.credits.builder), async execute(interaction: CommandInteraction) { // Destructure const { options } = interaction; if (options?.getSubcommandGroup() === "credits") { - logger?.verbose(`Subcommand group is credits`); + logger?.silly(`Subcommand group is credits`); - return groups.credits.execute(interaction); + return modules.credits.execute(interaction); } if (options?.getSubcommandGroup() === "counters") { - logger?.verbose(`Subcommand group is counters`); + logger?.silly(`Subcommand group is counters`); - return groups.counters.execute(interaction); + return modules.counters.execute(interaction); } - logger?.verbose(`Subcommand group is not credits or counters`); + logger?.silly(`Subcommand group is not credits or counters`); }, }; diff --git a/src/plugins/manage/groups/counters/index.ts b/src/plugins/manage/modules/counters/index.ts similarity index 81% rename from src/plugins/manage/groups/counters/index.ts rename to src/plugins/manage/modules/counters/index.ts index 6d54522..3fb9d3e 100644 --- a/src/plugins/manage/groups/counters/index.ts +++ b/src/plugins/manage/modules/counters/index.ts @@ -23,17 +23,17 @@ export default { const { options } = interaction; if (options?.getSubcommand() === "add") { - logger?.verbose(`Executing create subcommand`); + logger?.silly(`Executing create subcommand`); return modules.add.execute(interaction); } if (options?.getSubcommand() === "remove") { - logger?.verbose(`Executing delete subcommand`); + logger?.silly(`Executing delete subcommand`); return modules.remove.execute(interaction); } - logger?.verbose(`Unknown subcommand ${options?.getSubcommand()}`); + logger?.silly(`Unknown subcommand ${options?.getSubcommand()}`); }, }; diff --git a/src/plugins/manage/groups/counters/modules/add/index.ts b/src/plugins/manage/modules/counters/modules/add/index.ts similarity index 74% rename from src/plugins/manage/groups/counters/modules/add/index.ts rename to src/plugins/manage/modules/counters/modules/add/index.ts index 09e1f56..1bb9cb2 100644 --- a/src/plugins/manage/groups/counters/modules/add/index.ts +++ b/src/plugins/manage/modules/counters/modules/add/index.ts @@ -16,7 +16,6 @@ import logger from "@logger"; // Models import counterSchema from "@schemas/counter"; -import i18next from "i18next"; // Function export default { @@ -57,12 +56,7 @@ export default { const startValue = options?.getNumber("start"); const embed = new MessageEmbed() - .setTitle( - i18next.t("manage:groups:counters:modules:add:general:title", { - lng: locale, - ns: "plugins", - }) - ) + .setTitle("[:toolbox:] Counters - Add") .setTimestamp(new Date()) .setFooter({ text: footerText, iconURL: footerIcon }); @@ -75,16 +69,7 @@ export default { return interaction?.editReply({ embeds: [ embed - .setDescription( - i18next.t( - "manage:groups:counters:modules:add:error01:description", - { - lng: locale, - ns: "plugins", - channel: discordChannel, - } - ) - ) + .setDescription(`A counter already exists for this channel.`) .setColor(errorColor), ], }); @@ -98,20 +83,13 @@ export default { counter: startValue || 0, }) .then(async () => { - logger?.verbose(`Created counter`); + logger?.silly(`Created counter`); return interaction?.editReply({ embeds: [ embed .setDescription( - i18next.t( - "manage:groups:counters:modules:create:success01:description", - { - lng: locale, - ns: "plugins", - channel: discordChannel, - } - ) + `Successfully created counter for ${discordChannel?.name}.` ) .setColor(successColor), ], diff --git a/src/plugins/manage/modules/counters/modules/index.ts b/src/plugins/manage/modules/counters/modules/index.ts new file mode 100644 index 0000000..2f55183 --- /dev/null +++ b/src/plugins/manage/modules/counters/modules/index.ts @@ -0,0 +1,4 @@ +import add from "@plugins/manage/modules/counters/modules/add"; +import remove from "@plugins/manage/modules/counters/modules/remove"; + +export default { add, remove }; diff --git a/src/plugins/manage/groups/counters/modules/remove/index.ts b/src/plugins/manage/modules/counters/modules/remove/index.ts similarity index 73% rename from src/plugins/manage/groups/counters/modules/remove/index.ts rename to src/plugins/manage/modules/counters/modules/remove/index.ts index 72f90e8..c0991f7 100644 --- a/src/plugins/manage/groups/counters/modules/remove/index.ts +++ b/src/plugins/manage/modules/counters/modules/remove/index.ts @@ -16,7 +16,6 @@ import logger from "@logger"; import counterSchema from "@schemas/counter"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChannelType } from "discord-api-types/v10"; -import i18next from "i18next"; // Function export default { @@ -44,12 +43,7 @@ export default { const discordChannel = options?.getChannel("channel"); const embed = new MessageEmbed() - .setTitle( - i18next.t("manage:groups:counters:modules:remove:general:title", { - lng: locale, - ns: "plugins", - }) - ) + .setTitle("[:toolbox:] Counters - Remove") .setTimestamp(new Date()) .setFooter({ text: footerText, iconURL: footerIcon }); @@ -59,19 +53,13 @@ export default { }); if (counter === null) { - logger?.verbose(`Counter is null`); + logger?.silly(`Counter is null`); return interaction?.editReply({ embeds: [ embed .setDescription( - i18next.t( - "manage:groups:counters:modules:remove:error01:description", - { - lng: locale, - ns: "plugins", - } - ) + ":x: There is no counter in this channel. Please add a counter first." ) .setColor(errorColor), ], @@ -84,19 +72,13 @@ export default { channelId: discordChannel?.id, }) ?.then(async () => { - logger?.verbose(`Counter deleted`); + logger?.silly(`Counter deleted`); return interaction?.editReply({ embeds: [ embed .setDescription( - i18next.t( - "manage:groups:counters:modules:remove:success01:description", - { - lng: locale, - ns: "plugins", - } - ) + ":white_check_mark: Counter deleted successfully." ) .setColor(successColor), ], diff --git a/src/plugins/manage/groups/credits/index.ts b/src/plugins/manage/modules/credits/index.ts similarity index 77% rename from src/plugins/manage/groups/credits/index.ts rename to src/plugins/manage/modules/credits/index.ts index c342f7a..a12cf11 100644 --- a/src/plugins/manage/groups/credits/index.ts +++ b/src/plugins/manage/modules/credits/index.ts @@ -21,23 +21,23 @@ export default { switch (options.getSubcommand()) { case "give": - logger.verbose(`Executing give subcommand`); + logger.silly(`Executing give subcommand`); return modules.give.execute(interaction); case "set": - logger.verbose(`Executing set subcommand`); + logger.silly(`Executing set subcommand`); return modules.set.execute(interaction); case "take": - logger.verbose(`Executing take subcommand`); + logger.silly(`Executing take subcommand`); return modules.take.execute(interaction); case "transfer": - logger.verbose(`Executing transfer subcommand`); + logger.silly(`Executing transfer subcommand`); return modules.transfer.execute(interaction); default: - logger.verbose(`Unknown subcommand ${options.getSubcommand()}`); + logger.silly(`Unknown subcommand ${options.getSubcommand()}`); } }, }; diff --git a/src/plugins/manage/groups/credits/modules/give/index.ts b/src/plugins/manage/modules/credits/modules/give/index.ts similarity index 94% rename from src/plugins/manage/groups/credits/modules/give/index.ts rename to src/plugins/manage/modules/credits/modules/give/index.ts index fd52097..4734231 100644 --- a/src/plugins/manage/groups/credits/modules/give/index.ts +++ b/src/plugins/manage/modules/credits/modules/give/index.ts @@ -53,7 +53,7 @@ export default { // If amount option is null if (creditAmount === null) { - logger?.verbose(`Amount is null`); + logger?.silly(`Amount is null`); return interaction?.editReply({ embeds: [ @@ -69,7 +69,7 @@ export default { // If amount is zero or below if (creditAmount <= 0) { - logger?.verbose(`Amount is zero or below`); + logger?.silly(`Amount is zero or below`); return interaction?.editReply({ embeds: [ @@ -84,7 +84,7 @@ export default { } if (discordReceiver === null) { - logger?.verbose(`Discord receiver is null`); + logger?.silly(`Discord receiver is null`); return interaction?.editReply({ embeds: [ @@ -98,7 +98,7 @@ export default { }); } if (guild === null) { - logger?.verbose(`Guild is null`); + logger?.silly(`Guild is null`); return interaction?.editReply({ embeds: [ @@ -115,7 +115,7 @@ export default { const toUser = await fetchUser(discordReceiver, guild); if (toUser === null) { - logger?.verbose(`To user is null`); + logger?.silly(`To user is null`); return interaction?.editReply({ embeds: [ @@ -147,7 +147,7 @@ export default { // Save toUser await toUser?.save()?.then(async () => { - logger?.verbose(`Saved toUser`); + logger?.silly(`Saved toUser`); return interaction?.editReply({ embeds: [ diff --git a/src/plugins/manage/modules/credits/modules/index.ts b/src/plugins/manage/modules/credits/modules/index.ts new file mode 100644 index 0000000..1dd2f3d --- /dev/null +++ b/src/plugins/manage/modules/credits/modules/index.ts @@ -0,0 +1,6 @@ +import give from "@plugins/manage/modules/credits/modules/give"; +import set from "@plugins/manage/modules/credits/modules/set"; +import take from "@plugins/manage/modules/credits/modules/take"; +import transfer from "@plugins/manage/modules/credits/modules/transfer"; + +export default { give, set, take, transfer }; diff --git a/src/plugins/manage/groups/credits/modules/set/index.ts b/src/plugins/manage/modules/credits/modules/set/index.ts similarity index 93% rename from src/plugins/manage/groups/credits/modules/set/index.ts rename to src/plugins/manage/modules/credits/modules/set/index.ts index 29bd6ab..e8b8875 100644 --- a/src/plugins/manage/groups/credits/modules/set/index.ts +++ b/src/plugins/manage/modules/credits/modules/set/index.ts @@ -51,7 +51,7 @@ export default { // If amount is null if (creditAmount === null) { - logger?.verbose(`Amount is null`); + logger?.silly(`Amount is null`); return interaction?.editReply({ embeds: [ @@ -66,7 +66,7 @@ export default { } if (discordUser === null) { - logger?.verbose(`User is null`); + logger?.silly(`User is null`); return interaction?.editReply({ embeds: [ @@ -80,7 +80,7 @@ export default { }); } if (guild === null) { - logger?.verbose(`Guild is null`); + logger?.silly(`Guild is null`); return interaction?.editReply({ embeds: [ @@ -99,7 +99,7 @@ export default { // If toUser does not exist if (toUser === null) { - logger?.verbose(`User does not exist`); + logger?.silly(`User does not exist`); return interaction?.editReply({ embeds: [ @@ -115,7 +115,7 @@ export default { // If toUser.credits does not exist if (toUser?.credits === null) { - logger?.verbose(`User does not have any credits`); + logger?.silly(`User does not have any credits`); return interaction?.editReply({ embeds: [ @@ -134,7 +134,7 @@ export default { // Save toUser await toUser?.save()?.then(async () => { - logger?.verbose(`Saved user`); + logger?.silly(`Saved user`); return interaction?.editReply({ embeds: [ diff --git a/src/plugins/manage/groups/credits/modules/take/index.ts b/src/plugins/manage/modules/credits/modules/take/index.ts similarity index 93% rename from src/plugins/manage/groups/credits/modules/take/index.ts rename to src/plugins/manage/modules/credits/modules/take/index.ts index 21327b3..0b07fe4 100644 --- a/src/plugins/manage/groups/credits/modules/take/index.ts +++ b/src/plugins/manage/modules/credits/modules/take/index.ts @@ -56,7 +56,7 @@ export default { // If amount is null if (optionAmount === null) { - logger?.verbose(`Amount is null`); + logger?.silly(`Amount is null`); return interaction?.editReply({ embeds: [ @@ -72,7 +72,7 @@ export default { // If amount is zero or below if (optionAmount <= 0) { - logger?.verbose(`Amount is zero or below`); + logger?.silly(`Amount is zero or below`); return interaction?.editReply({ embeds: [ @@ -87,7 +87,7 @@ export default { } if (optionUser === null) { - logger?.verbose(`Discord receiver is null`); + logger?.silly(`Discord receiver is null`); return interaction?.editReply({ embeds: [ @@ -101,7 +101,7 @@ export default { }); } if (guild === null) { - logger?.verbose(`Guild is null`); + logger?.silly(`Guild is null`); return interaction?.editReply({ embeds: [ @@ -120,7 +120,7 @@ export default { // If toUser does not exist if (toUser === null) { - logger?.verbose(`ToUser is null`); + logger?.silly(`ToUser is null`); return interaction?.editReply({ embeds: [ @@ -136,7 +136,7 @@ export default { // If toUser.credits does not exist if (toUser?.credits === null) { - logger?.verbose(`ToUser.credits is null`); + logger?.silly(`ToUser.credits is null`); return interaction?.editReply({ embeds: [ @@ -155,7 +155,7 @@ export default { // Save toUser await toUser?.save()?.then(async () => { - logger?.verbose(`Saved toUser`); + logger?.silly(`Saved toUser`); return interaction?.editReply({ embeds: [ diff --git a/src/plugins/manage/groups/credits/modules/transfer/index.ts b/src/plugins/manage/modules/credits/modules/transfer/index.ts similarity index 93% rename from src/plugins/manage/groups/credits/modules/transfer/index.ts rename to src/plugins/manage/modules/credits/modules/transfer/index.ts index 250c015..00e1fbe 100644 --- a/src/plugins/manage/groups/credits/modules/transfer/index.ts +++ b/src/plugins/manage/modules/credits/modules/transfer/index.ts @@ -61,7 +61,7 @@ export default { // If amount is null if (optionAmount === null) { - logger?.verbose(`Amount is null`); + logger?.silly(`Amount is null`); return interaction?.editReply({ embeds: [ @@ -76,7 +76,7 @@ export default { } if (guild === null) { - logger?.verbose(`Guild is null`); + logger?.silly(`Guild is null`); return interaction?.editReply({ embeds: [ @@ -90,7 +90,7 @@ export default { }); } if (optionFromUser === null) { - logger?.verbose(`From user is null`); + logger?.silly(`From user is null`); return interaction?.editReply({ embeds: [ @@ -104,7 +104,7 @@ export default { }); } if (optionToUser === null) { - logger?.verbose(`To user is null`); + logger?.silly(`To user is null`); return interaction?.editReply({ embeds: [ @@ -126,7 +126,7 @@ export default { // If toUser does not exist if (fromUser === null) { - logger?.verbose(`From user does not exist`); + logger?.silly(`From user does not exist`); return interaction?.editReply({ embeds: [ @@ -144,7 +144,7 @@ export default { // If toUser.credits does not exist if (!fromUser?.credits) { - logger?.verbose(`From user does not have credits`); + logger?.silly(`From user does not have credits`); return interaction?.editReply({ embeds: [ @@ -162,7 +162,7 @@ export default { // If toUser does not exist if (toUser === null) { - logger?.verbose(`To user does not exist`); + logger?.silly(`To user does not exist`); return interaction?.editReply({ embeds: [ @@ -180,7 +180,7 @@ export default { // If toUser.credits does not exist if (toUser?.credits === null) { - logger?.verbose(`To user does not have credits`); + logger?.silly(`To user does not have credits`); return interaction?.editReply({ embeds: [ @@ -204,7 +204,7 @@ export default { // Save users await saveUser(fromUser, toUser)?.then(async () => { - logger?.verbose(`Saved users`); + logger?.silly(`Saved users`); return interaction?.editReply({ embeds: [ diff --git a/src/plugins/manage/modules/index.ts b/src/plugins/manage/modules/index.ts new file mode 100644 index 0000000..61797b1 --- /dev/null +++ b/src/plugins/manage/modules/index.ts @@ -0,0 +1,4 @@ +import counters from "@plugins/manage/modules/counters"; +import credits from "@plugins/manage/modules/credits"; + +export default { counters, credits }; diff --git a/src/plugins/profile/index.ts b/src/plugins/profile/index.ts index 4766d49..d37ad1b 100644 --- a/src/plugins/profile/index.ts +++ b/src/plugins/profile/index.ts @@ -20,11 +20,11 @@ export default { const { options } = interaction; if (options?.getSubcommand() === "view") { - logger?.verbose(`Executing view subcommand`); + logger?.silly(`Executing view subcommand`); return modules.view.execute(interaction); } - logger?.verbose(`No subcommand found`); + logger?.silly(`No subcommand found`); }, }; diff --git a/src/plugins/profile/modules/view.ts b/src/plugins/profile/modules/view.ts index aeb8e62..472c969 100644 --- a/src/plugins/profile/modules/view.ts +++ b/src/plugins/profile/modules/view.ts @@ -36,7 +36,7 @@ export default { ); if (guild === null) { - return logger?.verbose(`Guild is null`); + return logger?.silly(`Guild is null`); } // User Information diff --git a/src/plugins/reputation/index.ts b/src/plugins/reputation/index.ts index 9ee66d6..f5237ab 100644 --- a/src/plugins/reputation/index.ts +++ b/src/plugins/reputation/index.ts @@ -19,11 +19,11 @@ export default { const { options } = interaction; if (options?.getSubcommand() === "give") { - logger?.verbose(`Executing give subcommand`); + logger?.silly(`Executing give subcommand`); await modules.give.execute(interaction); } - logger?.verbose(`No subcommand found`); + logger?.silly(`No subcommand found`); }, }; diff --git a/src/plugins/reputation/modules/give.ts b/src/plugins/reputation/modules/give.ts index e3d6dff..c467c4b 100644 --- a/src/plugins/reputation/modules/give.ts +++ b/src/plugins/reputation/modules/give.ts @@ -58,14 +58,14 @@ export default { const optionType = options?.getString("type"); if (guild === null) { - return logger?.verbose(`Guild is null`); + return logger?.silly(`Guild is null`); } // User information const userObj = await fetchUser(user, guild); if (userObj === null) { - return logger?.verbose(`User is null`); + return logger?.silly(`User is null`); } // Check if user has a timeout @@ -77,7 +77,7 @@ export default { // If user is not on timeout if (isTimeout) { - logger?.verbose(`User is on timeout`); + logger?.silly(`User is on timeout`); return interaction?.editReply({ embeds: [ @@ -97,7 +97,7 @@ export default { // Do not allow self reputation if (optionTarget?.id === user?.id) { - logger?.verbose(`User is trying to give reputation to self`); + logger?.silly(`User is trying to give reputation to self`); return interaction?.editReply({ embeds: [ @@ -117,21 +117,21 @@ export default { // If type is positive if (optionType === "positive") { - logger?.verbose(`User is giving positive reputation`); + logger?.silly(`User is giving positive reputation`); userObj.reputation += 1; } // If type is negative else if (optionType === "negative") { - logger?.verbose(`User is giving negative reputation`); + logger?.silly(`User is giving negative reputation`); userObj.reputation -= 1; } // Save user await userObj?.save()?.then(async () => { - logger?.verbose(`User reputation has been updated`); + logger?.silly(`User reputation has been updated`); await timeoutSchema?.create({ guildId: guild?.id, @@ -156,7 +156,7 @@ export default { }); setTimeout(async () => { - logger?.verbose(`Removing timeout`); + logger?.silly(`Removing timeout`); await timeoutSchema?.deleteOne({ guildId: guild?.id, diff --git a/src/plugins/settings/groups/guild/modules/index.ts b/src/plugins/settings/groups/guild/modules/index.ts deleted file mode 100644 index 9a5fcd6..0000000 --- a/src/plugins/settings/groups/guild/modules/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -import audits from "@plugins/settings/groups/guild/modules/audits"; -import credits from "@plugins/settings/groups/guild/modules/credits"; -import points from "@plugins/settings/groups/guild/modules/points"; -import pterodactyl from "@plugins/settings/groups/guild/modules/pterodactyl"; -import shop from "@plugins/settings/groups/guild/modules/shop"; -import welcome from "@plugins/settings/groups/guild/modules/welcome"; - -export default { audits, credits, points, pterodactyl, shop, welcome }; diff --git a/src/plugins/settings/groups/index.ts b/src/plugins/settings/groups/index.ts deleted file mode 100644 index 3271a99..0000000 --- a/src/plugins/settings/groups/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import guild from "@plugins/settings/groups/guild"; - -export default { guild }; diff --git a/src/plugins/settings/index.ts b/src/plugins/settings/index.ts index c55d10e..5ab9d74 100644 --- a/src/plugins/settings/index.ts +++ b/src/plugins/settings/index.ts @@ -2,31 +2,31 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { CommandInteraction } from "discord.js"; -// Groups -import groups from "./groups"; +// Modules +import modules from "./modules"; // Handlers import logger from "@logger"; // Function export default { - groups, + modules, builder: new SlashCommandBuilder() .setName("settings") .setDescription("Manage settings.") - .addSubcommandGroup(groups.guild.builder), + .addSubcommandGroup(modules.guild.builder), async execute(interaction: CommandInteraction) { const { options } = interaction; if (options.getSubcommandGroup() === "guild") { - logger.verbose(`Executing guild subcommand`); + logger.silly(`Executing guild subcommand`); - return groups.guild.execute(interaction); + return modules.guild.execute(interaction); } - logger.verbose(`No subcommand group found`); + logger.silly(`No subcommand group found`); }, }; diff --git a/src/plugins/settings/groups/guild/index.ts b/src/plugins/settings/modules/guild/index.ts similarity index 79% rename from src/plugins/settings/groups/guild/index.ts rename to src/plugins/settings/modules/guild/index.ts index 973e678..a9a3fc1 100644 --- a/src/plugins/settings/groups/guild/index.ts +++ b/src/plugins/settings/modules/guild/index.ts @@ -30,31 +30,31 @@ export default { switch (options?.getSubcommand()) { case "pterodactyl": - logger?.verbose(`Subcommand is pterodactyl`); + logger?.silly(`Subcommand is pterodactyl`); return modules.pterodactyl.execute(interaction); case "credits": - logger?.verbose(`Subcommand is credits`); + logger?.silly(`Subcommand is credits`); return modules.credits.execute(interaction); case "points": - logger?.verbose(`Subcommand is points`); + logger?.silly(`Subcommand is points`); return modules.points.execute(interaction); case "welcome": - logger?.verbose(`Subcommand is welcome`); + logger?.silly(`Subcommand is welcome`); return modules.welcome.execute(interaction); case "audits": - logger?.verbose(`Subcommand is audits`); + logger?.silly(`Subcommand is audits`); return modules.audits.execute(interaction); case "shop": - logger?.verbose(`Subcommand is shop`); + logger?.silly(`Subcommand is shop`); return modules.shop.execute(interaction); default: - logger?.verbose(`Subcommand is not found`); + logger?.silly(`Subcommand is not found`); } }, }; diff --git a/src/plugins/settings/groups/guild/modules/audits.ts b/src/plugins/settings/modules/guild/modules/audits.ts similarity index 95% rename from src/plugins/settings/groups/guild/modules/audits.ts rename to src/plugins/settings/modules/guild/modules/audits.ts index 06a325e..55c718f 100644 --- a/src/plugins/settings/groups/guild/modules/audits.ts +++ b/src/plugins/settings/modules/guild/modules/audits.ts @@ -48,7 +48,7 @@ export default { }); if (guildDB === null) { - return logger?.verbose(`Guild not found in database.`); + return logger?.silly(`Guild not found in database.`); } // Modify values @@ -58,7 +58,7 @@ export default { // Save guild await guildDB?.save()?.then(async () => { - logger?.verbose(`Guild audits updated.`); + logger?.silly(`Guild audits updated.`); return interaction?.editReply({ embeds: [ diff --git a/src/plugins/settings/groups/guild/modules/credits.ts b/src/plugins/settings/modules/guild/modules/credits.ts similarity index 98% rename from src/plugins/settings/groups/guild/modules/credits.ts rename to src/plugins/settings/modules/guild/modules/credits.ts index 7c29eda..91a1f00 100644 --- a/src/plugins/settings/groups/guild/modules/credits.ts +++ b/src/plugins/settings/modules/guild/modules/credits.ts @@ -68,7 +68,7 @@ export default { }); if (guildDB === null) { - return logger?.verbose(`Guild is null`); + return logger?.silly(`Guild is null`); } // Modify values @@ -86,7 +86,7 @@ export default { // Save guild await guildDB?.save()?.then(async () => { - logger?.verbose(`Guild saved`); + logger?.silly(`Guild saved`); return interaction?.editReply({ embeds: [ diff --git a/src/plugins/settings/modules/guild/modules/index.ts b/src/plugins/settings/modules/guild/modules/index.ts new file mode 100644 index 0000000..ccdf8f7 --- /dev/null +++ b/src/plugins/settings/modules/guild/modules/index.ts @@ -0,0 +1,8 @@ +import audits from "@plugins/settings/modules/guild/modules/audits"; +import credits from "@plugins/settings/modules/guild/modules/credits"; +import points from "@plugins/settings/modules/guild/modules/points"; +import pterodactyl from "@plugins/settings/modules/guild/modules/pterodactyl"; +import shop from "@plugins/settings/modules/guild/modules/shop"; +import welcome from "@plugins/settings/modules/guild/modules/welcome"; + +export default { audits, credits, points, pterodactyl, shop, welcome }; diff --git a/src/plugins/settings/groups/guild/modules/points.ts b/src/plugins/settings/modules/guild/modules/points.ts similarity index 96% rename from src/plugins/settings/groups/guild/modules/points.ts rename to src/plugins/settings/modules/guild/modules/points.ts index 4379f04..0eef364 100644 --- a/src/plugins/settings/groups/guild/modules/points.ts +++ b/src/plugins/settings/modules/guild/modules/points.ts @@ -56,7 +56,7 @@ export default { }); if (guildDB === null) { - return logger?.verbose(`Guild not found in database.`); + return logger?.silly(`Guild not found in database.`); } // Modify values @@ -69,7 +69,7 @@ export default { // Save guild await guildDB?.save()?.then(async () => { - logger?.verbose(`Guild points updated.`); + logger?.silly(`Guild points updated.`); return interaction?.editReply({ embeds: [ diff --git a/src/plugins/settings/groups/guild/modules/pterodactyl.ts b/src/plugins/settings/modules/guild/modules/pterodactyl.ts similarity index 97% rename from src/plugins/settings/groups/guild/modules/pterodactyl.ts rename to src/plugins/settings/modules/guild/modules/pterodactyl.ts index 13345d6..3e79567 100644 --- a/src/plugins/settings/groups/guild/modules/pterodactyl.ts +++ b/src/plugins/settings/modules/guild/modules/pterodactyl.ts @@ -53,7 +53,7 @@ export default { { new: true, upsert: true } ) .then(async () => { - logger?.verbose(`Updated API credentials.`); + logger?.silly(`Updated API credentials.`); return interaction?.editReply({ embeds: [ diff --git a/src/plugins/settings/groups/guild/modules/shop.ts b/src/plugins/settings/modules/guild/modules/shop.ts similarity index 95% rename from src/plugins/settings/groups/guild/modules/shop.ts rename to src/plugins/settings/modules/guild/modules/shop.ts index ffa6f4a..839bf8e 100644 --- a/src/plugins/settings/groups/guild/modules/shop.ts +++ b/src/plugins/settings/modules/guild/modules/shop.ts @@ -48,7 +48,7 @@ export default { }); if (guildDB === null) { - return logger?.verbose(`Guild not found in database.`); + return logger?.silly(`Guild not found in database.`); } // Modify values @@ -61,7 +61,7 @@ export default { // Save guild await guildDB?.save()?.then(async () => { - logger?.verbose(`Guild shop updated.`); + logger?.silly(`Guild shop updated.`); return interaction?.editReply({ embeds: [ diff --git a/src/plugins/settings/groups/guild/modules/welcome.ts b/src/plugins/settings/modules/guild/modules/welcome.ts similarity index 97% rename from src/plugins/settings/groups/guild/modules/welcome.ts rename to src/plugins/settings/modules/guild/modules/welcome.ts index 48fdae8..b349bdb 100644 --- a/src/plugins/settings/groups/guild/modules/welcome.ts +++ b/src/plugins/settings/modules/guild/modules/welcome.ts @@ -69,7 +69,7 @@ export default { }); if (guildDB === null) { - return logger?.verbose(`Guild not found in database.`); + return logger?.silly(`Guild not found in database.`); } // Modify values @@ -91,7 +91,7 @@ export default { // Save guild await guildDB?.save()?.then(async () => { - logger?.verbose(`Guild welcome updated.`); + logger?.silly(`Guild welcome updated.`); return interaction?.editReply({ embeds: [ diff --git a/src/plugins/settings/modules/index.ts b/src/plugins/settings/modules/index.ts new file mode 100644 index 0000000..a487700 --- /dev/null +++ b/src/plugins/settings/modules/index.ts @@ -0,0 +1,3 @@ +import guild from "@plugins/settings/modules/guild"; + +export default { guild }; diff --git a/src/plugins/shop/groups/index.ts b/src/plugins/shop/groups/index.ts deleted file mode 100644 index c1c25c9..0000000 --- a/src/plugins/shop/groups/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import roles from "./roles"; - -export default { roles }; diff --git a/src/plugins/shop/index.ts b/src/plugins/shop/index.ts index 8c46187..330306e 100644 --- a/src/plugins/shop/index.ts +++ b/src/plugins/shop/index.ts @@ -5,37 +5,33 @@ import { CommandInteraction } from "discord.js"; // Modules import modules from "./modules"; -// Groups -import groups from "./groups"; - // Handlers import logger from "../../logger"; // Function export default { modules, - groups, builder: new SlashCommandBuilder() .setName("shop") .setDescription("Shop for credits and custom roles.") .addSubcommand(modules.pterodactyl.builder) - .addSubcommandGroup(groups.roles.builder), + .addSubcommandGroup(modules.roles.builder), async execute(interaction: CommandInteraction) { const { options } = interaction; if (options?.getSubcommand() === "pterodactyl") { - logger.verbose(`Executing pterodactyl subcommand`); + logger.silly(`Executing pterodactyl subcommand`); return modules.pterodactyl.execute(interaction); } if (options?.getSubcommandGroup() === "roles") { - logger?.verbose(`Subcommand group is roles`); + logger?.silly(`Subcommand group is roles`); - return groups.roles.execute(interaction); + return modules.roles.execute(interaction); } - logger?.verbose(`No subcommand found.`); + logger?.silly(`No subcommand found.`); }, }; diff --git a/src/plugins/shop/modules/index.ts b/src/plugins/shop/modules/index.ts index bc33df3..c356cae 100644 --- a/src/plugins/shop/modules/index.ts +++ b/src/plugins/shop/modules/index.ts @@ -1,3 +1,4 @@ import pterodactyl from "@plugins/shop/modules/pterodactyl"; +import roles from "@plugins/shop/modules/roles"; -export default { pterodactyl }; +export default { pterodactyl, roles }; diff --git a/src/plugins/shop/modules/pterodactyl.ts b/src/plugins/shop/modules/pterodactyl.ts index 3cde4d1..57e36af 100644 --- a/src/plugins/shop/modules/pterodactyl.ts +++ b/src/plugins/shop/modules/pterodactyl.ts @@ -37,7 +37,7 @@ export default { const optionAmount = options?.getInteger("amount"); if (optionAmount === null) { - logger?.verbose(`Amount is null.`); + logger?.silly(`Amount is null.`); return interaction?.editReply({ embeds: [ @@ -56,19 +56,19 @@ export default { } if (guild === null) { - return logger?.verbose(`Guild is null`); + return logger?.silly(`Guild is null`); } const userDB = await fetchUser(user, guild); if (userDB === null) { - return logger?.verbose(`User is null`); + return logger?.silly(`User is null`); } const dmUser = client?.users?.cache?.get(user?.id); if ((optionAmount || userDB?.credits) < 100) { - logger?.verbose(`Amount or user credits is below 100.`); + logger?.silly(`Amount or user credits is below 100.`); return interaction?.editReply({ embeds: [ @@ -93,7 +93,7 @@ export default { } if ((optionAmount || userDB?.credits) > 1000000) { - logger?.verbose(`Amount or user credits is above 1.000.000.`); + logger?.silly(`Amount or user credits is above 1.000.000.`); return interaction?.editReply({ embeds: [ @@ -119,7 +119,7 @@ export default { } if (userDB?.credits < optionAmount) { - logger?.verbose(`User credits is below amount.`); + logger?.silly(`User credits is below amount.`); return interaction?.editReply({ embeds: [ @@ -168,7 +168,7 @@ export default { }) ?.then(async () => { - logger?.verbose(`Successfully created voucher.`); + logger?.silly(`Successfully created voucher.`); userDB.credits -= optionAmount || userDB?.credits; @@ -176,7 +176,7 @@ export default { ?.save() ?.then(async () => { - logger?.verbose(`Successfully saved new credits.`); + logger?.silly(`Successfully saved new credits.`); await dmUser?.send({ embeds: [ @@ -218,7 +218,7 @@ export default { }) .catch(async (error) => { - logger?.verbose(`Error saving new credits. - ${error}`); + logger?.silly(`Error saving new credits. - ${error}`); return interaction?.editReply({ embeds: [ @@ -238,7 +238,7 @@ export default { }) .catch(async (error: any) => { - logger?.verbose(`Error creating voucher. - ${error}`); + logger?.silly(`Error creating voucher. - ${error}`); return interaction?.editReply({ embeds: [ diff --git a/src/plugins/shop/groups/roles/index.ts b/src/plugins/shop/modules/roles/index.ts similarity index 90% rename from src/plugins/shop/groups/roles/index.ts rename to src/plugins/shop/modules/roles/index.ts index 0900764..d9242de 100644 --- a/src/plugins/shop/groups/roles/index.ts +++ b/src/plugins/shop/modules/roles/index.ts @@ -33,7 +33,7 @@ export default { if (guildDB === null) return; if (!guildDB.shop.roles.status) { - logger.verbose(`Shop roles disabled.`); + logger.silly(`Shop roles disabled.`); return interaction?.editReply({ embeds: [ @@ -52,13 +52,13 @@ export default { } if (options?.getSubcommand() === "buy") { - logger.verbose(`Executing buy subcommand`); + logger.silly(`Executing buy subcommand`); await modules.buy.execute(interaction); } if (options?.getSubcommand() === "cancel") { - logger.verbose(`Executing cancel subcommand`); + logger.silly(`Executing cancel subcommand`); await modules.cancel.execute(interaction); } diff --git a/src/plugins/shop/groups/roles/modules/buy.ts b/src/plugins/shop/modules/roles/modules/buy.ts similarity index 91% rename from src/plugins/shop/groups/roles/modules/buy.ts rename to src/plugins/shop/modules/roles/modules/buy.ts index ed6a73b..32c5918 100644 --- a/src/plugins/shop/groups/roles/modules/buy.ts +++ b/src/plugins/shop/modules/roles/modules/buy.ts @@ -52,7 +52,7 @@ export default { // If amount is null if (optionName === null) { - logger?.verbose(`Name is null.`); + logger?.silly(`Name is null.`); return interaction?.editReply({ embeds: [ @@ -85,15 +85,15 @@ export default { const userDB = await fetchUser(user, guild); if (userDB === null) { - return logger?.verbose(`User is null`); + return logger?.silly(`User is null`); } if (guildDB === null) { - return logger?.verbose(`Guild is null`); + return logger?.silly(`Guild is null`); } if (guildDB.shop === null) { - return logger?.verbose(`Shop is null`); + return logger?.silly(`Shop is null`); } const { pricePerHour } = guildDB.shop.roles; @@ -112,7 +112,7 @@ export default { await (member?.roles as GuildMemberRoleManager)?.add(role?.id); - logger?.verbose(`Role ${role?.name} was bought by ${user?.tag}`); + logger?.silly(`Role ${role?.name} was bought by ${user?.tag}`); return interaction?.editReply({ embeds: [ @@ -139,7 +139,7 @@ export default { }); }) .catch(async (error) => { - return logger?.verbose(`Role could not be created. ${error}`); + return logger?.silly(`Role could not be created. ${error}`); }); }, }; diff --git a/src/plugins/shop/groups/roles/modules/cancel.ts b/src/plugins/shop/modules/roles/modules/cancel.ts similarity index 94% rename from src/plugins/shop/groups/roles/modules/cancel.ts rename to src/plugins/shop/modules/roles/modules/cancel.ts index ee5e705..5dd9362 100644 --- a/src/plugins/shop/groups/roles/modules/cancel.ts +++ b/src/plugins/shop/modules/roles/modules/cancel.ts @@ -39,7 +39,7 @@ export default { const optionRole = options.getRole("role"); if (optionRole === null) { - logger?.verbose(`Role is null.`); + logger?.silly(`Role is null.`); return interaction?.editReply({ embeds: [ @@ -73,7 +73,7 @@ export default { const userDB = await fetchUser(user, guild); if (userDB === null) { - return logger?.verbose(`User is null`); + return logger?.silly(`User is null`); } await shopRolesSchema?.deleteOne({ @@ -104,7 +104,7 @@ export default { }); }) .catch(async (error) => { - return logger?.verbose(`Role could not be deleted. ${error}`); + return logger?.silly(`Role could not be deleted. ${error}`); }); }, }; diff --git a/src/plugins/shop/groups/roles/modules/index.ts b/src/plugins/shop/modules/roles/modules/index.ts similarity index 100% rename from src/plugins/shop/groups/roles/modules/index.ts rename to src/plugins/shop/modules/roles/modules/index.ts diff --git a/src/plugins/utility/modules/avatar.ts b/src/plugins/utility/modules/avatar.ts index 86494c1..aa8c0e0 100644 --- a/src/plugins/utility/modules/avatar.ts +++ b/src/plugins/utility/modules/avatar.ts @@ -1,6 +1,5 @@ import { successColor, footerText, footerIcon } from "@config/embed"; -import i18next from "i18next"; import { CommandInteraction, MessageEmbed } from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; @@ -18,32 +17,19 @@ export default { ); }, execute: async (interaction: CommandInteraction) => { - const { locale } = interaction; - const userOption = interaction.options.getUser("user"); const targetUser = userOption || interaction.user; const embed = new MessageEmbed() - .setTitle( - i18next.t("utility:modules:avatar:general:title", { - lng: locale, - ns: "plugins", - }) - ) + .setTitle("[:tools:] Avatar") .setTimestamp(new Date()) .setFooter({ text: footerText, iconURL: footerIcon }); return interaction.editReply({ embeds: [ embed - .setDescription( - i18next.t("utility:modules:avatar:success01:description", { - lng: locale, - ns: "plugins", - user: targetUser, - }) - ) + .setDescription(`${targetUser.username}'s avatar:`) .setThumbnail(targetUser.displayAvatarURL()) .setColor(successColor), ], diff --git a/src/schedules/jobs/shopRoles.ts b/src/schedules/jobs/shopRoles.ts index be1767b..b42a3f5 100644 --- a/src/schedules/jobs/shopRoles.ts +++ b/src/schedules/jobs/shopRoles.ts @@ -64,7 +64,7 @@ export default async (client: Client) => { guildId, }) .then(async () => { - logger.verbose( + logger.silly( `Shop role document ${roleId} has been deleted from user ${userId}.` ); }) @@ -78,7 +78,7 @@ export default async (client: Client) => { } if (new Date() > nextPayment) { - logger.verbose( + logger.silly( `Shop role ${roleId} is due for payment. Withdrawing credits from user ${userId}.` ); @@ -109,7 +109,7 @@ export default async (client: Client) => { await role .save() .then(async () => { - logger.verbose(`Shop role ${roleId} has been paid for.`); + logger.silly(`Shop role ${roleId} has been paid for.`); }) .catch(async (err) => { logger.error( @@ -118,7 +118,7 @@ export default async (client: Client) => { ); }); - logger.verbose( + logger.silly( `Shop role ${roleId} has been paid for. Keeping role ${roleId} for user ${userId}.` ); }) From ab708538c43817493c583463f5d67c1a8adb8cca Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 20 May 2022 15:37:20 +0200 Subject: [PATCH 114/142] =?UTF-8?q?=E2=9C=A8=20per=20guild=20embed=20confi?= =?UTF-8?q?g?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/database/schemas/guild.ts | 30 ++++ src/events/guildMemberAdd/audits.ts | 6 +- src/events/guildMemberAdd/joinMessage.ts | 7 +- src/events/guildMemberRemove/audits.ts | 6 +- src/events/guildMemberRemove/leaveMessage.ts | 6 +- src/events/interactionCreate/audits.ts | 6 +- .../interactionCreate/components/isCommand.ts | 9 +- src/events/messageDelete/audits.ts | 6 +- src/events/messageUpdate/audits.ts | 6 +- src/{ => handlers}/schedules/index.ts | 2 +- src/helpers/deferReply.ts | 8 +- src/helpers/getEmbedConfig.ts | 18 +++ src/index.ts | 6 +- src/{schedules => }/jobs/shopRoles.ts | 0 .../modules/guild => config}/index.ts | 36 ++--- .../guild => config}/modules/audits.ts | 9 +- .../guild => config}/modules/credits.ts | 8 +- src/plugins/config/modules/embeds.ts | 129 ++++++++++++++++++ src/plugins/config/modules/index.ts | 9 ++ .../guild => config}/modules/points.ts | 6 +- .../guild => config}/modules/pterodactyl.ts | 6 +- .../modules/guild => config}/modules/shop.ts | 6 +- .../guild => config}/modules/welcome.ts | 6 +- src/plugins/counters/modules/view/index.ts | 10 +- src/plugins/credits/modules/balance/index.ts | 10 +- src/plugins/credits/modules/gift/index.ts | 10 +- src/plugins/credits/modules/top/index.ts | 10 +- src/plugins/credits/modules/work/index.ts | 11 +- src/plugins/fun/modules/meme.ts | 5 +- src/plugins/manage/modules/counters/index.ts | 4 + .../modules/counters/modules/add/index.ts | 11 +- .../modules/counters/modules/remove/index.ts | 10 +- src/plugins/manage/modules/credits/index.ts | 4 + .../modules/credits/modules/give/index.ts | 11 +- .../modules/credits/modules/set/index.ts | 10 +- .../modules/credits/modules/take/index.ts | 11 +- .../modules/credits/modules/transfer/index.ts | 11 +- src/plugins/profile/modules/view.ts | 6 +- src/plugins/reputation/modules/give.ts | 11 +- src/plugins/settings/index.ts | 32 ----- .../settings/modules/guild/modules/index.ts | 8 -- src/plugins/settings/modules/index.ts | 3 - src/plugins/shop/modules/pterodactyl.ts | 10 +- src/plugins/shop/modules/roles/index.ts | 5 +- src/plugins/shop/modules/roles/modules/buy.ts | 11 +- .../shop/modules/roles/modules/cancel.ts | 11 +- src/plugins/utility/modules/about.ts | 5 +- src/plugins/utility/modules/avatar.ts | 5 +- src/plugins/utility/modules/lookup.ts | 11 +- src/plugins/utility/modules/stats.ts | 6 +- tsconfig.json | 2 +- 51 files changed, 387 insertions(+), 198 deletions(-) rename src/{ => handlers}/schedules/index.ts (89%) create mode 100644 src/helpers/getEmbedConfig.ts rename src/{schedules => }/jobs/shopRoles.ts (100%) rename src/plugins/{settings/modules/guild => config}/index.ts (63%) rename src/plugins/{settings/modules/guild => config}/modules/audits.ts (90%) rename src/plugins/{settings/modules/guild => config}/modules/credits.ts (94%) create mode 100644 src/plugins/config/modules/embeds.ts create mode 100644 src/plugins/config/modules/index.ts rename src/plugins/{settings/modules/guild => config}/modules/points.ts (93%) rename src/plugins/{settings/modules/guild => config}/modules/pterodactyl.ts (88%) rename src/plugins/{settings/modules/guild => config}/modules/shop.ts (91%) rename src/plugins/{settings/modules/guild => config}/modules/welcome.ts (94%) delete mode 100644 src/plugins/settings/index.ts delete mode 100644 src/plugins/settings/modules/guild/modules/index.ts delete mode 100644 src/plugins/settings/modules/index.ts diff --git a/src/database/schemas/guild.ts b/src/database/schemas/guild.ts index 849845b..0b7a78d 100644 --- a/src/database/schemas/guild.ts +++ b/src/database/schemas/guild.ts @@ -1,3 +1,4 @@ +import { ColorResolvable } from "discord.js"; import { Schema, model } from "mongoose"; interface IGuild { @@ -10,6 +11,13 @@ interface IGuild { minimumLength: number; workTimeout: number; }; + embeds: { + successColor: ColorResolvable; + waitColor: ColorResolvable; + errorColor: ColorResolvable; + footerIcon: string; + footerText: string; + }; shop: { roles: { status: boolean; pricePerHour: number } }; points: { status: boolean; @@ -61,6 +69,28 @@ const guildSchema = new Schema( default: 900000, }, }, + embeds: { + successColor: { + type: String, + default: "#22bb33", + }, + waitColor: { + type: String, + default: "#f0ad4e", + }, + errorColor: { + type: String, + default: "#bb2124", + }, + footerText: { + type: String, + default: "https://github.com/ZynerOrg/xyter", + }, + footerIcon: { + type: String, + default: "https://github.com/ZynerOrg.png", + }, + }, shop: { roles: { status: { diff --git a/src/events/guildMemberAdd/audits.ts b/src/events/guildMemberAdd/audits.ts index af99a77..c47c78e 100644 --- a/src/events/guildMemberAdd/audits.ts +++ b/src/events/guildMemberAdd/audits.ts @@ -3,10 +3,14 @@ import { GuildMember, MessageEmbed, TextChannel } from "discord.js"; import guildSchema from "@schemas/guild"; -import { footerText, footerIcon, successColor } from "@config/embed"; +import getEmbedConfig from "@helpers/getEmbedConfig"; export default { execute: async (member: GuildMember) => { + const { footerText, footerIcon, successColor } = await getEmbedConfig( + member.guild + ); + const guildData = await guildSchema.findOne({ guildId: member.guild.id }); const { client } = member; diff --git a/src/events/guildMemberAdd/joinMessage.ts b/src/events/guildMemberAdd/joinMessage.ts index 8c7e9bb..bf7aec3 100644 --- a/src/events/guildMemberAdd/joinMessage.ts +++ b/src/events/guildMemberAdd/joinMessage.ts @@ -1,13 +1,14 @@ -import logger from "@logger"; import { GuildMember, MessageEmbed, TextChannel } from "discord.js"; import guildSchema from "@schemas/guild"; -import { footerText, footerIcon, successColor } from "@config/embed"; +import getEmbedConfig from "@helpers/getEmbedConfig"; export default { execute: async (member: GuildMember) => { - logger.info(member); + const { footerText, footerIcon, successColor } = await getEmbedConfig( + member.guild + ); const guildData = await guildSchema.findOne({ guildId: member.guild.id }); diff --git a/src/events/guildMemberRemove/audits.ts b/src/events/guildMemberRemove/audits.ts index 3bbd8aa..620e52e 100644 --- a/src/events/guildMemberRemove/audits.ts +++ b/src/events/guildMemberRemove/audits.ts @@ -3,10 +3,14 @@ import { GuildMember, MessageEmbed, TextChannel } from "discord.js"; import guildSchema from "@schemas/guild"; -import { footerText, footerIcon, errorColor } from "@config/embed"; +import getEmbedConfig from "@helpers/getEmbedConfig"; export default { execute: async (member: GuildMember) => { + const { footerText, footerIcon, errorColor } = await getEmbedConfig( + member.guild + ); + const guildData = await guildSchema.findOne({ guildId: member.guild.id }); const { client } = member; diff --git a/src/events/guildMemberRemove/leaveMessage.ts b/src/events/guildMemberRemove/leaveMessage.ts index b4f6100..113242e 100644 --- a/src/events/guildMemberRemove/leaveMessage.ts +++ b/src/events/guildMemberRemove/leaveMessage.ts @@ -3,11 +3,13 @@ import { GuildMember, MessageEmbed, TextChannel } from "discord.js"; import guildSchema from "@schemas/guild"; -import { footerText, footerIcon, errorColor } from "@config/embed"; +import getEmbedConfig from "@helpers/getEmbedConfig"; export default { execute: async (member: GuildMember) => { - logger.info(member); + const { footerText, footerIcon, errorColor } = await getEmbedConfig( + member.guild + ); const guildData = await guildSchema.findOne({ guildId: member.guild.id }); diff --git a/src/events/interactionCreate/audits.ts b/src/events/interactionCreate/audits.ts index d91348e..c6df788 100644 --- a/src/events/interactionCreate/audits.ts +++ b/src/events/interactionCreate/audits.ts @@ -3,7 +3,7 @@ import { Interaction, MessageEmbed, TextChannel } from "discord.js"; import guildSchema from "@schemas/guild"; -import { footerText, footerIcon, successColor } from "@config/embed"; +import getEmbedConfig from "@helpers/getEmbedConfig"; export default { execute: async (interaction: Interaction) => { @@ -11,6 +11,10 @@ export default { if (interaction.guild === null) return; + const { footerText, footerIcon, successColor } = await getEmbedConfig( + interaction.guild + ); + const guildData = await guildSchema.findOne({ guildId: interaction.guild.id, }); diff --git a/src/events/interactionCreate/components/isCommand.ts b/src/events/interactionCreate/components/isCommand.ts index cb5b716..7af8e7e 100644 --- a/src/events/interactionCreate/components/isCommand.ts +++ b/src/events/interactionCreate/components/isCommand.ts @@ -3,12 +3,17 @@ import { CommandInteraction, MessageEmbed } from "discord.js"; import logger from "@logger"; -import { errorColor, footerText, footerIcon } from "@config/embed"; import deferReply from "@root/helpers/deferReply"; -import getCommandMetadata from "@root/helpers/getCommandMetadata"; +import getEmbedConfig from "@helpers/getEmbedConfig"; +import getCommandMetadata from "@helpers/getCommandMetadata"; export default async (interaction: CommandInteraction) => { if (!interaction.isCommand()) return; + if (interaction.guild == null) return; + + const { errorColor, footerText, footerIcon } = await getEmbedConfig( + interaction.guild + ); const { client, guild, commandName, user, memberPermissions } = interaction; diff --git a/src/events/messageDelete/audits.ts b/src/events/messageDelete/audits.ts index d35cf37..1f37b59 100644 --- a/src/events/messageDelete/audits.ts +++ b/src/events/messageDelete/audits.ts @@ -3,7 +3,7 @@ import { Message, MessageEmbed, TextChannel } from "discord.js"; import guildSchema from "@schemas/guild"; -import { footerText, footerIcon, successColor } from "@config/embed"; +import getEmbedConfig from "@helpers/getEmbedConfig"; export default { execute: async (message: Message) => { @@ -11,6 +11,10 @@ export default { if (message.guild === null) return; + const { footerText, footerIcon, successColor } = await getEmbedConfig( + message.guild + ); + const guildData = await guildSchema.findOne({ guildId: message.guild.id, }); diff --git a/src/events/messageUpdate/audits.ts b/src/events/messageUpdate/audits.ts index b7f2726..c9bed8a 100644 --- a/src/events/messageUpdate/audits.ts +++ b/src/events/messageUpdate/audits.ts @@ -4,7 +4,7 @@ import { Message, MessageEmbed, TextChannel } from "discord.js"; import guildSchema from "@schemas/guild"; -import { footerText, footerIcon, successColor } from "@config/embed"; +import getEmbedConfig from "@helpers/getEmbedConfig"; export default { execute: async (oldMessage: Message, newMessage: Message) => { @@ -14,6 +14,10 @@ export default { if (oldMessage.guild === null) return; if (newMessage.guild === null) return; + const { footerText, footerIcon, successColor } = await getEmbedConfig( + newMessage.guild + ); + const guildData = await guildSchema.findOne({ guildId: oldMessage.guild.id, }); diff --git a/src/schedules/index.ts b/src/handlers/schedules/index.ts similarity index 89% rename from src/schedules/index.ts rename to src/handlers/schedules/index.ts index 71ce35b..20ed685 100644 --- a/src/schedules/index.ts +++ b/src/handlers/schedules/index.ts @@ -5,7 +5,7 @@ import schedule from "node-schedule"; import logger from "@logger"; // Jobs -import shopRoles from "@root/schedules/jobs/shopRoles"; +import shopRoles from "@jobs/shopRoles"; export default async (client: Client) => { const expression = "*/5 * * * *"; diff --git a/src/helpers/deferReply.ts b/src/helpers/deferReply.ts index 378c62e..feec1a7 100644 --- a/src/helpers/deferReply.ts +++ b/src/helpers/deferReply.ts @@ -1,11 +1,17 @@ import { CommandInteraction, MessageEmbed } from "discord.js"; -import { waitColor, footerText, footerIcon } from "@config/embed"; +import getEmbedConfig from "@helpers/getEmbedConfig"; export default async (interaction: CommandInteraction, ephemeral: boolean) => { + if (interaction.guild == null) return; + await interaction.deferReply({ ephemeral, }); + const { waitColor, footerText, footerIcon } = await getEmbedConfig( + interaction.guild + ); + await interaction.editReply({ embeds: [ new MessageEmbed() diff --git a/src/helpers/getEmbedConfig.ts b/src/helpers/getEmbedConfig.ts new file mode 100644 index 0000000..3532542 --- /dev/null +++ b/src/helpers/getEmbedConfig.ts @@ -0,0 +1,18 @@ +import guildSchema from "@schemas/guild"; + +import { ColorResolvable, Guild } from "discord.js"; + +export default async (guild: Guild) => { + const guildConfig = await guildSchema.findOne({ guildId: guild.id }); + + if (guildConfig == null) + return { + successColor: "#22bb33" as ColorResolvable, + waitColor: "#f0ad4e" as ColorResolvable, + errorColor: "#bb2124" as ColorResolvable, + footerIcon: "https://github.com/ZynerOrg.png", + footerText: "https://github.com/ZynerOrg/xyter", + }; + + return guildConfig.embeds; +}; diff --git a/src/index.ts b/src/index.ts index fe76eaa..08b72e0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,11 +5,11 @@ import { token, intents } from "@config/discord"; import { Client } from "discord.js"; // discord.js import database from "@root/events"; -import schedules from "@schedules"; +import schedules from "@handlers/schedules"; import events from "@handlers/events"; import commands from "@handlers/commands"; -async function main() { +const main = async () => { const client = new Client({ intents, }); @@ -21,6 +21,6 @@ async function main() { await events(client); await client.login(token); -} +}; main(); diff --git a/src/schedules/jobs/shopRoles.ts b/src/jobs/shopRoles.ts similarity index 100% rename from src/schedules/jobs/shopRoles.ts rename to src/jobs/shopRoles.ts diff --git a/src/plugins/settings/modules/guild/index.ts b/src/plugins/config/index.ts similarity index 63% rename from src/plugins/settings/modules/guild/index.ts rename to src/plugins/config/index.ts index a9a3fc1..9cf1ab4 100644 --- a/src/plugins/settings/modules/guild/index.ts +++ b/src/plugins/config/index.ts @@ -1,30 +1,30 @@ // Dependencies +import { SlashCommandBuilder } from "@discordjs/builders"; import { CommandInteraction } from "discord.js"; -// Handlers -import logger from "@logger"; - // Modules import modules from "./modules"; -import { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders"; +// Handlers +import logger from "@logger"; // Function export default { modules, - builder: (group: SlashCommandSubcommandGroupBuilder) => { - return group - .setName("guild") - .setDescription("Guild settings.") - .addSubcommand(modules.pterodactyl.builder) - .addSubcommand(modules.credits.builder) - .addSubcommand(modules.points.builder) - .addSubcommand(modules.welcome.builder) - .addSubcommand(modules.audits.builder) - .addSubcommand(modules.shop.builder); - }, - execute: async (interaction: CommandInteraction) => { + builder: new SlashCommandBuilder() + .setName("config") + .setDescription("Manage guild configurations.") + + .addSubcommand(modules.pterodactyl.builder) + .addSubcommand(modules.credits.builder) + .addSubcommand(modules.points.builder) + .addSubcommand(modules.welcome.builder) + .addSubcommand(modules.audits.builder) + .addSubcommand(modules.shop.builder) + .addSubcommand(modules.embeds.builder), + + async execute(interaction: CommandInteraction) { // Destructure member const { options } = interaction; @@ -53,6 +53,10 @@ export default { logger?.silly(`Subcommand is shop`); return modules.shop.execute(interaction); + case "embeds": + logger?.silly(`Subcommand is shop`); + + return modules.embeds.execute(interaction); default: logger?.silly(`Subcommand is not found`); } diff --git a/src/plugins/settings/modules/guild/modules/audits.ts b/src/plugins/config/modules/audits.ts similarity index 90% rename from src/plugins/settings/modules/guild/modules/audits.ts rename to src/plugins/config/modules/audits.ts index 55c718f..9692167 100644 --- a/src/plugins/settings/modules/guild/modules/audits.ts +++ b/src/plugins/config/modules/audits.ts @@ -2,7 +2,7 @@ import { CommandInteraction, Permissions } from "discord.js"; // Configurations -import { successColor, footerText, footerIcon } from "@config/embed"; +import getEmbedConfig from "@helpers/getEmbedConfig"; // Handlers import logger from "@logger"; @@ -35,8 +35,11 @@ export default { ); }, execute: async (interaction: CommandInteraction) => { - // Destructure member - const { options, guild } = interaction; + if (interaction.guild == null) return; + const { errorColor, successColor, footerText, footerIcon } = + await getEmbedConfig(interaction.guild); + + const { guild, options } = interaction; // Get options const status = options?.getBoolean("status"); diff --git a/src/plugins/settings/modules/guild/modules/credits.ts b/src/plugins/config/modules/credits.ts similarity index 94% rename from src/plugins/settings/modules/guild/modules/credits.ts rename to src/plugins/config/modules/credits.ts index 91a1f00..146329d 100644 --- a/src/plugins/settings/modules/guild/modules/credits.ts +++ b/src/plugins/config/modules/credits.ts @@ -2,7 +2,7 @@ import { CommandInteraction, Permissions } from "discord.js"; // Configurations -import { successColor, footerText, footerIcon } from "@config/embed"; +import getEmbedConfig from "@helpers/getEmbedConfig"; //Handlers import logger from "@logger"; @@ -51,9 +51,13 @@ export default { ); }, execute: async (interaction: CommandInteraction) => { - // Destructure member + if (interaction.guild == null) return; + const { errorColor, successColor, footerText, footerIcon } = + await getEmbedConfig(interaction.guild); // Destructure member const { guild, options } = interaction; + if (guild == null) return; + // Get options const status = options?.getBoolean("status"); const rate = options?.getNumber("rate"); diff --git a/src/plugins/config/modules/embeds.ts b/src/plugins/config/modules/embeds.ts new file mode 100644 index 0000000..f4f3a15 --- /dev/null +++ b/src/plugins/config/modules/embeds.ts @@ -0,0 +1,129 @@ +// Dependencies +import { ColorResolvable, CommandInteraction, Permissions } from "discord.js"; + +//Handlers +import logger from "@logger"; + +// Models +import guildSchema from "@schemas/guild"; +import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import getEmbedConfig from "@helpers/getEmbedConfig"; + +// Function +export default { + metadata: { + guildOnly: true, + ephemeral: true, + permissions: [Permissions.FLAGS.MANAGE_GUILD], + }, + + builder: (command: SlashCommandSubcommandBuilder) => { + return command + .setName("embeds") + .setDescription(`Embeds`) + .addStringOption((option) => + option + .setName("success-color") + .setDescription("No provided description") + ) + .addStringOption((option) => + option.setName("wait-color").setDescription("No provided description") + ) + .addStringOption((option) => + option.setName("error-color").setDescription("No provided description") + ) + .addStringOption((option) => + option.setName("footer-icon").setDescription("No provided description") + ) + .addStringOption((option) => + option.setName("footer-text").setDescription("No provided description") + ); + }, + execute: async (interaction: CommandInteraction) => { + // Destructure member + const { guild, options } = interaction; + + if (guild == null) return; + + const embedConfig = await getEmbedConfig(guild); + + if (embedConfig == null) return; + + logger.info(embedConfig); + + // Get options + const successColor = options?.getString("success-color") as ColorResolvable; + const waitColor = options?.getString("wait-color") as ColorResolvable; + const errorColor = options?.getString("error-color") as ColorResolvable; + const footerIcon = options?.getString("footer-icon"); + const footerText = options?.getString("footer-text"); + + // Get guild object + const guildDB = await guildSchema?.findOne({ + guildId: guild?.id, + }); + + if (guildDB === null) { + return logger?.silly(`Guild is null`); + } + + // Modify values + guildDB.embeds.successColor = + successColor !== null ? successColor : guildDB?.embeds?.successColor; + guildDB.embeds.waitColor = + waitColor !== null ? waitColor : guildDB?.embeds?.waitColor; + guildDB.embeds.errorColor = + errorColor !== null ? errorColor : guildDB?.embeds?.errorColor; + guildDB.embeds.footerIcon = + footerIcon !== null ? footerIcon : guildDB?.embeds?.footerIcon; + guildDB.embeds.footerText = + footerText !== null ? footerText : guildDB?.embeds?.footerText; + + // Save guild + await guildDB?.save()?.then(async () => { + logger?.silly(`Guild saved`); + + return interaction?.editReply({ + embeds: [ + { + title: ":tools: Settings - Guild [Credits]", + description: `Credits settings updated.`, + color: successColor || embedConfig.successColor, + fields: [ + { + name: "🤖 Success Color", + value: `${guildDB?.embeds?.successColor}`, + inline: true, + }, + { + name: "📈 Wait Color", + value: `${guildDB?.embeds?.waitColor}`, + inline: true, + }, + { + name: "📈 Error Color", + value: `${guildDB?.embeds?.errorColor}`, + inline: true, + }, + { + name: "🔨 Footer Icon", + value: `${guildDB?.embeds?.footerIcon}`, + inline: true, + }, + { + name: "⏰ Footer Text", + value: `${guildDB?.embeds?.footerText}`, + inline: true, + }, + ], + timestamp: new Date(), + footer: { + iconURL: footerIcon || embedConfig.footerIcon, + text: footerText || embedConfig.footerText, + }, + }, + ], + }); + }); + }, +}; diff --git a/src/plugins/config/modules/index.ts b/src/plugins/config/modules/index.ts new file mode 100644 index 0000000..e14701a --- /dev/null +++ b/src/plugins/config/modules/index.ts @@ -0,0 +1,9 @@ +import audits from "@plugins/config/modules/audits"; +import credits from "@plugins/config/modules/credits"; +import points from "@plugins/config/modules/points"; +import pterodactyl from "@plugins/config/modules/pterodactyl"; +import shop from "@plugins/config/modules/shop"; +import welcome from "@plugins/config/modules/welcome"; +import embeds from "@plugins/config/modules/embeds"; + +export default { audits, credits, points, pterodactyl, shop, welcome, embeds }; diff --git a/src/plugins/settings/modules/guild/modules/points.ts b/src/plugins/config/modules/points.ts similarity index 93% rename from src/plugins/settings/modules/guild/modules/points.ts rename to src/plugins/config/modules/points.ts index 0eef364..4011013 100644 --- a/src/plugins/settings/modules/guild/modules/points.ts +++ b/src/plugins/config/modules/points.ts @@ -2,7 +2,7 @@ import { CommandInteraction, Permissions } from "discord.js"; // Configurations -import { successColor, footerText, footerIcon } from "@config/embed"; +import getEmbedConfig from "@helpers/getEmbedConfig"; // Handlers import logger from "@logger"; @@ -41,6 +41,10 @@ export default { ); }, execute: async (interaction: CommandInteraction) => { + if (interaction.guild == null) return; + const { errorColor, successColor, footerText, footerIcon } = + await getEmbedConfig(interaction.guild); + // Destructure member const { options, guild } = interaction; diff --git a/src/plugins/settings/modules/guild/modules/pterodactyl.ts b/src/plugins/config/modules/pterodactyl.ts similarity index 88% rename from src/plugins/settings/modules/guild/modules/pterodactyl.ts rename to src/plugins/config/modules/pterodactyl.ts index 3e79567..5ffa3e6 100644 --- a/src/plugins/settings/modules/guild/modules/pterodactyl.ts +++ b/src/plugins/config/modules/pterodactyl.ts @@ -2,7 +2,7 @@ import { CommandInteraction, Permissions } from "discord.js"; // Configurations -import { successColor, footerText, footerIcon } from "@config/embed"; +import getEmbedConfig from "@helpers/getEmbedConfig"; // Handlers import logger from "@logger"; @@ -38,7 +38,9 @@ export default { ); }, execute: async (interaction: CommandInteraction) => { - // Destructure member + if (interaction.guild == null) return; + const { errorColor, successColor, footerText, footerIcon } = + await getEmbedConfig(interaction.guild); // Destructure member const { options, guild } = interaction; // Get options diff --git a/src/plugins/settings/modules/guild/modules/shop.ts b/src/plugins/config/modules/shop.ts similarity index 91% rename from src/plugins/settings/modules/guild/modules/shop.ts rename to src/plugins/config/modules/shop.ts index 839bf8e..9f7f634 100644 --- a/src/plugins/settings/modules/guild/modules/shop.ts +++ b/src/plugins/config/modules/shop.ts @@ -2,7 +2,7 @@ import { CommandInteraction, Permissions } from "discord.js"; // Configurations -import { successColor, footerText, footerIcon } from "@config/embed"; +import getEmbedConfig from "@helpers/getEmbedConfig"; // Handlers import logger from "@logger"; @@ -35,7 +35,9 @@ export default { ); }, execute: async (interaction: CommandInteraction) => { - // Destructure member + if (interaction.guild == null) return; + const { errorColor, successColor, footerText, footerIcon } = + await getEmbedConfig(interaction.guild); // Destructure member const { options, guild } = interaction; // Get options diff --git a/src/plugins/settings/modules/guild/modules/welcome.ts b/src/plugins/config/modules/welcome.ts similarity index 94% rename from src/plugins/settings/modules/guild/modules/welcome.ts rename to src/plugins/config/modules/welcome.ts index b349bdb..edfb89c 100644 --- a/src/plugins/settings/modules/guild/modules/welcome.ts +++ b/src/plugins/config/modules/welcome.ts @@ -2,7 +2,7 @@ import { CommandInteraction, Permissions } from "discord.js"; // Configurations -import { successColor, footerText, footerIcon } from "@config/embed"; +import getEmbedConfig from "@helpers/getEmbedConfig"; // Handlers import logger from "@logger"; @@ -53,7 +53,9 @@ export default { ); }, execute: async (interaction: CommandInteraction) => { - // Destructure member + if (interaction.guild == null) return; + const { errorColor, successColor, footerText, footerIcon } = + await getEmbedConfig(interaction.guild); // Destructure member const { options, guild } = interaction; // Get options diff --git a/src/plugins/counters/modules/view/index.ts b/src/plugins/counters/modules/view/index.ts index 3697aa2..d672f0d 100644 --- a/src/plugins/counters/modules/view/index.ts +++ b/src/plugins/counters/modules/view/index.ts @@ -1,9 +1,4 @@ -import { - errorColor, - successColor, - footerText, - footerIcon, -} from "@config/embed"; +import getEmbedConfig from "@helpers/getEmbedConfig"; import { CommandInteraction, MessageEmbed } from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; @@ -30,6 +25,9 @@ export default { }, execute: async (interaction: CommandInteraction) => { + if (interaction.guild == null) return; + const { errorColor, successColor, footerText, footerIcon } = + await getEmbedConfig(interaction.guild); const { options, guild } = interaction; const discordChannel = options?.getChannel("channel"); diff --git a/src/plugins/credits/modules/balance/index.ts b/src/plugins/credits/modules/balance/index.ts index 412d4b4..60ee17e 100644 --- a/src/plugins/credits/modules/balance/index.ts +++ b/src/plugins/credits/modules/balance/index.ts @@ -1,9 +1,4 @@ -import { - errorColor, - successColor, - footerText, - footerIcon, -} from "@config/embed"; +import getEmbedConfig from "@helpers/getEmbedConfig"; import { CommandInteraction, MessageEmbed } from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; @@ -24,6 +19,9 @@ export default { ); }, execute: async (interaction: CommandInteraction) => { + if (interaction.guild == null) return; + const { errorColor, successColor, footerText, footerIcon } = + await getEmbedConfig(interaction.guild); const { options, user, guild } = interaction; const discordUser = options.getUser("user"); diff --git a/src/plugins/credits/modules/gift/index.ts b/src/plugins/credits/modules/gift/index.ts index 0590b85..c2dcde4 100644 --- a/src/plugins/credits/modules/gift/index.ts +++ b/src/plugins/credits/modules/gift/index.ts @@ -2,12 +2,7 @@ import { CommandInteraction, MessageEmbed } from "discord.js"; // Configurations -import { - errorColor, - successColor, - footerText, - footerIcon, -} from "@config/embed"; +import getEmbedConfig from "@helpers/getEmbedConfig"; // Handlers import logger from "@logger"; @@ -44,6 +39,9 @@ export default { ); }, execute: async (interaction: CommandInteraction) => { + if (interaction.guild == null) return; + const { errorColor, successColor, footerText, footerIcon } = + await getEmbedConfig(interaction.guild); const { options, user, guild, client, locale } = interaction; const optionUser = options.getUser("user"); diff --git a/src/plugins/credits/modules/top/index.ts b/src/plugins/credits/modules/top/index.ts index a334e0d..747f1bc 100644 --- a/src/plugins/credits/modules/top/index.ts +++ b/src/plugins/credits/modules/top/index.ts @@ -1,9 +1,4 @@ -import { - successColor, - errorColor, - footerText, - footerIcon, -} from "@config/embed"; +import getEmbedConfig from "@helpers/getEmbedConfig"; import { CommandInteraction, MessageEmbed } from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; @@ -18,6 +13,9 @@ export default { return command.setName("top").setDescription(`View the top users`); }, execute: async (interaction: CommandInteraction) => { + if (interaction.guild == null) return; + const { errorColor, successColor, footerText, footerIcon } = + await getEmbedConfig(interaction.guild); const { guild } = interaction; const embed = new MessageEmbed() diff --git a/src/plugins/credits/modules/work/index.ts b/src/plugins/credits/modules/work/index.ts index ca863bd..1cde8cb 100644 --- a/src/plugins/credits/modules/work/index.ts +++ b/src/plugins/credits/modules/work/index.ts @@ -4,12 +4,7 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import Chance from "chance"; // Configurations -import { - successColor, - errorColor, - footerText, - footerIcon, -} from "@config/embed"; +import getEmbedConfig from "@helpers/getEmbedConfig"; // Handlers import logger from "@logger"; @@ -28,7 +23,9 @@ export default { return command.setName("work").setDescription(`Work to earn credits`); }, execute: async (interaction: CommandInteraction) => { - // Destructure member + if (interaction.guild == null) return; + const { errorColor, successColor, footerText, footerIcon } = + await getEmbedConfig(interaction.guild); // Destructure member const { guild, user } = interaction; const embed = new MessageEmbed() diff --git a/src/plugins/fun/modules/meme.ts b/src/plugins/fun/modules/meme.ts index fb0c3c8..d37a1b9 100644 --- a/src/plugins/fun/modules/meme.ts +++ b/src/plugins/fun/modules/meme.ts @@ -1,4 +1,4 @@ -import { successColor, footerText, footerIcon } from "@config/embed"; +import getEmbedConfig from "@helpers/getEmbedConfig"; import axios from "axios"; import { CommandInteraction, MessageEmbed } from "discord.js"; @@ -12,6 +12,9 @@ export default { return command.setName("meme").setDescription("Get a meme from r/memes)"); }, execute: async (interaction: CommandInteraction) => { + if (interaction.guild == null) return; + const { errorColor, successColor, footerText, footerIcon } = + await getEmbedConfig(interaction.guild); await axios .get("https://www.reddit.com/r/memes/random/.json") .then(async (res) => { diff --git a/src/plugins/manage/modules/counters/index.ts b/src/plugins/manage/modules/counters/index.ts index 3fb9d3e..9206725 100644 --- a/src/plugins/manage/modules/counters/index.ts +++ b/src/plugins/manage/modules/counters/index.ts @@ -3,6 +3,7 @@ import { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders"; import { CommandInteraction } from "discord.js"; import logger from "@logger"; +import getEmbedConfig from "@helpers/getEmbedConfig"; // Modules import modules from "./modules"; @@ -20,6 +21,9 @@ export default { }, execute: async (interaction: CommandInteraction) => { + if (interaction.guild == null) return; + const { errorColor, successColor, footerText, footerIcon } = + await getEmbedConfig(interaction.guild); const { options } = interaction; if (options?.getSubcommand() === "add") { diff --git a/src/plugins/manage/modules/counters/modules/add/index.ts b/src/plugins/manage/modules/counters/modules/add/index.ts index 1bb9cb2..bd9854c 100644 --- a/src/plugins/manage/modules/counters/modules/add/index.ts +++ b/src/plugins/manage/modules/counters/modules/add/index.ts @@ -4,14 +4,8 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChannelType } from "discord-api-types/v10"; // Configurations -import { - successColor, - errorColor, - footerText, - footerIcon, -} from "@config/embed"; +import getEmbedConfig from "@helpers/getEmbedConfig"; -// Handlers import logger from "@logger"; // Models @@ -49,6 +43,9 @@ export default { ); }, execute: async (interaction: CommandInteraction) => { + if (interaction.guild == null) return; + const { errorColor, successColor, footerText, footerIcon } = + await getEmbedConfig(interaction.guild); const { options, guild, locale } = interaction; const discordChannel = options?.getChannel("channel"); diff --git a/src/plugins/manage/modules/counters/modules/remove/index.ts b/src/plugins/manage/modules/counters/modules/remove/index.ts index c0991f7..b108261 100644 --- a/src/plugins/manage/modules/counters/modules/remove/index.ts +++ b/src/plugins/manage/modules/counters/modules/remove/index.ts @@ -2,12 +2,7 @@ import { CommandInteraction, MessageEmbed, Permissions } from "discord.js"; // Configurations -import { - successColor, - errorColor, - footerText, - footerIcon, -} from "@config/embed"; +import getEmbedConfig from "@helpers/getEmbedConfig"; // Handlers import logger from "@logger"; @@ -38,6 +33,9 @@ export default { ); }, execute: async (interaction: CommandInteraction) => { + if (interaction.guild == null) return; + const { errorColor, successColor, footerText, footerIcon } = + await getEmbedConfig(interaction.guild); const { options, guild, locale } = interaction; const discordChannel = options?.getChannel("channel"); diff --git a/src/plugins/manage/modules/credits/index.ts b/src/plugins/manage/modules/credits/index.ts index a12cf11..f0f5793 100644 --- a/src/plugins/manage/modules/credits/index.ts +++ b/src/plugins/manage/modules/credits/index.ts @@ -1,6 +1,7 @@ import { CommandInteraction } from "discord.js"; import { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders"; import logger from "@logger"; +import getEmbedConfig from "@helpers/getEmbedConfig"; import modules from "./modules"; @@ -17,6 +18,9 @@ export default { .addSubcommand(modules.transfer.builder); }, execute: async (interaction: CommandInteraction) => { + if (interaction.guild == null) return; + const { errorColor, successColor, footerText, footerIcon } = + await getEmbedConfig(interaction.guild); const { options } = interaction; switch (options.getSubcommand()) { diff --git a/src/plugins/manage/modules/credits/modules/give/index.ts b/src/plugins/manage/modules/credits/modules/give/index.ts index 4734231..cec0376 100644 --- a/src/plugins/manage/modules/credits/modules/give/index.ts +++ b/src/plugins/manage/modules/credits/modules/give/index.ts @@ -3,12 +3,7 @@ import { CommandInteraction, MessageEmbed, Permissions } from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Configurations -import { - successColor, - errorColor, - footerText, - footerIcon, -} from "@config/embed"; +import getEmbedConfig from "@helpers/getEmbedConfig"; // Handlers import logger from "@logger"; @@ -45,7 +40,9 @@ export default { ); }, execute: async (interaction: CommandInteraction) => { - // Destructure + if (interaction.guild == null) return; + const { errorColor, successColor, footerText, footerIcon } = + await getEmbedConfig(interaction.guild); // Destructure const { guild, options } = interaction; const discordReceiver = options?.getUser("user"); diff --git a/src/plugins/manage/modules/credits/modules/set/index.ts b/src/plugins/manage/modules/credits/modules/set/index.ts index e8b8875..a7d86a2 100644 --- a/src/plugins/manage/modules/credits/modules/set/index.ts +++ b/src/plugins/manage/modules/credits/modules/set/index.ts @@ -2,12 +2,7 @@ import { CommandInteraction, MessageEmbed, Permissions } from "discord.js"; // Configurations -import { - successColor, - errorColor, - footerText, - footerIcon, -} from "@config/embed"; +import getEmbedConfig from "@helpers/getEmbedConfig"; // Handlers import logger from "@logger"; @@ -44,6 +39,9 @@ export default { ); }, execute: async (interaction: CommandInteraction) => { + if (interaction.guild == null) return; + const { errorColor, successColor, footerText, footerIcon } = + await getEmbedConfig(interaction.guild); const { options, guild } = interaction; const discordUser = options.getUser("user"); diff --git a/src/plugins/manage/modules/credits/modules/take/index.ts b/src/plugins/manage/modules/credits/modules/take/index.ts index 0b07fe4..9c823b9 100644 --- a/src/plugins/manage/modules/credits/modules/take/index.ts +++ b/src/plugins/manage/modules/credits/modules/take/index.ts @@ -2,12 +2,7 @@ import { CommandInteraction, MessageEmbed, Permissions } from "discord.js"; // Configurations -import { - successColor, - errorColor, - footerText, - footerIcon, -} from "@config/embed"; +import getEmbedConfig from "@helpers/getEmbedConfig"; // Handlers import logger from "@logger"; @@ -45,7 +40,9 @@ export default { ); }, execute: async (interaction: CommandInteraction) => { - // Destructure + if (interaction.guild == null) return; + const { errorColor, successColor, footerText, footerIcon } = + await getEmbedConfig(interaction.guild); // Destructure const { guild, options } = interaction; // User option diff --git a/src/plugins/manage/modules/credits/modules/transfer/index.ts b/src/plugins/manage/modules/credits/modules/transfer/index.ts index 00e1fbe..19de23a 100644 --- a/src/plugins/manage/modules/credits/modules/transfer/index.ts +++ b/src/plugins/manage/modules/credits/modules/transfer/index.ts @@ -2,12 +2,7 @@ import { CommandInteraction, MessageEmbed, Permissions } from "discord.js"; // Configurations -import { - successColor, - errorColor, - footerText, - footerIcon, -} from "@config/embed"; +import getEmbedConfig from "@helpers/getEmbedConfig"; // Handlers import logger from "@logger"; @@ -51,7 +46,9 @@ export default { ); }, execute: async (interaction: CommandInteraction) => { - // Destructure member + if (interaction.guild == null) return; + const { errorColor, successColor, footerText, footerIcon } = + await getEmbedConfig(interaction.guild); // Destructure member const { guild, options } = interaction; // Get options diff --git a/src/plugins/profile/modules/view.ts b/src/plugins/profile/modules/view.ts index 472c969..d73baaa 100644 --- a/src/plugins/profile/modules/view.ts +++ b/src/plugins/profile/modules/view.ts @@ -2,7 +2,7 @@ import { CommandInteraction } from "discord.js"; // Configurations -import { successColor, footerText, footerIcon } from "@config/embed"; +import getEmbedConfig from "@helpers/getEmbedConfig"; // Models import fetchUser from "@helpers/fetchUser"; @@ -24,7 +24,9 @@ export default { }, execute: async (interaction: CommandInteraction) => { - // Destructure + if (interaction.guild == null) return; + const { errorColor, successColor, footerText, footerIcon } = + await getEmbedConfig(interaction.guild); // Destructure const { client, options, user, guild } = interaction; // Target information diff --git a/src/plugins/reputation/modules/give.ts b/src/plugins/reputation/modules/give.ts index c467c4b..949f9c9 100644 --- a/src/plugins/reputation/modules/give.ts +++ b/src/plugins/reputation/modules/give.ts @@ -2,12 +2,7 @@ import { CommandInteraction } from "discord.js"; // Configurations -import { - successColor, - errorColor, - footerText, - footerIcon, -} from "@config/embed"; +import getEmbedConfig from "@helpers/getEmbedConfig"; import { timeout } from "@config/reputation"; @@ -48,7 +43,9 @@ export default { ); }, execute: async (interaction: CommandInteraction) => { - // Destructure + if (interaction.guild == null) return; + const { errorColor, successColor, footerText, footerIcon } = + await getEmbedConfig(interaction.guild); // Destructure const { options, user, guild } = interaction; // Target option diff --git a/src/plugins/settings/index.ts b/src/plugins/settings/index.ts deleted file mode 100644 index 5ab9d74..0000000 --- a/src/plugins/settings/index.ts +++ /dev/null @@ -1,32 +0,0 @@ -// Dependencies -import { SlashCommandBuilder } from "@discordjs/builders"; -import { CommandInteraction } from "discord.js"; - -// Modules -import modules from "./modules"; - -// Handlers -import logger from "@logger"; - -// Function -export default { - modules, - - builder: new SlashCommandBuilder() - .setName("settings") - .setDescription("Manage settings.") - - .addSubcommandGroup(modules.guild.builder), - - async execute(interaction: CommandInteraction) { - const { options } = interaction; - - if (options.getSubcommandGroup() === "guild") { - logger.silly(`Executing guild subcommand`); - - return modules.guild.execute(interaction); - } - - logger.silly(`No subcommand group found`); - }, -}; diff --git a/src/plugins/settings/modules/guild/modules/index.ts b/src/plugins/settings/modules/guild/modules/index.ts deleted file mode 100644 index ccdf8f7..0000000 --- a/src/plugins/settings/modules/guild/modules/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -import audits from "@plugins/settings/modules/guild/modules/audits"; -import credits from "@plugins/settings/modules/guild/modules/credits"; -import points from "@plugins/settings/modules/guild/modules/points"; -import pterodactyl from "@plugins/settings/modules/guild/modules/pterodactyl"; -import shop from "@plugins/settings/modules/guild/modules/shop"; -import welcome from "@plugins/settings/modules/guild/modules/welcome"; - -export default { audits, credits, points, pterodactyl, shop, welcome }; diff --git a/src/plugins/settings/modules/index.ts b/src/plugins/settings/modules/index.ts deleted file mode 100644 index a487700..0000000 --- a/src/plugins/settings/modules/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import guild from "@plugins/settings/modules/guild"; - -export default { guild }; diff --git a/src/plugins/shop/modules/pterodactyl.ts b/src/plugins/shop/modules/pterodactyl.ts index 57e36af..f3ef08b 100644 --- a/src/plugins/shop/modules/pterodactyl.ts +++ b/src/plugins/shop/modules/pterodactyl.ts @@ -2,12 +2,7 @@ import { CommandInteraction } from "discord.js"; import { v4 as uuidv4 } from "uuid"; import axios from "axios"; -import { - successColor, - errorColor, - footerText, - footerIcon, -} from "@config/embed"; +import getEmbedConfig from "@helpers/getEmbedConfig"; import logger from "@logger"; import encryption from "@handlers/encryption"; @@ -32,6 +27,9 @@ export default { ); }, execute: async (interaction: CommandInteraction) => { + if (interaction.guild == null) return; + const { errorColor, successColor, footerText, footerIcon } = + await getEmbedConfig(interaction.guild); const { options, guild, user, client } = interaction; const optionAmount = options?.getInteger("amount"); diff --git a/src/plugins/shop/modules/roles/index.ts b/src/plugins/shop/modules/roles/index.ts index d9242de..d158e72 100644 --- a/src/plugins/shop/modules/roles/index.ts +++ b/src/plugins/shop/modules/roles/index.ts @@ -5,7 +5,7 @@ import { CommandInteraction } from "discord.js"; // Handlers import logger from "@logger"; -import { errorColor, footerText, footerIcon } from "@config/embed"; +import getEmbedConfig from "@helpers/getEmbedConfig"; // Modules import modules from "./modules"; @@ -24,6 +24,9 @@ export default { .addSubcommand(modules.cancel.builder); }, execute: async (interaction: CommandInteraction) => { + if (interaction.guild == null) return; + const { errorColor, successColor, footerText, footerIcon } = + await getEmbedConfig(interaction.guild); const { options, guild } = interaction; const guildDB = await guildSchema?.findOne({ diff --git a/src/plugins/shop/modules/roles/modules/buy.ts b/src/plugins/shop/modules/roles/modules/buy.ts index 32c5918..4e4528d 100644 --- a/src/plugins/shop/modules/roles/modules/buy.ts +++ b/src/plugins/shop/modules/roles/modules/buy.ts @@ -6,12 +6,8 @@ import { } from "discord.js"; // Configurations -import { - successColor, - errorColor, - footerText, - footerIcon, -} from "@config/embed"; +import getEmbedConfig from "@helpers/getEmbedConfig"; + // Models import shopRolesSchema from "@schemas/shopRole"; import guildSchema from "@schemas/guild"; @@ -45,6 +41,9 @@ export default { ); }, execute: async (interaction: CommandInteraction) => { + if (interaction.guild == null) return; + const { errorColor, successColor, footerText, footerIcon } = + await getEmbedConfig(interaction.guild); const { options, guild, user, member } = interaction; const optionName = options?.getString("name"); diff --git a/src/plugins/shop/modules/roles/modules/cancel.ts b/src/plugins/shop/modules/roles/modules/cancel.ts index 5dd9362..546dbc7 100644 --- a/src/plugins/shop/modules/roles/modules/cancel.ts +++ b/src/plugins/shop/modules/roles/modules/cancel.ts @@ -2,12 +2,8 @@ import { CommandInteraction, GuildMemberRoleManager } from "discord.js"; // Configurations -import { - successColor, - errorColor, - footerText, - footerIcon, -} from "@config/embed"; +import getEmbedConfig from "@helpers/getEmbedConfig"; + // Models import shopRolesSchema from "@schemas/shopRole"; @@ -34,6 +30,9 @@ export default { ); }, execute: async (interaction: CommandInteraction) => { + if (interaction.guild == null) return; + const { errorColor, successColor, footerText, footerIcon } = + await getEmbedConfig(interaction.guild); const { options, guild, user, member } = interaction; const optionRole = options.getRole("role"); diff --git a/src/plugins/utility/modules/about.ts b/src/plugins/utility/modules/about.ts index 35aa0c0..fdc8e7e 100644 --- a/src/plugins/utility/modules/about.ts +++ b/src/plugins/utility/modules/about.ts @@ -2,7 +2,7 @@ import { CommandInteraction } from "discord.js"; // Configurations -import { successColor, footerText, footerIcon } from "@config/embed"; +import getEmbedConfig from "@helpers/getEmbedConfig"; import { hosterName, hosterUrl } from "@config/other"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; @@ -15,6 +15,9 @@ export default { return command.setName("about").setDescription("About this bot!)"); }, execute: async (interaction: CommandInteraction) => { + if (interaction.guild == null) return; + const { errorColor, successColor, footerText, footerIcon } = + await getEmbedConfig(interaction.guild); const interactionEmbed = { title: ":hammer: Utilities [About]", description: `This bot is hosted by ${ diff --git a/src/plugins/utility/modules/avatar.ts b/src/plugins/utility/modules/avatar.ts index aa8c0e0..e30b4be 100644 --- a/src/plugins/utility/modules/avatar.ts +++ b/src/plugins/utility/modules/avatar.ts @@ -1,4 +1,4 @@ -import { successColor, footerText, footerIcon } from "@config/embed"; +import getEmbedConfig from "@helpers/getEmbedConfig"; import { CommandInteraction, MessageEmbed } from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; @@ -17,6 +17,9 @@ export default { ); }, execute: async (interaction: CommandInteraction) => { + if (interaction.guild == null) return; + const { errorColor, successColor, footerText, footerIcon } = + await getEmbedConfig(interaction.guild); const userOption = interaction.options.getUser("user"); const targetUser = userOption || interaction.user; diff --git a/src/plugins/utility/modules/lookup.ts b/src/plugins/utility/modules/lookup.ts index c3d2e26..49785d2 100644 --- a/src/plugins/utility/modules/lookup.ts +++ b/src/plugins/utility/modules/lookup.ts @@ -1,12 +1,8 @@ import axios from "axios"; import { CommandInteraction, MessageEmbed } from "discord.js"; -import { - successColor, - errorColor, - footerText, - footerIcon, -} from "@config/embed"; +import getEmbedConfig from "@helpers/getEmbedConfig"; + import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; @@ -30,6 +26,9 @@ export default { ); }, execute: async (interaction: CommandInteraction) => { + if (interaction.guild == null) return; + const { errorColor, successColor, footerText, footerIcon } = + await getEmbedConfig(interaction.guild); const embedTitle = "[:hammer:] Utility (Lookup)"; embedBuilder.setTitle(embedTitle); diff --git a/src/plugins/utility/modules/stats.ts b/src/plugins/utility/modules/stats.ts index 0014915..c14e284 100644 --- a/src/plugins/utility/modules/stats.ts +++ b/src/plugins/utility/modules/stats.ts @@ -1,4 +1,5 @@ -import { successColor, footerText, footerIcon } from "@config/embed"; +import getEmbedConfig from "@helpers/getEmbedConfig"; + import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { CommandInteraction } from "discord.js"; export default { @@ -8,6 +9,9 @@ export default { return command.setName("stats").setDescription("Check bot statistics!)"); }, execute: async (interaction: CommandInteraction) => { + if (interaction.guild == null) return; + const { errorColor, successColor, footerText, footerIcon } = + await getEmbedConfig(interaction.guild); const { client } = interaction; if (client?.uptime === null) return; let totalSeconds = client?.uptime / 1000; diff --git a/tsconfig.json b/tsconfig.json index 6fda632..8f7076a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -22,7 +22,7 @@ "@events/*": ["events/*"], "@logger": ["logger"], "@database": ["database"], - "@schedules": ["schedules"], + "@jobs/*": ["jobs/*"], "@handlers/*": ["handlers/*"], "@helpers/*": ["helpers/*"], "@locale": ["locale"], From c9d0881ae900c5559e75ce838e105c13acd7cf94 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 20 May 2022 22:58:43 +0200 Subject: [PATCH 115/142] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20fixed=20code=20sme?= =?UTF-8?q?lls?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/events/guildMemberRemove/leaveMessage.ts | 1 - src/plugins/config/modules/audits.ts | 5 +++-- src/plugins/config/modules/credits.ts | 5 +++-- src/plugins/config/modules/points.ts | 5 +++-- src/plugins/config/modules/pterodactyl.ts | 5 +++-- src/plugins/config/modules/shop.ts | 5 +++-- src/plugins/config/modules/welcome.ts | 5 +++-- src/plugins/credits/modules/gift/index.ts | 2 +- src/plugins/fun/index.ts | 10 ++++------ src/plugins/fun/modules/meme.ts | 5 +++-- src/plugins/manage/modules/counters/index.ts | 4 ---- .../manage/modules/counters/modules/add/index.ts | 2 +- .../manage/modules/counters/modules/remove/index.ts | 2 +- src/plugins/manage/modules/credits/index.ts | 3 --- src/plugins/profile/modules/view.ts | 5 +++-- src/plugins/shop/modules/roles/index.ts | 5 +++-- src/plugins/utility/modules/about.ts | 5 +++-- src/plugins/utility/modules/avatar.ts | 5 +++-- src/plugins/utility/modules/lookup.ts | 2 +- src/plugins/utility/modules/stats.ts | 5 +++-- 20 files changed, 44 insertions(+), 42 deletions(-) diff --git a/src/events/guildMemberRemove/leaveMessage.ts b/src/events/guildMemberRemove/leaveMessage.ts index 113242e..efed730 100644 --- a/src/events/guildMemberRemove/leaveMessage.ts +++ b/src/events/guildMemberRemove/leaveMessage.ts @@ -1,4 +1,3 @@ -import logger from "@logger"; import { GuildMember, MessageEmbed, TextChannel } from "discord.js"; import guildSchema from "@schemas/guild"; diff --git a/src/plugins/config/modules/audits.ts b/src/plugins/config/modules/audits.ts index 9692167..817c990 100644 --- a/src/plugins/config/modules/audits.ts +++ b/src/plugins/config/modules/audits.ts @@ -36,8 +36,9 @@ export default { }, execute: async (interaction: CommandInteraction) => { if (interaction.guild == null) return; - const { errorColor, successColor, footerText, footerIcon } = - await getEmbedConfig(interaction.guild); + const { successColor, footerText, footerIcon } = await getEmbedConfig( + interaction.guild + ); const { guild, options } = interaction; diff --git a/src/plugins/config/modules/credits.ts b/src/plugins/config/modules/credits.ts index 146329d..3e20851 100644 --- a/src/plugins/config/modules/credits.ts +++ b/src/plugins/config/modules/credits.ts @@ -52,8 +52,9 @@ export default { }, execute: async (interaction: CommandInteraction) => { if (interaction.guild == null) return; - const { errorColor, successColor, footerText, footerIcon } = - await getEmbedConfig(interaction.guild); // Destructure member + const { successColor, footerText, footerIcon } = await getEmbedConfig( + interaction.guild + ); // Destructure member const { guild, options } = interaction; if (guild == null) return; diff --git a/src/plugins/config/modules/points.ts b/src/plugins/config/modules/points.ts index 4011013..a7e24a2 100644 --- a/src/plugins/config/modules/points.ts +++ b/src/plugins/config/modules/points.ts @@ -42,8 +42,9 @@ export default { }, execute: async (interaction: CommandInteraction) => { if (interaction.guild == null) return; - const { errorColor, successColor, footerText, footerIcon } = - await getEmbedConfig(interaction.guild); + const { successColor, footerText, footerIcon } = await getEmbedConfig( + interaction.guild + ); // Destructure member const { options, guild } = interaction; diff --git a/src/plugins/config/modules/pterodactyl.ts b/src/plugins/config/modules/pterodactyl.ts index 5ffa3e6..b7162d6 100644 --- a/src/plugins/config/modules/pterodactyl.ts +++ b/src/plugins/config/modules/pterodactyl.ts @@ -39,8 +39,9 @@ export default { }, execute: async (interaction: CommandInteraction) => { if (interaction.guild == null) return; - const { errorColor, successColor, footerText, footerIcon } = - await getEmbedConfig(interaction.guild); // Destructure member + const { successColor, footerText, footerIcon } = await getEmbedConfig( + interaction.guild + ); // Destructure member const { options, guild } = interaction; // Get options diff --git a/src/plugins/config/modules/shop.ts b/src/plugins/config/modules/shop.ts index 9f7f634..e9f4d9f 100644 --- a/src/plugins/config/modules/shop.ts +++ b/src/plugins/config/modules/shop.ts @@ -36,8 +36,9 @@ export default { }, execute: async (interaction: CommandInteraction) => { if (interaction.guild == null) return; - const { errorColor, successColor, footerText, footerIcon } = - await getEmbedConfig(interaction.guild); // Destructure member + const { successColor, footerText, footerIcon } = await getEmbedConfig( + interaction.guild + ); // Destructure member const { options, guild } = interaction; // Get options diff --git a/src/plugins/config/modules/welcome.ts b/src/plugins/config/modules/welcome.ts index edfb89c..48399c7 100644 --- a/src/plugins/config/modules/welcome.ts +++ b/src/plugins/config/modules/welcome.ts @@ -54,8 +54,9 @@ export default { }, execute: async (interaction: CommandInteraction) => { if (interaction.guild == null) return; - const { errorColor, successColor, footerText, footerIcon } = - await getEmbedConfig(interaction.guild); // Destructure member + const { successColor, footerText, footerIcon } = await getEmbedConfig( + interaction.guild + ); // Destructure member const { options, guild } = interaction; // Get options diff --git a/src/plugins/credits/modules/gift/index.ts b/src/plugins/credits/modules/gift/index.ts index c2dcde4..e0766bd 100644 --- a/src/plugins/credits/modules/gift/index.ts +++ b/src/plugins/credits/modules/gift/index.ts @@ -42,7 +42,7 @@ export default { if (interaction.guild == null) return; const { errorColor, successColor, footerText, footerIcon } = await getEmbedConfig(interaction.guild); - const { options, user, guild, client, locale } = interaction; + const { options, user, guild, client } = interaction; const optionUser = options.getUser("user"); const optionAmount = options.getInteger("amount"); diff --git a/src/plugins/fun/index.ts b/src/plugins/fun/index.ts index 4b89165..9ba8e81 100644 --- a/src/plugins/fun/index.ts +++ b/src/plugins/fun/index.ts @@ -16,12 +16,10 @@ export default { async execute(interaction: CommandInteraction) { const { options } = interaction; - switch (options.getSubcommand()) { - case "meme": - await modules.meme.execute(interaction); - break; - default: - logger.silly(`Unknown subcommand ${options.getSubcommand()}`); + if (options.getSubcommand() === "meme") { + await modules.meme.execute(interaction); + } else { + logger.silly(`Unknown subcommand ${options.getSubcommand()}`); } }, }; diff --git a/src/plugins/fun/modules/meme.ts b/src/plugins/fun/modules/meme.ts index d37a1b9..be62672 100644 --- a/src/plugins/fun/modules/meme.ts +++ b/src/plugins/fun/modules/meme.ts @@ -13,8 +13,9 @@ export default { }, execute: async (interaction: CommandInteraction) => { if (interaction.guild == null) return; - const { errorColor, successColor, footerText, footerIcon } = - await getEmbedConfig(interaction.guild); + const { successColor, footerText, footerIcon } = await getEmbedConfig( + interaction.guild + ); await axios .get("https://www.reddit.com/r/memes/random/.json") .then(async (res) => { diff --git a/src/plugins/manage/modules/counters/index.ts b/src/plugins/manage/modules/counters/index.ts index 9206725..3fb9d3e 100644 --- a/src/plugins/manage/modules/counters/index.ts +++ b/src/plugins/manage/modules/counters/index.ts @@ -3,7 +3,6 @@ import { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders"; import { CommandInteraction } from "discord.js"; import logger from "@logger"; -import getEmbedConfig from "@helpers/getEmbedConfig"; // Modules import modules from "./modules"; @@ -21,9 +20,6 @@ export default { }, execute: async (interaction: CommandInteraction) => { - if (interaction.guild == null) return; - const { errorColor, successColor, footerText, footerIcon } = - await getEmbedConfig(interaction.guild); const { options } = interaction; if (options?.getSubcommand() === "add") { diff --git a/src/plugins/manage/modules/counters/modules/add/index.ts b/src/plugins/manage/modules/counters/modules/add/index.ts index bd9854c..b4c6e99 100644 --- a/src/plugins/manage/modules/counters/modules/add/index.ts +++ b/src/plugins/manage/modules/counters/modules/add/index.ts @@ -46,7 +46,7 @@ export default { if (interaction.guild == null) return; const { errorColor, successColor, footerText, footerIcon } = await getEmbedConfig(interaction.guild); - const { options, guild, locale } = interaction; + const { options, guild } = interaction; const discordChannel = options?.getChannel("channel"); const countingWord = options?.getString("word"); diff --git a/src/plugins/manage/modules/counters/modules/remove/index.ts b/src/plugins/manage/modules/counters/modules/remove/index.ts index b108261..8a61687 100644 --- a/src/plugins/manage/modules/counters/modules/remove/index.ts +++ b/src/plugins/manage/modules/counters/modules/remove/index.ts @@ -36,7 +36,7 @@ export default { if (interaction.guild == null) return; const { errorColor, successColor, footerText, footerIcon } = await getEmbedConfig(interaction.guild); - const { options, guild, locale } = interaction; + const { options, guild } = interaction; const discordChannel = options?.getChannel("channel"); diff --git a/src/plugins/manage/modules/credits/index.ts b/src/plugins/manage/modules/credits/index.ts index f0f5793..c5e4bdb 100644 --- a/src/plugins/manage/modules/credits/index.ts +++ b/src/plugins/manage/modules/credits/index.ts @@ -18,9 +18,6 @@ export default { .addSubcommand(modules.transfer.builder); }, execute: async (interaction: CommandInteraction) => { - if (interaction.guild == null) return; - const { errorColor, successColor, footerText, footerIcon } = - await getEmbedConfig(interaction.guild); const { options } = interaction; switch (options.getSubcommand()) { diff --git a/src/plugins/profile/modules/view.ts b/src/plugins/profile/modules/view.ts index d73baaa..c6704a3 100644 --- a/src/plugins/profile/modules/view.ts +++ b/src/plugins/profile/modules/view.ts @@ -25,8 +25,9 @@ export default { execute: async (interaction: CommandInteraction) => { if (interaction.guild == null) return; - const { errorColor, successColor, footerText, footerIcon } = - await getEmbedConfig(interaction.guild); // Destructure + const { successColor, footerText, footerIcon } = await getEmbedConfig( + interaction.guild + ); // Destructure const { client, options, user, guild } = interaction; // Target information diff --git a/src/plugins/shop/modules/roles/index.ts b/src/plugins/shop/modules/roles/index.ts index d158e72..33ece41 100644 --- a/src/plugins/shop/modules/roles/index.ts +++ b/src/plugins/shop/modules/roles/index.ts @@ -25,8 +25,9 @@ export default { }, execute: async (interaction: CommandInteraction) => { if (interaction.guild == null) return; - const { errorColor, successColor, footerText, footerIcon } = - await getEmbedConfig(interaction.guild); + const { errorColor, footerText, footerIcon } = await getEmbedConfig( + interaction.guild + ); const { options, guild } = interaction; const guildDB = await guildSchema?.findOne({ diff --git a/src/plugins/utility/modules/about.ts b/src/plugins/utility/modules/about.ts index fdc8e7e..8011d51 100644 --- a/src/plugins/utility/modules/about.ts +++ b/src/plugins/utility/modules/about.ts @@ -16,8 +16,9 @@ export default { }, execute: async (interaction: CommandInteraction) => { if (interaction.guild == null) return; - const { errorColor, successColor, footerText, footerIcon } = - await getEmbedConfig(interaction.guild); + const { successColor, footerText, footerIcon } = await getEmbedConfig( + interaction.guild + ); const interactionEmbed = { title: ":hammer: Utilities [About]", description: `This bot is hosted by ${ diff --git a/src/plugins/utility/modules/avatar.ts b/src/plugins/utility/modules/avatar.ts index e30b4be..b060be3 100644 --- a/src/plugins/utility/modules/avatar.ts +++ b/src/plugins/utility/modules/avatar.ts @@ -18,8 +18,9 @@ export default { }, execute: async (interaction: CommandInteraction) => { if (interaction.guild == null) return; - const { errorColor, successColor, footerText, footerIcon } = - await getEmbedConfig(interaction.guild); + const { successColor, footerText, footerIcon } = await getEmbedConfig( + interaction.guild + ); const userOption = interaction.options.getUser("user"); const targetUser = userOption || interaction.user; diff --git a/src/plugins/utility/modules/lookup.ts b/src/plugins/utility/modules/lookup.ts index 49785d2..f9ea2ce 100644 --- a/src/plugins/utility/modules/lookup.ts +++ b/src/plugins/utility/modules/lookup.ts @@ -3,7 +3,6 @@ import { CommandInteraction, MessageEmbed } from "discord.js"; import getEmbedConfig from "@helpers/getEmbedConfig"; - import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import logger from "@logger"; @@ -44,6 +43,7 @@ export default { embeds: [ embedBuilder .setColor(errorColor) + .setFooter({ text: footerText, iconURL: footerIcon }) .setDescription( `${response?.data?.message}: ${response?.data?.query}` ), diff --git a/src/plugins/utility/modules/stats.ts b/src/plugins/utility/modules/stats.ts index c14e284..a7f44a0 100644 --- a/src/plugins/utility/modules/stats.ts +++ b/src/plugins/utility/modules/stats.ts @@ -10,8 +10,9 @@ export default { }, execute: async (interaction: CommandInteraction) => { if (interaction.guild == null) return; - const { errorColor, successColor, footerText, footerIcon } = - await getEmbedConfig(interaction.guild); + const { successColor, footerText, footerIcon } = await getEmbedConfig( + interaction.guild + ); const { client } = interaction; if (client?.uptime === null) return; let totalSeconds = client?.uptime / 1000; From 1cf7602f69bb43d7bae24a2ec728eab75a6ace8e Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 20 May 2022 23:01:10 +0200 Subject: [PATCH 116/142] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20fixed=20code=20sme?= =?UTF-8?q?ll?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/manage/modules/credits/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plugins/manage/modules/credits/index.ts b/src/plugins/manage/modules/credits/index.ts index c5e4bdb..a12cf11 100644 --- a/src/plugins/manage/modules/credits/index.ts +++ b/src/plugins/manage/modules/credits/index.ts @@ -1,7 +1,6 @@ import { CommandInteraction } from "discord.js"; import { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders"; import logger from "@logger"; -import getEmbedConfig from "@helpers/getEmbedConfig"; import modules from "./modules"; From 7fe1149fd0154296421449ae431ada21d7564506 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 20 May 2022 23:11:33 +0200 Subject: [PATCH 117/142] =?UTF-8?q?=F0=9F=9A=91=20src/index.ts=20using=20o?= =?UTF-8?q?ld=20.then=20function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.ts | 34 +++++----------------------------- 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/src/index.ts b/src/index.ts index 573ff72..e502414 100644 --- a/src/index.ts +++ b/src/index.ts @@ -17,43 +17,19 @@ const main = async () => { }); // Start database manager - await database() - .then(async () => { - await logger.silly("Database process started"); - }) - .catch(async (err) => { - await logger.error(`${err}`); - }); + await database(); // Start schedule manager - await schedules(client) - .then(async () => { - await logger.silly("Schedules process started"); - }) - .catch(async (err) => { - await logger.error(`${err}`); - }); + await schedules(client); // Start command handler - await commands(client) - .then(async () => { - await logger.silly("Commands process started"); - }) - .catch(async (err) => { - await logger.error(`${err}`); - }); + await commands(client); // Start event handler - await events(client) - .then(async () => { - await logger.silly("Events process started"); - }) - .catch(async (err) => { - await logger.error(`${err}`); - }); + await events(client); // Authorize with Discord's API await client.login(token); }; -main() \ No newline at end of file +main(); From 6076b5f22063c40390af6b876b1eb5a4e2fd2142 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 20 May 2022 23:13:07 +0200 Subject: [PATCH 118/142] =?UTF-8?q?=F0=9F=9A=91=20logger=20module=20was=20?= =?UTF-8?q?using=20old=20format?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/logger/index.ts | 47 +++++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/src/logger/index.ts b/src/logger/index.ts index c82f2ae..ae96924 100644 --- a/src/logger/index.ts +++ b/src/logger/index.ts @@ -3,31 +3,24 @@ import "winston-daily-rotate-file"; const { combine, timestamp, printf, colorize, align, json } = winston.format; -module.exports = { - // Logger initialized async-hronously - logger: async () => { - return winston.createLogger({ - level: process.env.LOG_LEVEL || "silly", - transports: [ - new winston.transports.DailyRotateFile({ - filename: "logs/combined-%DATE%.log", - datePattern: "YYYY-MM-DD", - maxFiles: "14d", - format: combine(timestamp(), json()), +export default winston.createLogger({ + level: process.env.LOG_LEVEL || "silly", + transports: [ + new winston.transports.DailyRotateFile({ + filename: "logs/combined-%DATE%.log", + datePattern: "YYYY-MM-DD", + maxFiles: "14d", + format: combine(timestamp(), json()), + }), + new winston.transports.Console({ + format: combine( + colorize({ all: true }), + timestamp({ + format: "YYYY-MM-DD HH:MM:ss", }), - new winston.transports.Console({ - format: combine( - colorize({ all: true }), - timestamp({ - format: "YYYY-MM-DD HH:MM:ss", - }), - align(), - printf( - (info) => `[${info.timestamp}] ${info.level}: ${info.message}` - ) - ), - }), - ], - }); - }, -}; + align(), + printf((info) => `[${info.timestamp}] ${info.level}: ${info.message}`) + ), + }), + ], +}); From 3a10ed97f7590ddc8f13d38ac398373aad27072e Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sat, 21 May 2022 00:18:49 +0200 Subject: [PATCH 119/142] =?UTF-8?q?=F0=9F=9A=91=20start=20script=20change?= =?UTF-8?q?=20to=20nodemon?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 38dca3b..aca27bf 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "src/index.ts", "scripts": { "test": "jest", - "start": "node .", + "start": "nodemon .", "prettier-format": "prettier \"src/**/*.ts\" --write", "lint": "eslint ./src --ext .ts", "prepare": "husky install" From 6c70c645a54527a7b933792e0777722812ae9464 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sat, 21 May 2022 00:21:52 +0200 Subject: [PATCH 120/142] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index aca27bf..216f2fb 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "src/index.ts", "scripts": { "test": "jest", - "start": "nodemon .", + "start": "nodemon src/index.ts", "prettier-format": "prettier \"src/**/*.ts\" --write", "lint": "eslint ./src --ext .ts", "prepare": "husky install" From d7087e7c3cbdbf0f88ef1334208206e683f3b213 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sat, 21 May 2022 00:37:28 +0200 Subject: [PATCH 121/142] =?UTF-8?q?=F0=9F=8F=B7=EF=B8=8F=20temporarely=20f?= =?UTF-8?q?ixed=20encryption=20types?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/handlers/encryption.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index aca27bf..216f2fb 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "src/index.ts", "scripts": { "test": "jest", - "start": "nodemon .", + "start": "nodemon src/index.ts", "prettier-format": "prettier \"src/**/*.ts\" --write", "lint": "eslint ./src --ext .ts", "prepare": "husky install" diff --git a/src/handlers/encryption.ts b/src/handlers/encryption.ts index 5e07d89..8e7ea27 100644 --- a/src/handlers/encryption.ts +++ b/src/handlers/encryption.ts @@ -4,7 +4,7 @@ import { secretKey, algorithm } from "@config/encryption"; const iv = crypto.randomBytes(16); -const encrypt = (text: any): { iv: error; content: error } => { +const encrypt = (text: any): { iv: any; content: any } => { const cipher = crypto.createCipheriv(algorithm, secretKey, iv); const encrypted = Buffer.concat([cipher.update(text), cipher.final()]); From 92e12fad88c6902887248856287188bb74944ac4 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sat, 21 May 2022 00:51:24 +0200 Subject: [PATCH 122/142] =?UTF-8?q?=F0=9F=A9=B9=20/credits=20gift=20is=20n?= =?UTF-8?q?ow=20working?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/credits/modules/gift/index.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/plugins/credits/modules/gift/index.ts b/src/plugins/credits/modules/gift/index.ts index e0766bd..0325ab0 100644 --- a/src/plugins/credits/modules/gift/index.ts +++ b/src/plugins/credits/modules/gift/index.ts @@ -184,6 +184,12 @@ export default { }); } + // Withdraw amount from fromUserDB + fromUserDB.credits -= optionAmount; + + // Deposit amount to toUserDB + toUserDB.credits += optionAmount; + // Save users await saveUser(fromUserDB, toUserDB).then(async () => { // Get DM user object From 5a56f35e07ec3e5c98495ddf81cb2905da2eeebc Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sat, 21 May 2022 11:42:55 +0200 Subject: [PATCH 123/142] Update index.ts --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index e502414..eaef4db 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,7 +4,7 @@ import { token, intents } from "@config/discord"; import { Client } from "discord.js"; // discord.js -import database from "@root/events"; +import database from "@database"; import schedules from "@handlers/schedules"; import events from "@handlers/events"; import commands from "@handlers/commands"; From 8537fcbded20d31fda8383f27473727eed77eaf6 Mon Sep 17 00:00:00 2001 From: servous Date: Sat, 28 May 2022 11:59:45 +0200 Subject: [PATCH 124/142] Improved TS typing/interfaces. --- src/handlers/deployCommands.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/handlers/deployCommands.ts b/src/handlers/deployCommands.ts index 8af167e..4ca0923 100644 --- a/src/handlers/deployCommands.ts +++ b/src/handlers/deployCommands.ts @@ -1,17 +1,24 @@ -// Dependencies +// @ts-ignore import { token, clientId } from "@config/discord"; +// @ts-ignore import { devMode, guildId } from "@config/other"; import logger from "../logger"; import { Client } from "@root/types/common/discord"; import { REST } from "@discordjs/rest"; import { Routes } from "discord-api-types/v9"; +import { SlashCommandBuilder } from "@discordjs/builders"; +import { RESTPostAPIApplicationCommandsJSONBody } from "discord-api-types/v10"; export default async (client: Client) => { - const pluginList = [] as string[]; + const pluginList: Array = []; + + interface IPluginData { + builder: SlashCommandBuilder; + } await Promise.all( - client.commands.map(async (pluginData: any) => { + client.commands.map(async (pluginData: IPluginData) => { pluginList.push(pluginData.builder.toJSON()); logger.verbose( `Plugin is ready for deployment: ${pluginData.builder.name}` From f960ef3cec02505a7e9bfcd134c5429ab3e096f7 Mon Sep 17 00:00:00 2001 From: servous Date: Sat, 28 May 2022 12:27:17 +0200 Subject: [PATCH 125/142] Improving TypeScript typing/interfaces. --- package.json | 1 + src/events/index.ts | 22 ------------------- .../interactionCreate/components/isCommand.ts | 2 +- src/handlers/encryption.ts | 11 +++++++--- src/helpers/sleep.ts | 2 +- src/plugins/config/modules/pterodactyl.ts | 5 +++-- src/plugins/shop/modules/pterodactyl.ts | 8 ++++--- src/types/common/discord.d.ts | 3 ++- 8 files changed, 21 insertions(+), 33 deletions(-) delete mode 100644 src/events/index.ts diff --git a/package.json b/package.json index 216f2fb..3acb125 100644 --- a/package.json +++ b/package.json @@ -65,6 +65,7 @@ "husky": "8.0.1", "jest": "28.0.0", "lint-staged": "^12.3.7", + "nodemon": "^2.0.16", "prettier": "^2.6.0" }, "lint-staged": { diff --git a/src/events/index.ts b/src/events/index.ts deleted file mode 100644 index b7dd3b6..0000000 --- a/src/events/index.ts +++ /dev/null @@ -1,22 +0,0 @@ -// 3rd party dependencies -import mongoose from "mongoose"; - -// Dependencies -import logger from "@logger"; - -// Configuration -import { url } from "@config/database"; - -export default async () => { - await mongoose.connect(url).then(async (connection) => { - logger.info(`Connected to database: ${connection.connection.name}`); - }); - - mongoose.connection.on("error", async (error) => { - logger.error(`${error}`); - }); - - mongoose.connection.on("warn", async (warning) => { - logger.warn(warning); - }); -}; diff --git a/src/events/interactionCreate/components/isCommand.ts b/src/events/interactionCreate/components/isCommand.ts index 7af8e7e..30edc4c 100644 --- a/src/events/interactionCreate/components/isCommand.ts +++ b/src/events/interactionCreate/components/isCommand.ts @@ -83,7 +83,7 @@ export default async (interaction: CommandInteraction) => { `Command: ${commandName} executed in guild: ${guild?.name} (${guild?.id}) by user: ${user?.tag} (${user?.id})` ); }) - .catch(async (error: any) => { + .catch(async (error: string) => { logger?.error(`${error}`); return interaction.editReply({ diff --git a/src/handlers/encryption.ts b/src/handlers/encryption.ts index 8e7ea27..cab28ff 100644 --- a/src/handlers/encryption.ts +++ b/src/handlers/encryption.ts @@ -1,12 +1,17 @@ import crypto from "crypto"; +// @ts-ignore import { secretKey, algorithm } from "@config/encryption"; const iv = crypto.randomBytes(16); -const encrypt = (text: any): { iv: any; content: any } => { - const cipher = crypto.createCipheriv(algorithm, secretKey, iv); +interface IEncrypt { + iv: string; + content: string; +} +const encrypt = (text: crypto.BinaryLike): IEncrypt => { + const cipher = crypto.createCipheriv(algorithm, secretKey, iv); const encrypted = Buffer.concat([cipher.update(text), cipher.final()]); return { @@ -15,7 +20,7 @@ const encrypt = (text: any): { iv: any; content: any } => { }; }; -const decrypt = (hash: any) => { +const decrypt = (hash: IEncrypt) => { const decipher = crypto.createDecipheriv( algorithm, secretKey, diff --git a/src/helpers/sleep.ts b/src/helpers/sleep.ts index 5e53d79..792c81f 100644 --- a/src/helpers/sleep.ts +++ b/src/helpers/sleep.ts @@ -1,6 +1,6 @@ import logger from "@logger"; -export default function sleep(milliseconds: any) { +export default function sleep(milliseconds: number) { return new Promise((resolve) => { setTimeout(resolve, milliseconds); logger?.silly(`Sleeping for ${milliseconds} milliseconds`); diff --git a/src/plugins/config/modules/pterodactyl.ts b/src/plugins/config/modules/pterodactyl.ts index b7162d6..e6673e1 100644 --- a/src/plugins/config/modules/pterodactyl.ts +++ b/src/plugins/config/modules/pterodactyl.ts @@ -45,8 +45,9 @@ export default { const { options, guild } = interaction; // Get options - const url = options?.getString("url"); - const token = encryption.encrypt(options?.getString("token")); + const tokenData = options.getString("token"); + const url = options.getString("url"); + const token = tokenData && encryption.encrypt(tokenData); // Update API credentials await apiSchema diff --git a/src/plugins/shop/modules/pterodactyl.ts b/src/plugins/shop/modules/pterodactyl.ts index f3ef08b..22da19c 100644 --- a/src/plugins/shop/modules/pterodactyl.ts +++ b/src/plugins/shop/modules/pterodactyl.ts @@ -147,10 +147,12 @@ export default { guildId: guild?.id, }); + if (!apiCredentials) return; + const api = axios?.create({ - baseURL: apiCredentials?.url, + baseURL: apiCredentials.url, headers: { - Authorization: `Bearer ${encryption.decrypt(apiCredentials?.token)}`, + Authorization: `Bearer ${encryption.decrypt(apiCredentials.token)}`, }, }); @@ -235,7 +237,7 @@ export default { }); }) - .catch(async (error: any) => { + .catch(async (error) => { logger?.silly(`Error creating voucher. - ${error}`); return interaction?.editReply({ diff --git a/src/types/common/discord.d.ts b/src/types/common/discord.d.ts index 1e4926f..68458e0 100644 --- a/src/types/common/discord.d.ts +++ b/src/types/common/discord.d.ts @@ -1,7 +1,8 @@ import { Collection, Client as DJSClient } from "discord.js"; + declare module "discord.js" { export interface Client extends DJSClient { - commands: Collection; + commands: Collection; } } From 50f070787c95546a22337d564b54077d1f305980 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sat, 28 May 2022 12:54:37 +0200 Subject: [PATCH 126/142] =?UTF-8?q?=F0=9F=90=9B=20Default=20embed=20if=20g?= =?UTF-8?q?uild=20is=20null=20#337?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/helpers/getEmbedConfig.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/helpers/getEmbedConfig.ts b/src/helpers/getEmbedConfig.ts index 3532542..df62073 100644 --- a/src/helpers/getEmbedConfig.ts +++ b/src/helpers/getEmbedConfig.ts @@ -1,17 +1,19 @@ import guildSchema from "@schemas/guild"; +import * as embedConfig from "@config/embed"; -import { ColorResolvable, Guild } from "discord.js"; +import { Guild } from "discord.js"; + +export default async (guild: Guild | null) => { + if (guild == null) + return { + ...embedConfig, + }; -export default async (guild: Guild) => { const guildConfig = await guildSchema.findOne({ guildId: guild.id }); if (guildConfig == null) return { - successColor: "#22bb33" as ColorResolvable, - waitColor: "#f0ad4e" as ColorResolvable, - errorColor: "#bb2124" as ColorResolvable, - footerIcon: "https://github.com/ZynerOrg.png", - footerText: "https://github.com/ZynerOrg/xyter", + ...embedConfig, }; return guildConfig.embeds; From 518ec431d8ab329db087da2484b0dfaf64f6ab00 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sat, 28 May 2022 12:55:23 +0200 Subject: [PATCH 127/142] =?UTF-8?q?=F0=9F=9A=B8=20more=20logical=20meme=20?= =?UTF-8?q?command?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fun/modules/{meme.ts => meme/index.ts} | 31 ++++++++++++++----- 1 file changed, 23 insertions(+), 8 deletions(-) rename src/plugins/fun/modules/{meme.ts => meme/index.ts} (57%) diff --git a/src/plugins/fun/modules/meme.ts b/src/plugins/fun/modules/meme/index.ts similarity index 57% rename from src/plugins/fun/modules/meme.ts rename to src/plugins/fun/modules/meme/index.ts index be62672..4efe8a7 100644 --- a/src/plugins/fun/modules/meme.ts +++ b/src/plugins/fun/modules/meme/index.ts @@ -11,11 +11,12 @@ export default { builder: (command: SlashCommandSubcommandBuilder) => { return command.setName("meme").setDescription("Get a meme from r/memes)"); }, + execute: async (interaction: CommandInteraction) => { - if (interaction.guild == null) return; - const { successColor, footerText, footerIcon } = await getEmbedConfig( - interaction.guild - ); + const { guild } = interaction; + + const embedConfig = await getEmbedConfig(guild); + await axios .get("https://www.reddit.com/r/memes/random/.json") .then(async (res) => { @@ -23,14 +24,28 @@ export default { const content = response[0].data; const embed = new MessageEmbed() - .setTitle(content.title) + .setAuthor({ + name: content.title, + iconURL: + "https://www.redditinc.com/assets/images/site/reddit-logo.png", + url: `https://reddit.com${content.permalink}`, + }) + .setTitle("[:sweat_smile:] Meme") + .addFields([ + { name: "Author", value: content.author, inline: true }, + { + name: "Votes", + value: `${content.ups}/${content.downs}`, + inline: true, + }, + ]) .setTimestamp(new Date()) .setImage(content.url) .setFooter({ - text: `👍 ${content.ups}︱👎 ${content.downs}\n${footerText}`, - iconURL: footerIcon, + text: embedConfig.footerText, + iconURL: embedConfig.footerIcon, }) - .setColor(successColor); + .setColor(embedConfig.successColor); return interaction.editReply({ embeds: [embed] }); }) From ddc43cf50946590bdad825911e2e83ce2692fc79 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sat, 28 May 2022 13:02:35 +0200 Subject: [PATCH 128/142] =?UTF-8?q?=F0=9F=9A=B8=20better=20throw=20new=20E?= =?UTF-8?q?rror=20handling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/events/interactionCreate/components/isCommand.ts | 9 ++++++--- src/helpers/capitalizeFirstLetter.ts | 3 +++ 2 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 src/helpers/capitalizeFirstLetter.ts diff --git a/src/events/interactionCreate/components/isCommand.ts b/src/events/interactionCreate/components/isCommand.ts index 30edc4c..91c61dd 100644 --- a/src/events/interactionCreate/components/isCommand.ts +++ b/src/events/interactionCreate/components/isCommand.ts @@ -6,6 +6,7 @@ import logger from "@logger"; import deferReply from "@root/helpers/deferReply"; import getEmbedConfig from "@helpers/getEmbedConfig"; import getCommandMetadata from "@helpers/getCommandMetadata"; +import capitalizeFirstLetter from "@helpers/capitalizeFirstLetter"; export default async (interaction: CommandInteraction) => { if (!interaction.isCommand()) return; @@ -89,10 +90,12 @@ export default async (interaction: CommandInteraction) => { return interaction.editReply({ embeds: [ new MessageEmbed() - .setTitle("Error") - .setDescription( - `There was an error executing the command: **${currentCommand?.data?.name}**.` + .setTitle( + `[:x:] ${capitalizeFirstLetter( + interaction.options.getSubcommand() + )}` ) + .setDescription(`${"``"}${error}${"``"}`) .setColor(errorColor) .setTimestamp(new Date()) .setFooter({ text: footerText, iconURL: footerIcon }), diff --git a/src/helpers/capitalizeFirstLetter.ts b/src/helpers/capitalizeFirstLetter.ts new file mode 100644 index 0000000..1190b36 --- /dev/null +++ b/src/helpers/capitalizeFirstLetter.ts @@ -0,0 +1,3 @@ +export default (text: string): string => { + return text.charAt(0).toUpperCase() + text.slice(1); +}; From 1a6bbd80f24ef1db925e348dbb84c7453e5777fa Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sat, 28 May 2022 13:03:02 +0200 Subject: [PATCH 129/142] =?UTF-8?q?=F0=9F=A5=85=20use=20throw=20new=20Erro?= =?UTF-8?q?r=20instead=20of=20logger.error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/fun/modules/meme/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/fun/modules/meme/index.ts b/src/plugins/fun/modules/meme/index.ts index 4efe8a7..3b6d706 100644 --- a/src/plugins/fun/modules/meme/index.ts +++ b/src/plugins/fun/modules/meme/index.ts @@ -50,7 +50,7 @@ export default { return interaction.editReply({ embeds: [embed] }); }) .catch((error) => { - logger.error(`${error}`); + throw new Error(error.message); }); }, }; From c84191d70f0015282178c0937aadaf94873eb8c6 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sat, 28 May 2022 13:17:32 +0200 Subject: [PATCH 130/142] =?UTF-8?q?=F0=9F=8E=A8=20mostly=20typed=20event?= =?UTF-8?q?=20handler?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/events/guildCreate/index.ts | 28 ++++++++++---------- src/events/guildDelete/index.ts | 25 ++++++++++-------- src/events/guildMemberAdd/index.ts | 29 +++++++++++---------- src/events/guildMemberRemove/index.ts | 29 +++++++++++---------- src/events/interactionCreate/index.ts | 25 ++++++++++-------- src/events/messageCreate/index.ts | 16 +++++++----- src/events/messageDelete/index.ts | 13 ++++++---- src/events/messageUpdate/index.ts | 31 ++++++++++++---------- src/events/ready/index.ts | 32 ++++++++++++----------- src/handlers/events.ts | 37 --------------------------- src/helpers/listDir/index.ts | 10 ++++++++ src/index.ts | 4 +-- src/interfaces/EventOptions.ts | 3 +++ src/managers/event/index.ts | 24 +++++++++++++++++ 14 files changed, 165 insertions(+), 141 deletions(-) delete mode 100644 src/handlers/events.ts create mode 100644 src/helpers/listDir/index.ts create mode 100644 src/interfaces/EventOptions.ts create mode 100644 src/managers/event/index.ts diff --git a/src/events/guildCreate/index.ts b/src/events/guildCreate/index.ts index 01b70f6..d76b9a2 100644 --- a/src/events/guildCreate/index.ts +++ b/src/events/guildCreate/index.ts @@ -1,20 +1,20 @@ -// 3rd party dependencies import { Guild } from "discord.js"; - -// Dependencies import updatePresence from "@helpers/updatePresence"; import fetchGuild from "@helpers/fetchGuild"; import logger from "@logger"; +import { IEventOptions } from "@root/interfaces/EventOptions"; -export default { - async execute(guild: Guild) { - const { client } = guild; - - logger?.silly(`Added to guild: ${guild.name} (${guild.id})`); - - await fetchGuild(guild); - await updatePresence(client); - - logger.silly(`guildCreate: ${guild}`); - }, +export const options: IEventOptions = { + type: "on", +}; + +export const execute = async (guild: Guild) => { + const { client } = guild; + + logger?.silly(`Added to guild: ${guild.name} (${guild.id})`); + + await fetchGuild(guild); + await updatePresence(client); + + logger.silly(`guildCreate: ${guild}`); }; diff --git a/src/events/guildDelete/index.ts b/src/events/guildDelete/index.ts index 123393c..741b69c 100644 --- a/src/events/guildDelete/index.ts +++ b/src/events/guildDelete/index.ts @@ -5,16 +5,19 @@ import { Guild } from "discord.js"; import updatePresence from "@helpers/updatePresence"; import dropGuild from "@helpers/dropGuild"; import logger from "@logger"; +import { IEventOptions } from "@root/interfaces/EventOptions"; -export default { - async execute(guild: Guild) { - const { client } = guild; - - logger?.silly(`Deleted from guild: ${guild.name} (${guild.id})`); - - await dropGuild(guild); - await updatePresence(client); - - logger.silly(`guildDelete: ${guild}`); - }, +export const options: IEventOptions = { + type: "on", +}; + +export const execute = async (guild: Guild) => { + const { client } = guild; + + logger?.silly(`Deleted from guild: ${guild.name} (${guild.id})`); + + await dropGuild(guild); + await updatePresence(client); + + logger.silly(`guildDelete: ${guild}`); }; diff --git a/src/events/guildMemberAdd/index.ts b/src/events/guildMemberAdd/index.ts index 9ece541..2cda131 100644 --- a/src/events/guildMemberAdd/index.ts +++ b/src/events/guildMemberAdd/index.ts @@ -7,18 +7,21 @@ import fetchUser from "@helpers/fetchUser"; import logger from "@logger"; import joinMessage from "../guildMemberAdd/joinMessage"; import audits from "../guildMemberAdd/audits"; +import { IEventOptions } from "@root/interfaces/EventOptions"; -export default { - async execute(member: GuildMember) { - const { client, user, guild } = member; - - logger?.silly( - `New member: ${user.tag} (${user.id}) added to guild: ${guild.name} (${guild.id})` - ); - - await audits.execute(member); - await joinMessage.execute(member); - await fetchUser(user, guild); - await updatePresence(client); - }, +export const options: IEventOptions = { + type: "on", +}; + +export const execute = async (member: GuildMember) => { + const { client, user, guild } = member; + + logger?.silly( + `New member: ${user.tag} (${user.id}) added to guild: ${guild.name} (${guild.id})` + ); + + await audits.execute(member); + await joinMessage.execute(member); + await fetchUser(user, guild); + await updatePresence(client); }; diff --git a/src/events/guildMemberRemove/index.ts b/src/events/guildMemberRemove/index.ts index 3d28c31..2cb2d48 100644 --- a/src/events/guildMemberRemove/index.ts +++ b/src/events/guildMemberRemove/index.ts @@ -7,18 +7,21 @@ import dropUser from "@helpers/dropUser"; import logger from "@logger"; import leaveMessage from "./leaveMessage"; import audits from "./audits"; +import { IEventOptions } from "@root/interfaces/EventOptions"; -export default { - async execute(member: GuildMember) { - const { client, user, guild } = member; - - logger?.silly( - `Removed member: ${user.tag} (${user.id}) from guild: ${guild.name} (${guild.id})` - ); - - await audits.execute(member); - await leaveMessage.execute(member); - await dropUser(user, guild); - await updatePresence(client); - }, +export const options: IEventOptions = { + type: "on", +}; + +export const execute = async (member: GuildMember) => { + const { client, user, guild } = member; + + logger?.silly( + `Removed member: ${user.tag} (${user.id}) from guild: ${guild.name} (${guild.id})` + ); + + await audits.execute(member); + await leaveMessage.execute(member); + await dropUser(user, guild); + await updatePresence(client); }; diff --git a/src/events/interactionCreate/index.ts b/src/events/interactionCreate/index.ts index 2848f39..e29deec 100644 --- a/src/events/interactionCreate/index.ts +++ b/src/events/interactionCreate/index.ts @@ -5,16 +5,19 @@ import { CommandInteraction } from "discord.js"; import isCommand from "@root/events/interactionCreate/components/isCommand"; import logger from "@logger"; import audits from "./audits"; +import { IEventOptions } from "@root/interfaces/EventOptions"; -export default { - async execute(interaction: CommandInteraction) { - const { guild, id } = interaction; - - logger?.silly( - `New interaction: ${id} in guild: ${guild?.name} (${guild?.id})` - ); - - await audits.execute(interaction); - await isCommand(interaction); - }, +export const options: IEventOptions = { + type: "on", +}; + +export const execute = async (interaction: CommandInteraction) => { + const { guild, id } = interaction; + + logger?.silly( + `New interaction: ${id} in guild: ${guild?.name} (${guild?.id})` + ); + + await audits.execute(interaction); + await isCommand(interaction); }; diff --git a/src/events/messageCreate/index.ts b/src/events/messageCreate/index.ts index 004ca71..6eb9744 100644 --- a/src/events/messageCreate/index.ts +++ b/src/events/messageCreate/index.ts @@ -1,10 +1,14 @@ import { Message } from "discord.js"; import modules from "@events/messageCreate/modules"; -export default { - async execute(message: Message) { - await modules.credits.execute(message); - await modules.points.execute(message); - await modules.counters.execute(message); - }, +import { IEventOptions } from "@root/interfaces/EventOptions"; + +export const options: IEventOptions = { + type: "on", +}; + +export const execute = async (message: Message) => { + await modules.credits.execute(message); + await modules.points.execute(message); + await modules.counters.execute(message); }; diff --git a/src/events/messageDelete/index.ts b/src/events/messageDelete/index.ts index 77223d2..f2c89c3 100644 --- a/src/events/messageDelete/index.ts +++ b/src/events/messageDelete/index.ts @@ -1,10 +1,13 @@ import { Message } from "discord.js"; import audits from "@events/messageDelete/audits"; import counter from "./modules/counter"; +import { IEventOptions } from "@root/interfaces/EventOptions"; -export default { - async execute(message: Message) { - await audits.execute(message); - await counter(message); - }, +export const options: IEventOptions = { + type: "on", +}; + +export const execute = async (message: Message) => { + await audits.execute(message); + await counter(message); }; diff --git a/src/events/messageUpdate/index.ts b/src/events/messageUpdate/index.ts index 9238805..d22272c 100644 --- a/src/events/messageUpdate/index.ts +++ b/src/events/messageUpdate/index.ts @@ -6,19 +6,22 @@ import logger from "@logger"; import counter from "./modules/counter"; import audits from "./audits"; +import { IEventOptions } from "@root/interfaces/EventOptions"; -export default { - async execute(oldMessage: Message, newMessage: Message) { - const { author, guild } = newMessage; - - await audits.execute(oldMessage, newMessage); - - logger?.silly( - `Message update event fired by ${author.tag} (${author.id}) in guild: ${guild?.name} (${guild?.id})` - ); - - if (author?.bot) return logger?.silly(`Message update event fired by bot`); - - await counter(newMessage); - }, +export const options: IEventOptions = { + type: "on", +}; + +export const execute = async (oldMessage: Message, newMessage: Message) => { + const { author, guild } = newMessage; + + await audits.execute(oldMessage, newMessage); + + logger?.silly( + `Message update event fired by ${author.tag} (${author.id}) in guild: ${guild?.name} (${guild?.id})` + ); + + if (author?.bot) return logger?.silly(`Message update event fired by bot`); + + await counter(newMessage); }; diff --git a/src/events/ready/index.ts b/src/events/ready/index.ts index b312f73..7f5ff67 100644 --- a/src/events/ready/index.ts +++ b/src/events/ready/index.ts @@ -6,20 +6,22 @@ import logger from "@logger"; import updatePresence from "@helpers/updatePresence"; import deployCommands from "@handlers/deployCommands"; import devMode from "@handlers/devMode"; +import { IEventOptions } from "@root/interfaces/EventOptions"; -export default { - once: true, - async execute(client: Client) { - logger.info("Ready!"); - - await updatePresence(client); - await devMode(client); - await deployCommands(client); - - client.guilds?.cache.forEach((guild) => { - logger.silly( - `${client.user?.tag} (${client.user?.id}) is in guild: ${guild.name} (${guild.id}) with member count of ${guild.memberCount}` - ); - }); - }, +export const options: IEventOptions = { + type: "once", +}; + +export const execute = async (client: Client) => { + logger.info("Ready!"); + + await updatePresence(client); + await devMode(client); + await deployCommands(client); + + client.guilds?.cache.forEach((guild) => { + logger.silly( + `${client.user?.tag} (${client.user?.id}) is in guild: ${guild.name} (${guild.id}) with member count of ${guild.memberCount}` + ); + }); }; diff --git a/src/handlers/events.ts b/src/handlers/events.ts deleted file mode 100644 index f7da9c1..0000000 --- a/src/handlers/events.ts +++ /dev/null @@ -1,37 +0,0 @@ -import fs from "fs"; // fs -import { Client } from "discord.js"; // discord.js -import logger from "@logger"; - -export default async (client: Client) => { - fs.readdir("./src/events", async (error, events) => { - if (error) { - return logger.error(`Error reading plugins: ${error}`); - } - - await Promise.all( - events.map(async (eventName, index) => { - const event = await import(`../events/${eventName}`); - - logger.verbose( - `Loaded event ${index + 1}/${events.length}: ${eventName}` - ); - - if (event.once) { - return client.once(eventName, async (...args) => - event.default.execute(...args) - ); - } - - return client.on(eventName, async (...args) => - event.default.execute(...args) - ); - }) - ) - .then(async () => { - logger.info(`Started all ${events.length} events.`); - }) - .catch(async (err) => { - logger.error(`${err}`); - }); - }); -}; diff --git a/src/helpers/listDir/index.ts b/src/helpers/listDir/index.ts new file mode 100644 index 0000000..247fbe0 --- /dev/null +++ b/src/helpers/listDir/index.ts @@ -0,0 +1,10 @@ +import fs from "fs"; +const fsPromises = fs.promises; + +export default async (path: string) => { + try { + return await fsPromises.readdir(path); + } catch (err) { + console.error("Error occurred while reading directory!", err); + } +}; diff --git a/src/index.ts b/src/index.ts index eaef4db..b1b7aca 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,7 +6,7 @@ import { Client } from "discord.js"; // discord.js import database from "@database"; import schedules from "@handlers/schedules"; -import events from "@handlers/events"; +import * as eventManager from "@root/managers/event"; import commands from "@handlers/commands"; // Main process that starts all other sub processes @@ -26,7 +26,7 @@ const main = async () => { await commands(client); // Start event handler - await events(client); + await eventManager.register(client); // Authorize with Discord's API await client.login(token); diff --git a/src/interfaces/EventOptions.ts b/src/interfaces/EventOptions.ts new file mode 100644 index 0000000..7634394 --- /dev/null +++ b/src/interfaces/EventOptions.ts @@ -0,0 +1,3 @@ +export interface IEventOptions { + type: "on" | "once"; +} diff --git a/src/managers/event/index.ts b/src/managers/event/index.ts new file mode 100644 index 0000000..6fa8a51 --- /dev/null +++ b/src/managers/event/index.ts @@ -0,0 +1,24 @@ +/* eslint-disable no-loops/no-loops */ +import { Client } from "discord.js"; +import listDir from "@helpers/listDir"; + +export const register = async (client: Client) => { + const eventNames = await listDir("src/events"); + if (!eventNames) return; + + for await (const eventName of eventNames) { + const event = await import(`../../events/${eventName}`); + const eventExecutor = async (...args: any[]) => event.execute(...args); + if (!event.options?.type) return; + + switch (event.options.type) { + case "once": + client.once(eventName, eventExecutor); + break; + + case "on": + client.on(eventName, eventExecutor); + break; + } + } +}; From 9bafd71cc052c08f8de920b6e7bfbd3ad905412c Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sat, 28 May 2022 13:24:25 +0200 Subject: [PATCH 131/142] =?UTF-8?q?=F0=9F=8F=B7=EF=B8=8F=20reused=20interf?= =?UTF-8?q?ace=20for=20mongoose=20schema?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/database/schemas/api.ts | 3 ++- src/handlers/encryption.ts | 12 ++++-------- src/interfaces/EncryptionData.ts | 4 ++++ tsconfig.json | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) create mode 100644 src/interfaces/EncryptionData.ts diff --git a/src/database/schemas/api.ts b/src/database/schemas/api.ts index 12519d2..ef4e817 100644 --- a/src/database/schemas/api.ts +++ b/src/database/schemas/api.ts @@ -1,10 +1,11 @@ import { Snowflake } from "discord.js"; import { model, Schema } from "mongoose"; +import { IEncryptionData } from "@interface/EncryptionData"; export interface IApi { guildId: Snowflake; url: string; - token: { iv: string; content: string }; + token: IEncryptionData; } const apiSchema = new Schema( diff --git a/src/handlers/encryption.ts b/src/handlers/encryption.ts index cab28ff..9e70939 100644 --- a/src/handlers/encryption.ts +++ b/src/handlers/encryption.ts @@ -1,16 +1,12 @@ import crypto from "crypto"; -// @ts-ignore import { secretKey, algorithm } from "@config/encryption"; +import { IEncryptionData } from "@interface/EncryptionData"; + const iv = crypto.randomBytes(16); -interface IEncrypt { - iv: string; - content: string; -} - -const encrypt = (text: crypto.BinaryLike): IEncrypt => { +const encrypt = (text: crypto.BinaryLike): IEncryptionData => { const cipher = crypto.createCipheriv(algorithm, secretKey, iv); const encrypted = Buffer.concat([cipher.update(text), cipher.final()]); @@ -20,7 +16,7 @@ const encrypt = (text: crypto.BinaryLike): IEncrypt => { }; }; -const decrypt = (hash: IEncrypt) => { +const decrypt = (hash: IEncryptionData) => { const decipher = crypto.createDecipheriv( algorithm, secretKey, diff --git a/src/interfaces/EncryptionData.ts b/src/interfaces/EncryptionData.ts new file mode 100644 index 0000000..ac41844 --- /dev/null +++ b/src/interfaces/EncryptionData.ts @@ -0,0 +1,4 @@ +export interface IEncryptionData { + iv: string; + content: string; +} diff --git a/tsconfig.json b/tsconfig.json index 8f7076a..0879e1c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,7 +16,7 @@ "baseUrl": "./src", "typeRoots": ["/types/common", "./node_modules/@types"], "paths": { - "@interface/*": ["Interfaces/*"], + "@interface/*": ["interfaces/*"], "@root/*": ["*"], "@config/*": ["config/*"], "@events/*": ["events/*"], From ee57233499c8810493e12f7c8a5748e2848a3a33 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sat, 28 May 2022 13:25:53 +0200 Subject: [PATCH 132/142] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20hel?= =?UTF-8?q?pers=20are=20now=20folders?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{capitalizeFirstLetter.ts => capitalizeFirstLetter/index.ts} | 0 src/helpers/{deferReply.ts => deferReply/index.ts} | 0 src/helpers/{dropGuild.ts => dropGuild/index.ts} | 0 src/helpers/{dropUser.ts => dropUser/index.ts} | 0 src/helpers/{embedBuilder.ts => embedBuilder/index.ts} | 0 src/helpers/{fetchGuild.ts => fetchGuild/index.ts} | 0 src/helpers/{fetchUser.ts => fetchUser/index.ts} | 0 .../{getCommandMetadata.ts => getCommandMetadata/index.ts} | 0 src/helpers/{getEmbedConfig.ts => getEmbedConfig/index.ts} | 0 src/helpers/{pluralize.ts => pluralize/index.ts} | 0 src/helpers/{saveUser.ts => saveUser/index.ts} | 0 src/helpers/{sleep.ts => sleep/index.ts} | 0 src/helpers/{updatePresence.ts => updatePresence/index.ts} | 0 13 files changed, 0 insertions(+), 0 deletions(-) rename src/helpers/{capitalizeFirstLetter.ts => capitalizeFirstLetter/index.ts} (100%) rename src/helpers/{deferReply.ts => deferReply/index.ts} (100%) rename src/helpers/{dropGuild.ts => dropGuild/index.ts} (100%) rename src/helpers/{dropUser.ts => dropUser/index.ts} (100%) rename src/helpers/{embedBuilder.ts => embedBuilder/index.ts} (100%) rename src/helpers/{fetchGuild.ts => fetchGuild/index.ts} (100%) rename src/helpers/{fetchUser.ts => fetchUser/index.ts} (100%) rename src/helpers/{getCommandMetadata.ts => getCommandMetadata/index.ts} (100%) rename src/helpers/{getEmbedConfig.ts => getEmbedConfig/index.ts} (100%) rename src/helpers/{pluralize.ts => pluralize/index.ts} (100%) rename src/helpers/{saveUser.ts => saveUser/index.ts} (100%) rename src/helpers/{sleep.ts => sleep/index.ts} (100%) rename src/helpers/{updatePresence.ts => updatePresence/index.ts} (100%) diff --git a/src/helpers/capitalizeFirstLetter.ts b/src/helpers/capitalizeFirstLetter/index.ts similarity index 100% rename from src/helpers/capitalizeFirstLetter.ts rename to src/helpers/capitalizeFirstLetter/index.ts diff --git a/src/helpers/deferReply.ts b/src/helpers/deferReply/index.ts similarity index 100% rename from src/helpers/deferReply.ts rename to src/helpers/deferReply/index.ts diff --git a/src/helpers/dropGuild.ts b/src/helpers/dropGuild/index.ts similarity index 100% rename from src/helpers/dropGuild.ts rename to src/helpers/dropGuild/index.ts diff --git a/src/helpers/dropUser.ts b/src/helpers/dropUser/index.ts similarity index 100% rename from src/helpers/dropUser.ts rename to src/helpers/dropUser/index.ts diff --git a/src/helpers/embedBuilder.ts b/src/helpers/embedBuilder/index.ts similarity index 100% rename from src/helpers/embedBuilder.ts rename to src/helpers/embedBuilder/index.ts diff --git a/src/helpers/fetchGuild.ts b/src/helpers/fetchGuild/index.ts similarity index 100% rename from src/helpers/fetchGuild.ts rename to src/helpers/fetchGuild/index.ts diff --git a/src/helpers/fetchUser.ts b/src/helpers/fetchUser/index.ts similarity index 100% rename from src/helpers/fetchUser.ts rename to src/helpers/fetchUser/index.ts diff --git a/src/helpers/getCommandMetadata.ts b/src/helpers/getCommandMetadata/index.ts similarity index 100% rename from src/helpers/getCommandMetadata.ts rename to src/helpers/getCommandMetadata/index.ts diff --git a/src/helpers/getEmbedConfig.ts b/src/helpers/getEmbedConfig/index.ts similarity index 100% rename from src/helpers/getEmbedConfig.ts rename to src/helpers/getEmbedConfig/index.ts diff --git a/src/helpers/pluralize.ts b/src/helpers/pluralize/index.ts similarity index 100% rename from src/helpers/pluralize.ts rename to src/helpers/pluralize/index.ts diff --git a/src/helpers/saveUser.ts b/src/helpers/saveUser/index.ts similarity index 100% rename from src/helpers/saveUser.ts rename to src/helpers/saveUser/index.ts diff --git a/src/helpers/sleep.ts b/src/helpers/sleep/index.ts similarity index 100% rename from src/helpers/sleep.ts rename to src/helpers/sleep/index.ts diff --git a/src/helpers/updatePresence.ts b/src/helpers/updatePresence/index.ts similarity index 100% rename from src/helpers/updatePresence.ts rename to src/helpers/updatePresence/index.ts From e3e054122e5206a04a0c9f03fdefa2b346f6da61 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sat, 28 May 2022 14:32:35 +0200 Subject: [PATCH 133/142] =?UTF-8?q?=F0=9F=8F=B7=EF=B8=8F=20replace=20IPlug?= =?UTF-8?q?inData=20with=20ICommand?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/handlers/deployCommands.ts | 11 +++-------- src/helpers/getCommandMetadata/index.ts | 14 ++++++++------ src/interfaces/Command.ts | 7 +++++++ 3 files changed, 18 insertions(+), 14 deletions(-) create mode 100644 src/interfaces/Command.ts diff --git a/src/handlers/deployCommands.ts b/src/handlers/deployCommands.ts index 4ca0923..7883abd 100644 --- a/src/handlers/deployCommands.ts +++ b/src/handlers/deployCommands.ts @@ -1,24 +1,19 @@ -// @ts-ignore import { token, clientId } from "@config/discord"; -// @ts-ignore import { devMode, guildId } from "@config/other"; import logger from "../logger"; import { Client } from "@root/types/common/discord"; import { REST } from "@discordjs/rest"; import { Routes } from "discord-api-types/v9"; -import { SlashCommandBuilder } from "@discordjs/builders"; import { RESTPostAPIApplicationCommandsJSONBody } from "discord-api-types/v10"; +import { ICommand } from "@interface/Command"; + export default async (client: Client) => { const pluginList: Array = []; - interface IPluginData { - builder: SlashCommandBuilder; - } - await Promise.all( - client.commands.map(async (pluginData: IPluginData) => { + client.commands.map(async (pluginData: ICommand) => { pluginList.push(pluginData.builder.toJSON()); logger.verbose( `Plugin is ready for deployment: ${pluginData.builder.name}` diff --git a/src/helpers/getCommandMetadata/index.ts b/src/helpers/getCommandMetadata/index.ts index 7894c00..fe7784b 100644 --- a/src/helpers/getCommandMetadata/index.ts +++ b/src/helpers/getCommandMetadata/index.ts @@ -1,12 +1,14 @@ import { CommandInteraction } from "discord.js"; +import { ICommand } from "@interface/Command"; -export default async (interaction: CommandInteraction, currentCommand: any) => { +export default async ( + interaction: CommandInteraction, + currentCommand: ICommand +) => { const subcommand = interaction.options.getSubcommand(); const subcommandGroup = interaction.options.getSubcommandGroup(false); - if (!subcommandGroup) { - return currentCommand.modules[subcommand].metadata; - } - - return currentCommand.modules[subcommandGroup].modules[subcommand].metadata; + return subcommandGroup + ? currentCommand.modules[subcommandGroup].modules[subcommand].metadata + : currentCommand.modules[subcommand].metadata; }; diff --git a/src/interfaces/Command.ts b/src/interfaces/Command.ts new file mode 100644 index 0000000..34585d9 --- /dev/null +++ b/src/interfaces/Command.ts @@ -0,0 +1,7 @@ +import { SlashCommandBuilder } from "@discordjs/builders"; + +export interface ICommand { + modules: any; + builder: SlashCommandBuilder; + execute: Promise; +} From efd7f245982a2e7a6a767d86c76e18f7234a115a Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sat, 28 May 2022 14:43:28 +0200 Subject: [PATCH 134/142] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20sep?= =?UTF-8?q?erated=20/config=20embeds?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/config/modules/embeds.ts | 129 ------------------ .../embeds/components/getValues/index.ts | 38 ++++++ src/plugins/config/modules/embeds/index.ts | 104 ++++++++++++++ 3 files changed, 142 insertions(+), 129 deletions(-) delete mode 100644 src/plugins/config/modules/embeds.ts create mode 100644 src/plugins/config/modules/embeds/components/getValues/index.ts create mode 100644 src/plugins/config/modules/embeds/index.ts diff --git a/src/plugins/config/modules/embeds.ts b/src/plugins/config/modules/embeds.ts deleted file mode 100644 index f4f3a15..0000000 --- a/src/plugins/config/modules/embeds.ts +++ /dev/null @@ -1,129 +0,0 @@ -// Dependencies -import { ColorResolvable, CommandInteraction, Permissions } from "discord.js"; - -//Handlers -import logger from "@logger"; - -// Models -import guildSchema from "@schemas/guild"; -import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; -import getEmbedConfig from "@helpers/getEmbedConfig"; - -// Function -export default { - metadata: { - guildOnly: true, - ephemeral: true, - permissions: [Permissions.FLAGS.MANAGE_GUILD], - }, - - builder: (command: SlashCommandSubcommandBuilder) => { - return command - .setName("embeds") - .setDescription(`Embeds`) - .addStringOption((option) => - option - .setName("success-color") - .setDescription("No provided description") - ) - .addStringOption((option) => - option.setName("wait-color").setDescription("No provided description") - ) - .addStringOption((option) => - option.setName("error-color").setDescription("No provided description") - ) - .addStringOption((option) => - option.setName("footer-icon").setDescription("No provided description") - ) - .addStringOption((option) => - option.setName("footer-text").setDescription("No provided description") - ); - }, - execute: async (interaction: CommandInteraction) => { - // Destructure member - const { guild, options } = interaction; - - if (guild == null) return; - - const embedConfig = await getEmbedConfig(guild); - - if (embedConfig == null) return; - - logger.info(embedConfig); - - // Get options - const successColor = options?.getString("success-color") as ColorResolvable; - const waitColor = options?.getString("wait-color") as ColorResolvable; - const errorColor = options?.getString("error-color") as ColorResolvable; - const footerIcon = options?.getString("footer-icon"); - const footerText = options?.getString("footer-text"); - - // Get guild object - const guildDB = await guildSchema?.findOne({ - guildId: guild?.id, - }); - - if (guildDB === null) { - return logger?.silly(`Guild is null`); - } - - // Modify values - guildDB.embeds.successColor = - successColor !== null ? successColor : guildDB?.embeds?.successColor; - guildDB.embeds.waitColor = - waitColor !== null ? waitColor : guildDB?.embeds?.waitColor; - guildDB.embeds.errorColor = - errorColor !== null ? errorColor : guildDB?.embeds?.errorColor; - guildDB.embeds.footerIcon = - footerIcon !== null ? footerIcon : guildDB?.embeds?.footerIcon; - guildDB.embeds.footerText = - footerText !== null ? footerText : guildDB?.embeds?.footerText; - - // Save guild - await guildDB?.save()?.then(async () => { - logger?.silly(`Guild saved`); - - return interaction?.editReply({ - embeds: [ - { - title: ":tools: Settings - Guild [Credits]", - description: `Credits settings updated.`, - color: successColor || embedConfig.successColor, - fields: [ - { - name: "🤖 Success Color", - value: `${guildDB?.embeds?.successColor}`, - inline: true, - }, - { - name: "📈 Wait Color", - value: `${guildDB?.embeds?.waitColor}`, - inline: true, - }, - { - name: "📈 Error Color", - value: `${guildDB?.embeds?.errorColor}`, - inline: true, - }, - { - name: "🔨 Footer Icon", - value: `${guildDB?.embeds?.footerIcon}`, - inline: true, - }, - { - name: "⏰ Footer Text", - value: `${guildDB?.embeds?.footerText}`, - inline: true, - }, - ], - timestamp: new Date(), - footer: { - iconURL: footerIcon || embedConfig.footerIcon, - text: footerText || embedConfig.footerText, - }, - }, - ], - }); - }); - }, -}; diff --git a/src/plugins/config/modules/embeds/components/getValues/index.ts b/src/plugins/config/modules/embeds/components/getValues/index.ts new file mode 100644 index 0000000..f068ac4 --- /dev/null +++ b/src/plugins/config/modules/embeds/components/getValues/index.ts @@ -0,0 +1,38 @@ +import { ColorResolvable, CommandInteraction } from "discord.js"; +import guildSchema from "@schemas/guild"; +import getEmbedConfig from "@root/helpers/getEmbedConfig"; + +export default async (interaction: CommandInteraction) => { + const { options, guild } = interaction; + + if (!guild) throw new Error("Guild not found"); + + const embedConfig = await getEmbedConfig(guild); + if (!embedConfig) throw new Error("Embed config not found"); + + // Get new values + const newSuccessColor = options.getString("success-color") as ColorResolvable; + const newWaitColor = options.getString("wait-color") as ColorResolvable; + const newErrorColor = options.getString("error-color") as ColorResolvable; + const newFooterIcon = options.getString("footer-icon"); + const newFooterText = options.getString("footer-text"); + + // Get guild values + const guildData = await guildSchema.findOne({ + guildId: guild.id, + }); + if (!guildData) throw new Error("Guild data not found"); + if (!guildData?.embeds) + throw new Error("Guild embed configuration not found"); + let { successColor, waitColor, errorColor, footerText, footerIcon } = + guildData.embeds; + + // Set new values + successColor = newSuccessColor || successColor; + waitColor = newWaitColor || waitColor; + errorColor = newErrorColor || errorColor; + footerIcon = newFooterIcon || footerIcon; + footerText = newFooterText || footerText; + + return { successColor, waitColor, errorColor, footerText, footerIcon }; +}; diff --git a/src/plugins/config/modules/embeds/index.ts b/src/plugins/config/modules/embeds/index.ts new file mode 100644 index 0000000..32ad931 --- /dev/null +++ b/src/plugins/config/modules/embeds/index.ts @@ -0,0 +1,104 @@ +// Dependencies +import { + ColorResolvable, + CommandInteraction, + MessageEmbed, + Permissions, +} from "discord.js"; + +//Handlers +import logger from "@logger"; + +// Models +import guildSchema from "@schemas/guild"; +import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import getEmbedConfig from "@helpers/getEmbedConfig"; +import getValues from "./components/getValues"; + +// Function +export default { + metadata: { + guildOnly: true, + ephemeral: true, + permissions: [Permissions.FLAGS.MANAGE_GUILD], + }, + + builder: (command: SlashCommandSubcommandBuilder) => { + return command + .setName("embeds") + .setDescription(`Embeds`) + .addStringOption((option) => + option + .setName("success-color") + .setDescription("No provided description") + ) + .addStringOption((option) => + option.setName("wait-color").setDescription("No provided description") + ) + .addStringOption((option) => + option.setName("error-color").setDescription("No provided description") + ) + .addStringOption((option) => + option.setName("footer-icon").setDescription("No provided description") + ) + .addStringOption((option) => + option.setName("footer-text").setDescription("No provided description") + ); + }, + execute: async (interaction: CommandInteraction) => { + const { guild } = interaction; + if (!guild) throw new Error("Guild not found"); + + const { successColor, waitColor, errorColor, footerText, footerIcon } = + await getValues(interaction); + + // Initialize embed object + const embed = new MessageEmbed() + .setTitle("[:tools:] Embeds") + .setFooter({ text: footerText, iconURL: footerIcon }) + .setTimestamp(new Date()); + + // Get guild values + const guildData = await guildSchema.findOne({ + guildId: guild.id, + }); + if (!guildData) throw new Error("Guild data not found"); + + await guildData.save().then(async () => { + embed + .setDescription("Following embed configuration will be used.") + .setColor(successColor) + .addFields([ + { + name: "🟢 Success Color", + value: `${successColor}`, + inline: true, + }, + { + name: "🟡 Wait Color", + value: `${waitColor}`, + inline: true, + }, + { + name: "🔴 Error Color", + value: `${errorColor}`, + inline: true, + }, + { + name: "🖼️ Footer Icon", + value: `${footerIcon}`, + inline: true, + }, + { + name: "📄 Footer Text", + value: `${footerText}`, + inline: true, + }, + ]); + + return interaction.editReply({ + embeds: [embed], + }); + }); + }, +}; From 598bff90c87426985970aba2e427683fa29a1b4d Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sat, 28 May 2022 17:35:00 +0200 Subject: [PATCH 135/142] =?UTF-8?q?=F0=9F=9A=9A=20config=20modules=20are?= =?UTF-8?q?=20now=20folders?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/{audits.ts => audits/index.ts} | 0 .../modules/{credits.ts => credits/index.ts} | 0 .../modules/{points.ts => points/index.ts} | 0 .../{pterodactyl.ts => pterodactyl/index.ts} | 0 .../config/modules/{shop.ts => shop/index.ts} | 0 .../modules/{welcome.ts => welcome/index.ts} | 58 +++++++++---------- 6 files changed, 29 insertions(+), 29 deletions(-) rename src/plugins/config/modules/{audits.ts => audits/index.ts} (100%) rename src/plugins/config/modules/{credits.ts => credits/index.ts} (100%) rename src/plugins/config/modules/{points.ts => points/index.ts} (100%) rename src/plugins/config/modules/{pterodactyl.ts => pterodactyl/index.ts} (100%) rename src/plugins/config/modules/{shop.ts => shop/index.ts} (100%) rename src/plugins/config/modules/{welcome.ts => welcome/index.ts} (77%) diff --git a/src/plugins/config/modules/audits.ts b/src/plugins/config/modules/audits/index.ts similarity index 100% rename from src/plugins/config/modules/audits.ts rename to src/plugins/config/modules/audits/index.ts diff --git a/src/plugins/config/modules/credits.ts b/src/plugins/config/modules/credits/index.ts similarity index 100% rename from src/plugins/config/modules/credits.ts rename to src/plugins/config/modules/credits/index.ts diff --git a/src/plugins/config/modules/points.ts b/src/plugins/config/modules/points/index.ts similarity index 100% rename from src/plugins/config/modules/points.ts rename to src/plugins/config/modules/points/index.ts diff --git a/src/plugins/config/modules/pterodactyl.ts b/src/plugins/config/modules/pterodactyl/index.ts similarity index 100% rename from src/plugins/config/modules/pterodactyl.ts rename to src/plugins/config/modules/pterodactyl/index.ts diff --git a/src/plugins/config/modules/shop.ts b/src/plugins/config/modules/shop/index.ts similarity index 100% rename from src/plugins/config/modules/shop.ts rename to src/plugins/config/modules/shop/index.ts diff --git a/src/plugins/config/modules/welcome.ts b/src/plugins/config/modules/welcome/index.ts similarity index 77% rename from src/plugins/config/modules/welcome.ts rename to src/plugins/config/modules/welcome/index.ts index 48399c7..bdd962b 100644 --- a/src/plugins/config/modules/welcome.ts +++ b/src/plugins/config/modules/welcome/index.ts @@ -96,39 +96,39 @@ export default { await guildDB?.save()?.then(async () => { logger?.silly(`Guild welcome updated.`); + if (!guildDB?.welcome?.status) { + return interaction?.editReply({ + embeds: [ + { + title: "[:tools:] Welcome", + description: `This module is currently disabled, please enable it to continue.`, + color: successColor, + timestamp: new Date(), + footer: { + iconURL: footerIcon, + text: footerText, + }, + }, + ], + }); + } + return interaction?.editReply({ embeds: [ { - title: ":hammer: Settings - Guild [Welcome]", - description: `Welcome settings updated.`, + title: "[:tools:] Welcome", + description: `The following configuration will be used. + + [👋] **Welcome** + + ㅤ**Channel**: <#${guildDB?.welcome?.joinChannel}> + ㅤ**Message**: ${guildDB?.welcome?.joinChannelMessage} + + [🚪] **Leave** + + ㅤ**Channel**: <#${guildDB?.welcome?.leaveChannel}> + ㅤ**Message**: ${guildDB?.welcome?.leaveChannelMessage}`, color: successColor, - fields: [ - { - name: "🤖 Status", - value: `${guildDB?.welcome?.status}`, - inline: true, - }, - { - name: "🌊 Join Channel", - value: `${guildDB?.welcome?.joinChannel}`, - inline: true, - }, - { - name: "🌊 Leave Channel", - value: `${guildDB?.welcome?.leaveChannel}`, - inline: true, - }, - { - name: "📄 Join Channel Message", - value: `${guildDB?.welcome?.joinChannelMessage}`, - inline: true, - }, - { - name: "📄 Leave Channel Message", - value: `${guildDB?.welcome?.leaveChannelMessage}`, - inline: true, - }, - ], timestamp: new Date(), footer: { iconURL: footerIcon, From 2d3d7fe7aa69b1ab1b8c446e52032f4dfc48f718 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sun, 29 May 2022 19:06:31 +0200 Subject: [PATCH 136/142] =?UTF-8?q?=F0=9F=9A=A8=20reverted=20from=20absolu?= =?UTF-8?q?te=20to=20relative=20paths?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 +++ src/database/index.ts | 4 ++-- src/database/schemas/api.ts | 2 +- src/events/guildCreate/index.ts | 8 ++++---- src/events/guildDelete/index.ts | 8 ++++---- src/events/guildMemberAdd/audits.ts | 6 +++--- src/events/guildMemberAdd/index.ts | 8 ++++---- src/events/guildMemberAdd/joinMessage.ts | 4 ++-- src/events/guildMemberRemove/audits.ts | 6 +++--- src/events/guildMemberRemove/index.ts | 8 ++++---- src/events/guildMemberRemove/leaveMessage.ts | 4 ++-- src/events/interactionCreate/audits.ts | 6 +++--- .../interactionCreate/components/isCommand.ts | 10 +++++----- src/events/interactionCreate/index.ts | 6 +++--- src/events/messageCreate/index.ts | 4 ++-- src/events/messageCreate/modules/counters/index.ts | 4 ++-- src/events/messageCreate/modules/credits/index.ts | 8 ++++---- src/events/messageCreate/modules/index.ts | 6 +++--- src/events/messageCreate/modules/points/index.ts | 8 ++++---- src/events/messageDelete/audits.ts | 6 +++--- src/events/messageDelete/index.ts | 4 ++-- src/events/messageDelete/modules/counter.ts | 4 ++-- src/events/messageUpdate/audits.ts | 6 +++--- src/events/messageUpdate/index.ts | 4 ++-- src/events/messageUpdate/modules/counter.ts | 4 ++-- src/events/ready/index.ts | 10 +++++----- src/handlers/commands.ts | 14 +++++--------- src/handlers/deployCommands.ts | 8 ++++---- src/handlers/devMode.ts | 4 ++-- src/handlers/encryption.ts | 4 ++-- src/handlers/schedules/index.ts | 4 ++-- src/helpers/deferReply/index.ts | 2 +- src/helpers/dropGuild/index.ts | 14 +++++++------- src/helpers/dropUser/index.ts | 4 ++-- src/helpers/embedBuilder/index.ts | 2 +- src/helpers/fetchGuild/index.ts | 4 ++-- src/helpers/fetchUser/index.ts | 4 ++-- src/helpers/getCommandMetadata/index.ts | 2 +- src/helpers/getEmbedConfig/index.ts | 4 ++-- src/helpers/pluralize/index.ts | 2 +- src/helpers/saveUser/index.ts | 4 ++-- src/helpers/sleep/index.ts | 2 +- src/helpers/updatePresence/index.ts | 2 +- src/index.ts | 10 +++++----- src/jobs/shopRoles.ts | 8 ++++---- src/managers/event/index.ts | 2 +- src/plugins/config/index.ts | 2 +- src/plugins/config/modules/audits/index.ts | 6 +++--- src/plugins/config/modules/credits/index.ts | 6 +++--- .../modules/embeds/components/getValues/index.ts | 4 ++-- src/plugins/config/modules/embeds/index.ts | 6 +++--- src/plugins/config/modules/index.ts | 14 +++++++------- src/plugins/config/modules/points/index.ts | 6 +++--- src/plugins/config/modules/pterodactyl/index.ts | 8 ++++---- src/plugins/config/modules/shop/index.ts | 6 +++--- src/plugins/config/modules/welcome/index.ts | 6 +++--- src/plugins/counters/index.ts | 4 ++-- src/plugins/counters/modules/index.ts | 2 +- src/plugins/counters/modules/view/index.ts | 4 ++-- src/plugins/credits/index.ts | 4 ++-- src/plugins/credits/modules/balance/index.ts | 6 +++--- src/plugins/credits/modules/gift/index.ts | 8 ++++---- src/plugins/credits/modules/index.ts | 8 ++++---- src/plugins/credits/modules/top/index.ts | 6 +++--- src/plugins/credits/modules/work/index.ts | 10 +++++----- src/plugins/fun/index.ts | 4 ++-- src/plugins/fun/modules/index.ts | 2 +- src/plugins/fun/modules/meme/index.ts | 4 ++-- src/plugins/manage/index.ts | 4 ++-- src/plugins/manage/modules/counters/index.ts | 2 +- .../manage/modules/counters/modules/add/index.ts | 6 +++--- .../manage/modules/counters/modules/index.ts | 4 ++-- .../modules/counters/modules/remove/index.ts | 6 +++--- src/plugins/manage/modules/credits/index.ts | 2 +- .../manage/modules/credits/modules/give/index.ts | 8 ++++---- .../manage/modules/credits/modules/index.ts | 8 ++++---- .../manage/modules/credits/modules/set/index.ts | 6 +++--- .../manage/modules/credits/modules/take/index.ts | 8 ++++---- .../modules/credits/modules/transfer/index.ts | 8 ++++---- src/plugins/manage/modules/index.ts | 4 ++-- src/plugins/profile/index.ts | 4 ++-- src/plugins/profile/modules/index.ts | 2 +- src/plugins/profile/modules/view.ts | 6 +++--- src/plugins/reputation/index.ts | 2 +- src/plugins/reputation/modules/give.ts | 10 +++++----- src/plugins/reputation/modules/index.ts | 2 +- src/plugins/shop/modules/index.ts | 4 ++-- src/plugins/shop/modules/pterodactyl.ts | 12 ++++++------ src/plugins/shop/modules/roles/index.ts | 6 +++--- src/plugins/shop/modules/roles/modules/buy.ts | 12 ++++++------ src/plugins/shop/modules/roles/modules/cancel.ts | 10 +++++----- src/plugins/utility/index.ts | 2 +- src/plugins/utility/modules/about.ts | 4 ++-- src/plugins/utility/modules/avatar.ts | 2 +- src/plugins/utility/modules/index.ts | 8 ++++---- src/plugins/utility/modules/lookup.ts | 4 ++-- src/plugins/utility/modules/stats.ts | 2 +- src/types/common/discord.d.ts | 5 +++-- 98 files changed, 270 insertions(+), 270 deletions(-) diff --git a/.gitignore b/.gitignore index 0ae1541..9f176fb 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,9 @@ package-lock.json !**/config/index.ts !**/config/example.*.ts +# Build +build/ + # Logs logs diff --git a/src/database/index.ts b/src/database/index.ts index b7dd3b6..9060935 100644 --- a/src/database/index.ts +++ b/src/database/index.ts @@ -2,10 +2,10 @@ import mongoose from "mongoose"; // Dependencies -import logger from "@logger"; +import logger from "../logger"; // Configuration -import { url } from "@config/database"; +import { url } from "../config/database"; export default async () => { await mongoose.connect(url).then(async (connection) => { diff --git a/src/database/schemas/api.ts b/src/database/schemas/api.ts index ef4e817..5a78afd 100644 --- a/src/database/schemas/api.ts +++ b/src/database/schemas/api.ts @@ -1,6 +1,6 @@ import { Snowflake } from "discord.js"; import { model, Schema } from "mongoose"; -import { IEncryptionData } from "@interface/EncryptionData"; +import { IEncryptionData } from "../../interfaces/EncryptionData"; export interface IApi { guildId: Snowflake; diff --git a/src/events/guildCreate/index.ts b/src/events/guildCreate/index.ts index d76b9a2..a309884 100644 --- a/src/events/guildCreate/index.ts +++ b/src/events/guildCreate/index.ts @@ -1,8 +1,8 @@ import { Guild } from "discord.js"; -import updatePresence from "@helpers/updatePresence"; -import fetchGuild from "@helpers/fetchGuild"; -import logger from "@logger"; -import { IEventOptions } from "@root/interfaces/EventOptions"; +import updatePresence from "../../helpers/updatePresence"; +import fetchGuild from "../../helpers/fetchGuild"; +import logger from "../../logger"; +import { IEventOptions } from "../../interfaces/EventOptions"; export const options: IEventOptions = { type: "on", diff --git a/src/events/guildDelete/index.ts b/src/events/guildDelete/index.ts index 741b69c..be090b8 100644 --- a/src/events/guildDelete/index.ts +++ b/src/events/guildDelete/index.ts @@ -2,10 +2,10 @@ import { Guild } from "discord.js"; // Dependencies -import updatePresence from "@helpers/updatePresence"; -import dropGuild from "@helpers/dropGuild"; -import logger from "@logger"; -import { IEventOptions } from "@root/interfaces/EventOptions"; +import updatePresence from "../../helpers/updatePresence"; +import dropGuild from "../../helpers/dropGuild"; +import logger from "../../logger"; +import { IEventOptions } from "../../interfaces/EventOptions"; export const options: IEventOptions = { type: "on", diff --git a/src/events/guildMemberAdd/audits.ts b/src/events/guildMemberAdd/audits.ts index c47c78e..6e140c6 100644 --- a/src/events/guildMemberAdd/audits.ts +++ b/src/events/guildMemberAdd/audits.ts @@ -1,9 +1,9 @@ -import logger from "@logger"; +import logger from "../../logger"; import { GuildMember, MessageEmbed, TextChannel } from "discord.js"; -import guildSchema from "@schemas/guild"; +import guildSchema from "../../database/schemas/guild"; -import getEmbedConfig from "@helpers/getEmbedConfig"; +import getEmbedConfig from "../../helpers/getEmbedConfig"; export default { execute: async (member: GuildMember) => { diff --git a/src/events/guildMemberAdd/index.ts b/src/events/guildMemberAdd/index.ts index 2cda131..0dff9bf 100644 --- a/src/events/guildMemberAdd/index.ts +++ b/src/events/guildMemberAdd/index.ts @@ -2,12 +2,12 @@ import { GuildMember } from "discord.js"; // Dependencies -import updatePresence from "@helpers/updatePresence"; -import fetchUser from "@helpers/fetchUser"; -import logger from "@logger"; +import updatePresence from "../../helpers/updatePresence"; +import fetchUser from "../../helpers/fetchUser"; +import logger from "../../logger"; import joinMessage from "../guildMemberAdd/joinMessage"; import audits from "../guildMemberAdd/audits"; -import { IEventOptions } from "@root/interfaces/EventOptions"; +import { IEventOptions } from "../../interfaces/EventOptions"; export const options: IEventOptions = { type: "on", diff --git a/src/events/guildMemberAdd/joinMessage.ts b/src/events/guildMemberAdd/joinMessage.ts index bf7aec3..db0a745 100644 --- a/src/events/guildMemberAdd/joinMessage.ts +++ b/src/events/guildMemberAdd/joinMessage.ts @@ -1,8 +1,8 @@ import { GuildMember, MessageEmbed, TextChannel } from "discord.js"; -import guildSchema from "@schemas/guild"; +import guildSchema from "../../database/schemas/guild"; -import getEmbedConfig from "@helpers/getEmbedConfig"; +import getEmbedConfig from "../../helpers/getEmbedConfig"; export default { execute: async (member: GuildMember) => { diff --git a/src/events/guildMemberRemove/audits.ts b/src/events/guildMemberRemove/audits.ts index 620e52e..9f2c343 100644 --- a/src/events/guildMemberRemove/audits.ts +++ b/src/events/guildMemberRemove/audits.ts @@ -1,9 +1,9 @@ -import logger from "@logger"; +import logger from "../../logger"; import { GuildMember, MessageEmbed, TextChannel } from "discord.js"; -import guildSchema from "@schemas/guild"; +import guildSchema from "../../database/schemas/guild"; -import getEmbedConfig from "@helpers/getEmbedConfig"; +import getEmbedConfig from "../../helpers/getEmbedConfig"; export default { execute: async (member: GuildMember) => { diff --git a/src/events/guildMemberRemove/index.ts b/src/events/guildMemberRemove/index.ts index 2cb2d48..502aad4 100644 --- a/src/events/guildMemberRemove/index.ts +++ b/src/events/guildMemberRemove/index.ts @@ -2,12 +2,12 @@ import { GuildMember } from "discord.js"; // Dependencies -import updatePresence from "@helpers/updatePresence"; -import dropUser from "@helpers/dropUser"; -import logger from "@logger"; +import updatePresence from "../../helpers/updatePresence"; +import dropUser from "../../helpers/dropUser"; +import logger from "../../logger"; import leaveMessage from "./leaveMessage"; import audits from "./audits"; -import { IEventOptions } from "@root/interfaces/EventOptions"; +import { IEventOptions } from "../../interfaces/EventOptions"; export const options: IEventOptions = { type: "on", diff --git a/src/events/guildMemberRemove/leaveMessage.ts b/src/events/guildMemberRemove/leaveMessage.ts index efed730..427866b 100644 --- a/src/events/guildMemberRemove/leaveMessage.ts +++ b/src/events/guildMemberRemove/leaveMessage.ts @@ -1,8 +1,8 @@ import { GuildMember, MessageEmbed, TextChannel } from "discord.js"; -import guildSchema from "@schemas/guild"; +import guildSchema from "../../database/schemas/guild"; -import getEmbedConfig from "@helpers/getEmbedConfig"; +import getEmbedConfig from "../../helpers/getEmbedConfig"; export default { execute: async (member: GuildMember) => { diff --git a/src/events/interactionCreate/audits.ts b/src/events/interactionCreate/audits.ts index c6df788..3a311c5 100644 --- a/src/events/interactionCreate/audits.ts +++ b/src/events/interactionCreate/audits.ts @@ -1,9 +1,9 @@ -import logger from "@logger"; +import logger from "../../logger"; import { Interaction, MessageEmbed, TextChannel } from "discord.js"; -import guildSchema from "@schemas/guild"; +import guildSchema from "../../database/schemas/guild"; -import getEmbedConfig from "@helpers/getEmbedConfig"; +import getEmbedConfig from "../../helpers/getEmbedConfig"; export default { execute: async (interaction: Interaction) => { diff --git a/src/events/interactionCreate/components/isCommand.ts b/src/events/interactionCreate/components/isCommand.ts index 91c61dd..3addf8b 100644 --- a/src/events/interactionCreate/components/isCommand.ts +++ b/src/events/interactionCreate/components/isCommand.ts @@ -1,12 +1,12 @@ // Dependencies import { CommandInteraction, MessageEmbed } from "discord.js"; -import logger from "@logger"; +import logger from "../../../logger"; -import deferReply from "@root/helpers/deferReply"; -import getEmbedConfig from "@helpers/getEmbedConfig"; -import getCommandMetadata from "@helpers/getCommandMetadata"; -import capitalizeFirstLetter from "@helpers/capitalizeFirstLetter"; +import deferReply from "../../../helpers/deferReply"; +import getEmbedConfig from "../../../helpers/getEmbedConfig"; +import getCommandMetadata from "../../../helpers/getCommandMetadata"; +import capitalizeFirstLetter from "../../../helpers/capitalizeFirstLetter"; export default async (interaction: CommandInteraction) => { if (!interaction.isCommand()) return; diff --git a/src/events/interactionCreate/index.ts b/src/events/interactionCreate/index.ts index e29deec..7e173dc 100644 --- a/src/events/interactionCreate/index.ts +++ b/src/events/interactionCreate/index.ts @@ -2,10 +2,10 @@ import { CommandInteraction } from "discord.js"; // Dependencies -import isCommand from "@root/events/interactionCreate/components/isCommand"; -import logger from "@logger"; +import isCommand from "../../events/interactionCreate/components/isCommand"; +import logger from "../../logger"; import audits from "./audits"; -import { IEventOptions } from "@root/interfaces/EventOptions"; +import { IEventOptions } from "../../interfaces/EventOptions"; export const options: IEventOptions = { type: "on", diff --git a/src/events/messageCreate/index.ts b/src/events/messageCreate/index.ts index 6eb9744..f5beddf 100644 --- a/src/events/messageCreate/index.ts +++ b/src/events/messageCreate/index.ts @@ -1,7 +1,7 @@ import { Message } from "discord.js"; -import modules from "@events/messageCreate/modules"; +import modules from "../../events/messageCreate/modules"; -import { IEventOptions } from "@root/interfaces/EventOptions"; +import { IEventOptions } from "../../interfaces/EventOptions"; export const options: IEventOptions = { type: "on", diff --git a/src/events/messageCreate/modules/counters/index.ts b/src/events/messageCreate/modules/counters/index.ts index a65a4db..882fbc6 100644 --- a/src/events/messageCreate/modules/counters/index.ts +++ b/src/events/messageCreate/modules/counters/index.ts @@ -1,7 +1,7 @@ import { Message } from "discord.js"; -import logger from "@logger"; -import counterSchema from "@schemas/counter"; +import logger from "../../../../logger"; +import counterSchema from "../../../../database/schemas/counter"; export default { execute: async (message: Message) => { diff --git a/src/events/messageCreate/modules/credits/index.ts b/src/events/messageCreate/modules/credits/index.ts index 856c308..1058490 100644 --- a/src/events/messageCreate/modules/credits/index.ts +++ b/src/events/messageCreate/modules/credits/index.ts @@ -1,9 +1,9 @@ -import logger from "@logger"; -import timeouts from "@schemas/timeout"; +import logger from "../../../../logger"; +import timeouts from "../../../../database/schemas/timeout"; import { Message } from "discord.js"; -import fetchUser from "@helpers/fetchUser"; -import fetchGuild from "@helpers/fetchGuild"; +import fetchUser from "../../../../helpers/fetchUser"; +import fetchGuild from "../../../../helpers/fetchGuild"; export default { execute: async (message: Message) => { diff --git a/src/events/messageCreate/modules/index.ts b/src/events/messageCreate/modules/index.ts index e2d04fb..aff2dd3 100644 --- a/src/events/messageCreate/modules/index.ts +++ b/src/events/messageCreate/modules/index.ts @@ -1,6 +1,6 @@ -import counters from "@events/messageCreate/modules/counters"; -import credits from "@events/messageCreate/modules/credits"; -import points from "@events/messageCreate/modules/points"; +import counters from "./counters"; +import credits from "./credits"; +import points from "./points"; export default { counters, diff --git a/src/events/messageCreate/modules/points/index.ts b/src/events/messageCreate/modules/points/index.ts index e4d3aa4..12b683a 100644 --- a/src/events/messageCreate/modules/points/index.ts +++ b/src/events/messageCreate/modules/points/index.ts @@ -1,8 +1,8 @@ -import logger from "@logger"; -import timeouts from "@schemas/timeout"; +import logger from "../../../../logger"; +import timeouts from "../../../../database/schemas/timeout"; -import fetchUser from "@helpers/fetchUser"; -import fetchGuild from "@helpers/fetchGuild"; +import fetchUser from "../../../../helpers/fetchUser"; +import fetchGuild from "../../../../helpers/fetchGuild"; import { Message } from "discord.js"; export default { diff --git a/src/events/messageDelete/audits.ts b/src/events/messageDelete/audits.ts index 1f37b59..eb28000 100644 --- a/src/events/messageDelete/audits.ts +++ b/src/events/messageDelete/audits.ts @@ -1,9 +1,9 @@ -import logger from "@logger"; +import logger from "../../logger"; import { Message, MessageEmbed, TextChannel } from "discord.js"; -import guildSchema from "@schemas/guild"; +import guildSchema from "../../database/schemas/guild"; -import getEmbedConfig from "@helpers/getEmbedConfig"; +import getEmbedConfig from "../../helpers/getEmbedConfig"; export default { execute: async (message: Message) => { diff --git a/src/events/messageDelete/index.ts b/src/events/messageDelete/index.ts index f2c89c3..7279add 100644 --- a/src/events/messageDelete/index.ts +++ b/src/events/messageDelete/index.ts @@ -1,7 +1,7 @@ import { Message } from "discord.js"; -import audits from "@events/messageDelete/audits"; +import audits from "../../events/messageDelete/audits"; import counter from "./modules/counter"; -import { IEventOptions } from "@root/interfaces/EventOptions"; +import { IEventOptions } from "../../interfaces/EventOptions"; export const options: IEventOptions = { type: "on", diff --git a/src/events/messageDelete/modules/counter.ts b/src/events/messageDelete/modules/counter.ts index 6169b45..e488ae4 100644 --- a/src/events/messageDelete/modules/counter.ts +++ b/src/events/messageDelete/modules/counter.ts @@ -2,8 +2,8 @@ import { Message } from "discord.js"; // Models -import counterSchema from "@schemas/counter"; -import logger from "@logger"; +import counterSchema from "../../../database/schemas/counter"; +import logger from "../../../logger"; export default async (message: Message) => { const { guild, channel, author, content } = message; diff --git a/src/events/messageUpdate/audits.ts b/src/events/messageUpdate/audits.ts index c9bed8a..3438666 100644 --- a/src/events/messageUpdate/audits.ts +++ b/src/events/messageUpdate/audits.ts @@ -1,10 +1,10 @@ /* eslint-disable no-loops/no-loops */ -import logger from "@logger"; +import logger from "../../logger"; import { Message, MessageEmbed, TextChannel } from "discord.js"; -import guildSchema from "@schemas/guild"; +import guildSchema from "../../database/schemas/guild"; -import getEmbedConfig from "@helpers/getEmbedConfig"; +import getEmbedConfig from "../../helpers/getEmbedConfig"; export default { execute: async (oldMessage: Message, newMessage: Message) => { diff --git a/src/events/messageUpdate/index.ts b/src/events/messageUpdate/index.ts index d22272c..263d53e 100644 --- a/src/events/messageUpdate/index.ts +++ b/src/events/messageUpdate/index.ts @@ -1,12 +1,12 @@ // Dependencies import { Message } from "discord.js"; -import logger from "@logger"; +import logger from "../../logger"; // Modules import counter from "./modules/counter"; import audits from "./audits"; -import { IEventOptions } from "@root/interfaces/EventOptions"; +import { IEventOptions } from "../../interfaces/EventOptions"; export const options: IEventOptions = { type: "on", diff --git a/src/events/messageUpdate/modules/counter.ts b/src/events/messageUpdate/modules/counter.ts index 465b00a..8ea7087 100644 --- a/src/events/messageUpdate/modules/counter.ts +++ b/src/events/messageUpdate/modules/counter.ts @@ -2,8 +2,8 @@ import { Message } from "discord.js"; // Models -import counterSchema from "@schemas/counter"; -import logger from "@logger"; +import counterSchema from "../../../database/schemas/counter"; +import logger from "../../../logger"; export default async (message: Message) => { const { guild, channel, author, content } = message; diff --git a/src/events/ready/index.ts b/src/events/ready/index.ts index 7f5ff67..61ce106 100644 --- a/src/events/ready/index.ts +++ b/src/events/ready/index.ts @@ -1,12 +1,12 @@ // Dependencies import { Client } from "discord.js"; -import logger from "@logger"; +import logger from "../../logger"; // Helpers -import updatePresence from "@helpers/updatePresence"; -import deployCommands from "@handlers/deployCommands"; -import devMode from "@handlers/devMode"; -import { IEventOptions } from "@root/interfaces/EventOptions"; +import updatePresence from "../../helpers/updatePresence"; +import deployCommands from "../../handlers/deployCommands"; +import devMode from "../../handlers/devMode"; +import { IEventOptions } from "../../interfaces/EventOptions"; export const options: IEventOptions = { type: "once", diff --git a/src/handlers/commands.ts b/src/handlers/commands.ts index 81b1eeb..8b75999 100644 --- a/src/handlers/commands.ts +++ b/src/handlers/commands.ts @@ -1,7 +1,7 @@ import fs from "fs"; // fs -import { Collection } from "discord.js"; // discord.js -import { Client } from "@root/types/common/discord"; -import logger from "@logger"; +import { Collection, Client } from "discord.js"; // discord.js +import logger from "../logger"; +import { ICommand } from "../interfaces/Command"; export default async (client: Client) => { client.commands = new Collection(); @@ -13,13 +13,9 @@ export default async (client: Client) => { await Promise.all( plugins.map(async (pluginName, index) => { - const plugin = await import(`../plugins/${pluginName}`); + const plugin: ICommand = await import(`../plugins/${pluginName}`); - await client.commands.set( - plugin.default.builder.name, - plugin.default, - plugin.default.metadata - ); + await client.commands.set(plugin.builder.name, plugin); logger.verbose( `Loaded plugin ${index + 1}/${plugins.length}: ${pluginName}` diff --git a/src/handlers/deployCommands.ts b/src/handlers/deployCommands.ts index 7883abd..e0fe066 100644 --- a/src/handlers/deployCommands.ts +++ b/src/handlers/deployCommands.ts @@ -1,13 +1,13 @@ -import { token, clientId } from "@config/discord"; -import { devMode, guildId } from "@config/other"; +import { token, clientId } from "../config/discord"; +import { devMode, guildId } from "../config/other"; import logger from "../logger"; -import { Client } from "@root/types/common/discord"; +import { Client } from "discord.js"; import { REST } from "@discordjs/rest"; import { Routes } from "discord-api-types/v9"; import { RESTPostAPIApplicationCommandsJSONBody } from "discord-api-types/v10"; -import { ICommand } from "@interface/Command"; +import { ICommand } from "../interfaces/Command"; export default async (client: Client) => { const pluginList: Array = []; diff --git a/src/handlers/devMode.ts b/src/handlers/devMode.ts index 53a2cd6..764fbcf 100644 --- a/src/handlers/devMode.ts +++ b/src/handlers/devMode.ts @@ -1,10 +1,10 @@ // Dependencies import { Client } from "discord.js"; -import logger from "@logger"; +import logger from "../logger"; // Configuration -import { devMode, guildId } from "@config/other"; +import { devMode, guildId } from "../config/other"; export default async (client: Client) => { if (!devMode) { diff --git a/src/handlers/encryption.ts b/src/handlers/encryption.ts index 9e70939..de5a7b9 100644 --- a/src/handlers/encryption.ts +++ b/src/handlers/encryption.ts @@ -1,8 +1,8 @@ import crypto from "crypto"; -import { secretKey, algorithm } from "@config/encryption"; +import { secretKey, algorithm } from "../config/encryption"; -import { IEncryptionData } from "@interface/EncryptionData"; +import { IEncryptionData } from "../interfaces/EncryptionData"; const iv = crypto.randomBytes(16); diff --git a/src/handlers/schedules/index.ts b/src/handlers/schedules/index.ts index 20ed685..c6a1cef 100644 --- a/src/handlers/schedules/index.ts +++ b/src/handlers/schedules/index.ts @@ -2,10 +2,10 @@ import { Client } from "discord.js"; import schedule from "node-schedule"; -import logger from "@logger"; +import logger from "../../logger"; // Jobs -import shopRoles from "@jobs/shopRoles"; +import shopRoles from "../../jobs/shopRoles"; export default async (client: Client) => { const expression = "*/5 * * * *"; diff --git a/src/helpers/deferReply/index.ts b/src/helpers/deferReply/index.ts index feec1a7..45d95ed 100644 --- a/src/helpers/deferReply/index.ts +++ b/src/helpers/deferReply/index.ts @@ -1,5 +1,5 @@ import { CommandInteraction, MessageEmbed } from "discord.js"; -import getEmbedConfig from "@helpers/getEmbedConfig"; +import getEmbedConfig from "../../helpers/getEmbedConfig"; export default async (interaction: CommandInteraction, ephemeral: boolean) => { if (interaction.guild == null) return; diff --git a/src/helpers/dropGuild/index.ts b/src/helpers/dropGuild/index.ts index d69d09b..e0d8356 100644 --- a/src/helpers/dropGuild/index.ts +++ b/src/helpers/dropGuild/index.ts @@ -1,11 +1,11 @@ -import guildSchema from "@schemas/guild"; -import userSchema from "@schemas/user"; -import apiSchema from "@schemas/api"; -import counterSchema from "@schemas/counter"; -import shopRoleSchema from "@schemas/shopRole"; -import timeoutSchema from "@schemas/timeout"; +import guildSchema from "../../database/schemas/guild"; +import userSchema from "../../database/schemas/user"; +import apiSchema from "../../database/schemas/api"; +import counterSchema from "../../database/schemas/counter"; +import shopRoleSchema from "../../database/schemas/shopRole"; +import timeoutSchema from "../../database/schemas/timeout"; -import logger from "@logger"; +import logger from "../../logger"; import { Guild } from "discord.js"; diff --git a/src/helpers/dropUser/index.ts b/src/helpers/dropUser/index.ts index 8306285..976cd6c 100644 --- a/src/helpers/dropUser/index.ts +++ b/src/helpers/dropUser/index.ts @@ -1,6 +1,6 @@ -import userSchema from "@schemas/user"; +import userSchema from "../../database/schemas/user"; -import logger from "@logger"; +import logger from "../../logger"; import { Guild, User } from "discord.js"; diff --git a/src/helpers/embedBuilder/index.ts b/src/helpers/embedBuilder/index.ts index 8d15d90..d93cc5c 100644 --- a/src/helpers/embedBuilder/index.ts +++ b/src/helpers/embedBuilder/index.ts @@ -1,4 +1,4 @@ -import { footerText, footerIcon } from "@config/embed"; +import { footerText, footerIcon } from "../../config/embed"; import { MessageEmbed } from "discord.js"; export default new MessageEmbed() diff --git a/src/helpers/fetchGuild/index.ts b/src/helpers/fetchGuild/index.ts index 4c8f107..bf4aff5 100644 --- a/src/helpers/fetchGuild/index.ts +++ b/src/helpers/fetchGuild/index.ts @@ -2,10 +2,10 @@ import { Guild } from "discord.js"; // Models -import guildSchema from "@schemas/guild"; +import guildSchema from "../../database/schemas/guild"; // Handlers -import logger from "@logger"; +import logger from "../../logger"; // Function export default async (guild: Guild) => { diff --git a/src/helpers/fetchUser/index.ts b/src/helpers/fetchUser/index.ts index 96386ef..19b9f1f 100644 --- a/src/helpers/fetchUser/index.ts +++ b/src/helpers/fetchUser/index.ts @@ -2,10 +2,10 @@ import { Guild, User } from "discord.js"; // Models -import userSchema from "@schemas/user"; +import userSchema from "../../database/schemas/user"; // Handlers -import logger from "@logger"; +import logger from "../../logger"; // Function export default async (user: User, guild: Guild) => { diff --git a/src/helpers/getCommandMetadata/index.ts b/src/helpers/getCommandMetadata/index.ts index fe7784b..71940d2 100644 --- a/src/helpers/getCommandMetadata/index.ts +++ b/src/helpers/getCommandMetadata/index.ts @@ -1,5 +1,5 @@ import { CommandInteraction } from "discord.js"; -import { ICommand } from "@interface/Command"; +import { ICommand } from "../../interfaces/Command"; export default async ( interaction: CommandInteraction, diff --git a/src/helpers/getEmbedConfig/index.ts b/src/helpers/getEmbedConfig/index.ts index df62073..a52cbe5 100644 --- a/src/helpers/getEmbedConfig/index.ts +++ b/src/helpers/getEmbedConfig/index.ts @@ -1,5 +1,5 @@ -import guildSchema from "@schemas/guild"; -import * as embedConfig from "@config/embed"; +import guildSchema from "../../database/schemas/guild"; +import * as embedConfig from "../../config/embed"; import { Guild } from "discord.js"; diff --git a/src/helpers/pluralize/index.ts b/src/helpers/pluralize/index.ts index 3c5d55f..d6e266d 100644 --- a/src/helpers/pluralize/index.ts +++ b/src/helpers/pluralize/index.ts @@ -1,4 +1,4 @@ -import logger from "@root/logger"; +import logger from "../../logger"; export default (count: number, noun: string, suffix?: string): string => { const result = `${count} ${noun}${count !== 1 ? suffix || "s" : ""}`; diff --git a/src/helpers/saveUser/index.ts b/src/helpers/saveUser/index.ts index 8feb92e..2608bd4 100644 --- a/src/helpers/saveUser/index.ts +++ b/src/helpers/saveUser/index.ts @@ -1,5 +1,5 @@ -import sleep from "@helpers/sleep"; -import logger from "@logger"; +import sleep from "../../helpers/sleep"; +import logger from "../../logger"; import Chance from "chance"; export default async function saveUser(data: any, data2: any) { diff --git a/src/helpers/sleep/index.ts b/src/helpers/sleep/index.ts index 792c81f..d69f15b 100644 --- a/src/helpers/sleep/index.ts +++ b/src/helpers/sleep/index.ts @@ -1,4 +1,4 @@ -import logger from "@logger"; +import logger from "../../logger"; export default function sleep(milliseconds: number) { return new Promise((resolve) => { diff --git a/src/helpers/updatePresence/index.ts b/src/helpers/updatePresence/index.ts index 7f23885..3add873 100644 --- a/src/helpers/updatePresence/index.ts +++ b/src/helpers/updatePresence/index.ts @@ -1,6 +1,6 @@ // Dependencies import { Client } from "discord.js"; -import logger from "@logger"; +import logger from "../../logger"; // Function export default async (client: Client) => { diff --git a/src/index.ts b/src/index.ts index b1b7aca..cad389c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,13 +1,13 @@ import "tsconfig-paths/register"; // Allows using tsconfig.json paths during runtime -import { token, intents } from "@config/discord"; +import { token, intents } from "./config/discord"; import { Client } from "discord.js"; // discord.js -import database from "@database"; -import schedules from "@handlers/schedules"; -import * as eventManager from "@root/managers/event"; -import commands from "@handlers/commands"; +import database from "./database"; +import schedules from "./handlers/schedules"; +import * as eventManager from "./managers/event"; +import commands from "./handlers/commands"; // Main process that starts all other sub processes const main = async () => { diff --git a/src/jobs/shopRoles.ts b/src/jobs/shopRoles.ts index b42a3f5..76ea653 100644 --- a/src/jobs/shopRoles.ts +++ b/src/jobs/shopRoles.ts @@ -1,12 +1,12 @@ // Dependencies import { Client } from "discord.js"; -import logger from "@logger"; +import logger from "../logger"; // Schemas -import userSchema from "@schemas/user"; -import shopRoleSchema from "@schemas/shopRole"; -import guildSchema from "@schemas/guild"; +import userSchema from "../database/schemas/user"; +import shopRoleSchema from "../database/schemas/shopRole"; +import guildSchema from "../database/schemas/guild"; export default async (client: Client) => { const roles = await shopRoleSchema.find(); diff --git a/src/managers/event/index.ts b/src/managers/event/index.ts index 6fa8a51..be51927 100644 --- a/src/managers/event/index.ts +++ b/src/managers/event/index.ts @@ -1,6 +1,6 @@ /* eslint-disable no-loops/no-loops */ import { Client } from "discord.js"; -import listDir from "@helpers/listDir"; +import listDir from "../../helpers/listDir"; export const register = async (client: Client) => { const eventNames = await listDir("src/events"); diff --git a/src/plugins/config/index.ts b/src/plugins/config/index.ts index 9cf1ab4..0b82732 100644 --- a/src/plugins/config/index.ts +++ b/src/plugins/config/index.ts @@ -6,7 +6,7 @@ import { CommandInteraction } from "discord.js"; import modules from "./modules"; // Handlers -import logger from "@logger"; +import logger from "../../logger"; // Function export default { diff --git a/src/plugins/config/modules/audits/index.ts b/src/plugins/config/modules/audits/index.ts index 817c990..0ea9a17 100644 --- a/src/plugins/config/modules/audits/index.ts +++ b/src/plugins/config/modules/audits/index.ts @@ -2,13 +2,13 @@ import { CommandInteraction, Permissions } from "discord.js"; // Configurations -import getEmbedConfig from "@helpers/getEmbedConfig"; +import getEmbedConfig from "../../../../helpers/getEmbedConfig"; // Handlers -import logger from "@logger"; +import logger from "../../../../logger"; // Models -import guildSchema from "@schemas/guild"; +import guildSchema from "../../../../database/schemas/guild"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChannelType } from "discord-api-types/v10"; diff --git a/src/plugins/config/modules/credits/index.ts b/src/plugins/config/modules/credits/index.ts index 3e20851..8ec5998 100644 --- a/src/plugins/config/modules/credits/index.ts +++ b/src/plugins/config/modules/credits/index.ts @@ -2,13 +2,13 @@ import { CommandInteraction, Permissions } from "discord.js"; // Configurations -import getEmbedConfig from "@helpers/getEmbedConfig"; +import getEmbedConfig from "../../../../helpers/getEmbedConfig"; //Handlers -import logger from "@logger"; +import logger from "../../../../logger"; // Models -import guildSchema from "@schemas/guild"; +import guildSchema from "../../../../database/schemas/guild"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Function diff --git a/src/plugins/config/modules/embeds/components/getValues/index.ts b/src/plugins/config/modules/embeds/components/getValues/index.ts index f068ac4..d511a52 100644 --- a/src/plugins/config/modules/embeds/components/getValues/index.ts +++ b/src/plugins/config/modules/embeds/components/getValues/index.ts @@ -1,6 +1,6 @@ import { ColorResolvable, CommandInteraction } from "discord.js"; -import guildSchema from "@schemas/guild"; -import getEmbedConfig from "@root/helpers/getEmbedConfig"; +import guildSchema from "../../../../../../database/schemas/guild"; +import getEmbedConfig from "../../../../../../helpers/getEmbedConfig"; export default async (interaction: CommandInteraction) => { const { options, guild } = interaction; diff --git a/src/plugins/config/modules/embeds/index.ts b/src/plugins/config/modules/embeds/index.ts index 32ad931..94f1db8 100644 --- a/src/plugins/config/modules/embeds/index.ts +++ b/src/plugins/config/modules/embeds/index.ts @@ -7,12 +7,12 @@ import { } from "discord.js"; //Handlers -import logger from "@logger"; +import logger from "../../../../logger"; // Models -import guildSchema from "@schemas/guild"; +import guildSchema from "../../../../database/schemas/guild"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; -import getEmbedConfig from "@helpers/getEmbedConfig"; +import getEmbedConfig from "../../../../helpers/getEmbedConfig"; import getValues from "./components/getValues"; // Function diff --git a/src/plugins/config/modules/index.ts b/src/plugins/config/modules/index.ts index e14701a..09a9f5a 100644 --- a/src/plugins/config/modules/index.ts +++ b/src/plugins/config/modules/index.ts @@ -1,9 +1,9 @@ -import audits from "@plugins/config/modules/audits"; -import credits from "@plugins/config/modules/credits"; -import points from "@plugins/config/modules/points"; -import pterodactyl from "@plugins/config/modules/pterodactyl"; -import shop from "@plugins/config/modules/shop"; -import welcome from "@plugins/config/modules/welcome"; -import embeds from "@plugins/config/modules/embeds"; +import audits from "./audits"; +import credits from "./credits"; +import points from "./points"; +import pterodactyl from "./pterodactyl"; +import shop from "./shop"; +import welcome from "./welcome"; +import embeds from "./embeds"; export default { audits, credits, points, pterodactyl, shop, welcome, embeds }; diff --git a/src/plugins/config/modules/points/index.ts b/src/plugins/config/modules/points/index.ts index a7e24a2..0693916 100644 --- a/src/plugins/config/modules/points/index.ts +++ b/src/plugins/config/modules/points/index.ts @@ -2,13 +2,13 @@ import { CommandInteraction, Permissions } from "discord.js"; // Configurations -import getEmbedConfig from "@helpers/getEmbedConfig"; +import getEmbedConfig from "../../../../helpers/getEmbedConfig"; // Handlers -import logger from "@logger"; +import logger from "../../../../logger"; // Models -import guildSchema from "@schemas/guild"; +import guildSchema from "../../../../database/schemas/guild"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Function diff --git a/src/plugins/config/modules/pterodactyl/index.ts b/src/plugins/config/modules/pterodactyl/index.ts index e6673e1..52e65b0 100644 --- a/src/plugins/config/modules/pterodactyl/index.ts +++ b/src/plugins/config/modules/pterodactyl/index.ts @@ -2,14 +2,14 @@ import { CommandInteraction, Permissions } from "discord.js"; // Configurations -import getEmbedConfig from "@helpers/getEmbedConfig"; +import getEmbedConfig from "../../../../helpers/getEmbedConfig"; // Handlers -import logger from "@logger"; +import logger from "../../../../logger"; // Models -import apiSchema from "@schemas/api"; -import encryption from "@handlers/encryption"; +import apiSchema from "../../../../database/schemas/api"; +import encryption from "../../../../handlers/encryption"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Function diff --git a/src/plugins/config/modules/shop/index.ts b/src/plugins/config/modules/shop/index.ts index e9f4d9f..a775385 100644 --- a/src/plugins/config/modules/shop/index.ts +++ b/src/plugins/config/modules/shop/index.ts @@ -2,13 +2,13 @@ import { CommandInteraction, Permissions } from "discord.js"; // Configurations -import getEmbedConfig from "@helpers/getEmbedConfig"; +import getEmbedConfig from "../../../../helpers/getEmbedConfig"; // Handlers -import logger from "@logger"; +import logger from "../../../../logger"; // Models -import guildSchema from "@schemas/guild"; +import guildSchema from "../../../../database/schemas/guild"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Function diff --git a/src/plugins/config/modules/welcome/index.ts b/src/plugins/config/modules/welcome/index.ts index bdd962b..e6d5e9b 100644 --- a/src/plugins/config/modules/welcome/index.ts +++ b/src/plugins/config/modules/welcome/index.ts @@ -2,13 +2,13 @@ import { CommandInteraction, Permissions } from "discord.js"; // Configurations -import getEmbedConfig from "@helpers/getEmbedConfig"; +import getEmbedConfig from "../../../../helpers/getEmbedConfig"; // Handlers -import logger from "@logger"; +import logger from "../../../../logger"; // Models -import guildSchema from "@schemas/guild"; +import guildSchema from "../../../../database/schemas/guild"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChannelType } from "discord-api-types/v10"; diff --git a/src/plugins/counters/index.ts b/src/plugins/counters/index.ts index ca3fc56..57ec908 100644 --- a/src/plugins/counters/index.ts +++ b/src/plugins/counters/index.ts @@ -1,8 +1,8 @@ import { CommandInteraction } from "discord.js"; import { SlashCommandBuilder } from "@discordjs/builders"; -import logger from "@logger"; +import logger from "../../logger"; -import modules from "@plugins/counters/modules"; +import modules from "../../plugins/counters/modules"; export default { modules, diff --git a/src/plugins/counters/modules/index.ts b/src/plugins/counters/modules/index.ts index 8c5ea76..dc539f8 100644 --- a/src/plugins/counters/modules/index.ts +++ b/src/plugins/counters/modules/index.ts @@ -1,3 +1,3 @@ -import view from "@plugins/counters/modules/view"; +import view from "./view"; export default { view }; diff --git a/src/plugins/counters/modules/view/index.ts b/src/plugins/counters/modules/view/index.ts index d672f0d..b509dd5 100644 --- a/src/plugins/counters/modules/view/index.ts +++ b/src/plugins/counters/modules/view/index.ts @@ -1,10 +1,10 @@ -import getEmbedConfig from "@helpers/getEmbedConfig"; +import getEmbedConfig from "../../../../helpers/getEmbedConfig"; import { CommandInteraction, MessageEmbed } from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChannelType } from "discord-api-types/v10"; -import counterSchema from "@schemas/counter"; +import counterSchema from "../../../../database/schemas/counter"; export default { metadata: { guildOnly: true, ephemeral: false }, diff --git a/src/plugins/credits/index.ts b/src/plugins/credits/index.ts index 5e8033f..1e1860f 100644 --- a/src/plugins/credits/index.ts +++ b/src/plugins/credits/index.ts @@ -1,8 +1,8 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { CommandInteraction } from "discord.js"; -import logger from "@logger"; +import logger from "../../logger"; -import modules from "@plugins/credits/modules"; +import modules from "../../plugins/credits/modules"; export default { modules, diff --git a/src/plugins/credits/modules/balance/index.ts b/src/plugins/credits/modules/balance/index.ts index 60ee17e..2387d57 100644 --- a/src/plugins/credits/modules/balance/index.ts +++ b/src/plugins/credits/modules/balance/index.ts @@ -1,10 +1,10 @@ -import getEmbedConfig from "@helpers/getEmbedConfig"; +import getEmbedConfig from "../../../../helpers/getEmbedConfig"; import { CommandInteraction, MessageEmbed } from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; -import logger from "@logger"; +import logger from "../../../../logger"; -import fetchUser from "@helpers/fetchUser"; +import fetchUser from "../../../../helpers/fetchUser"; export default { metadata: { guildOnly: true, ephemeral: true }, diff --git a/src/plugins/credits/modules/gift/index.ts b/src/plugins/credits/modules/gift/index.ts index 0325ab0..61f4309 100644 --- a/src/plugins/credits/modules/gift/index.ts +++ b/src/plugins/credits/modules/gift/index.ts @@ -2,16 +2,16 @@ import { CommandInteraction, MessageEmbed } from "discord.js"; // Configurations -import getEmbedConfig from "@helpers/getEmbedConfig"; +import getEmbedConfig from "../../../../helpers/getEmbedConfig"; // Handlers -import logger from "@logger"; +import logger from "../../../../logger"; // Helpers -import saveUser from "@helpers/saveUser"; +import saveUser from "../../../../helpers/saveUser"; // Models -import fetchUser from "@helpers/fetchUser"; +import fetchUser from "../../../../helpers/fetchUser"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Function diff --git a/src/plugins/credits/modules/index.ts b/src/plugins/credits/modules/index.ts index 9b144f2..20edcaf 100644 --- a/src/plugins/credits/modules/index.ts +++ b/src/plugins/credits/modules/index.ts @@ -1,6 +1,6 @@ -import balance from "@plugins/credits/modules/balance"; -import gift from "@plugins/credits/modules/gift"; -import top from "@plugins/credits/modules/top"; -import work from "@plugins/credits/modules/work"; +import balance from "./balance"; +import gift from "./gift"; +import top from "./top"; +import work from "./work"; export default { balance, gift, top, work }; diff --git a/src/plugins/credits/modules/top/index.ts b/src/plugins/credits/modules/top/index.ts index 747f1bc..0aaa2f8 100644 --- a/src/plugins/credits/modules/top/index.ts +++ b/src/plugins/credits/modules/top/index.ts @@ -1,10 +1,10 @@ -import getEmbedConfig from "@helpers/getEmbedConfig"; +import getEmbedConfig from "../../../../helpers/getEmbedConfig"; import { CommandInteraction, MessageEmbed } from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; -import logger from "@logger"; +import logger from "../../../../logger"; -import userSchema, { IUser } from "@schemas/user"; +import userSchema, { IUser } from "../../../../database/schemas/user"; export default { metadata: { guildOnly: true, ephemeral: false }, diff --git a/src/plugins/credits/modules/work/index.ts b/src/plugins/credits/modules/work/index.ts index 1cde8cb..7f29629 100644 --- a/src/plugins/credits/modules/work/index.ts +++ b/src/plugins/credits/modules/work/index.ts @@ -4,17 +4,17 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import Chance from "chance"; // Configurations -import getEmbedConfig from "@helpers/getEmbedConfig"; +import getEmbedConfig from "../../../../helpers/getEmbedConfig"; // Handlers -import logger from "@logger"; +import logger from "../../../../logger"; // Models -import timeoutSchema from "@schemas/timeout"; +import timeoutSchema from "../../../../database/schemas/timeout"; // Helpers -import fetchUser from "@helpers/fetchUser"; -import fetchGuild from "@helpers/fetchGuild"; +import fetchUser from "../../../../helpers/fetchUser"; +import fetchGuild from "../../../../helpers/fetchGuild"; export default { metadata: { guildOnly: true, ephemeral: true }, diff --git a/src/plugins/fun/index.ts b/src/plugins/fun/index.ts index 9ba8e81..687c036 100644 --- a/src/plugins/fun/index.ts +++ b/src/plugins/fun/index.ts @@ -1,8 +1,8 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { CommandInteraction } from "discord.js"; -import logger from "@logger"; +import logger from "../../logger"; -import modules from "@plugins/fun/modules"; +import modules from "../../plugins/fun/modules"; export default { modules, diff --git a/src/plugins/fun/modules/index.ts b/src/plugins/fun/modules/index.ts index 2b59097..53aeddc 100644 --- a/src/plugins/fun/modules/index.ts +++ b/src/plugins/fun/modules/index.ts @@ -1,4 +1,4 @@ -import meme from "@plugins/fun/modules/meme"; +import meme from "./meme"; export default { meme, diff --git a/src/plugins/fun/modules/meme/index.ts b/src/plugins/fun/modules/meme/index.ts index 3b6d706..9134223 100644 --- a/src/plugins/fun/modules/meme/index.ts +++ b/src/plugins/fun/modules/meme/index.ts @@ -1,9 +1,9 @@ -import getEmbedConfig from "@helpers/getEmbedConfig"; +import getEmbedConfig from "../../../../helpers/getEmbedConfig"; import axios from "axios"; import { CommandInteraction, MessageEmbed } from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; -import logger from "@logger"; +import logger from "../../../../logger"; export default { metadata: { guildOnly: false, ephemeral: false }, diff --git a/src/plugins/manage/index.ts b/src/plugins/manage/index.ts index 993ba9f..7f51c88 100644 --- a/src/plugins/manage/index.ts +++ b/src/plugins/manage/index.ts @@ -3,8 +3,8 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { CommandInteraction } from "discord.js"; // Groups -import modules from "@plugins/manage/modules"; -import logger from "@logger"; +import modules from "../../plugins/manage/modules"; +import logger from "../../logger"; // Function export default { diff --git a/src/plugins/manage/modules/counters/index.ts b/src/plugins/manage/modules/counters/index.ts index 3fb9d3e..d5c351c 100644 --- a/src/plugins/manage/modules/counters/index.ts +++ b/src/plugins/manage/modules/counters/index.ts @@ -2,7 +2,7 @@ import { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders"; import { CommandInteraction } from "discord.js"; -import logger from "@logger"; +import logger from "../../../../logger"; // Modules import modules from "./modules"; diff --git a/src/plugins/manage/modules/counters/modules/add/index.ts b/src/plugins/manage/modules/counters/modules/add/index.ts index b4c6e99..cdefbb8 100644 --- a/src/plugins/manage/modules/counters/modules/add/index.ts +++ b/src/plugins/manage/modules/counters/modules/add/index.ts @@ -4,12 +4,12 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChannelType } from "discord-api-types/v10"; // Configurations -import getEmbedConfig from "@helpers/getEmbedConfig"; +import getEmbedConfig from "../../../../../../helpers/getEmbedConfig"; -import logger from "@logger"; +import logger from "../../../../../../logger"; // Models -import counterSchema from "@schemas/counter"; +import counterSchema from "../../../../../../database/schemas/counter"; // Function export default { diff --git a/src/plugins/manage/modules/counters/modules/index.ts b/src/plugins/manage/modules/counters/modules/index.ts index 2f55183..bc9da9c 100644 --- a/src/plugins/manage/modules/counters/modules/index.ts +++ b/src/plugins/manage/modules/counters/modules/index.ts @@ -1,4 +1,4 @@ -import add from "@plugins/manage/modules/counters/modules/add"; -import remove from "@plugins/manage/modules/counters/modules/remove"; +import add from "./add"; +import remove from "./remove"; export default { add, remove }; diff --git a/src/plugins/manage/modules/counters/modules/remove/index.ts b/src/plugins/manage/modules/counters/modules/remove/index.ts index 8a61687..295f2b0 100644 --- a/src/plugins/manage/modules/counters/modules/remove/index.ts +++ b/src/plugins/manage/modules/counters/modules/remove/index.ts @@ -2,13 +2,13 @@ import { CommandInteraction, MessageEmbed, Permissions } from "discord.js"; // Configurations -import getEmbedConfig from "@helpers/getEmbedConfig"; +import getEmbedConfig from "../../../../../../helpers/getEmbedConfig"; // Handlers -import logger from "@logger"; +import logger from "../../../../../../logger"; // Models -import counterSchema from "@schemas/counter"; +import counterSchema from "../../../../../../database/schemas/counter"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChannelType } from "discord-api-types/v10"; diff --git a/src/plugins/manage/modules/credits/index.ts b/src/plugins/manage/modules/credits/index.ts index a12cf11..11e4563 100644 --- a/src/plugins/manage/modules/credits/index.ts +++ b/src/plugins/manage/modules/credits/index.ts @@ -1,6 +1,6 @@ import { CommandInteraction } from "discord.js"; import { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders"; -import logger from "@logger"; +import logger from "../../../../logger"; import modules from "./modules"; diff --git a/src/plugins/manage/modules/credits/modules/give/index.ts b/src/plugins/manage/modules/credits/modules/give/index.ts index cec0376..ebbc762 100644 --- a/src/plugins/manage/modules/credits/modules/give/index.ts +++ b/src/plugins/manage/modules/credits/modules/give/index.ts @@ -3,16 +3,16 @@ import { CommandInteraction, MessageEmbed, Permissions } from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Configurations -import getEmbedConfig from "@helpers/getEmbedConfig"; +import getEmbedConfig from "../../../../../../helpers/getEmbedConfig"; // Handlers -import logger from "@logger"; +import logger from "../../../../../../logger"; // Helpers -import pluralize from "@helpers/pluralize"; +import pluralize from "../../../../../../helpers/pluralize"; // Models -import fetchUser from "@helpers/fetchUser"; +import fetchUser from "../../../../../../helpers/fetchUser"; // Function export default { diff --git a/src/plugins/manage/modules/credits/modules/index.ts b/src/plugins/manage/modules/credits/modules/index.ts index 1dd2f3d..ede5ae7 100644 --- a/src/plugins/manage/modules/credits/modules/index.ts +++ b/src/plugins/manage/modules/credits/modules/index.ts @@ -1,6 +1,6 @@ -import give from "@plugins/manage/modules/credits/modules/give"; -import set from "@plugins/manage/modules/credits/modules/set"; -import take from "@plugins/manage/modules/credits/modules/take"; -import transfer from "@plugins/manage/modules/credits/modules/transfer"; +import give from "./give"; +import set from "./set"; +import take from "./take"; +import transfer from "./transfer"; export default { give, set, take, transfer }; diff --git a/src/plugins/manage/modules/credits/modules/set/index.ts b/src/plugins/manage/modules/credits/modules/set/index.ts index a7d86a2..a8e1771 100644 --- a/src/plugins/manage/modules/credits/modules/set/index.ts +++ b/src/plugins/manage/modules/credits/modules/set/index.ts @@ -2,15 +2,15 @@ import { CommandInteraction, MessageEmbed, Permissions } from "discord.js"; // Configurations -import getEmbedConfig from "@helpers/getEmbedConfig"; +import getEmbedConfig from "../../../../../../helpers/getEmbedConfig"; // Handlers -import logger from "@logger"; +import logger from "../../../../../../logger"; // Helpers // Models -import fetchUser from "@helpers/fetchUser"; +import fetchUser from "../../../../../../helpers/fetchUser"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Function diff --git a/src/plugins/manage/modules/credits/modules/take/index.ts b/src/plugins/manage/modules/credits/modules/take/index.ts index 9c823b9..5cf794a 100644 --- a/src/plugins/manage/modules/credits/modules/take/index.ts +++ b/src/plugins/manage/modules/credits/modules/take/index.ts @@ -2,16 +2,16 @@ import { CommandInteraction, MessageEmbed, Permissions } from "discord.js"; // Configurations -import getEmbedConfig from "@helpers/getEmbedConfig"; +import getEmbedConfig from "../../../../../../helpers/getEmbedConfig"; // Handlers -import logger from "@logger"; +import logger from "../../../../../../logger"; // Helpers -import pluralize from "@helpers/pluralize"; +import pluralize from "../../../../../../helpers/pluralize"; // Models -import fetchUser from "@helpers/fetchUser"; +import fetchUser from "../../../../../../helpers/fetchUser"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Function diff --git a/src/plugins/manage/modules/credits/modules/transfer/index.ts b/src/plugins/manage/modules/credits/modules/transfer/index.ts index 19de23a..d65667b 100644 --- a/src/plugins/manage/modules/credits/modules/transfer/index.ts +++ b/src/plugins/manage/modules/credits/modules/transfer/index.ts @@ -2,16 +2,16 @@ import { CommandInteraction, MessageEmbed, Permissions } from "discord.js"; // Configurations -import getEmbedConfig from "@helpers/getEmbedConfig"; +import getEmbedConfig from "../../../../../../helpers/getEmbedConfig"; // Handlers -import logger from "@logger"; +import logger from "../../../../../../logger"; // Helpers -import saveUser from "@helpers/saveUser"; +import saveUser from "../../../../../../helpers/saveUser"; // Models -import fetchUser from "@helpers/fetchUser"; +import fetchUser from "../../../../../../helpers/fetchUser"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Function diff --git a/src/plugins/manage/modules/index.ts b/src/plugins/manage/modules/index.ts index 61797b1..e9b808b 100644 --- a/src/plugins/manage/modules/index.ts +++ b/src/plugins/manage/modules/index.ts @@ -1,4 +1,4 @@ -import counters from "@plugins/manage/modules/counters"; -import credits from "@plugins/manage/modules/credits"; +import counters from "./counters"; +import credits from "./credits"; export default { counters, credits }; diff --git a/src/plugins/profile/index.ts b/src/plugins/profile/index.ts index d37ad1b..bb3c5b3 100644 --- a/src/plugins/profile/index.ts +++ b/src/plugins/profile/index.ts @@ -3,10 +3,10 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { CommandInteraction } from "discord.js"; // Modules -import modules from "@plugins/profile/modules"; +import modules from "../../plugins/profile/modules"; // Handlers -import logger from "@logger"; +import logger from "../../logger"; // Function export default { diff --git a/src/plugins/profile/modules/index.ts b/src/plugins/profile/modules/index.ts index 1dc8e1b..dc539f8 100644 --- a/src/plugins/profile/modules/index.ts +++ b/src/plugins/profile/modules/index.ts @@ -1,3 +1,3 @@ -import view from "@plugins/profile/modules/view"; +import view from "./view"; export default { view }; diff --git a/src/plugins/profile/modules/view.ts b/src/plugins/profile/modules/view.ts index c6704a3..5a59fd3 100644 --- a/src/plugins/profile/modules/view.ts +++ b/src/plugins/profile/modules/view.ts @@ -2,12 +2,12 @@ import { CommandInteraction } from "discord.js"; // Configurations -import getEmbedConfig from "@helpers/getEmbedConfig"; +import getEmbedConfig from "../../../helpers/getEmbedConfig"; // Models -import fetchUser from "@helpers/fetchUser"; +import fetchUser from "../../../helpers/fetchUser"; -import logger from "@logger"; +import logger from "../../../logger"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Function diff --git a/src/plugins/reputation/index.ts b/src/plugins/reputation/index.ts index f5237ab..a027d7e 100644 --- a/src/plugins/reputation/index.ts +++ b/src/plugins/reputation/index.ts @@ -6,7 +6,7 @@ import { CommandInteraction } from "discord.js"; import modules from "./modules"; // Handlers -import logger from "@logger"; +import logger from "../../logger"; // Function export default { diff --git a/src/plugins/reputation/modules/give.ts b/src/plugins/reputation/modules/give.ts index 949f9c9..c55e909 100644 --- a/src/plugins/reputation/modules/give.ts +++ b/src/plugins/reputation/modules/give.ts @@ -2,16 +2,16 @@ import { CommandInteraction } from "discord.js"; // Configurations -import getEmbedConfig from "@helpers/getEmbedConfig"; +import getEmbedConfig from "../../../helpers/getEmbedConfig"; -import { timeout } from "@config/reputation"; +import { timeout } from "../../../config/reputation"; // Handlers -import logger from "@logger"; +import logger from "../../../logger"; // Models -import timeoutSchema from "@schemas/timeout"; -import fetchUser from "@helpers/fetchUser"; +import timeoutSchema from "../../../database/schemas/timeout"; +import fetchUser from "../../../helpers/fetchUser"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Function diff --git a/src/plugins/reputation/modules/index.ts b/src/plugins/reputation/modules/index.ts index f6746fd..e891cf0 100644 --- a/src/plugins/reputation/modules/index.ts +++ b/src/plugins/reputation/modules/index.ts @@ -1,3 +1,3 @@ -import give from "@plugins/reputation/modules/give"; +import give from "./give"; export default { give }; diff --git a/src/plugins/shop/modules/index.ts b/src/plugins/shop/modules/index.ts index c356cae..e39fb66 100644 --- a/src/plugins/shop/modules/index.ts +++ b/src/plugins/shop/modules/index.ts @@ -1,4 +1,4 @@ -import pterodactyl from "@plugins/shop/modules/pterodactyl"; -import roles from "@plugins/shop/modules/roles"; +import pterodactyl from "./pterodactyl"; +import roles from "./roles"; export default { pterodactyl, roles }; diff --git a/src/plugins/shop/modules/pterodactyl.ts b/src/plugins/shop/modules/pterodactyl.ts index 22da19c..daa698d 100644 --- a/src/plugins/shop/modules/pterodactyl.ts +++ b/src/plugins/shop/modules/pterodactyl.ts @@ -2,15 +2,15 @@ import { CommandInteraction } from "discord.js"; import { v4 as uuidv4 } from "uuid"; import axios from "axios"; -import getEmbedConfig from "@helpers/getEmbedConfig"; +import getEmbedConfig from "../../../helpers/getEmbedConfig"; -import logger from "@logger"; -import encryption from "@handlers/encryption"; +import logger from "../../../logger"; +import encryption from "../../../handlers/encryption"; -import pluralize from "@helpers/pluralize"; +import pluralize from "../../../helpers/pluralize"; -import apiSchema from "@schemas/api"; -import fetchUser from "@helpers/fetchUser"; +import apiSchema from "../../../database/schemas/api"; +import fetchUser from "../../../helpers/fetchUser"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; export default { diff --git a/src/plugins/shop/modules/roles/index.ts b/src/plugins/shop/modules/roles/index.ts index 33ece41..a4ffb2a 100644 --- a/src/plugins/shop/modules/roles/index.ts +++ b/src/plugins/shop/modules/roles/index.ts @@ -3,14 +3,14 @@ import { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders"; import { CommandInteraction } from "discord.js"; // Handlers -import logger from "@logger"; +import logger from "../../../../logger"; -import getEmbedConfig from "@helpers/getEmbedConfig"; +import getEmbedConfig from "../../../../helpers/getEmbedConfig"; // Modules import modules from "./modules"; -import guildSchema from "@schemas/guild"; +import guildSchema from "../../../../database/schemas/guild"; // Function export default { diff --git a/src/plugins/shop/modules/roles/modules/buy.ts b/src/plugins/shop/modules/roles/modules/buy.ts index 4e4528d..b92ba7a 100644 --- a/src/plugins/shop/modules/roles/modules/buy.ts +++ b/src/plugins/shop/modules/roles/modules/buy.ts @@ -6,17 +6,17 @@ import { } from "discord.js"; // Configurations -import getEmbedConfig from "@helpers/getEmbedConfig"; +import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; // Models -import shopRolesSchema from "@schemas/shopRole"; -import guildSchema from "@schemas/guild"; +import shopRolesSchema from "../../../../../database/schemas/shopRole"; +import guildSchema from "../../../../../database/schemas/guild"; -import logger from "@logger"; +import logger from "../../../../../logger"; // Helpers -import pluralize from "@helpers/pluralize"; -import fetchUser from "@helpers/fetchUser"; +import pluralize from "../../../../../helpers/pluralize"; +import fetchUser from "../../../../../helpers/fetchUser"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Function diff --git a/src/plugins/shop/modules/roles/modules/cancel.ts b/src/plugins/shop/modules/roles/modules/cancel.ts index 546dbc7..cf16d95 100644 --- a/src/plugins/shop/modules/roles/modules/cancel.ts +++ b/src/plugins/shop/modules/roles/modules/cancel.ts @@ -2,16 +2,16 @@ import { CommandInteraction, GuildMemberRoleManager } from "discord.js"; // Configurations -import getEmbedConfig from "@helpers/getEmbedConfig"; +import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; // Models -import shopRolesSchema from "@schemas/shopRole"; +import shopRolesSchema from "../../../../../database/schemas/shopRole"; -import logger from "@logger"; +import logger from "../../../../../logger"; // Helpers -import pluralize from "@helpers/pluralize"; -import fetchUser from "@helpers/fetchUser"; +import pluralize from "../../../../../helpers/pluralize"; +import fetchUser from "../../../../../helpers/fetchUser"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Function diff --git a/src/plugins/utility/index.ts b/src/plugins/utility/index.ts index 6dc6fff..b831189 100644 --- a/src/plugins/utility/index.ts +++ b/src/plugins/utility/index.ts @@ -3,7 +3,7 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { CommandInteraction } from "discord.js"; // Modules -import modules from "@plugins/utility/modules"; +import modules from "../../plugins/utility/modules"; // Handlers import logger from "../../logger"; diff --git a/src/plugins/utility/modules/about.ts b/src/plugins/utility/modules/about.ts index 8011d51..18eca4c 100644 --- a/src/plugins/utility/modules/about.ts +++ b/src/plugins/utility/modules/about.ts @@ -2,9 +2,9 @@ import { CommandInteraction } from "discord.js"; // Configurations -import getEmbedConfig from "@helpers/getEmbedConfig"; +import getEmbedConfig from "../../../helpers/getEmbedConfig"; -import { hosterName, hosterUrl } from "@config/other"; +import { hosterName, hosterUrl } from "../../../config/other"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Function diff --git a/src/plugins/utility/modules/avatar.ts b/src/plugins/utility/modules/avatar.ts index b060be3..57110cf 100644 --- a/src/plugins/utility/modules/avatar.ts +++ b/src/plugins/utility/modules/avatar.ts @@ -1,4 +1,4 @@ -import getEmbedConfig from "@helpers/getEmbedConfig"; +import getEmbedConfig from "../../../helpers/getEmbedConfig"; import { CommandInteraction, MessageEmbed } from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; diff --git a/src/plugins/utility/modules/index.ts b/src/plugins/utility/modules/index.ts index 80c5a64..cd69316 100644 --- a/src/plugins/utility/modules/index.ts +++ b/src/plugins/utility/modules/index.ts @@ -1,7 +1,7 @@ -import avatar from "@plugins/utility/modules/avatar"; -import about from "@plugins/utility/modules/about"; -import lookup from "@plugins/utility/modules/lookup"; -import stats from "@plugins/utility/modules/stats"; +import avatar from "./avatar"; +import about from "./about"; +import lookup from "./lookup"; +import stats from "./stats"; export default { avatar, diff --git a/src/plugins/utility/modules/lookup.ts b/src/plugins/utility/modules/lookup.ts index 241b7ce..a5825f9 100644 --- a/src/plugins/utility/modules/lookup.ts +++ b/src/plugins/utility/modules/lookup.ts @@ -1,11 +1,11 @@ import axios from "axios"; import { CommandInteraction } from "discord.js"; -import getEmbedConfig from "@helpers/getEmbedConfig"; +import getEmbedConfig from "../../../helpers/getEmbedConfig"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; -import embedBuilder from "@root/helpers/embedBuilder"; +import embedBuilder from "../../../helpers/embedBuilder"; export default { metadata: { guildOnly: false, ephemeral: false }, diff --git a/src/plugins/utility/modules/stats.ts b/src/plugins/utility/modules/stats.ts index a7f44a0..805b948 100644 --- a/src/plugins/utility/modules/stats.ts +++ b/src/plugins/utility/modules/stats.ts @@ -1,4 +1,4 @@ -import getEmbedConfig from "@helpers/getEmbedConfig"; +import getEmbedConfig from "../../../helpers/getEmbedConfig"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { CommandInteraction } from "discord.js"; diff --git a/src/types/common/discord.d.ts b/src/types/common/discord.d.ts index 68458e0..e83d22f 100644 --- a/src/types/common/discord.d.ts +++ b/src/types/common/discord.d.ts @@ -1,8 +1,9 @@ -import { Collection, Client as DJSClient } from "discord.js"; +import { Collection } from "discord.js"; +import ICommand from "../interfaces/Command"; declare module "discord.js" { export interface Client extends DJSClient { - commands: Collection; + commands: Collection; } } From 880ad789c98d230481be3606ae90beb451def7ee Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sun, 29 May 2022 19:35:42 +0200 Subject: [PATCH 137/142] =?UTF-8?q?=F0=9F=9A=91=20plugins=20now=20loading?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/handlers/commands.ts | 2 +- src/helpers/getCommandMetadata/index.ts | 4 +- src/interfaces/Command.ts | 2 +- src/managers/event/index.ts | 2 +- src/plugins/config/index.ts | 83 ++++++--------- src/plugins/counters/index.ts | 25 ++--- src/plugins/credits/index.ts | 56 +++++----- src/plugins/fun/index.ts | 26 +++-- src/plugins/manage/index.ts | 40 +++---- src/plugins/manage/modules/counters/index.ts | 52 +++++----- src/plugins/manage/modules/credits/index.ts | 57 ++++------ src/plugins/manage/modules/index.ts | 4 +- src/plugins/profile/index.ts | 27 +++-- src/plugins/reputation/index.ts | 28 ++--- src/plugins/shop/index.ts | 37 ++++--- src/plugins/shop/modules/index.ts | 2 +- src/plugins/shop/modules/roles/index.ts | 103 +++++++++---------- src/plugins/utility/index.ts | 48 +++++---- 18 files changed, 267 insertions(+), 331 deletions(-) diff --git a/src/handlers/commands.ts b/src/handlers/commands.ts index 8b75999..1df02fe 100644 --- a/src/handlers/commands.ts +++ b/src/handlers/commands.ts @@ -6,7 +6,7 @@ import { ICommand } from "../interfaces/Command"; export default async (client: Client) => { client.commands = new Collection(); - fs.readdir("./src/plugins", async (error, plugins) => { + fs.readdir("plugins", async (error, plugins) => { if (error) { return logger.error(`Error reading plugins: ${error}`); } diff --git a/src/helpers/getCommandMetadata/index.ts b/src/helpers/getCommandMetadata/index.ts index 71940d2..647eb75 100644 --- a/src/helpers/getCommandMetadata/index.ts +++ b/src/helpers/getCommandMetadata/index.ts @@ -9,6 +9,6 @@ export default async ( const subcommandGroup = interaction.options.getSubcommandGroup(false); return subcommandGroup - ? currentCommand.modules[subcommandGroup].modules[subcommand].metadata - : currentCommand.modules[subcommand].metadata; + ? currentCommand.moduleData[subcommandGroup].moduleData[subcommand].metadata + : currentCommand.moduleData[subcommand].metadata; }; diff --git a/src/interfaces/Command.ts b/src/interfaces/Command.ts index 34585d9..f8a895a 100644 --- a/src/interfaces/Command.ts +++ b/src/interfaces/Command.ts @@ -1,7 +1,7 @@ import { SlashCommandBuilder } from "@discordjs/builders"; export interface ICommand { - modules: any; builder: SlashCommandBuilder; + moduleData: any; execute: Promise; } diff --git a/src/managers/event/index.ts b/src/managers/event/index.ts index be51927..8a3a506 100644 --- a/src/managers/event/index.ts +++ b/src/managers/event/index.ts @@ -3,7 +3,7 @@ import { Client } from "discord.js"; import listDir from "../../helpers/listDir"; export const register = async (client: Client) => { - const eventNames = await listDir("src/events"); + const eventNames = await listDir("events"); if (!eventNames) return; for await (const eventName of eventNames) { diff --git a/src/plugins/config/index.ts b/src/plugins/config/index.ts index 0b82732..4110d5c 100644 --- a/src/plugins/config/index.ts +++ b/src/plugins/config/index.ts @@ -8,57 +8,36 @@ import modules from "./modules"; // Handlers import logger from "../../logger"; +export const builder = new SlashCommandBuilder() + .setName("config") + .setDescription("Manage guild configurations.") + + .addSubcommand(modules.pterodactyl.builder) + .addSubcommand(modules.credits.builder) + .addSubcommand(modules.points.builder) + .addSubcommand(modules.welcome.builder) + .addSubcommand(modules.audits.builder) + .addSubcommand(modules.shop.builder) + .addSubcommand(modules.embeds.builder); + +export const moduleData = modules; + // Function -export default { - modules, - - builder: new SlashCommandBuilder() - .setName("config") - .setDescription("Manage guild configurations.") - - .addSubcommand(modules.pterodactyl.builder) - .addSubcommand(modules.credits.builder) - .addSubcommand(modules.points.builder) - .addSubcommand(modules.welcome.builder) - .addSubcommand(modules.audits.builder) - .addSubcommand(modules.shop.builder) - .addSubcommand(modules.embeds.builder), - - async execute(interaction: CommandInteraction) { - // Destructure member - const { options } = interaction; - - switch (options?.getSubcommand()) { - case "pterodactyl": - logger?.silly(`Subcommand is pterodactyl`); - - return modules.pterodactyl.execute(interaction); - case "credits": - logger?.silly(`Subcommand is credits`); - - return modules.credits.execute(interaction); - case "points": - logger?.silly(`Subcommand is points`); - - return modules.points.execute(interaction); - case "welcome": - logger?.silly(`Subcommand is welcome`); - - return modules.welcome.execute(interaction); - case "audits": - logger?.silly(`Subcommand is audits`); - - return modules.audits.execute(interaction); - case "shop": - logger?.silly(`Subcommand is shop`); - - return modules.shop.execute(interaction); - case "embeds": - logger?.silly(`Subcommand is shop`); - - return modules.embeds.execute(interaction); - default: - logger?.silly(`Subcommand is not found`); - } - }, +export const execute = async (interaction: CommandInteraction) => { + switch (interaction.options?.getSubcommand()) { + case "pterodactyl": + return modules.pterodactyl.execute(interaction); + case "credits": + return modules.credits.execute(interaction); + case "points": + return modules.points.execute(interaction); + case "welcome": + return modules.welcome.execute(interaction); + case "audits": + return modules.audits.execute(interaction); + case "shop": + return modules.shop.execute(interaction); + case "embeds": + return modules.embeds.execute(interaction); + } }; diff --git a/src/plugins/counters/index.ts b/src/plugins/counters/index.ts index 57ec908..df23d0b 100644 --- a/src/plugins/counters/index.ts +++ b/src/plugins/counters/index.ts @@ -4,23 +4,16 @@ import logger from "../../logger"; import modules from "../../plugins/counters/modules"; -export default { - modules, +export const builder = new SlashCommandBuilder() + .setName("counters") + .setDescription("View guild counters") - builder: new SlashCommandBuilder() - .setName("counters") - .setDescription("View guild counters") + .addSubcommand(modules.view.builder); - .addSubcommand(modules.view.builder), +export const moduleData = modules; - async execute(interaction: CommandInteraction) { - const { options } = interaction; - - if (options.getSubcommand() === "view") { - logger.silly(`Executing view subcommand`); - return modules.view.execute(interaction); - } - - logger.silly(`Unknown subcommand ${options.getSubcommand()}`); - }, +export const execute = async (interaction: CommandInteraction) => { + if (interaction.options.getSubcommand() === "view") { + await modules.view.execute(interaction); + } }; diff --git a/src/plugins/credits/index.ts b/src/plugins/credits/index.ts index 1e1860f..02c03a5 100644 --- a/src/plugins/credits/index.ts +++ b/src/plugins/credits/index.ts @@ -2,38 +2,36 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { CommandInteraction } from "discord.js"; import logger from "../../logger"; -import modules from "../../plugins/credits/modules"; +import modules from "./modules"; -export default { - modules, +export const builder = new SlashCommandBuilder() + .setName("credits") + .setDescription("Manage your credits.") - builder: new SlashCommandBuilder() - .setName("credits") - .setDescription("Manage your credits.") + .addSubcommand(modules.balance.builder) + .addSubcommand(modules.gift.builder) + .addSubcommand(modules.top.builder) + .addSubcommand(modules.work.builder); - .addSubcommand(modules.balance.builder) - .addSubcommand(modules.gift.builder) - .addSubcommand(modules.top.builder) - .addSubcommand(modules.work.builder), +export const moduleData = modules; - async execute(interaction: CommandInteraction) { - const { options } = interaction; +export const execute = async (interaction: CommandInteraction) => { + const { options } = interaction; - switch (options.getSubcommand()) { - case "balance": - await modules.balance.execute(interaction); - break; - case "gift": - await modules.gift.execute(interaction); - break; - case "top": - await modules.top.execute(interaction); - break; - case "work": - await modules.work.execute(interaction); - break; - default: - logger.silly(`Unknown subcommand ${options.getSubcommand()}`); - } - }, + switch (options.getSubcommand()) { + case "balance": + await modules.balance.execute(interaction); + break; + case "gift": + await modules.gift.execute(interaction); + break; + case "top": + await modules.top.execute(interaction); + break; + case "work": + await modules.work.execute(interaction); + break; + default: + logger.silly(`Unknown subcommand ${options.getSubcommand()}`); + } }; diff --git a/src/plugins/fun/index.ts b/src/plugins/fun/index.ts index 687c036..758814c 100644 --- a/src/plugins/fun/index.ts +++ b/src/plugins/fun/index.ts @@ -4,22 +4,20 @@ import logger from "../../logger"; import modules from "../../plugins/fun/modules"; -export default { - modules, +export const builder = new SlashCommandBuilder() + .setName("fun") + .setDescription("Fun commands.") - builder: new SlashCommandBuilder() - .setName("fun") - .setDescription("Fun commands.") + .addSubcommand(modules.meme.builder); - .addSubcommand(modules.meme.builder), +export const moduleData = modules; - async execute(interaction: CommandInteraction) { - const { options } = interaction; +export const execute = async (interaction: CommandInteraction) => { + const { options } = interaction; - if (options.getSubcommand() === "meme") { - await modules.meme.execute(interaction); - } else { - logger.silly(`Unknown subcommand ${options.getSubcommand()}`); - } - }, + if (options.getSubcommand() === "meme") { + await modules.meme.execute(interaction); + } else { + logger.silly(`Unknown subcommand ${options.getSubcommand()}`); + } }; diff --git a/src/plugins/manage/index.ts b/src/plugins/manage/index.ts index 7f51c88..a54f2e2 100644 --- a/src/plugins/manage/index.ts +++ b/src/plugins/manage/index.ts @@ -6,32 +6,24 @@ import { CommandInteraction } from "discord.js"; import modules from "../../plugins/manage/modules"; import logger from "../../logger"; +export const moduleData = modules; + // Function -export default { - modules, +export const builder = new SlashCommandBuilder() + .setName("manage") + .setDescription("Manage the bot.") + .addSubcommandGroup(modules.counters.builder) + .addSubcommandGroup(modules.credits.builder); - builder: new SlashCommandBuilder() - .setName("manage") - .setDescription("Manage the bot.") - .addSubcommandGroup(modules.counters.builder) - .addSubcommandGroup(modules.credits.builder), +export const execute = async (interaction: CommandInteraction) => { + // Destructure + const { options } = interaction; - async execute(interaction: CommandInteraction) { - // Destructure - const { options } = interaction; + if (options?.getSubcommandGroup() === "credits") { + return modules.credits.execute(interaction); + } - if (options?.getSubcommandGroup() === "credits") { - logger?.silly(`Subcommand group is credits`); - - return modules.credits.execute(interaction); - } - - if (options?.getSubcommandGroup() === "counters") { - logger?.silly(`Subcommand group is counters`); - - return modules.counters.execute(interaction); - } - - logger?.silly(`Subcommand group is not credits or counters`); - }, + if (options?.getSubcommandGroup() === "counters") { + return modules.counters.execute(interaction); + } }; diff --git a/src/plugins/manage/modules/counters/index.ts b/src/plugins/manage/modules/counters/index.ts index d5c351c..36d6cd9 100644 --- a/src/plugins/manage/modules/counters/index.ts +++ b/src/plugins/manage/modules/counters/index.ts @@ -8,32 +8,30 @@ import logger from "../../../../logger"; import modules from "./modules"; // Function -export default { - modules, +export const moduleData = modules; - builder: (group: SlashCommandSubcommandGroupBuilder) => { - return group - .setName("counters") - .setDescription("Manage guild counters.") - .addSubcommand(modules.add.builder) - .addSubcommand(modules.remove.builder); - }, - - execute: async (interaction: CommandInteraction) => { - const { options } = interaction; - - if (options?.getSubcommand() === "add") { - logger?.silly(`Executing create subcommand`); - - return modules.add.execute(interaction); - } - - if (options?.getSubcommand() === "remove") { - logger?.silly(`Executing delete subcommand`); - - return modules.remove.execute(interaction); - } - - logger?.silly(`Unknown subcommand ${options?.getSubcommand()}`); - }, +export const builder = (group: SlashCommandSubcommandGroupBuilder) => { + return group + .setName("counters") + .setDescription("Manage guild counters.") + .addSubcommand(modules.add.builder) + .addSubcommand(modules.remove.builder); +}; + +export const execute = async (interaction: CommandInteraction) => { + const { options } = interaction; + + if (options?.getSubcommand() === "add") { + logger?.silly(`Executing create subcommand`); + + return modules.add.execute(interaction); + } + + if (options?.getSubcommand() === "remove") { + logger?.silly(`Executing delete subcommand`); + + return modules.remove.execute(interaction); + } + + logger?.silly(`Unknown subcommand ${options?.getSubcommand()}`); }; diff --git a/src/plugins/manage/modules/credits/index.ts b/src/plugins/manage/modules/credits/index.ts index 11e4563..cd6819b 100644 --- a/src/plugins/manage/modules/credits/index.ts +++ b/src/plugins/manage/modules/credits/index.ts @@ -4,40 +4,27 @@ import logger from "../../../../logger"; import modules from "./modules"; -export default { - modules, +export const moduleData = modules; - builder: (group: SlashCommandSubcommandGroupBuilder) => { - return group - .setName("credits") - .setDescription("Manage the credits of a user.") - .addSubcommand(modules.give.builder) - .addSubcommand(modules.set.builder) - .addSubcommand(modules.take.builder) - .addSubcommand(modules.transfer.builder); - }, - execute: async (interaction: CommandInteraction) => { - const { options } = interaction; - - switch (options.getSubcommand()) { - case "give": - logger.silly(`Executing give subcommand`); - - return modules.give.execute(interaction); - case "set": - logger.silly(`Executing set subcommand`); - - return modules.set.execute(interaction); - case "take": - logger.silly(`Executing take subcommand`); - - return modules.take.execute(interaction); - case "transfer": - logger.silly(`Executing transfer subcommand`); - - return modules.transfer.execute(interaction); - default: - logger.silly(`Unknown subcommand ${options.getSubcommand()}`); - } - }, +export const builder = (group: SlashCommandSubcommandGroupBuilder) => { + return group + .setName("credits") + .setDescription("Manage the credits of a user.") + .addSubcommand(modules.give.builder) + .addSubcommand(modules.set.builder) + .addSubcommand(modules.take.builder) + .addSubcommand(modules.transfer.builder); +}; + +export const execute = async (interaction: CommandInteraction) => { + switch (interaction.options.getSubcommand()) { + case "give": + return modules.give.execute(interaction); + case "set": + return modules.set.execute(interaction); + case "take": + return modules.take.execute(interaction); + case "transfer": + return modules.transfer.execute(interaction); + } }; diff --git a/src/plugins/manage/modules/index.ts b/src/plugins/manage/modules/index.ts index e9b808b..c55982f 100644 --- a/src/plugins/manage/modules/index.ts +++ b/src/plugins/manage/modules/index.ts @@ -1,4 +1,4 @@ -import counters from "./counters"; -import credits from "./credits"; +import * as counters from "./counters"; +import * as credits from "./credits"; export default { counters, credits }; diff --git a/src/plugins/profile/index.ts b/src/plugins/profile/index.ts index bb3c5b3..808c9e7 100644 --- a/src/plugins/profile/index.ts +++ b/src/plugins/profile/index.ts @@ -8,23 +8,22 @@ import modules from "../../plugins/profile/modules"; // Handlers import logger from "../../logger"; +export const moduleData = modules; + // Function -export default { - modules, +export const builder = new SlashCommandBuilder() + .setName("profile") + .setDescription("Check a profile.") + .addSubcommand(modules.view.builder); - builder: new SlashCommandBuilder() - .setName("profile") - .setDescription("Check a profile.") - .addSubcommand(modules.view.builder), - async execute(interaction: CommandInteraction) { - const { options } = interaction; +export const execute = async (interaction: CommandInteraction) => { + const { options } = interaction; - if (options?.getSubcommand() === "view") { - logger?.silly(`Executing view subcommand`); + if (options?.getSubcommand() === "view") { + logger?.silly(`Executing view subcommand`); - return modules.view.execute(interaction); - } + return modules.view.execute(interaction); + } - logger?.silly(`No subcommand found`); - }, + logger?.silly(`No subcommand found`); }; diff --git a/src/plugins/reputation/index.ts b/src/plugins/reputation/index.ts index a027d7e..b0812d4 100644 --- a/src/plugins/reputation/index.ts +++ b/src/plugins/reputation/index.ts @@ -8,22 +8,22 @@ import modules from "./modules"; // Handlers import logger from "../../logger"; +export const moduleData = modules; + // Function -export default { - modules, - builder: new SlashCommandBuilder() - .setName("reputation") - .setDescription("Manage reputation.") - .addSubcommand(modules.give.builder), - async execute(interaction: CommandInteraction) { - const { options } = interaction; +export const builder = new SlashCommandBuilder() + .setName("reputation") + .setDescription("Manage reputation.") + .addSubcommand(modules.give.builder); - if (options?.getSubcommand() === "give") { - logger?.silly(`Executing give subcommand`); +export const execute = async (interaction: CommandInteraction) => { + const { options } = interaction; - await modules.give.execute(interaction); - } + if (options?.getSubcommand() === "give") { + logger?.silly(`Executing give subcommand`); - logger?.silly(`No subcommand found`); - }, + await modules.give.execute(interaction); + } + + logger?.silly(`No subcommand found`); }; diff --git a/src/plugins/shop/index.ts b/src/plugins/shop/index.ts index 330306e..2ef6f65 100644 --- a/src/plugins/shop/index.ts +++ b/src/plugins/shop/index.ts @@ -8,30 +8,29 @@ import modules from "./modules"; // Handlers import logger from "../../logger"; +export const moduleData = modules; + // Function -export default { - modules, +export const builder = new SlashCommandBuilder() + .setName("shop") + .setDescription("Shop for credits and custom roles.") + .addSubcommand(modules.pterodactyl.builder) + .addSubcommandGroup(modules.roles.builder); - builder: new SlashCommandBuilder() - .setName("shop") - .setDescription("Shop for credits and custom roles.") - .addSubcommand(modules.pterodactyl.builder) - .addSubcommandGroup(modules.roles.builder), - async execute(interaction: CommandInteraction) { - const { options } = interaction; +export const execute = async (interaction: CommandInteraction) => { + const { options } = interaction; - if (options?.getSubcommand() === "pterodactyl") { - logger.silly(`Executing pterodactyl subcommand`); + if (options?.getSubcommand() === "pterodactyl") { + logger.silly(`Executing pterodactyl subcommand`); - return modules.pterodactyl.execute(interaction); - } + return modules.pterodactyl.execute(interaction); + } - if (options?.getSubcommandGroup() === "roles") { - logger?.silly(`Subcommand group is roles`); + if (options?.getSubcommandGroup() === "roles") { + logger?.silly(`Subcommand group is roles`); - return modules.roles.execute(interaction); - } + return modules.roles.execute(interaction); + } - logger?.silly(`No subcommand found.`); - }, + logger?.silly(`No subcommand found.`); }; diff --git a/src/plugins/shop/modules/index.ts b/src/plugins/shop/modules/index.ts index e39fb66..d191ec6 100644 --- a/src/plugins/shop/modules/index.ts +++ b/src/plugins/shop/modules/index.ts @@ -1,4 +1,4 @@ import pterodactyl from "./pterodactyl"; -import roles from "./roles"; +import * as roles from "./roles"; export default { pterodactyl, roles }; diff --git a/src/plugins/shop/modules/roles/index.ts b/src/plugins/shop/modules/roles/index.ts index a4ffb2a..bdec977 100644 --- a/src/plugins/shop/modules/roles/index.ts +++ b/src/plugins/shop/modules/roles/index.ts @@ -12,59 +12,54 @@ import modules from "./modules"; import guildSchema from "../../../../database/schemas/guild"; +export const moduleData = modules; + // Function -export default { - modules, - - builder: (group: SlashCommandSubcommandGroupBuilder) => { - return group - .setName("roles") - .setDescription("Shop for custom roles.") - .addSubcommand(modules.buy.builder) - .addSubcommand(modules.cancel.builder); - }, - execute: async (interaction: CommandInteraction) => { - if (interaction.guild == null) return; - const { errorColor, footerText, footerIcon } = await getEmbedConfig( - interaction.guild - ); - const { options, guild } = interaction; - - const guildDB = await guildSchema?.findOne({ - guildId: guild?.id, - }); - - if (guildDB === null) return; - - if (!guildDB.shop.roles.status) { - logger.silly(`Shop roles disabled.`); - - return interaction?.editReply({ - embeds: [ - { - title: ":dollar: Shop - Roles", - description: "This server has disabled shop roles.", - color: errorColor, - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, - }, - ], - }); - } - - if (options?.getSubcommand() === "buy") { - logger.silly(`Executing buy subcommand`); - - await modules.buy.execute(interaction); - } - - if (options?.getSubcommand() === "cancel") { - logger.silly(`Executing cancel subcommand`); - - await modules.cancel.execute(interaction); - } - }, +export const builder = (group: SlashCommandSubcommandGroupBuilder) => { + return group + .setName("roles") + .setDescription("Shop for custom roles.") + .addSubcommand(modules.buy.builder) + .addSubcommand(modules.cancel.builder); +}; + +export const execute = async (interaction: CommandInteraction) => { + if (interaction.guild == null) return; + const { errorColor, footerText, footerIcon } = await getEmbedConfig( + interaction.guild + ); + const { options, guild } = interaction; + + const guildDB = await guildSchema?.findOne({ + guildId: guild?.id, + }); + + if (guildDB === null) return; + + if (!guildDB.shop.roles.status) { + logger.silly(`Shop roles disabled.`); + + return interaction?.editReply({ + embeds: [ + { + title: ":dollar: Shop - Roles", + description: "This server has disabled shop roles.", + color: errorColor, + timestamp: new Date(), + footer: { + iconURL: footerIcon, + text: footerText, + }, + }, + ], + }); + } + + if (options?.getSubcommand() === "buy") { + await modules.buy.execute(interaction); + } + + if (options?.getSubcommand() === "cancel") { + await modules.cancel.execute(interaction); + } }; diff --git a/src/plugins/utility/index.ts b/src/plugins/utility/index.ts index b831189..4849a3b 100644 --- a/src/plugins/utility/index.ts +++ b/src/plugins/utility/index.ts @@ -8,33 +8,31 @@ import modules from "../../plugins/utility/modules"; // Handlers import logger from "../../logger"; +export const moduleData = modules; + // Function -export default { - modules, +export const builder = new SlashCommandBuilder() + .setName("utility") + .setDescription("Common utility.") - builder: new SlashCommandBuilder() - .setName("utility") - .setDescription("Common utility.") + .addSubcommand(modules.lookup.builder) + .addSubcommand(modules.about.builder) + .addSubcommand(modules.stats.builder) + .addSubcommand(modules.avatar.builder); - .addSubcommand(modules.lookup.builder) - .addSubcommand(modules.about.builder) - .addSubcommand(modules.stats.builder) - .addSubcommand(modules.avatar.builder), +export const execute = async (interaction: CommandInteraction) => { + const { options } = interaction; - async execute(interaction: CommandInteraction) { - const { options } = interaction; - - switch (options.getSubcommand()) { - case "lookup": - return modules.lookup.execute(interaction); - case "about": - return modules.about.execute(interaction); - case "stats": - return modules.stats.execute(interaction); - case "avatar": - return modules.avatar.execute(interaction); - default: - logger.error(`Unknown subcommand ${options.getSubcommand()}`); - } - }, + switch (options.getSubcommand()) { + case "lookup": + return modules.lookup.execute(interaction); + case "about": + return modules.about.execute(interaction); + case "stats": + return modules.stats.execute(interaction); + case "avatar": + return modules.avatar.execute(interaction); + default: + logger.error(`Unknown subcommand ${options.getSubcommand()}`); + } }; From 75c9fdf43881e8332968b75e198df867ef07a124 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sun, 29 May 2022 19:56:35 +0200 Subject: [PATCH 138/142] =?UTF-8?q?=F0=9F=91=94=20Changed=20to=20transacti?= =?UTF-8?q?ons=20#297?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/helpers/saveUser/index.ts | 43 --------- src/helpers/sleep/index.ts | 8 -- src/plugins/credits/modules/gift/index.ts | 87 +++++++++++-------- .../modules/credits/modules/transfer/index.ts | 73 +++++++++++----- 4 files changed, 101 insertions(+), 110 deletions(-) delete mode 100644 src/helpers/saveUser/index.ts delete mode 100644 src/helpers/sleep/index.ts diff --git a/src/helpers/saveUser/index.ts b/src/helpers/saveUser/index.ts deleted file mode 100644 index 2608bd4..0000000 --- a/src/helpers/saveUser/index.ts +++ /dev/null @@ -1,43 +0,0 @@ -import sleep from "../../helpers/sleep"; -import logger from "../../logger"; -import Chance from "chance"; - -export default async function saveUser(data: any, data2: any) { - process.nextTick( - async () => { - // Chance module - const chance = new Chance(); - - await sleep( - chance.integer({ - min: 0, - max: 1, - }) * - 10 + - 1 * 100 - ); // 100 - 1000 random Number generator - data.save((_: any) => - _ - ? logger?.error( - `ERROR Occurred while saving data (saveUser) \n${"=".repeat( - 50 - )}\n${`${_}\n${"=".repeat(50)}`}` - ) - : logger?.silly(`Saved user: ${data.id} (saveUser)`) - ); - if (data2) { - data2.save((_: any) => - _ - ? logger?.error( - `ERROR Occurred while saving data (saveUser) \n${"=".repeat( - 50 - )}\n${`${_}\n${"=".repeat(50)}`}` - ) - : logger?.silly(`Saved user: ${data2.id} (saveUser)`) - ); - } - }, - data, - data2 - ); -} diff --git a/src/helpers/sleep/index.ts b/src/helpers/sleep/index.ts deleted file mode 100644 index d69f15b..0000000 --- a/src/helpers/sleep/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -import logger from "../../logger"; - -export default function sleep(milliseconds: number) { - return new Promise((resolve) => { - setTimeout(resolve, milliseconds); - logger?.silly(`Sleeping for ${milliseconds} milliseconds`); - }); -} diff --git a/src/plugins/credits/modules/gift/index.ts b/src/plugins/credits/modules/gift/index.ts index 61f4309..9873c02 100644 --- a/src/plugins/credits/modules/gift/index.ts +++ b/src/plugins/credits/modules/gift/index.ts @@ -7,8 +7,7 @@ import getEmbedConfig from "../../../../helpers/getEmbedConfig"; // Handlers import logger from "../../../../logger"; -// Helpers -import saveUser from "../../../../helpers/saveUser"; +import mongoose from "mongoose"; // Models import fetchUser from "../../../../helpers/fetchUser"; @@ -184,53 +183,69 @@ export default { }); } - // Withdraw amount from fromUserDB - fromUserDB.credits -= optionAmount; + const session = await mongoose.startSession(); - // Deposit amount to toUserDB - toUserDB.credits += optionAmount; + session.startTransaction(); - // Save users - await saveUser(fromUserDB, toUserDB).then(async () => { - // Get DM user object - const dmUser = client.users.cache.get(optionUser.id); + try { + // Withdraw amount from fromUserDB + fromUserDB.credits -= optionAmount; - if (dmUser == null) return; + // Deposit amount to toUserDB + toUserDB.credits += optionAmount; - // Send DM to user - await dmUser - .send({ - embeds: [ - embed - .setDescription( - `${ - user.tag - } has gifted you ${optionAmount} credits with reason: ${ - optionReason || "unspecified" - }` - ) - .setColor(successColor), - ], - }) - .catch(async (error) => - logger.error(`[Gift] Error sending DM to user: ${error}`) - ); + await fromUserDB.save(); - logger.silly( - `[Gift] Successfully gifted ${optionAmount} credits to ${optionUser.tag}` - ); + await toUserDB.save(); + + await session.commitTransaction(); + } catch (error) { + await session.abortTransaction(); + session.endSession(); + logger.error(`${error}`); return interaction.editReply({ embeds: [ embed .setDescription( - `Successfully gifted ${optionAmount} credits to ${ - optionUser.tag - } with reason: ${optionReason || "unspecified"}` + "An error occurred while trying to gift credits. Please try again." ) - .setColor(successColor), + .setColor(errorColor), ], }); + } finally { + // ending the session + session.endSession(); + } + + // Get DM user object + const dmUser = client.users.cache.get(optionUser.id); + + if (!dmUser) throw new Error("User not found"); + + // Send DM to user + await dmUser.send({ + embeds: [ + embed + .setDescription( + `${user.tag} has gifted you ${optionAmount} credits with reason: ${ + optionReason || "unspecified" + }` + ) + .setColor(successColor), + ], + }); + + return interaction.editReply({ + embeds: [ + embed + .setDescription( + `Successfully gifted ${optionAmount} credits to ${ + optionUser.tag + } with reason: ${optionReason || "unspecified"}` + ) + .setColor(successColor), + ], }); }, }; diff --git a/src/plugins/manage/modules/credits/modules/transfer/index.ts b/src/plugins/manage/modules/credits/modules/transfer/index.ts index d65667b..011e603 100644 --- a/src/plugins/manage/modules/credits/modules/transfer/index.ts +++ b/src/plugins/manage/modules/credits/modules/transfer/index.ts @@ -1,15 +1,14 @@ // Dependencies import { CommandInteraction, MessageEmbed, Permissions } from "discord.js"; +import mongoose from "mongoose"; + // Configurations import getEmbedConfig from "../../../../../../helpers/getEmbedConfig"; // Handlers import logger from "../../../../../../logger"; -// Helpers -import saveUser from "../../../../../../helpers/saveUser"; - // Models import fetchUser from "../../../../../../helpers/fetchUser"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; @@ -193,38 +192,66 @@ export default { }); } - // Withdraw amount from fromUser - fromUser.credits -= optionAmount; + const session = await mongoose.startSession(); - // Deposit amount to toUser - toUser.credits += optionAmount; + session.startTransaction(); - // Save users - await saveUser(fromUser, toUser)?.then(async () => { - logger?.silly(`Saved users`); + try { + // Withdraw amount from fromUserDB + fromUser.credits -= optionAmount; - return interaction?.editReply({ + // Deposit amount to toUserDB + toUser.credits += optionAmount; + + await fromUser.save(); + + await toUser.save(); + + await session.commitTransaction(); + } catch (error) { + await session.abortTransaction(); + session.endSession(); + logger.error(`${error}`); + + return interaction.editReply({ embeds: [ new MessageEmbed() .setTitle("[:toolbox:] Manage - Credits (Transfer)") - .setDescription(`Transferred ${optionAmount} credits.`) - .addFields( - { - name: `${optionFromUser?.username} Balance`, - value: `${fromUser?.credits}`, - inline: true, - }, - { - name: `${optionToUser?.username} Balance`, - value: `${toUser?.credits}`, - inline: true, - } + .setDescription( + "An error occurred while trying to gift credits. Please try again." ) + .setColor(errorColor) .setTimestamp(new Date()) .setColor(successColor) .setFooter({ text: footerText, iconURL: footerIcon }), ], }); + } finally { + // ending the session + session.endSession(); + } + + return interaction?.editReply({ + embeds: [ + new MessageEmbed() + .setTitle("[:toolbox:] Manage - Credits (Transfer)") + .setDescription(`Transferred ${optionAmount} credits.`) + .addFields( + { + name: `${optionFromUser?.username} Balance`, + value: `${fromUser?.credits}`, + inline: true, + }, + { + name: `${optionToUser?.username} Balance`, + value: `${toUser?.credits}`, + inline: true, + } + ) + .setTimestamp(new Date()) + .setColor(successColor) + .setFooter({ text: footerText, iconURL: footerIcon }), + ], }); }, }; From 5623136fcd9f79fc5670777d3608cc5f7da9df73 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sun, 29 May 2022 20:24:24 +0200 Subject: [PATCH 139/142] =?UTF-8?q?=E2=9C=A8=20Manual=20code=20drops=20#34?= =?UTF-8?q?1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/manage/modules/credits/index.ts | 5 +- .../modules/credits/modules/drop/index.ts | 126 ++++++++++++++++++ .../manage/modules/credits/modules/index.ts | 3 +- 3 files changed, 132 insertions(+), 2 deletions(-) create mode 100644 src/plugins/manage/modules/credits/modules/drop/index.ts diff --git a/src/plugins/manage/modules/credits/index.ts b/src/plugins/manage/modules/credits/index.ts index cd6819b..5e215ec 100644 --- a/src/plugins/manage/modules/credits/index.ts +++ b/src/plugins/manage/modules/credits/index.ts @@ -13,7 +13,8 @@ export const builder = (group: SlashCommandSubcommandGroupBuilder) => { .addSubcommand(modules.give.builder) .addSubcommand(modules.set.builder) .addSubcommand(modules.take.builder) - .addSubcommand(modules.transfer.builder); + .addSubcommand(modules.transfer.builder) + .addSubcommand(modules.drop.builder); }; export const execute = async (interaction: CommandInteraction) => { @@ -26,5 +27,7 @@ export const execute = async (interaction: CommandInteraction) => { return modules.take.execute(interaction); case "transfer": return modules.transfer.execute(interaction); + case "drop": + return modules.drop.execute(interaction); } }; diff --git a/src/plugins/manage/modules/credits/modules/drop/index.ts b/src/plugins/manage/modules/credits/modules/drop/index.ts new file mode 100644 index 0000000..d5129ea --- /dev/null +++ b/src/plugins/manage/modules/credits/modules/drop/index.ts @@ -0,0 +1,126 @@ +// Dependencies +import { CommandInteraction, MessageEmbed, Permissions } from "discord.js"; +import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import { v4 as uuidv4 } from "uuid"; +import axios from "axios"; +import apiSchema from "../../../../../../database/schemas/api"; +import encryption from "../../../../../../handlers/encryption"; + +// Configurations +import getEmbedConfig from "../../../../../../helpers/getEmbedConfig"; + +// Handlers +import logger from "../../../../../../logger"; + +// Helpers +import pluralize from "../../../../../../helpers/pluralize"; + +// Models +import fetchUser from "../../../../../../helpers/fetchUser"; + +// Function +export default { + metadata: { + guildOnly: true, + ephemeral: true, + permissions: [Permissions.FLAGS.MANAGE_GUILD], + }, + + builder: (command: SlashCommandSubcommandBuilder) => { + return command + .setName("drop") + .setDescription("Drop some credits for specified amount of users.") + .addIntegerOption((option) => + option + .setName("uses") + .setDescription("How many users should be able to use this.") + .setRequired(true) + ) + .addIntegerOption((option) => + option + .setName("credit") + .setDescription(`How much credits provided per use.`) + .setRequired(true) + ) + .addChannelOption((option) => + option + .setName("channel") + .setDescription("The channel to send the message to.") + .setRequired(true) + ); + }, + execute: async (interaction: CommandInteraction) => { + if (interaction.guild == null) return; + const { errorColor, successColor, footerText, footerIcon } = + await getEmbedConfig(interaction.guild); // Destructure + const { guild, options } = interaction; + + const uses = options?.getInteger("uses"); + const creditAmount = options?.getInteger("credit"); + const channel = options?.getChannel("channel"); + + if (!uses) throw new Error("Amount of uses is required."); + if (!creditAmount) throw new Error("Amount of credits is required."); + if (!channel) throw new Error("Channel is required."); + + const embed = new MessageEmbed() + .setTitle("[:toolbox:] Drop") + .setFooter({ text: footerText, iconURL: footerIcon }); + + const code = uuidv4(); + + const apiCredentials = await apiSchema?.findOne({ + guildId: guild?.id, + }); + + if (!apiCredentials) return; + + const api = axios?.create({ + baseURL: apiCredentials.url, + headers: { + Authorization: `Bearer ${encryption.decrypt(apiCredentials.token)}`, + }, + }); + + const shopUrl = apiCredentials?.url?.replace("/api", "/store"); + + await api + .post("vouchers", { + uses, + code, + credits: creditAmount, + memo: `${interaction?.createdTimestamp} - ${interaction?.user?.id}`, + }) + .then(async () => { + await interaction.editReply({ + embeds: [ + embed + .setColor(successColor) + .setDescription(`Successfully crated code: ${code}`), + ], + }); + + const discordChannel = guild.channels.cache.get(channel.id); + + if (!discordChannel) return; + + if (discordChannel.type !== "GUILD_TEXT") return; + + discordChannel.send({ + embeds: [ + new MessageEmbed() + .setTitle("[:parachute:] Code Drop!") + .addFields([ + { name: "Code", value: `${code}`, inline: true }, + { name: "Amount", value: `${creditAmount}`, inline: true }, + { name: "Uses", value: `${uses}`, inline: true }, + ]) + .setDescription( + `${interaction.user} dropped a voucher! You can use the code [here](${shopUrl})!` + ) + .setColor(successColor), + ], + }); + }); + }, +}; diff --git a/src/plugins/manage/modules/credits/modules/index.ts b/src/plugins/manage/modules/credits/modules/index.ts index ede5ae7..07b72e6 100644 --- a/src/plugins/manage/modules/credits/modules/index.ts +++ b/src/plugins/manage/modules/credits/modules/index.ts @@ -2,5 +2,6 @@ import give from "./give"; import set from "./set"; import take from "./take"; import transfer from "./transfer"; +import drop from "./drop"; -export default { give, set, take, transfer }; +export default { give, set, take, transfer, drop }; From 0fe4e32fb9a627fc6584f6c7047f49829d55f332 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sun, 29 May 2022 20:45:03 +0200 Subject: [PATCH 140/142] =?UTF-8?q?=F0=9F=9A=B8=20Author=20is=20now=20an?= =?UTF-8?q?=20link?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/fun/modules/meme/index.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/plugins/fun/modules/meme/index.ts b/src/plugins/fun/modules/meme/index.ts index 9134223..c168557 100644 --- a/src/plugins/fun/modules/meme/index.ts +++ b/src/plugins/fun/modules/meme/index.ts @@ -3,7 +3,6 @@ import getEmbedConfig from "../../../../helpers/getEmbedConfig"; import axios from "axios"; import { CommandInteraction, MessageEmbed } from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; -import logger from "../../../../logger"; export default { metadata: { guildOnly: false, ephemeral: false }, @@ -32,7 +31,11 @@ export default { }) .setTitle("[:sweat_smile:] Meme") .addFields([ - { name: "Author", value: content.author, inline: true }, + { + name: "Author", + value: `[${content.author}](https://reddit.com/user/${content.author})`, + inline: true, + }, { name: "Votes", value: `${content.ups}/${content.downs}`, From 825ff53878b93e05b78307bf06fefd0572a9d247 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sun, 29 May 2022 21:33:37 +0200 Subject: [PATCH 141/142] =?UTF-8?q?=F0=9F=9A=9A=20plugins=20are=20now=20co?= =?UTF-8?q?mamnds?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/{plugins => commands}/config/index.ts | 0 .../config/modules/audits/index.ts | 0 .../config/modules/credits/index.ts | 0 .../embeds/components/getValues/index.ts | 0 .../config/modules/embeds/index.ts | 0 .../config/modules/index.ts | 0 .../config/modules/points/index.ts | 0 .../config/modules/pterodactyl/index.ts | 0 .../config/modules/shop/index.ts | 0 .../config/modules/welcome/index.ts | 0 src/{plugins => commands}/counters/index.ts | 2 +- .../counters/modules/index.ts | 0 .../counters/modules/view/index.ts | 0 src/{plugins => commands}/credits/index.ts | 0 .../credits/modules/balance/index.ts | 0 .../credits/modules/gift/index.ts | 0 .../credits/modules/index.ts | 0 .../credits/modules/top/index.ts | 0 .../credits/modules/work/index.ts | 0 src/{plugins => commands}/fun/index.ts | 2 +- .../fun/modules/index.ts | 0 .../fun/modules/meme/index.ts | 0 src/{plugins => commands}/manage/index.ts | 2 +- .../manage/modules/counters/index.ts | 0 .../modules/counters/modules/add/index.ts | 0 .../manage/modules/counters/modules/index.ts | 0 .../modules/counters/modules/remove/index.ts | 0 .../manage/modules/credits/index.ts | 0 .../modules/credits/modules/drop/index.ts | 0 .../modules/credits/modules/give/index.ts | 0 .../manage/modules/credits/modules/index.ts | 0 .../modules/credits/modules/set/index.ts | 0 .../modules/credits/modules/take/index.ts | 0 .../modules/credits/modules/transfer/index.ts | 0 .../manage/modules/index.ts | 0 src/{plugins => commands}/profile/index.ts | 2 +- .../profile/modules/index.ts | 0 .../profile/modules/view.ts | 0 src/{plugins => commands}/reputation/index.ts | 0 .../reputation/modules/give.ts | 0 .../reputation/modules/index.ts | 0 src/{plugins => commands}/shop/index.ts | 0 .../shop/modules/index.ts | 0 .../shop/modules/pterodactyl.ts | 0 .../shop/modules/roles/index.ts | 0 .../shop/modules/roles/modules/buy.ts | 0 .../shop/modules/roles/modules/cancel.ts | 0 .../shop/modules/roles/modules/index.ts | 0 src/{plugins => commands}/utility/index.ts | 2 +- .../utility/modules/about.ts | 0 .../utility/modules/avatar.ts | 0 .../utility/modules/index.ts | 0 .../utility/modules/lookup.ts | 0 .../utility/modules/stats.ts | 0 src/config/example.other.ts | 3 ++ src/handlers/commands.ts | 32 ------------------- src/handlers/deployCommands.ts | 27 ++++++++-------- src/index.ts | 4 +-- src/logger/index.ts | 4 ++- src/managers/command/index.ts | 30 +++++++++++++++++ 60 files changed, 56 insertions(+), 54 deletions(-) rename src/{plugins => commands}/config/index.ts (100%) rename src/{plugins => commands}/config/modules/audits/index.ts (100%) rename src/{plugins => commands}/config/modules/credits/index.ts (100%) rename src/{plugins => commands}/config/modules/embeds/components/getValues/index.ts (100%) rename src/{plugins => commands}/config/modules/embeds/index.ts (100%) rename src/{plugins => commands}/config/modules/index.ts (100%) rename src/{plugins => commands}/config/modules/points/index.ts (100%) rename src/{plugins => commands}/config/modules/pterodactyl/index.ts (100%) rename src/{plugins => commands}/config/modules/shop/index.ts (100%) rename src/{plugins => commands}/config/modules/welcome/index.ts (100%) rename src/{plugins => commands}/counters/index.ts (90%) rename src/{plugins => commands}/counters/modules/index.ts (100%) rename src/{plugins => commands}/counters/modules/view/index.ts (100%) rename src/{plugins => commands}/credits/index.ts (100%) rename src/{plugins => commands}/credits/modules/balance/index.ts (100%) rename src/{plugins => commands}/credits/modules/gift/index.ts (100%) rename src/{plugins => commands}/credits/modules/index.ts (100%) rename src/{plugins => commands}/credits/modules/top/index.ts (100%) rename src/{plugins => commands}/credits/modules/work/index.ts (100%) rename src/{plugins => commands}/fun/index.ts (92%) rename src/{plugins => commands}/fun/modules/index.ts (100%) rename src/{plugins => commands}/fun/modules/meme/index.ts (100%) rename src/{plugins => commands}/manage/index.ts (93%) rename src/{plugins => commands}/manage/modules/counters/index.ts (100%) rename src/{plugins => commands}/manage/modules/counters/modules/add/index.ts (100%) rename src/{plugins => commands}/manage/modules/counters/modules/index.ts (100%) rename src/{plugins => commands}/manage/modules/counters/modules/remove/index.ts (100%) rename src/{plugins => commands}/manage/modules/credits/index.ts (100%) rename src/{plugins => commands}/manage/modules/credits/modules/drop/index.ts (100%) rename src/{plugins => commands}/manage/modules/credits/modules/give/index.ts (100%) rename src/{plugins => commands}/manage/modules/credits/modules/index.ts (100%) rename src/{plugins => commands}/manage/modules/credits/modules/set/index.ts (100%) rename src/{plugins => commands}/manage/modules/credits/modules/take/index.ts (100%) rename src/{plugins => commands}/manage/modules/credits/modules/transfer/index.ts (100%) rename src/{plugins => commands}/manage/modules/index.ts (100%) rename src/{plugins => commands}/profile/index.ts (92%) rename src/{plugins => commands}/profile/modules/index.ts (100%) rename src/{plugins => commands}/profile/modules/view.ts (100%) rename src/{plugins => commands}/reputation/index.ts (100%) rename src/{plugins => commands}/reputation/modules/give.ts (100%) rename src/{plugins => commands}/reputation/modules/index.ts (100%) rename src/{plugins => commands}/shop/index.ts (100%) rename src/{plugins => commands}/shop/modules/index.ts (100%) rename src/{plugins => commands}/shop/modules/pterodactyl.ts (100%) rename src/{plugins => commands}/shop/modules/roles/index.ts (100%) rename src/{plugins => commands}/shop/modules/roles/modules/buy.ts (100%) rename src/{plugins => commands}/shop/modules/roles/modules/cancel.ts (100%) rename src/{plugins => commands}/shop/modules/roles/modules/index.ts (100%) rename src/{plugins => commands}/utility/index.ts (94%) rename src/{plugins => commands}/utility/modules/about.ts (100%) rename src/{plugins => commands}/utility/modules/avatar.ts (100%) rename src/{plugins => commands}/utility/modules/index.ts (100%) rename src/{plugins => commands}/utility/modules/lookup.ts (100%) rename src/{plugins => commands}/utility/modules/stats.ts (100%) delete mode 100644 src/handlers/commands.ts create mode 100644 src/managers/command/index.ts diff --git a/src/plugins/config/index.ts b/src/commands/config/index.ts similarity index 100% rename from src/plugins/config/index.ts rename to src/commands/config/index.ts diff --git a/src/plugins/config/modules/audits/index.ts b/src/commands/config/modules/audits/index.ts similarity index 100% rename from src/plugins/config/modules/audits/index.ts rename to src/commands/config/modules/audits/index.ts diff --git a/src/plugins/config/modules/credits/index.ts b/src/commands/config/modules/credits/index.ts similarity index 100% rename from src/plugins/config/modules/credits/index.ts rename to src/commands/config/modules/credits/index.ts diff --git a/src/plugins/config/modules/embeds/components/getValues/index.ts b/src/commands/config/modules/embeds/components/getValues/index.ts similarity index 100% rename from src/plugins/config/modules/embeds/components/getValues/index.ts rename to src/commands/config/modules/embeds/components/getValues/index.ts diff --git a/src/plugins/config/modules/embeds/index.ts b/src/commands/config/modules/embeds/index.ts similarity index 100% rename from src/plugins/config/modules/embeds/index.ts rename to src/commands/config/modules/embeds/index.ts diff --git a/src/plugins/config/modules/index.ts b/src/commands/config/modules/index.ts similarity index 100% rename from src/plugins/config/modules/index.ts rename to src/commands/config/modules/index.ts diff --git a/src/plugins/config/modules/points/index.ts b/src/commands/config/modules/points/index.ts similarity index 100% rename from src/plugins/config/modules/points/index.ts rename to src/commands/config/modules/points/index.ts diff --git a/src/plugins/config/modules/pterodactyl/index.ts b/src/commands/config/modules/pterodactyl/index.ts similarity index 100% rename from src/plugins/config/modules/pterodactyl/index.ts rename to src/commands/config/modules/pterodactyl/index.ts diff --git a/src/plugins/config/modules/shop/index.ts b/src/commands/config/modules/shop/index.ts similarity index 100% rename from src/plugins/config/modules/shop/index.ts rename to src/commands/config/modules/shop/index.ts diff --git a/src/plugins/config/modules/welcome/index.ts b/src/commands/config/modules/welcome/index.ts similarity index 100% rename from src/plugins/config/modules/welcome/index.ts rename to src/commands/config/modules/welcome/index.ts diff --git a/src/plugins/counters/index.ts b/src/commands/counters/index.ts similarity index 90% rename from src/plugins/counters/index.ts rename to src/commands/counters/index.ts index df23d0b..da17e90 100644 --- a/src/plugins/counters/index.ts +++ b/src/commands/counters/index.ts @@ -2,7 +2,7 @@ import { CommandInteraction } from "discord.js"; import { SlashCommandBuilder } from "@discordjs/builders"; import logger from "../../logger"; -import modules from "../../plugins/counters/modules"; +import modules from "../../commands/counters/modules"; export const builder = new SlashCommandBuilder() .setName("counters") diff --git a/src/plugins/counters/modules/index.ts b/src/commands/counters/modules/index.ts similarity index 100% rename from src/plugins/counters/modules/index.ts rename to src/commands/counters/modules/index.ts diff --git a/src/plugins/counters/modules/view/index.ts b/src/commands/counters/modules/view/index.ts similarity index 100% rename from src/plugins/counters/modules/view/index.ts rename to src/commands/counters/modules/view/index.ts diff --git a/src/plugins/credits/index.ts b/src/commands/credits/index.ts similarity index 100% rename from src/plugins/credits/index.ts rename to src/commands/credits/index.ts diff --git a/src/plugins/credits/modules/balance/index.ts b/src/commands/credits/modules/balance/index.ts similarity index 100% rename from src/plugins/credits/modules/balance/index.ts rename to src/commands/credits/modules/balance/index.ts diff --git a/src/plugins/credits/modules/gift/index.ts b/src/commands/credits/modules/gift/index.ts similarity index 100% rename from src/plugins/credits/modules/gift/index.ts rename to src/commands/credits/modules/gift/index.ts diff --git a/src/plugins/credits/modules/index.ts b/src/commands/credits/modules/index.ts similarity index 100% rename from src/plugins/credits/modules/index.ts rename to src/commands/credits/modules/index.ts diff --git a/src/plugins/credits/modules/top/index.ts b/src/commands/credits/modules/top/index.ts similarity index 100% rename from src/plugins/credits/modules/top/index.ts rename to src/commands/credits/modules/top/index.ts diff --git a/src/plugins/credits/modules/work/index.ts b/src/commands/credits/modules/work/index.ts similarity index 100% rename from src/plugins/credits/modules/work/index.ts rename to src/commands/credits/modules/work/index.ts diff --git a/src/plugins/fun/index.ts b/src/commands/fun/index.ts similarity index 92% rename from src/plugins/fun/index.ts rename to src/commands/fun/index.ts index 758814c..5c71cd2 100644 --- a/src/plugins/fun/index.ts +++ b/src/commands/fun/index.ts @@ -2,7 +2,7 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { CommandInteraction } from "discord.js"; import logger from "../../logger"; -import modules from "../../plugins/fun/modules"; +import modules from "../../commands/fun/modules"; export const builder = new SlashCommandBuilder() .setName("fun") diff --git a/src/plugins/fun/modules/index.ts b/src/commands/fun/modules/index.ts similarity index 100% rename from src/plugins/fun/modules/index.ts rename to src/commands/fun/modules/index.ts diff --git a/src/plugins/fun/modules/meme/index.ts b/src/commands/fun/modules/meme/index.ts similarity index 100% rename from src/plugins/fun/modules/meme/index.ts rename to src/commands/fun/modules/meme/index.ts diff --git a/src/plugins/manage/index.ts b/src/commands/manage/index.ts similarity index 93% rename from src/plugins/manage/index.ts rename to src/commands/manage/index.ts index a54f2e2..14b5f6c 100644 --- a/src/plugins/manage/index.ts +++ b/src/commands/manage/index.ts @@ -3,7 +3,7 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { CommandInteraction } from "discord.js"; // Groups -import modules from "../../plugins/manage/modules"; +import modules from "../../commands/manage/modules"; import logger from "../../logger"; export const moduleData = modules; diff --git a/src/plugins/manage/modules/counters/index.ts b/src/commands/manage/modules/counters/index.ts similarity index 100% rename from src/plugins/manage/modules/counters/index.ts rename to src/commands/manage/modules/counters/index.ts diff --git a/src/plugins/manage/modules/counters/modules/add/index.ts b/src/commands/manage/modules/counters/modules/add/index.ts similarity index 100% rename from src/plugins/manage/modules/counters/modules/add/index.ts rename to src/commands/manage/modules/counters/modules/add/index.ts diff --git a/src/plugins/manage/modules/counters/modules/index.ts b/src/commands/manage/modules/counters/modules/index.ts similarity index 100% rename from src/plugins/manage/modules/counters/modules/index.ts rename to src/commands/manage/modules/counters/modules/index.ts diff --git a/src/plugins/manage/modules/counters/modules/remove/index.ts b/src/commands/manage/modules/counters/modules/remove/index.ts similarity index 100% rename from src/plugins/manage/modules/counters/modules/remove/index.ts rename to src/commands/manage/modules/counters/modules/remove/index.ts diff --git a/src/plugins/manage/modules/credits/index.ts b/src/commands/manage/modules/credits/index.ts similarity index 100% rename from src/plugins/manage/modules/credits/index.ts rename to src/commands/manage/modules/credits/index.ts diff --git a/src/plugins/manage/modules/credits/modules/drop/index.ts b/src/commands/manage/modules/credits/modules/drop/index.ts similarity index 100% rename from src/plugins/manage/modules/credits/modules/drop/index.ts rename to src/commands/manage/modules/credits/modules/drop/index.ts diff --git a/src/plugins/manage/modules/credits/modules/give/index.ts b/src/commands/manage/modules/credits/modules/give/index.ts similarity index 100% rename from src/plugins/manage/modules/credits/modules/give/index.ts rename to src/commands/manage/modules/credits/modules/give/index.ts diff --git a/src/plugins/manage/modules/credits/modules/index.ts b/src/commands/manage/modules/credits/modules/index.ts similarity index 100% rename from src/plugins/manage/modules/credits/modules/index.ts rename to src/commands/manage/modules/credits/modules/index.ts diff --git a/src/plugins/manage/modules/credits/modules/set/index.ts b/src/commands/manage/modules/credits/modules/set/index.ts similarity index 100% rename from src/plugins/manage/modules/credits/modules/set/index.ts rename to src/commands/manage/modules/credits/modules/set/index.ts diff --git a/src/plugins/manage/modules/credits/modules/take/index.ts b/src/commands/manage/modules/credits/modules/take/index.ts similarity index 100% rename from src/plugins/manage/modules/credits/modules/take/index.ts rename to src/commands/manage/modules/credits/modules/take/index.ts diff --git a/src/plugins/manage/modules/credits/modules/transfer/index.ts b/src/commands/manage/modules/credits/modules/transfer/index.ts similarity index 100% rename from src/plugins/manage/modules/credits/modules/transfer/index.ts rename to src/commands/manage/modules/credits/modules/transfer/index.ts diff --git a/src/plugins/manage/modules/index.ts b/src/commands/manage/modules/index.ts similarity index 100% rename from src/plugins/manage/modules/index.ts rename to src/commands/manage/modules/index.ts diff --git a/src/plugins/profile/index.ts b/src/commands/profile/index.ts similarity index 92% rename from src/plugins/profile/index.ts rename to src/commands/profile/index.ts index 808c9e7..2039179 100644 --- a/src/plugins/profile/index.ts +++ b/src/commands/profile/index.ts @@ -3,7 +3,7 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { CommandInteraction } from "discord.js"; // Modules -import modules from "../../plugins/profile/modules"; +import modules from "../../commands/profile/modules"; // Handlers import logger from "../../logger"; diff --git a/src/plugins/profile/modules/index.ts b/src/commands/profile/modules/index.ts similarity index 100% rename from src/plugins/profile/modules/index.ts rename to src/commands/profile/modules/index.ts diff --git a/src/plugins/profile/modules/view.ts b/src/commands/profile/modules/view.ts similarity index 100% rename from src/plugins/profile/modules/view.ts rename to src/commands/profile/modules/view.ts diff --git a/src/plugins/reputation/index.ts b/src/commands/reputation/index.ts similarity index 100% rename from src/plugins/reputation/index.ts rename to src/commands/reputation/index.ts diff --git a/src/plugins/reputation/modules/give.ts b/src/commands/reputation/modules/give.ts similarity index 100% rename from src/plugins/reputation/modules/give.ts rename to src/commands/reputation/modules/give.ts diff --git a/src/plugins/reputation/modules/index.ts b/src/commands/reputation/modules/index.ts similarity index 100% rename from src/plugins/reputation/modules/index.ts rename to src/commands/reputation/modules/index.ts diff --git a/src/plugins/shop/index.ts b/src/commands/shop/index.ts similarity index 100% rename from src/plugins/shop/index.ts rename to src/commands/shop/index.ts diff --git a/src/plugins/shop/modules/index.ts b/src/commands/shop/modules/index.ts similarity index 100% rename from src/plugins/shop/modules/index.ts rename to src/commands/shop/modules/index.ts diff --git a/src/plugins/shop/modules/pterodactyl.ts b/src/commands/shop/modules/pterodactyl.ts similarity index 100% rename from src/plugins/shop/modules/pterodactyl.ts rename to src/commands/shop/modules/pterodactyl.ts diff --git a/src/plugins/shop/modules/roles/index.ts b/src/commands/shop/modules/roles/index.ts similarity index 100% rename from src/plugins/shop/modules/roles/index.ts rename to src/commands/shop/modules/roles/index.ts diff --git a/src/plugins/shop/modules/roles/modules/buy.ts b/src/commands/shop/modules/roles/modules/buy.ts similarity index 100% rename from src/plugins/shop/modules/roles/modules/buy.ts rename to src/commands/shop/modules/roles/modules/buy.ts diff --git a/src/plugins/shop/modules/roles/modules/cancel.ts b/src/commands/shop/modules/roles/modules/cancel.ts similarity index 100% rename from src/plugins/shop/modules/roles/modules/cancel.ts rename to src/commands/shop/modules/roles/modules/cancel.ts diff --git a/src/plugins/shop/modules/roles/modules/index.ts b/src/commands/shop/modules/roles/modules/index.ts similarity index 100% rename from src/plugins/shop/modules/roles/modules/index.ts rename to src/commands/shop/modules/roles/modules/index.ts diff --git a/src/plugins/utility/index.ts b/src/commands/utility/index.ts similarity index 94% rename from src/plugins/utility/index.ts rename to src/commands/utility/index.ts index 4849a3b..6fb52db 100644 --- a/src/plugins/utility/index.ts +++ b/src/commands/utility/index.ts @@ -3,7 +3,7 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { CommandInteraction } from "discord.js"; // Modules -import modules from "../../plugins/utility/modules"; +import modules from "../../commands/utility/modules"; // Handlers import logger from "../../logger"; diff --git a/src/plugins/utility/modules/about.ts b/src/commands/utility/modules/about.ts similarity index 100% rename from src/plugins/utility/modules/about.ts rename to src/commands/utility/modules/about.ts diff --git a/src/plugins/utility/modules/avatar.ts b/src/commands/utility/modules/avatar.ts similarity index 100% rename from src/plugins/utility/modules/avatar.ts rename to src/commands/utility/modules/avatar.ts diff --git a/src/plugins/utility/modules/index.ts b/src/commands/utility/modules/index.ts similarity index 100% rename from src/plugins/utility/modules/index.ts rename to src/commands/utility/modules/index.ts diff --git a/src/plugins/utility/modules/lookup.ts b/src/commands/utility/modules/lookup.ts similarity index 100% rename from src/plugins/utility/modules/lookup.ts rename to src/commands/utility/modules/lookup.ts diff --git a/src/plugins/utility/modules/stats.ts b/src/commands/utility/modules/stats.ts similarity index 100% rename from src/plugins/utility/modules/stats.ts rename to src/commands/utility/modules/stats.ts diff --git a/src/config/example.other.ts b/src/config/example.other.ts index 3a86a51..1695d42 100644 --- a/src/config/example.other.ts +++ b/src/config/example.other.ts @@ -9,3 +9,6 @@ export const hosterName = "someone"; // Hoster Url export const hosterUrl = "scheme://domain.tld"; + +// Winston log level +export const logLevel = "info"; diff --git a/src/handlers/commands.ts b/src/handlers/commands.ts deleted file mode 100644 index 1df02fe..0000000 --- a/src/handlers/commands.ts +++ /dev/null @@ -1,32 +0,0 @@ -import fs from "fs"; // fs -import { Collection, Client } from "discord.js"; // discord.js -import logger from "../logger"; -import { ICommand } from "../interfaces/Command"; - -export default async (client: Client) => { - client.commands = new Collection(); - - fs.readdir("plugins", async (error, plugins) => { - if (error) { - return logger.error(`Error reading plugins: ${error}`); - } - - await Promise.all( - plugins.map(async (pluginName, index) => { - const plugin: ICommand = await import(`../plugins/${pluginName}`); - - await client.commands.set(plugin.builder.name, plugin); - - logger.verbose( - `Loaded plugin ${index + 1}/${plugins.length}: ${pluginName}` - ); - }) - ) - .then(async () => { - logger.info(`Started all ${plugins.length} plugins.`); - }) - .catch(async (err) => { - logger.error(`${err}`); - }); - }); -}; diff --git a/src/handlers/deployCommands.ts b/src/handlers/deployCommands.ts index e0fe066..97c1786 100644 --- a/src/handlers/deployCommands.ts +++ b/src/handlers/deployCommands.ts @@ -2,7 +2,7 @@ import { token, clientId } from "../config/discord"; import { devMode, guildId } from "../config/other"; import logger from "../logger"; -import { Client } from "discord.js"; +import { ApplicationCommandDataResolvable, Client } from "discord.js"; import { REST } from "@discordjs/rest"; import { Routes } from "discord-api-types/v9"; import { RESTPostAPIApplicationCommandsJSONBody } from "discord-api-types/v10"; @@ -10,18 +10,19 @@ import { RESTPostAPIApplicationCommandsJSONBody } from "discord-api-types/v10"; import { ICommand } from "../interfaces/Command"; export default async (client: Client) => { - const pluginList: Array = []; + const commandList: Array = []; + + logger.info("Gathering command list"); await Promise.all( - client.commands.map(async (pluginData: ICommand) => { - pluginList.push(pluginData.builder.toJSON()); - logger.verbose( - `Plugin is ready for deployment: ${pluginData.builder.name}` - ); + client.commands.map(async (commandData: ICommand) => { + commandList.push(commandData.builder.toJSON()); + + logger.verbose(`${commandData.builder.name} pushed to list`); }) ) .then(async () => { - logger.info("All plugins are ready to be deployed."); + logger.info(`Finished gathering command list.`); }) .catch(async (error) => { logger.error(`${error}`); @@ -31,10 +32,10 @@ export default async (client: Client) => { await rest .put(Routes.applicationCommands(clientId), { - body: pluginList, + body: commandList, }) .then(async () => { - logger.info(`Successfully deployed plugins to Discord's API`); + logger.info(`Finished updating command list.`); }) .catch(async (error) => { logger.error(`${error}`); @@ -43,11 +44,9 @@ export default async (client: Client) => { if (devMode) { await rest .put(Routes.applicationGuildCommands(clientId, guildId), { - body: pluginList, + body: commandList, }) - .then(async () => - logger.info(`Successfully deployed guild plugins to Discord's API`) - ) + .then(async () => logger.info(`Finished updating guild command list.`)) .catch(async (error) => { logger.error(`${error}`); }); diff --git a/src/index.ts b/src/index.ts index cad389c..31e3e40 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,7 +7,7 @@ import { Client } from "discord.js"; // discord.js import database from "./database"; import schedules from "./handlers/schedules"; import * as eventManager from "./managers/event"; -import commands from "./handlers/commands"; +import * as commandManager from "./managers/command"; // Main process that starts all other sub processes const main = async () => { @@ -23,7 +23,7 @@ const main = async () => { await schedules(client); // Start command handler - await commands(client); + await commandManager.register(client); // Start event handler await eventManager.register(client); diff --git a/src/logger/index.ts b/src/logger/index.ts index ae96924..1ffbceb 100644 --- a/src/logger/index.ts +++ b/src/logger/index.ts @@ -1,10 +1,12 @@ import winston from "winston"; import "winston-daily-rotate-file"; +import { logLevel } from "../config/other"; + const { combine, timestamp, printf, colorize, align, json } = winston.format; export default winston.createLogger({ - level: process.env.LOG_LEVEL || "silly", + level: logLevel || "info", transports: [ new winston.transports.DailyRotateFile({ filename: "logs/combined-%DATE%.log", diff --git a/src/managers/command/index.ts b/src/managers/command/index.ts new file mode 100644 index 0000000..3cf3316 --- /dev/null +++ b/src/managers/command/index.ts @@ -0,0 +1,30 @@ +import fs from "fs"; // fs +import { Collection, Client } from "discord.js"; // discord.js +import logger from "../../logger"; +import { ICommand } from "../../interfaces/Command"; +import listDir from "../../helpers/listDir"; + +export const register = async (client: Client) => { + client.commands = new Collection(); + + const commandNames = await listDir("commands"); + if (!commandNames) return; + + logger.info(`Loading ${commandNames.length} commands`); + + await Promise.all( + commandNames.map(async (commandName, index) => { + const command: ICommand = await import(`../../commands/${commandName}`); + + client.commands.set(command.builder.name, command); + + logger.verbose(`${command.builder.name} loaded`); + }) + ) + .then(async () => { + logger.info(`Finished loading commands.`); + }) + .catch(async (err) => { + logger.error(`${err}`); + }); +}; From 5bcfafd0ed4ffcd325fa88051c96f12149946df8 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sun, 29 May 2022 21:48:12 +0200 Subject: [PATCH 142/142] =?UTF-8?q?=F0=9F=93=88=20add=20total=20users=20to?= =?UTF-8?q?=20default=20status?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/events/ready/index.ts | 8 +------- src/handlers/deployCommands.ts | 2 +- src/helpers/updatePresence/index.ts | 17 +++++++++++++---- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/events/ready/index.ts b/src/events/ready/index.ts index 61ce106..bd1e060 100644 --- a/src/events/ready/index.ts +++ b/src/events/ready/index.ts @@ -13,15 +13,9 @@ export const options: IEventOptions = { }; export const execute = async (client: Client) => { - logger.info("Ready!"); + logger.info("Discord's API client is ready!"); await updatePresence(client); await devMode(client); await deployCommands(client); - - client.guilds?.cache.forEach((guild) => { - logger.silly( - `${client.user?.tag} (${client.user?.id}) is in guild: ${guild.name} (${guild.id}) with member count of ${guild.memberCount}` - ); - }); }; diff --git a/src/handlers/deployCommands.ts b/src/handlers/deployCommands.ts index 97c1786..2123da7 100644 --- a/src/handlers/deployCommands.ts +++ b/src/handlers/deployCommands.ts @@ -2,7 +2,7 @@ import { token, clientId } from "../config/discord"; import { devMode, guildId } from "../config/other"; import logger from "../logger"; -import { ApplicationCommandDataResolvable, Client } from "discord.js"; +import { Client } from "discord.js"; import { REST } from "@discordjs/rest"; import { Routes } from "discord-api-types/v9"; import { RESTPostAPIApplicationCommandsJSONBody } from "discord-api-types/v10"; diff --git a/src/helpers/updatePresence/index.ts b/src/helpers/updatePresence/index.ts index 3add873..a8c4a35 100644 --- a/src/helpers/updatePresence/index.ts +++ b/src/helpers/updatePresence/index.ts @@ -4,11 +4,20 @@ import logger from "../../logger"; // Function export default async (client: Client) => { - const status = `${client?.guilds?.cache?.size} guilds.`; + if (!client?.user) throw new Error("Client's user is undefined."); - client?.user?.setPresence({ - activities: [{ type: "WATCHING", name: status }], + const { guilds } = client; + + const memberCount = guilds.cache.reduce((a, g) => a + g.memberCount, 0); + + const guildCount = guilds.cache.size; + + const status = `${memberCount} users in ${guildCount} guilds.`; + + client.user.setPresence({ + activities: [{ type: "LISTENING", name: status }], status: "online", }); - logger?.debug(`Updated client presence to: ${status}`); + + logger.info(`Client's presence is set to "${status}"`); };