diff --git a/base/JaBa.js b/base/JaBa.js index 3730aa55..10c3e154 100644 --- a/base/JaBa.js +++ b/base/JaBa.js @@ -72,7 +72,7 @@ class JaBa extends Client { } else { setTimeout(() => { if (m.deletable) m.delete(); - }, 10 * 60 * 1000); // m * s * ms + }, (10 * 60 * 1000)); // m * s * ms } }) .on("queueEnd", queue => queue.metadata.channel.send(this.translate("music/play:QUEUE_ENDED", null, queue.metadata.channel.guild.data.language))) diff --git a/commands/Economy/birthdate.js b/commands/Economy/birthdate.js index e898f29b..0d425772 100644 --- a/commands/Economy/birthdate.js +++ b/commands/Economy/birthdate.js @@ -11,8 +11,28 @@ class Birthdate extends BaseCommand { command: new SlashCommandBuilder() .setName("birthdate") .setDescription(client.translate("economy/birthdate:DESCRIPTION")) - .addStringOption(option => option.setName("date") - .setDescription(client.translate("economy/birthdate:DATE")) + .addIntegerOption(option => option.setName("day") + .setDescription(client.translate("economy/birthdate:DAY")) + .setRequired(true)) + .addIntegerOption(option => option.setName("month") + .setDescription(client.translate("economy/birthdate:MONTH")) + .setRequired(true) + .addChoices( + { name: "Январь", value: 1 }, + { name: "Февраль", value: 2 }, + { name: "Март", value: 3 }, + { name: "Апрель", value: 4 }, + { name: "Май", value: 5 }, + { name: "Июнь", value: 6 }, + { name: "Июль", value: 7 }, + { name: "Август", value: 8 }, + { name: "Сентябрь", value: 9 }, + { name: "Октябрь", value: 10 }, + { name: "Ноябрь", value: 11 }, + { name: "Декабрь", value: 12 } + )) + .addIntegerOption(option => option.setName("year") + .setDescription(client.translate("economy/birthdate:YEAR")) .setRequired(true)), aliases: [], dirname: __dirname, @@ -34,11 +54,9 @@ class Birthdate extends BaseCommand { * @param {Object} data */ async execute(client, interaction, data) { - const date = interaction.options.getString("date"); - const match = date.match(/\d+/g); - if (!match) return interaction.error("economy/birthdate:INVALID_DATE"); - const [day, month, year] = date.split("/"); - if (!day || !month || !year) return interaction.error("economy/birthdate:INVALID_DATE"); + const day = interaction.options.getInteger("day"); + const month = interaction.options.getInteger("month"); + const year = interaction.options.getInteger("year"); const d = new Date(year, month - 1, day); if (!(day == d.getDate() && month - 1 == d.getMonth() && year == d.getFullYear())) return interaction.error("economy/birthdate:INVALID_DATE"); diff --git a/commands/Economy/marry.js b/commands/Economy/marry.js index 09d4a697..4f3d186f 100644 --- a/commands/Economy/marry.js +++ b/commands/Economy/marry.js @@ -79,14 +79,13 @@ class Marry extends BaseCommand { new ButtonBuilder() .setCustomId("marry_confirm_yes") .setLabel(interaction.translate("common:ACCEPT")) - .setStyle(ButtonStyle.Danger), + .setStyle(ButtonStyle.Success), new ButtonBuilder() .setCustomId("marry_confirm_no") .setLabel(interaction.translate("common:CANCEL")) - .setStyle(ButtonStyle.Secondary), + .setStyle(ButtonStyle.Danger), ); - await interaction.reply({ content: interaction.translate("economy/marry:REQUEST", { to: member.toString(), @@ -96,7 +95,7 @@ class Marry extends BaseCommand { }); const filter = i => i.user.id === member.id; - const collector = interaction.channel.createMessageComponentCollector({ filter, time: 120000 }); + const collector = interaction.channel.createMessageComponentCollector({ filter, time: (10 * 60 * 1000) }); collector.on("collect", async i => { if (i.isButton()) { @@ -107,7 +106,25 @@ class Marry extends BaseCommand { collector.on("end", async (_, reason) => { delete pendings[interaction.member.id]; - if (reason === "time") return interaction.error("economy/marry:TIMEOUT"); + if (reason === "time") { + const row = new ActionRowBuilder() + .addComponents( + new ButtonBuilder() + .setCustomId("marry_confirm_yes") + .setLabel(interaction.translate("common:ACCEPT")) + .setStyle(ButtonStyle.Success) + .setDisabled(true), + new ButtonBuilder() + .setCustomId("marry_confirm_no") + .setLabel(interaction.translate("common:CANCEL")) + .setStyle(ButtonStyle.Danger) + .setDisabled(true), + ); + return interaction.editReply({ + components: [row] + }); + } + if (reason) { data.userData.lover = member.id; await data.userData.save(); @@ -131,6 +148,7 @@ class Marry extends BaseCommand { userData.markModified("achievements.married"); await userData.save(); } + if (!data.userData.achievements.married.achieved) { if (!sent) interaction.followUp(messageOptions); data.userData.achievements.married.achieved = true; @@ -139,14 +157,20 @@ class Marry extends BaseCommand { await data.userData.save(); } - return interaction.success("economy/marry:SUCCESS", { - creator: interaction.member.toString(), - partner: member.toString() + return interaction.editReply({ + content: interaction.translate("economy/marry:SUCCESS", { + creator: interaction.member.toString(), + partner: member.toString() + }), + components: [] }); } else { - return interaction.success("economy/marry:DENIED", { - creator: interaction.member.toString(), - partner: member.toString() + return interaction.editReply({ + content: interaction.translate("economy/marry:DENIED", { + creator: interaction.member.toString(), + partner: member.toString() + }), + components: [] }); } }); diff --git a/commands/Economy/number.js b/commands/Economy/number.js index a88d2397..d6f8b491 100644 --- a/commands/Economy/number.js +++ b/commands/Economy/number.js @@ -105,7 +105,7 @@ class Number extends BaseCommand { }); }); - collector.on("end", (_collected, reason) => { + collector.on("end", (_, reason) => { delete currentGames[interaction.guildId]; if (reason === "time") return interaction.editReply({ content: interaction.translate("economy/number:DEFEAT", { number }) }); else if (reason === "force") return interaction.editReply({ content: interaction.translate("misc:FORCE_STOP", { user: interaction.member.toString() }) }); diff --git a/commands/Economy/work.js b/commands/Economy/work.js index 2a1d475a..ce6c78cf 100644 --- a/commands/Economy/work.js +++ b/commands/Economy/work.js @@ -37,9 +37,9 @@ class Work extends BaseCommand { time: client.convertTime(isInCooldown, true, true) }); } - if (Date.now() > data.memberData.cooldowns.work + (24 * 3600000)) data.memberData.workStreak = 0; + if (Date.now() > data.memberData.cooldowns.work + (24 * 60 * 60 * 1000)) data.memberData.workStreak = 0; - const toWait = Date.now() + 43200000; // 24 hours + const toWait = Date.now() + (24 * 60 * 60 * 1000); // 24 hours data.memberData.cooldowns.work = toWait; data.memberData.markModified("cooldowns"); diff --git a/commands/Fun/memes.js b/commands/Fun/memes.js index 603c5ec7..d6abd064 100644 --- a/commands/Fun/memes.js +++ b/commands/Fun/memes.js @@ -58,7 +58,7 @@ class Memes extends BaseCommand { filter, componentType: ComponentType.SelectMenu, message: msg, - idle: 30 * 1000 + idle: (60 * 1000) }); collector.on("collect", async i => { @@ -78,6 +78,14 @@ class Memes extends BaseCommand { embeds: [embed] }); }); + + collector.on("end", (_, reason) => { + if (reason === "idle") { + if (msg) msg.update({ + components: [] + }); + } + }); } } diff --git a/commands/General/activity.js b/commands/General/activity.js index 5fa09154..41bf543e 100644 --- a/commands/General/activity.js +++ b/commands/General/activity.js @@ -64,7 +64,7 @@ class Activity extends BaseCommand { filter, componentType: ComponentType.SelectMenu, message: msg, - idle: 30 * 1000 + idle: (2 * 1000) }); collector.on("collect", async i => { @@ -85,6 +85,14 @@ class Activity extends BaseCommand { components: [] }); }); + + collector.on("end", (_, reason) => { + if (reason === "idle") { + if (msg) msg.update({ + components: [] + }); + } + }); } } diff --git a/commands/General/help.js b/commands/General/help.js index 7c5e394c..72dd2af4 100644 --- a/commands/General/help.js +++ b/commands/General/help.js @@ -77,7 +77,7 @@ class Help extends BaseCommand { const collector = new InteractionCollector(client, { componentType: ComponentType.SelectMenu, message: msg, - idle: 60 * 1000 + idle: (2 * 1000) }); collector.on("collect", async msg => { @@ -115,6 +115,14 @@ class Help extends BaseCommand { }); } }); + + collector.on("end", (_, reason) => { + if (reason === "idle") { + if (msg) msg.update({ + components: [] + }); + } + }); } } diff --git a/commands/Music/clips.js b/commands/Music/clips.js index 0be17635..4fc3b9ec 100644 --- a/commands/Music/clips.js +++ b/commands/Music/clips.js @@ -63,7 +63,7 @@ class Clips extends BaseCommand { filter, componentType: ComponentType.SelectMenu, message: msg, - idle: 30 * 1000 + idle: (2 * 1000) }); collector.on("collect", async i => { @@ -106,6 +106,14 @@ class Clips extends BaseCommand { components: [] }); }); + + collector.on("end", (_, reason) => { + if (reason === "idle") { + if (msg) msg.update({ + components: [] + }); + } + }); }); } } diff --git a/commands/Music/loop.js b/commands/Music/loop.js index ce7e7ab5..50c7f462 100644 --- a/commands/Music/loop.js +++ b/commands/Music/loop.js @@ -71,7 +71,7 @@ class Loop extends BaseCommand { const collector = new InteractionCollector(client, { componentType: ComponentType.SelectMenu, message: msg, - idle: 60 * 1000 + idle: (2 * 1000) }); collector.on("collect", async i => { @@ -90,6 +90,14 @@ class Loop extends BaseCommand { components: [] }); }); + + collector.on("end", (_, reason) => { + if (reason === "idle") { + if (msg) msg.update({ + components: [] + }); + } + }); } } diff --git a/commands/Music/nowplaying.js b/commands/Music/nowplaying.js index ba0eec37..f741b5dd 100644 --- a/commands/Music/nowplaying.js +++ b/commands/Music/nowplaying.js @@ -42,7 +42,7 @@ class Nowplaying extends BaseCommand { .setAuthor({ name: interaction.translate("music/queue:TITLE") }) - .setThumbnail(track.thumbnail) + .setThumbnail(track.thumbnail || "https://cdn.discordapp.com/attachments/708642702602010684/1012418217660121089/noimage.png") .addFields([ { name: interaction.translate("music/nowplaying:T_TITLE"), diff --git a/commands/Music/skip.js b/commands/Music/skip.js index 2a671739..dc793ed8 100644 --- a/commands/Music/skip.js +++ b/commands/Music/skip.js @@ -36,24 +36,25 @@ class Skip extends BaseCommand { const queue = client.player.getQueue(interaction.guildId); if (!queue) return interaction.error("music/play:NOT_PLAYING"); - const embed = new EmbedBuilder() - .setAuthor({ - name: interaction.translate("music/skip:SUCCESS") - }) - .setThumbnail(queue.tracks[1].thumbnail || null) - .setDescription(interaction.translate("music/play:NOW_PLAYING", { - songName: queue.tracks[1].title - })) - .setFooter({ - text: client.config.embed.footer - }) - .setColor(client.config.embed.color); + const skipped = queue.skip(); + if (skipped) { + const embed = new EmbedBuilder() + .setAuthor({ + name: interaction.translate("music/skip:SUCCESS") + }) + .setThumbnail(queue.current.thumbnail || null) + .setDescription(interaction.translate("music/play:NOW_PLAYING", { + songName: queue.current.title + })) + .setFooter({ + text: client.config.embed.footer + }) + .setColor(client.config.embed.color); - queue.skip(); - - interaction.reply({ - embeds: [embed] - }); + interaction.reply({ + embeds: [embed] + }); + } } } diff --git a/commands/NSFW/nsfw.js b/commands/NSFW/nsfw.js index 523e5735..db54d7e5 100644 --- a/commands/NSFW/nsfw.js +++ b/commands/NSFW/nsfw.js @@ -61,7 +61,7 @@ class NSFW extends BaseCommand { filter, componentType: ComponentType.SelectMenu, message: msg, - idle: 60 * 1000 + idle: (60 * 1000) }); collector.on("collect", async i => { @@ -81,6 +81,14 @@ class NSFW extends BaseCommand { embeds: [embed] }); }); + + collector.on("end", (_, reason) => { + if (reason === "idle") { + if (msg) msg.update({ + components: [] + }); + } + }); } } diff --git a/commands/Owner/servers.js b/commands/Owner/servers.js index 53e46b8f..964bd0be 100644 --- a/commands/Owner/servers.js +++ b/commands/Owner/servers.js @@ -69,7 +69,7 @@ class Servers extends BaseCommand { await msg.react("❌"); const collector = msg.createReactionCollector({ - time: 60 * 1000 + time: (2 * 1000) }); collector.on("collect", async reaction => { diff --git a/events/Guild/guildCreate.js b/events/Guild/guildCreate.js index a3401aa8..db003a53 100644 --- a/events/Guild/guildCreate.js +++ b/events/Guild/guildCreate.js @@ -36,7 +36,7 @@ class GuildCreate extends BaseEvent { .setAuthor({ name: "Спасибо что добавили меня на свой сервер!" }) - .setDescription("Чтобы получить список команд использууйуте `/help` и посмотрите на административные команды!.") + .setDescription("Чтобы получить список команд, используйте `/help`!.") .setColor(client.config.embed.color) .setFooter({ text: client.config.embed.footer @@ -47,8 +47,8 @@ class GuildCreate extends BaseEvent { const owner = await guild.fetchOwner(); owner.send(messageOptions); - const users = guild.members.cache.filter((m) => !m.user.bot).size; - const bots = guild.members.cache.filter((m) => m.user.bot).size; + const users = guild.members.cache.filter(m => !m.user.bot).size; + const bots = guild.members.cache.filter(m => m.user.bot).size; const embed = new EmbedBuilder() .setAuthor({ diff --git a/events/Guild/guildMemberAdd.js b/events/Guild/guildMemberAdd.js index 21322bd2..26f2f7e2 100644 --- a/events/Guild/guildMemberAdd.js +++ b/events/Guild/guildMemberAdd.js @@ -3,7 +3,6 @@ const Canvas = require("canvas"), { AttachmentBuilder } = require("discord.js"), { resolve } = require("path"); -// Register assets fonts Canvas.registerFont(resolve("./assets/fonts/RubikMonoOne-Regular.ttf"), { family: "RubikMonoOne" }); Canvas.registerFont(resolve("./assets/fonts/KeepCalm-Medium.ttf"), { family: "KeepCalm" }); @@ -53,10 +52,8 @@ class GuildMemberAdd extends BaseEvent { }); } - // Check if the autorole is enabled if (guildData.plugins.autorole.enabled) member.roles.add(guildData.plugins.autorole.role); - // Check if welcome message is enabled if (guildData.plugins.welcome.enabled) { const channel = member.guild.channels.cache.get(guildData.plugins.welcome.channel); if (channel) { @@ -134,8 +131,7 @@ class GuildMemberAdd extends BaseEvent { ctx.closePath(); ctx.clip(); const avatar = await Canvas.loadImage(member.displayAvatarURL({ - extension: "jpg", - size: 512 + extension: "jpg" })); ctx.drawImage(avatar, 45, 90, 270, 270); diff --git a/events/Guild/guildMemberRemove.js b/events/Guild/guildMemberRemove.js index a18e8f20..3ddb1f59 100644 --- a/events/Guild/guildMemberRemove.js +++ b/events/Guild/guildMemberRemove.js @@ -3,7 +3,6 @@ const Canvas = require("canvas"), { AttachmentBuilder } = require("discord.js"), { resolve } = require("path"); -// Register assets fonts Canvas.registerFont(resolve("./assets/fonts/RubikMonoOne-Regular.ttf"), { family: "RubikMonoOne" }); Canvas.registerFont(resolve("./assets/fonts/KeepCalm-Medium.ttf"), { family: "KeepCalm" }); @@ -39,7 +38,6 @@ class GuildMemberRemove extends BaseEvent { }); member.guild.data = guildData; - // Check if goodbye message is enabled if (guildData.plugins.goodbye.enabled) { const channel = member.guild.channels.cache.get(guildData.plugins.goodbye.channel); if (channel) { diff --git a/events/Guild/guildMemberUpdate.js b/events/Guild/guildMemberUpdate.js index 9f4bdf11..17649167 100644 --- a/events/Guild/guildMemberUpdate.js +++ b/events/Guild/guildMemberUpdate.js @@ -17,9 +17,9 @@ class GuildMemberUpdate extends BaseEvent { async execute(client, oldMember, newMember) { if (oldMember.guild && oldMember.guild.id === "568120814776614924") return; if (oldMember.guild.id !== client.config.support.id) return; - if (oldMember.roles.cache.some((r) => r.name === "Поддержавшие JaBa")) return; + if (oldMember.roles.cache.some(r => r.name === "Поддержавшие JaBa")) return; - if (newMember?.roles.cache.some((r) => r.name === "Поддержавшие JaBa")) { + if (newMember?.roles.cache.some(r => r.name === "Поддержавшие JaBa")) { const userData = await client.findOrCreateUser({ id: newMember.id }); diff --git a/helpers/checkReminds.js b/helpers/checkReminds.js index 34f3743c..b50dd799 100644 --- a/helpers/checkReminds.js +++ b/helpers/checkReminds.js @@ -3,7 +3,7 @@ const { EmbedBuilder } = require("discord.js"); module.exports.init = function (client) { client.usersData .find({ reminds: { $gt: [] } }) - .then((users) => { + .then(users => { for (const user of users) { if (!client.users.cache.has(user.id)) client.users.fetch(user.id); client.databaseCache.usersReminds.set(user.id, user); diff --git a/helpers/checkUnmutes.js b/helpers/checkUnmutes.js index ff48d52a..63194b2c 100644 --- a/helpers/checkUnmutes.js +++ b/helpers/checkUnmutes.js @@ -3,7 +3,7 @@ const { EmbedBuilder } = require("discord.js"); module.exports.init = async function (client) { client.membersData .find({ "mute.muted": true }) - .then((members) => { + .then(members => { members.forEach((member) => client.databaseCache.mutedUsers.set(`${member.id}${member.guildID}`, member)); }); setInterval(async () => { diff --git a/helpers/clearTransactions.js b/helpers/clearTransactions.js index a12f658e..aa816e0b 100644 --- a/helpers/clearTransactions.js +++ b/helpers/clearTransactions.js @@ -1,7 +1,6 @@ module.exports.init = async function (client) { setInterval(async () => { - // Date.now() + days * hours * mins * secs * msecs / 1 month - const timestamp = Date.now() + 30 * 24 * 60 * 60 * 1000; + const timestamp = Date.now() + (30 * 24 * 60 * 60 * 1000); // 1 month const members = client.membersData.find({ transactions: { $gt: [] } }); for (const member of members) { @@ -14,5 +13,5 @@ module.exports.init = async function (client) { } } } - }, 7 * 24 * 60 * 60 * 1000); // every 7 days + }, (7 * 24 * 60 * 60 * 1000)); // every 7 days }; \ No newline at end of file diff --git a/helpers/tictactoe.js b/helpers/tictactoe.js index 105abc5a..aecb0f74 100644 --- a/helpers/tictactoe.js +++ b/helpers/tictactoe.js @@ -835,7 +835,7 @@ async function tictactoe(interaction, options = {}) { } }); - collector.on("end", (collected, reason) => { + collector.on("end", (_, reason) => { if (reason == "time") { const embed = new EmbedBuilder() .setTitle(interaction.translate("economy/tictactoe:NO_ANSWER_TITLE")) diff --git a/languages/ru-RU/economy/birthdate.json b/languages/ru-RU/economy/birthdate.json index 97b6c119..bee21b33 100644 --- a/languages/ru-RU/economy/birthdate.json +++ b/languages/ru-RU/economy/birthdate.json @@ -1,9 +1,10 @@ { "DESCRIPTION": "Установить дату рождения", - "USAGE": "[ДД/ММ/ГГГГ]", - "EXAMPLES": "birthdate 17/03/2002", - "DATE": "Дата в формате ДД/ММ/ГГГГ (Например: 17/03/2002)", - "INVALID_DATE": "Используйте данный формат: ДД/ММ/ГГГГ. Например: `17 марта 2002` будет `17/03/2002`.", + "USAGE": "[ДД] [ММ] [ГГГГ]", + "EXAMPLES": "birthdate 17 03 2002", + "DAY": "День", + "MONTH": "Месяц", + "YEAR": "Год", "DATE_TOO_LOW": "Вам больше 80 лет? :eyes:", "DATE_TOO_HIGH": "Хммм... Вы ещё не родились!", "HAPPY_BIRTHDAY": "День рождения", diff --git a/languages/ru-RU/economy/marry.json b/languages/ru-RU/economy/marry.json index fdf0aa17..685af2f8 100644 --- a/languages/ru-RU/economy/marry.json +++ b/languages/ru-RU/economy/marry.json @@ -10,7 +10,6 @@ "REQUEST_AMEMBER_TO_MEMBER": "{{secondUser}} уже отправил(а) предложение {{firstUser}}!", "REQUEST_MEMBER_TO_AMEMBER": "{{firstUser}} уже отправил(а) предложение {{secondUser}}! Подождите пока {{secondUser}} согласиться или откажет на предложение {{firstUser}} (либо дождитесь истечения срока предложения)!", "REQUEST": "{{to}}, вы согласны вступить в брак с {{from}}?", - "TIMEOUT": "Время на ответ вышло, попробуйте ещё раз!", "DENIED": "{{creator}}, у меня есть плохие новости... {{partner}} отказался(лась) от вашего предложение.", "SUCCESS": "🎉 Поздравляем! **{{creator}}** и **{{partner}}** теперь состоят в браке!", "BOT_USER": "Боты вечно одиноки ;(" diff --git a/package-lock.json b/package-lock.json index ae32eaed..0445d09f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "jaba", - "version": "4.0", + "version": "4.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "jaba", - "version": "4.0", + "version": "4.1", "license": "ISC", "dependencies": { "@discord-player/extractor": "^3.0.2", diff --git a/package.json b/package.json index 5197d2bc..67ca4312 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jaba", - "version": "4.0", + "version": "4.1", "description": "My Discord Bot", "main": "index.js", "private": true,