aboutsummaryrefslogtreecommitdiff
path: root/twitch-bot/bot.js
diff options
context:
space:
mode:
authorBryson Steck <steck.bryson@gmail.com>2022-03-13 13:56:32 -0600
committerBryson Steck <steck.bryson@gmail.com>2022-03-13 13:56:32 -0600
commitc560490cc1457f7f2cebece7c2aa5f3bd83a36dc (patch)
tree30bc459c3c65fdf8b8fd49abbe01ec8352def556 /twitch-bot/bot.js
parent98260ccdb98b7b5b8fa287c83d75443fa8d8d1a2 (diff)
downloadlset-c560490cc1457f7f2cebece7c2aa5f3bd83a36dc.tar
lset-c560490cc1457f7f2cebece7c2aa5f3bd83a36dc.tar.gz
lset-c560490cc1457f7f2cebece7c2aa5f3bd83a36dc.tar.bz2
added editcommand
Diffstat (limited to 'twitch-bot/bot.js')
-rw-r--r--twitch-bot/bot.js24
1 files changed, 22 insertions, 2 deletions
diff --git a/twitch-bot/bot.js b/twitch-bot/bot.js
index 0399a1b..9d383e3 100644
--- a/twitch-bot/bot.js
+++ b/twitch-bot/bot.js
@@ -170,10 +170,11 @@ function createCommand(target) {
var command_reply = "";
for (int i = 2; i < fullMessage.length; i++) {
command_reply = command_reply + fullMessage[i] + " ";
+ }
chat_commands.push(['command': fullMessage[1], 'reply': command_reply]);
try {
const data = JSON.stringify(chat_commands, null, 4);
- fs.writeFileSync('user.json', data);
+ fs.writeFileSync('commands.json', data);
console.log('* Added command ' + settings.command_char + fullMessage[1]);
client.say(target, `Successfully added command: ${settings.command_char}${fullMessage[1]}`);
} catch (err) {
@@ -183,7 +184,26 @@ function createCommand(target) {
}
function editCommand(target) {
-
+ chat_commands.forEach(command => {
+ if (fullMessage[1].search(command.command) !== -1) {
+ var command_reply = "";
+ for (int i = 2; i < fullMessage.length; i++) {
+ command_reply = command_reply + fullMessage[i] + " ";
+ }
+ chat_commands[fullMessage[1]] = command_reply;
+ try {
+ const data = JSON.stringify(chat_commands, null, 4);
+ fs.writeFileSync('commands.json', data);
+ console.log('* Edited command ' + settings.command_char + fullMessage[1]);
+ client.say(target, `Successfully edited existing command: ${settings.command_char}${fullMessage[1]}`);
+ } catch (err) {
+ console.error('An error occured trying to run !editcommand: ' + err);
+ client.say(target, `Something went wrong editing this command, please try again later.`);
+ }
+ return true;
+ }
+ });
+ return false;
}
function reactions (target, message, user) {