style: run format:apply and misc lint changes

This commit is contained in:
2026-02-06 14:05:10 -03:00
parent 91a4c6e40d
commit 2fe0551dee
3 changed files with 20 additions and 23 deletions
+2 -2
View File
@@ -1,8 +1,8 @@
import { CommandCategoryInfo } from '../../commands';
const info: CommandCategoryInfo = {
name: 'Bot',
description: 'Bot management commands'
name: 'Bot',
description: 'Bot management commands'
};
export default info;
-2
View File
@@ -9,8 +9,6 @@ import { DataTypes } from 'sequelize';
import { config } from '../../utils/config';
import { DatabaseManager } from '../../modules/db';
import * as fs from 'fs';
const URL_REGEX = /(?:https?|ftp):\/\/[\n\S]+/g;
const DISCORD_REGEX = /<(?::\w+:|@!*&*|#)[0-9]+>/g; // from: https://www.reddit.com/r/discordapp/comments/iibxms/if_anyone_needs_regex_to_match_an_emote_mention/
+18 -19
View File
@@ -5,10 +5,9 @@ import * as https from 'https';
const ELEVENLABS_API_ENDPOINT = 'api.elevenlabs.io';
const FIREBASE_API_KEY = "AIzaSyBSsRE_1Os04-bxpd5JTLIniy3UK4OqKys";
const FIREBASE_API_KEY = 'AIzaSyBSsRE_1Os04-bxpd5JTLIniy3UK4OqKys';
const FIREBASE_URL = `https://securetoken.googleapis.com/v1/token?key=${FIREBASE_API_KEY}`;
/*
TO-DO: Implement previous text
*/
@@ -74,8 +73,7 @@ export class ElevenLabsTTS implements TTSModule {
this.settings = ElevenLabsTTS.DEFAULT_SETTINGS;
this.modelId = 'eleven_flash_v2_5';
if (this.canBeUsed())
this.initializationPromise = this.init();
if (this.canBeUsed()) this.initializationPromise = this.init();
this.setSettings = this.setSettings.bind(this);
this.setModel = this.setModel.bind(this);
@@ -84,10 +82,7 @@ export class ElevenLabsTTS implements TTSModule {
private async init(): Promise<void> {
await this.ensureSession();
await Promise.all([
this.fetchVoices(),
this.fetchModels()
]);
await Promise.all([this.fetchVoices(), this.fetchModels()]);
}
/*
@@ -153,7 +148,10 @@ export class ElevenLabsTTS implements TTSModule {
}
canBeUsed(): boolean {
return config.tts_elevenlabs_refreshtoken != undefined && config.tts_elevenlabs_key != undefined;
return (
config.tts_elevenlabs_refreshtoken != undefined &&
config.tts_elevenlabs_key != undefined
);
}
/*
@@ -244,31 +242,32 @@ export class ElevenLabsTTS implements TTSModule {
}
private async ensureSession(): Promise<void> {
if (this.session && Date.now() < this.session.expiresAt - 300000)
return;
if (this.session && Date.now() < this.session.expiresAt - 300000) return;
const refreshToken = this.session?.refreshToken || config.tts_elevenlabs_refreshtoken;
if (!refreshToken) throw new Error("No refresh token available");
const refreshToken =
this.session?.refreshToken || config.tts_elevenlabs_refreshtoken;
if (!refreshToken) throw new Error('No refresh token available');
const response = await fetch(FIREBASE_URL, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Referer': 'https://elevenlabs.io/',
'Origin': 'https://elevenlabs.io'
Referer: 'https://elevenlabs.io/',
Origin: 'https://elevenlabs.io'
},
body: new URLSearchParams({
grant_type: 'refresh_token',
refresh_token: refreshToken,
}),
refresh_token: refreshToken
})
});
if (!response.ok) throw new Error(`Auth Refresh Failed: ${await response.text()}`);
if (!response.ok)
throw new Error(`Auth Refresh Failed: ${await response.text()}`);
const data = await response.json();
this.session = {
idToken: data.id_token,
refreshToken: data.refresh_token,
expiresAt: Date.now() + (parseInt(data.expires_in) * 1000)
expiresAt: Date.now() + parseInt(data.expires_in) * 1000
};
}
}