forked from Galactic/galactic-bot
Option to disable automatic logging of infractions
This commit is contained in:
parent
88b1d871bc
commit
775a459dee
@ -33,7 +33,8 @@ export type ModerationSettings = {
|
||||
channel: Snowflake | null,
|
||||
infractions: InfractionType[],
|
||||
anonymous: boolean,
|
||||
enabled: boolean
|
||||
enabled: boolean,
|
||||
autolog: boolean,
|
||||
}
|
||||
|
||||
export type DMInfractionSettings = {
|
||||
|
@ -26,7 +26,7 @@ class AuditLogObserver extends Observer
|
||||
async guildBanAdd ({ user, guildWrapper: guild }: ExtendedGuildBan)
|
||||
{
|
||||
const settings = await guild.settings();
|
||||
if (!settings.moderation.channel || !settings.moderation.infractions.includes('BAN'))
|
||||
if (!settings.moderation.channel || !settings.moderation.infractions.includes('BAN') || !settings.moderation.autolog)
|
||||
return; // This is checked by the infraction handling, but it may save resources if checked earlier.
|
||||
const audit = await this._fetchFirstEntry(guild, user, 'MemberBanAdd');
|
||||
if (!audit)
|
||||
@ -46,7 +46,7 @@ class AuditLogObserver extends Observer
|
||||
async guildBanRemove ({ user, guildWrapper: wrapper }: ExtendedGuildBan)
|
||||
{
|
||||
const settings = await wrapper.settings();
|
||||
if (!settings.moderation.channel || !settings.moderation.infractions.includes('UNBAN'))
|
||||
if (!settings.moderation.channel || !settings.moderation.infractions.includes('UNBAN') || !settings.moderation.autolog)
|
||||
return; // This is checked by the infraction handling, but it may save resources if checked earlier.
|
||||
const audit = await this._fetchFirstEntry(wrapper, user, 'MemberBanRemove');
|
||||
if (!audit)
|
||||
@ -67,7 +67,7 @@ class AuditLogObserver extends Observer
|
||||
{
|
||||
const { guildWrapper: wrapper } = member;
|
||||
const settings = await wrapper.settings();
|
||||
if (!settings.moderation.channel || !settings.moderation.infractions.includes('KICK'))
|
||||
if (!settings.moderation.channel || !settings.moderation.infractions.includes('KICK') || !settings.moderation.autolog)
|
||||
return; // This is checked by the infraction handling, but it may save resources if checked earlier.
|
||||
const audit = await this._fetchFirstEntry(wrapper, member.user, 'MemberKick');
|
||||
if (!audit)
|
||||
@ -101,7 +101,10 @@ class AuditLogObserver extends Observer
|
||||
{
|
||||
const { guild: wrapper } = newMember;
|
||||
const settings = await wrapper.settings();
|
||||
if (!settings.moderation.channel)
|
||||
if (!settings.moderation.channel
|
||||
|| !settings.moderation.infractions.includes('MUTE')
|
||||
|| !settings.moderation.infractions.includes('UNMUTE')
|
||||
|| !settings.moderation.autolog)
|
||||
return;
|
||||
|
||||
// console.log(oldMember.communicationDisabledUntilTimestamp, newMember.communicationDisabledUntilTimestamp);
|
||||
@ -152,7 +155,10 @@ class AuditLogObserver extends Observer
|
||||
{
|
||||
const { guild: wrapper } = newMember;
|
||||
const settings = await wrapper.settings();
|
||||
if (!settings.moderation.channel)
|
||||
if (!settings.moderation.channel
|
||||
|| !settings.moderation.infractions.includes('MUTE')
|
||||
|| !settings.moderation.infractions.includes('UNMUTE')
|
||||
|| !settings.moderation.autolog)
|
||||
return;
|
||||
|
||||
const mutedRole = settings.mute.role;
|
||||
|
@ -42,7 +42,8 @@ class ModerationLog extends Setting
|
||||
channel: null,
|
||||
infractions: Infractions,
|
||||
anonymous: false,
|
||||
enabled: false
|
||||
enabled: false,
|
||||
autoLog: true,
|
||||
},
|
||||
definitions: {
|
||||
channel: 'GUILD_TEXT',
|
||||
@ -53,7 +54,15 @@ class ModerationLog extends Setting
|
||||
commandOptions: [
|
||||
{
|
||||
name: 'enabled',
|
||||
description: 'Enable/disable member logs',
|
||||
description: 'Enable/disable infraction logging',
|
||||
type: CommandOptionType.BOOLEAN,
|
||||
flag: true,
|
||||
valueOptional: true,
|
||||
defaultValue: true
|
||||
},
|
||||
{
|
||||
name: 'autolog',
|
||||
description: 'Enable/disable automatic logging of non-bot actions',
|
||||
type: CommandOptionType.BOOLEAN,
|
||||
flag: true,
|
||||
valueOptional: true,
|
||||
@ -89,10 +98,17 @@ class ModerationLog extends Setting
|
||||
|
||||
async execute (invoker: InvokerWrapper, opts: CommandParams, setting: ModerationSettings)
|
||||
{
|
||||
const { channel, infractions, anonymous, enabled } = opts,
|
||||
const { channel, infractions, anonymous, enabled, autolog } = opts,
|
||||
langParams: FormatParams = {};
|
||||
let index = 'SETTING_SUCCESS_ALT';
|
||||
|
||||
if (enabled)
|
||||
setting.enabled = enabled.asBool;
|
||||
if (anonymous)
|
||||
setting.anonymous = anonymous.asBool;
|
||||
if (autolog)
|
||||
setting.autolog = autolog.asBool;
|
||||
|
||||
if (channel)
|
||||
{
|
||||
const ch = channel.asChannel;
|
||||
@ -102,10 +118,6 @@ class ModerationLog extends Setting
|
||||
return { error: true, index: 'ERR_BOT_MISSING_PERMISSIONS', params: { missing: missing?.join(', ') || 'Any' } };
|
||||
setting.channel = channel.asChannel.id;
|
||||
}
|
||||
if (enabled)
|
||||
setting.enabled = enabled.asBool;
|
||||
if (anonymous)
|
||||
setting.anonymous = anonymous.asBool;
|
||||
|
||||
if (infractions)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user