style: run format:apply
This commit is contained in:
+4
-1
@@ -255,7 +255,10 @@ export class CommandManager {
|
||||
|
||||
if (command.requiresAdmin) {
|
||||
const member = interaction.member as GuildMember;
|
||||
if (!member.permissions.has(PermissionFlagsBits.Administrator) && member.id != config.owner_id) {
|
||||
if (
|
||||
!member.permissions.has(PermissionFlagsBits.Administrator) &&
|
||||
member.id != config.owner_id
|
||||
) {
|
||||
await interaction.reply({
|
||||
content:
|
||||
"You don't have the permissions required to execute this command.",
|
||||
|
||||
@@ -135,7 +135,8 @@ export class MixedStream {
|
||||
});
|
||||
|
||||
transcoder.on('end', () => {
|
||||
const durationMs = (totalBytes / 192000) * 1000 * (1 + DURATION_MARGIN_PCT);
|
||||
const durationMs =
|
||||
(totalBytes / 192000) * 1000 * (1 + DURATION_MARGIN_PCT);
|
||||
|
||||
setTimeout(() => {
|
||||
source.unpipe(transcoder);
|
||||
@@ -153,7 +154,6 @@ export class MixedStream {
|
||||
});
|
||||
|
||||
source.pipe(transcoder).pipe(mixerInput);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { config } from "../../utils/config";
|
||||
import { TTSModule, TTSResponse } from "../tts"
|
||||
import { config } from '../../utils/config';
|
||||
import { TTSModule, TTSResponse } from '../tts';
|
||||
|
||||
import * as https from 'https';
|
||||
import * as zlib from 'zlib';
|
||||
|
||||
import TIKTOK_TTS_VOICES from './tiktok_voices.json';
|
||||
const TIKTOK_TTS_ENDPOINT = 'https://api16-normal-v6.tiktokv.com/media/api/text/speech/invoke'
|
||||
const TIKTOK_TTS_ENDPOINT =
|
||||
'https://api16-normal-v6.tiktokv.com/media/api/text/speech/invoke';
|
||||
|
||||
class TikTokTTS implements TTSModule {
|
||||
public name: string = 'TikTok';
|
||||
@@ -26,12 +27,13 @@ class TikTokTTS implements TTSModule {
|
||||
path: endpoint.pathname + path,
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'User-Agent': 'com.zhiliaoapp.musically/2022600030 (Linux; U; Android 7.1.2; es_ES; SM-G988N; Build/NRD90M;tt-ok/3.12.13.1)',
|
||||
'Cookie': `sessionid=${config.tiktok_session_id}`,
|
||||
'User-Agent':
|
||||
'com.zhiliaoapp.musically/2022600030 (Linux; U; Android 7.1.2; es_ES; SM-G988N; Build/NRD90M;tt-ok/3.12.13.1)',
|
||||
Cookie: `sessionid=${config.tiktok_session_id}`,
|
||||
'Accept-Encoding': 'gzip,deflate,compress',
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return new Promise((resolve) => {
|
||||
const req = https.request(options, (res) => {
|
||||
@@ -44,11 +46,10 @@ class TikTokTTS implements TTSModule {
|
||||
try {
|
||||
const buffer = Buffer.concat(chunks);
|
||||
|
||||
// Handle decompression if needed
|
||||
const decompressBuffer = (buf: Buffer): Promise<Buffer> => {
|
||||
return new Promise((decompressResolve, decompressReject) => {
|
||||
if (encoding === 'gzip' || encoding === 'deflate') {
|
||||
zlib.unzip(buf, (err: any, decompressed: Buffer<ArrayBufferLike> | PromiseLike<Buffer<ArrayBufferLike>>) => {
|
||||
zlib.unzip(buf, (err: Error | null, decompressed: Buffer) => {
|
||||
if (err) decompressReject(err);
|
||||
else decompressResolve(decompressed);
|
||||
});
|
||||
@@ -78,7 +79,6 @@ class TikTokTTS implements TTSModule {
|
||||
.catch((err) => {
|
||||
resolve({ error: `Decompression/Parse error: ${err.message}` });
|
||||
});
|
||||
|
||||
} catch (err) {
|
||||
resolve({ error: `Parse error: ${err}` });
|
||||
}
|
||||
@@ -103,13 +103,13 @@ class TikTokTTS implements TTSModule {
|
||||
handleStatusError(code: number): string {
|
||||
switch (code) {
|
||||
case 1:
|
||||
return "Session ID may be invalid or expired";
|
||||
return 'Session ID may be invalid or expired';
|
||||
case 2:
|
||||
return "Text is too long";
|
||||
return 'Text is too long';
|
||||
case 4:
|
||||
return "Invalid voice";
|
||||
return 'Invalid voice';
|
||||
case 5:
|
||||
return "No session id.";
|
||||
return 'No session id.';
|
||||
}
|
||||
return `Unknown error code: ${code}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user