/[sudobot]/trunk/src/commands/information/AvatarLookupCommand.ts
ViewVC logotype

Annotation of /trunk/src/commands/information/AvatarLookupCommand.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 297 - (hide annotations)
Mon Jul 29 17:29:25 2024 UTC (8 months, 1 week ago) by rakin
File MIME type: application/typescript
File size: 1977 byte(s)
feat: add a PFP lookup command (#64)
1 rakin 297 import { formatDistanceToNowStrict } from "date-fns";
2     import { Message, Interaction, CacheType, CommandInteraction, Guild, GuildPreview } from "discord.js";
3     import Client from "../../client/Client";
4     import MessageEmbed from "../../client/MessageEmbed";
5     import CommandOptions from "../../types/CommandOptions";
6     import InteractionOptions from "../../types/InteractionOptions";
7     import { emoji } from "../../utils/Emoji";
8     import getUser from "../../utils/getUser";
9     import BaseCommand from "../../utils/structures/BaseCommand";
10    
11     export default class AvatarLookupCommand extends BaseCommand {
12     constructor() {
13     super("avatarlookup", "information", ["avlookup", "pfplookup", "findpfp"]);
14     }
15    
16     async run(client: Client, message: CommandInteraction<CacheType> | Message<boolean>, options: CommandOptions | InteractionOptions): Promise<void> {
17     if (!options.isInteraction && options.args[0] === undefined) {
18     await message.reply(`${emoji('error')} You must provide the user to lookup avatar.`);
19     return;
20     }
21    
22     const user = options.isInteraction ? options.options.getUser("user")! : await getUser(client, message as Message, options, 0);
23    
24     if (!user) {
25     await message.reply(`${emoji('error')} That user does not exist.`);
26     return;
27     }
28    
29     await message.reply({
30     embeds: [
31     new MessageEmbed({
32     author: {
33     name: user.tag,
34     iconURL: user.displayAvatarURL()
35     },
36     description: `Generated Google Search URL: https://images.google.com/searchbyimage?image_url=${encodeURIComponent(user.displayAvatarURL())}`,
37     footer: {
38     text: `Avatar Lookup • ${user.id}`
39     }
40     })
41     .setTimestamp()
42     .setThumbnail(user.displayAvatarURL())
43     ]
44     });
45     }
46     }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26