blob: 502e9c815dd5428c483e595ac5c46f63ea2f5d13 [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")
Skyler Grey75ea9172022-08-06 10:22:23 +010012 .addUserOption((option) =>
13 option
14 .setName("user")
15 .setDescription(
16 "The user to get the avatar of | Default: Yourself"
17 )
18 );
pineafan4f164f32022-02-26 22:07:12 +000019
pineafan63fc5e22022-08-04 22:04:10 +010020const callback = async (interaction: CommandInteraction): Promise<void> => {
21 const { renderUser } = client.logger;
Skyler Greyc634e2b2022-08-06 17:50:48 +010022 const member = (interaction.options.getMember("user") ??
Skyler Grey75ea9172022-08-06 10:22:23 +010023 interaction.member) as Discord.GuildMember;
24 await interaction.reply({
25 embeds: [
26 new EmojiEmbed()
27 .setTitle("User Info")
28 .setStatus("Success")
29 .setEmoji("MEMBER.JOIN")
30 .setDescription(
31 generateKeyValueList({
32 member: renderUser(member.user),
33 url: member.user.displayAvatarURL({ dynamic: true })
34 })
35 )
Skyler Greyc634e2b2022-08-06 17:50:48 +010036 .setImage(member.user.displayAvatarURL({ dynamic: true }))
Skyler Grey75ea9172022-08-06 10:22:23 +010037 ],
38 ephemeral: true,
39 fetchReply: true
40 });
pineafan63fc5e22022-08-04 22:04:10 +010041};
pineafan4f164f32022-02-26 22:07:12 +000042
Skyler Grey75ea9172022-08-06 10:22:23 +010043const check = (
44 _interaction: CommandInteraction,
45 _defaultCheck: WrappedCheck
46) => {
pineafan4f164f32022-02-26 22:07:12 +000047 return true;
pineafan63fc5e22022-08-04 22:04:10 +010048};
pineafan4f164f32022-02-26 22:07:12 +000049
50export { command };
51export { callback };
Skyler Grey75ea9172022-08-06 10:22:23 +010052export { check };