mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-11-21 12:44:58 +05:00
rename findOrCreate*Something* functions to get*Something*Data
This commit is contained in:
parent
f296eca51a
commit
6e73e504a5
33 changed files with 89 additions and 89 deletions
|
@ -304,11 +304,11 @@ class JaBaClient extends Client {
|
|||
}
|
||||
|
||||
/**
|
||||
* Finds or creates a user in the database based on the provided user ID.
|
||||
* Returns a User data from the database.
|
||||
* @param {string} userID - The ID of the user to find or create.
|
||||
* @returns {Promise<import("./User")>} The user data object, either retrieved from the database or newly created.
|
||||
*/
|
||||
async findOrCreateUser(userID) {
|
||||
async getUserData(userID) {
|
||||
let userData = await this.usersData.findOne({ id: userID });
|
||||
|
||||
if (userData) {
|
||||
|
@ -327,12 +327,12 @@ class JaBaClient extends Client {
|
|||
}
|
||||
|
||||
/**
|
||||
* Finds or creates a member in the database based on the provided member ID and guild ID.
|
||||
* Returns a Member data from the database.
|
||||
* @param {string} memberId - The ID of the member to find or create.
|
||||
* @param {string} 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.
|
||||
*/
|
||||
async findOrCreateMember(memberId, guildId) {
|
||||
async getMemberData(memberId, guildId) {
|
||||
let memberData = await this.membersData.findOne({ guildID: guildId, id: memberId });
|
||||
|
||||
if (memberData) {
|
||||
|
@ -344,7 +344,7 @@ class JaBaClient extends Client {
|
|||
|
||||
await memberData.save();
|
||||
|
||||
const guildData = await this.findOrCreateGuild(guildId);
|
||||
const guildData = await this.getGuildData(guildId);
|
||||
|
||||
if (guildData) {
|
||||
guildData.members.push(memberData._id);
|
||||
|
@ -359,11 +359,11 @@ class JaBaClient extends Client {
|
|||
}
|
||||
|
||||
/**
|
||||
* Finds or creates a guild in the database based on the provided guild ID.
|
||||
* Returns a Guild data from the database.
|
||||
* @param {string} guildId - The ID of the guild to find or create.
|
||||
* @returns {Promise<import("./Guild")>} The guild data object, either retrieved from the database or newly created.
|
||||
*/
|
||||
async findOrCreateGuild(guildId) {
|
||||
async getGuildData(guildId) {
|
||||
let guildData = await this.guildsData.findOne({ id: guildId }).populate("members");
|
||||
|
||||
if (guildData) {
|
||||
|
|
|
@ -33,7 +33,7 @@ class Memes extends BaseCommand {
|
|||
if (interaction.customId === "memes_select") {
|
||||
interaction.deferUpdate();
|
||||
|
||||
interaction.guild.data = await client.findOrCreateGuild(interaction.guildId);
|
||||
interaction.guild.data = await client.getGuildData(interaction.guildId);
|
||||
|
||||
const tag = interaction.values[0];
|
||||
const res = await fetch(`https://meme-api.com/gimme/${tag}`).then(response => response.json());
|
||||
|
|
|
@ -90,7 +90,7 @@ class Selectroles extends BaseCommand {
|
|||
|
||||
if (interaction.customId === "auto_roles") {
|
||||
interaction.data = [];
|
||||
interaction.data.guild = await client.findOrCreateGuild(interaction.guildId);
|
||||
interaction.data.guild = await client.getGuildData(interaction.guildId);
|
||||
|
||||
const removed = interaction.component.options.filter(option => {
|
||||
return !interaction.values.includes(option.value);
|
||||
|
|
|
@ -68,7 +68,7 @@ class Set extends BaseCommand {
|
|||
member = interaction.options.getMember("user");
|
||||
if (member.user.bot) return interaction.error("misc:BOT_USER", null, { ephemeral: true });
|
||||
|
||||
const memberData = await client.findOrCreateMember(member.id, interaction.guildId);
|
||||
const memberData = await client.getMemberData(member.id, interaction.guildId);
|
||||
|
||||
const int = interaction.options.getInteger("int");
|
||||
if (int < 0) return interaction.error("administration/set:INVALID_NUMBER", null, { ephemeral: true });
|
||||
|
|
|
@ -39,7 +39,7 @@ class Achievements extends BaseCommand {
|
|||
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 ? interaction.data.user : await client.findOrCreateUser(user.id);
|
||||
const userData = user.id === interaction.user.id ? interaction.data.user : await client.getUserData(user.id);
|
||||
|
||||
const embed = client.embed({
|
||||
author: {
|
||||
|
|
|
@ -36,7 +36,7 @@ class Divorce extends BaseCommand {
|
|||
|
||||
await userData.save();
|
||||
|
||||
const oldLover = await client.findOrCreateUser(user.id);
|
||||
const oldLover = await client.getUserData(user.id);
|
||||
oldLover.lover = null;
|
||||
|
||||
await oldLover.save();
|
||||
|
|
|
@ -46,7 +46,7 @@ class Marry extends BaseCommand {
|
|||
if (member.user.bot) return interaction.error("economy/marry:BOT_USER");
|
||||
if (member.id === interaction.member.id) return interaction.error("economy/marry:YOURSELF");
|
||||
|
||||
const otherUserData = await client.findOrCreateUser(member.id);
|
||||
const otherUserData = await client.getUserData(member.id);
|
||||
if (otherUserData.lover) return interaction.error("economy/marry:ALREADY_MARRIED_USER", { user: member.toString() });
|
||||
|
||||
for (const requester in pendings) {
|
||||
|
|
|
@ -41,13 +41,13 @@ class Money extends BaseCommand {
|
|||
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 ? interaction.data.member : await client.findOrCreateMember(member.id, interaction.guildId);
|
||||
const memberData = member.id === interaction.user.id ? interaction.data.member : await client.getMemberData(member.id, 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(member.id, guild.id);
|
||||
const data = await client.getMemberData(member.id, guild.id);
|
||||
globalMoney += data.money + data.bankSold;
|
||||
});
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ 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"))}`,
|
||||
});
|
||||
|
||||
const otherMemberData = await client.findOrCreateMember(otherMember.id, interaction.guildId);
|
||||
const otherMemberData = await client.getMemberData(otherMember.id, interaction.guildId);
|
||||
|
||||
memberData.money -= amount;
|
||||
otherMemberData.money += amount;
|
||||
|
|
|
@ -41,14 +41,14 @@ class Profile extends BaseCommand {
|
|||
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 ? 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 memberData = member.id === interaction.user.id ? interaction.data.member : await client.getMemberData(member.id, interaction.guildId);
|
||||
const userData = member.id === interaction.user.id ? interaction.data.user : await client.getUserData(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));
|
||||
let globalMoney = 0;
|
||||
await client.functions.asyncForEach(guilds, async guild => {
|
||||
const data = await client.findOrCreateMember(member.id, guild.id);
|
||||
const data = await client.getMemberData(member.id, guild.id);
|
||||
globalMoney += data.money + data.bankSold;
|
||||
});
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ class Rep extends BaseCommand {
|
|||
|
||||
userData.cooldowns.rep = toWait;
|
||||
|
||||
const otherUserData = await client.findOrCreateUser(user.id);
|
||||
const otherUserData = await client.getUserData(user.id);
|
||||
|
||||
otherUserData.rep++;
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ class Rob extends BaseCommand {
|
|||
const amount = interaction.options.getInteger("amount");
|
||||
if (amount <= 0) return interaction.error("misc:MORE_THAN_ZERO");
|
||||
|
||||
const otherMemberData = await client.findOrCreateMember(otherMember.id, interaction.guildId);
|
||||
const otherMemberData = await client.getMemberData(otherMember.id, interaction.guildId);
|
||||
if (amount > otherMemberData.money) return interaction.error("economy/rob:NOT_ENOUGH_MEMBER", { user: otherMember.toString() });
|
||||
|
||||
const isInCooldown = otherMemberData.cooldowns.rob || 0;
|
||||
|
|
|
@ -80,7 +80,7 @@ class Number extends BaseCommand {
|
|||
}),
|
||||
});
|
||||
|
||||
const memberData = await client.findOrCreateMember(msg.author.id, interaction.guildId);
|
||||
const memberData = await client.getMemberData(msg.author.id, interaction.guildId);
|
||||
|
||||
memberData.money += won;
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ class TicTacToe extends BaseCommand {
|
|||
embedColor: client.config.embed.color,
|
||||
embedFoot: client.config.embed.footer,
|
||||
}).then(async winner => {
|
||||
const memberData = await client.findOrCreateMember(winner.id, interaction.guildId);
|
||||
const memberData = await client.getMemberData(winner.id, interaction.guildId);
|
||||
|
||||
memberData.money += 100;
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ class Boosters extends BaseCommand {
|
|||
|
||||
if (interaction.customId.startsWith("boosters_")) {
|
||||
interaction.data = [];
|
||||
interaction.data.guild = await client.findOrCreateGuild(interaction.guildId);
|
||||
interaction.data.guild = await client.getGuildData(interaction.guildId);
|
||||
|
||||
const boosters = (await interaction.guild.members.fetch()).filter(m => m.premiumSince),
|
||||
embeds = generateBoostersEmbeds(interaction, boosters);
|
||||
|
|
|
@ -43,7 +43,7 @@ class Help extends BaseCommand {
|
|||
await interaction.deferUpdate();
|
||||
|
||||
interaction.data = [];
|
||||
interaction.data.guild = await client.findOrCreateGuild(interaction.guildId);
|
||||
interaction.data.guild = await client.getGuildData(interaction.guildId);
|
||||
|
||||
const arg = interaction?.values[0];
|
||||
const categoryCommands = [...new Map(client.commands.map(v => [v.constructor.name, v])).values()]
|
||||
|
|
|
@ -31,8 +31,8 @@ class Reminds extends BaseCommand {
|
|||
|
||||
if (interaction.customId.startsWith("reminds_")) {
|
||||
interaction.data = [];
|
||||
interaction.data.guild = await client.findOrCreateGuild(interaction.guildId);
|
||||
interaction.data.user = await client.findOrCreateUser(interaction.user.id);
|
||||
interaction.data.guild = await client.getGuildData(interaction.guildId);
|
||||
interaction.data.user = await client.getUserData(interaction.user.id);
|
||||
|
||||
const reminds = interaction.data.user.reminds,
|
||||
embeds = generateRemindsEmbeds(interaction, reminds);
|
||||
|
|
|
@ -40,7 +40,7 @@ class Clearwarns extends BaseCommand {
|
|||
async execute(client, interaction) {
|
||||
const member = interaction.options.getMember("user");
|
||||
|
||||
const memberData = await client.findOrCreateMember(member.id, interaction.guildId);
|
||||
const memberData = await client.getMemberData(member.id, interaction.guildId);
|
||||
|
||||
memberData.sanctions = [];
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ class WarnContext extends BaseCommand {
|
|||
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 });
|
||||
|
||||
const memberData = await client.findOrCreateMember(member.id, interaction.guildId);
|
||||
const memberData = await client.getMemberData(member.id, interaction.guildId);
|
||||
|
||||
const modal = new ModalBuilder()
|
||||
.setCustomId("warn_modal")
|
||||
|
|
|
@ -41,7 +41,7 @@ class Warns extends BaseCommand {
|
|||
const member = interaction.options.getMember("user");
|
||||
if (member.user.bot) return interaction.error("misc:BOT_USER");
|
||||
|
||||
const memberData = await client.findOrCreateMember(member.id, interaction.guildId);
|
||||
const memberData = await client.getMemberData(member.id, interaction.guildId);
|
||||
|
||||
const embed = client.embed({
|
||||
author: {
|
||||
|
|
|
@ -31,7 +31,7 @@ class Nowplaying extends BaseCommand {
|
|||
if (!interaction.isButton()) return;
|
||||
|
||||
if (interaction.customId.startsWith("nowp_")) {
|
||||
const locale = (await client.findOrCreateGuild(interaction.guildId)).language;
|
||||
const locale = (await client.getGuildData(interaction.guildId)).language;
|
||||
|
||||
const voice = interaction.member.voice.channel;
|
||||
if (!voice) return interaction.error("music/play:NO_VOICE_CHANNEL", null, { locale });
|
||||
|
|
|
@ -30,7 +30,7 @@ class Queue extends BaseCommand {
|
|||
if (!interaction.isButton()) return;
|
||||
|
||||
if (interaction.customId.startsWith("queue_")) {
|
||||
const locale = (await client.findOrCreateGuild(interaction.guildId)).language;
|
||||
const locale = (await client.getGuildData(interaction.guildId)).language;
|
||||
|
||||
const queue = client.player.nodes.get(interaction.guildId);
|
||||
if (!queue) return interaction.error("music/play:NOT_PLAYING", null, locale);
|
||||
|
|
|
@ -34,7 +34,7 @@ class NSFW extends BaseCommand {
|
|||
await interaction.deferUpdate();
|
||||
|
||||
interaction.data = [];
|
||||
interaction.data.guild = await client.findOrCreateGuild(interaction.guildId);
|
||||
interaction.data.guild = await client.getGuildData(interaction.guildId);
|
||||
|
||||
const tag = interaction?.values[0],
|
||||
splitted = tag.split("_"),
|
||||
|
|
|
@ -128,8 +128,8 @@ class Debug extends BaseCommand {
|
|||
const member = interaction.options.getMember("user");
|
||||
if (member.user.bot) return interaction.error("misc:BOT_USER", null, { ephemeral: true });
|
||||
|
||||
const userData = await client.findOrCreateUser(member.id),
|
||||
memberData = await client.findOrCreateMember(member.id, interaction.guildId);
|
||||
const userData = await client.getUserData(member.id),
|
||||
memberData = await client.getMemberData(member.id, interaction.guildId);
|
||||
|
||||
switch (type) {
|
||||
case "level": {
|
||||
|
@ -194,8 +194,8 @@ class Debug extends BaseCommand {
|
|||
const member = interaction.options.getMember("target");
|
||||
if (member.user.bot) return interaction.error("misc:BOT_USER", null, { ephemeral: true });
|
||||
|
||||
const userData = await client.findOrCreateUser(member.id),
|
||||
memberData = await client.findOrCreateMember(member.id, interaction.guildId);
|
||||
const userData = await client.getUserData(member.id),
|
||||
memberData = await client.getMemberData(member.id, interaction.guildId);
|
||||
|
||||
switch (type) {
|
||||
case "level": {
|
||||
|
|
|
@ -31,7 +31,7 @@ class CreateTicketEmbed extends BaseCommand {
|
|||
if (!interaction.isButton()) return;
|
||||
|
||||
interaction.data = [];
|
||||
interaction.data.guild = await client.findOrCreateGuild(interaction.guildId);
|
||||
interaction.data.guild = await client.getGuildData(interaction.guildId);
|
||||
|
||||
const guildData = interaction.data.guild,
|
||||
ticketsCategory = guildData.plugins?.tickets?.ticketsCategory,
|
||||
|
|
|
@ -20,12 +20,12 @@ module.exports = client => [
|
|||
Ukrainian: "uk-UA",
|
||||
}),
|
||||
getActualSet: async ({ guild }) => {
|
||||
const guildData = await client.findOrCreateGuild(guild.id);
|
||||
const guildData = await client.getGuildData(guild.id);
|
||||
|
||||
return guildData.language;
|
||||
},
|
||||
setNew: async ({ guild, newData }) => {
|
||||
const guildData = await client.findOrCreateGuild(guild.id);
|
||||
const guildData = await client.getGuildData(guild.id);
|
||||
|
||||
guildData.language = newData;
|
||||
|
||||
|
@ -45,12 +45,12 @@ module.exports = client => [
|
|||
optionDescription: "Toggle welcome messages sending",
|
||||
optionType: DBD.formTypes.switch(),
|
||||
getActualSet: async ({ guild }) => {
|
||||
const guildData = await client.findOrCreateGuild(guild.id);
|
||||
const guildData = await client.getGuildData(guild.id);
|
||||
|
||||
return guildData.plugins.welcome.enabled;
|
||||
},
|
||||
setNew: async ({ guild, newData }) => {
|
||||
const guildData = await client.findOrCreateGuild(guild.id);
|
||||
const guildData = await client.getGuildData(guild.id);
|
||||
|
||||
guildData.plugins.welcome.enabled = newData;
|
||||
|
||||
|
@ -65,12 +65,12 @@ module.exports = client => [
|
|||
optionDescription: "Toggle sending an image with welcome message",
|
||||
optionType: DBD.formTypes.switch(),
|
||||
getActualSet: async ({ guild }) => {
|
||||
const guildData = await client.findOrCreateGuild(guild.id);
|
||||
const guildData = await client.getGuildData(guild.id);
|
||||
|
||||
return guildData.plugins.welcome.withImage;
|
||||
},
|
||||
setNew: async ({ guild, newData }) => {
|
||||
const guildData = await client.findOrCreateGuild(guild.id);
|
||||
const guildData = await client.getGuildData(guild.id);
|
||||
|
||||
guildData.plugins.welcome.withImage = newData;
|
||||
|
||||
|
@ -85,12 +85,12 @@ module.exports = client => [
|
|||
optionDescription: "Change welcome message (You can use {user}, {server} and {membercount} wildcards)",
|
||||
optionType: DBD.formTypes.input("Welcome, {user}!", 2, 100, false, false),
|
||||
getActualSet: async ({ guild }) => {
|
||||
const guildData = await client.findOrCreateGuild(guild.id);
|
||||
const guildData = await client.getGuildData(guild.id);
|
||||
|
||||
return guildData.plugins.welcome.message;
|
||||
},
|
||||
setNew: async ({ guild, newData }) => {
|
||||
const guildData = await client.findOrCreateGuild(guild.id);
|
||||
const guildData = await client.getGuildData(guild.id);
|
||||
|
||||
guildData.plugins.welcome.message = newData !== "" ? newData : null;
|
||||
|
||||
|
@ -105,12 +105,12 @@ module.exports = client => [
|
|||
optionDescription: "Select a channel for welcome messages",
|
||||
optionType: DBD.formTypes.channelsSelect(false, [ChannelType.GuildText]),
|
||||
getActualSet: async ({ guild }) => {
|
||||
const guildData = await client.findOrCreateGuild(guild.id);
|
||||
const guildData = await client.getGuildData(guild.id);
|
||||
|
||||
return guildData.plugins.welcome.channel;
|
||||
},
|
||||
setNew: async ({ guild, newData }) => {
|
||||
const guildData = await client.findOrCreateGuild(guild.id);
|
||||
const guildData = await client.getGuildData(guild.id);
|
||||
|
||||
guildData.plugins.welcome.channel = newData !== "" ? newData : null;
|
||||
|
||||
|
@ -132,12 +132,12 @@ module.exports = client => [
|
|||
optionDescription: "Toggle goodbye messages sending",
|
||||
optionType: DBD.formTypes.switch(),
|
||||
getActualSet: async ({ guild }) => {
|
||||
const guildData = await client.findOrCreateGuild(guild.id);
|
||||
const guildData = await client.getGuildData(guild.id);
|
||||
|
||||
return guildData.plugins.goodbye.enabled;
|
||||
},
|
||||
setNew: async ({ guild, newData }) => {
|
||||
const guildData = await client.findOrCreateGuild(guild.id);
|
||||
const guildData = await client.getGuildData(guild.id);
|
||||
|
||||
guildData.plugins.goodbye.enabled = newData;
|
||||
|
||||
|
@ -152,12 +152,12 @@ module.exports = client => [
|
|||
optionDescription: "Toggle sending an image with goodbye message",
|
||||
optionType: DBD.formTypes.switch(),
|
||||
getActualSet: async ({ guild }) => {
|
||||
const guildData = await client.findOrCreateGuild(guild.id);
|
||||
const guildData = await client.getGuildData(guild.id);
|
||||
|
||||
return guildData.plugins.goodbye.withImage;
|
||||
},
|
||||
setNew: async ({ guild, newData }) => {
|
||||
const guildData = await client.findOrCreateGuild(guild.id);
|
||||
const guildData = await client.getGuildData(guild.id);
|
||||
|
||||
guildData.plugins.goodbye.withImage = newData;
|
||||
|
||||
|
@ -172,12 +172,12 @@ module.exports = client => [
|
|||
optionDescription: "Change goodbye message (You can use {user}, {server} and {membercount} wildcards)",
|
||||
optionType: DBD.formTypes.input("goodbye, {user}!", 2, 100, false, false),
|
||||
getActualSet: async ({ guild }) => {
|
||||
const guildData = await client.findOrCreateGuild(guild.id);
|
||||
const guildData = await client.getGuildData(guild.id);
|
||||
|
||||
return guildData.plugins.goodbye.message;
|
||||
},
|
||||
setNew: async ({ guild, newData }) => {
|
||||
const guildData = await client.findOrCreateGuild(guild.id);
|
||||
const guildData = await client.getGuildData(guild.id);
|
||||
|
||||
guildData.plugins.goodbye.message = newData !== "" ? newData : null;
|
||||
|
||||
|
@ -192,12 +192,12 @@ module.exports = client => [
|
|||
optionDescription: "Select a channel for goodbye messages",
|
||||
optionType: DBD.formTypes.channelsSelect(false, [ChannelType.GuildText]),
|
||||
getActualSet: async ({ guild }) => {
|
||||
const guildData = await client.findOrCreateGuild(guild.id);
|
||||
const guildData = await client.getGuildData(guild.id);
|
||||
|
||||
return guildData.plugins.goodbye.channel;
|
||||
},
|
||||
setNew: async ({ guild, newData }) => {
|
||||
const guildData = await client.findOrCreateGuild(guild.id);
|
||||
const guildData = await client.getGuildData(guild.id);
|
||||
|
||||
guildData.plugins.goodbye.channel = newData !== "" ? newData : null;
|
||||
|
||||
|
@ -219,12 +219,12 @@ module.exports = client => [
|
|||
optionDescription: "Toggle auto role granting for new members",
|
||||
optionType: DBD.formTypes.switch(),
|
||||
getActualSet: async ({ guild }) => {
|
||||
const guildData = await client.findOrCreateGuild(guild.id);
|
||||
const guildData = await client.getGuildData(guild.id);
|
||||
|
||||
return guildData.plugins.autorole.enabled;
|
||||
},
|
||||
setNew: async ({ guild, newData }) => {
|
||||
const guildData = await client.findOrCreateGuild(guild.id);
|
||||
const guildData = await client.getGuildData(guild.id);
|
||||
|
||||
guildData.plugins.autorole.enabled = newData;
|
||||
|
||||
|
@ -239,12 +239,12 @@ module.exports = client => [
|
|||
optionDescription: "Select a role for auto role. Select \"-\" to disable",
|
||||
optionType: DBD.formTypes.rolesSelect(false, false, true),
|
||||
getActualSet: async ({ guild }) => {
|
||||
const guildData = await client.findOrCreateGuild(guild.id);
|
||||
const guildData = await client.getGuildData(guild.id);
|
||||
|
||||
return guildData.plugins.autorole.role;
|
||||
},
|
||||
setNew: async ({ guild, newData }) => {
|
||||
const guildData = await client.findOrCreateGuild(guild.id);
|
||||
const guildData = await client.getGuildData(guild.id);
|
||||
|
||||
guildData.plugins.autorole.role = newData !== "" ? newData : null;
|
||||
|
||||
|
@ -266,12 +266,12 @@ module.exports = client => [
|
|||
optionDescription: "Toggle auto mod. It will remove invite links from non-moderators",
|
||||
optionType: DBD.formTypes.switch(),
|
||||
getActualSet: async ({ guild }) => {
|
||||
const guildData = await client.findOrCreateGuild(guild.id);
|
||||
const guildData = await client.getGuildData(guild.id);
|
||||
|
||||
return guildData.plugins.automod.enabled;
|
||||
},
|
||||
setNew: async ({ guild, newData }) => {
|
||||
const guildData = await client.findOrCreateGuild(guild.id);
|
||||
const guildData = await client.getGuildData(guild.id);
|
||||
|
||||
guildData.plugins.automod.enabled = newData;
|
||||
|
||||
|
@ -286,12 +286,12 @@ module.exports = client => [
|
|||
optionDescription: "Select a channels for auto mod to ignore",
|
||||
optionType: DBD.formTypes.channelsMultiSelect(false, false, [ChannelType.GuildText]),
|
||||
getActualSet: async ({ guild }) => {
|
||||
const guildData = await client.findOrCreateGuild(guild.id);
|
||||
const guildData = await client.getGuildData(guild.id);
|
||||
|
||||
return guildData.plugins.automod.ignored;
|
||||
},
|
||||
setNew: async ({ guild, newData }) => {
|
||||
const guildData = await client.findOrCreateGuild(guild.id);
|
||||
const guildData = await client.getGuildData(guild.id);
|
||||
|
||||
guildData.plugins.automod.ignored = newData;
|
||||
|
||||
|
@ -313,12 +313,12 @@ module.exports = client => [
|
|||
optionDescription: "Select a channel for messages update logs to go to. Select \"-\" to disable",
|
||||
optionType: DBD.formTypes.channelsSelect(false, [ChannelType.GuildText]),
|
||||
getActualSet: async ({ guild }) => {
|
||||
const guildData = await client.findOrCreateGuild(guild.id);
|
||||
const guildData = await client.getGuildData(guild.id);
|
||||
|
||||
return guildData.plugins?.monitoring?.messageUpdate;
|
||||
},
|
||||
setNew: async ({ guild, newData }) => {
|
||||
const guildData = await client.findOrCreateGuild(guild.id);
|
||||
const guildData = await client.getGuildData(guild.id);
|
||||
|
||||
if (guildData.plugins.monitoring === undefined) guildData.plugins.monitoring = {};
|
||||
|
||||
|
@ -335,12 +335,12 @@ module.exports = client => [
|
|||
optionDescription: "Select a channel for messages deletion logs to go to. Select \"-\" to disable",
|
||||
optionType: DBD.formTypes.channelsSelect(false, [ChannelType.GuildText]),
|
||||
getActualSet: async ({ guild }) => {
|
||||
const guildData = await client.findOrCreateGuild(guild.id);
|
||||
const guildData = await client.getGuildData(guild.id);
|
||||
|
||||
return guildData.plugins?.monitoring?.messageDelete;
|
||||
},
|
||||
setNew: async ({ guild, newData }) => {
|
||||
const guildData = await client.findOrCreateGuild(guild.id);
|
||||
const guildData = await client.getGuildData(guild.id);
|
||||
|
||||
if (guildData.plugins.monitoring === undefined) guildData.plugins.monitoring = {};
|
||||
|
||||
|
@ -364,12 +364,12 @@ module.exports = client => [
|
|||
optionDescription: "Select a channel for suggestions to go to",
|
||||
optionType: DBD.formTypes.channelsSelect(false, [ChannelType.GuildText]),
|
||||
getActualSet: async ({ guild }) => {
|
||||
const guildData = await client.findOrCreateGuild(guild.id);
|
||||
const guildData = await client.getGuildData(guild.id);
|
||||
|
||||
return guildData.plugins.suggestions;
|
||||
},
|
||||
setNew: async ({ guild, newData }) => {
|
||||
const guildData = await client.findOrCreateGuild(guild.id);
|
||||
const guildData = await client.getGuildData(guild.id);
|
||||
|
||||
guildData.plugins.suggestions = newData !== "" ? newData : null;
|
||||
|
||||
|
@ -384,12 +384,12 @@ module.exports = client => [
|
|||
optionDescription: "Select a channel for reports to go to. Select \"-\" to disable",
|
||||
optionType: DBD.formTypes.channelsSelect(false, [ChannelType.GuildText]),
|
||||
getActualSet: async ({ guild }) => {
|
||||
const guildData = await client.findOrCreateGuild(guild.id);
|
||||
const guildData = await client.getGuildData(guild.id);
|
||||
|
||||
return guildData.plugins.reports;
|
||||
},
|
||||
setNew: async ({ guild, newData }) => {
|
||||
const guildData = await client.findOrCreateGuild(guild.id);
|
||||
const guildData = await client.getGuildData(guild.id);
|
||||
|
||||
guildData.plugins.reports = newData !== "" ? newData : null;
|
||||
|
||||
|
@ -404,12 +404,12 @@ module.exports = client => [
|
|||
optionDescription: "Select a channel for birthdays message to go to. Select \"-\" to disable",
|
||||
optionType: DBD.formTypes.channelsSelect(false, [ChannelType.GuildText]),
|
||||
getActualSet: async ({ guild }) => {
|
||||
const guildData = await client.findOrCreateGuild(guild.id);
|
||||
const guildData = await client.getGuildData(guild.id);
|
||||
|
||||
return guildData.plugins.birthdays;
|
||||
},
|
||||
setNew: async ({ guild, newData }) => {
|
||||
const guildData = await client.findOrCreateGuild(guild.id);
|
||||
const guildData = await client.getGuildData(guild.id);
|
||||
|
||||
guildData.plugins.birthdays = newData !== "" ? newData : null;
|
||||
|
||||
|
@ -424,12 +424,12 @@ module.exports = client => [
|
|||
optionDescription: "Select a channel for moderation logs to go to (warns). Select \"-\" to disable",
|
||||
optionType: DBD.formTypes.channelsSelect(false, [ChannelType.GuildText]),
|
||||
getActualSet: async ({ guild }) => {
|
||||
const guildData = await client.findOrCreateGuild(guild.id);
|
||||
const guildData = await client.getGuildData(guild.id);
|
||||
|
||||
return guildData.plugins.modlogs;
|
||||
},
|
||||
setNew: async ({ guild, newData }) => {
|
||||
const guildData = await client.findOrCreateGuild(guild.id);
|
||||
const guildData = await client.getGuildData(guild.id);
|
||||
|
||||
guildData.plugins.modlogs = newData !== "" ? newData : null;
|
||||
|
||||
|
|
|
@ -19,11 +19,11 @@ class CommandHandler extends BaseEvent {
|
|||
|
||||
const data = [];
|
||||
|
||||
data.user = await client.findOrCreateUser(interaction.user.id);
|
||||
data.user = await client.getUserData(interaction.user.id);
|
||||
|
||||
if (interaction.inGuild()) {
|
||||
data.guild = await client.findOrCreateGuild(interaction.guildId);
|
||||
data.member = await client.findOrCreateMember(interaction.member.id, interaction.guildId);
|
||||
data.guild = await client.getGuildData(interaction.guildId);
|
||||
data.member = await client.getMemberData(interaction.member.id, interaction.guildId);
|
||||
}
|
||||
|
||||
interaction.data = data;
|
||||
|
|
|
@ -14,7 +14,7 @@ class GuildCreate extends BaseEvent {
|
|||
* @param {import("discord.js").Guild} guild
|
||||
*/
|
||||
async execute(client, guild) {
|
||||
const userData = await client.findOrCreateUser(guild.ownerId);
|
||||
const userData = await client.getUserData(guild.ownerId);
|
||||
|
||||
if (!userData.achievements.invite.achieved) {
|
||||
userData.achievements.invite.progress.now = 1;
|
||||
|
|
|
@ -32,7 +32,7 @@ class GuildMemberAdd extends BaseEvent {
|
|||
|
||||
await member.guild.members.fetch();
|
||||
|
||||
const guildData = await client.findOrCreateGuild(member.guild.id);
|
||||
const guildData = await client.getGuildData(member.guild.id);
|
||||
|
||||
if (guildData.plugins.autorole.enabled) member.roles.add(guildData.plugins.autorole.role);
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ class GuildMemberRemove extends BaseEvent {
|
|||
|
||||
await member.guild.members.fetch();
|
||||
|
||||
const guildData = await client.findOrCreateGuild(member.guild.id);
|
||||
const guildData = await client.getGuildData(member.guild.id);
|
||||
|
||||
if (guildData.plugins.goodbye.enabled) {
|
||||
const channel = member.guild.channels.cache.get(guildData.plugins.goodbye.channel);
|
||||
|
|
|
@ -20,7 +20,7 @@ class GuildMemberUpdate extends BaseEvent {
|
|||
if (oldMember.roles.cache.some(r => r.id === "940149470975365191")) return;
|
||||
|
||||
if (newMember?.roles.cache.some(r => r.id === "940149470975365191")) {
|
||||
const userData = await client.findOrCreateUser(newMember.id);
|
||||
const userData = await client.getUserData(newMember.id);
|
||||
|
||||
userData.achievements.tip.progress.now = 1;
|
||||
userData.achievements.tip.achieved = true;
|
||||
|
|
|
@ -24,13 +24,13 @@ class MessageCreate extends BaseEvent {
|
|||
if (message.author.bot) return;
|
||||
if (message.content.match(new RegExp(`^<@!?${client.user.id}>( |)$`))) return message.replyT("misc:HELLO_SERVER", null, { mention: true });
|
||||
|
||||
data.user = await client.findOrCreateUser(message.author.id);
|
||||
data.user = await client.getUserData(message.author.id);
|
||||
|
||||
if (message.guild) {
|
||||
if (!message.member) await message.guild.members.fetch(message.author.id);
|
||||
|
||||
data.guild = await client.findOrCreateGuild(message.guildId);
|
||||
data.member = await client.findOrCreateMember(message.author.id, message.guildId);
|
||||
data.guild = await client.getGuildData(message.guildId);
|
||||
data.member = await client.getMemberData(message.author.id, message.guildId);
|
||||
}
|
||||
|
||||
message.data = data;
|
||||
|
@ -106,7 +106,7 @@ class MessageCreate extends BaseEvent {
|
|||
}
|
||||
|
||||
message.mentions.users.forEach(async u => {
|
||||
const userData = await client.findOrCreateUser(u.id);
|
||||
const userData = await client.getUserData(u.id);
|
||||
|
||||
if (userData.afk) message.replyT("general/afk:IS_AFK", { user: u.getUsername(), reason: userData.afk }, { ephemeral: true });
|
||||
});
|
||||
|
|
|
@ -7,7 +7,7 @@ const { CronJob } = require("cron");
|
|||
module.exports.init = async client => {
|
||||
const cronjob = new CronJob("0 5 * * *", async function () {
|
||||
client.guilds.cache.forEach(async guild => {
|
||||
const guildData = await client.findOrCreateGuild(guild.id);
|
||||
const guildData = await client.getGuildData(guild.id);
|
||||
const channel = guildData.plugins.birthdays ? client.channels.cache.get(guildData.plugins.birthdays) || (await client.channels.fetch(guildData.plugins.birthdays)) : null;
|
||||
|
||||
if (guildData.plugins.birthdays && client.channels.cache.get(guildData.plugins.birthdays)) {
|
||||
|
@ -69,7 +69,7 @@ module.exports.init = async client => {
|
|||
*/
|
||||
module.exports.run = async client => {
|
||||
client.guilds.cache.forEach(async guild => {
|
||||
const guildData = await client.findOrCreateGuild(guild.id);
|
||||
const guildData = await client.getGuildData(guild.id);
|
||||
const channel = guildData.plugins.birthdays ? client.channels.cache.get(guildData.plugins.birthdays) || (await client.channels.fetch(guildData.plugins.birthdays)) : null;
|
||||
|
||||
if (guildData.plugins.birthdays) {
|
||||
|
|
Loading…
Reference in a new issue