Skip to content

Commit

Permalink
add command to get someones pfp
Browse files Browse the repository at this point in the history
  • Loading branch information
lenscas committed Oct 20, 2023
1 parent fa0fe81 commit d9aab88
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
CommandInteraction,
InteractionReplyOptions,
Message,
MessageOptions,
MessagePayload,
Modal,
ModalSubmitInteraction,
Expand Down Expand Up @@ -85,7 +86,7 @@ export type Command = {
aliases: string[];
help_text: string;
check: (params: TextCommandParams) => Promise<boolean>;
run: (params: TextCommandParams) => Promise<void | string>;
run: (params: TextCommandParams) => Promise<void | string | MessagePayload | MessageOptions>;
slash_command?: {
config: (
x: SlashCommandBuilder,
Expand Down
49 changes: 49 additions & 0 deletions src/commands/users/get_pfp.ts
Original file line number Diff line number Diff line change
@@ -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],
};
},
},
);

0 comments on commit d9aab88

Please sign in to comment.