Fix formatting
This commit is contained in:
54
index.js
54
index.js
@@ -16,29 +16,29 @@ const db = new sqlite.Database(process.env.DB_FILE);
|
||||
const api = {
|
||||
db: db,
|
||||
ttsEngines: (() => {
|
||||
let engines={};
|
||||
console.log(`Registering TTS engines...`);
|
||||
const engineDirectories = fs.readdirSync('./tts');
|
||||
engineDirectories.forEach((dir) => {
|
||||
if(dir.startsWith('.')) return;
|
||||
eng=require(`./tts/${dir}/index.js`);
|
||||
engines[dir]=new eng;
|
||||
console.log(`Loading ./tts/${dir}/index.js`)
|
||||
})
|
||||
return engines;
|
||||
let engines = {};
|
||||
console.log(`Registering TTS engines...`);
|
||||
const engineDirectories = fs.readdirSync('./tts');
|
||||
engineDirectories.forEach((dir) => {
|
||||
if (dir.startsWith('.')) return;
|
||||
eng = require(`./tts/${dir}/index.js`);
|
||||
engines[dir] = new eng;
|
||||
console.log(`Loading ./tts/${dir}/index.js`)
|
||||
})
|
||||
return engines;
|
||||
})(),
|
||||
announcementVoice: process.env.ANNOUNCEMENT_VOICE,
|
||||
announcementEngine: undefined,
|
||||
|
||||
respond: (message, text, voiceText) => {
|
||||
let toSend = message.member.displayName+", "+(voiceText ? voiceText : text);
|
||||
if(message.member.voice.channel) {
|
||||
api.speak(message.member.voice.channel, toSend);
|
||||
} else {
|
||||
message.reply(text);
|
||||
}
|
||||
},
|
||||
|
||||
announcementVoice: process.env.ANNOUNCEMENT_VOICE,
|
||||
announcementEngine: undefined,
|
||||
|
||||
respond: (message, text, voiceText) => {
|
||||
let toSend = message.member.displayName + ", " + (voiceText ? voiceText : text);
|
||||
if (message.member.voice.channel) {
|
||||
api.speak(message.member.voice.channel, toSend);
|
||||
} else {
|
||||
message.reply(text);
|
||||
}
|
||||
},
|
||||
|
||||
isInVoiceChannel: (channel) => {
|
||||
return joinedVoiceChannels.includes(channel);
|
||||
},
|
||||
@@ -48,7 +48,7 @@ const api = {
|
||||
},
|
||||
|
||||
generateVoice: async (string, engine, voice, params) => {
|
||||
const hash = sha1(voice+string);
|
||||
const hash = sha1(voice + string);
|
||||
const filepath = process.env.VOICE_TMP_PATH + hash + '.' + engine.fileExtension;
|
||||
if (!fs.existsSync(filepath)) {
|
||||
await engine.getSpeechFile(string, filepath, voice, params);
|
||||
@@ -70,7 +70,7 @@ const api = {
|
||||
}
|
||||
},
|
||||
|
||||
speak: async (channel, message, engine=api.announcementEngine, voice=api.announcementVoice, params={}) => {
|
||||
speak: async (channel, message, engine = api.announcementEngine, voice = api.announcementVoice, params = {}) => {
|
||||
const conn = api.getConnectionForVoiceChannel(channel);
|
||||
const filepath = await api.generateVoice(message, engine, voice, params);
|
||||
if (conn) conn.play(filepath);
|
||||
@@ -82,10 +82,10 @@ const api = {
|
||||
}
|
||||
|
||||
function registerModules() {
|
||||
console.log(`Registering modules...`);
|
||||
console.log(`Registering modules...`);
|
||||
const moduleDirectories = fs.readdirSync('./modules');
|
||||
moduleDirectories.forEach((dir) => {
|
||||
if(dir.startsWith('.')) return;
|
||||
if (dir.startsWith('.')) return;
|
||||
modules.push(require(`./modules/${dir}/index.js`));
|
||||
console.log(`Loading ./modules/${dir}/index.js`)
|
||||
})
|
||||
@@ -98,7 +98,7 @@ function handleMessage(message) {
|
||||
const command = args[0].substr(1, args[0].length);
|
||||
const execution = commandHandlers.get(command);
|
||||
if (command) {
|
||||
if(execution) execution(args, message);
|
||||
if (execution) execution(args, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user