@antiraid-ext/utils/punishmentmanager
API reference for @antiraid-ext/utils/punishmentmanager
@antiraid-ext/utils/punishmentmanager
Types
ResolutionReason
Raw Type
type ResolutionReason = "reversed"
"reversed"
Punishment
Raw Type
type Punishment = {
punishmentId: string,
userId: discord.Snowflake,
modId: discord.Snowflake?,
punishment: string,
reason: string,
delete_message_seconds: number?,
created_at: datetime.DateTime,
expires_at: datetime.DateTime?,
resolved: ResolutionReason?
}
Prop | Type | Description |
---|---|---|
punishmentId | - | |
userId | - | |
modId? | - | |
punishment | - | |
reason | - | |
delete_message_seconds? | - | |
created_at | - | |
expires_at? | - | |
resolved? | - |
CreatePunishment
Raw Type
type CreatePunishment = {
userId: discord.Snowflake,
modId: discord.Snowflake?,
punishment: string,
reason: string,
expires_at: datetime.DateTime?,
delete_message_seconds: number?
}
Prop | Type | Description |
---|---|---|
userId | - | |
modId? | - | |
punishment | - | |
reason | - | |
expires_at? | - | |
delete_message_seconds? | - |
PunishmentManager
[[ Manages the moderation 'punishments' (think bee punishments!) of a user. ]]
Raw Type
--[[
Manages the moderation 'punishments' (think bee punishments!) of a user.
]]
type PunishmentManager = {
--- Gets all the punishments a user has accrued
getPunishmentsOnUser: (userId: discord.Snowflake) -> {Punishment},
--- Gets a single punishment by its ID
getPunishment: (userId: discord.Snowflake, punishmentId: string) -> Punishment?,
--- Creates a new punishment for a user returning a Punishment
createUserPunishment: (punishment: CreatePunishment) -> Punishment,
--- Sets the expiration of a punishment. Repeated calls override previous expiration
setPunishmentExpiration: (userId: discord.Snowflake, punishmentId: string, reason: string, expiresAt: datetime.DateTime) -> (),
--- Deletes the expiration of a punishment
deletePunishmentExpiration: (userId: discord.Snowflake, punishmentId: string, resolve: ResolutionReason?) -> (),
--- Deletes a punishment. This will also reverse the punishment if possible and delete the expiration if it exists
deletePunishment: (userId: discord.Snowflake, punishmentId: string, mod: string?, auditReason: string) -> (),
--- Reverse a whole class of punishments, this will create a dummy punishment for reversal disabling expiration for all punishments within the bot
reversePunishmentClass: (userId: discord.Snowflake, mod: string?, punishment: string, auditReason: string) -> (),
--- Returns the cached list of punishments for a user. If the cache is expired, it will fetch the punishments from the kv store
getCachedUserPunishments: (userId: string) -> {Punishment},
--- Manually update the cached list of punishments for a user
---
--- This is useful for when you know the punishments have changed and you want to update the cache
updateCachedUserPunishments: (userId: string, punishments: {Punishment}) -> nil,
--- Clears the cached list of punishments for a user
clearCachedUserPunishments: (userId: string) -> nil,
--- Compactly stringifies a punishment
punishmentCompactString: (punishment: Punishment) -> string,
--- Gets the list of punishment actions. This can then be modified directly to add/remove punishment actions
getPunishmentActions: () -> {
[string]: PunishmentAction
}
}
Prop | Type | Description |
---|---|---|
getPunishmentsOnUser | Gets all the punishments a user has accrued | |
getPunishment | Gets a single punishment by its ID | |
createUserPunishment | Creates a new punishment for a user returning a Punishment | |
setPunishmentExpiration | Sets the expiration of a punishment. Repeated calls override previous expiration | |
deletePunishmentExpiration | Deletes the expiration of a punishment | |
deletePunishment | Deletes a punishment. This will also reverse the punishment if possible and delete the expiration if it exists | |
reversePunishmentClass | Reverse a whole class of punishments, this will create a dummy punishment for reversal disabling expiration for all punishments within the bot | |
getCachedUserPunishments | Returns the cached list of punishments for a user. If the cache is expired, it will fetch the punishments from the kv store | |
updateCachedUserPunishments | Manually update the cached list of punishments for a userThis is useful for when you know the punishments have changed and you want to update the cache | |
clearCachedUserPunishments | Clears the cached list of punishments for a user | |
punishmentCompactString | Compactly stringifies a punishment | |
getPunishmentActions | Gets the list of punishment actions. This can then be modified directly to add/remove punishment actions |
PunishmentAction
A punishment action stores how to apply and reverse a punishment
Raw Type
--- A punishment action stores how to apply and reverse a punishment
type PunishmentAction = {
name: string,
description: string,
check: (ctx: Primitives.TemplateContext, p: Punishment) -> (),
needsReversal: boolean,
apply: (ctx: Primitives.TemplateContext, p: Punishment) -> (),
remove: ((ctx: Primitives.TemplateContext, p: Punishment) -> ())?
}
Prop | Type | Description |
---|---|---|
check | - | |
apply | - | |
name | - | |
description | - | |
needsReversal | - | |
remove? | - |
Functions
PunishmentManager
2 minutes
Function Signature
-- 2 minutes
function PunishmentManager(ctx: Primitives.TemplateContext, stingmanager: stingmanager.StingManager) -> PunishmentManager end
Arguments
ctx
stingmanager
Returns
ret1
Last updated on