From cffa0ea718d240456440748d95407a1ecc875a27 Mon Sep 17 00:00:00 2001 From: Supositware Date: Wed, 17 Aug 2022 16:22:59 +0200 Subject: [PATCH] List donator command --- commands/utility/donator.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 commands/utility/donator.js diff --git a/commands/utility/donator.js b/commands/utility/donator.js new file mode 100644 index 00000000..a65a4986 --- /dev/null +++ b/commands/utility/donator.js @@ -0,0 +1,30 @@ +import { SlashCommandBuilder } from '@discordjs/builders'; +import db from '../../models/index.js'; +const donator = db.donator; + +export default { + data: new SlashCommandBuilder() + .setName('donator') + .setDescription('All the people who donated for this bot <3'), + async execute(interaction) { + await interaction.deferReply(); + const client = interaction.client; + const Donator = await donator.findAll({ order: ['id'] }); + + let donatorMessage = 'Thanks to:\n'; + + if (Donator[0]) { + for (let i = 0; i < Donator.length; i++) { + const user = await client.users.fetch(Donator[i].get('userID').toString()); + if (user !== null) {donatorMessage += `**${user.tag} (${user.id}) | ${Donator[i].get('comment')}**\n`;} + else {donatorMessage += `**A user of discord (${user.id}) | ${Donator[i].get('comment')} (This user no longer share a server with the bot)**\n`;} + + } + } + else { + donatorMessage += 'No one :('; + } + + return interaction.editReply(donatorMessage); + }, +};