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,
|
channel: Snowflake | null,
|
||||||
infractions: InfractionType[],
|
infractions: InfractionType[],
|
||||||
anonymous: boolean,
|
anonymous: boolean,
|
||||||
enabled: boolean
|
enabled: boolean,
|
||||||
|
autolog: boolean,
|
||||||
}
|
}
|
||||||
|
|
||||||
export type DMInfractionSettings = {
|
export type DMInfractionSettings = {
|
||||||
|
@ -26,7 +26,7 @@ class AuditLogObserver extends Observer
|
|||||||
async guildBanAdd ({ user, guildWrapper: guild }: ExtendedGuildBan)
|
async guildBanAdd ({ user, guildWrapper: guild }: ExtendedGuildBan)
|
||||||
{
|
{
|
||||||
const settings = await guild.settings();
|
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.
|
return; // This is checked by the infraction handling, but it may save resources if checked earlier.
|
||||||
const audit = await this._fetchFirstEntry(guild, user, 'MemberBanAdd');
|
const audit = await this._fetchFirstEntry(guild, user, 'MemberBanAdd');
|
||||||
if (!audit)
|
if (!audit)
|
||||||
@ -46,7 +46,7 @@ class AuditLogObserver extends Observer
|
|||||||
async guildBanRemove ({ user, guildWrapper: wrapper }: ExtendedGuildBan)
|
async guildBanRemove ({ user, guildWrapper: wrapper }: ExtendedGuildBan)
|
||||||
{
|
{
|
||||||
const settings = await wrapper.settings();
|
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.
|
return; // This is checked by the infraction handling, but it may save resources if checked earlier.
|
||||||
const audit = await this._fetchFirstEntry(wrapper, user, 'MemberBanRemove');
|
const audit = await this._fetchFirstEntry(wrapper, user, 'MemberBanRemove');
|
||||||
if (!audit)
|
if (!audit)
|
||||||
@ -67,7 +67,7 @@ class AuditLogObserver extends Observer
|
|||||||
{
|
{
|
||||||
const { guildWrapper: wrapper } = member;
|
const { guildWrapper: wrapper } = member;
|
||||||
const settings = await wrapper.settings();
|
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.
|
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');
|
const audit = await this._fetchFirstEntry(wrapper, member.user, 'MemberKick');
|
||||||
if (!audit)
|
if (!audit)
|
||||||
@ -101,7 +101,10 @@ class AuditLogObserver extends Observer
|
|||||||
{
|
{
|
||||||
const { guild: wrapper } = newMember;
|
const { guild: wrapper } = newMember;
|
||||||
const settings = await wrapper.settings();
|
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;
|
return;
|
||||||
|
|
||||||
// console.log(oldMember.communicationDisabledUntilTimestamp, newMember.communicationDisabledUntilTimestamp);
|
// console.log(oldMember.communicationDisabledUntilTimestamp, newMember.communicationDisabledUntilTimestamp);
|
||||||
@ -152,7 +155,10 @@ class AuditLogObserver extends Observer
|
|||||||
{
|
{
|
||||||
const { guild: wrapper } = newMember;
|
const { guild: wrapper } = newMember;
|
||||||
const settings = await wrapper.settings();
|
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;
|
return;
|
||||||
|
|
||||||
const mutedRole = settings.mute.role;
|
const mutedRole = settings.mute.role;
|
||||||
|
@ -42,7 +42,8 @@ class ModerationLog extends Setting
|
|||||||
channel: null,
|
channel: null,
|
||||||
infractions: Infractions,
|
infractions: Infractions,
|
||||||
anonymous: false,
|
anonymous: false,
|
||||||
enabled: false
|
enabled: false,
|
||||||
|
autoLog: true,
|
||||||
},
|
},
|
||||||
definitions: {
|
definitions: {
|
||||||
channel: 'GUILD_TEXT',
|
channel: 'GUILD_TEXT',
|
||||||
@ -53,7 +54,15 @@ class ModerationLog extends Setting
|
|||||||
commandOptions: [
|
commandOptions: [
|
||||||
{
|
{
|
||||||
name: 'enabled',
|
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,
|
type: CommandOptionType.BOOLEAN,
|
||||||
flag: true,
|
flag: true,
|
||||||
valueOptional: true,
|
valueOptional: true,
|
||||||
@ -89,10 +98,17 @@ class ModerationLog extends Setting
|
|||||||
|
|
||||||
async execute (invoker: InvokerWrapper, opts: CommandParams, setting: ModerationSettings)
|
async execute (invoker: InvokerWrapper, opts: CommandParams, setting: ModerationSettings)
|
||||||
{
|
{
|
||||||
const { channel, infractions, anonymous, enabled } = opts,
|
const { channel, infractions, anonymous, enabled, autolog } = opts,
|
||||||
langParams: FormatParams = {};
|
langParams: FormatParams = {};
|
||||||
let index = 'SETTING_SUCCESS_ALT';
|
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)
|
if (channel)
|
||||||
{
|
{
|
||||||
const ch = channel.asChannel;
|
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' } };
|
return { error: true, index: 'ERR_BOT_MISSING_PERMISSIONS', params: { missing: missing?.join(', ') || 'Any' } };
|
||||||
setting.channel = channel.asChannel.id;
|
setting.channel = channel.asChannel.id;
|
||||||
}
|
}
|
||||||
if (enabled)
|
|
||||||
setting.enabled = enabled.asBool;
|
|
||||||
if (anonymous)
|
|
||||||
setting.anonymous = anonymous.asBool;
|
|
||||||
|
|
||||||
if (infractions)
|
if (infractions)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user