pissbot-9000/commands/interaction/subcommands/tts/moonbase.js
derpystuff cc37d5f50b - make tts use subcommands
- add moonbase
2023-04-19 00:47:45 +02:00

40 lines
No EOL
1.3 KiB
JavaScript

const { Constants } = require('detritus-client');
const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = Constants;
const { moonbase } = require('../../../../labscore/api');
const { createEmbed } = require('../../../../labscore/utils/embed');
const { icon, highlight } = require('../../../../labscore/utils/markdown');
module.exports = {
description: 'Moonbase Alpha text to speech voices',
name: 'moonbase',
type: ApplicationCommandOptionTypes.SUB_COMMAND,
options: [
{
name: 'text',
description: 'Text',
type: ApplicationCommandOptionTypes.STRING,
required: true,
maxLength: 1024
}
],
run: async (context, args) => {
try {
await context.respond({ data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE })
let audio = await moonbase(context, args.text, args.voice)
await context.editOrRespond({
embeds: [createEmbed("defaultNoFooter", context, { description: `${icon("audio")} Audio Generated in ${highlight(audio.timings + "s")}.` })],
file: { value: audio.response.body, filename: "moonbase.wav" }
})
} catch (e) {
console.log(e)
await context.editOrRespond({
embeds: [createEmbed("error", context, "Unable to generate audio file.")]
})
}
},
};