Finished Process for single point of creation for new commands
Streamlined command creation to an object and function with single point of change.
This commit is contained in:
parent
aaef4d2e9a
commit
0d1c0a020c
1 changed files with 24 additions and 20 deletions
44
main.ts
44
main.ts
|
|
@ -19,15 +19,30 @@ const newPlayerTemplate: player = {
|
||||||
"dm_points": 0
|
"dm_points": 0
|
||||||
}
|
}
|
||||||
const processes: any = {
|
const processes: any = {
|
||||||
"!read": {
|
"read": {
|
||||||
title: "read",
|
title: "Read",
|
||||||
description: "Read a description of your character",
|
description: "Read a description of your squirrel",
|
||||||
run: (msg, data) => read(msg, data)
|
run: (msg: any, data: player, args: string[], file: any) => read(msg, data)
|
||||||
},
|
},
|
||||||
"!create": {
|
"create": {
|
||||||
title: "create",
|
title: "Create",
|
||||||
description: "Create a character, can only be used once.",
|
description: "Create a squirrel, can only be used once.",
|
||||||
run: (msg, args) => create(msg, args)
|
run: (msg: any, data: player, args: string[], file: any) => create(msg, args)
|
||||||
|
},
|
||||||
|
"namechange": {
|
||||||
|
title: "Namechange",
|
||||||
|
description: "Change the name of your squirrel, can only be used once",
|
||||||
|
run: (msg: any, data: player, args: string[], file: any) => nameChange(msg, data, file)
|
||||||
|
},
|
||||||
|
"races": {
|
||||||
|
title: "Races",
|
||||||
|
description: "List all the races",
|
||||||
|
run: (msg: any, data: player, args: string[], file: any) => printRaces(msg)
|
||||||
|
},
|
||||||
|
"classes": {
|
||||||
|
title: "Classes",
|
||||||
|
description: "List all the classes",
|
||||||
|
run: (msg: any, data: player, args: string[], file: any) => printClasses(msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -71,20 +86,9 @@ client.on('message', msg => {
|
||||||
|
|
||||||
processes.forEach(process => {
|
processes.forEach(process => {
|
||||||
if(command === `!${process.title}`){
|
if(command === `!${process.title}`){
|
||||||
process.run()
|
process.run(msg, playerData, args, playerFile);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (command === `!read`) {
|
|
||||||
read(msg, playerData);
|
|
||||||
} else if (command === `!create`) {
|
|
||||||
msg.reply(`You already have a squirrel silly.`);
|
|
||||||
} else if (command === `!namechange`) {
|
|
||||||
nameChange(msg, playerData, playerFile);
|
|
||||||
} else if (command === `!races`) {
|
|
||||||
printRaces(msg);
|
|
||||||
} else if (command === `!classes`) {
|
|
||||||
printClasses(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (command === `!create`) {
|
} else if (command === `!create`) {
|
||||||
console.log(`Attempting to make a squirrel for ${authorId}`);
|
console.log(`Attempting to make a squirrel for ${authorId}`);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue