Bugfix to case, resolve and edit functionality
This commit is contained in:
parent
3d5909724f
commit
e9c17cd830
2
@types/Moderation.d.ts
vendored
2
@types/Moderation.d.ts
vendored
@ -88,4 +88,4 @@ export type MissingPermsProps = {
|
|||||||
export type InfractionEditResult = {
|
export type InfractionEditResult = {
|
||||||
error: true,
|
error: true,
|
||||||
index: string
|
index: string
|
||||||
} | undefined;
|
} | undefined | void;
|
@ -15,7 +15,7 @@ class EventHooker
|
|||||||
#target: DiscordClient;
|
#target: DiscordClient;
|
||||||
#logger: LoggerClient;
|
#logger: LoggerClient;
|
||||||
#events: Map<keyof ClientEvents, CallableFunction[]>;
|
#events: Map<keyof ClientEvents, CallableFunction[]>;
|
||||||
#safeEvents: string[];
|
#safeEvents: (keyof ClientEvents)[];
|
||||||
|
|
||||||
constructor (target: DiscordClient)
|
constructor (target: DiscordClient)
|
||||||
{
|
{
|
||||||
@ -26,7 +26,7 @@ class EventHooker
|
|||||||
this.#events = new Map();
|
this.#events = new Map();
|
||||||
this.#logger = target.createLogger(this);
|
this.#logger = target.createLogger(this);
|
||||||
|
|
||||||
this.#safeEvents = [ 'componentUpdate', 'ready', 'shardReady', 'rateLimit', 'guildCreate' ];
|
this.#safeEvents = [ 'componentUpdate', 'ready', 'shardReady', 'rateLimit', 'guildCreate', 'apiResponse' ];
|
||||||
}
|
}
|
||||||
|
|
||||||
hook<K extends keyof ClientEvents> (eventName: K, func: EventHook<K>)
|
hook<K extends keyof ClientEvents> (eventName: K, func: EventHook<K>)
|
||||||
|
@ -15,6 +15,7 @@ import {
|
|||||||
Kick,
|
Kick,
|
||||||
Lockdown,
|
Lockdown,
|
||||||
Mute,
|
Mute,
|
||||||
|
Note,
|
||||||
Removerole,
|
Removerole,
|
||||||
Softban, Unban,
|
Softban, Unban,
|
||||||
Unlockdown,
|
Unlockdown,
|
||||||
@ -41,6 +42,7 @@ const Constant: {
|
|||||||
REMOVEROLE: typeof Removerole;
|
REMOVEROLE: typeof Removerole;
|
||||||
LOCKDOWN: typeof Lockdown;
|
LOCKDOWN: typeof Lockdown;
|
||||||
UNLOCKDOWN: typeof Unlockdown;
|
UNLOCKDOWN: typeof Unlockdown;
|
||||||
|
NOTE: typeof Note
|
||||||
},
|
},
|
||||||
Hierarchy: {
|
Hierarchy: {
|
||||||
[key: string]: number
|
[key: string]: number
|
||||||
@ -58,7 +60,8 @@ const Constant: {
|
|||||||
ADDROLE: Addrole,
|
ADDROLE: Addrole,
|
||||||
REMOVEROLE: Removerole,
|
REMOVEROLE: Removerole,
|
||||||
LOCKDOWN: Lockdown,
|
LOCKDOWN: Lockdown,
|
||||||
UNLOCKDOWN: Unlockdown
|
UNLOCKDOWN: Unlockdown,
|
||||||
|
NOTE: Note
|
||||||
},
|
},
|
||||||
Hierarchy: {
|
Hierarchy: {
|
||||||
WARN: 0,
|
WARN: 0,
|
||||||
@ -87,6 +90,7 @@ class ModerationManager implements Initialisable
|
|||||||
REMOVEROLE: typeof Removerole;
|
REMOVEROLE: typeof Removerole;
|
||||||
LOCKDOWN: typeof Lockdown;
|
LOCKDOWN: typeof Lockdown;
|
||||||
UNLOCKDOWN: typeof Unlockdown;
|
UNLOCKDOWN: typeof Unlockdown;
|
||||||
|
NOTE: typeof Note
|
||||||
};
|
};
|
||||||
|
|
||||||
get infractionClasses ()
|
get infractionClasses ()
|
||||||
@ -101,13 +105,10 @@ class ModerationManager implements Initialisable
|
|||||||
|
|
||||||
constructor (client: DiscordClient)
|
constructor (client: DiscordClient)
|
||||||
{
|
{
|
||||||
|
|
||||||
this.#client = client;
|
this.#client = client;
|
||||||
this.#callbacks = new Collection();
|
this.#callbacks = new Collection();
|
||||||
this.#logger = client.createLogger(this); // new Logger({ name: 'ModMngr' });
|
this.#logger = client.createLogger(this); // new Logger({ name: 'ModMngr' });
|
||||||
|
|
||||||
this.#infractionClasses = Constant.Infractions;
|
this.#infractionClasses = Constant.Infractions;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
|
@ -77,7 +77,7 @@ class EditCommand extends SlashCommand
|
|||||||
|
|
||||||
const results: InfractionEditResult[] = [];
|
const results: InfractionEditResult[] = [];
|
||||||
if (reasonOpt)
|
if (reasonOpt)
|
||||||
await infraction.editReason(member, reason ?? 'N/A');
|
results.push(await infraction.editReason(member, reason ?? 'N/A'));
|
||||||
if (points)
|
if (points)
|
||||||
results.push(await infraction.editPoints(member, points.asNumber));
|
results.push(await infraction.editPoints(member, points.asNumber));
|
||||||
if (expiration)
|
if (expiration)
|
||||||
|
@ -60,6 +60,7 @@ class UnmuteInfraction extends Infraction
|
|||||||
now = Date.now();
|
now = Date.now();
|
||||||
|
|
||||||
let callback = null;
|
let callback = null;
|
||||||
|
// TODO: Make this not rely on a member wrapper
|
||||||
const memberWrapper = await this.guild.memberWrapper(this.member!).catch(() => null);
|
const memberWrapper = await this.guild.memberWrapper(this.member!).catch(() => null);
|
||||||
if (Object.keys(this.data).length)
|
if (Object.keys(this.data).length)
|
||||||
{
|
{
|
||||||
@ -69,7 +70,7 @@ class UnmuteInfraction extends Infraction
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
callback = await memberWrapper!.getCallback('MUTE');
|
callback = await memberWrapper?.getCallback('MUTE');
|
||||||
if (callback)
|
if (callback)
|
||||||
{
|
{
|
||||||
removedRoles = callback.infraction.data.removedRoles ?? null;
|
removedRoles = callback.infraction.data.removedRoles ?? null;
|
||||||
@ -101,7 +102,7 @@ class UnmuteInfraction extends Infraction
|
|||||||
|
|
||||||
if (!callback && settings.mute.type < 3)
|
if (!callback && settings.mute.type < 3)
|
||||||
{
|
{
|
||||||
if (role && this.member!.roles.cache.has((role as Role).id))
|
if (role && this.member?.roles.cache.has((role as Role).id))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -657,7 +657,7 @@ class Infraction
|
|||||||
await this.#modLogMessage.edit({ embeds: [ await this.#embed() ] });
|
await this.#modLogMessage.edit({ embeds: [ await this.#embed() ] });
|
||||||
}
|
}
|
||||||
|
|
||||||
async editReason (staff: UserResolveable, reason: string)
|
async editReason (staff: UserResolveable, reason: string): Promise<InfractionEditResult>
|
||||||
{
|
{
|
||||||
this.#error();
|
this.#error();
|
||||||
const log: InfractionChange = {
|
const log: InfractionChange = {
|
||||||
@ -813,12 +813,10 @@ class Infraction
|
|||||||
|
|
||||||
await this.#patch(data);
|
await this.#patch(data);
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async #patch (data: WithId<InfractionJSON>)
|
async #patch (data: WithId<InfractionJSON>)
|
||||||
{
|
{
|
||||||
|
|
||||||
this.#mongoId = new ObjectId(data._id);
|
this.#mongoId = new ObjectId(data._id);
|
||||||
this.#callbacked = data._callbacked ?? false;
|
this.#callbacked = data._callbacked ?? false;
|
||||||
this.#fetched = true;
|
this.#fetched = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user