diff --git a/src/modules/command/command.abstract.ts b/src/modules/command/command.abstract.ts index dabb011..4782301 100644 --- a/src/modules/command/command.abstract.ts +++ b/src/modules/command/command.abstract.ts @@ -6,7 +6,9 @@ import { } from 'discord.js'; export abstract class ACommand { - data: SlashCommandBuilder; + data: + | SlashCommandBuilder + | Omit; public abstract execute( arg: Interaction | CommandInteraction, diff --git a/src/modules/command/command.module.ts b/src/modules/command/command.module.ts index 37503f2..8866f6a 100644 --- a/src/modules/command/command.module.ts +++ b/src/modules/command/command.module.ts @@ -9,6 +9,7 @@ import { CoinflipCommand } from './commands/coinflip'; import { GoldCommand } from './commands/gold'; import SomeoneOnceSaidCommand from './commands/someone-once-said'; import { SomeoneOnceSaidModule } from '../someone-once-said/modules/someone-once-said.module'; +import GetRandomQuote from './commands/get-a-quote'; @Module({ providers: [ @@ -21,6 +22,7 @@ import { SomeoneOnceSaidModule } from '../someone-once-said/modules/someone-once CoinflipCommand, GoldCommand, SomeoneOnceSaidCommand, + GetRandomQuote, ], imports: [SomeoneOnceSaidModule], exports: [CommandService], diff --git a/src/modules/command/command.service.ts b/src/modules/command/command.service.ts index edb75d9..c8c7eeb 100644 --- a/src/modules/command/command.service.ts +++ b/src/modules/command/command.service.ts @@ -7,6 +7,7 @@ import { BugReport } from './commands/bug'; import { CoinflipCommand } from './commands/coinflip'; import { GoldCommand } from './commands/gold'; import SomeoneOnceSaidCommand from './commands/someone-once-said'; +import GetRandomQuote from './commands/get-a-quote'; @Injectable() export class CommandService { @@ -21,6 +22,7 @@ export class CommandService { coinflipModule: CoinflipCommand, goldModule: GoldCommand, someoneOnceSaidModule: SomeoneOnceSaidCommand, + getRandomQuoteModule: GetRandomQuote, ) { const commands: ACommand[] = [ //pingpongModule, @@ -31,6 +33,7 @@ export class CommandService { coinflipModule, goldModule, someoneOnceSaidModule, + getRandomQuoteModule, ]; commands.forEach((command) => { if (command.data.name && command.execute) { diff --git a/src/modules/command/commands/get-a-quote.ts b/src/modules/command/commands/get-a-quote.ts new file mode 100644 index 0000000..d94614d --- /dev/null +++ b/src/modules/command/commands/get-a-quote.ts @@ -0,0 +1,36 @@ +import { + CacheType, + CommandInteraction, + EmbedBuilder, + SlashCommandBuilder, +} from 'discord.js'; +import { ACommand } from '../command.abstract'; +import { SomeoneOnceSaidService } from '../../someone-once-said/services/someone-once-said.service'; +import { Inject } from '@nestjs/common'; + +export default class GetRandomQuote extends ACommand { + constructor( + @Inject(SomeoneOnceSaidService) + private readonly someoneonceSaidService: SomeoneOnceSaidService, + ) { + super(); + } + data = new SlashCommandBuilder() + .setName('randomquote') + .setDescription('get a random quote of a user'); + + async execute(arg: CommandInteraction): Promise { + const someoneOnceSaid = await this.someoneonceSaidService.getRandomQuote(); + if (!someoneOnceSaid) return; + const quoteEmbed = new EmbedBuilder() + .setTitle( + `${someoneOnceSaid.secName ?? someoneOnceSaid.username} once said 🤓`, + ) + .setDescription(someoneOnceSaid.phrase) + .setFooter({ + text: someoneOnceSaid?.secName ?? someoneOnceSaid.username, + }) + .setTimestamp(someoneOnceSaid.createdAt); + arg.reply({ embeds: [quoteEmbed] }); + } +} diff --git a/src/modules/command/commands/someone-once-said.ts b/src/modules/command/commands/someone-once-said.ts index 650a110..d753cd8 100644 --- a/src/modules/command/commands/someone-once-said.ts +++ b/src/modules/command/commands/someone-once-said.ts @@ -17,8 +17,11 @@ export default class SomeoneOnceSaidCommand extends ACommand { super(); } data = new SlashCommandBuilder() - .setName('Quote') - .setDescription('Make it a quote'); + .setName('quote') + .setDescription('Make it a quote') + .addStringOption((option) => + option.setName('phrase').setDescription('What was said'), + ); async execute(arg: CommandInteraction): Promise { let phrase = arg.options.get('phrase');