diff --git a/src/command.ts b/src/command.ts index efc7bcc..18c7d29 100644 --- a/src/command.ts +++ b/src/command.ts @@ -8,6 +8,7 @@ import { CommandInteraction, InteractionReplyOptions, Message, + MessageOptions, MessagePayload, Modal, ModalSubmitInteraction, @@ -85,7 +86,7 @@ export type Command = { aliases: string[]; help_text: string; check: (params: TextCommandParams) => Promise; - run: (params: TextCommandParams) => Promise; + run: (params: TextCommandParams) => Promise; slash_command?: { config: ( x: SlashCommandBuilder, diff --git a/src/commands/users/get_pfp.ts b/src/commands/users/get_pfp.ts new file mode 100644 index 0000000..df25c59 --- /dev/null +++ b/src/commands/users/get_pfp.ts @@ -0,0 +1,49 @@ +import { create_command_for_command_channel } from '../../command'; +import { Client, Guild, MessageEmbed, MessageOptions, MessagePayload, User } from 'discord.js'; + +const commandFunc = async (person_to_get_pfp_from: User) => { + const img = person_to_get_pfp_from.displayAvatarURL({ size: 2048, dynamic: true }); + return new MessageEmbed() + .setTitle(`${person_to_get_pfp_from.username}'s avatar`) + .setImage(img) + .setColor('NOT_QUITE_BLACK') + .setAuthor(person_to_get_pfp_from.username); +}; + +export const command = create_command_for_command_channel( + async ({ message }) => { + if (!message.guild) { + return; + } + const user = message.mentions.users.first(); + if (!user) { + return 'You have to ping the person you want to get the image from'; + } + const embed = await commandFunc(user); + const payload: MessageOptions = { embeds: [embed] }; + return payload; + }, + 'Gets someones pfp', + [], + undefined, + { + config: (x) => + x + .addUserOption((x) => x.setName('user').setRequired(true).setDescription('User you want the pfp from')) + .toJSON(), + func: async ({ interaction }) => { + if (!interaction.guild) { + return; + } + const user = interaction.options.getUser('user'); + if (!user) { + return { ephemeral: true, content: 'You have to supply an user you want the pfp for' }; + } + const embed = await commandFunc(user); + return { + ephemeral: true, + embeds: [embed], + }; + }, + }, +);