interaction command client interaction command client interaction command client interaction command client interaction command client interaction command client interaction command client interaction command client interaction command client interaction command client

This commit is contained in:
derpystuff 2022-05-28 22:12:34 +02:00
parent 7395d7d096
commit 0196471203
4 changed files with 148 additions and 3 deletions

View file

@ -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.")]
})
}
},
};

View file

@ -1,4 +1,4 @@
const { Constants, ClusterClient, CommandClient } = require('detritus-client'); const { Constants, ClusterClient, CommandClient, InteractionCommandClient } = require('detritus-client');
const Paginator = require('./paginator').PaginatorCluster const Paginator = require('./paginator').PaginatorCluster
// Create client // Create client
@ -40,6 +40,10 @@ const paginator = new Paginator(cluster, {
await commandClient.addMultipleIn('../commands/message/'); await commandClient.addMultipleIn('../commands/message/');
await commandClient.run() await commandClient.run()
const interactionClient = new InteractionCommandClient()
await interactionClient.addMultipleIn('../commands/interaction/');
await interactionClient.run();
})(); })();
module.exports = { module.exports = {

View file

@ -115,4 +115,99 @@ module.exports.GUILD_FEATURES = Object.freeze({
"BOT_DEVELOPER_EARLY_ACCESS": "<:i:903276631173509130> Forum Channels Early Access" "BOT_DEVELOPER_EARLY_ACCESS": "<:i:903276631173509130> Forum Channels Early Access"
}) })
module.exports.DISCORD_INVITE = `https://discord.gg/8c4p6xcjru` 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"
}
]

View file

@ -3,7 +3,10 @@
"version": "1.0.0", "version": "1.0.0",
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"scripts": {}, "scripts": {
"start": "node .",
"local": "node local"
},
"keywords": [], "keywords": [],
"author": "", "author": "",
"license": "ISC", "license": "ISC",