blob: 8f327a567c3f4cf99cbf09641c4a3b1f994c0de0 [file] [log] [blame]
pineafan377794f2022-04-18 19:01:01 +01001import Discord, { CommandInteraction } from "discord.js";
pineafan4f164f32022-02-26 22:07:12 +00002import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
3import { WrappedCheck } from "jshaiku";
pineafan4edb7762022-06-26 19:21:04 +01004import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
pineafan377794f2022-04-18 19:01:01 +01005import generateKeyValueList from "../../utils/generateKeyValueList.js";
pineafan63fc5e22022-08-04 22:04:10 +01006import client from "../../utils/client.js";
pineafan4f164f32022-02-26 22:07:12 +00007
8const command = (builder: SlashCommandSubcommandBuilder) =>
9 builder
pineafan63fc5e22022-08-04 22:04:10 +010010 .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"));
pineafan4f164f32022-02-26 22:07:12 +000013
pineafan63fc5e22022-08-04 22:04:10 +010014const callback = async (interaction: CommandInteraction): Promise<void> => {
15 const { renderUser } = client.logger;
16 const member = (interaction.options.getMember("user") || interaction.member) as Discord.GuildMember;
pineafan4edb7762022-06-26 19:21:04 +010017 await interaction.reply({embeds: [new EmojiEmbed()
pineafan377794f2022-04-18 19:01:01 +010018 .setTitle("User Info")
19 .setStatus("Success")
20 .setEmoji("MEMBER.JOIN")
21 .setDescription(
22 generateKeyValueList({
23 "member": renderUser(member.user),
pineafan63fc5e22022-08-04 22:04:10 +010024 "url": member.user.displayAvatarURL({dynamic: true})
pineafan377794f2022-04-18 19:01:01 +010025 })
26 )
27 .setImage(await member.user.displayAvatarURL({dynamic: true}))
28 ], ephemeral: true, fetchReply: true});
pineafan63fc5e22022-08-04 22:04:10 +010029};
pineafan4f164f32022-02-26 22:07:12 +000030
pineafan63fc5e22022-08-04 22:04:10 +010031const check = (_interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
pineafan4f164f32022-02-26 22:07:12 +000032 return true;
pineafan63fc5e22022-08-04 22:04:10 +010033};
pineafan4f164f32022-02-26 22:07:12 +000034
35export { command };
36export { callback };
37export { check };