remove now deletes character from database
This commit is contained in:
@ -1,53 +1,6 @@
|
|||||||
module.exports = async (message, args, db) => {
|
module.exports = async (message, args, db) => {
|
||||||
let n;
|
db.remove({ user: message.author.tag }, {}, function (err, numRemoved) {
|
||||||
|
message.reply('Ich habe deine Daten gelöscht.\n'+
|
||||||
if(!isNaN(args[0]) && (args[1] === 'GD' || args[1] === 'ST' || args[1] === 'BH' || args[1] === 'EK')) {
|
"Wenn dir danach ist, kannst du mir gerne wieder eine neue Datei zusenden.")
|
||||||
// eslint-disable-next-line no-undef
|
});
|
||||||
db.query('SELECT * FROM dsageld WHERE userName = ' + '"' + message.author.tag + '"', function(err, row) { // the row is the user's data
|
|
||||||
if(row && err) {
|
|
||||||
message.reply('Es gab einen Fehler.');
|
|
||||||
}
|
|
||||||
if(typeof (row) == 'undefined') { // if the user is not in the database
|
|
||||||
message.reply('Es existiert kein Eintrag für dich füge ihn mit !create hinzu.');
|
|
||||||
}
|
|
||||||
else { // if the user is in the database
|
|
||||||
|
|
||||||
if(args[1] === 'GD') {
|
|
||||||
n = parseInt(row[0].GD, 10) - parseInt(args[0], 10);
|
|
||||||
}
|
|
||||||
else if(args[1] === 'ST') {
|
|
||||||
n = parseInt(row[0].ST, 10) - parseInt(args[0], 10);
|
|
||||||
}
|
|
||||||
else if(args[1] === 'BH') {
|
|
||||||
n = parseInt(row[0].BH, 10) - parseInt(args[0], 10);
|
|
||||||
}
|
|
||||||
else if(args[1] === 'EK') {
|
|
||||||
n = parseInt(row[0].EK, 10) - parseInt(args[0], 10);
|
|
||||||
}
|
|
||||||
else if(args[1] === 'LP') {
|
|
||||||
n = parseInt(row[0].EK, 10) - parseInt(args[0], 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(n >= 0) {
|
|
||||||
// eslint-disable-next-line no-undef
|
|
||||||
db.query('UPDATE dsageld SET' + '`' + args[1] + '`' + ' = (' + n + ') WHERE userName = ' + '"' + message.author.tag + '"');
|
|
||||||
// eslint-disable-next-line no-undef
|
|
||||||
db.query('SELECT * FROM dsageld WHERE userName = ' + '"' + message.author.tag + '"', function(err, row) { // the row is the user's data
|
|
||||||
message.reply(args[0] + args[1] + ' abgezogen, du hast: ' + row[0].GD + 'GD, ' + row[0].ST + 'ST, ' + row[0].BH + 'BH, ' + row[0].EK + 'EK,' + row[0].LP + 'LeP.');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else if(n < 0 && !(args[1] === 'LP')) {
|
|
||||||
message.reply('du hast nicht genügend ' + args[1]);
|
|
||||||
}
|
|
||||||
else if(n < 0 && args[1] === 'LP') {
|
|
||||||
// eslint-disable-next-line no-undef
|
|
||||||
db.query('UPDATE dsageld SET' + '`' + args[1] + '`' + ' = (' + n + ') WHERE userName = ' + '"' + message.author.tag + '"');
|
|
||||||
// eslint-disable-next-line no-undef
|
|
||||||
db.query('SELECT * FROM dsageld WHERE userName = ' + '"' + message.author.tag + '"', function(err, row) { // the row is the user's data
|
|
||||||
message.reply('Deine LeP sind unter Null: ' + n + ' LeP.');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
Reference in New Issue
Block a user