From 88e0ef6825dbdde57a0f2fe04c2b100678e70531 Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Wed, 2 Mar 2022 19:08:31 +0200 Subject: [PATCH] misc fixes --- src/structure/client/EventHooker.js | 9 ++++++--- src/structure/client/wrappers/GuildWrapper.js | 4 ++++ src/structure/client/wrappers/InteractionWrapper.js | 2 +- src/structure/components/settings/logging/Messages.js | 6 +++--- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/structure/client/EventHooker.js b/src/structure/client/EventHooker.js index f3e2546..7c9db07 100644 --- a/src/structure/client/EventHooker.js +++ b/src/structure/client/EventHooker.js @@ -1,5 +1,5 @@ const { EventEmitter } = require('events'); -const { InteractionWrapper } = require('./wrappers'); +const { InteractionWrapper, GuildWrapper } = require('./wrappers'); class EventHooker { @@ -35,10 +35,13 @@ class EventHooker { async _handleEvent(eventName) { this.target.on(eventName, async (...args) => { // Should probably move this elsewhere, but testing this out - if (eventName === 'interactionCreate') args[0] = new InteractionWrapper(this.target, args[0], args[0].guild); + for (const arg of args) if (arg?.guild) arg.guildWrapper = new GuildWrapper(this.target, arg.guild); + + if (eventName === 'interactionCreate') args[0] = new InteractionWrapper(this.target, args[0]); - // async-await does nothing in a .forEach loop, + // async-await does nothing in a .forEach loop, // the forEach implementation does not await the results of the function before moving onto the next iteration + // which is a problem if we don't want functionality to be overlapping, i.e. different filters trying to delete the same message for (const handler of this.events.get(eventName)) { await handler(...args); } diff --git a/src/structure/client/wrappers/GuildWrapper.js b/src/structure/client/wrappers/GuildWrapper.js index 5459f63..0187c2b 100644 --- a/src/structure/client/wrappers/GuildWrapper.js +++ b/src/structure/client/wrappers/GuildWrapper.js @@ -197,6 +197,10 @@ class GuildWrapper { return this.guild.roles; } + get premiumTier() { + return this.guild.premiumTier; + } + // Primarily used by the API toJSON() { const json = this.guild.toJSON(); diff --git a/src/structure/client/wrappers/InteractionWrapper.js b/src/structure/client/wrappers/InteractionWrapper.js index 0710852..88398b2 100644 --- a/src/structure/client/wrappers/InteractionWrapper.js +++ b/src/structure/client/wrappers/InteractionWrapper.js @@ -14,7 +14,7 @@ class InteractionWrapper { this.client = client; this.interaction = interaction; this.command = null; - this.guild = guildWrapper; + this.guild = guildWrapper || interaction.guildWrapper || interaction.guild; // this.options = []; diff --git a/src/structure/components/settings/logging/Messages.js b/src/structure/components/settings/logging/Messages.js index bdca725..af80a49 100644 --- a/src/structure/components/settings/logging/Messages.js +++ b/src/structure/components/settings/logging/Messages.js @@ -132,17 +132,17 @@ class MessageLog extends Setting { return [ { name: 'GENERAL_STATUS', - value: guild.format('SETTING_STATE', { bool: Boolean(setting.channel) }, { code: true }), + value: guild.format('GENERAL_STATE', { bool: Boolean(setting.channel) }, { code: true }), inline: true }, { name: 'GENERAL_CHANNEL', - value: `<#${setting.channel}>` || '`N/A`', + value: setting.channel ? `<#${setting.channel}>` : '`N/A`', inline: true }, { name: 'ATTACHMENT_LOGS', - value: guild.format('SETTING_STATE', { bool: Boolean(setting.attachments) }, { code: true }), + value: guild.format('GENERAL_STATE', { bool: Boolean(setting.attachments) }, { code: true }), inline: true }, {