From 4a5cc4e28de35cf51295373bac6a7f909b8fa291 Mon Sep 17 00:00:00 2001 From: JonnyBro Date: Tue, 1 Mar 2022 22:53:05 +0500 Subject: [PATCH] =?UTF-8?q?v3.4.1=20=D0=9F=D0=B5=D1=80=D0=B5=D0=BF=D0=B8?= =?UTF-8?q?=D1=81=D0=B0=D0=BD=D0=B0=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8?= =?UTF-8?q?=D1=8F=20=D1=81=D0=BB=D1=83=D1=87=D0=B0=D0=B9=D0=BD=D1=8B=D1=85?= =?UTF-8?q?=20=D1=87=D0=B8=D1=81=D0=B5=D0=BB=20supportLink=20=D0=BF=D0=B5?= =?UTF-8?q?=D1=80=D0=B5=D0=BF=D0=B8=D1=81=D0=B0=D0=BD=D0=B0=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=B4=20=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=D0=B3=D0=BB=D0=B0=D1=88=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=BD=D0=B0=20=D1=81=D0=B5=D1=80=D0=B2=D0=B5=D1=80=20?= =?UTF-8?q?=D0=BF=D0=BE=20=D0=B5=D0=B3=D0=BE=20ID=20=D0=A3=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D1=8C=D1=88=D0=B5=D0=BD=D0=BE=20=D0=BA=D0=BE=D0=BB-?= =?UTF-8?q?=D0=B2=D0=BE=20=D0=BE=D0=BF=D1=8B=D1=82=D0=B0=20=D0=B7=D0=B0=20?= =?UTF-8?q?=D1=81=D0=BE=D0=BE=D0=B1=D1=89=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=9C?= =?UTF-8?q?=D0=B5=D0=BB=D0=BA=D0=B8=D0=B5=20=D0=BF=D1=80=D0=B0=D0=B2=D0=BA?= =?UTF-8?q?=D0=B8=20=D0=B2=20=D0=BB=D0=BE=D0=BA=D0=B0=D0=BB=D0=B8=D0=B7?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D0=B8=20=D0=B8=20=D0=BA=D0=BE=D0=B4=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commands/Economy/findwords.js | 2 +- commands/Economy/number.js | 2 +- commands/Fun/8ball.js | 2 +- events/messageCreate.js | 18 ++---------------- helpers/functions.js | 31 ++++++++++--------------------- package.json | 2 +- 6 files changed, 16 insertions(+), 41 deletions(-) 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,