fix: misc checks / changes
This commit is contained in:
@@ -9,6 +9,8 @@ import { DataTypes } from 'sequelize';
|
|||||||
import { config } from '../../utils/config';
|
import { config } from '../../utils/config';
|
||||||
import { DatabaseManager } from '../../modules/db';
|
import { DatabaseManager } from '../../modules/db';
|
||||||
|
|
||||||
|
import * as fs from 'fs';
|
||||||
|
|
||||||
const URL_REGEX = /(?:https?|ftp):\/\/[\n\S]+/g;
|
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/
|
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/
|
||||||
|
|
||||||
@@ -74,13 +76,24 @@ class TTSListener implements Command {
|
|||||||
if (msgFiltered.length === 0) return;
|
if (msgFiltered.length === 0) return;
|
||||||
|
|
||||||
const audio = await ttsModule.generate(voiceName, msgFiltered);
|
const audio = await ttsModule.generate(voiceName, msgFiltered);
|
||||||
|
if (!audio) {
|
||||||
|
this.log.error("TTS generation didn't return anything");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (audio?.data) {
|
if (audio.data) {
|
||||||
const stream =
|
const stream =
|
||||||
AudioStreamManager.get.getOrCreateStream(voiceConnection);
|
AudioStreamManager.get.getOrCreateStream(voiceConnection);
|
||||||
const queue = stream.getQueue('TTS');
|
const queue = stream.getQueue('TTS');
|
||||||
queue.enqueue(Readable.from(audio.data));
|
queue.enqueue(Readable.from(audio.data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (audio.error) {
|
||||||
|
this.log.error(
|
||||||
|
'Error occurred while generating message: (%s)',
|
||||||
|
audio.error
|
||||||
|
);
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.log.error('Error occurred while processing TTS message (%s)', err);
|
this.log.error('Error occurred while processing TTS message (%s)', err);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user