pissbot-9000/commands/interaction/slash/fun/otter.js
2024-06-11 23:16:40 +02:00

45 lines
No EOL
1 KiB
JavaScript

const { otter } = require('#api');
const { createEmbed } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { editOrReply } = require('#utils/message')
const { ApplicationCommandOptionTypes } = require("detritus-client/lib/constants");
module.exports = {
description: 'Shows a random otter picture.',
name: 'otter',
contexts: [
0,
1,
2
],
integrationTypes: [
1
],
options: [
{
name: 'incognito',
description: 'Makes the response only visible to you.',
type: ApplicationCommandOptionTypes.BOOLEAN,
required: false,
default: false
}
],
run: async (context, args) => {
await acknowledge(context, args.incognito);
try{
const ott = (await otter()).response.body
return editOrReply(context, createEmbed("default", context, {
image: {
url: ott.url
}
}))
}catch(e){
console.log(e)
return editOrReply(context, createEmbed("error", context, `Unable to fetch otter.`))
}
}
};