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 = {
|
||||
error: true,
|
||||
index: string
|
||||
} | undefined;
|
||||
} | undefined | void;
|
@ -15,7 +15,7 @@ class EventHooker
|
||||
#target: DiscordClient;
|
||||
#logger: LoggerClient;
|
||||
#events: Map<keyof ClientEvents, CallableFunction[]>;
|
||||
#safeEvents: string[];
|
||||
#safeEvents: (keyof ClientEvents)[];
|
||||
|
||||
constructor (target: DiscordClient)
|
||||
{
|
||||
@ -26,7 +26,7 @@ class EventHooker
|
||||
this.#events = new Map();
|
||||
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>)
|
||||
|
@ -15,6 +15,7 @@ import {
|
||||
Kick,
|
||||
Lockdown,
|
||||
Mute,
|
||||
Note,
|
||||
Removerole,
|
||||
Softban, Unban,
|
||||
Unlockdown,
|
||||
@ -41,6 +42,7 @@ const Constant: {
|
||||
REMOVEROLE: typeof Removerole;
|
||||
LOCKDOWN: typeof Lockdown;
|
||||
UNLOCKDOWN: typeof Unlockdown;
|
||||
NOTE: typeof Note
|
||||
},
|
||||
Hierarchy: {
|
||||
[key: string]: number
|
||||
@ -58,7 +60,8 @@ const Constant: {
|
||||
ADDROLE: Addrole,
|
||||
REMOVEROLE: Removerole,
|
||||
LOCKDOWN: Lockdown,
|
||||
UNLOCKDOWN: Unlockdown
|
||||
UNLOCKDOWN: Unlockdown,
|
||||
NOTE: Note
|
||||
},
|
||||
Hierarchy: {
|
||||
WARN: 0,
|
||||
@ -87,6 +90,7 @@ class ModerationManager implements Initialisable
|
||||
REMOVEROLE: typeof Removerole;
|
||||
LOCKDOWN: typeof Lockdown;
|
||||
UNLOCKDOWN: typeof Unlockdown;
|
||||
NOTE: typeof Note
|
||||
};
|
||||
|
||||
get infractionClasses ()
|
||||
@ -101,13 +105,10 @@ class ModerationManager implements Initialisable
|
||||
|
||||
constructor (client: DiscordClient)
|
||||
{
|
||||
|
||||
this.#client = client;
|
||||
this.#callbacks = new Collection();
|
||||
this.#logger = client.createLogger(this); // new Logger({ name: 'ModMngr' });
|
||||
|
||||
this.#infractionClasses = Constant.Infractions;
|
||||
|
||||
}
|
||||
|
||||
actions: {
|
||||
|
@ -77,7 +77,7 @@ class EditCommand extends SlashCommand
|
||||
|
||||
const results: InfractionEditResult[] = [];
|
||||
if (reasonOpt)
|
||||
await infraction.editReason(member, reason ?? 'N/A');
|
||||
results.push(await infraction.editReason(member, reason ?? 'N/A'));
|
||||
if (points)
|
||||
results.push(await infraction.editPoints(member, points.asNumber));
|
||||
if (expiration)
|
||||
|
@ -60,6 +60,7 @@ class UnmuteInfraction extends Infraction
|
||||
now = Date.now();
|
||||
|
||||
let callback = null;
|
||||
// TODO: Make this not rely on a member wrapper
|
||||
const memberWrapper = await this.guild.memberWrapper(this.member!).catch(() => null);
|
||||
if (Object.keys(this.data).length)
|
||||
{
|
||||
@ -69,7 +70,7 @@ class UnmuteInfraction extends Infraction
|
||||
}
|
||||
else
|
||||
{
|
||||
callback = await memberWrapper!.getCallback('MUTE');
|
||||
callback = await memberWrapper?.getCallback('MUTE');
|
||||
if (callback)
|
||||
{
|
||||
removedRoles = callback.infraction.data.removedRoles ?? null;
|
||||
@ -101,7 +102,7 @@ class UnmuteInfraction extends Infraction
|
||||
|
||||
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
|
||||
{
|
||||
|
@ -657,7 +657,7 @@ class Infraction
|
||||
await this.#modLogMessage.edit({ embeds: [ await this.#embed() ] });
|
||||
}
|
||||
|
||||
async editReason (staff: UserResolveable, reason: string)
|
||||
async editReason (staff: UserResolveable, reason: string): Promise<InfractionEditResult>
|
||||
{
|
||||
this.#error();
|
||||
const log: InfractionChange = {
|
||||
@ -813,12 +813,10 @@ class Infraction
|
||||
|
||||
await this.#patch(data);
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
async #patch (data: WithId<InfractionJSON>)
|
||||
{
|
||||
|
||||
this.#mongoId = new ObjectId(data._id);
|
||||
this.#callbacked = data._callbacked ?? false;
|
||||
this.#fetched = true;
|
||||
|
Loading…
Reference in New Issue
Block a user