Фолбек если у трека нет изображения
Фикс skip
Фикс marry
Замена способа ввода даты рождения в birthdate
This commit is contained in:
JonnyBro 2022-08-26 00:21:26 +05:00
parent b1aaf966b4
commit a9588b4118
26 changed files with 157 additions and 73 deletions

View file

@ -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)))

View file

@ -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");

View file

@ -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: []
});
}
});

View file

@ -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() }) });

View file

@ -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");

View file

@ -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: []
});
}
});
}
}

View file

@ -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: []
});
}
});
}
}

View file

@ -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: []
});
}
});
}
}

View file

@ -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: []
});
}
});
});
}
}

View file

@ -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: []
});
}
});
}
}

View file

@ -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"),

View file

@ -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]
});
}
}
}

View file

@ -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: []
});
}
});
}
}

View file

@ -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 => {

View file

@ -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({

View file

@ -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);

View file

@ -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) {

View file

@ -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
});

View file

@ -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);

View file

@ -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 () => {

View file

@ -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
};

View file

@ -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"))

View file

@ -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": "День рождения",

View file

@ -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": "Боты вечно одиноки ;("

4
package-lock.json generated
View file

@ -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",

View file

@ -1,6 +1,6 @@
{
"name": "jaba",
"version": "4.0",
"version": "4.1",
"description": "My Discord Bot",
"main": "index.js",
"private": true,