Added Args consistency
I also played around with the idea of multiple names like "Kit Kat" for a squirrel, but it was a massive pain. Ended up deciding hyphenated names were normal in Squirrel Society.
This commit is contained in:
parent
d88cde8a73
commit
f74a9ca9f1
3 changed files with 27 additions and 18 deletions
13
README.md
13
README.md
|
|
@ -1 +1,14 @@
|
||||||
# NovaBot
|
# 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.
|
||||||
|
|
|
||||||
16
main.js
16
main.js
|
|
@ -188,12 +188,11 @@ function read(msg, data) {
|
||||||
}
|
}
|
||||||
function create(msg, args, file) {
|
function create(msg, args, file) {
|
||||||
if (args.length === 3) {
|
if (args.length === 3) {
|
||||||
var newSquirrel_1 = msg.content.split(' ');
|
|
||||||
var newPlayer = newPlayerTemplate;
|
var newPlayer = newPlayerTemplate;
|
||||||
var incorrect_1 = "";
|
var incorrect_1 = "";
|
||||||
incorrect_1 = " race";
|
incorrect_1 = " race";
|
||||||
races.some(function (type) {
|
races.some(function (type) {
|
||||||
if (newSquirrel_1[2].toLowerCase() == type) {
|
if (args[1].toLowerCase() == type) {
|
||||||
incorrect_1 = "";
|
incorrect_1 = "";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -203,7 +202,7 @@ function create(msg, args, file) {
|
||||||
else
|
else
|
||||||
incorrect_1 += ", and class";
|
incorrect_1 += ", and class";
|
||||||
classes.some(function (type) {
|
classes.some(function (type) {
|
||||||
if (newSquirrel_1[3].toLowerCase() == type) {
|
if (args[2].toLowerCase() == type) {
|
||||||
if (incorrect_1 == " race, and class")
|
if (incorrect_1 == " race, and class")
|
||||||
incorrect_1 = " race";
|
incorrect_1 = " race";
|
||||||
else
|
else
|
||||||
|
|
@ -212,9 +211,9 @@ function create(msg, args, file) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (incorrect_1 === "") {
|
if (incorrect_1 === "") {
|
||||||
newPlayer.name = newSquirrel_1[1] + " " + lastNames[randomInt(0, lastNames.length - 1)];
|
newPlayer.name = args[0] + " " + lastNames[randomInt(0, lastNames.length - 1)];
|
||||||
newPlayer.race = newSquirrel_1[2];
|
newPlayer.race = args[1];
|
||||||
newPlayer["class"] = newSquirrel_1[3];
|
newPlayer["class"] = args[2];
|
||||||
fs.writeFileSync(file, JSON.stringify(newPlayer));
|
fs.writeFileSync(file, JSON.stringify(newPlayer));
|
||||||
msg.reply("Squirrel " + newPlayer.name + " has been created");
|
msg.reply("Squirrel " + newPlayer.name + " has been created");
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -231,9 +230,8 @@ function create(msg, args, file) {
|
||||||
}
|
}
|
||||||
function nameChange(msg, data, args, file) {
|
function nameChange(msg, data, args, file) {
|
||||||
if (data.level == 1) {
|
if (data.level == 1) {
|
||||||
if (args.length >= 2) {
|
if (args.length >= 1) {
|
||||||
var newName = args[1];
|
data.name = capitalize(args[0]) + " " + data.name.split(' ')[1];
|
||||||
data.name = capitalize(newName) + " " + data.name.split(' ')[1];
|
|
||||||
fs.writeFileSync(file, JSON.stringify(data));
|
fs.writeFileSync(file, JSON.stringify(data));
|
||||||
msg.reply("Name changed to " + data.name);
|
msg.reply("Name changed to " + data.name);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
16
main.ts
16
main.ts
|
|
@ -202,13 +202,12 @@ function read(msg: any, data: player): void {
|
||||||
|
|
||||||
function create(msg: any, args: Array<string>, file: any): boolean {
|
function create(msg: any, args: Array<string>, file: any): boolean {
|
||||||
if (args.length === 3) {
|
if (args.length === 3) {
|
||||||
let newSquirrel: Array<string> = msg.content.split(' ');
|
|
||||||
let newPlayer: player = newPlayerTemplate;
|
let newPlayer: player = newPlayerTemplate;
|
||||||
let incorrect: string = "";
|
let incorrect: string = "";
|
||||||
|
|
||||||
incorrect = " race";
|
incorrect = " race";
|
||||||
races.some(type => {
|
races.some(type => {
|
||||||
if (newSquirrel[2].toLowerCase() == type) {
|
if (args[1].toLowerCase() == type) {
|
||||||
incorrect = "";
|
incorrect = "";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -219,7 +218,7 @@ function create(msg: any, args: Array<string>, file: any): boolean {
|
||||||
else
|
else
|
||||||
incorrect += ", and class";
|
incorrect += ", and class";
|
||||||
classes.some(type => {
|
classes.some(type => {
|
||||||
if (newSquirrel[3].toLowerCase() == type) {
|
if (args[2].toLowerCase() == type) {
|
||||||
if (incorrect == " race, and class")
|
if (incorrect == " race, and class")
|
||||||
incorrect = " race";
|
incorrect = " race";
|
||||||
else
|
else
|
||||||
|
|
@ -229,9 +228,9 @@ function create(msg: any, args: Array<string>, file: any): boolean {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (incorrect === "") {
|
if (incorrect === "") {
|
||||||
newPlayer.name = newSquirrel[1] + " " + lastNames[randomInt(0, lastNames.length - 1)];
|
newPlayer.name = args[0] + " " + lastNames[randomInt(0, lastNames.length - 1)];
|
||||||
newPlayer.race = newSquirrel[2];
|
newPlayer.race = args[1];
|
||||||
newPlayer.class = newSquirrel[3];
|
newPlayer.class = args[2];
|
||||||
fs.writeFileSync(file, JSON.stringify(newPlayer));
|
fs.writeFileSync(file, JSON.stringify(newPlayer));
|
||||||
msg.reply(`Squirrel ${newPlayer.name} has been created`);
|
msg.reply(`Squirrel ${newPlayer.name} has been created`);
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -247,9 +246,8 @@ function create(msg: any, args: Array<string>, file: any): boolean {
|
||||||
|
|
||||||
function nameChange(msg: any, data: player, args: string[], file: any): void {
|
function nameChange(msg: any, data: player, args: string[], file: any): void {
|
||||||
if (data.level == 1) {
|
if (data.level == 1) {
|
||||||
if (args.length >= 2) {
|
if (args.length >= 1) {
|
||||||
let newName: string = args[1];
|
data.name = capitalize(args[0]) + " " + data.name.split(' ')[1];
|
||||||
data.name = capitalize(newName) + " " + data.name.split(' ')[1];
|
|
||||||
fs.writeFileSync(file, JSON.stringify(data));
|
fs.writeFileSync(file, JSON.stringify(data));
|
||||||
msg.reply(`Name changed to ${data.name}`);
|
msg.reply(`Name changed to ${data.name}`);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue