Implement api.output, announcevoice command, a bunch of other tts shit, etc etc etc buh
This commit is contained in:
19
index.js
19
index.js
@@ -27,6 +27,17 @@ const api = {
|
||||
})
|
||||
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);
|
||||
}
|
||||
},
|
||||
|
||||
isInVoiceChannel: (channel) => {
|
||||
return joinedVoiceChannels.includes(channel);
|
||||
@@ -59,7 +70,7 @@ const api = {
|
||||
}
|
||||
},
|
||||
|
||||
speak: async (channel, message, engine=api.ttsEngines.gtranslate, voice='en-us', 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);
|
||||
@@ -83,15 +94,17 @@ function registerModules() {
|
||||
|
||||
function handleMessage(message) {
|
||||
if (message.content.startsWith(process.env.PREFIX)) {
|
||||
const args = message.contents.split(" ");
|
||||
const args = message.content.split(" ");
|
||||
const command = args[0].substr(1, args[0].length);
|
||||
const execution = commandHandlers.get(command);
|
||||
if (command) {
|
||||
command(args, message);
|
||||
if(execution) execution(args, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
api.announcementEngine = api.ttsEngines[process.env.ANNOUNCEMENT_ENGINE];
|
||||
registerModules();
|
||||
bot.login(process.env.TOKEN);
|
||||
bot.on('message', handleMessage);
|
Reference in New Issue
Block a user