This commit is contained in:
Jonny_Bro (Nikita) 2024-01-15 23:19:59 +05:00
parent 33f842088b
commit aec6ec7c58
No known key found for this signature in database
GPG key ID: 28B0D27F8DD5A4C9
8 changed files with 118 additions and 28 deletions

View file

@ -198,7 +198,8 @@ 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;
@ -231,6 +232,37 @@ async function changeSetting(interaction, setting, state, channel, guildData) {
ephemeral: true,
});
}
} else {
if (!state) {
guildData.plugins[setting] = null;
guildData.markModified(`plugins.${setting}`);
await guildData.save();
return interaction.reply({
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,
});
}
}
}
module.exports = Config;

View file

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

View file

@ -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}`,

View 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",
},
]);
}
}

View file

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

View file

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

View file

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

View file

@ -1,6 +1,6 @@
{
"name": "jaba",
"version": "4.4.0",
"version": "4.4.1",
"description": "My Discord Bot",
"main": "index.js",
"scripts": {