LogoAntiRaid

@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?
}
PropTypeDescription
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?
}
PropTypeDescription
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
	}
}
PropTypeDescription
getPunishmentsOnUser
Gets all the punishments a user has accrued
getPunishment
(userId: discord.Snowflake, punishmentId: string) -> Punishment?
Gets a single punishment by its ID
createUserPunishment
(punishment: CreatePunishment) -> Punishment
Creates a new punishment for a user returning a Punishment
setPunishmentExpiration
(userId: discord.Snowflake, punishmentId: string, reason: string, expiresAt: datetime.DateTime) -> ()
Sets the expiration of a punishment. Repeated calls override previous expiration
deletePunishmentExpiration
(userId: discord.Snowflake, punishmentId: string, resolve: ResolutionReason?) -> ()
Deletes the expiration of a punishment
deletePunishment
(userId: discord.Snowflake, punishmentId: string, mod: string?, auditReason: string) -> ()
Deletes a punishment. This will also reverse the punishment if possible and delete the expiration if it exists
reversePunishmentClass
(userId: discord.Snowflake, mod: string?, punishment: 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
getCachedUserPunishments
(userId: string) -> {Punishment}
Returns the cached list of punishments for a user. If the cache is expired, it will fetch the punishments from the kv store
updateCachedUserPunishments
(userId: string, punishments: {Punishment}) -> nil
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
(userId: string) -> nil
Clears the cached list of punishments for a user
punishmentCompactString
(punishment: Punishment) -> string
Compactly stringifies a punishment
getPunishmentActions
() -> {[string]: PunishmentAction}
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) -> ())?
}
PropTypeDescription
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

Primitives.TemplateContext

stingmanager

stingmanager.StingManager

Returns

ret1

PunishmentManager

Last updated on