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 | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 4 | import EmojiEmbed from "../../utils/generateEmojiEmbed.js"; |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 5 | import generateKeyValueList from "../../utils/generateKeyValueList.js"; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame^] | 6 | import client from "../../utils/client.js"; |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 7 | |
| 8 | const command = (builder: SlashCommandSubcommandBuilder) => |
| 9 | builder |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame^] | 10 | .setName("avatar") |
| 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 | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame^] | 14 | const callback = async (interaction: CommandInteraction): Promise<void> => { |
| 15 | const { renderUser } = client.logger; |
| 16 | const member = (interaction.options.getMember("user") || interaction.member) as Discord.GuildMember; |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 17 | await interaction.reply({embeds: [new EmojiEmbed() |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 18 | .setTitle("User Info") |
| 19 | .setStatus("Success") |
| 20 | .setEmoji("MEMBER.JOIN") |
| 21 | .setDescription( |
| 22 | generateKeyValueList({ |
| 23 | "member": renderUser(member.user), |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame^] | 24 | "url": member.user.displayAvatarURL({dynamic: true}) |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 25 | }) |
| 26 | ) |
| 27 | .setImage(await member.user.displayAvatarURL({dynamic: true})) |
| 28 | ], ephemeral: true, fetchReply: true}); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame^] | 29 | }; |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 30 | |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame^] | 31 | const check = (_interaction: CommandInteraction, _defaultCheck: WrappedCheck) => { |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 32 | return true; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame^] | 33 | }; |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 34 | |
| 35 | export { command }; |
| 36 | export { callback }; |
| 37 | export { check }; |