From 2fe0551dee0a5a62183d887d77766242731db022 Mon Sep 17 00:00:00 2001 From: neru Date: Fri, 6 Feb 2026 14:05:10 -0300 Subject: [PATCH] style: run format:apply and misc lint changes --- src/commands/bot/_category.ts | 4 ++-- src/commands/tts/messageListener.ts | 2 -- src/modules/tts-modes/elevenlabs.ts | 37 ++++++++++++++--------------- 3 files changed, 20 insertions(+), 23 deletions(-) diff --git a/src/commands/bot/_category.ts b/src/commands/bot/_category.ts index fe9e00b..97df34d 100644 --- a/src/commands/bot/_category.ts +++ b/src/commands/bot/_category.ts @@ -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; diff --git a/src/commands/tts/messageListener.ts b/src/commands/tts/messageListener.ts index dee7be1..bcf03d6 100644 --- a/src/commands/tts/messageListener.ts +++ b/src/commands/tts/messageListener.ts @@ -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/ diff --git a/src/modules/tts-modes/elevenlabs.ts b/src/modules/tts-modes/elevenlabs.ts index 2eaff95..a281d17 100644 --- a/src/modules/tts-modes/elevenlabs.ts +++ b/src/modules/tts-modes/elevenlabs.ts @@ -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 { 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 { - 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 }; } }