mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-11-22 05:04:58 +05:00
v4.4.1 - https://blog.jababot.ru
This commit is contained in:
parent
33f842088b
commit
aec6ec7c58
8 changed files with 118 additions and 28 deletions
|
@ -198,38 +198,70 @@ class Config extends BaseCommand {
|
|||
async function changeSetting(interaction, setting, state, channel, guildData) {
|
||||
const settingSplitted = setting.split(".");
|
||||
|
||||
if (settingSplitted.length === 2 && guildData.plugins[settingSplitted[0]] === undefined) guildData.plugins[settingSplitted[0]] = {};
|
||||
if (settingSplitted.length === 2) {
|
||||
if (guildData.plugins[settingSplitted[0]] === undefined) guildData.plugins[settingSplitted[0]] = {};
|
||||
|
||||
if (!state) {
|
||||
guildData.plugins[settingSplitted[0]][settingSplitted[1]] = null;
|
||||
|
||||
guildData.markModified(`plugins.${settingSplitted[0]}`);
|
||||
await guildData.save();
|
||||
|
||||
return interaction.reply({
|
||||
content: `${interaction.translate(`administration/config:${settingSplitted.length === 2 ? settingSplitted[1].toUpperCase() : setting.toUpperCase()}`)}: **${interaction.translate("common:DISABLED")}**`,
|
||||
ephemeral: true,
|
||||
});
|
||||
} else {
|
||||
if (settingSplitted[1] === "ticketsCategory" && channel.type !== ChannelType.GuildCategory) return interaction.reply({ content: interaction.translate("administration/config:TICKETS_NOT_CATEGORY"), ephemeral: true });
|
||||
|
||||
if (channel) {
|
||||
guildData.plugins[settingSplitted[0]][settingSplitted[1]] = channel.id;
|
||||
if (!state) {
|
||||
guildData.plugins[settingSplitted[0]][settingSplitted[1]] = null;
|
||||
|
||||
guildData.markModified(`plugins.${settingSplitted[0]}`);
|
||||
await guildData.save();
|
||||
|
||||
return interaction.reply({
|
||||
content: `${interaction.translate(`administration/config:${settingSplitted.length === 2 ? settingSplitted[1].toUpperCase() : setting.toUpperCase()}`)}: **${interaction.translate("common:ENABLED")}** (${channel.toString()})`,
|
||||
content: `${interaction.translate(`administration/config:${settingSplitted.length === 2 ? settingSplitted[1].toUpperCase() : setting.toUpperCase()}`)}: **${interaction.translate("common:DISABLED")}**`,
|
||||
ephemeral: true,
|
||||
});
|
||||
} else
|
||||
} else {
|
||||
if (settingSplitted[1] === "ticketsCategory" && channel.type !== ChannelType.GuildCategory) return interaction.reply({ content: interaction.translate("administration/config:TICKETS_NOT_CATEGORY"), ephemeral: true });
|
||||
|
||||
if (channel) {
|
||||
guildData.plugins[settingSplitted[0]][settingSplitted[1]] = channel.id;
|
||||
|
||||
guildData.markModified(`plugins.${settingSplitted[0]}`);
|
||||
await guildData.save();
|
||||
|
||||
return interaction.reply({
|
||||
content: `${interaction.translate(`administration/config:${settingSplitted.length === 2 ? settingSplitted[1].toUpperCase() : setting.toUpperCase()}`)}: **${interaction.translate("common:ENABLED")}** (${channel.toString()})`,
|
||||
ephemeral: true,
|
||||
});
|
||||
} else
|
||||
return interaction.reply({
|
||||
content: `${interaction.translate(`administration/config:${settingSplitted.length === 2 ? settingSplitted[1].toUpperCase() : setting.toUpperCase()}`)}: ${
|
||||
guildData.plugins[setting] ? `**${interaction.translate("common:ENABLED")}** (<#${guildData.plugins[setting]}>)` : `**${interaction.translate("common:DISABLED")}**`
|
||||
}`,
|
||||
ephemeral: true,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (!state) {
|
||||
guildData.plugins[setting] = null;
|
||||
|
||||
guildData.markModified(`plugins.${setting}`);
|
||||
await guildData.save();
|
||||
|
||||
return interaction.reply({
|
||||
content: `${interaction.translate(`administration/config:${settingSplitted.length === 2 ? settingSplitted[1].toUpperCase() : setting.toUpperCase()}`)}: ${
|
||||
guildData.plugins[setting] ? `**${interaction.translate("common:ENABLED")}** (<#${guildData.plugins[setting]}>)` : `**${interaction.translate("common:DISABLED")}**`
|
||||
}`,
|
||||
content: `${interaction.translate(`administration/config:${setting.toUpperCase()}`)}: **${interaction.translate("common:DISABLED")}**`,
|
||||
ephemeral: true,
|
||||
});
|
||||
} else {
|
||||
if (channel) {
|
||||
guildData.plugins[setting] = channel.id;
|
||||
|
||||
guildData.markModified(`plugins.${setting}`);
|
||||
await guildData.save();
|
||||
|
||||
return interaction.reply({
|
||||
content: `${interaction.translate(`administration/config:${setting.toUpperCase()}`)}: **${interaction.translate("common:ENABLED")}** (${channel.toString()})`,
|
||||
ephemeral: true,
|
||||
});
|
||||
} else
|
||||
return interaction.reply({
|
||||
content: `${interaction.translate(`administration/config:${setting.toUpperCase()}`)}: ${
|
||||
guildData.plugins[setting] ? `**${interaction.translate("common:ENABLED")}** (<#${guildData.plugins[setting]}>)` : `**${interaction.translate("common:DISABLED")}**`
|
||||
}`,
|
||||
ephemeral: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -127,7 +127,7 @@ class Help extends BaseCommand {
|
|||
commands = [...new Map(client.commands.map(v => [v.constructor.name, v])).values()],
|
||||
results = commands.filter(c => c.command.name.includes(command));
|
||||
|
||||
return interaction.respond(
|
||||
return await interaction.respond(
|
||||
results.slice(0, 25).map(command => ({
|
||||
name: command.command.name,
|
||||
value: command.command.name,
|
||||
|
|
|
@ -90,7 +90,7 @@ class Clips extends BaseCommand {
|
|||
files = fs.readdirSync("./clips"),
|
||||
results = files.filter(f => f.includes(query));
|
||||
|
||||
return interaction.respond(
|
||||
return await interaction.respond(
|
||||
results.slice(0, 25).map(file => ({
|
||||
name: file.substring(0, file.length - 4),
|
||||
value: `./clips/${file}`,
|
||||
|
|
|
@ -110,12 +110,17 @@ class Play extends BaseCommand {
|
|||
|
||||
const results = await client.player.search(query);
|
||||
|
||||
return interaction.respond(
|
||||
return results.tracks.length > 0 ? await interaction.respond(
|
||||
results.tracks.slice(0, 10).map(track => ({
|
||||
name: (`${track.author} - ${track.title}`.length >= 100) & (`${track.author} - ${track.title}`.slice(0, 80) + "...") || `${track.author} - ${track.title}`,
|
||||
value: track.url,
|
||||
})),
|
||||
);
|
||||
) : await interaction.respond([
|
||||
{
|
||||
name: "Nothing",
|
||||
value: "Nothing",
|
||||
},
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ class Volume extends BaseCommand {
|
|||
const int = interaction.options.getInteger("int"),
|
||||
results = Array.from({ length: 100 }, (_, k) => k + 1).filter(i => i.toString().includes(int));
|
||||
|
||||
return interaction.respond(
|
||||
return await interaction.respond(
|
||||
results.slice(0, 25).map(i => ({
|
||||
name: i,
|
||||
value: i,
|
||||
|
|
|
@ -73,7 +73,7 @@ class Reload extends BaseCommand {
|
|||
const command = interaction.options.getString("command"),
|
||||
results = client.commands.filter(c => c.command.name.includes(command));
|
||||
|
||||
return interaction.respond(
|
||||
return await interaction.respond(
|
||||
results
|
||||
.map(c => c)
|
||||
.slice(0, 25)
|
||||
|
|
|
@ -64,3 +64,56 @@ module.exports.init = async function (client) {
|
|||
|
||||
cronjob.start();
|
||||
};
|
||||
|
||||
module.exports.run = async function (client) {
|
||||
client.guilds.cache.forEach(async guild => {
|
||||
const guildData = await client.findOrCreateGuild(guild.id);
|
||||
|
||||
if (guildData.plugins.birthdays) {
|
||||
const channel = guild.channels.cache.get(guildData.plugins.birthdays) || await guild.channels.fetch(guildData.plugins.birthdays),
|
||||
date = new Date(),
|
||||
currentDay = date.getDate(),
|
||||
currentMonth = date.getMonth(),
|
||||
currentYear = date.getFullYear();
|
||||
|
||||
if (channel) {
|
||||
client.usersData.find({ birthdate: { $gt: 1 } }).then(async users => {
|
||||
for (const user of users) {
|
||||
if (!guild.members.cache.find(m => m.id === user.id)) return;
|
||||
|
||||
const userDate = new Date(user.birthdate),
|
||||
day = userDate.getDate(),
|
||||
month = userDate.getMonth(),
|
||||
year = userDate.getFullYear(),
|
||||
age = currentYear - year;
|
||||
|
||||
if (currentMonth === month && currentDay === day) {
|
||||
const embed = new EmbedBuilder()
|
||||
.setAuthor({
|
||||
name: client.user.getUsername(),
|
||||
iconURL: client.user.displayAvatarURL(),
|
||||
})
|
||||
.setColor(client.config.embed.color)
|
||||
.setFooter(client.config.embed.footer)
|
||||
.addFields([
|
||||
{
|
||||
name: client.translate("economy/birthdate:HAPPY_BIRTHDAY", null, guildData.language),
|
||||
value: client.translate("economy/birthdate:HAPPY_BIRTHDAY_MESSAGE", {
|
||||
name: user.username,
|
||||
user: user.id,
|
||||
age: `**${age}** ${client.functions.getNoun(age, client.translate("misc:NOUNS:AGE:1", null, guildData.language), client.translate("misc:NOUNS:AGE:2", null, guildData.language), client.translate("misc:NOUNS:AGE:5", null, guildData.language))}`,
|
||||
}, guildData.language),
|
||||
},
|
||||
]);
|
||||
|
||||
const msg = await channel.send({
|
||||
embeds: [embed],
|
||||
});
|
||||
await msg.react("🎉");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "jaba",
|
||||
"version": "4.4.0",
|
||||
"version": "4.4.1",
|
||||
"description": "My Discord Bot",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
|
Loading…
Reference in a new issue