* fixing typos * merge Dynamic commands (#3) * Update README.md * Update README.md * fixing typos * dynamically read new commands inside folder. * eslint, update package.json due to moving files Co-authored-by: Marcus Netz <marcus.netz@godyo.com> * fix talent checking on empty arguments list * Origin/message embed (#4) * add first embedded message on tp.js * move db from message commands * fix missing arguments list, add need_args * add global Message Replies. * add more global Message Replies. * more embedded messages. fixing string * missing comma * adding a few more strings on talents. Co-authored-by: Marcus Netz <marcus.netz@godyo.com> * fixing creating from json file * bugfix: db not defined * possible fix for nonworking talent? * fix double msg * fix: aliases are now being used * change: show command displays now some character attributes * added various aliases to commands, added global strings. Co-authored-by: Marcus Netz <marcus.netz@godyo.com>
48 lines
1.0 KiB
JavaScript
48 lines
1.0 KiB
JavaScript
const globals = require('../globals')
|
|
const db = globals.db
|
|
module.exports = {
|
|
name: 'add',
|
|
description: '',
|
|
aliases: [],
|
|
usage: '',
|
|
needs_args: true,
|
|
async exec(message, args) {
|
|
try {
|
|
console.log(message.author.tag + ': ' + args);
|
|
if (!isNaN(args[0])) {
|
|
message.reply(args[1]);
|
|
console.log('1: ' + args[1] + ', 2: ' + args[2]);
|
|
const money = ['gold', 'silver', 'bronce', 'iron', 'hp'];
|
|
db.find({
|
|
user: message.author.tag,
|
|
}, function(err, docs) {
|
|
|
|
gold = docs[0].gold;
|
|
silver = docs[0].silver;
|
|
bronce = docs[0].bronce;
|
|
iron = docs[0].iron;
|
|
hp = docs[0].hp;
|
|
|
|
});
|
|
db.update({
|
|
user: message.author.tag,
|
|
}, {
|
|
gold: gold,
|
|
silver: silver,
|
|
bronce: bronce,
|
|
iron: iron,
|
|
hp: hp,
|
|
}, function(err, docs) {
|
|
if (!docs.length > 0) {
|
|
message.reply('Sorry, Für dich habe ich keinen Eintrag 😥');
|
|
return;
|
|
}
|
|
message.reply(`ich habe ${args[2]} zu ${args[1]} hinzugefügt.`);
|
|
});
|
|
}
|
|
}
|
|
catch (e) {
|
|
throw e;
|
|
}
|
|
},
|
|
}; |