random doggo
This commit is contained in:
parent
8c97e6c0dc
commit
298f4240e2
1 changed files with 42 additions and 0 deletions
42
src/commands/borf.ts
Normal file
42
src/commands/borf.ts
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
import { ApplyOptions } from '@sapphire/decorators';
|
||||||
|
import { Command } from '@sapphire/framework';
|
||||||
|
import { Message } from 'discord.js';
|
||||||
|
|
||||||
|
@ApplyOptions<Command.Options>({
|
||||||
|
description: 'Borf! Borf!'
|
||||||
|
})
|
||||||
|
export class UserCommand extends Command {
|
||||||
|
// Register Chat Input and Context Menu command
|
||||||
|
public override registerApplicationCommands(registry: Command.Registry) {
|
||||||
|
// Register Chat Input command
|
||||||
|
registry.registerChatInputCommand({
|
||||||
|
name: this.name,
|
||||||
|
description: this.description
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Message command
|
||||||
|
public async messageRun(message: Message) {
|
||||||
|
return this.sendPing(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Chat Input (slash) command
|
||||||
|
public async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
|
||||||
|
return this.sendPing(interaction);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async sendPing(interactionOrMessage: Message | Command.ChatInputCommandInteraction | Command.ContextMenuCommandInteraction) {
|
||||||
|
const dogResponse = await fetch('https://dog.ceo/api/breeds/image/random');
|
||||||
|
const dogData = await dogResponse.json();
|
||||||
|
console.log(dogData);
|
||||||
|
|
||||||
|
interactionOrMessage instanceof Message
|
||||||
|
? await interactionOrMessage.channel.send({
|
||||||
|
content: dogData.status === 'success' ? dogData.message : 'Error: I had troubles fetching perfect puppies for you... :('
|
||||||
|
})
|
||||||
|
: await interactionOrMessage.reply({
|
||||||
|
content: 'success' ? dogData.message : 'Error: I had troubles fetching perfect puppies for you... :(',
|
||||||
|
fetchReply: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue