mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-11-22 05:04:58 +05:00
v3.4.1
Переписана функция случайных чисел supportLink переписана под создание приглашения на сервер по его ID Уменьшено кол-во опыта за сообщение Мелкие правки в локализации и коде
This commit is contained in:
parent
00d8ecdc1b
commit
4a5cc4e28d
6 changed files with 16 additions and 41 deletions
|
@ -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
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
|
@ -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({
|
||||
|
|
|
@ -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();
|
||||
}
|
|
@ -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) {
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue