pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame^] | 1 | import Discord, { CommandInteraction } from "discord.js"; |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 2 | import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; |
| 3 | import { WrappedCheck } from "jshaiku"; |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame^] | 4 | import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js"; |
| 5 | import getEmojiByName from "../../utils/getEmojiByName.js"; |
| 6 | import generateKeyValueList from "../../utils/generateKeyValueList.js"; |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 7 | |
| 8 | const command = (builder: SlashCommandSubcommandBuilder) => |
| 9 | builder |
| 10 | .setName("avatar") |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame^] | 11 | .setDescription("Shows the avatar of a user") |
| 12 | .addUserOption(option => option.setName("user").setDescription("The user to get the avatar of | Default: Yourself")) |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 13 | |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame^] | 14 | const callback = async (interaction: CommandInteraction) => { |
| 15 | // @ts-ignore |
| 16 | const { renderUser } = interaction.client.logger |
| 17 | let member = (interaction.options.getMember("user") || interaction.member) as Discord.GuildMember; |
| 18 | await interaction.reply({embeds: [new generateEmojiEmbed() |
| 19 | .setTitle("User Info") |
| 20 | .setStatus("Success") |
| 21 | .setEmoji("MEMBER.JOIN") |
| 22 | .setDescription( |
| 23 | generateKeyValueList({ |
| 24 | "member": renderUser(member.user), |
| 25 | "url": member.user.displayAvatarURL({dynamic: true}), |
| 26 | }) |
| 27 | ) |
| 28 | .setImage(await member.user.displayAvatarURL({dynamic: true})) |
| 29 | ], ephemeral: true, fetchReply: true}); |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => { |
| 33 | return true; |
| 34 | } |
| 35 | |
| 36 | export { command }; |
| 37 | export { callback }; |
| 38 | export { check }; |