mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-11-22 13:14:58 +05:00
remove unused code
This commit is contained in:
parent
f1eca51313
commit
7174722160
13 changed files with 78 additions and 94 deletions
|
@ -156,7 +156,7 @@ class Config extends BaseCommand {
|
||||||
state = interaction.options.getBoolean("state"),
|
state = interaction.options.getBoolean("state"),
|
||||||
channel = interaction.options.getChannel("channel");
|
channel = interaction.options.getChannel("channel");
|
||||||
|
|
||||||
await changeSetting(interaction, setting, state, channel);
|
await changeSetting(interaction, setting, state, channel, data.guildData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -167,13 +167,14 @@ class Config extends BaseCommand {
|
||||||
* @param {String} setting
|
* @param {String} setting
|
||||||
* @param {Boolean} state
|
* @param {Boolean} state
|
||||||
* @param {import("discord.js").GuildTextBasedChannel} channel
|
* @param {import("discord.js").GuildTextBasedChannel} channel
|
||||||
|
* @param {import("../../base/Guild")} guildData
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
async function changeSetting(interaction, setting, state, channel) {
|
async function changeSetting(interaction, setting, state, channel, guildData) {
|
||||||
if (!state) {
|
if (!state) {
|
||||||
interaction.guild.data.plugins[setting] = null;
|
guildData.plugins[setting] = null;
|
||||||
interaction.guild.data.markModified(`plugins.${setting}`);
|
guildData.markModified(`plugins.${setting}`);
|
||||||
await interaction.guild.data.save();
|
await guildData.save();
|
||||||
|
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content: `${interaction.translate(`administration/config:${setting.toUpperCase()}`)}: **${interaction.translate("common:DISABLED")}**`,
|
content: `${interaction.translate(`administration/config:${setting.toUpperCase()}`)}: **${interaction.translate("common:DISABLED")}**`,
|
||||||
|
@ -181,16 +182,16 @@ async function changeSetting(interaction, setting, state, channel) {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (channel) {
|
if (channel) {
|
||||||
interaction.guild.data.plugins[setting] = channel.id;
|
guildData.plugins[setting] = channel.id;
|
||||||
interaction.guild.data.markModified(`plugins.${setting}`);
|
guildData.markModified(`plugins.${setting}`);
|
||||||
await interaction.guild.data.save();
|
await guildData.save();
|
||||||
|
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content: `${interaction.translate(`administration/config:${setting.toUpperCase()}`)}: **${interaction.translate("common:ENABLED")}** (${channel.toString()})`,
|
content: `${interaction.translate(`administration/config:${setting.toUpperCase()}`)}: **${interaction.translate("common:ENABLED")}** (${channel.toString()})`,
|
||||||
ephemeral: true,
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
} else return interaction.reply({
|
} else return interaction.reply({
|
||||||
content: `${interaction.translate(`administration/config:${setting.toUpperCase()}`)}: ${interaction.guild.data.plugins[setting] ? `**${interaction.translate("common:ENABLED")}** (<#${interaction.guild.data.plugins[setting]}>)` : `**${interaction.translate("common:DISABLED")}**`}`,
|
content: `${interaction.translate(`administration/config:${setting.toUpperCase()}`)}: ${guildData.plugins[setting] ? `**${interaction.translate("common:ENABLED")}** (<#${guildData.plugins[setting]}>)` : `**${interaction.translate("common:DISABLED")}**`}`,
|
||||||
ephemeral: true,
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,14 +34,14 @@ class Boosters extends BaseCommand {
|
||||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||||
* @param {Object} data
|
* @param {Object} data
|
||||||
*/
|
*/
|
||||||
async execute(client, interaction) {
|
async execute(client, interaction, data) {
|
||||||
await interaction.deferReply();
|
await interaction.deferReply();
|
||||||
|
|
||||||
let currentPage = 0;
|
let currentPage = 0;
|
||||||
const boosters = (await interaction.guild.members.fetch()).filter(m => m.premiumSince);
|
const boosters = (await interaction.guild.members.fetch()).filter(m => m.premiumSince);
|
||||||
if (boosters.size === 0) return interaction.error("general/boosters:NO_BOOSTERS", null, { edit: true });
|
if (boosters.size === 0) return interaction.error("general/boosters:NO_BOOSTERS", null, { edit: true });
|
||||||
|
|
||||||
const embeds = generateBoostersEmbeds(client, interaction, boosters);
|
const embeds = generateBoostersEmbeds(client, interaction, boosters, data.guildData);
|
||||||
|
|
||||||
const row = new ActionRowBuilder()
|
const row = new ActionRowBuilder()
|
||||||
.addComponents(
|
.addComponents(
|
||||||
|
@ -151,9 +151,10 @@ class Boosters extends BaseCommand {
|
||||||
* @param {import("../../base/JaBa")} client
|
* @param {import("../../base/JaBa")} client
|
||||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||||
* @param {Array} boosters
|
* @param {Array} boosters
|
||||||
|
* @param {import("../../base/Guild")} guildData
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
function generateBoostersEmbeds(client, interaction, boosters) {
|
function generateBoostersEmbeds(client, interaction, boosters, guildData) {
|
||||||
const embeds = [];
|
const embeds = [];
|
||||||
let k = 10;
|
let k = 10;
|
||||||
|
|
||||||
|
@ -162,7 +163,7 @@ function generateBoostersEmbeds(client, interaction, boosters) {
|
||||||
let j = i;
|
let j = i;
|
||||||
k += 10;
|
k += 10;
|
||||||
|
|
||||||
const info = current.map(member => `${++j}. ${member.toString()} | ${interaction.translate("general/boosters:BOOSTER_SINCE")}: **${client.functions.printDate(client, member.premiumSince, null, interaction.guild.data.language)}**`).join("\n");
|
const info = current.map(member => `${++j}. ${member.toString()} | ${interaction.translate("general/boosters:BOOSTER_SINCE")}: **${client.functions.printDate(client, member.premiumSince, null, guildData.language)}**`).join("\n");
|
||||||
|
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setColor(interaction.client.config.embed.color)
|
.setColor(interaction.client.config.embed.color)
|
||||||
|
|
|
@ -71,7 +71,7 @@ class Remindme extends BaseCommand {
|
||||||
|
|
||||||
interaction.success("general/remindme:SAVED", {
|
interaction.success("general/remindme:SAVED", {
|
||||||
message,
|
message,
|
||||||
time: moment(rData.sendAt).locale(interaction.guild.data.language).format("dddd, Do MMMM YYYY, HH:mm:ss"),
|
time: moment(rData.sendAt).locale(data.guildData.language).format("dddd, Do MMMM YYYY, HH:mm:ss"),
|
||||||
}, { edit: true });
|
}, { edit: true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,11 +48,13 @@ class Report extends BaseCommand {
|
||||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||||
* @param {Object} data
|
* @param {Object} data
|
||||||
*/
|
*/
|
||||||
async execute(client, interaction) {
|
async execute(client, interaction, data) {
|
||||||
const repChannel = interaction.guild.channels.cache.get(interaction.guild.data.plugins.reports);
|
const repChannel = interaction.guild.channels.cache.get(data.guildData.plugins.reports);
|
||||||
if (!repChannel) return interaction.error("general/report:MISSING_CHANNEL");
|
if (!repChannel) return interaction.error("general/report:MISSING_CHANNEL");
|
||||||
|
|
||||||
const member = interaction.options.getMember("user");
|
const member = interaction.options.getMember("user");
|
||||||
if (member.id === interaction.user.id) return interaction.error("general/report:INVALID_USER");
|
if (member.id === interaction.user.id) return interaction.error("general/report:INVALID_USER");
|
||||||
|
|
||||||
const rep = interaction.options.getString("message");
|
const rep = interaction.options.getString("message");
|
||||||
|
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
|
|
|
@ -41,9 +41,10 @@ class Suggest extends BaseCommand {
|
||||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||||
* @param {Object} data
|
* @param {Object} data
|
||||||
*/
|
*/
|
||||||
async execute(client, interaction) {
|
async execute(client, interaction, data) {
|
||||||
const suggChannel = interaction.guild.channels.cache.get(interaction.guild.data.plugins.suggestions);
|
const suggChannel = interaction.guild.channels.cache.get(data.guildData.plugins.suggestions);
|
||||||
if (!suggChannel) return interaction.error("general/suggest:MISSING_CHANNEL");
|
if (!suggChannel) return interaction.error("general/suggest:MISSING_CHANNEL");
|
||||||
|
|
||||||
const suggestion = interaction.options.getString("message");
|
const suggestion = interaction.options.getString("message");
|
||||||
|
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
|
|
|
@ -35,7 +35,7 @@ class Nowplaying extends BaseCommand {
|
||||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||||
* @param {Object} data
|
* @param {Object} data
|
||||||
*/
|
*/
|
||||||
async execute(client, interaction) {
|
async execute(client, interaction, data) {
|
||||||
await interaction.deferReply();
|
await interaction.deferReply();
|
||||||
|
|
||||||
const queue = client.player.nodes.get(interaction.guildId);
|
const queue = client.player.nodes.get(interaction.guildId);
|
||||||
|
@ -62,7 +62,7 @@ class Nowplaying extends BaseCommand {
|
||||||
{ name: "\u200B", value: "\u200B", inline: true },
|
{ name: "\u200B", value: "\u200B", inline: true },
|
||||||
{
|
{
|
||||||
name: interaction.translate("common:VIEWS"),
|
name: interaction.translate("common:VIEWS"),
|
||||||
value: track.raw.live ? "" : new Intl.NumberFormat(interaction.client.languages.find(language => language.name === interaction.guild.data.language).moment, { notation: "standard" }).format(track.raw.views),
|
value: track.raw.live ? "" : new Intl.NumberFormat(interaction.client.languages.find(language => language.name === data.guldData.language).moment, { notation: "standard" }).format(track.raw.views),
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,42 +12,32 @@ class CommandHandler extends BaseEvent {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param {import("../base/JaBa")} client
|
* @param {import("../base/JaBa")} client
|
||||||
* @param {import("discord.js").Interaction} interaction
|
* @param {import("discord.js").BaseInteraction} interaction
|
||||||
*/
|
*/
|
||||||
async execute(client, interaction) {
|
async execute(client, interaction) {
|
||||||
const command = client.commands.get(interaction.commandName);
|
const command = client.commands.get(interaction.commandName);
|
||||||
const data = [];
|
const data = [];
|
||||||
|
|
||||||
const userData = await client.findOrCreateUser({
|
const userData = await client.findOrCreateUser({ id: interaction.user.id });
|
||||||
id: interaction.user.id,
|
|
||||||
});
|
|
||||||
data.userData = userData;
|
data.userData = userData;
|
||||||
|
|
||||||
if (interaction.inGuild()) {
|
if (interaction.inGuild()) {
|
||||||
const guildData = await client.findOrCreateGuild({
|
const guildData = await client.findOrCreateGuild({ id: interaction.guildId });
|
||||||
id: interaction.guildId,
|
const memberData = await client.findOrCreateMember({ id: interaction.member.id, guildId: interaction.guildId });
|
||||||
});
|
|
||||||
interaction.guild.data = data.guildData = guildData;
|
|
||||||
|
|
||||||
const memberData = await client.findOrCreateMember({
|
data.guildData = guildData;
|
||||||
id: interaction.member.id,
|
|
||||||
guildId: interaction.guildId,
|
|
||||||
});
|
|
||||||
data.memberData = memberData;
|
data.memberData = memberData;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (interaction.isAutocomplete()) {
|
if (interaction.isAutocomplete())
|
||||||
return await command.autocompleteRun(client, interaction);
|
return await command.autocompleteRun(client, interaction);
|
||||||
}
|
|
||||||
if (interaction.type !== InteractionType.ApplicationCommand && !interaction.isCommand()) return;
|
if (interaction.type !== InteractionType.ApplicationCommand && !interaction.isCommand()) return;
|
||||||
|
|
||||||
if (command.guildOnly && !interaction.inGuild()) return interaction.error("misc:GUILD_ONLY", null, { ephemeral: true });
|
|
||||||
if (command.ownerOnly && interaction.user.id !== client.config.owner.id) return interaction.error("misc:OWNER_ONLY", null, { ephemeral: true });
|
if (command.ownerOnly && interaction.user.id !== client.config.owner.id) return interaction.error("misc:OWNER_ONLY", null, { ephemeral: true });
|
||||||
|
|
||||||
if (!interaction.guildId === "1039187019957555252") return interaction.error({ content: "IAT Only", ephemeral: true }); // IAT
|
if (!interaction.guildId === "1039187019957555252") return interaction.error({ content: "IAT Only", ephemeral: true });
|
||||||
if (!interaction.guildId === "600970971410857996") return interaction.error({ content: "SC Only", ephemeral: true }); // SC
|
if (!interaction.guildId === "600970971410857996") return interaction.error({ content: "SC Only", ephemeral: true });
|
||||||
|
|
||||||
/*
|
|
||||||
if (!userData.achievements.firstCommand.achieved) {
|
if (!userData.achievements.firstCommand.achieved) {
|
||||||
const args = {
|
const args = {
|
||||||
content: interaction.user.toString(),
|
content: interaction.user.toString(),
|
||||||
|
@ -62,9 +52,8 @@ class CommandHandler extends BaseEvent {
|
||||||
userData.markModified("achievements.firstCommand");
|
userData.markModified("achievements.firstCommand");
|
||||||
await userData.save();
|
await userData.save();
|
||||||
|
|
||||||
interaction.channel.isDMBased() ? interaction.user.send(args) : await interaction.channel.send(args);
|
interaction.user.send(args);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
client.logger.log(`User ${interaction.user.discriminator === "0" ? interaction.user.username : interaction.user.tag} 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"}`, "cmd");
|
client.logger.log(`User ${interaction.user.discriminator === "0" ? interaction.user.username : interaction.user.tag} 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"}`, "cmd");
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ class GuildCreate extends BaseEvent {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!userData.achievements.invite.achieved) {
|
if (!userData.achievements.invite.achieved) {
|
||||||
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.invite");
|
userData.markModified("achievements.invite");
|
||||||
await userData.save();
|
await userData.save();
|
||||||
|
@ -28,9 +28,9 @@ class GuildCreate extends BaseEvent {
|
||||||
|
|
||||||
const thanks = new EmbedBuilder()
|
const thanks = new EmbedBuilder()
|
||||||
.setAuthor({
|
.setAuthor({
|
||||||
name: "Спасибо что добавили меня на свой сервер!",
|
name: "Thanks for inviting me to your server!",
|
||||||
})
|
})
|
||||||
.setDescription("Чтобы получить список команд, используйте `/help`!.")
|
.setDescription("Use </help:1029832476077596773> in your server to get list of all commands!.")
|
||||||
.setColor(client.config.embed.color)
|
.setColor(client.config.embed.color)
|
||||||
.setFooter({
|
.setFooter({
|
||||||
text: client.config.embed.footer,
|
text: client.config.embed.footer,
|
||||||
|
|
|
@ -35,20 +35,6 @@ class GuildMemberAdd extends BaseEvent {
|
||||||
const guildData = await client.findOrCreateGuild({
|
const guildData = await client.findOrCreateGuild({
|
||||||
id: member.guild.id,
|
id: member.guild.id,
|
||||||
});
|
});
|
||||||
member.guild.data = guildData;
|
|
||||||
|
|
||||||
const memberData = await client.findOrCreateMember({
|
|
||||||
id: member.id,
|
|
||||||
guildId: member.guild.id,
|
|
||||||
});
|
|
||||||
if (memberData.mute.muted && memberData.mute.endDate > Date.now())
|
|
||||||
member.guild.channels.cache.forEach(channel => {
|
|
||||||
channel.permissionOverwrites.edit(member.id, {
|
|
||||||
SEND_MESSAGES: false,
|
|
||||||
ADD_REACTIONS: false,
|
|
||||||
CONNECT: false,
|
|
||||||
}).catch(() => {});
|
|
||||||
});
|
|
||||||
|
|
||||||
if (guildData.plugins.autorole.enabled) member.roles.add(guildData.plugins.autorole.role);
|
if (guildData.plugins.autorole.enabled) member.roles.add(guildData.plugins.autorole.role);
|
||||||
|
|
||||||
|
@ -95,11 +81,11 @@ class GuildMemberAdd extends BaseEvent {
|
||||||
// Draw server name
|
// Draw server name
|
||||||
ctx.font = applyText(canvas, client.translate("administration/welcome:IMG_WELCOME", {
|
ctx.font = applyText(canvas, client.translate("administration/welcome:IMG_WELCOME", {
|
||||||
server: member.guild.name,
|
server: member.guild.name,
|
||||||
}, member.guild.data.language), 53, 625, "RubikMonoOne");
|
}, guildData.language), 53, 625, "RubikMonoOne");
|
||||||
|
|
||||||
ctx.fillText(client.translate("administration/welcome:IMG_WELCOME", {
|
ctx.fillText(client.translate("administration/welcome:IMG_WELCOME", {
|
||||||
server: member.guild.name,
|
server: member.guild.name,
|
||||||
}, member.guild.data.language), canvas.width - 700, canvas.height - 70);
|
}, guildData.language), canvas.width - 700, canvas.height - 70);
|
||||||
|
|
||||||
// Draw discriminator
|
// Draw discriminator
|
||||||
ctx.font = "35px RubikMonoOne";
|
ctx.font = "35px RubikMonoOne";
|
||||||
|
@ -107,20 +93,20 @@ class GuildMemberAdd extends BaseEvent {
|
||||||
|
|
||||||
// Draw membercount
|
// Draw membercount
|
||||||
ctx.font = "22px RubikMonoOne";
|
ctx.font = "22px RubikMonoOne";
|
||||||
ctx.fillText(`${member.guild.memberCount}й ${client.translate("misc:NOUNS:MEMBERS:1", null, member.guild.data.language)}`, 40, canvas.height - 35);
|
ctx.fillText(`${member.guild.memberCount}й ${client.translate("misc:NOUNS:MEMBERS:1", null, guildData.language)}`, 40, canvas.height - 35);
|
||||||
|
|
||||||
// Draw # for discriminator
|
// Draw # for discriminator
|
||||||
ctx.fillStyle = "#FFFFFF";
|
ctx.fillStyle = "#FFFFFF";
|
||||||
ctx.font = "70px RubikMonoOne";
|
ctx.font = "70px RubikMonoOne";
|
||||||
ctx.fillText("#", canvas.width - 690, canvas.height - 165);
|
ctx.fillText(member.user.discriminator === "0" ? "" : "#", canvas.width - 690, canvas.height - 165);
|
||||||
|
|
||||||
// Draw title
|
// Draw title
|
||||||
ctx.font = "45px RubikMonoOne";
|
ctx.font = "45px RubikMonoOne";
|
||||||
ctx.strokeStyle = "#000000";
|
ctx.strokeStyle = "#000000";
|
||||||
ctx.lineWidth = 10;
|
ctx.lineWidth = 10;
|
||||||
ctx.strokeText(client.translate("administration/welcome:TITLE", null, member.guild.data.language), canvas.width - 670, canvas.height - 330);
|
ctx.strokeText(client.translate("administration/welcome:TITLE", null, guildData.language), canvas.width - 670, canvas.height - 330);
|
||||||
ctx.fillStyle = "#FFFFFF";
|
ctx.fillStyle = "#FFFFFF";
|
||||||
ctx.fillText(client.translate("administration/welcome:TITLE", null, member.guild.data.language), canvas.width - 670, canvas.height - 330);
|
ctx.fillText(client.translate("administration/welcome:TITLE", null, guildData.language), canvas.width - 670, canvas.height - 330);
|
||||||
|
|
||||||
// Draw avatar circle
|
// Draw avatar circle
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
|
|
|
@ -35,7 +35,6 @@ class GuildMemberRemove extends BaseEvent {
|
||||||
const guildData = await client.findOrCreateGuild({
|
const guildData = await client.findOrCreateGuild({
|
||||||
id: member.guild.id,
|
id: member.guild.id,
|
||||||
});
|
});
|
||||||
member.guild.data = guildData;
|
|
||||||
|
|
||||||
if (guildData.plugins.goodbye.enabled) {
|
if (guildData.plugins.goodbye.enabled) {
|
||||||
const channel = member.guild.channels.cache.get(guildData.plugins.goodbye.channel);
|
const channel = member.guild.channels.cache.get(guildData.plugins.goodbye.channel);
|
||||||
|
@ -80,11 +79,11 @@ class GuildMemberRemove extends BaseEvent {
|
||||||
// Draw server name
|
// Draw server name
|
||||||
ctx.font = applyText(canvas, client.translate("administration/goodbye:IMG_GOODBYE", {
|
ctx.font = applyText(canvas, client.translate("administration/goodbye:IMG_GOODBYE", {
|
||||||
server: member.guild.name,
|
server: member.guild.name,
|
||||||
}, member.guild.data.language), 53, 625, "RubikMonoOne");
|
}, guildData.language), 53, 625, "RubikMonoOne");
|
||||||
|
|
||||||
ctx.fillText(client.translate("administration/goodbye:IMG_GOODBYE", {
|
ctx.fillText(client.translate("administration/goodbye:IMG_GOODBYE", {
|
||||||
server: member.guild.name,
|
server: member.guild.name,
|
||||||
}, member.guild.data.language), canvas.width - 700, canvas.height - 70);
|
}, guildData.language), canvas.width - 700, canvas.height - 70);
|
||||||
|
|
||||||
// Draw discriminator
|
// Draw discriminator
|
||||||
ctx.font = "35px RubikMonoOne";
|
ctx.font = "35px RubikMonoOne";
|
||||||
|
@ -92,7 +91,7 @@ class GuildMemberRemove extends BaseEvent {
|
||||||
|
|
||||||
// Draw membercount
|
// Draw membercount
|
||||||
ctx.font = "22px RubikMonoOne";
|
ctx.font = "22px RubikMonoOne";
|
||||||
ctx.fillText(`${member.guild.memberCount} ${client.functions.getNoun(member.guild.memberCount, client.translate("misc:NOUNS:MEMBERS:1", null, member.guild.data.language), client.translate("misc:NOUNS:MEMBERS:2", null, member.guild.data.language), client.translate("misc:NOUNS:MEMBERS:5", null, member.guild.data.language))}`, 40, canvas.height - 35);
|
ctx.fillText(`${member.guild.memberCount} ${client.functions.getNoun(member.guild.memberCount, client.translate("misc:NOUNS:MEMBERS:1", null, guildData.language), client.translate("misc:NOUNS:MEMBERS:2", null, guildData.language), client.translate("misc:NOUNS:MEMBERS:5", null, guildData.language))}`, 40, canvas.height - 35);
|
||||||
|
|
||||||
// Draw # for discriminator
|
// Draw # for discriminator
|
||||||
ctx.fillStyle = "#FFFFFF";
|
ctx.fillStyle = "#FFFFFF";
|
||||||
|
@ -103,9 +102,9 @@ class GuildMemberRemove extends BaseEvent {
|
||||||
ctx.font = "45px RubikMonoOne";
|
ctx.font = "45px RubikMonoOne";
|
||||||
ctx.strokeStyle = "#000000";
|
ctx.strokeStyle = "#000000";
|
||||||
ctx.lineWidth = 10;
|
ctx.lineWidth = 10;
|
||||||
ctx.strokeText(client.translate("administration/goodbye:TITLE", null, member.guild.data.language), canvas.width - 670, canvas.height - 330);
|
ctx.strokeText(client.translate("administration/goodbye:TITLE", null, guildData.language), canvas.width - 670, canvas.height - 330);
|
||||||
ctx.fillStyle = "#FFFFFF";
|
ctx.fillStyle = "#FFFFFF";
|
||||||
ctx.fillText(client.translate("administration/goodbye:TITLE", null, member.guild.data.language), canvas.width - 670, canvas.height - 330);
|
ctx.fillText(client.translate("administration/goodbye:TITLE", null, guildData.language), canvas.width - 670, canvas.height - 330);
|
||||||
|
|
||||||
// Draw avatar circle
|
// Draw avatar circle
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
|
|
|
@ -17,12 +17,13 @@ class GuildMemberUpdate extends BaseEvent {
|
||||||
async execute(client, oldMember, newMember) {
|
async execute(client, oldMember, newMember) {
|
||||||
if (oldMember.guild && oldMember.guild.id === "568120814776614924") return;
|
if (oldMember.guild && oldMember.guild.id === "568120814776614924") return;
|
||||||
if (oldMember.guild.id !== client.config.support.id) return;
|
if (oldMember.guild.id !== client.config.support.id) return;
|
||||||
if (oldMember.roles.cache.some(r => r.name === "Поддержавшие JaBa")) return;
|
if (oldMember.roles.cache.some(r => r.id === "940149470975365191")) return;
|
||||||
|
|
||||||
if (newMember?.roles.cache.some(r => r.name === "Поддержавшие JaBa")) {
|
if (newMember?.roles.cache.some(r => r.id === "940149470975365191")) {
|
||||||
const userData = await client.findOrCreateUser({
|
const userData = await client.findOrCreateUser({
|
||||||
id: newMember.id,
|
id: newMember.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
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.tip");
|
userData.markModified("achievements.tip");
|
||||||
|
|
|
@ -20,30 +20,26 @@ class MessageCreate extends BaseEvent {
|
||||||
if (message.guild && message.guild.id === "568120814776614924") return;
|
if (message.guild && message.guild.id === "568120814776614924") return;
|
||||||
|
|
||||||
const data = {};
|
const data = {};
|
||||||
|
|
||||||
if (message.author.bot) return;
|
if (message.author.bot) return;
|
||||||
|
|
||||||
|
const userData = await client.findOrCreateUser({ id: message.author.id });
|
||||||
|
data.userData = userData;
|
||||||
|
|
||||||
if (message.guild && !message.member) await message.guild.members.fetch(message.author.id);
|
if (message.guild && !message.member) await message.guild.members.fetch(message.author.id);
|
||||||
if (message.guild) {
|
if (message.guild) {
|
||||||
const guild = await client.findOrCreateGuild({
|
const guild = await client.findOrCreateGuild({ id: message.guild.id });
|
||||||
id: message.guild.id,
|
data.guildData = guild;
|
||||||
});
|
|
||||||
message.guild.data = data.guildData = guild;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.content.match(new RegExp(`^<@!?${client.user.id}>( |)$`))) return message.replyT("misc:HELLO_SERVER", null, { mention: true });
|
if (message.content.match(new RegExp(`^<@!?${client.user.id}>( |)$`))) return message.replyT("misc:HELLO_SERVER", null, { mention: true });
|
||||||
if (message.guild) {
|
if (message.guild) {
|
||||||
const memberData = await client.findOrCreateMember({
|
const memberData = await client.findOrCreateMember({ id: message.author.id, guildId: message.guild.id });
|
||||||
id: message.author.id,
|
|
||||||
guildId: message.guild.id,
|
|
||||||
});
|
|
||||||
data.memberData = memberData;
|
data.memberData = memberData;
|
||||||
}
|
}
|
||||||
|
|
||||||
const userData = await client.findOrCreateUser({
|
|
||||||
id: message.author.id,
|
|
||||||
});
|
|
||||||
data.userData = userData;
|
|
||||||
|
|
||||||
if (message.guild) {
|
if (message.guild) {
|
||||||
await updateXp(client, message, data);
|
await updateXp(client, message, data.memberData);
|
||||||
|
|
||||||
if (message.content.includes("discord.com/channels/")) {
|
if (message.content.includes("discord.com/channels/")) {
|
||||||
const link = message.content.match(/(https|http):\/\/(ptb\.|canary\.)?(discord.com)\/(channels)\/\d+\/\d+\/\d+/g)[0],
|
const link = message.content.match(/(https|http):\/\/(ptb\.|canary\.)?(discord.com)\/(channels)\/\d+\/\d+\/\d+/g)[0],
|
||||||
|
@ -133,12 +129,12 @@ class MessageCreate extends BaseEvent {
|
||||||
*
|
*
|
||||||
* @param {import("../base/JaBa")} client
|
* @param {import("../base/JaBa")} client
|
||||||
* @param {import("discord.js").Message} msg
|
* @param {import("discord.js").Message} msg
|
||||||
* @param {*} data
|
* @param {import("../base/Member")} memberData
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
async function updateXp(client, msg, data) {
|
async function updateXp(client, msg, memberData) {
|
||||||
const points = parseInt(data.memberData.exp),
|
const points = parseInt(memberData.exp),
|
||||||
level = parseInt(data.memberData.level),
|
level = parseInt(memberData.level),
|
||||||
isInCooldown = xpCooldown[msg.author.id];
|
isInCooldown = xpCooldown[msg.author.id];
|
||||||
|
|
||||||
if (isInCooldown)
|
if (isInCooldown)
|
||||||
|
@ -152,14 +148,14 @@ async function updateXp(client, msg, data) {
|
||||||
const neededXp = 5 * (level * level) + 80 * level + 100;
|
const neededXp = 5 * (level * level) + 80 * level + 100;
|
||||||
|
|
||||||
if (newXp > neededXp) {
|
if (newXp > neededXp) {
|
||||||
data.memberData.level = parseInt(level + 1, 10);
|
memberData.level = parseInt(level + 1, 10);
|
||||||
data.memberData.exp = 0;
|
memberData.exp = 0;
|
||||||
msg.replyT("misc:LEVEL_UP", {
|
msg.replyT("misc:LEVEL_UP", {
|
||||||
level: data.memberData.level,
|
level: memberData.level,
|
||||||
}, { mention: false });
|
}, { mention: false });
|
||||||
} else data.memberData.exp = parseInt(newXp, 10);
|
} else memberData.exp = parseInt(newXp, 10);
|
||||||
|
|
||||||
await data.memberData.save();
|
await memberData.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = MessageCreate;
|
module.exports = MessageCreate;
|
|
@ -14,6 +14,7 @@ const config = require("../config");
|
||||||
const dbName = config.mongoDB.split("/").pop();
|
const dbName = config.mongoDB.split("/").pop();
|
||||||
const baseURL = config.mongoDB.substr(0, config.mongoDB.length - dbName.length);
|
const baseURL = config.mongoDB.substr(0, config.mongoDB.length - dbName.length);
|
||||||
const client = new MongoClient(baseURL, {
|
const client = new MongoClient(baseURL, {
|
||||||
|
useNewUrlParser: true,
|
||||||
useUnifiedTopology: true,
|
useUnifiedTopology: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -26,22 +27,28 @@ client.connect().then(async () => {
|
||||||
const users = db.collection("users");
|
const users = db.collection("users");
|
||||||
|
|
||||||
console.log(chalk.yellow("Creating guilds index..."));
|
console.log(chalk.yellow("Creating guilds index..."));
|
||||||
|
|
||||||
await guilds.createIndex({
|
await guilds.createIndex({
|
||||||
id: 1,
|
id: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(chalk.green("Guilds index created."));
|
console.log(chalk.green("Guilds index created."));
|
||||||
|
|
||||||
console.log(chalk.yellow("Creating members index..."));
|
console.log(chalk.yellow("Creating members index..."));
|
||||||
|
|
||||||
await members.createIndex({
|
await members.createIndex({
|
||||||
guildID: 1,
|
guildID: 1,
|
||||||
id: -1,
|
id: -1,
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(chalk.green("Members index created."));
|
console.log(chalk.green("Members index created."));
|
||||||
|
|
||||||
console.log(chalk.yellow("Creating users index..."));
|
console.log(chalk.yellow("Creating users index..."));
|
||||||
|
|
||||||
await users.createIndex({
|
await users.createIndex({
|
||||||
id: 1,
|
id: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(chalk.green("Users index created."));
|
console.log(chalk.green("Users index created."));
|
||||||
|
|
||||||
console.log(chalk.blue("\n\nIndexes created."));
|
console.log(chalk.blue("\n\nIndexes created."));
|
||||||
|
@ -49,5 +56,6 @@ client.connect().then(async () => {
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
console.log(chalk.red("Couldn't connect to mongoDB database..."));
|
console.log(chalk.red("Couldn't connect to mongoDB database..."));
|
||||||
|
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
});
|
});
|
Loading…
Reference in a new issue