+Commands{change name, help, read} better error catching.
This commit is contained in:
parent
16fc473a2a
commit
bd6374c1c7
6 changed files with 135 additions and 87 deletions
23
commands/change name.ts
Normal file
23
commands/change name.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import { squirrel } from "../scripts/enums";
|
||||
import { capitalize, getPlayerData, updateSquirrelFile } from "../scripts/functions";
|
||||
|
||||
module.exports = {
|
||||
name: "namechange",
|
||||
description: "Change the name of your squirrel, can only be used at level 1",
|
||||
args: "**name** - the new name for your squirrel",
|
||||
execute(msg, args) {
|
||||
let data: squirrel = getPlayerData(msg.author.id);
|
||||
|
||||
if (data.level == 1) {
|
||||
if (args.length >= 1) {
|
||||
data.name = capitalize(args[0]) + " " + data.name.split(' ')[1];
|
||||
updateSquirrelFile(msg.author.id, data);
|
||||
msg.reply(`Name changed to ${data.name}`);
|
||||
} else {
|
||||
msg.reply(`Please provide a name`);
|
||||
}
|
||||
} else {
|
||||
msg.reply(`Sorry, you have to be level 1 to change your name. You're stuck with ${data.name}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue