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
// Settings
[COMMAND_SETTINGS_HELP]
Configure bot settings for the server.
[COMMAND_MODERATION_HELP]
Configure moderation related settings.

View File

@ -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}`.

View File

@ -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 },

View File

@ -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({

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 { 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
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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 };

View File

@ -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
}]
}];