add jokes kekw

This commit is contained in:
Ryan Cao 2022-08-30 21:28:56 +08:00
parent 4dd06821d1
commit 8c5b317e11
No known key found for this signature in database
GPG key ID: 528A2C1B6656B97F
3 changed files with 16 additions and 1 deletions

View file

@ -44,6 +44,7 @@ export const reuploadCommands = async () => {
.setRequired(true) .setRequired(true)
) )
.setDefaultMemberPermissions(PermissionFlagsBits.ModerateMembers), .setDefaultMemberPermissions(PermissionFlagsBits.ModerateMembers),
new SlashCommandBuilder().setName('joke').setDescription("it's a joke"),
].map((command) => command.toJSON()); ].map((command) => command.toJSON());
const rest = new REST({ version: '10' }).setToken(process.env.DISCORD_TOKEN!); const rest = new REST({ version: '10' }).setToken(process.env.DISCORD_TOKEN!);

11
src/commands/joke.ts Normal file
View file

@ -0,0 +1,11 @@
import type { CacheType, ChatInputCommandInteraction } from 'discord.js';
export const jokeCommand = async (
i: ChatInputCommandInteraction<CacheType>
) => {
await i.deferReply();
const joke = await fetch('https://icanhazdadjoke.com', {
headers: { Accept: 'text/plain' },
}).then((r) => r.text());
await i.editReply(joke);
};

View file

@ -9,6 +9,7 @@ import { membersCommand } from './commands/members';
import { starsCommand } from './commands/stars'; import { starsCommand } from './commands/stars';
import { modrinthCommand } from './commands/modrinth'; import { modrinthCommand } from './commands/modrinth';
import { tagsCommand } from './commands/tags'; import { tagsCommand } from './commands/tags';
import { jokeCommand } from './commands/joke';
import random from 'just-random'; import random from 'just-random';
import { green, bold, yellow } from 'kleur/colors'; import { green, bold, yellow } from 'kleur/colors';
@ -118,7 +119,9 @@ client.on('interactionCreate', async (interaction) => {
await interaction.channel.send(interaction.options.getString('content')!); await interaction.channel.send(interaction.options.getString('content')!);
await interaction.editReply('I said what you said!'); await interaction.editReply('I said what you said!');
} else if (commandName === 'tag') { } else if (commandName === 'tag') {
tagsCommand(interaction); await tagsCommand(interaction);
} else if (commandName === 'joke') {
await jokeCommand(interaction);
} }
}); });