ReferenceError: msg is not defined
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
const globals = require('../globals')
|
||||
const globals = require('../globals');
|
||||
module.exports = async (message, args, db) => {
|
||||
let coin = Math.floor(Math.random()*2)
|
||||
message.reply('Folgende Seite hat der Münzwurf ergeben: ' + globals.Coin[coin] + '.')
|
||||
const coin = Math.floor(Math.random() * 2);
|
||||
message.reply('Folgende Seite hat der Münzwurf ergeben: ' + globals.Coin[coin] + '.');
|
||||
};
|
@ -1,42 +1,45 @@
|
||||
const globals = require('../globals')
|
||||
const globals = require('../globals');
|
||||
module.exports = async (message, args, db) => {
|
||||
try {
|
||||
// user calls without arguments.
|
||||
if (!args[0]) {
|
||||
message.reply('Bitte gib mir ein Attributswert, oder das Attribut auf welches du würfeln möchtest.')
|
||||
return
|
||||
message.reply('Bitte gib mir ein Attributswert, oder das Attribut auf welches du würfeln möchtest.');
|
||||
return;
|
||||
}
|
||||
let level = 8
|
||||
let attributename
|
||||
let level = 8;
|
||||
let attributename;
|
||||
|
||||
await db.find({
|
||||
user: message.author.tag,
|
||||
}, async function (err, docs) {
|
||||
}, async function(err, docs) {
|
||||
|
||||
// user calls with text. need to gather info from database
|
||||
if (isNaN(args[0])) {
|
||||
if (!docs.length > 0) {
|
||||
message.reply('Sorry, Für dich habe ich keinen Eintrag 😥\n' +
|
||||
'Bitte gib mir den Attributswert, auf welchen du würfeln möchtest.');
|
||||
return
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
// try to get id of short formatted attributes.
|
||||
if (args[0].length == 2) {
|
||||
for (let i in globals.Werte) {
|
||||
for (const i in globals.Werte) {
|
||||
if (globals.Werte[i].kuerzel == args[0].toUpperCase()) attributename = globals.Werte[i].id;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
attributename = args[0].toLowerCase();
|
||||
}
|
||||
for (let i in docs[0].character.attributes) {
|
||||
for (const i in docs[0].character.attributes) {
|
||||
if (docs[0].character.attributes[i].id == attributename) level = docs[0].character.attributes[i].level;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
level = args[0];
|
||||
}
|
||||
const countOccurrences = (arr, val) => arr.reduce((a, v) => (v === val ? a + 1 : a), 0);
|
||||
let dice = []
|
||||
const dice = [];
|
||||
dice.push(Math.floor(Math.random() * 20) + 1);
|
||||
if (dice[0] == 1 || dice[0] == 20) {
|
||||
dice.push(Math.floor(Math.random() * 20) + 1);
|
||||
@ -44,30 +47,33 @@ module.exports = async (message, args, db) => {
|
||||
// handle crits
|
||||
if (countOccurrences(dice, 1) == 2) {
|
||||
message.reply('Du hast einen kritischen Erfolg erzielt (' + dice.join(', ') + ')! 🎉🥳🎆');
|
||||
return
|
||||
} else if (countOccurrences(dice, 20) == 2) {
|
||||
message.reply('Du hast einen Patzer (' + dice.join(', ') + ')! 😭 Viel Erfolg beim nächsten mal!')
|
||||
return
|
||||
return;
|
||||
}
|
||||
else if (countOccurrences(dice, 20) == 2) {
|
||||
message.reply('Du hast einen Patzer (' + dice.join(', ') + ')! 😭 Viel Erfolg beim nächsten mal!');
|
||||
return;
|
||||
}
|
||||
if ((dice.length == 2 && dice[0] != 20 && dice[1] <= level) || (dice.length == 1 && dice[0] <= level)) {
|
||||
if (attributename) {
|
||||
message.reply('Du hast die Probe auf ' + attributename + ' (Stufe ' + level + ') bestanden.\n' +
|
||||
'Deine 🎲: ' + dice.join(', '))
|
||||
} else {
|
||||
'Deine 🎲: ' + dice.join(', '));
|
||||
}
|
||||
else {
|
||||
message.reply('Du hast die Probe (Stufe ' + level + ') bestanden.\n' +
|
||||
'Deine 🎲: ' + dice.join(', '))
|
||||
'Deine 🎲: ' + dice.join(', '));
|
||||
}
|
||||
} else {
|
||||
if (attributename) {
|
||||
}
|
||||
else if (attributename) {
|
||||
message.reply('Du hast die Probe auf ' + attributename + ' (Stufe ' + level + ') leider nicht bestanden 😢.\n' +
|
||||
'Deine 🎲: ' + dice.join(', '))
|
||||
} else {
|
||||
message.reply('Du hast die Probe (Stufe ' + level + ') leider nicht bestanden 😢.\n' +
|
||||
'Deine 🎲: ' + dice.join(', '))
|
||||
'Deine 🎲: ' + dice.join(', '));
|
||||
}
|
||||
else {
|
||||
message.reply('Du hast die Probe (Stufe ' + level + ') leider nicht bestanden 😢.\n' +
|
||||
'Deine 🎲: ' + dice.join(', '));
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
}
|
||||
catch (e) {
|
||||
throw e;
|
||||
}
|
||||
};
|
@ -13,10 +13,10 @@ const kopf = require('./HeadsOrTails');
|
||||
const zahl = require('./HeadsOrTails');
|
||||
const heads = require('./HeadsOrTails');
|
||||
const tails = require('./HeadsOrTails');
|
||||
const e = require('./attribute')
|
||||
const ew = require('./attribute')
|
||||
const a = require('./attribute')
|
||||
const attr = require('./attribute')
|
||||
const e = require('./attribute');
|
||||
const ew = require('./attribute');
|
||||
const a = require('./attribute');
|
||||
const attr = require('./attribute');
|
||||
require('dotenv').config();
|
||||
|
||||
const cmdprefix = process.env.CMDPREFIX || '!';
|
||||
@ -37,7 +37,7 @@ const commands = {
|
||||
e,
|
||||
a,
|
||||
attr,
|
||||
ew
|
||||
ew,
|
||||
};
|
||||
|
||||
const Datastore = require('nedb'),
|
||||
@ -47,7 +47,7 @@ const Datastore = require('nedb'),
|
||||
});
|
||||
|
||||
module.exports = async (message) => {
|
||||
console.log(`${new Date().toUTCString()} ${message.author.tag} (size: ${message.attachments.size})`)
|
||||
console.log(`${new Date().toUTCString()} ${message.author.tag} (size: ${message.attachments.size})`);
|
||||
if ((message.attachments.size > 0) && message.channel.type == 'dm' && !message.author.bot) {
|
||||
try {
|
||||
const response = await fetch(message.attachments.first().url);
|
||||
|
@ -1,6 +1,6 @@
|
||||
module.exports = async (message, args, db) => {
|
||||
db.remove({ user: message.author.tag }, {}, function (err, numRemoved) {
|
||||
message.reply('Ich habe deine Daten gelöscht.\n'+
|
||||
"Wenn dir danach ist, kannst du mir gerne wieder eine neue Datei zusenden.")
|
||||
db.remove({ user: message.author.tag }, {}, function(err, numRemoved) {
|
||||
message.reply('Ich habe deine Daten gelöscht.\n' +
|
||||
'Wenn dir danach ist, kannst du mir gerne wieder eine neue Datei zusenden.');
|
||||
});
|
||||
};
|
@ -1,21 +1,24 @@
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
module.exports = async (message, args, db) => {
|
||||
let arguments = args.join('')
|
||||
let regex = /\s?[DdWw]\s?/;
|
||||
let msg;
|
||||
let arguments = args.join('');
|
||||
const regex = /\s?[DdWw]\s?/;
|
||||
arguments = arguments.split(regex);
|
||||
|
||||
if (arguments.length == 2){
|
||||
if (arguments.length == 2) {
|
||||
let numberOfDice = arguments[0];
|
||||
let diceValues = arguments[1];
|
||||
let roll = [];
|
||||
for (let i = 0; i<numberOfDice; i++) {
|
||||
let a = Math.floor(Math.random() * diceValues) + 1;
|
||||
roll.push(a)
|
||||
const diceValues = arguments[1];
|
||||
const roll = [];
|
||||
for (let i = 0; i < numberOfDice; i++) {
|
||||
const a = Math.floor(Math.random() * diceValues) + 1;
|
||||
roll.push(a);
|
||||
}
|
||||
if(numberOfDice=1) { let msg = 'n'}
|
||||
else { let msg = ' ' + numberOfDice;}
|
||||
message.reply('Das sind deine Ergebnisse für deine' + msg +' ' + diceValues + '-seitigen 🎲: ' + roll.join(', ') + '.')
|
||||
if(numberOfDice = 1) { let = 'n';}
|
||||
else { msg = ' ' + numberOfDice;}
|
||||
message.reply('Das sind deine Ergebnisse für deine' + msg + ' ' + diceValues + '-seitigen 🎲: ' + roll.join(', ') + '.');
|
||||
}
|
||||
else {
|
||||
message.reply('Leider kann ich damit nichts anfangen. Bitte noch einmal so probieren:\n' +
|
||||
'!roll <Anzahl> W <Augenzahl>');
|
||||
}
|
||||
else { message.reply('Leider kann ich damit nichts anfangen. Bitte noch einmal so probieren:\n'+
|
||||
'!roll <Anzahl> W <Augenzahl>')}
|
||||
};
|
@ -15,17 +15,17 @@ module.exports = async (message, args, db) => {
|
||||
}
|
||||
const values = [];
|
||||
const roll = [];
|
||||
let found = false
|
||||
let found = false;
|
||||
let bonus = 0;
|
||||
let ok = 0;
|
||||
let patzer = 0;
|
||||
let crit = 0;
|
||||
for (i in docs[0].character.skills) {
|
||||
if (docs[0].character.skills[i].id == args[0]) {bonus = docs[0].character.skills[i].level; found = true}
|
||||
if (docs[0].character.skills[i].id == args[0]) {bonus = docs[0].character.skills[i].level; found = true;}
|
||||
}
|
||||
if (!found) {
|
||||
message.reply('Sorry, das Talent ist mir unbekannt.')
|
||||
return
|
||||
message.reply('Sorry, das Talent ist mir unbekannt.');
|
||||
return;
|
||||
}
|
||||
const bonus_orig = bonus;
|
||||
const result = globals.Talente.find(talent => talent.id === args[0]);
|
||||
|
@ -4,7 +4,7 @@ const money = [{
|
||||
|
||||
|
||||
}];
|
||||
const Coin = ['Kopf','Zahl'];
|
||||
const Coin = ['Kopf', 'Zahl'];
|
||||
const Werte = [
|
||||
{ id: 'mut', kuerzel: 'MU', name: 'Mut' },
|
||||
{ id: 'klugheit', kuerzel: 'KL', name: 'Klugheit' },
|
||||
|
Reference in New Issue
Block a user