This commit is contained in:
Erik 2022-07-22 11:40:07 +03:00
parent a15e9f6698
commit e6f35b2a76
Signed by untrusted user: Navy.gif
GPG Key ID: 811EC0CD80E7E5FB
9 changed files with 33 additions and 21 deletions

View File

@ -48,6 +48,9 @@ Granted permissions
No permissions granted No permissions granted
// Settings // Settings
[COMMAND_SETTINGS_HELP]
Configure bot settings for the server.
[COMMAND_MODERATION_HELP] [COMMAND_MODERATION_HELP]
Configure moderation related settings. Configure moderation related settings.

View File

@ -47,6 +47,9 @@ The command option {option} requires a text channel.
[O_COMMANDHANDLER_TYPEVOICE_CHANNEL] [O_COMMANDHANDLER_TYPEVOICE_CHANNEL]
The command option {option} requires a voice channel. The command option {option} requires a voice channel.
[O_COMMANDHANDLER_TYPECHANNELS]
The command option {option} requires channels.
[O_COMMANDHANDLER_TYPENUMBER] [O_COMMANDHANDLER_TYPENUMBER]
The command option {option} requires a number between `{min}` and `{max}`. The command option {option} requires a number between `{min}` and `{max}`.

View File

@ -374,7 +374,7 @@ class ModerationManager {
const currentDate = Date.now(); const currentDate = Date.now();
const resolve = async (i) => { 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]]; const undoClass = Constant.Infractions[Constants.InfractionOpposites[i.type]];
if (!undoClass) return false; if (!undoClass) return false;
@ -457,6 +457,7 @@ class ModerationManager {
} }
async removeCallback(callback, updateCase = false) { async removeCallback(callback, updateCase = false) {
// if(!callback) return;
this.logger.debug(`Removing callback ${callback.infraction.type} for ${callback.infraction.targetType} ${callback.infraction.target}.`); this.logger.debug(`Removing callback ${callback.infraction.type} for ${callback.infraction.targetType} ${callback.infraction.target}.`);
if(updateCase) await this.client.storageManager.mongodb.infractions.updateOne( if(updateCase) await this.client.storageManager.mongodb.infractions.updateOne(
{ id: callback.infraction.id }, { id: callback.infraction.id },

View File

@ -6,6 +6,7 @@ const { stripIndents } = require('common-tags');
const { Observer } = require('../../interfaces'); const { Observer } = require('../../interfaces');
const { BinaryTree, Util, FilterUtil } = require('../../../utilities'); const { BinaryTree, Util, FilterUtil } = require('../../../utilities');
const { Warn, Mute, Kick, Softban, Ban } = require('../infractions'); const { Warn, Mute, Kick, Softban, Ban } = require('../infractions');
const { ComponentType, ButtonStyle } = require('discord.js');
const CONSTANTS = { const CONSTANTS = {
Infractions: { Infractions: {
@ -16,7 +17,7 @@ const CONSTANTS = {
BAN: Ban BAN: Ban
}, },
ButtonStyles: { ButtonStyles: {
BAN: 'DANGER', BAN: ButtonStyle.Danger,
}, },
Permissions: { Permissions: {
WARN: 'KickMembers', WARN: 'KickMembers',
@ -311,15 +312,15 @@ module.exports = class AutoModeration extends Observer {
const components = []; const components = [];
for (const action of actions) { for (const action of actions) {
components.push({ components.push({
type: 'BUTTON', type: ComponentType.Button,
label: action.type, label: action.type,
customId: `WORDWATCHER_${action.trigger}`, customId: `WORDWATCHER_${action.trigger}`,
style: CONSTANTS.ButtonStyles[action.type] || 'PRIMARY' style: CONSTANTS.ButtonStyles[action.type] || ButtonStyle.Primary
}); });
} }
const actionRow = components.length ? [{ const actionRow = components.length ? [{
type: 'ACTION_ROW', type: ComponentType.ActionRow,
components components
}] : undefined; }] : undefined;
const sent = await logChannel.send({ const sent = await logChannel.send({

View File

@ -1,4 +1,4 @@
const { EmbedBuilder, Message, ChannelType } = require('discord.js'); const { EmbedBuilder, Message, ChannelType, ComponentType } = require('discord.js');
const { Util } = require('../../../utilities'); const { Util } = require('../../../utilities');
const { InvokerWrapper, MessageWrapper } = require('../../client/wrappers'); const { InvokerWrapper, MessageWrapper } = require('../../client/wrappers');
const { Observer, CommandError } = require('../../interfaces/'); const { Observer, CommandError } = require('../../interfaces/');
@ -477,11 +477,11 @@ class CommandHandler extends Observer {
ephemeral: !invoker.replied, ephemeral: !invoker.replied,
components: [ components: [
{ {
type: 'ACTION_ROW', type: ComponentType.ActionRow,
components: [ components: [
{ {
label: 'Support', label: 'Support',
type: 'BUTTON', type: ComponentType.Button,
style: 'LINK', style: 'LINK',
url: this.client._options.discord.invite url: this.client._options.discord.invite
} }

View File

@ -49,7 +49,7 @@ class MemberLog extends Setting {
async execute(interaction, opts, setting) { async execute(interaction, opts, setting) {
if (opts.join) setting.join = opts.join.value; 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.channel) setting.channel = opts.channel.value.id;
if (opts.enabled) setting.enabled = opts.enabled.value; if (opts.enabled) setting.enabled = opts.enabled.value;

View File

@ -93,8 +93,10 @@ class MessageLog extends Setting {
let hook = await guild.getWebhook(this.name); let hook = await guild.getWebhook(this.name);
if (hook) await hook.edit({ channel }); if (hook) await hook.edit({ channel });
else { else {
hook = await channel.createWebhook('Galactic Bot message logs', hook = await channel.createWebhook({
{ reason: 'Message logs webhook.' }); // avatar: './util/GBotTest.png', name: 'Galactic Bot message logs',
reason: 'Message logs webhook.'
}); // avatar: './util/GBotTest.png',
await guild.updateWebhook(this.name, hook); await guild.updateWebhook(this.name, hook);
setting.webhook = hook.id; setting.webhook = hook.id;
} }

View File

@ -3,6 +3,7 @@ const { inspect } = require('util');
const { Util } = require("../../../../utilities"); const { Util } = require("../../../../utilities");
const { Emojis, Constants: { PermissionNames, EmbedLimits } } = require('../../../../constants'); const { Emojis, Constants: { PermissionNames, EmbedLimits } } = require('../../../../constants');
const { ComponentType, ChannelType } = require('discord.js');
const CONSTANTS = { const CONSTANTS = {
MaxChars: 98 MaxChars: 98
@ -206,16 +207,16 @@ class MuteSetting extends Setting {
emoji: 'loading', emoji: 'loading',
components: [ components: [
{ {
type: 'ACTION_ROW', type: ComponentType.ActionRow,
components: [ components: [
{ {
type: 'BUTTON', type: ComponentType.Button,
label: 'Yes', label: 'Yes',
custom_id: 'yes', custom_id: 'yes',
style: 3 style: 3
}, },
{ {
type: 'BUTTON', type: ComponentType.Button,
label: 'No', label: 'No',
custom_id: 'no', custom_id: 'no',
style: 4 style: 4
@ -246,7 +247,7 @@ class MuteSetting extends Setting {
let updatedPermissions = false; let updatedPermissions = false;
const issues = []; 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()) { for (const channel of channels.values()) {
@ -255,7 +256,7 @@ class MuteSetting extends Setting {
continue; continue;
} }
const configuration = channel.type === 'GUILD_TEXT' const configuration = channel.type === ChannelType.GuildText
? { permissions: { SendMessages: false, AddReactions: false }, bitwise: 0x800n } ? { permissions: { SendMessages: false, AddReactions: false }, bitwise: 0x800n }
: { permissions: { CONNECT: false, SendMessages: false, AddReactions: false }, bitwise: 0x100000n }; : { permissions: { CONNECT: false, SendMessages: false, AddReactions: false }, bitwise: 0x100000n };

View File

@ -1,3 +1,4 @@
const { ComponentType, ButtonStyle } = require("discord.js");
const { Emojis } = require("../../../../constants"); const { Emojis } = require("../../../../constants");
const { Util } = require("../../../../utilities"); const { Util } = require("../../../../utilities");
const { Setting } = require("../../../interfaces"); const { Setting } = require("../../../interfaces");
@ -71,9 +72,9 @@ class SelfroleSetting extends Setting {
if (setting.roles.length && setting.channel && setting.roles.length <= 25) { if (setting.roles.length && setting.channel && setting.roles.length <= 25) {
const roles = await guild.resolveRoles(setting.roles); const roles = await guild.resolveRoles(setting.roles);
const components = [{ const components = [{
type: 'ACTION_ROW', type: ComponentType.ActionRow,
components: [{ components: [{
type: 'SELECT_MENU', type: ComponentType.SelectMenu,
customId: 'selfrole-select', customId: 'selfrole-select',
maxValues: roles.length, maxValues: roles.length,
options: roles.map((r) => { options: roles.map((r) => {
@ -81,12 +82,12 @@ class SelfroleSetting extends Setting {
}) })
}] }]
}, { }, {
type: 'ACTION_ROW', type: ComponentType.ActionRow,
components: [{ components: [{
type: 'BUTTON', type: ComponentType.Button,
customId: 'selfrole-clear', customId: 'selfrole-clear',
label: 'Clear', label: 'Clear',
style: 'PRIMARY', style: ButtonStyle.Primary,
emoji: Emojis.failure emoji: Emojis.failure
}] }]
}]; }];