diff --git a/commands/Economy/findwords.js b/commands/Economy/findwords.js index ddda6226..3770f792 100644 --- a/commands/Economy/findwords.js +++ b/commands/Economy/findwords.js @@ -33,7 +33,7 @@ class FindWords extends Command { const participants = [], winners = [], words = [], - nbGames = this.client.functions.randomNum(4, 10); + nbGames = this.client.functions.randomNum(3, 10); // Store the date wich the game has started const createdAt = Date.now(); // 20929038303 diff --git a/commands/Economy/number.js b/commands/Economy/number.js index 0d88a97c..d070ef4c 100644 --- a/commands/Economy/number.js +++ b/commands/Economy/number.js @@ -23,7 +23,7 @@ class Number extends Command { if (currentGames[message.guild.id]) return message.error("economy/number:GAME_RUNNING"); const participants = [], - number = this.client.functions.randomNum(1000, 10000); + number = this.client.functions.randomNum(1000, 6000); await message.sendT("economy/number:GAME_START"); diff --git a/commands/Fun/8ball.js b/commands/Fun/8ball.js index a60a9c14..e0ab1bc7 100644 --- a/commands/Fun/8ball.js +++ b/commands/Fun/8ball.js @@ -19,7 +19,7 @@ class Eightball extends Command { async run(message, args) { if (!args[0] || !message.content.endsWith("?")) return message.error("fun/8ball:ERR_QUESTION"); - const answerN = this.client.functions.randomNum(1, 21); + const answerN = this.client.functions.randomNum(1, 20); const answer = message.translate(`fun/8ball:RESPONSE_${answerN}`); message.reply({ diff --git a/events/messageCreate.js b/events/messageCreate.js index 1d91eef1..2ae2420d 100644 --- a/events/messageCreate.js +++ b/events/messageCreate.js @@ -212,37 +212,23 @@ module.exports = class { } }; -/** - * updateXp - * This function update userdata by adding xp - */ async function updateXp(client, msg, data) { - // Gets the user informations const points = parseInt(data.memberData.exp); const level = parseInt(data.memberData.level); - - // if the member is already in the cooldown db const isInCooldown = xpCooldown[msg.author.id]; if (isInCooldown) { if (isInCooldown > Date.now()) return; } - // Records in the database the time when the member will be able to win xp again (1min) - const toWait = Date.now() + 60000; + const toWait = Date.now() + 60000; // 1 min xpCooldown[msg.author.id] = toWait; - // Gets a random number between 5 and 10 - const won = client.functions.randomNum(5, 10); - + const won = client.functions.randomNum(2, 5); const newXp = parseInt(points + won, 10); - - // calculation how many xp it takes for the next new one const neededXp = 5 * (level * level) + 80 * level + 100; - // check if the member up to the next level if (newXp > neededXp) data.memberData.level = parseInt(level + 1, 10); - // Update user data data.memberData.exp = parseInt(newXp, 10); await data.memberData.save(); } \ No newline at end of file diff --git a/helpers/functions.js b/helpers/functions.js index 96c9d56e..dd9e9fe5 100644 --- a/helpers/functions.js +++ b/helpers/functions.js @@ -5,12 +5,6 @@ languages.forEach((lang) => { }); module.exports = { - /** - * Gets message prefix - * @param {object} message The Discord message - * @param {object} data Server data - * @returns The prefix - */ getPrefix(message, data) { if (message.channel.type !== "DM") { const prefixes = [ @@ -21,34 +15,31 @@ module.exports = { message.client.user.username.toLowerCase(), data.guild.prefix ]; + let prefix = null; + prefixes.forEach((p) => { if (message.content.startsWith(p) || message.content.toLowerCase().startsWith(p)) prefix = p; }); return prefix; - } else { - return true; - } + } else return true; }, - // This function return an actual link to the support server - async supportLink(client) { - const guild = client.guilds.cache.get(client.config.support.id); + async createInvite(client, guildId) { + const guild = client.guilds.cache.get(guildId); const member = guild.me; const channel = guild.channels.cache.find((ch) => ch.permissionsFor(member.id).has(Permissions.FLAGS.CREATE_INSTANT_INVITE) && ch.type === "GUILD_TEXT" || ch.type === "GUILD_VOICE"); if (channel) { const invite = await channel.createInvite({ - maxAge: 0 + maxAge: 0, + maxUses: 5 }).catch(() => {}); - return invite ? invite.url : null; - } else { - return ""; - } + return invite ? invite.url : "No URL"; + } return "No Invite"; }, - // This function sort an array sortByKey(array, key) { return array.sort(function (a, b) { const x = a[key]; @@ -57,7 +48,6 @@ module.exports = { }); }, - // This function return a shuffled array shuffle(pArray) { const array = []; pArray.forEach(element => array.push(element)); @@ -78,9 +68,8 @@ module.exports = { return array; }, - // This function return a random number between min and max randomNum(min, max) { - return Math.floor(Math.random() * (max - min)) + min; + return Math.floor(Math.random() * (max - min) + min + 1); }, convertTime(guild, time) { diff --git a/package.json b/package.json index 4c1bc0ed..4d2f254b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jaba", - "version": "3.4.0", + "version": "3.4.1", "description": "A very complete Discord bot (more than 100 commands) that uses the Discord.js", "main": "index.js", "private": true,