diff --git a/commands/interaction/tts/tiktok.js b/commands/interaction/tts/tiktok.js new file mode 100644 index 0000000..6a7cbb5 --- /dev/null +++ b/commands/interaction/tts/tiktok.js @@ -0,0 +1,43 @@ +const { Constants } = require('detritus-client'); +const { tiktok } = require('../../../labscore/api'); +const { TIKTOK_VOICES } = require('../../../labscore/constants'); +const { createEmbed } = require('../../../labscore/utils/embed'); +const { icon } = require('../../../labscore/utils/markdown'); +const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = Constants; + +module.exports = { + description: 'tiktok audio', + name: 'tiktok', + options: [ + { + name: 'voice', + description: 'TTS Voice to use', + choices: TIKTOK_VOICES, + required: true, + }, + { + name: 'text', + description: 'Text', + type: ApplicationCommandOptionTypes.STRING, + required: true, + maxLength: 256 + } + ], + run: async (context, args) => { + try { + await context.respond({ data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE }) + + let audio = await tiktok(context, args.text, args.voice) + + await context.editOrRespond({ + embeds: [createEmbed("default", context, { description: `${icon("audio")} Audio Generated in ${audio.timings}` })], + file: { value: audio.response.body, filename: "tiktok.mp3" } + }) + + } catch (e) { + await context.editOrRespond({ + embeds: [createEmbed("error", context, "Unable to generate audio file.")] + }) + } + }, +}; \ No newline at end of file diff --git a/labscore/client.js b/labscore/client.js index 3e05589..5b85db8 100644 --- a/labscore/client.js +++ b/labscore/client.js @@ -1,4 +1,4 @@ -const { Constants, ClusterClient, CommandClient } = require('detritus-client'); +const { Constants, ClusterClient, CommandClient, InteractionCommandClient } = require('detritus-client'); const Paginator = require('./paginator').PaginatorCluster // Create client @@ -40,6 +40,10 @@ const paginator = new Paginator(cluster, { await commandClient.addMultipleIn('../commands/message/'); await commandClient.run() + const interactionClient = new InteractionCommandClient() + await interactionClient.addMultipleIn('../commands/interaction/'); + await interactionClient.run(); + })(); module.exports = { diff --git a/labscore/constants.js b/labscore/constants.js index b0b3192..6948059 100644 --- a/labscore/constants.js +++ b/labscore/constants.js @@ -115,4 +115,99 @@ module.exports.GUILD_FEATURES = Object.freeze({ "BOT_DEVELOPER_EARLY_ACCESS": "<:i:903276631173509130> Forum Channels Early Access" }) -module.exports.DISCORD_INVITE = `https://discord.gg/8c4p6xcjru` \ No newline at end of file +module.exports.DISCORD_INVITE = `https://discord.gg/8c4p6xcjru` + +module.exports.TIKTOK_VOICES = [ + { + "name": "English AU - Female", + "value": "en_au_001" + }, + { + "name": "English AU - Male", + "value": "en_au_002" + }, + { + "name": "English UK - Male", + "value": "en_uk_001" + }, + { + "name": "English US - Female", + "value": "en_us_001" + }, + { + "name": "English US - Male", + "value": "en_us_006" + }, + { + "name": "Ghost Face (Disney)", + "value": "en_us_ghostface" + }, + { + "name": "Chewbacca (Disney)", + "value": "en_us_chewbacca" + }, + { + "name": "C3PO (Disney)", + "value": "en_us_c3po" + }, + { + "name": "Stitch (Disney)", + "value": "en_us_stitch" + }, + { + "name": "Stormtrooper (Disney)", + "value": "en_us_stormtrooper" + }, + { + "name": "Rocket (Disney)", + "value": "en_us_rocket" + }, + { + "name": "French - Male", + "value": "fr_001" + }, + { + "name": "German - Female", + "value": "de_001" + }, + { + "name": "German - Male", + "value": "de_002" + }, + { + "name": "Spanish - Male", + "value": "es_002" + }, + { + "name": "Spanish MX - Male", + "value": "es_mx_002" + }, + { + "name": "Portuguese BR - Female", + "value": "br_001" + }, + { + "name": "Portuguese BR - Male", + "value": "br_005" + }, + { + "name": "Indonesian - Female", + "value": "id_001" + }, + { + "name": "Japanese - Female", + "value": "jp_001" + }, + { + "name": "Japanese - Male", + "value": "jp_006" + }, + { + "name": "Korean - Male", + "value": "kr_002" + }, + { + "name": "Korean - Female", + "value": "kr_003" + } +] \ No newline at end of file diff --git a/package.json b/package.json index 7a29ba8..9679010 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,10 @@ "version": "1.0.0", "description": "", "main": "index.js", - "scripts": {}, + "scripts": { + "start": "node .", + "local": "node local" + }, "keywords": [], "author": "", "license": "ISC",