From a2e5f1545ad7d7c15256783adeb5e6edd54f6b4d Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sun, 17 Apr 2022 23:05:13 +0200 Subject: [PATCH 001/108] =?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/108] =?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/108] =?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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] =?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/108] =?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/108] =?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/108] =?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/108] =?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/108] =?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/108] =?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/108] 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/108] 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/108] 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/108] 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/108] 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/108] =?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/108] =?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/108] =?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/108] :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/108] =?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/108] =?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/108] =?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/108] 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/108] 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/108] 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/108] 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/108] =?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/108] 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/108] 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/108] =?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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] =?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/108] =?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/108] =?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/108] =?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/108] 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/108] 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/108] 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/108] =?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/108] =?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/108] =?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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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/108] 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 21e2edd1f51ba2373297b8d127534f9c3ee8ce03 Mon Sep 17 00:00:00 2001 From: snyk-bot Date: Thu, 19 May 2022 07:51:58 +0000 Subject: [PATCH 108/108] 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",