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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26