|
| 1 | +import { ApplicationCommandOption, CommandContext, CommandOptionType, SlashCreator } from 'slash-create'; |
| 2 | +import { GenerationCommand } from '../../../imgsrv/abstracts'; |
| 3 | +import { BlurplePayload } from '../../../imgsrv/payload'; |
| 4 | +import { find } from '../../../media'; |
| 5 | + |
| 6 | +const filterOptions: ApplicationCommandOption[] = [ |
| 7 | + { |
| 8 | + name: 'media', |
| 9 | + type: CommandOptionType.STRING, |
| 10 | + description: 'Can be a URL or an emoji. Use the "avatar" option to get an avatar.' |
| 11 | + }, |
| 12 | + { |
| 13 | + name: 'avatar', |
| 14 | + type: CommandOptionType.USER, |
| 15 | + description: 'Use the avatar of the given user, defaults to the last posted image.' |
| 16 | + }, |
| 17 | + { |
| 18 | + name: 'gif', |
| 19 | + type: CommandOptionType.BOOLEAN, |
| 20 | + description: 'Whether to export a GIF in this filter.' |
| 21 | + } |
| 22 | +]; |
| 23 | + |
| 24 | +export default class Duotone extends GenerationCommand { |
| 25 | + constructor(creator: SlashCreator) { |
| 26 | + super(creator, { |
| 27 | + name: 'duotone', |
| 28 | + description: 'Use a duotone filter on an image.', |
| 29 | + options: [ |
| 30 | + { |
| 31 | + name: 'blurple', |
| 32 | + type: CommandOptionType.SUB_COMMAND, |
| 33 | + description: 'Blurpify things!', |
| 34 | + options: [ |
| 35 | + ...filterOptions, |
| 36 | + { |
| 37 | + name: 'new_color', |
| 38 | + type: CommandOptionType.BOOLEAN, |
| 39 | + description: 'Whether to use the new blurple color in the filter.' |
| 40 | + } |
| 41 | + ] |
| 42 | + }, |
| 43 | + { |
| 44 | + name: 'fireengine', |
| 45 | + type: CommandOptionType.SUB_COMMAND, |
| 46 | + description: 'Mixing the fire.', |
| 47 | + options: filterOptions |
| 48 | + }, |
| 49 | + { |
| 50 | + name: 'honeyglow', |
| 51 | + type: CommandOptionType.SUB_COMMAND, |
| 52 | + description: 'Sweet honey.', |
| 53 | + options: filterOptions |
| 54 | + }, |
| 55 | + { |
| 56 | + name: 'mtndew', |
| 57 | + type: CommandOptionType.SUB_COMMAND, |
| 58 | + description: 'Do the dew.', |
| 59 | + options: filterOptions |
| 60 | + } |
| 61 | + ], |
| 62 | + throttling: { |
| 63 | + usages: 1, |
| 64 | + duration: 10 |
| 65 | + } |
| 66 | + }); |
| 67 | + } |
| 68 | + |
| 69 | + async run(ctx: CommandContext) { |
| 70 | + const endpoint = ctx.subcommands[0]; |
| 71 | + |
| 72 | + const user = ctx.users.first() || ctx.user; |
| 73 | + const media = ctx.options.media as string; |
| 74 | + |
| 75 | + const result = await find(user, media, ctx, ctx.users.size === 1); |
| 76 | + const payload: BlurplePayload = { image: result.url }; |
| 77 | + |
| 78 | + // Define special options |
| 79 | + if (ctx.options.blurple?.new_color) payload.new_color = true; |
| 80 | + |
| 81 | + return this.generate(ctx, payload, endpoint); |
| 82 | + } |
| 83 | +} |
0 commit comments