mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-11-21 20:54:58 +05:00
fix saving data (i hope)
This commit is contained in:
parent
1896d3e41a
commit
f296eca51a
38 changed files with 45 additions and 205 deletions
|
@ -328,20 +328,19 @@ class JaBaClient extends Client {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds or creates a member in the database based on the provided member ID and guild ID.
|
* Finds or creates a member in the database based on the provided member ID and guild ID.
|
||||||
* @param {Object} options - The options for finding or creating the member.
|
* @param {string} memberId - The ID of the member to find or create.
|
||||||
* @param {string} options.id - The ID of the member to find or create.
|
* @param {string} guildId - The ID of the guild the member belongs to.
|
||||||
* @param {string} options.guildId - The ID of the guild the member belongs to.
|
|
||||||
* @returns {Promise<import("./Member")>} The member data object, either retrieved from the database or newly created.
|
* @returns {Promise<import("./Member")>} The member data object, either retrieved from the database or newly created.
|
||||||
*/
|
*/
|
||||||
async findOrCreateMember({ id: memberID, guildId }) {
|
async findOrCreateMember(memberId, guildId) {
|
||||||
let memberData = await this.membersData.findOne({ guildID: guildId, id: memberID });
|
let memberData = await this.membersData.findOne({ guildID: guildId, id: memberId });
|
||||||
|
|
||||||
if (memberData) {
|
if (memberData) {
|
||||||
this.databaseCache.members.set(`${memberID}${guildId}`, memberData);
|
this.databaseCache.members.set(`${memberId}${guildId}`, memberData);
|
||||||
|
|
||||||
return memberData;
|
return memberData;
|
||||||
} else {
|
} else {
|
||||||
memberData = new this.membersData({ id: memberID, guildID: guildId });
|
memberData = new this.membersData({ id: memberId, guildID: guildId });
|
||||||
|
|
||||||
await memberData.save();
|
await memberData.save();
|
||||||
|
|
||||||
|
@ -353,7 +352,7 @@ class JaBaClient extends Client {
|
||||||
await guildData.save();
|
await guildData.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.databaseCache.members.set(`${memberID}${guildId}`, memberData);
|
this.databaseCache.members.set(`${memberId}/${guildId}`, memberData);
|
||||||
|
|
||||||
return memberData;
|
return memberData;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,8 +35,6 @@ class ImportMee6 extends BaseCommand {
|
||||||
interaction.data.member.level = level;
|
interaction.data.member.level = level;
|
||||||
interaction.data.member.exp = 0;
|
interaction.data.member.exp = 0;
|
||||||
|
|
||||||
interaction.data.member.markModified("level");
|
|
||||||
interaction.data.member.markModified("exp");
|
|
||||||
await interaction.data.member.save();
|
await interaction.data.member.save();
|
||||||
|
|
||||||
interaction.editReply({
|
interaction.editReply({
|
||||||
|
|
|
@ -78,14 +78,12 @@ class Automod extends BaseCommand {
|
||||||
ignored: [],
|
ignored: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
data.guild.markModified("plugins.automod");
|
|
||||||
await data.guild.save();
|
await data.guild.save();
|
||||||
|
|
||||||
interaction.success(`administration/automod:${state ? "ENABLED" : "DISABLED"}`);
|
interaction.success(`administration/automod:${state ? "ENABLED" : "DISABLED"}`);
|
||||||
} else if (command === "ignore") {
|
} else if (command === "ignore") {
|
||||||
data.guild.plugins.automod.ignored.push(channel.id);
|
data.guild.plugins.automod.ignored.push(channel.id);
|
||||||
|
|
||||||
data.guild.markModified("plugins.automod");
|
|
||||||
await data.guild.save();
|
await data.guild.save();
|
||||||
|
|
||||||
interaction.success("administration/automod:DISABLED_CHANNEL", {
|
interaction.success("administration/automod:DISABLED_CHANNEL", {
|
||||||
|
|
|
@ -57,7 +57,6 @@ class Autorole extends BaseCommand {
|
||||||
};
|
};
|
||||||
|
|
||||||
if (state && role) {
|
if (state && role) {
|
||||||
guildData.markModified("plugins.autorole");
|
|
||||||
await guildData.save();
|
await guildData.save();
|
||||||
|
|
||||||
interaction.success("administration/autorole:ENABLED", {
|
interaction.success("administration/autorole:ENABLED", {
|
||||||
|
@ -66,7 +65,6 @@ class Autorole extends BaseCommand {
|
||||||
} else {
|
} else {
|
||||||
guildData.plugins.autorole.enabled = false;
|
guildData.plugins.autorole.enabled = false;
|
||||||
|
|
||||||
guildData.markModified("plugins.autorole");
|
|
||||||
await guildData.save();
|
await guildData.save();
|
||||||
|
|
||||||
interaction.success("administration/autorole:DISABLED");
|
interaction.success("administration/autorole:DISABLED");
|
||||||
|
|
|
@ -194,7 +194,6 @@ async function changeSetting(interaction, setting, state, channel) {
|
||||||
if (!state) {
|
if (!state) {
|
||||||
data.plugins[settingSplitted[0]][settingSplitted[1]] = null;
|
data.plugins[settingSplitted[0]][settingSplitted[1]] = null;
|
||||||
|
|
||||||
data.markModified(`plugins.${settingSplitted[0]}`);
|
|
||||||
await data.save();
|
await data.save();
|
||||||
|
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
|
@ -207,7 +206,6 @@ async function changeSetting(interaction, setting, state, channel) {
|
||||||
if (channel) {
|
if (channel) {
|
||||||
data.plugins[settingSplitted[0]][settingSplitted[1]] = channel.id;
|
data.plugins[settingSplitted[0]][settingSplitted[1]] = channel.id;
|
||||||
|
|
||||||
data.markModified(`plugins.${settingSplitted[0]}`);
|
|
||||||
await data.save();
|
await data.save();
|
||||||
|
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
|
@ -226,7 +224,6 @@ async function changeSetting(interaction, setting, state, channel) {
|
||||||
if (!state) {
|
if (!state) {
|
||||||
data.plugins[setting] = null;
|
data.plugins[setting] = null;
|
||||||
|
|
||||||
data.markModified(`plugins.${setting}`);
|
|
||||||
await data.save();
|
await data.save();
|
||||||
|
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
|
@ -237,7 +234,6 @@ async function changeSetting(interaction, setting, state, channel) {
|
||||||
if (channel) {
|
if (channel) {
|
||||||
data.plugins[setting] = channel.id;
|
data.plugins[setting] = channel.id;
|
||||||
|
|
||||||
data.markModified(`plugins.${setting}`);
|
|
||||||
await data.save();
|
await data.save();
|
||||||
|
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
|
|
|
@ -101,7 +101,6 @@ class Goodbye extends BaseCommand {
|
||||||
withImage: null,
|
withImage: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
guildData.markModified("plugins.goodbye");
|
|
||||||
await guildData.save();
|
await guildData.save();
|
||||||
|
|
||||||
interaction.success("administration/goodbye:DISABLED", null, { ephemeral: true });
|
interaction.success("administration/goodbye:DISABLED", null, { ephemeral: true });
|
||||||
|
@ -117,7 +116,6 @@ class Goodbye extends BaseCommand {
|
||||||
withImage: image,
|
withImage: image,
|
||||||
};
|
};
|
||||||
|
|
||||||
guildData.markModified("plugins.goodbye");
|
|
||||||
await guildData.save();
|
await guildData.save();
|
||||||
|
|
||||||
interaction.success("administration/goodbye:ENABLED", {
|
interaction.success("administration/goodbye:ENABLED", {
|
||||||
|
|
|
@ -68,10 +68,7 @@ class Set extends BaseCommand {
|
||||||
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(member.id, interaction.guildId);
|
||||||
id: member.id,
|
|
||||||
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 });
|
||||||
|
@ -80,7 +77,6 @@ class Set extends BaseCommand {
|
||||||
case "level": {
|
case "level": {
|
||||||
memberData.level = int;
|
memberData.level = int;
|
||||||
|
|
||||||
memberData.markModified("level");
|
|
||||||
await memberData.save();
|
await memberData.save();
|
||||||
|
|
||||||
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
|
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
|
||||||
|
@ -92,7 +88,6 @@ class Set extends BaseCommand {
|
||||||
case "xp": {
|
case "xp": {
|
||||||
memberData.exp = int;
|
memberData.exp = int;
|
||||||
|
|
||||||
memberData.markModified("exp");
|
|
||||||
await memberData.save();
|
await memberData.save();
|
||||||
|
|
||||||
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
|
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
|
||||||
|
@ -104,7 +99,6 @@ class Set extends BaseCommand {
|
||||||
case "credits": {
|
case "credits": {
|
||||||
memberData.money = int;
|
memberData.money = int;
|
||||||
|
|
||||||
memberData.markModified("money");
|
|
||||||
await memberData.save();
|
await memberData.save();
|
||||||
|
|
||||||
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
|
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
|
||||||
|
@ -116,7 +110,6 @@ class Set extends BaseCommand {
|
||||||
case "bank": {
|
case "bank": {
|
||||||
memberData.bankSold = int;
|
memberData.bankSold = int;
|
||||||
|
|
||||||
memberData.markModified("bankSold");
|
|
||||||
await memberData.save();
|
await memberData.save();
|
||||||
|
|
||||||
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
|
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
|
||||||
|
|
|
@ -45,7 +45,6 @@ class Setlang extends BaseCommand {
|
||||||
|
|
||||||
guildData.language = language.name;
|
guildData.language = language.name;
|
||||||
|
|
||||||
guildData.markModified("language");
|
|
||||||
await guildData.save();
|
await guildData.save();
|
||||||
|
|
||||||
return interaction.success("administration/setlang:SUCCESS", {
|
return interaction.success("administration/setlang:SUCCESS", {
|
||||||
|
|
|
@ -101,7 +101,6 @@ class Welcome extends BaseCommand {
|
||||||
withImage: null,
|
withImage: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
guildData.markModified("plugins.welcome");
|
|
||||||
await guildData.save();
|
await guildData.save();
|
||||||
|
|
||||||
interaction.success("administration/welcome:DISABLED", null, { ephemeral: true });
|
interaction.success("administration/welcome:DISABLED", null, { ephemeral: true });
|
||||||
|
@ -117,7 +116,6 @@ class Welcome extends BaseCommand {
|
||||||
withImage: image,
|
withImage: image,
|
||||||
};
|
};
|
||||||
|
|
||||||
guildData.markModified("plugins.welcome");
|
|
||||||
await guildData.save();
|
await guildData.save();
|
||||||
|
|
||||||
interaction.success("administration/welcome:ENABLED", {
|
interaction.success("administration/welcome:ENABLED", {
|
||||||
|
|
|
@ -63,8 +63,6 @@ class Bank extends BaseCommand {
|
||||||
memberData.money -= credits;
|
memberData.money -= credits;
|
||||||
memberData.bankSold += credits;
|
memberData.bankSold += credits;
|
||||||
|
|
||||||
memberData.markModified("money");
|
|
||||||
memberData.markModified("bankSold");
|
|
||||||
await memberData.save();
|
await memberData.save();
|
||||||
|
|
||||||
const info = {
|
const info = {
|
||||||
|
@ -99,8 +97,6 @@ class Bank extends BaseCommand {
|
||||||
memberData.money += credits;
|
memberData.money += credits;
|
||||||
memberData.bankSold -= credits;
|
memberData.bankSold -= credits;
|
||||||
|
|
||||||
memberData.markModified("money");
|
|
||||||
memberData.markModified("bankSold");
|
|
||||||
await memberData.save();
|
await memberData.save();
|
||||||
|
|
||||||
interaction.success("economy/bank:SUCCESS_WD", {
|
interaction.success("economy/bank:SUCCESS_WD", {
|
||||||
|
|
|
@ -87,7 +87,6 @@ class Birthdate extends BaseCommand {
|
||||||
|
|
||||||
userData.birthdate = d;
|
userData.birthdate = d;
|
||||||
|
|
||||||
userData.markModified("birthdate");
|
|
||||||
await userData.save();
|
await userData.save();
|
||||||
|
|
||||||
interaction.success("economy/birthdate:SUCCESS", {
|
interaction.success("economy/birthdate:SUCCESS", {
|
||||||
|
|
|
@ -34,13 +34,11 @@ class Divorce extends BaseCommand {
|
||||||
|
|
||||||
userData.lover = null;
|
userData.lover = null;
|
||||||
|
|
||||||
userData.markModified("lover");
|
|
||||||
await userData.save();
|
await userData.save();
|
||||||
|
|
||||||
const oldLover = await client.findOrCreateUser(user.id);
|
const oldLover = await client.findOrCreateUser(user.id);
|
||||||
oldLover.lover = null;
|
oldLover.lover = null;
|
||||||
|
|
||||||
oldLover.markModified("lover");
|
|
||||||
await oldLover.save();
|
await oldLover.save();
|
||||||
|
|
||||||
interaction.success("economy/divorce:DIVORCED", {
|
interaction.success("economy/divorce:DIVORCED", {
|
||||||
|
|
|
@ -122,11 +122,6 @@ class Marry extends BaseCommand {
|
||||||
userData.lover = member.id;
|
userData.lover = member.id;
|
||||||
otherUserData.lover = interaction.member.id;
|
otherUserData.lover = interaction.member.id;
|
||||||
|
|
||||||
userData.markModified("lover");
|
|
||||||
otherUserData.markModified("lover");
|
|
||||||
await userData.save();
|
|
||||||
await otherUserData.save();
|
|
||||||
|
|
||||||
const messageOptions = {
|
const messageOptions = {
|
||||||
content: `${member.toString()} :heart: ${interaction.member.toString()}`,
|
content: `${member.toString()} :heart: ${interaction.member.toString()}`,
|
||||||
files: [
|
files: [
|
||||||
|
@ -143,20 +138,17 @@ class Marry extends BaseCommand {
|
||||||
sent = true;
|
sent = true;
|
||||||
otherUserData.achievements.married.achieved = true;
|
otherUserData.achievements.married.achieved = true;
|
||||||
otherUserData.achievements.married.progress.now = 1;
|
otherUserData.achievements.married.progress.now = 1;
|
||||||
|
|
||||||
otherUserData.markModified("achievements");
|
|
||||||
await otherUserData.save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!userData.achievements.married.achieved) {
|
if (!userData.achievements.married.achieved) {
|
||||||
if (!sent) interaction.followUp(messageOptions);
|
if (!sent) interaction.followUp(messageOptions);
|
||||||
userData.achievements.married.achieved = true;
|
userData.achievements.married.achieved = true;
|
||||||
userData.achievements.married.progress.now = 1;
|
userData.achievements.married.progress.now = 1;
|
||||||
|
|
||||||
userData.markModified("achievements");
|
|
||||||
await userData.save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await userData.save();
|
||||||
|
await otherUserData.save();
|
||||||
|
|
||||||
return interaction.editReply({
|
return interaction.editReply({
|
||||||
content: interaction.translate("economy/marry:SUCCESS", {
|
content: interaction.translate("economy/marry:SUCCESS", {
|
||||||
creator: interaction.member.toString(),
|
creator: interaction.member.toString(),
|
||||||
|
|
|
@ -41,16 +41,13 @@ class Money extends BaseCommand {
|
||||||
const member = interaction.options.getMember("user") || interaction.member;
|
const member = interaction.options.getMember("user") || interaction.member;
|
||||||
if (member.user.bot) return interaction.error("economy/money:BOT_USER");
|
if (member.user.bot) return interaction.error("economy/money:BOT_USER");
|
||||||
|
|
||||||
const memberData = member.id === interaction.user.id ? interaction.data.member : await client.findOrCreateMember({ id: member.id, guildId: interaction.guildId });
|
const memberData = member.id === interaction.user.id ? interaction.data.member : await client.findOrCreateMember(member.id, interaction.guildId);
|
||||||
|
|
||||||
const guilds = client.guilds.cache.filter(g => g.members.cache.find(m => m.id === member.id));
|
const guilds = client.guilds.cache.filter(g => g.members.cache.find(m => m.id === member.id));
|
||||||
|
|
||||||
let globalMoney = 0;
|
let globalMoney = 0;
|
||||||
await client.functions.asyncForEach(guilds, async guild => {
|
await client.functions.asyncForEach(guilds, async guild => {
|
||||||
const data = await client.findOrCreateMember({
|
const data = await client.findOrCreateMember(member.id, guild.id);
|
||||||
id: member.id,
|
|
||||||
guildId: guild.id,
|
|
||||||
});
|
|
||||||
globalMoney += data.money + data.bankSold;
|
globalMoney += data.money + data.bankSold;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -59,21 +59,11 @@ class Pay extends BaseCommand {
|
||||||
amount: `**${amount}** ${client.functions.getNoun(amount, interaction.translate("misc:NOUNS:CREDITS:1"), interaction.translate("misc:NOUNS:CREDITS:2"), interaction.translate("misc:NOUNS:CREDITS:5"))}`,
|
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 otherMemberData = await client.findOrCreateMember({
|
const otherMemberData = await client.findOrCreateMember(otherMember.id, interaction.guildId);
|
||||||
id: otherMember.id,
|
|
||||||
guildId: interaction.guildId,
|
|
||||||
});
|
|
||||||
|
|
||||||
memberData.money -= amount;
|
memberData.money -= amount;
|
||||||
|
|
||||||
memberData.markModified("money");
|
|
||||||
await memberData.save();
|
|
||||||
|
|
||||||
otherMemberData.money += amount;
|
otherMemberData.money += amount;
|
||||||
|
|
||||||
otherMemberData.markModified("money");
|
|
||||||
await otherMemberData.save();
|
|
||||||
|
|
||||||
const info1 = {
|
const info1 = {
|
||||||
user: otherMember.user.getUsername(),
|
user: otherMember.user.getUsername(),
|
||||||
amount: amount,
|
amount: amount,
|
||||||
|
@ -90,6 +80,9 @@ class Pay extends BaseCommand {
|
||||||
};
|
};
|
||||||
otherMemberData.transactions.push(info2);
|
otherMemberData.transactions.push(info2);
|
||||||
|
|
||||||
|
await memberData.save();
|
||||||
|
await otherMemberData.save();
|
||||||
|
|
||||||
interaction.success("economy/pay:SUCCESS", {
|
interaction.success("economy/pay:SUCCESS", {
|
||||||
user: otherMember.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"))}`,
|
amount: `**${amount}** ${client.functions.getNoun(amount, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||||
|
|
|
@ -41,17 +41,14 @@ class Profile extends BaseCommand {
|
||||||
const member = interaction.options.getMember("user") || interaction.member;
|
const member = interaction.options.getMember("user") || interaction.member;
|
||||||
if (member.user.bot) return interaction.error("economy/profile:BOT_USER");
|
if (member.user.bot) return interaction.error("economy/profile:BOT_USER");
|
||||||
|
|
||||||
const memberData = member.id === interaction.user.id ? interaction.data.member : await client.findOrCreateMember({ id: member.id, guildId: interaction.guildId });
|
const memberData = member.id === interaction.user.id ? interaction.data.member : await client.findOrCreateMember(member.id, interaction.guildId);
|
||||||
const userData = member.id === interaction.user.id ? interaction.data.user : await client.findOrCreateUser(member.id);
|
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);
|
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));
|
const guilds = client.guilds.cache.filter(g => g.members.cache.find(m => m.id === member.id));
|
||||||
let globalMoney = 0;
|
let globalMoney = 0;
|
||||||
await client.functions.asyncForEach(guilds, async guild => {
|
await client.functions.asyncForEach(guilds, async guild => {
|
||||||
const data = await client.findOrCreateMember({
|
const data = await client.findOrCreateMember(member.id, guild.id);
|
||||||
id: member.id,
|
|
||||||
guildId: guild.id,
|
|
||||||
});
|
|
||||||
globalMoney += data.money + data.bankSold;
|
globalMoney += data.money + data.bankSold;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -56,9 +56,6 @@ class Rep extends BaseCommand {
|
||||||
|
|
||||||
userData.cooldowns.rep = toWait;
|
userData.cooldowns.rep = toWait;
|
||||||
|
|
||||||
userData.markModified("cooldowns");
|
|
||||||
await userData.save();
|
|
||||||
|
|
||||||
const otherUserData = await client.findOrCreateUser(user.id);
|
const otherUserData = await client.findOrCreateUser(user.id);
|
||||||
|
|
||||||
otherUserData.rep++;
|
otherUserData.rep++;
|
||||||
|
@ -79,7 +76,7 @@ class Rep extends BaseCommand {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
otherUserData.markModified("rep");
|
await userData.save();
|
||||||
await otherUserData.save();
|
await otherUserData.save();
|
||||||
|
|
||||||
interaction.success("economy/rep:SUCCESS", {
|
interaction.success("economy/rep:SUCCESS", {
|
||||||
|
|
|
@ -55,10 +55,7 @@ class Rob extends BaseCommand {
|
||||||
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");
|
||||||
|
|
||||||
const otherMemberData = await client.findOrCreateMember({
|
const otherMemberData = await client.findOrCreateMember(otherMember.id, interaction.guildId);
|
||||||
id: otherMember.id,
|
|
||||||
guildId: interaction.guildId,
|
|
||||||
});
|
|
||||||
if (amount > otherMemberData.money) return interaction.error("economy/rob:NOT_ENOUGH_MEMBER", { user: otherMember.toString() });
|
if (amount > otherMemberData.money) return interaction.error("economy/rob:NOT_ENOUGH_MEMBER", { user: otherMember.toString() });
|
||||||
|
|
||||||
const isInCooldown = otherMemberData.cooldowns.rob || 0;
|
const isInCooldown = otherMemberData.cooldowns.rob || 0;
|
||||||
|
@ -81,9 +78,6 @@ class Rob extends BaseCommand {
|
||||||
|
|
||||||
otherMemberData.cooldowns.rob = toWait;
|
otherMemberData.cooldowns.rob = toWait;
|
||||||
|
|
||||||
otherMemberData.markModified("cooldowns");
|
|
||||||
await otherMemberData.save();
|
|
||||||
|
|
||||||
interaction.replyT("economy/rob:ROB_WON_" + randomNum, {
|
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"))}`,
|
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: otherMember.toString(),
|
user: otherMember.toString(),
|
||||||
|
@ -92,8 +86,6 @@ class Rob extends BaseCommand {
|
||||||
memberData.money += amount;
|
memberData.money += amount;
|
||||||
otherMemberData.money -= amount;
|
otherMemberData.money -= amount;
|
||||||
|
|
||||||
memberData.markModified("money");
|
|
||||||
otherMemberData.markModified("money");
|
|
||||||
await memberData.save();
|
await memberData.save();
|
||||||
await otherMemberData.save();
|
await otherMemberData.save();
|
||||||
} else {
|
} else {
|
||||||
|
@ -109,8 +101,6 @@ class Rob extends BaseCommand {
|
||||||
memberData.money -= potentiallyLose;
|
memberData.money -= potentiallyLose;
|
||||||
otherMemberData.money += won;
|
otherMemberData.money += won;
|
||||||
|
|
||||||
memberData.markModified("money");
|
|
||||||
otherMemberData.markModified("money");
|
|
||||||
await memberData.save();
|
await memberData.save();
|
||||||
await otherMemberData.save();
|
await otherMemberData.save();
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,6 @@ class Setbio extends BaseCommand {
|
||||||
|
|
||||||
userData.bio = newBio;
|
userData.bio = newBio;
|
||||||
|
|
||||||
userData.markModified("bio");
|
|
||||||
await userData.save();
|
await userData.save();
|
||||||
|
|
||||||
interaction.success("economy/setbio:SUCCESS");
|
interaction.success("economy/setbio:SUCCESS");
|
||||||
|
|
|
@ -135,13 +135,8 @@ class Slots extends BaseCommand {
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
userData.markModified("achievements");
|
|
||||||
await userData.save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
memberData.markModified("money");
|
|
||||||
memberData.markModified("transactions");
|
|
||||||
await memberData.save();
|
await memberData.save();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -186,13 +181,8 @@ class Slots extends BaseCommand {
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
userData.markModified("achievements");
|
|
||||||
await userData.save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
memberData.markModified("money");
|
|
||||||
memberData.markModified("transactions");
|
|
||||||
await memberData.save();
|
await memberData.save();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -216,15 +206,8 @@ class Slots extends BaseCommand {
|
||||||
memberData.money -= amount;
|
memberData.money -= amount;
|
||||||
memberData.transactions.push(info);
|
memberData.transactions.push(info);
|
||||||
|
|
||||||
if (!userData.achievements.slots.achieved) {
|
if (!userData.achievements.slots.achieved) userData.achievements.slots.progress.now = 0;
|
||||||
userData.achievements.slots.progress.now = 0;
|
|
||||||
|
|
||||||
userData.markModified("achievements");
|
|
||||||
await userData.save();
|
|
||||||
}
|
|
||||||
|
|
||||||
memberData.markModified("money");
|
|
||||||
memberData.markModified("transactions");
|
|
||||||
await memberData.save();
|
await memberData.save();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -41,7 +41,6 @@ class Transactions extends BaseCommand {
|
||||||
if (interaction.options.getBoolean("clear")) {
|
if (interaction.options.getBoolean("clear")) {
|
||||||
memberData.transactions = [];
|
memberData.transactions = [];
|
||||||
|
|
||||||
memberData.markModified("transactions");
|
|
||||||
await memberData.save();
|
await memberData.save();
|
||||||
|
|
||||||
return interaction.success("economy/transactions:CLEARED", null, { ephemeral: true });
|
return interaction.success("economy/transactions:CLEARED", null, { ephemeral: true });
|
||||||
|
|
|
@ -30,23 +30,16 @@ class Work extends BaseCommand {
|
||||||
const { member: memberData, user: userData } = interaction.data,
|
const { member: memberData, user: userData } = interaction.data,
|
||||||
isInCooldown = memberData.cooldowns?.work;
|
isInCooldown = memberData.cooldowns?.work;
|
||||||
|
|
||||||
if (isInCooldown) {
|
if (isInCooldown && isInCooldown > 0 && isInCooldown > Math.floor(Date.now() / 1000))
|
||||||
if (isInCooldown > Date.now())
|
return interaction.error("economy/work:COOLDOWN", {
|
||||||
return interaction.error("economy/work:COOLDOWN", {
|
time: `<t:${Math.floor(isInCooldown)}:R>`,
|
||||||
time: `<t:${Math.floor(isInCooldown / 1000)}:R>`,
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Date.now() > Math.floor(memberData.cooldowns.work + 24 * 60 * 60 * 1000) / 1000) memberData.workStreak = 0;
|
if (Math.floor(Date.now() / 1000) > Math.floor(memberData.cooldowns.work + 24 * 60 * 60)) memberData.workStreak = 0;
|
||||||
|
|
||||||
const toWait = Math.floor((Date.now() + 24 * 60 * 60 * 1000) / 1000); // 24 hours
|
memberData.cooldowns.work = Math.floor(Date.now() / 1000) + 24 * 60 * 60; // 24 hours
|
||||||
memberData.cooldowns.work = toWait;
|
|
||||||
memberData.workStreak = (memberData.workStreak || 0) + 1;
|
memberData.workStreak = (memberData.workStreak || 0) + 1;
|
||||||
|
|
||||||
memberData.markModified("cooldowns");
|
|
||||||
memberData.markModified("workStreak");
|
|
||||||
await memberData.save();
|
|
||||||
|
|
||||||
const embed = client.embed({
|
const embed = client.embed({
|
||||||
footer: {
|
footer: {
|
||||||
text: interaction.translate("economy/work:AWARD"),
|
text: interaction.translate("economy/work:AWARD"),
|
||||||
|
@ -96,9 +89,6 @@ class Work extends BaseCommand {
|
||||||
|
|
||||||
memberData.money += won;
|
memberData.money += won;
|
||||||
|
|
||||||
memberData.markModified("money");
|
|
||||||
await memberData.save();
|
|
||||||
|
|
||||||
const info = {
|
const info = {
|
||||||
user: interaction.translate("economy/work:SALARY"),
|
user: interaction.translate("economy/work:SALARY"),
|
||||||
amount: won,
|
amount: won,
|
||||||
|
@ -123,10 +113,11 @@ class Work extends BaseCommand {
|
||||||
userData.achievements.work.achieved = true;
|
userData.achievements.work.achieved = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
userData.markModified("achievements");
|
|
||||||
await userData.save();
|
await userData.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await memberData.save();
|
||||||
|
|
||||||
interaction.reply(messageOptions);
|
interaction.reply(messageOptions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,10 +80,7 @@ class Number extends BaseCommand {
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
const memberData = await client.findOrCreateMember({
|
const memberData = await client.findOrCreateMember(msg.author.id, interaction.guildId);
|
||||||
id: msg.author.id,
|
|
||||||
guildId: interaction.guildId,
|
|
||||||
});
|
|
||||||
|
|
||||||
memberData.money += won;
|
memberData.money += won;
|
||||||
|
|
||||||
|
@ -95,7 +92,6 @@ class Number extends BaseCommand {
|
||||||
};
|
};
|
||||||
data.memberData.transactions.push(info);
|
data.memberData.transactions.push(info);
|
||||||
|
|
||||||
memberData.markModified("transactions");
|
|
||||||
await memberData.save();
|
await memberData.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,10 +43,7 @@ class TicTacToe extends BaseCommand {
|
||||||
embedColor: client.config.embed.color,
|
embedColor: client.config.embed.color,
|
||||||
embedFoot: client.config.embed.footer,
|
embedFoot: client.config.embed.footer,
|
||||||
}).then(async winner => {
|
}).then(async winner => {
|
||||||
const memberData = await client.findOrCreateMember({
|
const memberData = await client.findOrCreateMember(winner.id, interaction.guildId);
|
||||||
id: winner.id,
|
|
||||||
guildId: interaction.guildId,
|
|
||||||
});
|
|
||||||
|
|
||||||
memberData.money += 100;
|
memberData.money += 100;
|
||||||
|
|
||||||
|
@ -59,8 +56,6 @@ class TicTacToe extends BaseCommand {
|
||||||
|
|
||||||
memberData.transactions.push(info);
|
memberData.transactions.push(info);
|
||||||
|
|
||||||
memberData.markModified("money");
|
|
||||||
memberData.markModified("transactions");
|
|
||||||
await memberData.save();
|
await memberData.save();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,6 @@ class Afk extends BaseCommand {
|
||||||
|
|
||||||
userData.afk = reason;
|
userData.afk = reason;
|
||||||
|
|
||||||
userData.markModified("afk");
|
|
||||||
await userData.save();
|
await userData.save();
|
||||||
|
|
||||||
interaction.success("general/afk:SUCCESS", {
|
interaction.success("general/afk:SUCCESS", {
|
||||||
|
|
|
@ -64,7 +64,6 @@ class Remindme extends BaseCommand {
|
||||||
|
|
||||||
userData.reminds.push(reminder);
|
userData.reminds.push(reminder);
|
||||||
|
|
||||||
userData.markModified("reminds");
|
|
||||||
await userData.save();
|
await userData.save();
|
||||||
|
|
||||||
client.databaseCache.usersReminds.set(interaction.user.id, userData);
|
client.databaseCache.usersReminds.set(interaction.user.id, userData);
|
||||||
|
|
|
@ -40,14 +40,10 @@ class Clearwarns extends BaseCommand {
|
||||||
async execute(client, interaction) {
|
async execute(client, interaction) {
|
||||||
const member = interaction.options.getMember("user");
|
const member = interaction.options.getMember("user");
|
||||||
|
|
||||||
const memberData = await client.findOrCreateMember({
|
const memberData = await client.findOrCreateMember(member.id, interaction.guildId);
|
||||||
id: member.id,
|
|
||||||
guildId: interaction.guildId,
|
|
||||||
});
|
|
||||||
|
|
||||||
memberData.sanctions = [];
|
memberData.sanctions = [];
|
||||||
|
|
||||||
memberData.markModified("sanctions");
|
|
||||||
await memberData.save();
|
await memberData.save();
|
||||||
|
|
||||||
interaction.success("moderation/clearwarns:SUCCESS", {
|
interaction.success("moderation/clearwarns:SUCCESS", {
|
||||||
|
|
|
@ -32,10 +32,7 @@ class WarnContext extends BaseCommand {
|
||||||
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/warn:SUPERIOR", null, { ephemeral: true });
|
if (interaction.guild.ownerId !== interaction.member.id && !(moderationPosition > memberPosition)) return interaction.error("moderation/warn:SUPERIOR", null, { ephemeral: true });
|
||||||
|
|
||||||
const memberData = await client.findOrCreateMember({
|
const memberData = await client.findOrCreateMember(member.id, interaction.guildId);
|
||||||
id: member.id,
|
|
||||||
guildId: interaction.guildId,
|
|
||||||
});
|
|
||||||
|
|
||||||
const modal = new ModalBuilder()
|
const modal = new ModalBuilder()
|
||||||
.setCustomId("warn_modal")
|
.setCustomId("warn_modal")
|
||||||
|
@ -176,7 +173,6 @@ class WarnContext extends BaseCommand {
|
||||||
|
|
||||||
memberData.sanctions.push(caseInfo);
|
memberData.sanctions.push(caseInfo);
|
||||||
|
|
||||||
memberData.markModified("sanctions");
|
|
||||||
await memberData.save();
|
await memberData.save();
|
||||||
|
|
||||||
const guildData = interaction.data.guild;
|
const guildData = interaction.data.guild;
|
||||||
|
|
|
@ -41,10 +41,7 @@ class Warns extends BaseCommand {
|
||||||
const member = interaction.options.getMember("user");
|
const member = interaction.options.getMember("user");
|
||||||
if (member.user.bot) return interaction.error("misc:BOT_USER");
|
if (member.user.bot) return interaction.error("misc:BOT_USER");
|
||||||
|
|
||||||
const memberData = await client.findOrCreateMember({
|
const memberData = await client.findOrCreateMember(member.id, interaction.guildId);
|
||||||
id: member.id,
|
|
||||||
guildId: interaction.guildId,
|
|
||||||
});
|
|
||||||
|
|
||||||
const embed = client.embed({
|
const embed = client.embed({
|
||||||
author: {
|
author: {
|
||||||
|
|
|
@ -129,16 +129,12 @@ class Debug extends BaseCommand {
|
||||||
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(member.id),
|
const userData = await client.findOrCreateUser(member.id),
|
||||||
memberData = await client.findOrCreateMember({
|
memberData = await client.findOrCreateMember(member.id, interaction.guildId);
|
||||||
id: member.id,
|
|
||||||
guildId: interaction.guildId,
|
|
||||||
});
|
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "level": {
|
case "level": {
|
||||||
memberData.level = int;
|
memberData.level = int;
|
||||||
|
|
||||||
memberData.markModified("level");
|
|
||||||
await memberData.save();
|
await memberData.save();
|
||||||
|
|
||||||
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
|
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
|
||||||
|
@ -150,7 +146,6 @@ class Debug extends BaseCommand {
|
||||||
case "xp": {
|
case "xp": {
|
||||||
memberData.exp = int;
|
memberData.exp = int;
|
||||||
|
|
||||||
memberData.markModified("exp");
|
|
||||||
await memberData.save();
|
await memberData.save();
|
||||||
|
|
||||||
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
|
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
|
||||||
|
@ -162,7 +157,6 @@ class Debug extends BaseCommand {
|
||||||
case "credits": {
|
case "credits": {
|
||||||
memberData.money = int;
|
memberData.money = int;
|
||||||
|
|
||||||
memberData.markModified("money");
|
|
||||||
await memberData.save();
|
await memberData.save();
|
||||||
|
|
||||||
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
|
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
|
||||||
|
@ -174,7 +168,6 @@ class Debug extends BaseCommand {
|
||||||
case "bank": {
|
case "bank": {
|
||||||
memberData.bankSold = int;
|
memberData.bankSold = int;
|
||||||
|
|
||||||
memberData.markModified("bankSold");
|
|
||||||
await memberData.save();
|
await memberData.save();
|
||||||
|
|
||||||
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
|
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
|
||||||
|
@ -186,7 +179,6 @@ class Debug extends BaseCommand {
|
||||||
case "rep": {
|
case "rep": {
|
||||||
userData.rep = int;
|
userData.rep = int;
|
||||||
|
|
||||||
userData.markModified("rep");
|
|
||||||
await userData.save();
|
await userData.save();
|
||||||
|
|
||||||
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
|
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
|
||||||
|
@ -203,16 +195,12 @@ class Debug extends BaseCommand {
|
||||||
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(member.id),
|
const userData = await client.findOrCreateUser(member.id),
|
||||||
memberData = await client.findOrCreateMember({
|
memberData = await client.findOrCreateMember(member.id, interaction.guildId);
|
||||||
id: member.id,
|
|
||||||
guildId: interaction.guildId,
|
|
||||||
});
|
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "level": {
|
case "level": {
|
||||||
memberData.level += int;
|
memberData.level += int;
|
||||||
|
|
||||||
memberData.markModified("level");
|
|
||||||
await memberData.save();
|
await memberData.save();
|
||||||
|
|
||||||
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
|
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
|
||||||
|
@ -224,7 +212,6 @@ class Debug extends BaseCommand {
|
||||||
case "xp": {
|
case "xp": {
|
||||||
memberData.exp += int;
|
memberData.exp += int;
|
||||||
|
|
||||||
memberData.markModified("exp");
|
|
||||||
await memberData.save();
|
await memberData.save();
|
||||||
|
|
||||||
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
|
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
|
||||||
|
@ -236,7 +223,6 @@ class Debug extends BaseCommand {
|
||||||
case "credits": {
|
case "credits": {
|
||||||
memberData.money += int;
|
memberData.money += int;
|
||||||
|
|
||||||
memberData.markModified("money");
|
|
||||||
await memberData.save();
|
await memberData.save();
|
||||||
|
|
||||||
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
|
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
|
||||||
|
@ -248,7 +234,6 @@ class Debug extends BaseCommand {
|
||||||
case "bank": {
|
case "bank": {
|
||||||
memberData.bankSold += int;
|
memberData.bankSold += int;
|
||||||
|
|
||||||
memberData.markModified("bankSold");
|
|
||||||
await memberData.save();
|
await memberData.save();
|
||||||
|
|
||||||
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
|
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
|
||||||
|
@ -260,7 +245,6 @@ class Debug extends BaseCommand {
|
||||||
case "rep": {
|
case "rep": {
|
||||||
userData.rep += int;
|
userData.rep += int;
|
||||||
|
|
||||||
userData.markModified("rep");
|
|
||||||
await userData.save();
|
await userData.save();
|
||||||
|
|
||||||
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
|
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
|
||||||
|
|
|
@ -51,9 +51,6 @@ class CreateTicketEmbed extends BaseCommand {
|
||||||
|
|
||||||
guildData.plugins.tickets.count++;
|
guildData.plugins.tickets.count++;
|
||||||
|
|
||||||
guildData.markModified("plugins.tickets");
|
|
||||||
await guildData.save();
|
|
||||||
|
|
||||||
const channel = await interaction.guild.channels.create({
|
const channel = await interaction.guild.channels.create({
|
||||||
name: `${interaction.user.username}-support-${guildData.plugins.tickets.count}`,
|
name: `${interaction.user.username}-support-${guildData.plugins.tickets.count}`,
|
||||||
topic: interaction.user.id,
|
topic: interaction.user.id,
|
||||||
|
@ -103,6 +100,8 @@ class CreateTicketEmbed extends BaseCommand {
|
||||||
.setStyle(ButtonStyle.Secondary);
|
.setStyle(ButtonStyle.Secondary);
|
||||||
const row = new ActionRowBuilder().addComponents(closeButton, transcriptButton);
|
const row = new ActionRowBuilder().addComponents(closeButton, transcriptButton);
|
||||||
|
|
||||||
|
await guildData.save();
|
||||||
|
|
||||||
await channel.send({ embeds: [embed], components: [row] });
|
await channel.send({ embeds: [embed], components: [row] });
|
||||||
} else if (button.customId === "close_ticket") {
|
} else if (button.customId === "close_ticket") {
|
||||||
const embed = client.embed({
|
const embed = client.embed({
|
||||||
|
|
|
@ -29,7 +29,6 @@ module.exports = client => [
|
||||||
|
|
||||||
guildData.language = newData;
|
guildData.language = newData;
|
||||||
|
|
||||||
guildData.markModified("language");
|
|
||||||
await guildData.save();
|
await guildData.save();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -55,7 +54,6 @@ module.exports = client => [
|
||||||
|
|
||||||
guildData.plugins.welcome.enabled = newData;
|
guildData.plugins.welcome.enabled = newData;
|
||||||
|
|
||||||
guildData.markModified("plugins");
|
|
||||||
await guildData.save();
|
await guildData.save();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -76,7 +74,6 @@ module.exports = client => [
|
||||||
|
|
||||||
guildData.plugins.welcome.withImage = newData;
|
guildData.plugins.welcome.withImage = newData;
|
||||||
|
|
||||||
guildData.markModified("plugins");
|
|
||||||
await guildData.save();
|
await guildData.save();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -97,7 +94,6 @@ module.exports = client => [
|
||||||
|
|
||||||
guildData.plugins.welcome.message = newData !== "" ? newData : null;
|
guildData.plugins.welcome.message = newData !== "" ? newData : null;
|
||||||
|
|
||||||
guildData.markModified("plugins");
|
|
||||||
await guildData.save();
|
await guildData.save();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -118,7 +114,6 @@ module.exports = client => [
|
||||||
|
|
||||||
guildData.plugins.welcome.channel = newData !== "" ? newData : null;
|
guildData.plugins.welcome.channel = newData !== "" ? newData : null;
|
||||||
|
|
||||||
guildData.markModified("plugins");
|
|
||||||
await guildData.save();
|
await guildData.save();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -146,7 +141,6 @@ module.exports = client => [
|
||||||
|
|
||||||
guildData.plugins.goodbye.enabled = newData;
|
guildData.plugins.goodbye.enabled = newData;
|
||||||
|
|
||||||
guildData.markModified("plugins");
|
|
||||||
await guildData.save();
|
await guildData.save();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -167,7 +161,6 @@ module.exports = client => [
|
||||||
|
|
||||||
guildData.plugins.goodbye.withImage = newData;
|
guildData.plugins.goodbye.withImage = newData;
|
||||||
|
|
||||||
guildData.markModified("plugins");
|
|
||||||
await guildData.save();
|
await guildData.save();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -188,7 +181,6 @@ module.exports = client => [
|
||||||
|
|
||||||
guildData.plugins.goodbye.message = newData !== "" ? newData : null;
|
guildData.plugins.goodbye.message = newData !== "" ? newData : null;
|
||||||
|
|
||||||
guildData.markModified("plugins");
|
|
||||||
await guildData.save();
|
await guildData.save();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -209,7 +201,6 @@ module.exports = client => [
|
||||||
|
|
||||||
guildData.plugins.goodbye.channel = newData !== "" ? newData : null;
|
guildData.plugins.goodbye.channel = newData !== "" ? newData : null;
|
||||||
|
|
||||||
guildData.markModified("plugins");
|
|
||||||
await guildData.save();
|
await guildData.save();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -237,7 +228,6 @@ module.exports = client => [
|
||||||
|
|
||||||
guildData.plugins.autorole.enabled = newData;
|
guildData.plugins.autorole.enabled = newData;
|
||||||
|
|
||||||
guildData.markModified("plugins");
|
|
||||||
await guildData.save();
|
await guildData.save();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -258,7 +248,6 @@ module.exports = client => [
|
||||||
|
|
||||||
guildData.plugins.autorole.role = newData !== "" ? newData : null;
|
guildData.plugins.autorole.role = newData !== "" ? newData : null;
|
||||||
|
|
||||||
guildData.markModified("plugins");
|
|
||||||
await guildData.save();
|
await guildData.save();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -286,7 +275,6 @@ module.exports = client => [
|
||||||
|
|
||||||
guildData.plugins.automod.enabled = newData;
|
guildData.plugins.automod.enabled = newData;
|
||||||
|
|
||||||
guildData.markModified("plugins");
|
|
||||||
await guildData.save();
|
await guildData.save();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -307,7 +295,6 @@ module.exports = client => [
|
||||||
|
|
||||||
guildData.plugins.automod.ignored = newData;
|
guildData.plugins.automod.ignored = newData;
|
||||||
|
|
||||||
guildData.markModified("plugins");
|
|
||||||
await guildData.save();
|
await guildData.save();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -337,7 +324,6 @@ module.exports = client => [
|
||||||
|
|
||||||
guildData.plugins.monitoring.messageUpdate = newData !== "" ? newData : null;
|
guildData.plugins.monitoring.messageUpdate = newData !== "" ? newData : null;
|
||||||
|
|
||||||
guildData.markModified("plugins");
|
|
||||||
await guildData.save();
|
await guildData.save();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -360,7 +346,6 @@ module.exports = client => [
|
||||||
|
|
||||||
guildData.plugins.monitoring.messageDelete = newData !== "" ? newData : null;
|
guildData.plugins.monitoring.messageDelete = newData !== "" ? newData : null;
|
||||||
|
|
||||||
guildData.markModified("plugins");
|
|
||||||
await guildData.save();
|
await guildData.save();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -388,7 +373,6 @@ module.exports = client => [
|
||||||
|
|
||||||
guildData.plugins.suggestions = newData !== "" ? newData : null;
|
guildData.plugins.suggestions = newData !== "" ? newData : null;
|
||||||
|
|
||||||
guildData.markModified("plugins");
|
|
||||||
await guildData.save();
|
await guildData.save();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -409,7 +393,6 @@ module.exports = client => [
|
||||||
|
|
||||||
guildData.plugins.reports = newData !== "" ? newData : null;
|
guildData.plugins.reports = newData !== "" ? newData : null;
|
||||||
|
|
||||||
guildData.markModified("plugins");
|
|
||||||
await guildData.save();
|
await guildData.save();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -430,7 +413,6 @@ module.exports = client => [
|
||||||
|
|
||||||
guildData.plugins.birthdays = newData !== "" ? newData : null;
|
guildData.plugins.birthdays = newData !== "" ? newData : null;
|
||||||
|
|
||||||
guildData.markModified("plugins");
|
|
||||||
await guildData.save();
|
await guildData.save();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -451,7 +433,6 @@ module.exports = client => [
|
||||||
|
|
||||||
guildData.plugins.modlogs = newData !== "" ? newData : null;
|
guildData.plugins.modlogs = newData !== "" ? newData : null;
|
||||||
|
|
||||||
guildData.markModified("plugins");
|
|
||||||
await guildData.save();
|
await guildData.save();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -23,7 +23,7 @@ class CommandHandler extends BaseEvent {
|
||||||
|
|
||||||
if (interaction.inGuild()) {
|
if (interaction.inGuild()) {
|
||||||
data.guild = await client.findOrCreateGuild(interaction.guildId);
|
data.guild = await client.findOrCreateGuild(interaction.guildId);
|
||||||
data.member = await client.findOrCreateMember({ id: interaction.member.id, guildId: interaction.guildId });
|
data.member = await client.findOrCreateMember(interaction.member.id, interaction.guildId);
|
||||||
}
|
}
|
||||||
|
|
||||||
interaction.data = data;
|
interaction.data = data;
|
||||||
|
@ -50,7 +50,6 @@ class CommandHandler extends BaseEvent {
|
||||||
interaction.data.user.achievements.firstCommand.progress.now = 1;
|
interaction.data.user.achievements.firstCommand.progress.now = 1;
|
||||||
interaction.data.user.achievements.firstCommand.achieved = true;
|
interaction.data.user.achievements.firstCommand.achieved = true;
|
||||||
|
|
||||||
interaction.data.user.markModified("achievements");
|
|
||||||
await interaction.data.user.save();
|
await interaction.data.user.save();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -20,7 +20,6 @@ class GuildCreate extends BaseEvent {
|
||||||
userData.achievements.invite.progress.now = 1;
|
userData.achievements.invite.progress.now = 1;
|
||||||
userData.achievements.invite.achieved = true;
|
userData.achievements.invite.achieved = true;
|
||||||
|
|
||||||
userData.markModified("achievements");
|
|
||||||
await userData.save();
|
await userData.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@ class GuildMemberUpdate extends BaseEvent {
|
||||||
userData.achievements.tip.progress.now = 1;
|
userData.achievements.tip.progress.now = 1;
|
||||||
userData.achievements.tip.achieved = true;
|
userData.achievements.tip.achieved = true;
|
||||||
|
|
||||||
userData.markModified("achievements");
|
|
||||||
await userData.save();
|
await userData.save();
|
||||||
|
|
||||||
newMember.send({
|
newMember.send({
|
||||||
|
|
|
@ -30,7 +30,7 @@ class MessageCreate extends BaseEvent {
|
||||||
if (!message.member) await message.guild.members.fetch(message.author.id);
|
if (!message.member) await message.guild.members.fetch(message.author.id);
|
||||||
|
|
||||||
data.guild = await client.findOrCreateGuild(message.guildId);
|
data.guild = await client.findOrCreateGuild(message.guildId);
|
||||||
data.member = await client.findOrCreateMember({ id: message.author.id, guildId: message.guildId });
|
data.member = await client.findOrCreateMember(message.author.id, message.guildId);
|
||||||
}
|
}
|
||||||
|
|
||||||
message.data = data;
|
message.data = data;
|
||||||
|
@ -98,7 +98,6 @@ class MessageCreate extends BaseEvent {
|
||||||
if (message.data.user.afk) {
|
if (message.data.user.afk) {
|
||||||
message.data.user.afk = null;
|
message.data.user.afk = null;
|
||||||
|
|
||||||
message.data.user.markModified("afk");
|
|
||||||
await message.data.user.save();
|
await message.data.user.save();
|
||||||
|
|
||||||
message.replyT("general/afk:DELETED", {
|
message.replyT("general/afk:DELETED", {
|
||||||
|
@ -146,8 +145,6 @@ async function updateXp(message) {
|
||||||
}, { mention: false });
|
}, { mention: false });
|
||||||
} else memberData.exp = parseInt(newXp, 10);
|
} else memberData.exp = parseInt(newXp, 10);
|
||||||
|
|
||||||
memberData.markModified("level");
|
|
||||||
memberData.markModified("exp");
|
|
||||||
await memberData.save();
|
await memberData.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,6 @@ module.exports.init = function (client) {
|
||||||
|
|
||||||
user.reminds = user.reminds.filter(r => r.sendAt >= dateNow);
|
user.reminds = user.reminds.filter(r => r.sendAt >= dateNow);
|
||||||
|
|
||||||
user.markModified("reminds");
|
|
||||||
await user.save();
|
await user.save();
|
||||||
|
|
||||||
if (user.reminds.length === 0) client.databaseCache.usersReminds.delete(user.id);
|
if (user.reminds.length === 0) client.databaseCache.usersReminds.delete(user.id);
|
||||||
|
|
|
@ -30,7 +30,6 @@ module.exports.init = async function (client) {
|
||||||
const index = transactions.indexOf(transaction);
|
const index = transactions.indexOf(transaction);
|
||||||
transactions.splice(index, 1);
|
transactions.splice(index, 1);
|
||||||
|
|
||||||
member.markModified("transactions");
|
|
||||||
await member.save();
|
await member.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,14 +39,13 @@ module.exports.init = async function (client) {
|
||||||
setDaysTimeout(async () => {
|
setDaysTimeout(async () => {
|
||||||
client.usersData.find({}, function (err, res) {
|
client.usersData.find({}, function (err, res) {
|
||||||
for (const user of res) {
|
for (const user of res) {
|
||||||
client.users.fetch(user.id).then(u => {
|
client.users.fetch(user.id).then(async u => {
|
||||||
if (u.username.match(/.*Deleted User.* [A-z0-9]+/g)) {
|
if (u.username.match(/.*Deleted User.* [A-z0-9]+/g)) {
|
||||||
client.databaseCache.users.delete(u.id);
|
client.databaseCache.users.delete(u.id);
|
||||||
client.usersData.deleteOne({ id: u.id });
|
client.usersData.deleteOne({ id: u.id });
|
||||||
client.logger.log(`Removed from database deleted user - ID: ${u.id} Username: ${u.username}`);
|
client.logger.log(`Removed from database deleted user - ID: ${u.id} Username: ${u.username}`);
|
||||||
|
|
||||||
client.usersData.markModified();
|
await client.usersData.save();
|
||||||
client.usersData.save();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -55,14 +53,13 @@ module.exports.init = async function (client) {
|
||||||
|
|
||||||
client.membersData.find({}, function (err, res) {
|
client.membersData.find({}, function (err, res) {
|
||||||
for (const user of res) {
|
for (const user of res) {
|
||||||
client.users.fetch(user.id).then(u => {
|
client.users.fetch(user.id).then(async u => {
|
||||||
if (u.username.match(/.*Deleted User.* [A-z0-9]+/g)) {
|
if (u.username.match(/.*Deleted User.* [A-z0-9]+/g)) {
|
||||||
client.databaseCache.members.delete(u.id);
|
client.databaseCache.members.delete(u.id);
|
||||||
client.membersData.deleteOne({ id: u.id });
|
client.membersData.deleteOne({ id: u.id });
|
||||||
client.logger.log(`Removed from database deleted user - ID: ${u.id} Username: ${u.username}`);
|
client.logger.log(`Removed from database deleted user - ID: ${u.id} Username: ${u.username}`);
|
||||||
|
|
||||||
client.membersData.markModified();
|
await client.membersData.save();
|
||||||
client.membersData.save();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue