blob: 35c475f6109db3db34558a1554a64e56f00e122a [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 Grey75ea9172022-08-06 10:22:23 +010022 const member = (interaction.options.getMember("user") ||
23 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 )
36 .setImage(await member.user.displayAvatarURL({ dynamic: true }))
37 ],
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 };