forked from Talon/tardis-bot
		
	Add canttalk module, few changes here and there to accomodate for it
This commit is contained in:
		
							
								
								
									
										38
									
								
								modules/Canttalk/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								modules/Canttalk/index.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,38 @@ | ||||
| module.exports = async (bot, api) => { | ||||
|     bot.on('message', async (message) => { | ||||
|         if (!message.content.startsWith(process.env.PREFIX)) { | ||||
|             if (message.channel.id == process.env.TTS_CHANNEL) { | ||||
|                 let chan=message.member.voice.channel; | ||||
|                 let userRow = await api.db.get('select * from TTSPreferences where user_id=?', message.author.id); | ||||
|                 if (!userRow) { | ||||
|                     await api.db.run('insert into TTSPreferences (user_id,engine,voice) values (?,?,?)', [message.author.id, api.announcementEngine.shortName, api.announcementVoice]); | ||||
|                     userRow = await api.db.get('select * from TTSPreferences where user_id=?', message.author.id); | ||||
|                 } | ||||
|                 if (api.ttsEngines[userRow.engine]) { | ||||
|                     api.speak(chan,message.content, api.ttsEngines[userRow.engine], userRow.voice) | ||||
|                 } else { | ||||
|  | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     }); | ||||
|     api.registerCommand('myvoice', async (args, message) => { | ||||
|         let userEngine, userVoice; | ||||
|         if (args.length > 3) { | ||||
|             return api.respond(message, "You tried to change your speaking voice with too many arguments."); | ||||
|         } | ||||
|         if (api.ttsEngines[args[1]]) { | ||||
|             userEngine = args[1]; | ||||
|             if (api.ttsEngines[userEngine].validateVoice(args[2])) { | ||||
|                 userVoice = args[2]; | ||||
|                 api.respond(message, "Your voice is now " + userVoice + " from " + api.ttsEngines[userEngine].longName); | ||||
|             } else { | ||||
|                 userVoice = api.ttsEngines[userEngine].getDefaultVoice(); | ||||
|                 api.respond(message, "Your voice name was invalid, so I switched to the default voice (" + userVoice + ") for " + api.ttsEngines[userEngine].longName + " instead."); | ||||
|             } | ||||
|             await api.db.run('update TTSPreferences set engine=?, voice=? where user_id=?', userEngine, userVoice, message.author.id); | ||||
|         } else { | ||||
|             api.respond(message, args[1] + " is not a valid engine name"); | ||||
|         } | ||||
|     }); | ||||
| } | ||||
		Reference in New Issue
	
	Block a user