diff options
Diffstat (limited to 'src/commands/utilities/steal.ts')
-rw-r--r-- | src/commands/utilities/steal.ts | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/src/commands/utilities/steal.ts b/src/commands/utilities/steal.ts index 92abcb2..6298271 100644 --- a/src/commands/utilities/steal.ts +++ b/src/commands/utilities/steal.ts @@ -1,5 +1,5 @@ import { BushCommand, BushMessage } from '@lib'; -import { Emoji } from 'discord.js'; +import { Argument } from 'discord-akairo'; export default class StealCommand extends BushCommand { public constructor() { @@ -14,7 +14,11 @@ export default class StealCommand extends BushCommand { args: [ { id: 'emoji', - customType: util.arg.union('emoji', 'url'), + customType: Argument.union( + /<a?:(?<emojiName>[a-zA-Z0-9_]+):(?<emojiID>\d{15,21})>/gim, //emoji + 'url', + /^(\d{15,21})$/gim //snowflake + ), prompt: { start: 'What emoji would you like to steal?', retry: '{error} Pick a valid emoji.', @@ -29,14 +33,20 @@ export default class StealCommand extends BushCommand { userPermissions: ['SEND_MESSAGES', 'MANAGE_EMOJIS_AND_STICKERS'] }); } - public override async exec(message: BushMessage, args: { emoji?: URL | Emoji; name: string }): Promise<unknown> { + public override async exec( + message: BushMessage, + args: { emoji?: URL | string | { emojiName?: string; emojiID: string }; name: string } + ): Promise<unknown> { if ((!args || !args.emoji) && !message.attachments.size) return await message.util.reply(`${util.emojis.error} You must provide an emoji to steal.`); + client.console.debug(args, 5); const image = - message.attachments.size && message.attachments.first()!.contentType?.includes('image/') + (args?.emoji as any)?.matches && (args?.emoji as any)?.emojiID + ? `https://cdn.discordapp.com/emojis/${(args.emoji as any).emojiID}` + : typeof args.emoji === 'string' + ? `https://cdn.discordapp.com/emojis/${args.emoji}` + : typeof message.attachments.size && message.attachments.first()?.contentType?.includes('image/') ? message.attachments.first()!.url - : args?.emoji instanceof Emoji - ? `https://cdn.discordapp.com/emojis/${args.emoji.id}` : args?.emoji instanceof URL ? args.emoji.href : undefined; @@ -44,9 +54,13 @@ export default class StealCommand extends BushCommand { if (!image) return await message.util.reply(`${util.emojis.error} You must provide an emoji to steal.`); const creationSuccess = await message - .guild!.emojis.create(image, args.name, { - reason: `Stolen by ${message.author.tag} (${message.author.id})` - }) + .guild!.emojis.create( + image, + args.name === 'stolen emoji' && (args?.emoji as any)?.emojiName ? (args?.emoji as any)?.emojiName : args.name, + { + reason: `Stolen by ${message.author.tag} (${message.author.id})` + } + ) .catch((e: Error) => e); if (!(creationSuccess instanceof Error)) |