/[sudobot]/branches/2.x/src/commands/information/EmojiCommand.ts
ViewVC logotype

Contents of /branches/2.x/src/commands/information/EmojiCommand.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 577 - (show annotations)
Mon Jul 29 18:52:37 2024 UTC (8 months ago) by rakinar2
File MIME type: application/typescript
File size: 2801 byte(s)
chore: add old version archive branches (2.x to 9.x-dev)
1 import { CommandInteraction, Emoji, Message } from 'discord.js';
2 import BaseCommand from '../../utils/structures/BaseCommand';
3 import DiscordClient from '../../client/Client';
4 import CommandOptions from '../../types/CommandOptions';
5 import InteractionOptions from '../../types/InteractionOptions';
6 import axios from 'axios';
7 import path from 'path';
8 import { deleteFile, download, timeSince } from '../../utils/util';
9 import MessageEmbed from '../../client/MessageEmbed';
10
11 export default class EmojiCommand extends BaseCommand {
12 supportsInteractions: boolean = true;
13
14 constructor() {
15 super('emoji', 'information', []);
16 }
17
18 async run(client: DiscordClient, msg: Message | CommandInteraction, options: CommandOptions | InteractionOptions) {
19 if (!options.isInteraction && options.args[0] === undefined) {
20 await msg.reply({
21 embeds: [
22 new MessageEmbed()
23 .setColor('#f14a60')
24 .setDescription(':x: This command requires at least one argument.')
25 ]
26 });
27
28 return;
29 }
30
31 let emojiString: string;
32
33 if (options.isInteraction) {
34 emojiString = await <string> options.options.getString('emoji');
35 }
36 else {
37 emojiString = options.args[0];
38 }
39
40 if (emojiString.startsWith('<:') && emojiString.endsWith('>')) {
41 console.log(emojiString);
42 emojiString = emojiString.substring(2, emojiString.length - 1);
43 }
44
45 const emoji = await client.emojis.cache.find(e => e.name === emojiString || e.identifier === emojiString);
46
47 if (!emoji) {
48 await msg.reply({
49 embeds: [
50 new MessageEmbed()
51 .setColor('#f14a60')
52 .setDescription('No emoji found or not a guild based emoji!')
53 ]
54 });
55
56 return;
57 }
58
59 await msg.reply({
60 embeds: [
61 new MessageEmbed()
62 .setAuthor({
63 name: emoji.guild.name,
64 iconURL: emoji.guild.iconURL()!,
65 })
66 .setTitle(emoji.name ?? 'Emoji Information')
67 .addField('Name', emoji.name ?? '*No name set*')
68 .addField('Identifier', emoji.identifier ?? '*No identifier set*')
69 .addField('Available', emoji.available ? 'Yes' : 'No')
70 .addField('Created at', timeSince(emoji.createdAt.getTime()))
71 .addField('Download', `[Click here](${emoji.url})`)
72 .setImage(emoji.url)
73 .setFooter({
74 text: `ID: ${emoji.id}`
75 })
76 ]
77 });
78 }
79 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26