diff --git a/src/commands/dailymsg.js b/src/commands/dailymsg.js index 50068783..ebff776b 100644 --- a/src/commands/dailymsg.js +++ b/src/commands/dailymsg.js @@ -99,7 +99,7 @@ module.exports = { ), /** * @param {CommandInteraction} interaction - * @param {Client} client + * @param {WouldYou} client * @param {guildModel} guildDb */ async execute(interaction, client, guildDb) { @@ -110,11 +110,11 @@ module.exports = { ) { switch (interaction.options.getSubcommand()) { case 'message': { - if (guildDb.dailyMsg && interaction.options.getString("message") === "true") return await interaction.reply({ + if (guildDb.dailyMsg && interaction.options.getString("message") === "true") return interaction.reply({ ephemeral: true, content: `${Daily.embed.alreadytrue}` }) - if (!guildDb.dailyMsg && interaction.options.getString("message") === "false") return await interaction.reply({ + if (!guildDb.dailyMsg && interaction.options.getString("message") === "false") return interaction.reply({ ephemeral: true, content: `${Daily.embed.alreadyfalse}` }) @@ -135,11 +135,11 @@ module.exports = { case 'types': { const types = interaction.options.getString("types") === "true" ? true : false; - if (guildDb.dailyRather && types) return await interaction.reply({ + if (guildDb.dailyRather && types) return interaction.reply({ ephemeral: true, content: `${Daily.embed.alreadytrue}` }) - if (!guildDb.dailyRather && !types) return await interaction.reply({ + if (!guildDb.dailyRather && !types) return interaction.reply({ ephemeral: true, content: `${Daily.embed.alreadyfalse}` }) @@ -161,19 +161,27 @@ module.exports = { case 'channel': { const channel = interaction.options.getChannel("channel"); - if (!channel?.permissionsFor(client?.user?.id)?.has([PermissionFlagsBits.ViewChannel])) return await interaction.reply({ + if (!channel?.permissionsFor(client?.user?.id)?.has([PermissionFlagsBits.ViewChannel])) return interaction.reply({ ephemeral: true, content: Daily.errorChannel.viewChannel }) - if (!channel?.permissionsFor(client?.user?.id)?.has([PermissionFlagsBits.SendMessages])) return await interaction.reply({ + if (!channel?.permissionsFor(client?.user?.id)?.has([PermissionFlagsBits.SendMessages])) return interaction.reply({ ephemeral: true, content: Daily.errorChannel.sendMessages }) - if (guildDb.dailyChannel && guildDb.dailyChannel === channel.id) return await interaction.reply({ + if (!channel?.permissionsFor(client?.user?.id)?.has([PermissionFlagsBits.ManageWebhooks])) return interaction.reply({ + ephemeral: true, + content: Daily.errorChannel.manageWebhooks + }) + if (guildDb.dailyChannel && guildDb.dailyChannel === channel.id) return interaction.reply({ ephemeral: true, content: Daily.errorChannel.alreadySet }) + await client.webhookHandler.sendWebhook(channel, channel.id, { + content: '<:roundyou:1009964111045607525> This channel will be used to send daily Would You messages.' + }) + await client.database.updateGuild(interaction.guildId, { dailyChannel: channel.id, }, true) @@ -191,7 +199,7 @@ module.exports = { case 'role': { const role = interaction.options.getRole("role"); - if (guildDb.dailyRole && guildDb.dailyRole === role.id) return await interaction.reply({ + if (guildDb.dailyRole && guildDb.dailyRole === role.id) return interaction.reply({ ephemeral: true, content: Daily.errorRole }) @@ -215,15 +223,15 @@ module.exports = { const userInput = interaction.options.getString("timezone"); const lowerCaseUserInput = userInput.toLowerCase(); - if (guildDb.dailyTimezone.toLowerCase() === lowerCaseUserInput) return await interaction.reply({ + if (guildDb.dailyTimezone.toLowerCase() === lowerCaseUserInput) return interaction.reply({ ephemeral: true, content: Daily.timezone.errorSame }) - if (!isValid(lowerCaseUserInput)) return await interaction.reply({ + if (!isValid(lowerCaseUserInput)) return interaction.reply({ ephemeral: true, content: Daily.timezone.errorInvalid }) - if (!dateType(lowerCaseUserInput)) return await interaction.reply({ + if (!dateType(lowerCaseUserInput)) return interaction.reply({ ephemeral: true, content: Daily.timezone.errorInvalid }) diff --git a/src/events/guildCreate.js b/src/events/guildCreate.js index 8426be17..1f3c6099 100644 --- a/src/events/guildCreate.js +++ b/src/events/guildCreate.js @@ -1,27 +1,44 @@ -const { WebhookClient, EmbedBuilder } = require('discord.js'); +const {WebhookClient, EmbedBuilder} = require('discord.js'); require('dotenv').config(); module.exports = async (client, guild) => { - if (!guild?.name) return; + if (!guild?.name) return; - // Create and save the settings in the cache so that we don't need to do that at a command run - await client.database.getGuild(guild?.id, true); + // Create and save the settings in the cache so that we don't need to do that at a command run + await client.database.getGuild(guild?.id, true); - const webhookClient = new WebhookClient({ url: process.env.WEBHOOK }); - const webhookPrivate = new WebhookClient({ url: process.env.WEBHOOKPRIVATE }); + const webhookPrivate = new WebhookClient({url: process.env.WEBHOOKPRIVATE}); - let features; - if (guild.features && guild.features.includes("VERIFIED") || guild.features.includes("PARTNERED")) { - features = guild.features.includes("VERIFIED") ? `<:verified_green:1072265950134550548>` : `<:partner:1072265822577360982>` - } + let features; + if (guild.features && guild.features.includes("VERIFIED") || guild.features.includes("PARTNERED")) { + features = guild.features.includes("VERIFIED") ? `<:verified_green:1072265950134550548>` : `<:partner:1072265822577360982>` + } - webhookPrivate.send({ - embeds: [new EmbedBuilder().setTitle(`→ Joined Server`).setColor(`#0598F4`).setThumbnail(guild.iconURL({ format: 'png', dynamic: true })).setDescription(`**Name**: ${guild.name.replace("Discord", "").replace("discord", "").replace("Everyone", "").replace("everyone", "")}\n**Users**: ${guild.memberCount.toLocaleString()}${features ? `\n**Features**: ${features}` : ``}`)] - }) + await webhookPrivate.send({ + avatarURL: 'https://wouldyoubot.gg/static/img/round.webp', // Make sure to update this if you ever change the link thx <3 + username: global?.devBot ? 'Dev Bot' : 'Main Bot', + embeds: [ + new EmbedBuilder() + .setTitle(`→ Joined Server`) + .setColor(`#0598F4`) + .setThumbnail(guild.iconURL({ + format: 'png', + dynamic: true + })) + .setDescription(`**Name**: ${guild.name.replace("Discord", "").replace("discord", "").replace("Everyone", "").replace("everyone", "")}\n**Users**: ${guild.memberCount.toLocaleString()}${features ? `\n**Features**: ${features}` : ``}`) + .setFooter({ + text: global?.devBot ? 'Dev Bot' : 'Main Bot', + }) + ] + }) - webhookClient.send({ - content: `<:GoodCheck:1025490645525209148> Joined ${guild.name.replace("Discord", "").replace("discord", "").replace("Everyone", "").replace("everyone", "")}. I'm now in ${client.guilds.cache.size} guilds.`, - username: `${guild.name.replace("Discord", "").replace("discord", "").replace("Everyone", "").replace("everyone", "")}`, - avatarURL: guild.iconURL({ format: 'webp', dynamic: true, size: 1024 }), - }).catch((err) => console.log(err)); + if (!global?.devBot) { + const webhookClient = new WebhookClient({url: process.env.WEBHOOK}); + + await webhookClient.send({ + content: `<:GoodCheck:1025490645525209148> Joined ${guild.name.replace("Discord", "").replace("discord", "").replace("Everyone", "").replace("everyone", "")}. I'm now in ${client.guilds.cache.size} guilds.`, + username: `${guild.name.replace("Discord", "").replace("discord", "").replace("Everyone", "").replace("everyone", "")}`, + avatarURL: guild.iconURL({format: 'webp', dynamic: true, size: 1024}), + }).catch((err) => console.log(err)); + } }; diff --git a/src/events/guildDelete.js b/src/events/guildDelete.js index 62fb1c72..91fc9b76 100644 --- a/src/events/guildDelete.js +++ b/src/events/guildDelete.js @@ -1,27 +1,44 @@ -const { WebhookClient, EmbedBuilder } = require('discord.js'); +const {WebhookClient, EmbedBuilder} = require('discord.js'); require('dotenv').config(); module.exports = async (client, guild) => { - if(!guild?.name) return; + if (!guild?.name) return; - // Only delete the guild settings from the cache we don't want a data lose but also don't need not used data in the cache :) - await client.database.deleteGuild(guild?.id, true); + // Only delete the guild settings from the cache we don't want a data lose but also don't need not used data in the cache :) + await client.database.deleteGuild(guild?.id, true); - const webhookClient = new WebhookClient({ url: process.env.WEBHOOK }); - const webhookPrivate = new WebhookClient({ url: process.env.WEBHOOKPRIVATE }); + const webhookPrivate = new WebhookClient({url: process.env.WEBHOOKPRIVATE}); - let features; - if (guild.features && guild.features.includes("VERIFIED") || guild.features.includes("PARTNERED")) { - features = guild.features.includes("VERIFIED") ? `<:verified_green:1072265950134550548>` : `<:partner:1072265822577360982>`; - }; + let features; + if (guild.features && guild.features.includes("VERIFIED") || guild.features.includes("PARTNERED")) { + features = guild.features.includes("VERIFIED") ? `<:verified_green:1072265950134550548>` : `<:partner:1072265822577360982>`; + } - webhookPrivate.send({ - embeds: [new EmbedBuilder().setTitle(`← Left Server`).setColor(`#0598F4`).setThumbnail(guild.iconURL({ format: 'png', dynamic: true })).setDescription(`**Name**: ${guild.name.replace("Discord", "").replace("discord", "").replace("Everyone", "").replace("everyone", "")}\n**Users**: ${guild.memberCount.toLocaleString()}${features ? `\n**Features**: ${features}` : ``}`)] - }); + await webhookPrivate.send({ + avatarURL: 'https://wouldyoubot.gg/static/img/round.webp', // Make sure to update this if you ever change the link thx <3 + username: global?.devBot ? 'Dev Bot' : 'Main Bot', + embeds: [ + new EmbedBuilder() + .setTitle(`← Left Server`) + .setColor(`#0598F4`) + .setThumbnail(guild.iconURL({ + format: 'png', + dynamic: true + })) + .setDescription(`**Name**: ${guild.name.replace("Discord", "").replace("discord", "").replace("Everyone", "").replace("everyone", "")}\n**Users**: ${guild.memberCount.toLocaleString()}${features ? `\n**Features**: ${features}` : ``}`) + .setFooter({ + text: global?.devBot ? 'Dev Bot' : 'Main Bot', + }) + ] + }); - webhookClient.send({ - content: `<:BadCheck:1025490660968628436> Left ${guild.name.replace("Discord", "").replace("discord", "").replace("Everyone", "").replace("everyone", "")}. I'm now in ${client.guilds.cache.size} guilds.`, - username: `${guild.name.replace("Discord", "").replace("discord", "").replace("Everyone", "").replace("everyone", "")}`, - avatarURL: guild.iconURL({ format: 'webp', dynamic: true, size: 1024 }), - }).catch((err) => console.log(err)); + if (!global?.devBot) { + const webhookClient = new WebhookClient({url: process.env.WEBHOOK}); + + await webhookClient.send({ + content: `<:BadCheck:1025490660968628436> Left ${guild.name.replace("Discord", "").replace("discord", "").replace("Everyone", "").replace("everyone", "")}. I'm now in ${client.guilds.cache.size} guilds.`, + username: `${guild.name.replace("Discord", "").replace("discord", "").replace("Everyone", "").replace("everyone", "")}`, + avatarURL: guild.iconURL({format: 'webp', dynamic: true, size: 1024}), + }).catch((err) => console.log(err)); + } }; diff --git a/src/index.js b/src/index.js index 2265d0f9..0c30b18b 100644 --- a/src/index.js +++ b/src/index.js @@ -1,6 +1,24 @@ const WouldYou = require('./util/wouldYou'); const {ChalkAdvanced} = require("chalk-advanced"); +// Token to UserID Function +// Credits to Meister#9667 for helping me with this +const retriveUserIdbyToken = (token) => { + const parseuser = (token.split('.'))[0] + const buff = Buffer.from(parseuser, 'base64'); + const userid = buff.toString('utf-8'); + return userid; +} + +global.devBot = false; + +const botId = retriveUserIdbyToken(process.env.DISCORD_TOKEN); +if(botId !== '981649513427111957' || process.env.STATUS === 'DEVELOPMENT') { + global.devBot = true; +} else if(process.env.STATUS === 'DEVELOPMENT' && botId === '981649513427111957') { + throw new Error('Are you stupid? Why should you run the main bot with status "DEVELOPMENT"?!'); +} + const client = new WouldYou(); client.loginBot().then(() => { console.log( diff --git a/src/languages/de_DE.json b/src/languages/de_DE.json index fed1beed..1c901be7 100644 --- a/src/languages/de_DE.json +++ b/src/languages/de_DE.json @@ -196,6 +196,7 @@ "errorChannel": { "viewChannel": "Der angegebene Kanal erlaubt es mir nicht, ihn zu sehen. Bitte wähle einen Kanal, auf den ich Zugriff habe.", "sendMessages": "Der angegebene Kanal erlaubt es mir nicht nachrichten zu senden. Bitte wähle einen Kanal, auf den ich Zugriff habe.", + "manageWebhooks": "Der angegebene Kanal erlaubt es mir nicht Webhooks zu erstellen. Bitte wähle einen Kanal, in dem ich Webhooks erstellen kann.", "alreadySet": "Der angegebene Kanal ist derselbe, der bereits gesetzt ist. Stelle sicher, dass du einen anderen Kanal wählen." }, "success": { diff --git a/src/languages/en_EN.json b/src/languages/en_EN.json index 1341d550..7bbfd126 100644 --- a/src/languages/en_EN.json +++ b/src/languages/en_EN.json @@ -226,6 +226,7 @@ "errorChannel": { "viewChannel": "The channel provided doesn't allow me to view it. Select a channel which I have access to.", "sendMessages": "The channel provided doesn't allow me to send messages to it. Select a channel which I have access to.", + "manageWebhooks": "The channel provided doesn't allow me to create webhooks inside of it. Select a channel which I can create webhooks.", "alreadySet": "The provided channel is the same channel that is already set. Make sure to choose a different channel." }, "success": { diff --git a/src/languages/es_ES.json b/src/languages/es_ES.json index ed0268c1..01fc5053 100644 --- a/src/languages/es_ES.json +++ b/src/languages/es_ES.json @@ -226,6 +226,7 @@ "errorChannel": { "viewChannel": "No tengo permiso para ver ese canal. Selecciona un canal al que tenga acceso.", "sendMessages": "No tengo permiso para enviar mensajes a ese canal. Selecciona un canal al que tenga acceso.", + "manageWebhooks": "El canal proporcionado no me permite crear webhooks dentro de él. Seleccione un canal en el que pueda crear webhooks.", "alreadySet": "El canal proporcionado es el mismo canal que ya está configurado. Asegúrate de elegir un canal diferente." }, "success": { diff --git a/src/util/Models/guildModel.js b/src/util/Models/guildModel.js index 1d57a365..3a61b12a 100644 --- a/src/util/Models/guildModel.js +++ b/src/util/Models/guildModel.js @@ -36,10 +36,6 @@ const guildProfile = new Schema( type: String, default: "America/Chicago" }, - dailyDay: { - type: Number, - default: 0, - }, replay: { type: Boolean, default: true, diff --git a/src/util/dailyMessage.js b/src/util/dailyMessage.js index ce2de8d4..193f2da3 100644 --- a/src/util/dailyMessage.js +++ b/src/util/dailyMessage.js @@ -1,5 +1,6 @@ const {EmbedBuilder} = require('discord.js'); const mom = require("moment-timezone"); +const {ChalkAdvanced} = require("chalk-advanced"); const CronJob = require('cron').CronJob; module.exports = class DailyMessage { @@ -21,24 +22,21 @@ module.exports = class DailyMessage { * @return {Promise} */ async runSchedule() { - const today = new Date(); let guilds = await this.c.database.getAll(); - guilds = guilds.filter(g => this.c.guilds.cache.has(g.guildID) && g.dailyMsg && Number(g.dailyDay) !== today.getDay()); + guilds = guilds.filter(g => this.c.guilds.cache.has(g.guildID) && g.dailyMsg); + + console.log( + `${ChalkAdvanced.white('Daily Message')} ${ChalkAdvanced.gray( + '>', + )} ${ChalkAdvanced.green('Running daily message check for ' + guilds.length + ' guilds')}`, + ); let i = 0; for (const db of guilds) { i++; setTimeout(async () => { if (!db.dailyMsg) return; - if (!isNaN(db.dailyDay)) { - if (db.dailyDay === new Date().getDay()) return; - } - if (mom.tz(db.dailyTimezone).format("HH:mm") === "12:00") { - await this.c.database.updateGuild(db.guildID, { - dailyDay: today.getDay() - }, false) - const channel = await this.c.channels.fetch(db.dailyChannel).catch(err => { }); diff --git a/src/util/keepAlive.js b/src/util/keepAlive.js index 65c8a762..0380ff2b 100644 --- a/src/util/keepAlive.js +++ b/src/util/keepAlive.js @@ -7,6 +7,7 @@ const { } = require('discord.js'); const {inspect} = require('util'); +const {ChalkAdvanced} = require("chalk-advanced"); const warnWebhook = new WebhookClient({ url: process.env.WARNWEBHOOKURL, @@ -20,20 +21,64 @@ module.exports = class KeepAlive { this.c = client; } + /** + * Log a message to the console + * @param type + * @param msg + * @param _optionalData + * @private + */ + consoleError(type, msg, _optionalData = '') { + console.log( + `${ChalkAdvanced.white(type)} ${ChalkAdvanced.gray( + '>', + )} ${ChalkAdvanced.red(msg)}`, + _optionalData, + ); + } + /** * Start the keep alive system (listener to the process) */ start() { + this.c.ws.on('rateLimit', (log) => { + const { path, limit, timeout } = log; + + this.consoleError('RateLimit', 'We got rate-limited at', `Path: ${path} Limit: ${limit} Timeout: ${timeout}`); + const embed = new EmbedBuilder() + .setTitle('Rate limited') + .setColor(global?.devBot ? "#e407f5" : "#6e0000") + .addFields([{ + name: 'Rate-limit Info', + value: `Path: \`${path}\`\nLimit: \`${limit}\`\nTimeout: \`${timeout}\``, + }]) + .setFooter({ + text: global?.devBot ? 'Dev Bot' : 'Main Bot', + }) + .setTimestamp(); + + warnWebhook + .send({ + embeds: [embed], + }) + .catch((err) => { + }); + }) + this.c.on('debug', (e) => { if (!e.includes('ratelimit')) return; - console.log('[BOT] Watch-out Possible Rate-limit...\n', e); + this.consoleError('Debug', 'Watch-out Possible Rate-limit...', e); const embed = new EmbedBuilder() .setTitle('Watch-out Possible Rate-limit...') + .setColor(global?.devBot ? "#e407f5" : "#F00505") .addFields([{ name: 'Info', value: `\`\`\`${inspect(e, {depth: 0})}\`\`\``, }]) + .setFooter({ + text: global?.devBot ? 'Dev Bot' : 'Main Bot', + }) .setTimestamp(); warnWebhook @@ -45,17 +90,22 @@ module.exports = class KeepAlive { }); this.c.on('error', (e) => { - console.log('[BOT] Bot got a error...\n\n', e); + this.consoleError('Error', 'Bot got a error...', e); const embed = new EmbedBuilder() .setTitle('Bot got a error...') + .setColor(global?.devBot ? "#e407f5" : "#05b1f0") .addFields([{ name: 'Error', value: `\`\`\`${inspect(e, {depth: 0})}\`\`\``, }]) + .setFooter({ + text: global?.devBot ? 'Dev Bot' : 'Main Bot', + }) .setTimestamp(); errorWebhook .send({ + username: global?.devBot ? 'Dev Bot' : 'Main Bot', embeds: [embed], }) .catch((err) => { @@ -63,17 +113,22 @@ module.exports = class KeepAlive { }); this.c.on('warn', async (info) => { - console.log('[BOT] Bot got a warn...\n\n', info); + this.consoleError('Error', 'Bot got a warn...', info); const embed = new EmbedBuilder() .setTitle('Bot got a warn...') + .setColor(global?.devBot ? "#e407f5" : "#05b1f0") .addFields([{ name: 'Info', value: `\`\`\`${inspect(info, {depth: 0})}\`\`\``, }]) + .setFooter({ + text: global?.devBot ? 'Dev Bot' : 'Main Bot', + }) .setTimestamp(); warnWebhook .send({ + username: global?.devBot ? 'Dev Bot' : 'Main Bot', embeds: [embed], }) .catch((err) => { @@ -81,13 +136,13 @@ module.exports = class KeepAlive { }); process.on('unhandledRejection', async (reason, p) => { - console.log('[BOT | FATAL ERROR] Unhandled Rejection/Catch'); + this.consoleError('Fatal Error', 'Unhandled Rejection/Catch'); console.log(reason, p); const embed = new EmbedBuilder() .setTitle('New Unhandled Rejection/Catch') .setDescription(`\`\`\`${reason}\`\`\``) - .setColor('#4E5D94') + .setColor(global?.devBot ? "#e407f5" : "#F00505") .addFields([ { name: 'Reason', @@ -98,10 +153,14 @@ module.exports = class KeepAlive { value: `\`\`\`${inspect(p, {depth: 0})}\`\`\``, }, ]) + .setFooter({ + text: global?.devBot ? 'Dev Bot' : 'Main Bot', + }) .setTimestamp(); errorWebhook .send({ + username: global?.devBot ? 'Dev Bot' : 'Main Bot', embeds: [embed], }) .catch((err) => { @@ -109,13 +168,13 @@ module.exports = class KeepAlive { }); process.on('uncaughtException', async (err, origin) => { - console.log('[BOT | FATAL ERROR] Uncaught Exception/Catch'); + this.consoleError('Fatal Error', 'Uncaught Exception/Catch'); console.log(err, origin); const embed = new EmbedBuilder() .setTitle('New uncaughtException') .setDescription(`\`\`\`${err}\`\`\``) - .setColor('#4E5D94') + .setColor(global?.devBot ? "#e407f5" : "#F00505") .addFields([ { name: 'Error', @@ -126,23 +185,27 @@ module.exports = class KeepAlive { value: `\`\`\`${inspect(origin, {depth: 0})}\`\`\``, }, ]) + .setFooter({ + text: global?.devBot ? 'Dev Bot' : 'Main Bot', + }) .setTimestamp(); errorWebhook .send({ + username: global?.devBot ? 'Dev Bot' : 'Main Bot', embeds: [embed], }) .catch((err) => { }); }); process.on('uncaughtExceptionMonitor', async (err, origin) => { - console.log('[BOT | FATAL ERROR] Uncaught Exception/Catch (MONITOR)'); + this.consoleError('Fatal Error', 'Uncaught Exception/Catch (MONITOR)'); console.log(err, origin); const embed = new EmbedBuilder() .setTitle('New uncaughtExceptionMonitor' + `${global?.CustomBot ? ' (Custom Bot)' : ''}`) .setDescription(`\`\`\`${err}\`\`\``) - .setColor('#4E5D94') + .setColor(global?.devBot ? "#e407f5" : "#F00505") .addFields([ { name: 'Error', @@ -153,10 +216,14 @@ module.exports = class KeepAlive { value: `\`\`\`${inspect(origin, {depth: 0})}\`\`\``, }, ]) + .setFooter({ + text: global?.devBot ? 'Dev Bot' : 'Main Bot', + }) .setTimestamp(); errorWebhook .send({ + username: global?.devBot ? 'Dev Bot' : 'Main Bot', embeds: [embed], }) .catch((err) => { diff --git a/src/util/translationHandler.js b/src/util/translationHandler.js index 019c8530..e859ed19 100644 --- a/src/util/translationHandler.js +++ b/src/util/translationHandler.js @@ -98,9 +98,28 @@ module.exports = class TranslationHandler { * @example * const translation = getTranslation('en_EN', 'commands.ping.pong', {ping: 100}); */ - get(language, path, data) { + get(language, path, data = {}) { const l = this.getLanguage(language); - const c = l[path]; + const p = path.split('.'); + let c = null; + + if(p.length > 0) { + for (const i of p) { + try { + if(!c) { + if (!l[i]) break; + c = l[i]; + } else { + if (!c[i]) break; + c = c[i]; + } + } catch(err) { + break; + } + } + } else { + return path; + } if (!c) return path; diff --git a/src/util/webhookHandler.js b/src/util/webhookHandler.js index 9e793992..14350be9 100644 --- a/src/util/webhookHandler.js +++ b/src/util/webhookHandler.js @@ -132,18 +132,22 @@ module.exports = class WebhookHandler { return this.webhookFallBack(channel, channelId, message, false); }); } else { - if (channel?.permissionsFor(this.c?.user?.id).has([PermissionFlagsBits.ManageWebhooks])) { + if (channel?.permissionsFor(this.c?.user?.id).has([PermissionFlagsBits.EmbedLinks])) { + const guildSettings = await this.c.database.getGuild(channel.guild.id); + message.embeds = message?.embeds ?? []; message.embeds.unshift( new EmbedBuilder() .setColor('#FE0001') - .setDescription('🛑 ' + this.c.translation(channel.data?.language, 'webhookManager.noWebhook')) + .setDescription('🛑 ' + this.c.translation.get(guildSettings?.language ?? 'en_EN', 'webhookManager.noWebhook')) ); return channel .send(message) .catch(err => { + console.log(err); + console.log(message); }); } }