diff --git a/src/commands/leaderboard.ts b/src/commands/leaderboard.ts new file mode 100644 index 0000000..2e80748 --- /dev/null +++ b/src/commands/leaderboard.ts @@ -0,0 +1,48 @@ +import { Command, CommandBuilder, CommandClient, CommandInteraction, Constants, SlashCommand } from "athena-prime"; +import { getHighestPets, getUser } from "../utils"; + +// ---------- + +@SlashCommand( + new CommandBuilder('leaderboard', 'Get the petting leaderboard.') + .setIntegrationTypes(Constants.ApplicationIntegrationType.GuildInstall) + .setContexts(Constants.InteractionContextType.Guild) + .setCommandType(Constants.ApplicationCommandType.ChatInput) +) +class LeaderboardCommand extends Command { + cooldown = 15; + + async handleCommand(context: CommandClient, interaction: CommandInteraction) { + await interaction.defer(); + + const _data = await getHighestPets(); + const description = _data.length + ? _data + .map((entry, index) => + `**${index + 1}.** <@${entry.userId}> — **${entry.pets.toLocaleString()}** pets!` + ) + .join('\n') + : 'Nobody has any pets yet!'; + + await interaction.createMessage({ + embeds: [{ + author: { + name: interaction.user.username, + icon_url: interaction.user.avatarURL + }, + + color: 0xe77ed1, + + title: "Pond's Petting Leaderboard", + description: description, + + footer: { + text: `Made by nxbat @ Archwing`, + icon_url: 'https://femboytrain.ing/nxbat-archwing' + } + }] + }); + } +} + +export default new LeaderboardCommand('leaderboard');