mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-21 04:17:03 -04:00
improved tiktok command
This commit is contained in:
parent
ba73854391
commit
1927c4a6e8
13 changed files with 754 additions and 45 deletions
56
commands/interaction/subcommands/tts/tiktok/indonesian.js
Normal file
56
commands/interaction/subcommands/tts/tiktok/indonesian.js
Normal file
|
@ -0,0 +1,56 @@
|
|||
const { Constants } = require('detritus-client');
|
||||
const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = Constants;
|
||||
|
||||
const { tiktok } = require('../../../../../labscore/api');
|
||||
|
||||
const { createEmbed } = require('../../../../../labscore/utils/embed');
|
||||
const { icon, highlight } = require('../../../../../labscore/utils/markdown');
|
||||
const { TIKTOK_VOICES_INDONESIAN } = require('../../../../../labscore/constants');
|
||||
|
||||
let voices = []
|
||||
for(const k of Object.keys(TIKTOK_VOICES_INDONESIAN)) voices.unshift({
|
||||
value: k,
|
||||
name: TIKTOK_VOICES_INDONESIAN[k]
|
||||
})
|
||||
|
||||
module.exports = {
|
||||
description: 'Voices of Indonesian TikTok Characters.',
|
||||
name: 'indonesian',
|
||||
type: ApplicationCommandOptionTypes.SUB_COMMAND,
|
||||
options: [
|
||||
{
|
||||
name: 'text',
|
||||
description: 'Text',
|
||||
type: ApplicationCommandOptionTypes.STRING,
|
||||
required: true
|
||||
},
|
||||
{
|
||||
name: 'voice',
|
||||
description: 'Voice to use',
|
||||
choices: voices,
|
||||
required: true
|
||||
}
|
||||
],
|
||||
run: async (context, args) => {
|
||||
try {
|
||||
await context.respond({ data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE })
|
||||
|
||||
if(args.text.length >= 101) return await context.editOrRespond({
|
||||
embeds: [createEmbed("warning", context, "Text too long (must be 100 or shorter).")]
|
||||
})
|
||||
|
||||
let audio = await tiktok(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: "tiktok.mp3" }
|
||||
})
|
||||
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
await context.editOrRespond({
|
||||
embeds: [createEmbed("error", context, "Unable to generate audio file.")]
|
||||
})
|
||||
}
|
||||
},
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue