From e6f35b2a7666b826a9efafab998f97338711099f Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Fri, 22 Jul 2022 11:40:07 +0300 Subject: [PATCH] bugfixes --- .../en_gb/commands/en_gb_administration.lang | 3 +++ .../en_gb/observers/en_gb_commandHandler.lang | 3 +++ src/structure/client/ModerationManager.js | 3 ++- src/structure/components/observers/Automoderation.js | 9 +++++---- src/structure/components/observers/CommandHandler.js | 6 +++--- src/structure/components/settings/logging/Members.js | 2 +- src/structure/components/settings/logging/Messages.js | 6 ++++-- src/structure/components/settings/moderation/Mute.js | 11 ++++++----- src/structure/components/settings/utility/Selfrole.js | 11 ++++++----- 9 files changed, 33 insertions(+), 21 deletions(-) diff --git a/src/localization/en_gb/commands/en_gb_administration.lang b/src/localization/en_gb/commands/en_gb_administration.lang index c94e8d3..13d772e 100644 --- a/src/localization/en_gb/commands/en_gb_administration.lang +++ b/src/localization/en_gb/commands/en_gb_administration.lang @@ -48,6 +48,9 @@ Granted permissions No permissions granted // Settings +[COMMAND_SETTINGS_HELP] +Configure bot settings for the server. + [COMMAND_MODERATION_HELP] Configure moderation related settings. diff --git a/src/localization/en_gb/observers/en_gb_commandHandler.lang b/src/localization/en_gb/observers/en_gb_commandHandler.lang index 3d19388..264ece6 100644 --- a/src/localization/en_gb/observers/en_gb_commandHandler.lang +++ b/src/localization/en_gb/observers/en_gb_commandHandler.lang @@ -47,6 +47,9 @@ The command option {option} requires a text channel. [O_COMMANDHANDLER_TYPEVOICE_CHANNEL] The command option {option} requires a voice channel. +[O_COMMANDHANDLER_TYPECHANNELS] +The command option {option} requires channels. + [O_COMMANDHANDLER_TYPENUMBER] The command option {option} requires a number between `{min}` and `{max}`. diff --git a/src/structure/client/ModerationManager.js b/src/structure/client/ModerationManager.js index bb2b610..f69bd9a 100644 --- a/src/structure/client/ModerationManager.js +++ b/src/structure/client/ModerationManager.js @@ -374,7 +374,7 @@ class ModerationManager { const currentDate = Date.now(); const resolve = async (i) => { - this.logger.debug(`Resolving infraction ${i.id}`); + this.logger.debug(`Infraction callback: ${i.id}`); const undoClass = Constant.Infractions[Constants.InfractionOpposites[i.type]]; if (!undoClass) return false; @@ -457,6 +457,7 @@ class ModerationManager { } async removeCallback(callback, updateCase = false) { + // if(!callback) return; this.logger.debug(`Removing callback ${callback.infraction.type} for ${callback.infraction.targetType} ${callback.infraction.target}.`); if(updateCase) await this.client.storageManager.mongodb.infractions.updateOne( { id: callback.infraction.id }, diff --git a/src/structure/components/observers/Automoderation.js b/src/structure/components/observers/Automoderation.js index 87548a8..5a77cff 100644 --- a/src/structure/components/observers/Automoderation.js +++ b/src/structure/components/observers/Automoderation.js @@ -6,6 +6,7 @@ const { stripIndents } = require('common-tags'); const { Observer } = require('../../interfaces'); const { BinaryTree, Util, FilterUtil } = require('../../../utilities'); const { Warn, Mute, Kick, Softban, Ban } = require('../infractions'); +const { ComponentType, ButtonStyle } = require('discord.js'); const CONSTANTS = { Infractions: { @@ -16,7 +17,7 @@ const CONSTANTS = { BAN: Ban }, ButtonStyles: { - BAN: 'DANGER', + BAN: ButtonStyle.Danger, }, Permissions: { WARN: 'KickMembers', @@ -311,15 +312,15 @@ module.exports = class AutoModeration extends Observer { const components = []; for (const action of actions) { components.push({ - type: 'BUTTON', + type: ComponentType.Button, label: action.type, customId: `WORDWATCHER_${action.trigger}`, - style: CONSTANTS.ButtonStyles[action.type] || 'PRIMARY' + style: CONSTANTS.ButtonStyles[action.type] || ButtonStyle.Primary }); } const actionRow = components.length ? [{ - type: 'ACTION_ROW', + type: ComponentType.ActionRow, components }] : undefined; const sent = await logChannel.send({ diff --git a/src/structure/components/observers/CommandHandler.js b/src/structure/components/observers/CommandHandler.js index d1a393d..02eaf67 100644 --- a/src/structure/components/observers/CommandHandler.js +++ b/src/structure/components/observers/CommandHandler.js @@ -1,4 +1,4 @@ -const { EmbedBuilder, Message, ChannelType } = require('discord.js'); +const { EmbedBuilder, Message, ChannelType, ComponentType } = require('discord.js'); const { Util } = require('../../../utilities'); const { InvokerWrapper, MessageWrapper } = require('../../client/wrappers'); const { Observer, CommandError } = require('../../interfaces/'); @@ -477,11 +477,11 @@ class CommandHandler extends Observer { ephemeral: !invoker.replied, components: [ { - type: 'ACTION_ROW', + type: ComponentType.ActionRow, components: [ { label: 'Support', - type: 'BUTTON', + type: ComponentType.Button, style: 'LINK', url: this.client._options.discord.invite } diff --git a/src/structure/components/settings/logging/Members.js b/src/structure/components/settings/logging/Members.js index 41f06d2..99b73b9 100644 --- a/src/structure/components/settings/logging/Members.js +++ b/src/structure/components/settings/logging/Members.js @@ -49,7 +49,7 @@ class MemberLog extends Setting { async execute(interaction, opts, setting) { if (opts.join) setting.join = opts.join.value; - if (opts.leave) setting.join = opts.join.value; + if (opts.leave) setting.leave = opts.leave.value; if (opts.channel) setting.channel = opts.channel.value.id; if (opts.enabled) setting.enabled = opts.enabled.value; diff --git a/src/structure/components/settings/logging/Messages.js b/src/structure/components/settings/logging/Messages.js index 930c904..b18300b 100644 --- a/src/structure/components/settings/logging/Messages.js +++ b/src/structure/components/settings/logging/Messages.js @@ -93,8 +93,10 @@ class MessageLog extends Setting { let hook = await guild.getWebhook(this.name); if (hook) await hook.edit({ channel }); else { - hook = await channel.createWebhook('Galactic Bot message logs', - { reason: 'Message logs webhook.' }); // avatar: './util/GBotTest.png', + hook = await channel.createWebhook({ + name: 'Galactic Bot message logs', + reason: 'Message logs webhook.' + }); // avatar: './util/GBotTest.png', await guild.updateWebhook(this.name, hook); setting.webhook = hook.id; } diff --git a/src/structure/components/settings/moderation/Mute.js b/src/structure/components/settings/moderation/Mute.js index 8565252..4afe440 100644 --- a/src/structure/components/settings/moderation/Mute.js +++ b/src/structure/components/settings/moderation/Mute.js @@ -3,6 +3,7 @@ const { inspect } = require('util'); const { Util } = require("../../../../utilities"); const { Emojis, Constants: { PermissionNames, EmbedLimits } } = require('../../../../constants'); +const { ComponentType, ChannelType } = require('discord.js'); const CONSTANTS = { MaxChars: 98 @@ -206,16 +207,16 @@ class MuteSetting extends Setting { emoji: 'loading', components: [ { - type: 'ACTION_ROW', + type: ComponentType.ActionRow, components: [ { - type: 'BUTTON', + type: ComponentType.Button, label: 'Yes', custom_id: 'yes', style: 3 }, { - type: 'BUTTON', + type: ComponentType.Button, label: 'No', custom_id: 'no', style: 4 @@ -246,7 +247,7 @@ class MuteSetting extends Setting { let updatedPermissions = false; const issues = []; - const channels = guild.channels.cache.filter((ch) => ['GUILD_TEXT', 'GUILD_VOICE'].includes(ch.type)); + const channels = guild.channels.cache.filter((ch) => [ChannelType.GuildText, ChannelType.GuildVoice].includes(ch.type)); for (const channel of channels.values()) { @@ -255,7 +256,7 @@ class MuteSetting extends Setting { continue; } - const configuration = channel.type === 'GUILD_TEXT' + const configuration = channel.type === ChannelType.GuildText ? { permissions: { SendMessages: false, AddReactions: false }, bitwise: 0x800n } : { permissions: { CONNECT: false, SendMessages: false, AddReactions: false }, bitwise: 0x100000n }; diff --git a/src/structure/components/settings/utility/Selfrole.js b/src/structure/components/settings/utility/Selfrole.js index 11a8ad6..c0cb64d 100644 --- a/src/structure/components/settings/utility/Selfrole.js +++ b/src/structure/components/settings/utility/Selfrole.js @@ -1,3 +1,4 @@ +const { ComponentType, ButtonStyle } = require("discord.js"); const { Emojis } = require("../../../../constants"); const { Util } = require("../../../../utilities"); const { Setting } = require("../../../interfaces"); @@ -71,9 +72,9 @@ class SelfroleSetting extends Setting { if (setting.roles.length && setting.channel && setting.roles.length <= 25) { const roles = await guild.resolveRoles(setting.roles); const components = [{ - type: 'ACTION_ROW', + type: ComponentType.ActionRow, components: [{ - type: 'SELECT_MENU', + type: ComponentType.SelectMenu, customId: 'selfrole-select', maxValues: roles.length, options: roles.map((r) => { @@ -81,12 +82,12 @@ class SelfroleSetting extends Setting { }) }] }, { - type: 'ACTION_ROW', + type: ComponentType.ActionRow, components: [{ - type: 'BUTTON', + type: ComponentType.Button, customId: 'selfrole-clear', label: 'Clear', - style: 'PRIMARY', + style: ButtonStyle.Primary, emoji: Emojis.failure }] }];