From 0dabcc7ff545361895f4a6740fc59d2331f43a06 Mon Sep 17 00:00:00 2001 From: Atridad Lahiji Date: Fri, 4 Aug 2023 23:54:10 -0600 Subject: [PATCH] title --- src/commands/title.ts | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/commands/title.ts diff --git a/src/commands/title.ts b/src/commands/title.ts new file mode 100644 index 0000000..6546b4e --- /dev/null +++ b/src/commands/title.ts @@ -0,0 +1,43 @@ +import { ApplyOptions } from '@sapphire/decorators'; +import { Args, Command } from '@sapphire/framework'; +import { Message } from 'discord.js'; + +@ApplyOptions({ + description: 'This command is the title of your sextape.', + options: ['title'] +}) +export class UserCommand extends Command { + // Register Chat Input and Context Menu command + public override registerApplicationCommands(registry: Command.Registry) { + registry.registerChatInputCommand((builder) => + builder // + .setName(this.name) + .setDescription(this.description) + .addStringOption((option) => option.setName('title').setDescription('The title of your sextape.').setRequired(true)) + ); + } + + // Message command + public async messageRun(message: Message, args: Args) { + return this.titleHandler(message, args.getOption('title') || message.content.split('!title ')[1]); + } + + // Chat Input (slash) command + public async chatInputRun(interaction: Command.ChatInputCommandInteraction) { + return this.titleHandler(interaction, interaction.options.getString('title') || 'NOTHING'); + } + + private async titleHandler( + interactionOrMessage: Message | Command.ChatInputCommandInteraction | Command.ContextMenuCommandInteraction, + title: string + ) { + interactionOrMessage instanceof Message + ? await interactionOrMessage.channel.send({ + content: `${title}: Title of ${interactionOrMessage.author.username}'s sex tape!` + }) + : await interactionOrMessage.reply({ + content: `${title}: Title of ${interactionOrMessage.user.username}'s sex tape!`, + fetchReply: true + }); + } +}