Quik updates
This commit is contained in:
parent
67d51d7322
commit
1173e6e629
2 changed files with 46 additions and 1 deletions
|
@ -34,7 +34,7 @@ export class UserCommand extends Command {
|
|||
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... :(',
|
||||
content: dogData.status === 'success' ? dogData.message : 'Error: I had troubles fetching perfect puppies for you... :(',
|
||||
fetchReply: true
|
||||
});
|
||||
}
|
||||
|
|
45
src/commands/joke.ts
Normal file
45
src/commands/joke.ts
Normal file
|
@ -0,0 +1,45 @@
|
|||
import { ApplyOptions } from '@sapphire/decorators';
|
||||
import { Command } from '@sapphire/framework';
|
||||
import { Message } from 'discord.js';
|
||||
|
||||
@ApplyOptions<Command.Options>({
|
||||
description: 'Dad joke for daddies only!'
|
||||
})
|
||||
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.sendJoke(message);
|
||||
}
|
||||
|
||||
// Chat Input (slash) command
|
||||
public async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
|
||||
return this.sendJoke(interaction);
|
||||
}
|
||||
|
||||
private async sendJoke(interactionOrMessage: Message | Command.ChatInputCommandInteraction | Command.ContextMenuCommandInteraction) {
|
||||
const jokeResponse = await fetch('https://icanhazdadjoke.com/', {
|
||||
headers: {
|
||||
Accept: 'application/json'
|
||||
}
|
||||
});
|
||||
const jokeData = await jokeResponse.json();
|
||||
|
||||
interactionOrMessage instanceof Message
|
||||
? await interactionOrMessage.channel.send({
|
||||
content: jokeData.status === 200 ? jokeData.joke : '404 Joke Not Found'
|
||||
})
|
||||
: await interactionOrMessage.reply({
|
||||
content: jokeData.status === 200 ? jokeData.joke : '404 Joke Not Found',
|
||||
fetchReply: true
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue