@antiraid-core/primitives
API reference for @antiraid-core/primitives
@antiraid-core/primitives
Types
u8
AntiRaid primitives
Last updated: June 22nd 2025
Core types
Raw Type
-- AntiRaid primitives
--
-- Last updated: June 22nd 2025
-- Core types
type u8 = number
u16
Raw Type
type u16 = number
u32
Raw Type
type u32 = number
u64
Raw Type
type u64 = number
i8
Raw Type
type i8 = number
i16
Raw Type
type i16 = number
i32
Raw Type
type i32 = number
i64
Raw Type
type i64 = number
f32
Raw Type
type f32 = number
f64
Raw Type
type f64 = number
bool
Raw Type
type bool = boolean
char
Raw Type
type char = string
byte
Raw Type
type byte = number
Event
An event that has been dispatched to the template.
In templates, this is ``arg``.
Raw Type
--- An event that has been dispatched to the template.
---
--- In templates, this is \`\`arg\`\`.
type Event = {
--- The base name of the event.
base_name: string,
--- The name of the event.
name: string,
--- The data of the event.
data: any,
--- The author of the event, if any.
author: string?
}
Prop | Type | Description |
---|---|---|
base_name | The base name of the event. | |
name | The name of the event. | |
data | The data of the event. | |
author? | The author of the event, if any. |
ScriptData
Information about a script
Raw Type
--- Information about a script
type ScriptData = {
--- The guild ID the template is in.
guild_id: string,
--- The name of the template.
name: string,
--- The description of the template.
description: string?,
--- The name of the template as it appears on the template shop listing.
shop_name: string?,
--- The owner of the template on the template shop.
shop_owner: string?,
--- The events that this template listens to.
events: {string},
--- The channel to send errors to.
error_channel: string?,
--- The language of the template.
lang: string,
--- The allowed capabilities the template has access to.
allowed_caps: {string},
--- The user who created the template.
created_by: string,
--- The time the template was created.
created_at: string,
--- The user who last updated the template.
updated_by: string,
--- The time the template was last updated.
updated_at: string
}
Prop | Type | Description |
---|---|---|
guild_id | The guild ID the template is in. | |
name | The name of the template. | |
description? | The description of the template. | |
shop_name? | The name of the template as it appears on the template shop listing. | |
shop_owner? | The owner of the template on the template shop. | |
events | The events that this template listens to. | |
error_channel? | The channel to send errors to. | |
lang | The language of the template. | |
allowed_caps | The allowed capabilities the template has access to. | |
created_by | The user who created the template. | |
created_at | The time the template was created. | |
updated_by | The user who last updated the template. | |
updated_at | The time the template was last updated. |
Limitations
Raw Type
type Limitations = {
--- Capabilities that the template has access to.
capabilities: {string}
}
Prop | Type | Description |
---|---|---|
capabilities | Capabilities that the template has access to. |
TemplateContext
TemplateContext is a struct that represents the context of a template.
Stores key data including the templates data, pragma and what capabilities it should have access to.
Passing a TemplateContext is often required when using AntiRaid plugins for getting the inner context
of a template.
Raw Type
--- TemplateContext is a struct that represents the context of a template.
---
--- Stores key data including the templates data, pragma and what capabilities it should have access to.
---
--- Passing a TemplateContext is often required when using AntiRaid plugins for getting the inner context
--- of a template.
type TemplateContext = {
--- DataStores plugin
DataStores: datastoresP.Plugin,
--- Discord plugin
Discord: discordP.Plugin,
--- Image Captcha plugin
ImageCaptcha: imgcaptchaP.Plugin,
--- Key-Value plugin
KV: kvP.Plugin,
--- Object Storage plugin
ObjectStorage: objectstorageP.Plugin,
--- HTTP Client plugin
HTTPClient: httpclientP.Plugin,
--- The public data associated with the script.
data: ScriptData,
--- Returns the memory limit the VM has/the amount of memory the VM is allowed to use
memory_limit: u64,
--- The current guild ID the template is running on.
guild_id: string,
--- The owner guild ID of the template, if any. For shop templates, this will be the guild ID of the guild which owns the template on the shop
--- For guild-owned templates, this will be the guild ID of the guild which owns the template [the same as guild_id]
owner_guild_id: string,
--- The name of the template itself
template_name: string,
--- The capabilities the template has access to.
allowed_caps: {string},
--- Returns AntiRaid's discord user object [the current discord bot user driving the template].
current_user: discord.UserObject,
--- Returns if a template has a specific capability.
has_cap: (self: TemplateContext, cap: string) -> boolean,
--- Returns if a template has any of the specified capabilities.
has_any_cap: (self: TemplateContext, caps: {string}) -> boolean,
--- Returns a new TemplateContext with the specified limits which must be a strict subset
--- of the current context's limits.
withlimits: (self: TemplateContext, limits: Limitations) -> TemplateContext,
--- The global/common store table shared across all templates within the same
--- server
store: {}
}
Prop | Type | Description |
---|---|---|
has_cap | Returns if a template has a specific capability. | |
has_any_cap | Returns if a template has any of the specified capabilities. | |
withlimits | Returns a new TemplateContext with the specified limits which must be a strict subsetof the current context's limits. | |
DataStores | DataStores plugin | |
Discord | Discord plugin | |
ImageCaptcha | Image Captcha plugin | |
KV | Key-Value plugin | |
ObjectStorage | Object Storage plugin | |
HTTPClient | HTTP Client plugin | |
data | The public data associated with the script. | |
memory_limit | Returns the memory limit the VM has/the amount of memory the VM is allowed to use | |
guild_id | The current guild ID the template is running on. | |
owner_guild_id | The owner guild ID of the template, if any. For shop templates, this will be the guild ID of the guild which owns the template on the shopFor guild-owned templates, this will be the guild ID of the guild which owns the template [the same as guild_id] | |
template_name | The name of the template itself | |
allowed_caps | The capabilities the template has access to. | |
current_user | Returns AntiRaid's discord user object [the current discord bot user driving the template]. | |
store | {} | The global/common store table shared across all templates within the sameserver |
Last updated on