improved tiktok command

This commit is contained in:
derpystuff 2023-11-26 22:03:27 +01:00
parent ba73854391
commit 1927c4a6e8
13 changed files with 754 additions and 45 deletions

View file

@ -1,50 +1,20 @@
const { Constants } = require('detritus-client');
const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = Constants;
const { tiktok } = require('../../../../labscore/api');
const { TIKTOK_VOICES } = require('../../../../labscore/constants');
const { createEmbed } = require('../../../../labscore/utils/embed');
const { icon, highlight } = require('../../../../labscore/utils/markdown');
const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
module.exports = {
description: 'TikTok text to speech voices',
description: 'TikTok Voices',
name: 'tiktok',
type: ApplicationCommandOptionTypes.SUB_COMMAND,
type: ApplicationCommandOptionTypes.SUB_COMMAND_GROUP,
options: [
{
name: 'voice',
description: 'TTS Voice to use',
choices: TIKTOK_VOICES,
required: true,
},
{
name: 'text',
description: 'Text',
type: ApplicationCommandOptionTypes.STRING,
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.")]
})
}
},
require('./tiktok/character'),
require('./tiktok/pop-culture'),
require('./tiktok/song'),
require('./tiktok/french'),
require('./tiktok/japanese'),
require('./tiktok/german'),
require('./tiktok/spanish'),
require('./tiktok/italian'),
require('./tiktok/korean'),
require('./tiktok/portugese'),
require('./tiktok/indonesian')
]
};

View 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_CHARACTERS } = require('../../../../../labscore/constants');
let voices = []
for(const k of Object.keys(TIKTOK_VOICES_CHARACTERS)) voices.unshift({
value: k,
name: TIKTOK_VOICES_CHARACTERS[k]
})
module.exports = {
description: 'Voices of TikTok Characters.',
name: 'character',
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.")]
})
}
},
};

View 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_FRENCH } = require('../../../../../labscore/constants');
let voices = []
for(const k of Object.keys(TIKTOK_VOICES_FRENCH)) voices.unshift({
value: k,
name: TIKTOK_VOICES_FRENCH[k]
})
module.exports = {
description: 'Voices from French TikTok Characters.',
name: 'french',
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.")]
})
}
},
};

View 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_GERMAN } = require('../../../../../labscore/constants');
let voices = []
for(const k of Object.keys(TIKTOK_VOICES_GERMAN)) voices.unshift({
value: k,
name: TIKTOK_VOICES_GERMAN[k]
})
module.exports = {
description: 'Voices from German TikTok Characters.',
name: 'german',
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.")]
})
}
},
};

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

View 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_ITALIAN } = require('../../../../../labscore/constants');
let voices = []
for(const k of Object.keys(TIKTOK_VOICES_ITALIAN)) voices.unshift({
value: k,
name: TIKTOK_VOICES_ITALIAN[k]
})
module.exports = {
description: 'Voices of Italian TikTok Characters.',
name: 'italian',
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.")]
})
}
},
};

View 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_JAPANESE } = require('../../../../../labscore/constants');
let voices = []
for(const k of Object.keys(TIKTOK_VOICES_JAPANESE)) voices.unshift({
value: k,
name: TIKTOK_VOICES_JAPANESE[k]
})
module.exports = {
description: 'Voices from Japanese TikTok Characters.',
name: 'japanese',
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.")]
})
}
},
};

View 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_KOREAN } = require('../../../../../labscore/constants');
let voices = []
for(const k of Object.keys(TIKTOK_VOICES_KOREAN)) voices.unshift({
value: k,
name: TIKTOK_VOICES_KOREAN[k]
})
module.exports = {
description: 'Voices of Korean TikTok Characters.',
name: 'korean',
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.")]
})
}
},
};

View 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_POP_CULTURE } = require('../../../../../labscore/constants');
let voices = []
for(const k of Object.keys(TIKTOK_VOICES_POP_CULTURE)) voices.unshift({
value: k,
name: TIKTOK_VOICES_POP_CULTURE[k]
})
module.exports = {
description: 'Voices of Pop Culture Characters.',
name: 'pop-culture',
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.")]
})
}
},
};

View 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_PORTUGESE } = require('../../../../../labscore/constants');
let voices = []
for(const k of Object.keys(TIKTOK_VOICES_PORTUGESE)) voices.unshift({
value: k,
name: TIKTOK_VOICES_PORTUGESE[k]
})
module.exports = {
description: 'Voices of Portugese TikTok Characters.',
name: 'portugese',
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.")]
})
}
},
};

View 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_SONG } = require('../../../../../labscore/constants');
let voices = []
for(const k of Object.keys(TIKTOK_VOICES_SONG)) voices.unshift({
value: k,
name: TIKTOK_VOICES_SONG[k]
})
module.exports = {
description: 'Voices that sing songs.',
name: 'song',
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.")]
})
}
},
};

View 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_SPANISH } = require('../../../../../labscore/constants');
let voices = []
for(const k of Object.keys(TIKTOK_VOICES_SPANISH)) voices.unshift({
value: k,
name: TIKTOK_VOICES_SPANISH[k]
})
module.exports = {
description: 'Voices of Spanish TikTok Characters.',
name: 'spanish',
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.")]
})
}
},
};