Add string customization and example.env
This commit is contained in:
BIN
modules/.DS_Store
vendored
BIN
modules/.DS_Store
vendored
Binary file not shown.
@@ -1,3 +1,5 @@
|
||||
const printf=require('printf');
|
||||
|
||||
module.exports = async (bot, api) => {
|
||||
bot.on('message', async (message) => {
|
||||
if (!message.content.startsWith(process.env.PREFIX)) {
|
||||
@@ -19,20 +21,20 @@ module.exports = async (bot, api) => {
|
||||
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.");
|
||||
return api.respond(message, printf(api.strings.TOO_MANY_ARGUMENTS));
|
||||
}
|
||||
if (api.ttsEngines[args[1]]) {
|
||||
userEngine = args[1];
|
||||
if (api.ttsEngines[userEngine].validateVoice(args[2].toLowerCase())) {
|
||||
userVoice = args[2].toLowerCase();
|
||||
api.respond(message, "Your voice is now " + userVoice + " from " + api.ttsEngines[userEngine].longName);
|
||||
api.respond(message, printf(api.strings.USER_VOICE_CHANGED, userVoice, 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.");
|
||||
api.respond(message, printf(api.strings.INVALID_VOICE, api.announcementVoice, api.announcementEngine.longName));
|
||||
}
|
||||
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");
|
||||
api.respond(message, printf(api.strings.INVALID_ENGINE, args[1]));
|
||||
}
|
||||
});
|
||||
}
|
@@ -1,3 +1,4 @@
|
||||
const printf=require('printf');
|
||||
const AudioQueue=require('../../AudioQueue.js')
|
||||
|
||||
module.exports = function (bot, api) {
|
||||
@@ -20,9 +21,9 @@ module.exports = function (bot, api) {
|
||||
let username = newState.member.displayName;
|
||||
let str = "";
|
||||
if (!joined) {
|
||||
str = username + " left the channel";
|
||||
str = printf(api.strings.USER_LEFT, username);
|
||||
} else {
|
||||
str = username + " joined the channel";
|
||||
str = printf(api.strings.USER_JOINED, username);
|
||||
}
|
||||
api.queue.add(__dirname + "/sysmsg.wav");
|
||||
api.speak(channel, str);
|
||||
|
@@ -1,20 +1,22 @@
|
||||
const printf=require('printf');
|
||||
|
||||
module.exports = function (bot, api) {
|
||||
api.registerCommand('announcevoice', (args, message) => {
|
||||
let channel = bot.voice.connections.first().channel;
|
||||
if (args.length > 3) {
|
||||
return api.respond(message, "You tried to change my voice with too many arguments.");
|
||||
return api.respond(message, printf(api.strings.TOO_MANY_ARGUMENTS));
|
||||
}
|
||||
if (api.ttsEngines[args[1]]) {
|
||||
api.announcementEngine = api.ttsEngines[args[1]];
|
||||
if (api.announcementEngine.validateVoice(args[2])) {
|
||||
api.announcementVoice = args[2];
|
||||
api.respond(message, "My new voice is " + api.announcementVoice + " from " + api.announcementEngine.longName);
|
||||
api.respond(message, printf(api.strings.SYSTEM_VOICE_CHANGED, api.announcementVoice, api.announcementEngine.longName));
|
||||
} else {
|
||||
api.announcementVoice = api.announcementEngine.getDefaultVoice();
|
||||
api.respond(message, "Your voice name was invalid, so I switched to the default voice (" + api.announcementVoice + ") for " + api.announcementEngine.longName + " instead.");
|
||||
api.respond(message, printf(api.strings.INVALID_VOICE, api.announcementVoice, api.announcementEngine.longName));
|
||||
}
|
||||
} else {
|
||||
api.respond(message, args[1] + " is not a valid engine name");
|
||||
api.respond(message, printf(api.strings.INVALID_ENGINE, args[1]));
|
||||
}
|
||||
});
|
||||
api.registerCommand('flush',()=>api.queue.flush());
|
||||
|
@@ -8,6 +8,6 @@ module.exports = function (bot, api) {
|
||||
await api.joinChannel(channel);
|
||||
let conn=api.getConnectionForVoiceChannel(channel);
|
||||
api.queue=new AudioQueue(conn);
|
||||
api.speak(channel, `Running`);
|
||||
api.speak(channel, api.strings.WELCOME);
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user