diff --git a/README.md b/README.md index 368dd35..a27c471 100644 --- a/README.md +++ b/README.md @@ -1 +1,14 @@ # NovaBot + +This is a temporary read me, and if you have trouble running the bot feel free to contact me. + +To used this bot: +You must have node installed, and include the package discord.js. +Then create a info.json file, and in it include this: +{ + "key": "your discord key", + "prefix": "!" +} +The key is the discord key for your bot, and the prefix is the command identifier, to say it a different way, the prefix is the character that goes before commands that the bot recoginizes. + +Type `node main` in your terminal to start the bot. diff --git a/main.js b/main.js index 65d1252..6ecc61b 100644 --- a/main.js +++ b/main.js @@ -188,12 +188,11 @@ function read(msg, data) { } function create(msg, args, file) { if (args.length === 3) { - var newSquirrel_1 = msg.content.split(' '); var newPlayer = newPlayerTemplate; var incorrect_1 = ""; incorrect_1 = " race"; races.some(function (type) { - if (newSquirrel_1[2].toLowerCase() == type) { + if (args[1].toLowerCase() == type) { incorrect_1 = ""; return true; } @@ -203,7 +202,7 @@ function create(msg, args, file) { else incorrect_1 += ", and class"; classes.some(function (type) { - if (newSquirrel_1[3].toLowerCase() == type) { + if (args[2].toLowerCase() == type) { if (incorrect_1 == " race, and class") incorrect_1 = " race"; else @@ -212,9 +211,9 @@ function create(msg, args, file) { } }); if (incorrect_1 === "") { - newPlayer.name = newSquirrel_1[1] + " " + lastNames[randomInt(0, lastNames.length - 1)]; - newPlayer.race = newSquirrel_1[2]; - newPlayer["class"] = newSquirrel_1[3]; + newPlayer.name = args[0] + " " + lastNames[randomInt(0, lastNames.length - 1)]; + newPlayer.race = args[1]; + newPlayer["class"] = args[2]; fs.writeFileSync(file, JSON.stringify(newPlayer)); msg.reply("Squirrel " + newPlayer.name + " has been created"); return true; @@ -231,9 +230,8 @@ function create(msg, args, file) { } function nameChange(msg, data, args, file) { if (data.level == 1) { - if (args.length >= 2) { - var newName = args[1]; - data.name = capitalize(newName) + " " + data.name.split(' ')[1]; + if (args.length >= 1) { + data.name = capitalize(args[0]) + " " + data.name.split(' ')[1]; fs.writeFileSync(file, JSON.stringify(data)); msg.reply("Name changed to " + data.name); } diff --git a/main.ts b/main.ts index da0ffa4..9ff31f3 100644 --- a/main.ts +++ b/main.ts @@ -202,13 +202,12 @@ function read(msg: any, data: player): void { function create(msg: any, args: Array, file: any): boolean { if (args.length === 3) { - let newSquirrel: Array = msg.content.split(' '); let newPlayer: player = newPlayerTemplate; let incorrect: string = ""; incorrect = " race"; races.some(type => { - if (newSquirrel[2].toLowerCase() == type) { + if (args[1].toLowerCase() == type) { incorrect = ""; return true; } @@ -219,7 +218,7 @@ function create(msg: any, args: Array, file: any): boolean { else incorrect += ", and class"; classes.some(type => { - if (newSquirrel[3].toLowerCase() == type) { + if (args[2].toLowerCase() == type) { if (incorrect == " race, and class") incorrect = " race"; else @@ -229,9 +228,9 @@ function create(msg: any, args: Array, file: any): boolean { }); if (incorrect === "") { - newPlayer.name = newSquirrel[1] + " " + lastNames[randomInt(0, lastNames.length - 1)]; - newPlayer.race = newSquirrel[2]; - newPlayer.class = newSquirrel[3]; + newPlayer.name = args[0] + " " + lastNames[randomInt(0, lastNames.length - 1)]; + newPlayer.race = args[1]; + newPlayer.class = args[2]; fs.writeFileSync(file, JSON.stringify(newPlayer)); msg.reply(`Squirrel ${newPlayer.name} has been created`); return true; @@ -247,9 +246,8 @@ function create(msg: any, args: Array, file: any): boolean { function nameChange(msg: any, data: player, args: string[], file: any): void { if (data.level == 1) { - if (args.length >= 2) { - let newName: string = args[1]; - data.name = capitalize(newName) + " " + data.name.split(' ')[1]; + if (args.length >= 1) { + data.name = capitalize(args[0]) + " " + data.name.split(' ')[1]; fs.writeFileSync(file, JSON.stringify(data)); msg.reply(`Name changed to ${data.name}`); } else {