This commit is contained in:
Jonny_Bro (Nikita) 2024-02-09 23:26:57 +05:00
parent 427e1c6ae2
commit cc0fd759f7
No known key found for this signature in database
GPG key ID: 391C19BE62D36B33
92 changed files with 428 additions and 440 deletions

View file

@ -41,7 +41,7 @@ class JaBaClient extends Client {
this.player.events.on("playerStart", async (queue, track) => {
const m = (
await queue.metadata.channel.send({
content: this.translate("music/play:NOW_PLAYING", { songName: track.title }, queue.metadata.channel.guild.data.language),
content: this.translate("music/play:NOW_PLAYING", { songName: track.title }, queue.metadata.data.guild.language),
})
).id;
@ -58,14 +58,14 @@ class JaBaClient extends Client {
if (message && message.deletable) message.delete();
}, 5 * 60 * 1000);
});
this.player.events.on("emptyQueue", queue => queue.metadata.channel.send(this.translate("music/play:QUEUE_ENDED", null, queue.metadata.channel.guild.data.language)));
this.player.events.on("emptyChannel", queue => queue.metadata.channel.send(this.translate("music/play:STOP_EMPTY", null, queue.metadata.channel.guild.data.language)));
this.player.events.on("emptyQueue", queue => queue.metadata.channel.send(this.translate("music/play:QUEUE_ENDED", null, queue.metadata.data.guild.language)));
this.player.events.on("emptyChannel", queue => queue.metadata.channel.send(this.translate("music/play:STOP_EMPTY", null, queue.metadata.data.guild.language)));
this.player.events.on("playerError", (queue, e) => {
queue.metadata.channel.send({ content: this.translate("music/play:ERR_OCCURRED", { error: e.message }, queue.metadata.channel.guild.data.language) });
queue.metadata.channel.send({ content: this.translate("music/play:ERR_OCCURRED", { error: e.message }, queue.metadata.data.guild.language) });
console.log(e);
});
this.player.events.on("error", (queue, e) => {
queue.metadata.channel.send({ content: this.translate("music/play:ERR_OCCURRED", { error: e.message }, queue.metadata.channel.guild.data.language) });
queue.metadata.channel.send({ content: this.translate("music/play:ERR_OCCURRED", { error: e.message }, queue.metadata.data.guild.language) });
console.log(e);
});
@ -150,7 +150,7 @@ class JaBaClient extends Client {
* @returns {String} Bot's default language
*/
get defaultLanguage() {
return this.languages.find(language => language.default).name;
return this.languages.find(language => language.default);
}
/**
@ -159,7 +159,7 @@ class JaBaClient extends Client {
* @param {Array} args Arguments for translation
* @param {String} locale Language
*/
translate(key, args, locale = this.defaultLanguage) {
translate(key, args, locale = this.defaultLanguage.name) {
const lang = this.translations.get(locale);
return lang(key, args);
@ -224,7 +224,7 @@ class JaBaClient extends Client {
}
/**
* Unloads a command
* Removes a command from cache
* @param {String} dir Directory where command is located
* @param {String} name Command name
* @returns

View file

@ -46,7 +46,6 @@ class Ban extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
await interaction.deferReply();

View file

@ -23,17 +23,18 @@ class ImportMee6 extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
async execute(client, interaction) {
await interaction.deferReply();
const level = (await Mee6Api.getUserXp(interaction.guildId, interaction.member)).level;
data.memberData.level = level;
interaction.data.member.level = level;
interaction.data.member.exp = 0;
data.memberData.markModified("level");
await data.memberData.save();
interaction.data.member.markModified("level");
interaction.data.member.markModified("exp");
await interaction.data.member.save();
interaction.editReply({
content: interaction.translate("owner/debug:SUCCESS_LEVEL", {

View file

@ -46,7 +46,6 @@ class Kick extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
await interaction.deferReply();

View file

@ -33,6 +33,8 @@ class Memes extends BaseCommand {
if (interaction.customId === "memes_select") {
interaction.deferUpdate();
interaction.guild.data = await client.findOrCreateGuild(interaction.guildId);
const tag = interaction.values[0];
const res = await fetch(`https://meme-api.com/gimme/${tag}`).then(response => response.json());
@ -53,7 +55,6 @@ class Memes extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
await interaction.deferReply({ ephemeral: true });

View file

@ -25,7 +25,6 @@ class Staff extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
await interaction.guild.members.fetch();

View file

@ -65,28 +65,28 @@ class Automod extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
const state = interaction.options.getBoolean("state"),
async execute(client, interaction) {
const { data } = interaction,
state = interaction.options.getBoolean("state"),
channel = interaction.options.getChannel("channel"),
command = interaction.options.getSubcommand();
if (command === "toggle") {
data.guildData.plugins.automod = {
data.guild.plugins.automod = {
enabled: state,
ignored: [],
};
data.guildData.markModified("plugins.automod");
await data.guildData.save();
data.guild.markModified("plugins.automod");
await data.guild.save();
interaction.success(`administration/automod:${state ? "ENABLED" : "DISABLED"}`);
} else if (command === "ignore") {
data.guildData.plugins.automod.ignored.push(channel.id);
data.guild.plugins.automod.ignored.push(channel.id);
data.guildData.markModified("plugins.automod");
await data.guildData.save();
data.guild.markModified("plugins.automod");
await data.guild.save();
interaction.success("administration/automod:DISABLED_CHANNEL", {
channel: channel.toString(),

View file

@ -45,29 +45,29 @@ class Autorole extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
const state = interaction.options.getBoolean("state"),
async execute(client, interaction) {
const guildData = interaction.data.guild,
state = interaction.options.getBoolean("state"),
role = interaction.options.getRole("role");
data.guildData.plugins.autorole = {
guildData.plugins.autorole = {
enabled: state,
role,
};
if (state && role) {
data.guildData.markModified("plugins.autorole");
await data.guildData.save();
guildData.markModified("plugins.autorole");
await guildData.save();
interaction.success("administration/autorole:ENABLED", {
role: role.toString(),
});
} else {
data.guildData.plugins.autorole.enabled = false;
guildData.plugins.autorole.enabled = false;
data.guildData.markModified("plugins.autorole");
await data.guildData.save();
guildData.markModified("plugins.autorole");
await guildData.save();
interaction.success("administration/autorole:DISABLED");
}

View file

@ -84,14 +84,12 @@ class Config extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
const command = interaction.options.getSubcommand();
async execute(client, interaction) {
const guildData = interaction.data.guild,
command = interaction.options.getSubcommand();
if (command === "list") {
const guildData = data.guildData;
const embed = client.embed({
author: {
name: interaction.guild.name,
@ -173,7 +171,7 @@ class Config extends BaseCommand {
state = interaction.options.getBoolean("state"),
channel = interaction.options.getChannel("channel");
await changeSetting(interaction, setting, state, channel, data.guildData);
await changeSetting(interaction, setting, state, channel);
}
}
}
@ -184,20 +182,20 @@ class Config extends BaseCommand {
* @param {String} setting
* @param {Boolean} state
* @param {import("discord.js").GuildTextBasedChannel | import("discord.js").CategoryChannel} channel
* @param {import("../../base/Guild")} guildData
* @returns
*/
async function changeSetting(interaction, setting, state, channel, guildData) {
const settingSplitted = setting.split(".");
async function changeSetting(interaction, setting, state, channel) {
const settingSplitted = setting.split("."),
data = interaction.data.guild;
if (settingSplitted.length === 2) {
if (guildData.plugins[settingSplitted[0]] === undefined) guildData.plugins[settingSplitted[0]] = {};
if (data.plugins[settingSplitted[0]] === undefined) data.plugins[settingSplitted[0]] = {};
if (!state) {
guildData.plugins[settingSplitted[0]][settingSplitted[1]] = null;
data.plugins[settingSplitted[0]][settingSplitted[1]] = null;
guildData.markModified(`plugins.${settingSplitted[0]}`);
await guildData.save();
data.markModified(`plugins.${settingSplitted[0]}`);
await data.save();
return interaction.reply({
content: `${interaction.translate(`administration/config:${settingSplitted.length === 2 ? settingSplitted[1].toUpperCase() : setting.toUpperCase()}`)}: **${interaction.translate("common:DISABLED")}**`,
@ -207,10 +205,10 @@ async function changeSetting(interaction, setting, state, channel, guildData) {
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;
data.plugins[settingSplitted[0]][settingSplitted[1]] = channel.id;
guildData.markModified(`plugins.${settingSplitted[0]}`);
await guildData.save();
data.markModified(`plugins.${settingSplitted[0]}`);
await data.save();
return interaction.reply({
content: `${interaction.translate(`administration/config:${settingSplitted.length === 2 ? settingSplitted[1].toUpperCase() : setting.toUpperCase()}`)}: **${interaction.translate("common:ENABLED")}** (${channel.toString()})`,
@ -219,17 +217,17 @@ async function changeSetting(interaction, setting, state, channel, guildData) {
} 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")}**`
data.plugins[setting] ? `**${interaction.translate("common:ENABLED")}** (<#${data.plugins[setting]}>)` : `**${interaction.translate("common:DISABLED")}**`
}`,
ephemeral: true,
});
}
} else {
if (!state) {
guildData.plugins[setting] = null;
data.plugins[setting] = null;
guildData.markModified(`plugins.${setting}`);
await guildData.save();
data.markModified(`plugins.${setting}`);
await data.save();
return interaction.reply({
content: `${interaction.translate(`administration/config:${setting.toUpperCase()}`)}: **${interaction.translate("common:DISABLED")}**`,
@ -237,10 +235,10 @@ async function changeSetting(interaction, setting, state, channel, guildData) {
});
} else {
if (channel) {
guildData.plugins[setting] = channel.id;
data.plugins[setting] = channel.id;
guildData.markModified(`plugins.${setting}`);
await guildData.save();
data.markModified(`plugins.${setting}`);
await data.save();
return interaction.reply({
content: `${interaction.translate(`administration/config:${setting.toUpperCase()}`)}: **${interaction.translate("common:ENABLED")}** (${channel.toString()})`,
@ -249,7 +247,7 @@ async function changeSetting(interaction, setting, state, channel, guildData) {
} 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")}**`
data.plugins[setting] ? `**${interaction.translate("common:ENABLED")}** (<#${data.plugins[setting]}>)` : `**${interaction.translate("common:DISABLED")}**`
}`,
ephemeral: true,
});

View file

@ -81,10 +81,10 @@ class Goodbye extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
const command = interaction.options.getSubcommand();
async execute(client, interaction) {
const guildData = interaction.data.guild,
command = interaction.options.getSubcommand();
if (command === "test") {
client.emit("guildMemberRemove", interaction.member);
@ -94,15 +94,15 @@ class Goodbye extends BaseCommand {
const state = interaction.options.getBoolean("state");
if (!state) {
data.guildData.plugins.goodbye = {
guildData.plugins.goodbye = {
enabled: false,
message: null,
channelID: null,
withImage: null,
};
data.guildData.markModified("plugins.goodbye");
await data.guildData.save();
guildData.markModified("plugins.goodbye");
await guildData.save();
interaction.success("administration/goodbye:DISABLED", null, { ephemeral: true });
} else {
@ -110,15 +110,15 @@ class Goodbye extends BaseCommand {
const message = interaction.options.getString("message") || interaction.translate("administration/goodbye:DEFAULT_MESSAGE");
const image = interaction.options.getBoolean("image") === true ? true : false;
data.guildData.plugins.goodbye = {
guildData.plugins.goodbye = {
enabled: true,
channel: channel.id,
message: message,
withImage: image,
};
data.guildData.markModified("plugins.goodbye");
await data.guildData.save();
guildData.markModified("plugins.goodbye");
await guildData.save();
interaction.success("administration/goodbye:ENABLED", {
channel: `${channel.toString()}`,

View file

@ -89,6 +89,9 @@ class Selectroles extends BaseCommand {
if (!interaction.isStringSelectMenu()) return;
if (interaction.customId === "auto_roles") {
interaction.data = [];
interaction.data.guild = await client.findOrCreateGuild(interaction.guildId);
const removed = interaction.component.options.filter(option => {
return !interaction.values.includes(option.value);
});
@ -113,7 +116,6 @@ class Selectroles extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
await interaction.deferReply({ ephemeral: true });

View file

@ -62,7 +62,6 @@ class Set extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
const type = interaction.options.getString("type"),

View file

@ -37,16 +37,16 @@ class Setlang extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
const lang = interaction.options.getString("language"),
async execute(client, interaction) {
const guildData = interaction.data.guild,
lang = interaction.options.getString("language"),
language = client.languages.find(l => l.name === lang);
data.guildData.language = language.name;
guildData.language = language.name;
data.guildData.markModified("language");
await data.guildData.save();
guildData.markModified("language");
await guildData.save();
return interaction.success("administration/setlang:SUCCESS", {
lang: language.nativeName,

View file

@ -36,16 +36,14 @@ class Stealemoji extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
const parsedEmoji = parseEmoji(interaction.options.getString("emoji")),
ext = parsedEmoji.animated ? "gif" : "png";
const parsedEmoji = parseEmoji(interaction.options.getString("emoji"));
interaction.guild.emojis
.create({
name: parsedEmoji.name,
attachment: `https://cdn.discordapp.com/emojis/${parsedEmoji.id}.${ext}`,
attachment: `https://cdn.discordapp.com/emojis/${parsedEmoji.id}.${parsedEmoji.animated ? "gif" : "png"}`,
})
.then(emoji =>
interaction.success("administration/stealemoji:SUCCESS", {

View file

@ -81,10 +81,10 @@ class Welcome extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
const command = interaction.options.getSubcommand();
async execute(client, interaction) {
const guildData = interaction.data.guild,
command = interaction.options.getSubcommand();
if (command === "test") {
client.emit("guildMemberAdd", interaction.member);
@ -94,15 +94,15 @@ class Welcome extends BaseCommand {
const state = interaction.options.getBoolean("state");
if (!state) {
data.guildData.plugins.welcome = {
guildData.plugins.welcome = {
enabled: false,
message: null,
channelID: null,
withImage: null,
};
data.guildData.markModified("plugins.welcome");
await data.guildData.save();
guildData.markModified("plugins.welcome");
await guildData.save();
interaction.success("administration/welcome:DISABLED", null, { ephemeral: true });
} else {
@ -110,15 +110,15 @@ class Welcome extends BaseCommand {
const message = interaction.options.getString("message") || interaction.translate("administration/welcome:DEFAULT_MESSAGE");
const image = interaction.options.getBoolean("image") === true ? true : false;
data.guildData.plugins.welcome = {
guildData.plugins.welcome = {
enabled: true,
channel: channel.id,
message: message,
withImage: image,
};
data.guildData.markModified("plugins.welcome");
await data.guildData.save();
guildData.markModified("plugins.welcome");
await guildData.save();
interaction.success("administration/welcome:ENABLED", {
channel: `${channel.toString()}`,

View file

@ -34,13 +34,12 @@ class Achievements extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
async execute(client, interaction) {
const user = interaction.options.getUser("user") || interaction.member;
if (user.bot) return interaction.error("economy/profile:BOT_USER");
const userData = user.id === interaction.user.id ? data.userData : await client.findOrCreateUser(user.id);
const userData = user.id === interaction.user.id ? interaction.data.user : await client.findOrCreateUser(user.id);
const embed = client.embed({
author: {

View file

@ -46,25 +46,26 @@ class Bank extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
const choice = interaction.options.getString("option");
async execute(client, interaction) {
const memberData = interaction.data.member,
choice = interaction.options.getString("option");
if (choice === "deposit") {
const credits = interaction.options.getString("credits").toLowerCase() === "all" ? data.memberData.money : interaction.options.getString("credits");
const credits = interaction.options.getString("credits").toLowerCase() === "all" ? memberData.money : interaction.options.getString("credits");
if (isNaN(credits) || credits < 1) return interaction.error("misc:OPTION_NAN_ALL");
if (data.memberData.money < credits)
if (memberData.money < credits)
return interaction.error("economy/bank:NOT_ENOUGH_CREDIT", {
money: `**${credits}** ${client.functions.getNoun(credits, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
});
data.memberData.money -= credits;
data.memberData.bankSold += credits;
memberData.money -= credits;
memberData.bankSold += credits;
data.memberData.markModified("money");
data.memberData.markModified("bankSold");
await data.memberData.save();
memberData.markModified("money");
memberData.markModified("bankSold");
await memberData.save();
const info = {
user: interaction.translate("economy/transactions:BANK"),
@ -72,15 +73,16 @@ class Bank extends BaseCommand {
date: Date.now(),
type: "send",
};
data.memberData.transactions.push(info);
memberData.transactions.push(info);
interaction.success("economy/bank:SUCCESS_DEP", {
money: `**${credits}** ${client.functions.getNoun(credits, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
});
} else {
const credits = interaction.options.getString("credits") === "all" ? data.memberData.bankSold : interaction.options.getString("credits");
const credits = interaction.options.getString("credits") === "all" ? memberData.bankSold : interaction.options.getString("credits");
if (isNaN(credits) || credits < 1) return interaction.error("misc:OPTION_NAN_ALL");
if (data.memberData.bankSold < credits)
if (memberData.bankSold < credits)
return interaction.error("economy/bank:NOT_ENOUGH_BANK", {
money: `**${credits}** ${client.functions.getNoun(credits, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
});
@ -92,14 +94,14 @@ class Bank extends BaseCommand {
type: "got",
};
data.memberData.transactions.push(info);
memberData.transactions.push(info);
data.memberData.money += credits;
data.memberData.bankSold -= credits;
memberData.money += credits;
memberData.bankSold -= credits;
data.memberData.markModified("money");
data.memberData.markModified("bankSold");
await data.memberData.save();
memberData.markModified("money");
memberData.markModified("bankSold");
await memberData.save();
interaction.success("economy/bank:SUCCESS_WD", {
money: `**${credits}** ${client.functions.getNoun(credits, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,

View file

@ -69,10 +69,10 @@ class Birthdate extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
const day = interaction.options.getInteger("day"),
async execute(client, interaction) {
const userData = interaction.data.user,
day = interaction.options.getInteger("day"),
month = interaction.options.getInteger("month"),
year = interaction.options.getInteger("year"),
date = new Date(year, month - 1, day),
@ -82,10 +82,10 @@ class Birthdate extends BaseCommand {
if (date.getTime() > Date.now()) return interaction.error("economy/birthdate:DATE_TOO_HIGH");
if (date.getTime() < Date.now() - 2.523e12) return interaction.error("economy/birthdate:DATE_TOO_LOW");
data.userData.birthdate = d;
userData.birthdate = d;
data.userData.markModified("birthdate");
await data.userData.save();
userData.markModified("birthdate");
await userData.save();
interaction.success("economy/birthdate:SUCCESS", {
date: `<t:${d}:D>`,

View file

@ -25,16 +25,17 @@ class Divorce extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
if (!data.userData.lover) return interaction.error("economy/divorce:NOT_MARRIED");
const user = client.users.cache.get(data.userData.lover) || (await client.users.fetch(data.userData.lover));
async execute(client, interaction) {
const userData = interaction.data.user;
data.userData.lover = null;
if (!userData.lover) return interaction.error("economy/divorce:NOT_MARRIED");
const user = client.users.cache.get(userData.lover) || await client.users.fetch(userData.lover);
data.userData.markModified("lover");
await data.userData.save();
userData.lover = null;
userData.markModified("lover");
await userData.save();
const oldLover = await client.findOrCreateUser(user.id);
oldLover.lover = null;
@ -46,11 +47,13 @@ class Divorce extends BaseCommand {
user: user.toString(),
});
user.send({
content: interaction.translate("economy/divorce:DIVORCED_U", {
user: interaction.member.toString(),
}),
});
try {
user.send({
content: interaction.translate("economy/divorce:DIVORCED_U", {
user: interaction.member.toString(),
}),
});
} catch (e) { /**/ }
}
}

View file

@ -36,7 +36,6 @@ class Leaderboard extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
await interaction.deferReply();

View file

@ -36,17 +36,18 @@ class Marry extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
if (data.userData.lover) return interaction.error("economy/marry:ALREADY_MARRIED");
async execute(client, interaction) {
const userData = interaction.data.user;
if (userData.lover) return interaction.error("economy/marry:ALREADY_MARRIED");
const member = interaction.options.getMember("user");
if (member.user.bot) return interaction.error("economy/marry:BOT_USER");
if (member.id === interaction.member.id) return interaction.error("economy/marry:YOURSELF");
const userData = await client.findOrCreateUser(member.id);
if (userData.lover) return interaction.error("economy/marry:ALREADY_MARRIED_USER", { user: member.toString() });
const otherUserData = await client.findOrCreateUser(member.id);
if (otherUserData.lover) return interaction.error("economy/marry:ALREADY_MARRIED_USER", { user: member.toString() });
for (const requester in pendings) {
const receiver = pendings[requester];
@ -118,13 +119,13 @@ class Marry extends BaseCommand {
}
if (reason) {
data.userData.lover = member.id;
userData.lover = interaction.member.id;
userData.lover = member.id;
otherUserData.lover = interaction.member.id;
data.userData.markModified("lover");
userData.markModified("lover");
await data.userData.save();
otherUserData.markModified("lover");
await userData.save();
await otherUserData.save();
const messageOptions = {
content: `${member.toString()} :heart: ${interaction.member.toString()}`,
@ -137,9 +138,18 @@ class Marry extends BaseCommand {
};
let sent = false;
if (!userData.achievements.married.achieved) {
if (!otherUserData.achievements.married.achieved) {
interaction.followUp(messageOptions);
sent = true;
otherUserData.achievements.married.achieved = true;
otherUserData.achievements.married.progress.now = 1;
otherUserData.markModified("achievements");
await otherUserData.save();
}
if (!userData.achievements.married.achieved) {
if (!sent) interaction.followUp(messageOptions);
userData.achievements.married.achieved = true;
userData.achievements.married.progress.now = 1;
@ -147,15 +157,6 @@ class Marry extends BaseCommand {
await userData.save();
}
if (!data.userData.achievements.married.achieved) {
if (!sent) interaction.followUp(messageOptions);
data.userData.achievements.married.achieved = true;
data.userData.achievements.married.progress.now = 1;
data.userData.markModified("achievements");
await data.userData.save();
}
return interaction.editReply({
content: interaction.translate("economy/marry:SUCCESS", {
creator: interaction.member.toString(),

View file

@ -34,17 +34,17 @@ class Money extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
async execute(client, interaction) {
await interaction.deferReply();
const member = interaction.options.getMember("user") || interaction.member;
if (member.user.bot) return interaction.error("economy/money:BOT_USER");
const memberData = member.id === interaction.user.id ? data.memberData : await client.findOrCreateMember({ id: member.id, guildId: interaction.guildId });
const memberData = member.id === interaction.user.id ? interaction.data.member : await client.findOrCreateMember({ id: member.id, guildId: interaction.guildId });
const guilds = client.guilds.cache.filter(g => g.members.cache.find(m => m.id === member.id));
let globalMoney = 0;
await client.functions.asyncForEach(guilds, async guild => {
const data = await client.findOrCreateMember({

View file

@ -45,53 +45,53 @@ class Pay extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
const member = interaction.options.getMember("user");
if (member.user.bot) return interaction.error("economy/pay:BOT_USER");
if (member.id === interaction.member.id) return interaction.error("economy/pay:YOURSELF");
async execute(client, interaction) {
const memberData = interaction.data.member,
otherMember = interaction.options.getMember("user");
if (otherMember.user.bot) return interaction.error("economy/pay:BOT_USER");
if (otherMember.id === interaction.member.id) return interaction.error("economy/pay:YOURSELF");
const amount = interaction.options.getInteger("amount");
if (amount <= 0) return interaction.error("misc:MORE_THAN_ZERO");
if (amount > data.memberData.money)
if (amount > memberData.money)
return interaction.error("economy/pay:ENOUGH_MONEY", {
amount: `**${amount}** ${client.functions.getNoun(amount, interaction.translate("misc:NOUNS:CREDITS:1"), interaction.translate("misc:NOUNS:CREDITS:2"), interaction.translate("misc:NOUNS:CREDITS:5"))}`,
});
const memberData = await client.findOrCreateMember({
id: member.id,
const otherMemberData = await client.findOrCreateMember({
id: otherMember.id,
guildId: interaction.guildId,
});
data.memberData.money -= amount;
data.memberData.markModified("money");
await data.memberData.save();
memberData.money += amount;
memberData.money -= amount;
memberData.markModified("money");
await memberData.save();
otherMemberData.money += amount;
otherMemberData.markModified("money");
await otherMemberData.save();
const info1 = {
user: member.user.getUsername(),
user: otherMember.user.getUsername(),
amount: amount,
date: Date.now(),
type: "send",
};
data.memberData.transactions.push(info1);
memberData.transactions.push(info1);
const info2 = {
user: member.user.getUsername(),
user: otherMember.user.getUsername(),
amount: amount,
date: Date.now(),
type: "got",
};
data.memberData.transactions.push(info2);
otherMemberData.transactions.push(info2);
interaction.success("economy/pay:SUCCESS", {
user: member.toString(),
user: otherMember.toString(),
amount: `**${amount}** ${client.functions.getNoun(amount, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
});
}

View file

@ -34,16 +34,15 @@ class Profile extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
async execute(client, interaction) {
await interaction.deferReply();
const member = interaction.options.getMember("user") || interaction.member;
if (member.user.bot) return interaction.error("economy/profile:BOT_USER");
const memberData = member.id === interaction.user.id ? data.memberData : await client.findOrCreateMember({ id: member.id, guildId: interaction.guildId });
const userData = member.id === interaction.user.id ? data.userData : await client.findOrCreateUser(member.id);
const memberData = member.id === interaction.user.id ? interaction.data.member : await client.findOrCreateMember({ id: member.id, guildId: interaction.guildId });
const userData = member.id === interaction.user.id ? interaction.data.user : await client.findOrCreateUser(member.id);
if (userData.lover && !client.users.cache.find(u => u.id === userData.lover)) await client.users.fetch(userData.lover, true);
const guilds = client.guilds.cache.filter(g => g.members.cache.find(m => m.id === member.id));
@ -123,14 +122,14 @@ class Profile extends BaseCommand {
],
});
const buffer = await userData.getAchievements();
const achievements = await userData.getAchievements();
interaction.editReply({
embeds: [embed],
files: [
{
name: "achievements.png",
attachment: buffer,
attachment: achievements,
},
],
});

View file

@ -35,10 +35,10 @@ class Rep extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
const isInCooldown = data.userData.cooldowns?.rep;
async execute(client, interaction) {
const userData = interaction.data.user,
isInCooldown = userData.cooldowns?.rep;
if (isInCooldown) {
if (isInCooldown > Date.now())
@ -52,21 +52,21 @@ class Rep extends BaseCommand {
if (user.id === interaction.user.id) return interaction.error("economy/rep:YOURSELF");
const toWait = Math.floor((Date.now() + 12 * 60 * 60 * 1000) / 1000); // 12 hours
if (!data.userData.cooldowns) data.userData.cooldowns = {};
if (!userData.cooldowns) userData.cooldowns = {};
data.userData.cooldowns.rep = toWait;
userData.cooldowns.rep = toWait;
data.userData.markModified("cooldowns");
await data.userData.save();
userData.markModified("cooldowns");
await userData.save();
const userData = await client.findOrCreateUser(user.id);
const otherUserData = await client.findOrCreateUser(user.id);
userData.rep++;
otherUserData.rep++;
if (!userData.achievements.rep.achieved) {
userData.achievements.rep.progress.now = userData.rep > userData.achievements.rep.progress.total ? userData.achievements.rep.progress.total : userData.rep;
if (userData.achievements.rep.progress.now >= userData.achievements.rep.progress.total) {
userData.achievements.rep.achieved = true;
if (!otherUserData.achievements.rep.achieved) {
otherUserData.achievements.rep.progress.now = otherUserData.rep > otherUserData.achievements.rep.progress.total ? otherUserData.achievements.rep.progress.total : otherUserData.rep;
if (otherUserData.achievements.rep.progress.now >= otherUserData.achievements.rep.progress.total) {
otherUserData.achievements.rep.achieved = true;
interaction.followUp({
content: `${user}`,
files: [
@ -79,8 +79,8 @@ class Rep extends BaseCommand {
}
}
userData.markModified("rep");
await userData.save();
otherUserData.markModified("rep");
await otherUserData.save();
interaction.success("economy/rep:SUCCESS", {
user: user.toString(),

View file

@ -45,32 +45,32 @@ class Rob extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
const member = interaction.options.getMember("user");
if (member.user.bot) return interaction.error("economy/pay:BOT_USER");
if (member.id === interaction.member.id) return interaction.error("economy/rob:YOURSELF");
async execute(client, interaction) {
const memberData = interaction.data.member,
otherMember = interaction.options.getMember("user");
if (otherMember.user.bot) return interaction.error("economy/pay:BOT_USER");
if (otherMember.id === interaction.member.id) return interaction.error("economy/rob:YOURSELF");
const amount = interaction.options.getInteger("amount");
if (amount <= 0) return interaction.error("misc:MORE_THAN_ZERO");
const memberData = await client.findOrCreateMember({
id: member.id,
const otherMemberData = await client.findOrCreateMember({
id: otherMember.id,
guildId: interaction.guildId,
});
if (amount > memberData.money) return interaction.error("economy/rob:NOT_ENOUGH_MEMBER", { user: member.toString() });
if (amount > otherMemberData.money) return interaction.error("economy/rob:NOT_ENOUGH_MEMBER", { user: otherMember.toString() });
const isInCooldown = memberData.cooldowns.rob || 0;
const isInCooldown = otherMemberData.cooldowns.rob || 0;
if (isInCooldown) {
if (isInCooldown > Date.now()) return interaction.error("economy/rob:COOLDOWN", { user: member.toString() });
if (isInCooldown > Date.now()) return interaction.error("economy/rob:COOLDOWN", { user: otherMember.toString() });
}
const potentiallyLose = Math.floor(amount * 1.5);
if (potentiallyLose > data.memberData.money)
if (potentiallyLose > memberData.money)
return interaction.error("economy/rob:NOT_ENOUGH_AUTHOR", {
moneyMin: `**${potentiallyLose}** ${client.functions.getNoun(potentiallyLose, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
moneyCurrent: `**${data.memberData.money}** ${client.functions.getNoun(data.memberData.money, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
moneyCurrent: `**${memberData.money}** ${client.functions.getNoun(memberData.money, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
});
const itsAWon = Math.floor(client.functions.randomNum(0, 100) < 25);
@ -79,23 +79,23 @@ class Rob extends BaseCommand {
const toWait = Date.now() + 6 * 60 * 60 * 1000,
randomNum = client.functions.randomNum(1, 2);
memberData.cooldowns.rob = toWait;
otherMemberData.cooldowns.rob = toWait;
memberData.markModified("cooldowns");
await memberData.save();
otherMemberData.markModified("cooldowns");
await otherMemberData.save();
interaction.replyT("economy/rob:ROB_WON_" + randomNum, {
money: `**${amount}** ${client.functions.getNoun(amount, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
user: member.toString(),
user: otherMember.toString(),
});
data.memberData.money += amount;
memberData.money -= amount;
memberData.money += amount;
otherMemberData.money -= amount;
data.memberData.markModified("money");
memberData.markModified("money");
await data.memberData.save();
otherMemberData.markModified("money");
await memberData.save();
await otherMemberData.save();
} else {
const won = Math.floor(amount * 0.9),
randomNum = client.functions.randomNum(1, 2);
@ -103,16 +103,16 @@ class Rob extends BaseCommand {
interaction.replyT("economy/rob:ROB_LOSE_" + randomNum, {
fine: `**${potentiallyLose}** ${client.functions.getNoun(potentiallyLose, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
offset: `**${won}** ${client.functions.getNoun(won, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
user: member.toString(),
user: otherMember.toString(),
});
data.memberData.money -= potentiallyLose;
memberData.money += won;
memberData.money -= potentiallyLose;
otherMemberData.money += won;
data.memberData.markModified("money");
memberData.markModified("money");
await data.memberData.save();
otherMemberData.markModified("money");
await memberData.save();
await otherMemberData.save();
}
}
}

View file

@ -35,16 +35,16 @@ class Setbio extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
const newBio = interaction.options.getString("text");
async execute(client, interaction) {
const userData = interaction.data.user,
newBio = interaction.options.getString("text");
if (newBio.length > 150) return interaction.error("economy/setbio:MAX_CHARACTERS");
data.userData.bio = newBio;
userData.bio = newBio;
data.userData.markModified("bio");
await data.userData.save();
userData.markModified("bio");
await userData.save();
interaction.success("economy/setbio:SUCCESS");
}

View file

@ -35,13 +35,13 @@ class Slots extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
async execute(client, interaction) {
await interaction.deferReply();
const amount = interaction.options.getInteger("amount");
if (amount > data.memberData.money)
const { member: memberData, user: userData } = interaction.data,
amount = interaction.options.getInteger("amount");
if (amount > memberData.money)
return interaction.error("economy/slots:NOT_ENOUGH", {
money: `**${amount}** ${client.functions.getNoun(amount, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
}, { edit: true });
@ -119,13 +119,13 @@ class Slots extends BaseCommand {
type: "got",
};
data.memberData.money += toAdd;
data.memberData.transactions.push(info);
memberData.money += toAdd;
memberData.transactions.push(info);
if (!data.userData.achievements.slots.achieved) {
data.userData.achievements.slots.progress.now += 1;
if (data.userData.achievements.slots.progress.now === data.userData.achievements.slots.progress.total) {
data.userData.achievements.slots.achieved = true;
if (!userData.achievements.slots.achieved) {
userData.achievements.slots.progress.now += 1;
if (userData.achievements.slots.progress.now === userData.achievements.slots.progress.total) {
userData.achievements.slots.achieved = true;
interaction.followUp({
files: [
{
@ -136,13 +136,13 @@ class Slots extends BaseCommand {
});
}
data.userData.markModified("achievements");
await data.userData.save();
userData.markModified("achievements");
await userData.save();
}
data.memberData.markModified("money");
data.memberData.markModified("transactions");
await data.memberData.save();
memberData.markModified("money");
memberData.markModified("transactions");
await memberData.save();
return;
}
@ -170,13 +170,13 @@ class Slots extends BaseCommand {
type: "got",
};
data.memberData.money += toAdd;
data.memberData.transactions.push(info);
memberData.money += toAdd;
memberData.transactions.push(info);
if (!data.userData.achievements.slots.achieved) {
data.userData.achievements.slots.progress.now += 1;
if (data.userData.achievements.slots.progress.now === data.userData.achievements.slots.progress.total) {
data.userData.achievements.slots.achieved = true;
if (!userData.achievements.slots.achieved) {
userData.achievements.slots.progress.now += 1;
if (userData.achievements.slots.progress.now === userData.achievements.slots.progress.total) {
userData.achievements.slots.achieved = true;
interaction.followUp({
files: [
{
@ -187,13 +187,13 @@ class Slots extends BaseCommand {
});
}
data.userData.markModified("achievements");
await data.userData.save();
userData.markModified("achievements");
await userData.save();
}
data.memberData.markModified("money");
data.memberData.markModified("transactions");
await data.memberData.save();
memberData.markModified("money");
memberData.markModified("transactions");
await memberData.save();
return;
}
@ -213,19 +213,19 @@ class Slots extends BaseCommand {
type: "send",
};
data.memberData.money -= amount;
data.memberData.transactions.push(info);
memberData.money -= amount;
memberData.transactions.push(info);
if (!data.userData.achievements.slots.achieved) {
data.userData.achievements.slots.progress.now = 0;
if (!userData.achievements.slots.achieved) {
userData.achievements.slots.progress.now = 0;
data.userData.markModified("achievements");
await data.userData.save();
userData.markModified("achievements");
await userData.save();
}
data.memberData.markModified("money");
data.memberData.markModified("transactions");
await data.memberData.save();
memberData.markModified("money");
memberData.markModified("transactions");
await memberData.save();
return;
}

View file

@ -34,14 +34,15 @@ class Transactions extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
if (interaction.options.getBoolean("clear")) {
data.memberData.transactions = [];
async execute(client, interaction) {
const memberData = interaction.data.member;
data.memberData.markModified("transactions");
await data.memberData.save();
if (interaction.options.getBoolean("clear")) {
memberData.transactions = [];
memberData.markModified("transactions");
await memberData.save();
return interaction.success("economy/transactions:CLEARED", null, { ephemeral: true });
}
@ -52,7 +53,7 @@ class Transactions extends BaseCommand {
iconURL: interaction.member.displayAvatarURL(),
},
});
const transactions = data.memberData.transactions,
const transactions = memberData.transactions,
sortedTransactions = [[], []];
transactions.slice(-20).forEach(t => {

View file

@ -25,10 +25,10 @@ class Work extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
const isInCooldown = data.memberData.cooldowns?.work;
async execute(client, interaction) {
const { member: memberData, user: userData } = interaction.data,
isInCooldown = memberData.cooldowns?.work;
if (isInCooldown) {
if (isInCooldown > Date.now())
@ -37,15 +37,15 @@ class Work extends BaseCommand {
});
}
if (Date.now() > data.memberData.cooldowns.work + 24 * 60 * 60 * 1000) data.memberData.workStreak = 0;
if (Date.now() > memberData.cooldowns.work + 24 * 60 * 60 * 1000) memberData.workStreak = 0;
const toWait = Math.floor((Date.now() + 24 * 60 * 60 * 1000) / 1000); // 24 hours
data.memberData.cooldowns.work = toWait;
data.memberData.workStreak = (data.memberData.workStreak || 0) + 1;
memberData.cooldowns.work = toWait;
memberData.workStreak = (memberData.workStreak || 0) + 1;
data.memberData.markModified("cooldowns");
data.memberData.markModified("workStreak");
await data.memberData.save();
memberData.markModified("cooldowns");
memberData.markModified("workStreak");
await memberData.save();
const embed = client.embed({
footer: {
@ -57,7 +57,7 @@ class Work extends BaseCommand {
const award = [client.customEmojis.letters.a, client.customEmojis.letters.w, client.customEmojis.letters.a, client.customEmojis.letters.r, client.customEmojis.letters.d];
let won = 200;
if (data.memberData.workStreak >= 5) {
if (memberData.workStreak >= 5) {
won += 200;
embed.fields = [
{
@ -71,10 +71,11 @@ class Work extends BaseCommand {
value: interaction.translate("economy/work:STREAK_CONTENT"),
},
];
data.memberData.workStreak = 0;
memberData.workStreak = 0;
} else {
for (let i = 0; i < award.length; i++) {
if (data.memberData.workStreak > i) {
if (memberData.workStreak > i) {
const letter = parseEmoji(award[i]).name.split("_")[1];
award[i] = `:regional_indicator_${letter.toLowerCase()}:`;
}
@ -93,10 +94,10 @@ class Work extends BaseCommand {
];
}
data.memberData.money += won;
memberData.money += won;
data.memberData.markModified("money");
await data.memberData.save();
memberData.markModified("money");
await memberData.save();
const info = {
user: interaction.translate("economy/work:SALARY"),
@ -104,26 +105,26 @@ class Work extends BaseCommand {
date: Date.now(),
type: "got",
};
data.memberData.transactions.push(info);
memberData.transactions.push(info);
const messageOptions = {
embeds: [embed],
};
if (!data.userData.achievements.work.achieved) {
data.userData.achievements.work.progress.now += 1;
if (data.userData.achievements.work.progress.now === data.userData.achievements.work.progress.total) {
if (!userData.achievements.work.achieved) {
userData.achievements.work.progress.now += 1;
if (userData.achievements.work.progress.now === userData.achievements.work.progress.total) {
messageOptions.files = [
{
name: "unlocked.png",
attachment: "./assets/img/achievements/achievement_unlocked1.png",
},
];
data.userData.achievements.work.achieved = true;
userData.achievements.work.achieved = true;
}
data.userData.markModified("achievements");
await data.userData.save();
userData.markModified("achievements");
await userData.save();
}
interaction.reply(messageOptions);

View file

@ -35,7 +35,6 @@ class Eightball extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
await interaction.deferReply();

View file

@ -26,7 +26,6 @@ class Cat extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
await interaction.deferReply();

View file

@ -26,7 +26,6 @@ class Dog extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
await interaction.deferReply();

View file

@ -46,7 +46,6 @@ class LMGTFY extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
await interaction.deferReply({ ephemeral: true });

View file

@ -45,7 +45,6 @@ class Lovecalc extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
const firstMember = interaction.options.getMember("first_member"),

View file

@ -26,7 +26,6 @@ class Number extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
if (currentGames[interaction.guildId]) return interaction.error("fun/number:GAME_RUNNING");

View file

@ -36,7 +36,6 @@ class TicTacToe extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
tictactoe(interaction, {

View file

@ -35,17 +35,17 @@ class Afk extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
async execute(client, interaction) {
await interaction.deferReply({ ephemeral: true });
const reason = interaction.options.getString("message");
const userData = interaction.data.user,
reason = interaction.options.getString("message");
data.userData.afk = reason;
userData.afk = reason;
data.userData.markModified("afk");
await data.userData.save();
userData.markModified("afk");
await userData.save();
interaction.success("general/afk:SUCCESS", {
reason,

View file

@ -21,7 +21,6 @@ class AvatarContext extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").UserContextMenuCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
const avatarURL = interaction.targetUser.displayAvatarURL({ size: 2048 });

View file

@ -43,7 +43,6 @@ class Avatar extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
const member = interaction.options.getMember("user") || interaction.member;

View file

@ -30,9 +30,11 @@ class Boosters extends BaseCommand {
if (!interaction.isButton()) return;
if (interaction.customId.startsWith("boosters_")) {
const guildData = client.findOrCreateGuild(interaction.guildId),
boosters = (await interaction.guild.members.fetch()).filter(m => m.premiumSince),
embeds = generateBoostersEmbeds(client, interaction, boosters, guildData);
interaction.data = [];
interaction.data.guild = await client.findOrCreateGuild(interaction.guildId);
const boosters = (await interaction.guild.members.fetch()).filter(m => m.premiumSince),
embeds = generateBoostersEmbeds(client, interaction, boosters);
const row = new ActionRowBuilder().addComponents(
new ButtonBuilder().setCustomId("boosters_prev_page").setStyle(ButtonStyle.Primary).setEmoji("⬅️"),
@ -115,7 +117,6 @@ class Boosters extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
await interaction.deferReply();

View file

@ -35,7 +35,6 @@ class Emoji extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
const rawEmoji = interaction.options.getString("emoji");

View file

@ -42,6 +42,9 @@ class Help extends BaseCommand {
if (interaction.customId === "help_category_select") {
await interaction.deferUpdate();
interaction.data = [];
interaction.data.guild = await client.findOrCreateGuild(interaction.guildId);
const arg = interaction?.values[0];
const categoryCommands = [...new Map(client.commands.map(v => [v.constructor.name, v])).values()]
.filter(cmd => cmd.category === arg)

View file

@ -36,7 +36,6 @@ class Minecraft extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
await interaction.deferReply();

View file

@ -25,7 +25,6 @@ class Ping extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
const embed = client.embed({

View file

@ -1,7 +1,6 @@
const { SlashCommandBuilder } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"),
ms = require("ms"),
moment = require("moment");
ms = require("ms");
class Remindme extends BaseCommand {
/**
@ -47,38 +46,39 @@ class Remindme extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
async execute(client, interaction) {
await interaction.deferReply({ ephemeral: true });
if (!data.userData.reminds) data.userData.reminds = [];
const userData = interaction.data.user;
if (!userData.reminds) userData.reminds = [];
const dateNow = Date.now();
const reminderData = {
const reminder = {
message: interaction.options.getString("message"),
createdAt: dateNow,
sendAt: dateNow + ms(interaction.options.getString("time")),
createdAt: Math.floor(dateNow / 1000),
sendAt: Math.floor((dateNow + ms(interaction.options.getString("time"))) / 1000),
};
data.userData.reminds.push(reminderData);
userData.reminds.push(reminder);
data.userData.markModified("reminds");
await data.userData.save();
userData.markModified("reminds");
await userData.save();
client.databaseCache.usersReminds.set(interaction.user.id, data.userData);
client.databaseCache.usersReminds.set(interaction.user.id, userData);
const embed = client.embed({
author: interaction.translate("general/remindme:EMBED_SAVED"),
fields: [
{
name: interaction.translate("general/remindme:EMBED_TIME"),
value: moment(reminderData.sendAt).locale(interaction.getLocale()).format("Do MMMM YYYY, HH:mm:ss"),
value: `<t:${reminder.sendAt}:R>`,
},
{
name: interaction.translate("common:MESSAGE"),
value: reminderData.message,
value: reminder.message,
},
],
});

View file

@ -45,10 +45,10 @@ class Report extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
const repChannel = interaction.guild.channels.cache.get(data.guildData.plugins.reports);
async execute(client, interaction) {
const guildData = interaction.data.guild,
repChannel = interaction.guild.channels.cache.get(guildData.plugins.reports);
if (!repChannel) return interaction.error("general/report:MISSING_CHANNEL");
const member = interaction.options.getMember("user");

View file

@ -25,10 +25,9 @@ class Serverinfo extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
const guild = interaction.guild;
const { guild } = interaction;
await guild.members.fetch();
const owner = await guild.fetchOwner();

View file

@ -36,7 +36,6 @@ class Shorturl extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
const url = interaction.options.getString("url");

View file

@ -25,7 +25,6 @@ class Stats extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
const hiddenGuildMembersCount = client.guilds.cache.get("568120814776614924").memberCount;

View file

@ -35,10 +35,10 @@ class Suggest extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
const channel = interaction.guild.channels.cache.get(data.guildData.plugins.suggestions);
async execute(client, interaction) {
const guildData = interaction.data.guild,
channel = interaction.guild.channels.cache.get(guildData.plugins.suggestions);
if (!channel) return interaction.error("general/suggest:MISSING_CHANNEL");
const suggestion = interaction.options.getString("message");

View file

@ -36,7 +36,6 @@ class Whois extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
await interaction.deferReply();

View file

@ -55,12 +55,13 @@ class Checkjar extends BaseCommand {
jarTransactions.length = 10;
jarTransactions.forEach(t => {
// TODO
const time = moment.unix(t.time);
embed.data.fields.push([
{
name: `${t.description}`,
value: `Дата: ${time.locale("uk-UA").format("DD MMMM YYYY, HH:mm")}\nСумма: ${t.amount / Math.pow(10, 2)} грн`,
value: `Дата: <t:${time}:D>\nСумма: ${t.amount / Math.pow(10, 2)} грн`,
},
]);
});

View file

@ -54,7 +54,6 @@ class Clear extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
await interaction.deferReply({ ephemeral: true });

View file

@ -36,7 +36,6 @@ class Clearwarns extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
const member = interaction.options.getMember("user");

View file

@ -133,7 +133,6 @@ class Giveaway extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
const command = interaction.options.getSubcommand();

View file

@ -36,7 +36,6 @@ class Poll extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
const question = interaction.options.getString("question");

View file

@ -36,7 +36,6 @@ class Unban extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
const id = interaction.options.getString("user_id"),

View file

@ -36,7 +36,6 @@ class Ban extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
await interaction.deferReply();

View file

@ -22,9 +22,8 @@ class WarnContext extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").UserContextMenuCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
async execute(client, interaction) {
const member = interaction.targetMember,
memberPosition = member.roles.highest.position,
moderationPosition = interaction.member.roles.highest.position;
@ -180,8 +179,10 @@ class WarnContext extends BaseCommand {
memberData.markModified("sanctions");
await memberData.save();
if (data.guildData.plugins.modlogs) {
const channel = interaction.guild.channels.cache.get(data.guildData.plugins.modlogs);
const guildData = interaction.data.guild;
if (guildData.plugins.modlogs) {
const channel = interaction.guild.channels.cache.get(guildData.plugins.modlogs);
if (!channel) return;
channel.send({

View file

@ -36,7 +36,6 @@ class Warns extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
const member = interaction.options.getMember("user");

View file

@ -25,7 +25,6 @@ class Back extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
const voice = interaction.member.voice.channel;

View file

@ -38,7 +38,6 @@ class Clips extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
await interaction.deferReply();

View file

@ -42,7 +42,6 @@ class Loop extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
const voice = interaction.member.voice.channel;

View file

@ -31,6 +31,9 @@ class Nowplaying extends BaseCommand {
if (!interaction.isButton()) return;
if (interaction.customId.startsWith("nowp_")) {
interaction.data = [];
interaction.data.guild = await client.findOrCreateGuild(interaction.guildId);
const voice = interaction.member.voice.channel;
if (!voice) return interaction.error("music/play:NO_VOICE_CHANNEL");
@ -119,19 +122,22 @@ class Nowplaying extends BaseCommand {
ephemeral: true,
});
// TODO Fix error in collected if user doesnt send anything
const filter = m => m.author.id === interaction.user.id && m.content.startsWith("http"),
collected = (await interaction.channel.awaitMessages({ filter, time: 10 * 1000, max: 1 })).first(),
collect = await interaction.channel.awaitMessages({ filter, time: 10 * 1000, max: 1 });
if (collect.size < 1) return;
const collected = collect.first(),
query = collected.content.match(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/g)[0],
searchResult = await client.player.search(query, {
requestedBy: interaction.user,
});
if (collected.deletable) collected.delete();
if (!searchResult.hasTracks()) return interaction.error("music/play:NO_RESULT", { query: query }, { edit: true });
else queue.addTrack(searchResult);
if (collected.deletable) collected.delete();
await interaction.followUp({
content: interaction.translate("music/play:ADDED_QUEUE", {
songName: searchResult.hasPlaylist() ? searchResult.playlist.title : searchResult.tracks[0].title,
@ -221,7 +227,7 @@ class Nowplaying extends BaseCommand {
components: [row1, row2],
});
} else clearInterval(i);
}, 1 * 60 * 1000);
}, 60 * 1000);
}
}
@ -234,7 +240,6 @@ class Nowplaying extends BaseCommand {
async function updateEmbed(interaction, queue) {
const progressBar = queue.node.createProgressBar(),
track = queue.currentTrack,
data = await interaction.client.guildsData.findOne({ id: interaction.guildId }),
mode = queue.repeatMode === QueueRepeatMode.AUTOPLAY ? "3" : queue.repeatMode === QueueRepeatMode.QUEUE ? "2" : queue.repeatMode === QueueRepeatMode.TRACK ? "1" : "0",
translated = {
"3": interaction.translate("music/loop:AUTOPLAY"),
@ -260,7 +265,7 @@ async function updateEmbed(interaction, queue) {
{ name: "\u200B", value: "\u200B", inline: true },
{
name: interaction.translate("common:VIEWS"),
value: track.raw.live ? "Live" : new Intl.NumberFormat(interaction.client.languages.find(language => language.name === data.language).moment, { notation: "standard" }).format(track.raw.views),
value: track.raw.live ? "Live" : new Intl.NumberFormat(interaction.client.defaultLanguage.moment, { notation: "standard" }).format(track.raw.views),
inline: true,
},
{

View file

@ -21,7 +21,6 @@ class PlayContext extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").MessageContextMenuCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
await interaction.deferReply();

View file

@ -37,7 +37,6 @@ class Play extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
await interaction.deferReply();

View file

@ -30,6 +30,9 @@ class Queue extends BaseCommand {
if (!interaction.isButton()) return;
if (interaction.customId.startsWith("queue_")) {
interaction.data = [];
interaction.data.guld = await client.findOrCreateGuild(interaction.guildId);
const queue = client.player.nodes.get(interaction.guildId);
if (!queue) return interaction.error("music/play:NOT_PLAYING");
@ -119,7 +122,6 @@ class Queue extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
const queue = client.player.nodes.get(interaction.guildId);

View file

@ -34,7 +34,6 @@ class Seek extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
const time = interaction.options.getInteger("time"),

View file

@ -25,7 +25,6 @@ class Shuffle extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
const voice = interaction.member.voice.channel;

View file

@ -25,7 +25,6 @@ class Skip extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
const voice = interaction.member.voice.channel;

View file

@ -35,7 +35,6 @@ class Skipto extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
const voice = interaction.member.voice.channel;

View file

@ -25,7 +25,6 @@ class Stop extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
const voice = interaction.member.voice.channel;

View file

@ -36,7 +36,6 @@ class Volume extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
const voice = interaction.member.voice.channel;

View file

@ -33,6 +33,9 @@ class NSFW extends BaseCommand {
if (interaction.customId === "nsfw_select") {
await interaction.deferUpdate();
interaction.data = [];
interaction.data.guild = await client.findOrCreateGuild(interaction.guildId);
const tag = interaction?.values[0],
splitted = tag.split("_"),
res = await fetch(`https://nsfw-api-p302.onrender.com/media/${splitted[0].charAt(0).toLowerCase()}/${splitted[1].toLowerCase()}`).then(async r => await r.buffer()),
@ -55,12 +58,11 @@ class NSFW extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
await interaction.deferReply({ ephemeral: true });
if (interaction.guildId && !interaction.channel.nsfw) return interaction.error("misc:NSFW_COMMAND", null, { edit: true, ephemeral: true });
if (interaction.guild && !interaction.channel.nsfw) return interaction.error("misc:NSFW_COMMAND", null, { edit: true, ephemeral: true });
const tags = ["Hentai_Vanila", "Hentai_Yaoi", "Hentai_Yuri", "Hentai_BDSM", "Hentai_Trap", "Real_Ass", "Real_Boobs", "Real_Pussy"]
.map(tag =>

View file

@ -117,7 +117,6 @@ class Debug extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Array} data
*/
async execute(client, interaction) {
const command = interaction.options.getSubcommand();

View file

@ -35,10 +35,8 @@ class Eval extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
// eslint-disable-next-line no-unused-vars
async execute(client, interaction, data) {
async execute(client, interaction) {
await interaction.deferReply({ ephemeral: true });
const code = interaction.options.getString("code");

View file

@ -38,7 +38,6 @@ class Reload extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
const command = interaction.options.getString("command"),

View file

@ -53,7 +53,6 @@ class Say extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
await interaction.deferReply({ ephemeral: true });

View file

@ -25,7 +25,6 @@ class Servers extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
await interaction.deferReply({ ephemeral: true });

View file

@ -36,7 +36,6 @@ class AddUser extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
await interaction.deferReply();

View file

@ -26,11 +26,12 @@ class CloseTicket extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
async execute(client, interaction) {
await interaction.deferReply();
const guildData = interaction.data.guild;
if (!interaction.channel.name.includes("support")) return interaction.error("tickets/adduser:NOT_TICKET", null, { ephemeral: true, edit: true });
const embed = client.embed({
@ -66,8 +67,8 @@ class CloseTicket extends BaseCommand {
collector.on("end", async (_, reason) => {
if (reason !== "canceled") {
const transcriptionLogs = data.guildData.plugins.tickets.transcriptionLogs,
ticketLogs = data.guildData.plugins.tickets.ticketLogs;
const transcriptionLogs = guildData.plugins.tickets.transcriptionLogs,
ticketLogs = guildData.plugins.tickets.ticketLogs;
const reversedMessages = (await interaction.channel.messages.fetch()).filter(m => !m.author.bot);
const messages = Array.from(reversedMessages.values()).reverse();
@ -106,7 +107,7 @@ class CloseTicket extends BaseCommand {
}
});
const ticketLogs = data.guildData.plugins.tickets.ticketLogs;
const ticketLogs = guildData.plugins.tickets.ticketLogs;
const logEmbed = client.embed({
title: interaction.translate("tickets/closeticket:CLOSED_TITLE"),
fields: [

View file

@ -30,13 +30,15 @@ class CreateTicketEmbed extends BaseCommand {
client.on("interactionCreate", async interaction => {
if (!interaction.isButton()) return;
const guildData = await client.findOrCreateGuild(interaction.guildId);
const ticketsCategory = guildData.plugins.tickets.ticketsCategory,
ticketLogs = guildData.plugins.tickets.ticketLogs,
transcriptionLogs = guildData.plugins.tickets.transcriptionLogs;
if (interaction.isButton()) {
interaction.data = [];
interaction.data.guild = await client.findOrCreateGuild(interaction.guildId);
const guildData = interaction.guild.data,
ticketsCategory = guildData.plugins.tickets.ticketsCategory,
ticketLogs = guildData.plugins.tickets.ticketLogs,
transcriptionLogs = guildData.plugins.tickets.transcriptionLogs;
const button = interaction.component;
if (button.customId === "support_ticket") {
@ -206,10 +208,11 @@ class CreateTicketEmbed extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
if (!data.guildData.plugins.tickets.ticketsCategory) return interaction.error("tickets/createticketembed:NO_CATEGORY");
async execute(client, interaction) {
const guildData = interaction.data.guild;
if (!guildData.plugins.tickets.ticketsCategory) return interaction.error("tickets/createticketembed:NO_CATEGORY");
await interaction.deferReply({ ephemeral: true });

View file

@ -36,7 +36,6 @@ class RemoveUser extends BaseCommand {
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
await interaction.deferReply();

View file

@ -16,27 +16,27 @@ class CommandHandler extends BaseEvent {
*/
async execute(client, interaction) {
const command = client.commands.get(interaction.commandName);
const data = [];
const userData = await client.findOrCreateUser(interaction.user.id);
data.userData = userData;
data.user = await client.findOrCreateUser(interaction.user.id);
if (interaction.inGuild()) {
const guildData = await client.findOrCreateGuild(interaction.guildId);
const memberData = await client.findOrCreateMember({ id: interaction.member.id, guildId: interaction.guildId });
interaction.guild.data = data.guildData = guildData;
data.memberData = memberData;
data.guild = await client.findOrCreateGuild(interaction.guildId);
data.member = await client.findOrCreateMember({ id: interaction.member.id, guildId: interaction.guildId });
}
if (command?.dirname.includes("IAT") && interaction.guildId !== "1039187019957555252") return interaction.reply({ content: "IAT Only", ephemeral: true });
if (interaction.isAutocomplete()) return await command.autocompleteRun(client, interaction);
interaction.data = data;
if (interaction.isButton() && interaction.customId === "quote_delete" && interaction.message.deletable) return interaction.message.delete();
if (interaction.isAutocomplete()) return await command.autocompleteRun(client, interaction);
if (interaction.type !== InteractionType.ApplicationCommand && !interaction.isCommand()) return;
if (command?.dirname.includes("IAT") && interaction.guildId !== "1039187019957555252") return interaction.reply({ content: "IAT Only", ephemeral: true });
if (command.ownerOnly && interaction.user.id !== client.config.owner.id) return interaction.error("misc:OWNER_ONLY", null, { ephemeral: true });
if (!userData.achievements.firstCommand.achieved) {
if (!interaction.data.user.achievements.firstCommand.achieved) {
const args = {
content: interaction.user.toString(),
files: [
@ -47,20 +47,29 @@ class CommandHandler extends BaseEvent {
],
};
userData.achievements.firstCommand.progress.now = 1;
userData.achievements.firstCommand.achieved = true;
interaction.data.user.achievements.firstCommand.progress.now = 1;
interaction.data.user.achievements.firstCommand.achieved = true;
userData.markModified("achievements");
await userData.save();
interaction.data.user.markModified("achievements");
await interaction.data.user.save();
try {
interaction.user.send(args);
} catch (e) { /**/ }
}
client.logger.cmd(`User ${interaction.user.getUsername()} used ${command.command.name} in ${interaction.guild ? interaction.guild.name : "DM"} with arguments: ${interaction.options.data.length > 0 ? interaction.options.data.map(arg => { return `${arg.name}: ${arg.value}`; }).join(", ") : "no args" }`);
client.logger.cmd(
`User ${interaction.user.getUsername()} used ${command.command.name} in ${interaction.guild ? interaction.guild.name : "DM"} with arguments: ${
interaction.options.data.length > 0
? interaction.options.data
.map(arg => {
return `${arg.name}: ${arg.value}`;
}).join(", ")
: "no args"
}`,
);
return command.execute(client, interaction, data);
return command.execute(client, interaction);
}
}

View file

@ -19,25 +19,24 @@ class MessageCreate extends BaseEvent {
async execute(client, message) {
if (message.guild && message.guild.id === "568120814776614924") return;
const data = {};
const data = [];
if (message.author.bot) return;
if (message.content.match(new RegExp(`^<@!?${client.user.id}>( |)$`))) return message.replyT("misc:HELLO_SERVER", null, { mention: true });
const userData = await client.findOrCreateUser(message.author.id);
data.userData = userData;
data.user = await client.findOrCreateUser(message.author.id);
if (message.guild && !message.member) await message.guild.members.fetch(message.author.id);
if (message.guild) {
const guildData = await client.findOrCreateGuild(message.guildId);
const memberData = await client.findOrCreateMember({ id: message.author.id, guildId: message.guildId });
if (!message.member) await message.guild.members.fetch(message.author.id);
message.guild.data = data.guildData = guildData;
data.memberData = memberData;
data.guild = await client.findOrCreateGuild(message.guildId);
data.member = await client.findOrCreateMember({ id: message.author.id, guildId: message.guildId });
}
message.data = data;
if (message.guild) {
await updateXp(client, message, data.memberData);
await updateXp(message);
if (message.content.match(/(https|http):\/\/(ptb\.|canary\.)?(discord.com)\/(channels)\/\d+\/\d+\/\d+/g)) {
const link = message.content.match(/(https|http):\/\/(ptb\.|canary\.)?(discord.com)\/(channels)\/\d+\/\d+\/\d+/g)[0],
@ -89,18 +88,18 @@ class MessageCreate extends BaseEvent {
});
}
if (data.guildData.plugins.automod.enabled && !data.guildData.plugins.automod.ignored.includes(message.channelId))
if (message.data.guild.plugins.automod.enabled && !message.data.guild.plugins.automod.ignored.includes(message.channelId))
if (/(discord\.(gg|io|me|li)\/.+|discordapp\.com\/invite\/.+)/i.test(message.content))
if (!message.channel.permissionsFor(message.member).has(PermissionsBitField.Flags.ManageMessages)) {
await message.error("administration/automod:DELETED", null, { mention: true });
message.delete();
}
if (data.userData.afk) {
data.userData.afk = null;
if (message.data.user.afk) {
message.data.user.afk = null;
data.userData.markModified("afk");
await data.userData.save();
message.data.user.markModified("afk");
await message.data.user.save();
message.replyT("general/afk:DELETED", {
user: message.author.username,
@ -121,28 +120,28 @@ class MessageCreate extends BaseEvent {
/**
*
* @param {import("../base/Client")} client
* @param {import("discord.js").Message} msg
* @param {import("../base/Member")} memberData
* @param {import("discord.js").Message} message
* @returns
*/
async function updateXp(client, msg, memberData) {
const points = parseInt(memberData.exp),
async function updateXp(message) {
const memberData = message.data.member,
points = parseInt(memberData.exp),
level = parseInt(memberData.level),
isInCooldown = xpCooldown[msg.author.id];
isInCooldown = xpCooldown[message.author.id];
if (isInCooldown) if (isInCooldown > Date.now()) return;
const toWait = Date.now() + 60 * 1000; // 1 min
xpCooldown[msg.author.id] = toWait;
xpCooldown[message.author.id] = toWait;
const won = client.functions.randomNum(1, 2);
const won = message.client.functions.randomNum(1, 2);
const newXp = parseInt(points + won, 10);
const neededXp = 5 * (level * level) + 80 * level + 100;
if (newXp > neededXp) {
memberData.level = parseInt(level + 1, 10);
memberData.exp = 0;
msg.replyT("misc:LEVEL_UP", {
message.replyT("misc:LEVEL_UP", {
level: memberData.level,
}, { mention: false });
} else memberData.exp = parseInt(newXp, 10);

View file

@ -17,7 +17,7 @@ class messageDelete extends BaseEvent {
if (message.guild && message.guildId === "568120814776614924") return;
if (message.author.bot) return;
const guildData = await client.findOrCreateGuild(message.guildId);
const guildData = message.data.guild;
if (guildData.plugins?.monitoring?.messageDelete) {
const embed = client.embed({

View file

@ -20,7 +20,7 @@ class messageUpdate extends BaseEvent {
if (oldMessage.content === newMessage.content) return;
const guildData = await client.findOrCreateGuild(oldMessage.guildId);
const guildData = newMessage.data.guild;
if (guildData.plugins?.monitoring?.messageUpdate) {
const embed = client.embed({

View file

@ -1,5 +1,3 @@
const moment = require("moment");
/**
*
* @param {import("../base/Client")} client
@ -29,12 +27,12 @@ module.exports.init = function (client) {
fields: [
{
name: client.translate("general/remindme:EMBED_CREATED"),
value: moment(r.createdAt).locale(client.defaultLanguage).format("Do MMMM YYYY, HH:mm:ss"),
value: `<t:${r.createdAt}:f>`,
inline: true,
},
{
name: client.translate("general/remindme:EMBED_TIME"),
value: moment(r.sendAt).locale(client.defaultLanguage).format("Do MMMM YYYY, HH:mm:ss"),
value: `<t:${r.sendAt}:f>`,
inline: true,
},
{

View file

@ -5,7 +5,7 @@ User.prototype.getUsername = function () {
};
BaseInteraction.prototype.getLocale = function () {
return this.guild ? this.guild.data.language : "en-US";
return this.guild ? this.data?.guild?.language : "en-US";
};
BaseInteraction.prototype.translate = function (key, args) {
@ -35,15 +35,19 @@ BaseInteraction.prototype.error = async function (key, args, options = {}) {
return await this.replyT(key, args, options);
};
Message.prototype.getLocale = function () {
return this.guild ? this.data?.guild?.language : "en-US";
};
Message.prototype.translate = function (key, args) {
const language = this.client.translations.get(this.guild ? this.guild.data.language : "en-US");
const language = this.client.translations.get(this.getLocale());
if (!language) throw "Message: Invalid language set in data.";
return language(key, args);
};
Message.prototype.replyT = async function (key, args, options = {}) {
const translated = this.translate(key, args, this.guild.data.language ?? "en-US");
const translated = this.translate(key, args, this.getLocale());
const string = options.prefixEmoji ? `${this.client.customEmojis[options.prefixEmoji]} | ${translated}` : translated;
if (options.edit) return await this.edit({ content: string, allowedMentions: { repliedUser: options.mention ? true : false } });

View file

@ -83,7 +83,7 @@ module.exports = {
* @param {String} locale Language
* @returns {String} Beautified Date
*/
printDate(client, date, format = null, locale = client.defaultLanguage) {
printDate(client, date, format = null, locale = client.defaultLanguage.name) {
const languageData = client.languages.find(language => language.name === locale);
if (format === "" || format === null) format = languageData.defaultMomentFormat;
@ -99,7 +99,7 @@ module.exports = {
* @param {String} locale Language
* @returns {String} Time
*/
convertTime(client, time, type = false, prefix = true, locale = client.defaultLanguage) {
convertTime(client, time, type = false, prefix = true, locale = client.defaultLanguage.name) {
const languageData = client.languages.find(language => language.name === locale);
const m = moment(time).locale(languageData.moment);

View file

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