diff --git a/src/_reupload.ts b/src/_reupload.ts index 42dd2e4..4d7fba7 100644 --- a/src/_reupload.ts +++ b/src/_reupload.ts @@ -44,6 +44,7 @@ export const reuploadCommands = async () => { .setRequired(true) ) .setDefaultMemberPermissions(PermissionFlagsBits.ModerateMembers), + new SlashCommandBuilder().setName('joke').setDescription("it's a joke"), ].map((command) => command.toJSON()); const rest = new REST({ version: '10' }).setToken(process.env.DISCORD_TOKEN!); diff --git a/src/commands/joke.ts b/src/commands/joke.ts new file mode 100644 index 0000000..b0f9a34 --- /dev/null +++ b/src/commands/joke.ts @@ -0,0 +1,11 @@ +import type { CacheType, ChatInputCommandInteraction } from 'discord.js'; + +export const jokeCommand = async ( + i: ChatInputCommandInteraction +) => { + await i.deferReply(); + const joke = await fetch('https://icanhazdadjoke.com', { + headers: { Accept: 'text/plain' }, + }).then((r) => r.text()); + await i.editReply(joke); +}; diff --git a/src/index.ts b/src/index.ts index 90d4d62..b3565c2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -9,6 +9,7 @@ import { membersCommand } from './commands/members'; import { starsCommand } from './commands/stars'; import { modrinthCommand } from './commands/modrinth'; import { tagsCommand } from './commands/tags'; +import { jokeCommand } from './commands/joke'; import random from 'just-random'; 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.editReply('I said what you said!'); } else if (commandName === 'tag') { - tagsCommand(interaction); + await tagsCommand(interaction); + } else if (commandName === 'joke') { + await jokeCommand(interaction); } });