This commit is contained in:
JonnyBro 2023-01-09 01:39:13 +05:00
parent 0ae13edd23
commit d16b36687a
45 changed files with 165 additions and 108 deletions

View file

@ -38,8 +38,8 @@ class Automod extends BaseCommand {
* @param {Object} data * @param {Object} data
*/ */
async execute(client, interaction, data) { async execute(client, interaction, data) {
const state = interaction.options.getBoolean("state"); const state = interaction.options.getBoolean("state"),
const channel = interaction.options.getChannel("channel"); channel = interaction.options.getChannel("channel");
if (state) { if (state) {
data.guildData.plugins.automod = { data.guildData.plugins.automod = {
@ -48,12 +48,14 @@ class Automod extends BaseCommand {
}; };
data.guildData.markModified("plugins.automod"); data.guildData.markModified("plugins.automod");
await data.guildData.save(); await data.guildData.save();
return interaction.success("administration/automod:ENABLED"); return interaction.success("administration/automod:ENABLED");
} else { } else {
if (channel) { if (channel) {
data.guildData.plugins.automod.ignored.push(channel); data.guildData.plugins.automod.ignored.push(channel);
data.guildData.markModified("plugins.automod"); data.guildData.markModified("plugins.automod");
await data.guildData.save(); await data.guildData.save();
interaction.success("administration/automod:DISABLED_CHANNEL", { interaction.success("administration/automod:DISABLED_CHANNEL", {
channel: channel.toString(), channel: channel.toString(),
}); });
@ -64,6 +66,7 @@ class Automod extends BaseCommand {
}; };
data.guildData.markModified("plugins.automod"); data.guildData.markModified("plugins.automod");
await data.guildData.save(); await data.guildData.save();
interaction.success("administration/automod:DISABLED"); interaction.success("administration/automod:DISABLED");
} }
} }

View file

@ -132,9 +132,9 @@ class Config extends BaseCommand {
ephemeral: true, ephemeral: true,
}); });
} else { } else {
const setting = interaction.options.getString("setting"); const setting = interaction.options.getString("setting"),
const state = interaction.options.getBoolean("state"); state = interaction.options.getBoolean("state"),
const channel = interaction.options.getChannel("channel"); channel = interaction.options.getChannel("channel");
await changeSetting(interaction, setting, state, channel); await changeSetting(interaction, setting, state, channel);
} }
@ -154,6 +154,7 @@ async function changeSetting(interaction, setting, state, channel) {
interaction.guild.data.plugins[setting] = null; interaction.guild.data.plugins[setting] = null;
interaction.guild.data.markModified(`plugins.${setting}`); interaction.guild.data.markModified(`plugins.${setting}`);
await interaction.guild.data.save(); await interaction.guild.data.save();
return interaction.reply({ return interaction.reply({
content: `${interaction.translate(`administration/config:${setting.toUpperCase()}`)}: **${interaction.translate("common:DISABLED")}**`, content: `${interaction.translate(`administration/config:${setting.toUpperCase()}`)}: **${interaction.translate("common:DISABLED")}**`,
ephemeral: true, ephemeral: true,
@ -163,6 +164,7 @@ async function changeSetting(interaction, setting, state, channel) {
interaction.guild.data.plugins[setting] = channel.id; interaction.guild.data.plugins[setting] = channel.id;
interaction.guild.data.markModified(`plugins.${setting}`); interaction.guild.data.markModified(`plugins.${setting}`);
await interaction.guild.data.save(); await interaction.guild.data.save();
return interaction.reply({ return interaction.reply({
content: `${interaction.translate(`administration/config:${setting.toUpperCase()}`)}: **${interaction.translate("common:ENABLED")}** (${channel.toString()})`, content: `${interaction.translate(`administration/config:${setting.toUpperCase()}`)}: **${interaction.translate("common:ENABLED")}** (${channel.toString()})`,
ephemeral: true, ephemeral: true,

View file

@ -51,7 +51,8 @@ class Goodbye extends BaseCommand {
if (command === "test") { if (command === "test") {
client.emit("guildMemberRemove", interaction.member); client.emit("guildMemberRemove", interaction.member);
return interaction.success("administration/goodbye:TEST_SUCCESS", null, { ephemeral: true });
interaction.success("administration/goodbye:TEST_SUCCESS", null, { ephemeral: true });
} else { } else {
const state = interaction.options.getBoolean("state"); const state = interaction.options.getBoolean("state");

View file

@ -85,9 +85,10 @@ class Selectroles extends BaseCommand {
}, { edit: true }); }, { edit: true });
}); });
} else if (command === "addrole") { } else if (command === "addrole") {
const channel = interaction.options.getChannel("channel"); const channel = interaction.options.getChannel("channel"),
const message_id = interaction.options.getString("message_id"); message_id = interaction.options.getString("message_id"),
const message = await channel.messages.fetch(message_id); message = await channel.messages.fetch(message_id);
if (!message || message.author.id !== client.user.id) return interaction.error("administration/selectroles:MESSAGE_ROLE", null, { edit: true }); if (!message || message.author.id !== client.user.id) return interaction.error("administration/selectroles:MESSAGE_ROLE", null, { edit: true });
const role = interaction.options.getRole("role"); const role = interaction.options.getRole("role");

View file

@ -47,14 +47,15 @@ class Set extends BaseCommand {
* @param {Object} data * @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
const type = interaction.options.getString("type"); const type = interaction.options.getString("type"),
const member = interaction.options.getMember("user"); member = interaction.options.getMember("user");
if (member.user.bot) return interaction.error("misc:BOT_USER", null, { ephemeral: true }); if (member.user.bot) return interaction.error("misc:BOT_USER", null, { ephemeral: true });
const memberData = await client.findOrCreateMember({ const memberData = await client.findOrCreateMember({
id: member.id, id: member.id,
guildId: interaction.guildId, guildId: interaction.guildId,
}); });
const int = interaction.options.getInteger("int"); const int = interaction.options.getInteger("int");
if (int < 0) return interaction.error("administration/set:INVALID_NUMBER", null, { ephemeral: true }); if (int < 0) return interaction.error("administration/set:INVALID_NUMBER", null, { ephemeral: true });

View file

@ -39,8 +39,8 @@ class Setlang extends BaseCommand {
* @param {Object} data * @param {Object} data
*/ */
async execute(client, interaction, data) { async execute(client, interaction, data) {
const lang = interaction.options.getString("language"); const lang = interaction.options.getString("language"),
const language = client.languages.find(l => l.name === lang); language = client.languages.find(l => l.name === lang);
data.guildData.language = language.name; data.guildData.language = language.name;
await data.guildData.save(); await data.guildData.save();

View file

@ -35,8 +35,8 @@ class Stealemoji extends BaseCommand {
* @param {Object} data * @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
const parsedEmoji = parseEmoji(interaction.options.getString("emoji")); const parsedEmoji = parseEmoji(interaction.options.getString("emoji")),
const ext = parsedEmoji.animated ? "gif" : "png"; ext = parsedEmoji.animated ? "gif" : "png";
interaction.guild.emojis interaction.guild.emojis
.create({ .create({

View file

@ -51,7 +51,8 @@ class Welcome extends BaseCommand {
if (command === "test") { if (command === "test") {
client.emit("guildMemberAdd", interaction.member); client.emit("guildMemberAdd", interaction.member);
return interaction.success("administration/goodbye:TEST_SUCCESS", null, { ephemeral: true });
interaction.success("administration/goodbye:TEST_SUCCESS", null, { ephemeral: true });
} else { } else {
const state = interaction.options.getBoolean("state"); const state = interaction.options.getBoolean("state");

View file

@ -35,6 +35,7 @@ class Achievements extends BaseCommand {
async execute(client, interaction, data) { async execute(client, interaction, data) {
const user = interaction.options.getUser("user") || interaction.member; const user = interaction.options.getUser("user") || interaction.member;
if (user.bot) return interaction.error("economy/profile:BOT_USER"); if (user.bot) return interaction.error("economy/profile:BOT_USER");
const userData = (user.id === interaction.user.id ? data.userData : await client.findOrCreateUser({ const userData = (user.id === interaction.user.id ? data.userData : await client.findOrCreateUser({
id: user.id, id: user.id,
})); }));

View file

@ -54,9 +54,9 @@ class Birthdate extends BaseCommand {
* @param {Object} data * @param {Object} data
*/ */
async execute(client, interaction, data) { async execute(client, interaction, data) {
const day = interaction.options.getInteger("day"); const day = interaction.options.getInteger("day"),
const month = interaction.options.getInteger("month"); month = interaction.options.getInteger("month"),
const year = interaction.options.getInteger("year"); year = interaction.options.getInteger("year");
const d = new Date(year, month - 1, day); 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"); if (!(day == d.getDate() && month - 1 == d.getMonth() && year == d.getFullYear())) return interaction.error("economy/birthdate:INVALID_DATE");

View file

@ -69,8 +69,8 @@ class Leaderboard extends BaseCommand {
membersLeaderboard.sort((a, b) => b.money - a.money); membersLeaderboard.sort((a, b) => b.money - a.money);
if (membersLeaderboard.length > 20) membersLeaderboard.length = 20; if (membersLeaderboard.length > 20) membersLeaderboard.length = 20;
let userNames = ""; let userNames = "",
let money = ""; money = "";
for (let i = 0; i < membersLeaderboard.length; i++) { for (let i = 0; i < membersLeaderboard.length; i++) {
const data = membersLeaderboard[i]; const data = membersLeaderboard[i];
@ -113,9 +113,9 @@ class Leaderboard extends BaseCommand {
membersLeaderboard.sort((a, b) => b.level - a.level); membersLeaderboard.sort((a, b) => b.level - a.level);
if (membersLeaderboard.length > 20) membersLeaderboard.length = 20; if (membersLeaderboard.length > 20) membersLeaderboard.length = 20;
const userNames = []; const userNames = [],
const level = []; level = [],
const xp = []; xp = [];
for (let i = 0; i < membersLeaderboard.length; i++) { for (let i = 0; i < membersLeaderboard.length; i++) {
const data = membersLeaderboard[i]; const data = membersLeaderboard[i];
@ -166,8 +166,8 @@ class Leaderboard extends BaseCommand {
usersLeaderboard.sort((a, b) => b.rep - a.rep); usersLeaderboard.sort((a, b) => b.rep - a.rep);
if (usersLeaderboard.length > 20) usersLeaderboard.length = 20; if (usersLeaderboard.length > 20) usersLeaderboard.length = 20;
let userNames = ""; let userNames = "",
let rep = ""; rep = "";
for (let i = 0; i < usersLeaderboard.length; i++) { for (let i = 0; i < usersLeaderboard.length; i++) {
const data = usersLeaderboard[i]; const data = usersLeaderboard[i];

View file

@ -36,9 +36,11 @@ class Marry extends BaseCommand {
*/ */
async execute(client, interaction, data) { async execute(client, interaction, data) {
if (data.userData.lover) return interaction.error("economy/marry:ALREADY_MARRIED"); if (data.userData.lover) return interaction.error("economy/marry:ALREADY_MARRIED");
const member = interaction.options.getMember("user"); const member = interaction.options.getMember("user");
if (member.user.bot) return interaction.error("economy/marry:BOT_USER"); if (member.user.bot) return interaction.error("economy/marry:BOT_USER");
if (member.id === interaction.member.id) return interaction.error("economy/marry:YOURSELF"); if (member.id === interaction.member.id) return interaction.error("economy/marry:YOURSELF");
const userData = await client.findOrCreateUser({ const userData = await client.findOrCreateUser({
id: member.id, id: member.id,
}); });

View file

@ -40,10 +40,9 @@ class Pay extends BaseCommand {
const member = interaction.options.getMember("user"); const member = interaction.options.getMember("user");
if (member.user.bot) return interaction.error("economy/pay:BOT_USER"); if (member.user.bot) return interaction.error("economy/pay:BOT_USER");
if (member.id === interaction.member.id) return interaction.error("economy/pay:YOURSELF"); if (member.id === interaction.member.id) return interaction.error("economy/pay:YOURSELF");
const amount = interaction.options.getInteger("amount"); const amount = interaction.options.getInteger("amount");
if (amount <= 0) return interaction.error("misc:MORE_THAN_ZERO"); if (amount <= 0) return interaction.error("misc:MORE_THAN_ZERO");
if (amount > data.memberData.money) return interaction.error("economy/pay:ENOUGH_MONEY", { if (amount > data.memberData.money) return interaction.error("economy/pay:ENOUGH_MONEY", {
amount: `**${amount}** ${client.getNoun(amount, interaction.translate("misc:NOUNS:CREDITS:1"), interaction.translate("misc:NOUNS:CREDITS:2"), interaction.translate("misc:NOUNS:CREDITS:5"))}`, amount: `**${amount}** ${client.getNoun(amount, interaction.translate("misc:NOUNS:CREDITS:1"), interaction.translate("misc:NOUNS:CREDITS:2"), interaction.translate("misc:NOUNS:CREDITS:5"))}`,
}); });

View file

@ -50,6 +50,7 @@ class Profile extends BaseCommand {
id: member.id, id: member.id,
guildId: interaction.guildId, guildId: interaction.guildId,
})); }));
const userData = (member.id === interaction.user.id ? data.userData : await client.findOrCreateUser({ const userData = (member.id === interaction.user.id ? data.userData : await client.findOrCreateUser({
id: member.id, id: member.id,
})); }));

View file

@ -47,6 +47,7 @@ class Rep extends BaseCommand {
const toWait = Date.now() + 21600000; // 12 hours const toWait = Date.now() + 21600000; // 12 hours
if (!data.userData.cooldowns) data.userData.cooldowns = {}; if (!data.userData.cooldowns) data.userData.cooldowns = {};
data.userData.cooldowns.rep = toWait; data.userData.cooldowns.rep = toWait;
data.userData.markModified("cooldowns"); data.userData.markModified("cooldowns");
await data.userData.save(); await data.userData.save();

View file

@ -40,6 +40,7 @@ class Rob extends BaseCommand {
const member = interaction.options.getMember("user"); const member = interaction.options.getMember("user");
if (member.user.bot) return interaction.error("economy/pay:BOT_USER"); if (member.user.bot) return interaction.error("economy/pay:BOT_USER");
if (member.id === interaction.member.id) return interaction.error("economy/rob:YOURSELF"); if (member.id === interaction.member.id) return interaction.error("economy/rob:YOURSELF");
const amount = interaction.options.getInteger("amount"); const amount = interaction.options.getInteger("amount");
if (amount <= 0) return interaction.error("misc:MORE_THAN_ZERO"); if (amount <= 0) return interaction.error("misc:MORE_THAN_ZERO");
@ -63,29 +64,36 @@ class Rob extends BaseCommand {
const itsAWon = Math.floor(client.functions.randomNum(0, 100) < 25); const itsAWon = Math.floor(client.functions.randomNum(0, 100) < 25);
if (itsAWon) { if (itsAWon) {
const toWait = Date.now() + (6 * 60 * 60 * 1000); const toWait = Date.now() + (6 * 60 * 60 * 1000),
randomNum = client.functions.randomNum(1, 2);
memberData.cooldowns.rob = toWait; memberData.cooldowns.rob = toWait;
memberData.markModified("cooldowns"); memberData.markModified("cooldowns");
await memberData.save(); await memberData.save();
const randomNum = client.functions.randomNum(1, 2);
interaction.replyT("economy/rob:ROB_WON_" + randomNum, { interaction.replyT("economy/rob:ROB_WON_" + randomNum, {
money: `**${amount}** ${client.getNoun(amount, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, money: `**${amount}** ${client.getNoun(amount, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
user: member.toString(), user: member.toString(),
}); });
data.memberData.money += amount; data.memberData.money += amount;
memberData.money -= amount; memberData.money -= amount;
await memberData.save(); await memberData.save();
await data.memberData.save(); await data.memberData.save();
} else { } else {
const won = Math.floor(amount * 0.9); const won = Math.floor(amount * 0.9),
const randomNum = client.functions.randomNum(1, 2); randomNum = client.functions.randomNum(1, 2);
interaction.replyT("economy/rob:ROB_LOSE_" + randomNum, { interaction.replyT("economy/rob:ROB_LOSE_" + randomNum, {
fine: `**${potentiallyLose}** ${client.getNoun(potentiallyLose, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, fine: `**${potentiallyLose}** ${client.getNoun(potentiallyLose, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
offset: `**${won}** ${client.getNoun(won, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, offset: `**${won}** ${client.getNoun(won, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
user: member.toString(), user: member.toString(),
}); });
data.memberData.money -= potentiallyLose; data.memberData.money -= potentiallyLose;
memberData.money += won; memberData.money += won;
await memberData.save(); await memberData.save();
await data.memberData.save(); await data.memberData.save();
} }

View file

@ -39,11 +39,11 @@ class Lovecalc extends BaseCommand {
* @param {Object} data * @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
const firstMember = interaction.options.getMember("first_member"); const firstMember = interaction.options.getMember("first_member"),
const secondMember = interaction.options.getMember("second_member") || interaction.member; secondMember = interaction.options.getMember("second_member") || interaction.member;
const members = [firstMember, secondMember].sort((a, b) => parseInt(a.id, 10) - parseInt(b.id, 10)); const members = [firstMember, secondMember].sort((a, b) => parseInt(a.id, 10) - parseInt(b.id, 10)),
const hash = md5(`${members[0].id}${members[1].user.username}${members[0].user.username}${members[1].id}`); hash = md5(`${members[0].id}${members[1].user.username}${members[0].user.username}${members[1].id}`);
const string = hash const string = hash
.split("") .split("")

View file

@ -91,7 +91,7 @@ class Report extends BaseCommand {
interaction.success("general/report:SUCCESS", { interaction.success("general/report:SUCCESS", {
channel: repChannel.toString(), channel: repChannel.toString(),
}); }, { ephemeral: true });
} }
} }

View file

@ -78,7 +78,7 @@ class Suggest extends BaseCommand {
interaction.success("general/suggest:SUCCESS", { interaction.success("general/suggest:SUCCESS", {
channel: suggChannel.toString(), channel: suggChannel.toString(),
}); }, { ephemeral: true });
} }
} }

View file

@ -44,6 +44,7 @@ class Clearwarns extends BaseCommand {
memberData.sanctions = []; memberData.sanctions = [];
memberData.save(); memberData.save();
interaction.success("moderation/clearwarns:SUCCESS", { interaction.success("moderation/clearwarns:SUCCESS", {
username: member.user.tag, username: member.user.tag,
}); });

View file

@ -35,11 +35,12 @@ class Unban extends BaseCommand {
* @param {Object} data * @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
const id = interaction.options.getString("user_id"); const id = interaction.options.getString("user_id"),
const banned = await interaction.guild.bans.fetch(); banned = await interaction.guild.bans.fetch();
if (!banned.find(u => u.user.id === id)) return interaction.error("moderation/unban:NOT_BANNED", { id }); if (!banned.find(u => u.user.id === id)) return interaction.error("moderation/unban:NOT_BANNED", { id });
interaction.guild.bans.remove(id); await interaction.guild.bans.remove(id);
interaction.success("moderation/unban:UNBANNED", { interaction.success("moderation/unban:UNBANNED", {
id, id,

View file

@ -32,9 +32,10 @@ class Warn extends BaseCommand {
* @param {Object} data * @param {Object} data
*/ */
async execute(client, interaction, data) { async execute(client, interaction, data) {
const member = interaction.targetMember; const member = interaction.targetMember,
const memberPosition = member.roles.highest.position; memberPosition = member.roles.highest.position,
const moderationPosition = interaction.member.roles.highest.position; moderationPosition = interaction.member.roles.highest.position;
if (member.user.bot) return interaction.error("misc:BOT_USER", null, { ephemeral: true }); if (member.user.bot) return interaction.error("misc:BOT_USER", null, { ephemeral: true });
if (member.id === interaction.member.id) return interaction.error("moderation/warn:YOURSELF", null, { ephemeral: true }); if (member.id === interaction.member.id) return interaction.error("moderation/warn:YOURSELF", null, { ephemeral: true });
if (interaction.guild.ownerId !== interaction.member.id && !(moderationPosition > memberPosition)) return interaction.error("moderation/ban:SUPERIOR", null, { ephemeral: true }); if (interaction.guild.ownerId !== interaction.member.id && !(moderationPosition > memberPosition)) return interaction.error("moderation/ban:SUPERIOR", null, { ephemeral: true });
@ -51,6 +52,9 @@ class Warn extends BaseCommand {
const reasonInput = new TextInputBuilder() const reasonInput = new TextInputBuilder()
.setCustomId("warn_reason") .setCustomId("warn_reason")
.setLabel(interaction.translate("moderation/warn:MODAL_REASON")) .setLabel(interaction.translate("moderation/warn:MODAL_REASON"))
.setMinLength(5)
.setMaxLength(200)
.setRequired(true)
.setStyle(TextInputStyle.Short); .setStyle(TextInputStyle.Short);
modal.addComponents(new ActionRowBuilder().addComponents(reasonInput)); modal.addComponents(new ActionRowBuilder().addComponents(reasonInput));
@ -58,14 +62,19 @@ class Warn extends BaseCommand {
await interaction.showModal(modal); await interaction.showModal(modal);
const submitted = await interaction.awaitModalSubmit({ const submitted = await interaction.awaitModalSubmit({
time: 120000, time: (2 * 60 * 1000),
filter: i => i.user.id === interaction.member.id && i.customId === "warn_modal", filter: i => i.user.id === interaction.member.id && i.customId === "warn_modal",
}).catch(() => {
interaction.followUp({
content: interaction.translate("misc:TIMED_OUT"),
ephemeral: true,
});
}); });
if (submitted) { if (submitted) {
const reason = submitted.fields.getTextInputValue("warn_reason"); const reason = submitted.fields.getTextInputValue("warn_reason");
const sanctions = memberData.sanctions.filter((s) => s.type === "warn").length; const sanctions = memberData.sanctions.filter(s => s.type === "warn").length;
const banCount = data.guildData.plugins.warnsSanctions.ban; const banCount = data.guildData.plugins.warnsSanctions.ban;
const kickCount = data.guildData.plugins.warnsSanctions.kick; const kickCount = data.guildData.plugins.warnsSanctions.kick;
@ -113,9 +122,11 @@ class Warn extends BaseCommand {
.setColor(client.config.embed.color); .setColor(client.config.embed.color);
interaction.guild.members.ban(member).catch(() => {}); interaction.guild.members.ban(member).catch(() => {});
interaction.success("moderation/setwarns:AUTO_BAN", { interaction.followUp({
username: member.user.tag, content: interaction.translate("moderation/setwarns:AUTO_BAN", {
count: `${banCount} ${client.getNoun(banCount, interaction.translate("misc:NOUNS:WARNS:1"), interaction.translate("misc:NOUNS:WARNS:2"), interaction.translate("misc:NOUNS:WARNS:5"))}`, username: member.user.tag,
count: `${banCount} ${client.getNoun(banCount, interaction.translate("misc:NOUNS:WARNS:1"), interaction.translate("misc:NOUNS:WARNS:2"), interaction.translate("misc:NOUNS:WARNS:5"))}`,
}),
}); });
} }
} }
@ -140,9 +151,11 @@ class Warn extends BaseCommand {
.setColor(client.config.embed.color); .setColor(client.config.embed.color);
member.kick().catch(() => {}); member.kick().catch(() => {});
interaction.success("moderation/setwarns:AUTO_KICK", { interaction.followUp({
username: member.user.tag, content: interaction.translate("moderation/setwarns:AUTO_KICK", {
count: `${kickCount} ${client.getNoun(kickCount, interaction.translate("misc:NOUNS:WARNS:1"), interaction.translate("misc:NOUNS:WARNS:2"), interaction.translate("misc:NOUNS:WARNS:5"))}`, username: member.user.tag,
count: `${kickCount} ${client.getNoun(kickCount, interaction.translate("misc:NOUNS:WARNS:1"), interaction.translate("misc:NOUNS:WARNS:2"), interaction.translate("misc:NOUNS:WARNS:5"))}`,
}),
}); });
} }
} }
@ -156,20 +169,12 @@ class Warn extends BaseCommand {
}), }),
}); });
caseInfo.type = "warn";
embed embed
.setAuthor({ .setAuthor({
name: interaction.translate("moderation/warn:WARN"), name: interaction.translate("moderation/warn:WARN"),
}) })
.setColor(client.config.embed.color); .setColor(client.config.embed.color);
submitted.reply({
content: interaction.translate("moderation/warn:WARNED", {
user: member.toString(),
reason,
}),
});
memberData.sanctions.push(caseInfo); memberData.sanctions.push(caseInfo);
memberData.save(); memberData.save();
@ -181,6 +186,13 @@ class Warn extends BaseCommand {
embeds: [embed], embeds: [embed],
}); });
} }
return submitted.reply({
content: interaction.translate("moderation/warn:WARNED", {
user: member.toString(),
reason,
}),
});
} }
} }
} }

View file

@ -69,7 +69,7 @@ class Warns extends BaseCommand {
memberData.sanctions.forEach(sanction => { memberData.sanctions.forEach(sanction => {
embed.addFields([ embed.addFields([
{ {
name: sanction.type + " | #" + sanction.case, name: sanction.type,
value: `${interaction.translate("common:MODERATOR")}: <@${sanction.moderator}>\n${interaction.translate("common:REASON")}: ${sanction.reason}`, value: `${interaction.translate("common:MODERATOR")}: <@${sanction.moderator}>\n${interaction.translate("common:REASON")}: ${sanction.reason}`,
inline: true, inline: true,
}, },

View file

@ -33,6 +33,7 @@ class Back extends BaseCommand {
async execute(client, interaction) { async execute(client, interaction) {
const voice = interaction.member.voice.channel; const voice = interaction.member.voice.channel;
if (!voice) return interaction.error("music/play:NO_VOICE_CHANNEL", null, { ephemeral: true }); if (!voice) return interaction.error("music/play:NO_VOICE_CHANNEL", null, { ephemeral: true });
const queue = client.player.getQueue(interaction.guildId); const queue = client.player.getQueue(interaction.guildId);
if (!queue) return interaction.error("music/play:NOT_PLAYING", null, { ephemeral: true }); if (!queue) return interaction.error("music/play:NOT_PLAYING", null, { ephemeral: true });
if (!queue.previousTracks[0]) return interaction.error("music/back:NO_PREV_SONG", null, { ephemeral: true }); if (!queue.previousTracks[0]) return interaction.error("music/back:NO_PREV_SONG", null, { ephemeral: true });

View file

@ -156,6 +156,7 @@ class Clips extends BaseCommand {
} else { } else {
const voice = interaction.member.voice.channel; const voice = interaction.member.voice.channel;
if (!voice) return interaction.editReply({ content: interaction.translate("music/play:NO_VOICE_CHANNEL") }); if (!voice) return interaction.editReply({ content: interaction.translate("music/play:NO_VOICE_CHANNEL") });
const queue = client.player.getQueue(interaction.guild.id); const queue = client.player.getQueue(interaction.guild.id);
if (queue) return interaction.editReply({ content: interaction.translate("music/clips:ACTIVE_QUEUE") }); if (queue) return interaction.editReply({ content: interaction.translate("music/clips:ACTIVE_QUEUE") });
if (getVoiceConnection(interaction.guild.id)) return interaction.editReply({ content: interaction.translate("music/clips:ACTIVE_CLIP") }); if (getVoiceConnection(interaction.guild.id)) return interaction.editReply({ content: interaction.translate("music/clips:ACTIVE_CLIP") });

View file

@ -43,13 +43,14 @@ class Loop extends BaseCommand {
async execute(client, interaction) { async execute(client, interaction) {
const voice = interaction.member.voice.channel; const voice = interaction.member.voice.channel;
if (!voice) return interaction.error("music/play:NO_VOICE_CHANNEL", null, { edit: true }); if (!voice) return interaction.error("music/play:NO_VOICE_CHANNEL", null, { edit: true });
const queue = client.player.getQueue(interaction.guildId); const queue = client.player.getQueue(interaction.guildId);
if (!queue) return interaction.error("music/play:NOT_PLAYING", null, { edit: true }); if (!queue) return interaction.error("music/play:NOT_PLAYING", null, { edit: true });
const type = interaction.options.getString("option"); const type = interaction.options.getString("option"),
const mode = type === "3" ? QueueRepeatMode.AUTOPLAY : mode = type === "3" ? QueueRepeatMode.AUTOPLAY :
type === "2" ? QueueRepeatMode.QUEUE : type === "2" ? QueueRepeatMode.QUEUE :
type === "1" ? QueueRepeatMode.TRACK : QueueRepeatMode.OFF; type === "1" ? QueueRepeatMode.TRACK : QueueRepeatMode.OFF;
queue.setRepeatMode(mode); queue.setRepeatMode(mode);

View file

@ -36,8 +36,8 @@ class Nowplaying extends BaseCommand {
const queue = client.player.getQueue(interaction.guildId); const queue = client.player.getQueue(interaction.guildId);
if (!queue) return interaction.error("music/play:NOT_PLAYING", null, { edit: true }); if (!queue) return interaction.error("music/play:NOT_PLAYING", null, { edit: true });
const progressBar = queue.createProgressBar(); const progressBar = queue.createProgressBar(),
const track = queue.current; track = queue.current;
const embed = new EmbedBuilder() const embed = new EmbedBuilder()
.setAuthor({ .setAuthor({

View file

@ -36,9 +36,10 @@ class Play extends BaseCommand {
async execute(client, interaction) { async execute(client, interaction) {
await interaction.deferReply(); await interaction.deferReply();
const voice = interaction.member.voice.channel; const query = interaction.options.getString("query"),
voice = interaction.member.voice.channel;
if (!voice) return interaction.error("music/play:NO_VOICE_CHANNEL", null, { edit: true }); if (!voice) return interaction.error("music/play:NO_VOICE_CHANNEL", null, { edit: true });
const query = interaction.options.getString("query");
const perms = voice.permissionsFor(client.user); const perms = voice.permissionsFor(client.user);
if (!perms.has(PermissionsBitField.Flags.Connect) || !perms.has(PermissionsBitField.Flags.Speak)) return interaction.error("music/play:VOICE_CHANNEL_CONNECT", null, { edit: true }); if (!perms.has(PermissionsBitField.Flags.Connect) || !perms.has(PermissionsBitField.Flags.Speak)) return interaction.error("music/play:VOICE_CHANNEL_CONNECT", null, { edit: true });

View file

@ -33,11 +33,12 @@ class Seek extends BaseCommand {
* @param {Object} data * @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
const voice = interaction.member.voice.channel; const time = interaction.options.getInteger("time"),
voice = interaction.member.voice.channel;
if (!voice) return interaction.error("music/play:NO_VOICE_CHANNEL"); if (!voice) return interaction.error("music/play:NO_VOICE_CHANNEL");
const queue = client.player.getQueue(interaction.guildId); const queue = client.player.getQueue(interaction.guildId);
if (!queue) return interaction.error("music/play:NOT_PLAYING"); if (!queue) return interaction.error("music/play:NOT_PLAYING");
const time = interaction.options.getInteger("time");
queue.seek(time * 1000); queue.seek(time * 1000);
interaction.success("music/seek:SUCCESS", { interaction.success("music/seek:SUCCESS", {

View file

@ -33,6 +33,7 @@ class Shuffle extends BaseCommand {
async execute(client, interaction) { async execute(client, interaction) {
const voice = interaction.member.voice.channel; const voice = interaction.member.voice.channel;
if (!voice) return interaction.error("music/play:NO_VOICE_CHANNEL", null, { ephemeral: true }); if (!voice) return interaction.error("music/play:NO_VOICE_CHANNEL", null, { ephemeral: true });
const queue = client.player.getQueue(interaction.guildId); const queue = client.player.getQueue(interaction.guildId);
if (!queue) return interaction.error("music/play:NOT_PLAYING", null, { ephemeral: true }); if (!queue) return interaction.error("music/play:NOT_PLAYING", null, { ephemeral: true });

View file

@ -33,6 +33,7 @@ class Skip extends BaseCommand {
async execute(client, interaction) { async execute(client, interaction) {
const voice = interaction.member.voice.channel; const voice = interaction.member.voice.channel;
if (!voice) return interaction.error("music/play:NO_VOICE_CHANNEL"); if (!voice) return interaction.error("music/play:NO_VOICE_CHANNEL");
const queue = client.player.getQueue(interaction.guildId); const queue = client.player.getQueue(interaction.guildId);
if (!queue) return interaction.error("music/play:NOT_PLAYING"); if (!queue) return interaction.error("music/play:NOT_PLAYING");

View file

@ -35,12 +35,13 @@ class Skipto extends BaseCommand {
*/ */
async execute(client, interaction) { async execute(client, interaction) {
const voice = interaction.member.voice.channel; const voice = interaction.member.voice.channel;
const queue = client.player.getQueue(interaction.guildId);
const position = interaction.options.getInteger("position");
if (!voice) return interaction.error("music/play:NO_VOICE_CHANNEL"); if (!voice) return interaction.error("music/play:NO_VOICE_CHANNEL");
const queue = client.player.getQueue(interaction.guildId);
if (!queue) return interaction.error("music/play:NOT_PLAYING"); if (!queue) return interaction.error("music/play:NOT_PLAYING");
if (position < 0) return interaction.error("music/skipto:NO_PREV_SONG");
const position = interaction.options.getInteger("position");
if (position <= 0) return interaction.error("music/skipto:NO_PREV_SONG");
if (queue.tracks[position - 1]) { if (queue.tracks[position - 1]) {
queue.skipTo(queue.tracks[position - 1]); queue.skipTo(queue.tracks[position - 1]);

View file

@ -33,6 +33,7 @@ class Stop extends BaseCommand {
async execute(client, interaction) { async execute(client, interaction) {
const voice = interaction.member.voice.channel; const voice = interaction.member.voice.channel;
if (!voice) return interaction.error("music/play:NO_VOICE_CHANNEL"); if (!voice) return interaction.error("music/play:NO_VOICE_CHANNEL");
const queue = client.player.getQueue(interaction.guildId); const queue = client.player.getQueue(interaction.guildId);
if (!queue) return interaction.error("music/play:NOT_PLAYING"); if (!queue) return interaction.error("music/play:NOT_PLAYING");

View file

@ -54,6 +54,7 @@ class Announcement extends BaseCommand {
client.guilds.cache.forEach(async guild => { client.guilds.cache.forEach(async guild => {
if (guild.id === "568120814776614924") return; if (guild.id === "568120814776614924") return;
const channel = guild.channels.cache.get(guild?.data.plugins.news); const channel = guild.channels.cache.get(guild?.data.plugins.news);
await channel.send({ await channel.send({
content: `${interaction.options.getBoolean("tag") ? "||@everyone|| " : ""}ВАЖНОЕ ОБЪЯВЛЕНИЕ!`, content: `${interaction.options.getBoolean("tag") ? "||@everyone|| " : ""}ВАЖНОЕ ОБЪЯВЛЕНИЕ!`,

View file

@ -72,17 +72,20 @@ class Debug extends BaseCommand {
const command = interaction.options.getSubcommand(); const command = interaction.options.getSubcommand();
if (command === "set") { if (command === "set") {
const type = interaction.options.getString("type"); const type = interaction.options.getString("type"),
int = interaction.options.getInteger("int");
const member = interaction.options.getMember("user"); const member = interaction.options.getMember("user");
if (member.user.bot) return interaction.error("misc:BOT_USER", null, { ephemeral: true }); if (member.user.bot) return interaction.error("misc:BOT_USER", null, { ephemeral: true });
const userData = await client.findOrCreateUser({ const userData = await client.findOrCreateUser({
id: member.id, id: member.id,
}); }),
const memberData = await client.findOrCreateMember({ memberData = await client.findOrCreateMember({
id: member.id, id: member.id,
guildId: interaction.guildId, guildId: interaction.guildId,
}); });
const int = interaction.options.getInteger("int");
switch (type) { switch (type) {
case "level": { case "level": {
@ -131,17 +134,19 @@ class Debug extends BaseCommand {
} }
} }
} else { } else {
const type = interaction.options.getString("type"); const type = interaction.options.getString("type"),
int = interaction.options.getInteger("int");
const member = interaction.options.getMember("target"); const member = interaction.options.getMember("target");
if (member.user.bot) return interaction.error("misc:BOT_USER", null, { ephemeral: true }); if (member.user.bot) return interaction.error("misc:BOT_USER", null, { ephemeral: true });
const userData = await client.findOrCreateUser({ const userData = await client.findOrCreateUser({
id: member.id, id: member.id,
}); }),
const memberData = await client.findOrCreateMember({ memberData = await client.findOrCreateMember({
id: member.id, id: member.id,
guildId: interaction.guildId, guildId: interaction.guildId,
}); });
const int = interaction.options.getInteger("int");
switch (type) { switch (type) {
case "level": { case "level": {

View file

@ -42,16 +42,16 @@ class Eval extends BaseCommand {
return result.then(output => { return result.then(output => {
if (typeof output != "string") output = require("util").inspect(output, { depth: 0 }); if (typeof output != "string") output = require("util").inspect(output, { depth: 0 });
if (output.includes(client.token)) output = output.replace(client.token, "T0K3N"); if (output.includes(client.token)) output = output.replace(client.token, "T0K3N");
interaction.editReply({ interaction.editReply({
content: "```js\n" + output + "```", content: "```js\n" + output + "```",
}); });
}).catch(err => { }).catch(err => {
console.error(err); console.log(err);
err = err.toString(); err = err.toString();
if (err.includes(client.token)) err = err.replace(client.token, "T0K3N"); if (err.includes(client.token)) err = err.replace(client.token, "T0K3N");
interaction.editReply({ interaction.editReply({
content: "```js\n" + err + "```", content: "```js\n" + err + "```",
}); });

View file

@ -36,8 +36,8 @@ class Reload extends BaseCommand {
* @param {Object} data * @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
const command = interaction.options.getString("command"); const command = interaction.options.getString("command"),
const cmd = client.commands.get(command); cmd = client.commands.get(command);
if (!cmd) return interaction.error("owner/reload:NOT_FOUND", { command }, { ephemeral: true }); if (!cmd) return interaction.error("owner/reload:NOT_FOUND", { command }, { ephemeral: true });
await client.unloadCommand(`../commands/${cmd.category}`, cmd.command.name); await client.unloadCommand(`../commands/${cmd.category}`, cmd.command.name);

View file

@ -37,8 +37,9 @@ class Say extends BaseCommand {
*/ */
async execute(client, interaction) { async execute(client, interaction) {
await interaction.deferReply({ ephemeral: true }); await interaction.deferReply({ ephemeral: true });
const message = interaction.options.getString("message");
const channel = interaction.options.getChannel("channel"); const message = interaction.options.getString("message"),
channel = interaction.options.getChannel("channel");
if (!channel) { if (!channel) {
interaction.channel.sendTyping(); interaction.channel.sendTyping();

View file

@ -1,3 +1,10 @@
### JaBa v4.1.19
* Изменения
* Мелкие внутренние изменения.
* Исправления
* Ошибки *warn*.
### JaBa v4.1.18 ### JaBa v4.1.18
* Изменения * Изменения
* Обновление зависимостей. * Обновление зависимостей.

View file

@ -110,7 +110,7 @@ async function tictactoe(interaction, options = {}) {
const collector = m.createMessageComponentCollector({ const collector = m.createMessageComponentCollector({
componentType: ComponentType.Button, componentType: ComponentType.Button,
time: 5000, time: (5 * 1000),
}); });
collector.on("collect", async button => { collector.on("collect", async button => {
if (button.user.id !== opponent.id) if (button.user.id !== opponent.id)
@ -664,7 +664,7 @@ async function tictactoe(interaction, options = {}) {
const collector = m.createMessageComponentCollector({ const collector = m.createMessageComponentCollector({
componentType: ComponentType.Button, componentType: ComponentType.Button,
max: 1, max: 1,
time: 5000, time: (5 * 1000),
}); });
collector.on("collect", b => { collector.on("collect", b => {
@ -838,7 +838,7 @@ async function tictactoe(interaction, options = {}) {
.setColor(options.timeoutEmbedColor || "#C90000") .setColor(options.timeoutEmbedColor || "#C90000")
.setFooter(foot) .setFooter(foot)
.setTimestamp() .setTimestamp()
.setDescription(interaction.translate("economy/tictactoe:TIMES_UP")); .setDescription(interaction.translate("misc:TIMED_OUT"));
m.interaction.editReply({ m.interaction.editReply({
content: interaction.translate("economy/tictactoe:NOT_ANSWERED", { content: interaction.translate("economy/tictactoe:NOT_ANSWERED", {
user: opponent.id, user: opponent.id,

View file

@ -16,6 +16,5 @@
"NO_ANSWER_TITLE": "Запрос не принят вовремя", "NO_ANSWER_TITLE": "Запрос не принят вовремя",
"NOT_ANSWERED": "<@{{user}}> не принял запрос!", "NOT_ANSWERED": "<@{{user}}> не принял запрос!",
"CANCELED": "Игра отменена!", "CANCELED": "Игра отменена!",
"CANCELED_DESC": "<@{{user}}> отказался от игры!", "CANCELED_DESC": "<@{{user}}> отказался от игры!"
"TIMES_UP": "Время вышло! Лимит: 30 секунд"
} }

View file

@ -12,7 +12,7 @@
"OWNER_ONLY": "Данную команду может использовать только владелец бота!", "OWNER_ONLY": "Данную команду может использовать только владелец бота!",
"SELECT_CANCELED": "Выбор отменён...", "SELECT_CANCELED": "Выбор отменён...",
"STATS_FOOTER": "● [Панель управления]({{dashboardLink}})\n● [Документация]({{docsLink}})\n● [Пригласить JaBa на свой сервер]({{inviteLink}})\n● [Поддержать]({{donateLink}}) (укажите ваш Discord тэг для выдачи ачивки, для других способов поддержки пишите в ЛС <@{{owner}}>)", "STATS_FOOTER": "● [Панель управления]({{dashboardLink}})\n● [Документация]({{docsLink}})\n● [Пригласить JaBa на свой сервер]({{inviteLink}})\n● [Поддержать]({{donateLink}}) (укажите ваш Discord тэг для выдачи ачивки, для других способов поддержки пишите в ЛС <@{{owner}}>)",
"TIMES_UP": "Время вышло! Используйте команду снова!", "TIMED_OUT": "Время вышло!",
"JUMP_TO_PAGE": "Укажите страницу к которой хотите перейти (максимум **{{length}}**):", "JUMP_TO_PAGE": "Укажите страницу к которой хотите перейти (максимум **{{length}}**):",
"PERMISSIONS": { "PERMISSIONS": {

View file

@ -12,7 +12,7 @@
"OWNER_ONLY": "Цю команду може використовувати тільки власник бота!", "OWNER_ONLY": "Цю команду може використовувати тільки власник бота!",
"SELECT_CANCELED": "Вибір скасовано...", "SELECT_CANCELED": "Вибір скасовано...",
"STATS_FOOTER": "● [Панель керування]({{dashboardLink}})\n● [Документація]({{docsLink}})\n● [Запросити JaBa на свій сервер]({{inviteLink}})\n● [Підтримати]({{donateLink}}) (вкажіть ваш Discord тег для видачі ачивки, для інших способів підтримки пишіть в ЛЗ <@{{owner}}>)", "STATS_FOOTER": "● [Панель керування]({{dashboardLink}})\n● [Документація]({{docsLink}})\n● [Запросити JaBa на свій сервер]({{inviteLink}})\n● [Підтримати]({{donateLink}}) (вкажіть ваш Discord тег для видачі ачивки, для інших способів підтримки пишіть в ЛЗ <@{{owner}}>)",
"TIMES_UP": "Час вийшов! Використовуйте команду знову!", "TIMES_UP": "Час вийшов!",
"JUMP_TO_PAGE": "Вкажіть сторінку, до якої хочете перейти (максимум **{{length}}**):", "JUMP_TO_PAGE": "Вкажіть сторінку, до якої хочете перейти (максимум **{{length}}**):",
"PERMISSIONS": { "PERMISSIONS": {

4
package-lock.json generated
View file

@ -1,12 +1,12 @@
{ {
"name": "jaba", "name": "jaba",
"version": "4.1.18", "version": "4.1.19",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "jaba", "name": "jaba",
"version": "4.1.18", "version": "4.1.19",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@discord-player/extractor": "^3.0.2", "@discord-player/extractor": "^3.0.2",

View file

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