From 6c19c5763134bd4972d1d3d8a2d139f47b7a9eff Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Tue, 29 Mar 2022 01:46:55 +0300 Subject: [PATCH] cleanup --- src/structure/client/EventHooker.js | 4 +++- src/structure/client/Intercom.js | 7 +++++-- src/structure/components/observers/AuditLog.js | 1 - .../components/observers/GuildLogging.js | 18 ++++-------------- .../settings/moderation/WordWatcher.js | 2 +- src/structure/interfaces/Setting.js | 3 ++- 6 files changed, 15 insertions(+), 20 deletions(-) diff --git a/src/structure/client/EventHooker.js b/src/structure/client/EventHooker.js index e5a6eb9..6c04350 100644 --- a/src/structure/client/EventHooker.js +++ b/src/structure/client/EventHooker.js @@ -47,7 +47,9 @@ class EventHooker { this.logger.debug(`Handler ${eventName}`); // Should probably move this elsewhere, but testing this out -- or maybe not, might be the most appropriate place for this - for (const arg of args) if (arg?.guild) arg.guildWrapper = this.target.getGuildWrapper(arg.guild.id); + for (const arg of args) { + if (arg?.guild) arg.guildWrapper = this.target.getGuildWrapper(arg.guild.id); + } if (eventName === 'interactionCreate') args[0] = new InteractionWrapper(this.target, args[0]); diff --git a/src/structure/client/Intercom.js b/src/structure/client/Intercom.js index bebabe1..57b5bab 100644 --- a/src/structure/client/Intercom.js +++ b/src/structure/client/Intercom.js @@ -22,12 +22,15 @@ class Intercom { _transportCommands() { + const clientId = this.client.application.id; const commands = this.client.registry.components .filter((c) => c._type === 'command' && c.slash) .map((c) => c.shape); - // this.send('commands', { type: 'global', commands }); - this.send('commands', { type: 'guild', commands, clientId: this.client.application.id }); + if (process.env.NODE_ENV === 'development') return this.send('commands', { type: 'guild', commands, clientId }); + + this.send('commands', { type: 'global', commands, clientId }); + this.send('commands', { type: 'guild', commands, clientId }); } diff --git a/src/structure/components/observers/AuditLog.js b/src/structure/components/observers/AuditLog.js index 901efed..4f42259 100644 --- a/src/structure/components/observers/AuditLog.js +++ b/src/structure/components/observers/AuditLog.js @@ -1,5 +1,4 @@ const { Observer, Infraction } = require("../../interfaces"); -const { GuildWrapper } = require("../../client/wrappers"); class AuditLogObserver extends Observer { diff --git a/src/structure/components/observers/GuildLogging.js b/src/structure/components/observers/GuildLogging.js index b86417f..f9e2af7 100644 --- a/src/structure/components/observers/GuildLogging.js +++ b/src/structure/components/observers/GuildLogging.js @@ -42,8 +42,6 @@ class GuildLogger extends Observer { ['messageDeleteBulk', this.messageDeleteBulk.bind(this)], ['messageUpdate', this.messageEdit.bind(this)], ['voiceStateUpdate', this.voiceState.bind(this)], - //['guildBanAdd', this.ban.bind(this)], - //['guildBanRemove', this.unban.bind(this)], ['guildMemberAdd', this.memberJoin.bind(this)], ['guildMemberRemove', this.memberLeave.bind(this)], ['guildMemberUpdate', this.memberUpdate.bind(this)] @@ -559,23 +557,15 @@ class GuildLogger extends Observer { this.client.rateLimiter.queueSend(logChannel, wrapper.format(index, langParams).trim()); } - - // async ban(guild, user) { - - // } - - // async unban(guild, user) { - - // } - + _replaceTags(text, member) { const { user, guild } = member; return text .replace(/\{mention\}/gu, `<@${member.id}>`) .replace(/\{tag\}/gu, Util.escapeMarkdown(user.tag)) .replace(/\{username\}/gu, Util.escapeMarkdown(user.username)) - .replace(/\{serversize\}/gu, guild.memberCount) - .replace(/\{servername\}/gu, guild.name) + .replace(/\{guildsize\}/gu, guild.memberCount) + .replace(/\{guildname\}/gu, guild.name) .replace(/\{accage\}/gu, Util.humanise((Date.now() - user.createdTimestamp)/1000)) //.replace(/a/, '1') .replace(/\{id\}/gu, user.id) .trim(); @@ -646,7 +636,7 @@ class GuildLogger extends Observer { color: CONSTANTS.COLORS.BLUE }; - logChannel.send({ embed }); + logChannel.send({ embeds: [embed] }); } diff --git a/src/structure/components/settings/moderation/WordWatcher.js b/src/structure/components/settings/moderation/WordWatcher.js index cba7689..61b7ee6 100644 --- a/src/structure/components/settings/moderation/WordWatcher.js +++ b/src/structure/components/settings/moderation/WordWatcher.js @@ -91,7 +91,7 @@ class WordWatcher extends FilterSetting { } - _createTrigger(interaction, action, actionObject, actions) { + _createTrigger(interaction, action, actionObject) { actionObject.trigger = actionObject.type; diff --git a/src/structure/interfaces/Setting.js b/src/structure/interfaces/Setting.js index 78da76c..e79705c 100644 --- a/src/structure/interfaces/Setting.js +++ b/src/structure/interfaces/Setting.js @@ -90,7 +90,8 @@ class Setting extends Component { hook.collector = await this.collector(wrapper, selectMenu); } - usageEmbed(guild, verbose = false) { + // , verbose = false -- unsure if this is a necessary argument anymore + usageEmbed(guild) { const fields = [];