@antiraid/async

Utilities for asynchronous operations and timing

Methods

sleep

function sleep(duration: f64): f64

Sleep for a given duration.

Parameters

  • duration (f64): The duration to sleep for.

Returns

  • slept_time (f64): The actual duration slept for.

@antiraid/discord

This plugin allows for templates to interact with the Discord API

Types

Serenity.User

A user object in Discord, as represented by AntiRaid. Internal fields are subject to change

Refer to serenity::model::user::User for more documentation on what this type contains. Fields may be incomplete

{
  "id": "0",
  "username": "",
  "global_name": null,
  "avatar": null,
  "bot": false,
  "system": false,
  "mfa_enabled": false,
  "banner": null,
  "accent_color": null,
  "locale": null,
  "verified": null,
  "email": null,
  "flags": 0,
  "premium_type": 0,
  "public_flags": null,
  "member": null
}

Serenity.AuditLogs

A audit log in Discord, as represented by AntiRaid. Internal fields are subject to change

Refer to serenity::model::guild::audit_log::AuditLogs for more documentation on what this type contains. Fields may be incomplete

Serenity.AuditLogs.Action

An audit log action in Discord, as represented by AntiRaid. Internal fields are subject to change

Refer to serenity::model::guild::audit_log::Action for more documentation on what this type contains. Fields may be incomplete

1

Serenity.GuildChannel

A guild channel in Discord, as represented by AntiRaid. Internal fields are subject to change

Refer to serenity::model::channel::GuildChannel for more documentation on what this type contains. Fields may be incomplete

{
  "id": "0",
  "bitrate": null,
  "parent_id": null,
  "guild_id": "0",
  "type": 0,
  "owner_id": null,
  "last_message_id": null,
  "last_pin_timestamp": null,
  "name": "",
  "permission_overwrites": [],
  "position": 0,
  "topic": null,
  "user_limit": null,
  "nsfw": false,
  "rate_limit_per_user": null,
  "rtc_region": null,
  "video_quality_mode": null,
  "message_count": null,
  "member_count": null,
  "thread_metadata": null,
  "member": null,
  "default_auto_archive_duration": null,
  "permissions": null,
  "flags": 0,
  "total_message_sent": null,
  "available_tags": [],
  "applied_tags": [],
  "default_reaction_emoji": null,
  "default_thread_rate_limit_per_user": null,
  "status": null,
  "default_sort_order": null,
  "default_forum_layout": null
}

Serenity.PermissionOverwrite

A permission overwrite in Discord, as represented by AntiRaid. Internal fields are subject to change

Refer to serenity::model::channel::PermissionOverwrite for more documentation on what this type contains. Fields may be incomplete

{
  "allow": "2111062325329919",
  "deny": "2111062325329919",
  "id": "0",
  "type": 0
}

Serenity.ForumEmoji

A forum emoji in Discord, as represented by AntiRaid. Internal fields are subject to change

Refer to serenity::model::channel::ForumEmoji for more documentation on what this type contains. Fields may be incomplete

{
  "emoji_id": "0",
  "emoji_name": null
}

GetAuditLogOptions

Options for getting audit logs in Discord

{
  "action_type": 1,
  "user_id": "0",
  "before": "0",
  "limit": 0
}

Fields

GetChannelOptions

Options for getting a channel in Discord

{
  "channel_id": "0"
}

Fields

  • channel_id (string): The channel ID to get

EditChannelOptions

Options for editing a channel in Discord

{
  "channel_id": "0",
  "reason": "",
  "name": "my-channel",
  "type": 0,
  "position": 7,
  "topic": "My channel topic",
  "nsfw": true,
  "rate_limit_per_user": 5,
  "bitrate": null,
  "permission_overwrites": null,
  "parent_id": "0",
  "rtc_region": "us-west",
  "video_quality_mode": 1,
  "default_auto_archive_duration": 1440,
  "flags": 18,
  "available_tags": null,
  "default_reaction_emoji": {
    "emoji_id": "0",
    "emoji_name": null
  },
  "default_thread_rate_limit_per_user": null,
  "default_sort_order": null,
  "default_forum_layout": null
}

Fields

  • channel_id (string): The channel ID to edit
  • reason (string): The reason for editing the channel
  • name (string?): The name of the channel
  • type (string?): The type of the channel
  • position (number?): The position of the channel
  • topic (string?): The topic of the channel
  • nsfw (bool?): Whether the channel is NSFW
  • rate_limit_per_user (number?): The rate limit per user/Slow mode of the channel
  • bitrate (number?): The bitrate of the channel
  • permission_overwrites ({Serenity.PermissionOverwrite}?): The permission overwrites of the channel
  • parent_id (string??): The parent ID of the channel
  • rtc_region (string??): The RTC region of the channel
  • video_quality_mode (string?): The video quality mode of the channel
  • default_auto_archive_duration (string?): The default auto archive duration of the channel
  • flags (string?): The flags of the channel
  • available_tags ({Serenity.ForumTag}?): The available tags of the channel
  • default_reaction_emoji (Serenity.ForumEmoji??): The default reaction emoji of the channel
  • default_thread_rate_limit_per_user (number?): The default thread rate limit per user
  • default_sort_order (string?): The default sort order of the channel
  • default_forum_layout (string?): The default forum layout of the channel

EditThreadOptions

Options for editing a thread in Discord

{
  "channel_id": "0",
  "reason": "",
  "name": "my-thread",
  "archived": false,
  "auto_archive_duration": 1440,
  "locked": false,
  "invitable": true,
  "rate_limit_per_user": 5,
  "flags": 18,
  "applied_tags": null
}

Fields

  • channel_id (string): The channel ID to edit
  • reason (string): The reason for editing the channel
  • name (string?): The name of the thread
  • archived (bool?): Whether the thread is archived
  • auto_archive_duration (string?): The auto archive duration of the thread
  • locked (bool?): Whether the thread is locked
  • invitable (bool?): Whether the thread is invitable
  • rate_limit_per_user (number?): The rate limit per user/Slow mode of the thread
  • flags (string?): The flags of the thread
  • applied_tags ({Serenity.ForumTag}?): The applied tags of the thread

DeleteChannelOption

Options for deleting a channel in Discord

{
  "channel_id": "0",
  "reason": "My reason here"
}

Fields

  • channel_id (string): The channel ID to delete
  • reason (string): The reason for deleting the channel

CreateMessageEmbedField

A field in a message embed

{
  "name": "",
  "value": "",
  "inline": false
}

Fields

  • name (string): The name of the field
  • value (string): The value of the field
  • inline (bool): Whether the field is inline

CreateMessageEmbedAuthor

An author in a message embed

{
  "name": "",
  "url": null,
  "icon_url": null
}

Fields

  • name (string): The name of the author
  • url (string?): The URL of the author
  • icon_url (string?): The icon URL of the author

CreateMessageEmbedFooter

A footer in a message embed

{
  "text": "",
  "icon_url": null
}

Fields

  • text (string): The text of the footer
  • icon_url (string?): The icon URL of the footer

CreateMessageEmbed

An embed in a message

{
  "title": null,
  "description": null,
  "url": null,
  "timestamp": null,
  "color": null,
  "footer": null,
  "image": null,
  "thumbnail": null,
  "author": null,
  "fields": null
}

Fields

CreateMessageAttachment

An attachment in a message

{
  "filename": "",
  "description": null,
  "content": []
}

Fields

  • filename (string): The filename of the attachment
  • description (string?): The description (if any) of the attachment
  • content ({byte}): The content of the attachment

CreateMessage

Options for creating a message in Discord

{
  "embeds": null,
  "content": null,
  "attachments": null
}

Fields

MessageHandle

A handle to a message in Discord, as represented by AntiRaid. Internal fields are subject to change

Methods

MessageHandle:data
function MessageHandle:data(): any

Gets the data of the message

Returns
  • data (any): The inner data of the message

DiscordExecutor

DiscordExecutor allows templates to access/use the Discord API in a sandboxed form.

Methods

DiscordExecutor:get_audit_logs
function DiscordExecutor:get_audit_logs(data: GetAuditLogOptions): 

Gets the audit logs

Parameters
Returns
  • SerenityAuditLogs (): The audit log entry
DiscordExecutor:get_channel
function DiscordExecutor:get_channel(data: GetChannelOptions): 

Gets a channel

Parameters
Returns
  • Serenity.GuildChannel (): The guild channel
DiscordExecutor:edit_channel
function DiscordExecutor:edit_channel(data: EditChannelOptions): 

Edits a channel

Parameters
Returns
  • Serenity.GuildChannel (): The guild channel
DiscordExecutor:edit_thread
function DiscordExecutor:edit_thread(data: EditThreadOptions): 

Edits a thread

Parameters
Returns
  • Serenity.GuildChannel (): The guild channel
DiscordExecutor:delete_channel
function DiscordExecutor:delete_channel(data: DeleteChannelOption): 

Deletes a channel

Parameters
Returns
  • Serenity.GuildChannel (): The guild channel
DiscordExecutor:create_message
function DiscordExecutor:create_message(data: CreateMessage): 

Creates a message

Parameters
Returns
  • MessageHandle (): The message

Methods

new

function new(token: TemplateContext): DiscordExecutor

Parameters

Returns


@antiraid/interop

This plugin allows interoperability with AntiRaid and controlled interaction with the low-levels of AntiRaid templating subsystem.

Types

null

null is a special value that represents nothing. It is often used in AntiRaid instead of nil due to issues regarding existence etc. null is not equal to nil but is also an opaque type.

array_metatable

array_metatable is a special metatable that is used to represent arrays across the Lua-AntiRaid templating subsystem boundary. This metatable must be set on all arrays over this boundary and is required to ensure AntiRaid knows the value you're sending it is actually an array and not an arbitrary Luau table.

Methods

array_metatable

function array_metatable(): table

Returns the array metatable.

Returns

  • array_metatable (table): The array metatable.

null

function null(): null

Returns the null value.

Returns

  • null (null): The null value.

memusage

function memusage(): f64

Returns the current memory usage of the Lua VM.

Returns

  • memory_usage (f64): The current memory usage, in bytes, of the Lua VM.

guild_id

function guild_id(): string

Returns the current guild ID of the Lua VM.

Returns

  • guild_id (string): The current guild ID.

current_user

function current_user(): Serenity.User

Returns the current user of the Lua VM.

Returns


@antiraid/img_captcha

This plugin allows for the creation of text/image CAPTCHA's with customizable filters which can be useful in protecting against bots.

Types

CaptchaConfig

Captcha configuration. See examples for the arguments

{
  "char_count": 5,
  "filters": [
    {
      "filter": "Noise",
      "prob": 0.1
    },
    {
      "filter": "Wave",
      "f": 4.0,
      "amp": 2.0,
      "d": "horizontal"
    },
    {
      "filter": "Line",
      "p1": [
        1.0,
        0.0
      ],
      "p2": [
        20.0,
        20.0
      ],
      "thickness": 2.0,
      "color": {
        "r": 0,
        "g": 30,
        "b": 100
      }
    },
    {
      "filter": "RandomLine"
    },
    {
      "filter": "Grid",
      "y_gap": 30,
      "x_gap": 10
    },
    {
      "filter": "ColorInvert"
    }
  ],
  "viewbox_size": [
    512,
    512
  ],
  "set_viewbox_at_idx": null
}

Fields

  • filter (string): The name of the filter to use. See example for the parameters to pass for the filter as well as https://github.com/Anti-Raid/captcha.

Methods

new

function new(config: CaptchaConfig): {u8}

Creates a new CAPTCHA with the given configuration.

Parameters

  • config (CaptchaConfig): The configuration to use for the CAPTCHA.

Returns

  • captcha ({u8}): The created CAPTCHA object.

@antiraid/kv

Utilities for key-value operations.

Types

KvRecord

KvRecord represents a key-value record with metadata.

{
  "key": "",
  "value": null,
  "exists": false,
  "created_at": null,
  "last_updated_at": null
}

Fields

  • key (string): The key of the record.
  • value (any): The value of the record.
  • exists (bool): Whether the record exists.
  • created_at (datetime): The time the record was created.
  • last_updated_at (datetime): The time the record was last updated.

KvExecutor

KvExecutor allows templates to get, store and find persistent data within a server.

Methods

KvExecutor:find
function KvExecutor:find(key: string)
Parameters
  • key (string): The key to search for. % matches zero or more characters; _ matches a single character. To search anywhere in a string, surround {KEY} with %, e.g. %{KEY}%
KvExecutor:get
function KvExecutor:get(key: string)
Parameters
  • key (string): The key to get.
Returns
  • value (any): The value of the key.- exists (bool): Whether the key exists.
KvExecutor:getrecord
function KvExecutor:getrecord(key: string): KvRecord
Parameters
  • key (string): The key to get.
Returns
  • record (KvRecord): The record of the key.
KvExecutor:set
function KvExecutor:set(key: string, value: any)
Parameters
  • key (string): The key to set.
  • value (any): The value to set.
KvExecutor:delete
function KvExecutor:delete(key: string)
Parameters
  • key (string): The key to delete.

Methods

new

function new(token: TemplateContext): KvExecutor

Parameters

Returns


@antiraid/page

Create a page dedicated to your template on a server.

Types

Setting.Column

A setting column

{
  "id": "created_at",
  "name": "Created At",
  "description": "The time the record was created.",
  "column_type": {
    "Scalar": {
      "inner": {
        "TimestampTz": {}
      }
    }
  },
  "nullable": false,
  "suggestions": {
    "None": {}
  },
  "secret": false,
  "ignored_for": [
    "Create",
    "Update"
  ]
}

Fields

  • id (string): The ID of the column.
  • name (string): The name of the column.
  • description (string): The description of the column.
  • column_type (Setting.Column.ColumnType): The type of the column.
  • nullable (bool): Whether the column can be null.
  • suggestions (Setting.Column.ColumnSuggestion): The suggestions for the column.
  • secret (bool): Whether the column is secret.
  • ignored_for ({OperationType}): The operations that the column is ignored for [read-only]. It is not guaranteed that ignored field are sent to the template.

Setting

A setting

{
  "id": "setting_id",
  "name": "Setting Name",
  "description": "Setting Description",
  "primary_key": "id",
  "title_template": "{col1} - {col2}",
  "columns": [
    {
      "id": "col1",
      "name": "Column 1",
      "description": "Column 1 desc",
      "column_type": {
        "Scalar": {
          "inner": {
            "String": {
              "min_length": 120,
              "max_length": 120,
              "allowed_values": [
                "allowed_value"
              ],
              "kind": {
                "Normal": {}
              }
            }
          }
        }
      },
      "nullable": false,
      "suggestions": {
        "Static": {
          "suggestions": [
            "suggestion"
          ]
        }
      },
      "secret": false,
      "ignored_for": [
        "Create"
      ]
    },
    {
      "id": "col2",
      "name": "Column 2",
      "description": "Column 2 desc",
      "column_type": {
        "Array": {
          "inner": {
            "String": {
              "min_length": 120,
              "max_length": 120,
              "allowed_values": [
                "allowed_value"
              ],
              "kind": {
                "Token": {
                  "default_length": 10
                }
              }
            }
          }
        }
      },
      "nullable": false,
      "suggestions": {
        "Static": {
          "suggestions": [
            "suggestion"
          ]
        }
      },
      "secret": false,
      "ignored_for": [
        "View"
      ]
    },
    {
      "id": "col3",
      "name": "Column 3",
      "description": "Column 3 desc",
      "column_type": {
        "Array": {
          "inner": {
            "String": {
              "min_length": 120,
              "max_length": 120,
              "allowed_values": [
                "allowed_value"
              ],
              "kind": {
                "Textarea": {
                  "ctx": "anything"
                }
              }
            }
          }
        }
      },
      "nullable": false,
      "suggestions": {
        "Static": {
          "suggestions": [
            "suggestion"
          ]
        }
      },
      "secret": false,
      "ignored_for": [
        "Create"
      ]
    },
    {
      "id": "col4",
      "name": "Column 4",
      "description": "Column 4 desc",
      "column_type": {
        "Array": {
          "inner": {
            "String": {
              "min_length": 120,
              "max_length": 120,
              "allowed_values": [
                "allowed_value"
              ],
              "kind": {
                "TemplateRef": {}
              }
            }
          }
        }
      },
      "nullable": false,
      "suggestions": {
        "Static": {
          "suggestions": [
            "suggestion"
          ]
        }
      },
      "secret": false,
      "ignored_for": [
        "Create"
      ]
    },
    {
      "id": "col5",
      "name": "Column 5",
      "description": "Column 5 desc",
      "column_type": {
        "Array": {
          "inner": {
            "String": {
              "min_length": 120,
              "max_length": 120,
              "allowed_values": [
                "allowed_value"
              ],
              "kind": {
                "KittycatPermission": {}
              }
            }
          }
        }
      },
      "nullable": false,
      "suggestions": {
        "Static": {
          "suggestions": [
            "suggestion"
          ]
        }
      },
      "secret": false,
      "ignored_for": [
        "Create"
      ]
    },
    {
      "id": "col6",
      "name": "Column 6",
      "description": "Column 6 desc",
      "column_type": {
        "Array": {
          "inner": {
            "String": {
              "min_length": 120,
              "max_length": 120,
              "allowed_values": [
                "allowed_value"
              ],
              "kind": {
                "User": {}
              }
            }
          }
        }
      },
      "nullable": false,
      "suggestions": {
        "Static": {
          "suggestions": [
            "suggestion"
          ]
        }
      },
      "secret": false,
      "ignored_for": [
        "Create"
      ]
    },
    {
      "id": "col7",
      "name": "Column 7",
      "description": "Column 7 desc",
      "column_type": {
        "Array": {
          "inner": {
            "String": {
              "min_length": 120,
              "max_length": 120,
              "allowed_values": [
                "allowed_value"
              ],
              "kind": {
                "Role": {}
              }
            }
          }
        }
      },
      "nullable": false,
      "suggestions": {
        "Static": {
          "suggestions": [
            "suggestion"
          ]
        }
      },
      "secret": false,
      "ignored_for": [
        "Create"
      ]
    },
    {
      "id": "col8",
      "name": "Column 8",
      "description": "Column 8 desc",
      "column_type": {
        "Array": {
          "inner": {
            "String": {
              "min_length": 120,
              "max_length": 120,
              "allowed_values": [
                "allowed_value"
              ],
              "kind": {
                "Channel": {
                  "needed_bot_permissions": "2048",
                  "allowed_channel_types": [
                    0,
                    2
                  ]
                }
              }
            }
          }
        }
      },
      "nullable": false,
      "suggestions": {
        "Static": {
          "suggestions": [
            "suggestion"
          ]
        }
      },
      "secret": false,
      "ignored_for": [
        "Update"
      ]
    },
    {
      "id": "col9",
      "name": "Column 9",
      "description": "Column 9 desc",
      "column_type": {
        "Scalar": {
          "inner": {
            "Integer": {}
          }
        }
      },
      "nullable": false,
      "suggestions": {
        "Static": {
          "suggestions": [
            "suggestion"
          ]
        }
      },
      "secret": false,
      "ignored_for": [
        "Update"
      ]
    },
    {
      "id": "col10",
      "name": "Column 10",
      "description": "Column 10 desc",
      "column_type": {
        "Scalar": {
          "inner": {
            "Boolean": {}
          }
        }
      },
      "nullable": false,
      "suggestions": {
        "Static": {
          "suggestions": [
            "suggestion"
          ]
        }
      },
      "secret": false,
      "ignored_for": [
        "Update"
      ]
    },
    {
      "id": "created_at",
      "name": "Created At",
      "description": "The time the record was created.",
      "column_type": {
        "Scalar": {
          "inner": {
            "TimestampTz": {}
          }
        }
      },
      "nullable": false,
      "suggestions": {
        "None": {}
      },
      "secret": false,
      "ignored_for": [
        "Create",
        "Update"
      ]
    }
  ],
  "operations": []
}

Fields

  • id (string): The ID of the setting.
  • name (string): The name of the setting.
  • description (string): The description of the setting.
  • operations ({OperationType}): The operations that can be performed on the setting. Note that when using add_settings, you must pass this as the second argument to settings and ignore this field.
  • primary_key (string): The primary key of the setting that UNIQUELY identifies the row. When Delete is called, the value of this is what will be sent in the event. On Update, this key MUST also exist (otherwise, the template MUST error out)
  • title_template (string): The template for the title of each row for the setting. This is a string that can contain placeholders for columns. The placeholders are in the form of {column_id}. For example, if you have a column with ID col1 and another with ID col2, you can have a title template of {col1} - {col2} etc..
  • columns ({Setting.Column}): The columns of the setting.

CreatePageSetting

A table containing a setting for a page

Fields

  • setting (Setting): The setting to add to the page.
  • operations ({string}): The operations to perform on the setting. Elements of the array can be either View, Create, Update or Delete.

CreatePage

An intermediary structure for creating a page for a template

Fields

  • page_id (string): The ID of the page. This field can be updated ONLY if the page is not created yet with no current settings. The ID must not contain spaces, newlines, null characters, or tabs.
  • title (string): The title of the page. This field can be updated ONLY if the page is not created yet.
  • description (string): The description of the page. This field can be updated ONLY if the page is not created yet.
  • settings (table): The settings of the page. This field is read-only.
  • is_created (bool): Whether the page is created. This field is read-only.
  • template (Template): The template of the page. This field is read-only.

Methods

CreatePage:add_setting
function CreatePage:add_setting(setting: CreatePageSetting): nil
Parameters
Returns

Enums

Setting.Column.InnerColumnType

The inner column type of the value

Setting.Column.ColumnType

The type of a setting column

Variants

Setting.Column.ColumnType::Scalar

A scalar column type.

Fields

Setting.Column.ColumnType::Array

An array column type.

Fields

Methods

create_page

function create_page(token: TemplateContext): CreatePage

Parameters

Returns

  • create_page (CreatePage): An empty created page.

@antiraid/permissions

Utilities for handling permission checks.

Types

PermissionResult

PermissionResult is an internal type containing the status of a permission check in AntiRaid. The exact contents are undocumented as of now

LuaPermissionResult

LuaPermissionResult is a type containing the status of a permission check in AntiRaid with prior parsing done for Lua.

{
  "result": {
    "var": "Ok"
  },
  "is_ok": true,
  "code": "Ok",
  "markdown": ""
}

Fields

  • result (PermissionResult): The raw/underlying result of the permission check.
  • is_ok (bool): Whether the permission check was successful.
  • code (string): The code of the permission check.
  • markdown (string): The markdown representation of the permission check.

PermissionCheck

PermissionCheck is a type containing the permissions to check for a user.

{
  "kittycat_perms": [],
  "native_perms": [],
  "inner_and": false
}

Fields

  • kittycat_perms ({Permission}): The kittycat permissions needed to run the command.
  • native_perms ({string}): The native permissions needed to run the command.
  • inner_and (bool): Whether or not the perms are ANDed (all needed) or OR'd (at least one)

Permission

Permission is the primitive permission type used by AntiRaid. See https://github.com/InfinityBotList/kittycat for more information

{
  "namespace": "moderation",
  "perm": "ban",
  "negator": false
}

Fields

  • namespace (string): The namespace of the permission.
  • perm (string): The permission bit on the namespace.
  • negator (bool): Whether the permission is a negator permission or not

Methods

permission_from_string

function permission_from_string(perm_string: string): Permission

Returns a Permission object from a string.

Parameters

  • perm_string (string): The string to parse into a Permission object.

Returns

  • permission (Permission): The parsed Permission object.

permission_to_string

function permission_to_string(permission: Permission): string

Returns a string from a Permission object.

Parameters

  • permission (Permission): The Permission object to parse into a string.

Returns

  • perm_string (string): The parsed string.

has_perm

function has_perm(permissions: {Permission}, permission: Permission): bool

Checks if a list of permissions in Permission object form contains a specific permission.

Parameters

Returns

  • has_perm (bool): Whether the permission is present in the list of permissions as per kittycat rules.

has_perm_str

function has_perm_str(permissions: {string}, permission: string): bool

Checks if a list of permissions in canonical string form contains a specific permission.

Parameters

  • permissions ({string}): The list of permissions
  • permission (string): The permission to check for.

Returns

  • has_perm (bool): Whether the permission is present in the list of permissions as per kittycat rules.

check_perms

function check_perms(check: PermissionCheck, member_native_perms: Permissions, member_kittycat_perms: {Permission}): LuaPermissionResult

Checks if a permission check passes.

Parameters

  • check (PermissionCheck): The permission check to evaluate.
  • member_native_perms (Permissions): The native permissions of the member.
  • member_kittycat_perms ({Permission}): The kittycat permissions of the member.

Returns


@antiraid/typesext

Extra types used by Anti-Raid Lua templating subsystem to either add in common functionality such as streams or handle things like u64/i64 types performantly.

Types

LuaStream

LuaStream provides a stream implementation. This is returned by MessageHandle's await_component_interaction for instance for handling button clicks/select menu choices etc.

Methods

LuaStream:next
function LuaStream:next(): <T>

Returns the next item in the stream.

Returns
  • item (): The next item in the stream.
LuaStream:for_each
function LuaStream:for_each(callback: function)

Executes a callback for every entry in the stream.

Parameters
  • callback (function): The callback to execute for each entry.

MultiOption

MultiOption allows distinguishing between null and empty fields. Use the value to show both existence and value (Some(Some(value))) an empty object to show existence (Some(None)) or null to show neither (None)

U64

U64 is a 64-bit unsigned integer type. Implements Add/Subtract/Multiply/Divide/Modulus/Power/Integer Division/Equality/Comparison (Lt/Le and its complements Gt/Ge) and ToString with a type name of U64

Methods

U64:to_ne_bytes
function U64:to_ne_bytes(): {u8}

Converts the U64 to a little-endian byte array.

Returns
  • bytes ({u8}): The little-endian byte array.
U64:from_ne_bytes
function U64:from_ne_bytes(bytes: {u8}): U64

Converts a little-endian byte array to a U64.

Parameters
  • bytes ({u8}): The little-endian byte array.
Returns
  • u64 (U64): The U64 value.
U64:to_le_bytes
function U64:to_le_bytes(): {u8}

Converts the U64 to a little-endian byte array.

Returns
  • bytes ({u8}): The little-endian byte array.
U64:from_le_bytes
function U64:from_le_bytes(bytes: {u8}): U64

Converts a little-endian byte array to a U64.

Parameters
  • bytes ({u8}): The little-endian byte array.
Returns
  • u64 (U64): The U64 value.
U64:to_be_bytes
function U64:to_be_bytes(): {u8}

Converts the U64 to a big-endian byte array.

Returns
  • bytes ({u8}): The big-endian byte array.
U64:from_be_bytes
function U64:from_be_bytes(bytes: {u8}): U64

Converts a big-endian byte array to a U64.

Parameters
  • bytes ({u8}): The big-endian byte array.
Returns
  • u64 (U64): The U64 value.
U64:to_i64
function U64:to_i64(): I64

Converts the U64 to an i64.

Returns
  • i64 (I64): The i64 value.

I64

I64 is a 64-bit signed integer type. Implements Add/Subtract/Multiply/Divide/Modulus/Power/Integer Division/Equality/Comparison (Lt/Le and its complements Gt/Ge) and ToString with a type name of I64

Methods

I64:to_ne_bytes
function I64:to_ne_bytes(): {u8}

Converts the I64 to a little-endian byte array.

Returns
  • bytes ({u8}): The little-endian byte array.
I64:from_ne_bytes
function I64:from_ne_bytes(bytes: {u8}): I64

Converts a little-endian byte array to a I64.

Parameters
  • bytes ({u8}): The little-endian byte array.
Returns
  • i64 (I64): The I64 value.
I64:to_le_bytes
function I64:to_le_bytes(): {u8}

Converts the I64 to a little-endian byte array.

Returns
  • bytes ({u8}): The little-endian byte array.
I64:from_le_bytes
function I64:from_le_bytes(bytes: {u8}): I64

Converts a little-endian byte array to a I64.

Parameters
  • bytes ({u8}): The little-endian byte array.
Returns
  • i64 (I64): The I64 value.
I64:to_be_bytes
function I64:to_be_bytes(): {u8}

Converts the I64 to a big-endian byte array.

Returns
  • bytes ({u8}): The big-endian byte array.
I64:from_be_bytes
function I64:from_be_bytes(bytes: {u8}): I64

Converts a big-endian byte array to a I64.

Parameters
  • bytes ({u8}): The big-endian byte array.
Returns
  • i64 (I64): The I64 value.
I64:to_u64
function I64:to_u64(): U64

Converts the I64 to a U64.

Returns
  • u64 (U64): The U64 value.

bitu64

bit32 but for U64 datatype. Note that bit64 is experimental and may not be properly documented at all times. When in doubt, reach for Luau's bit32 documentation and simply replace 31's with 63's

Methods

bitu64:band
function bitu64:band(values: {U64}): U64

Performs a bitwise AND operation on the given values.

Parameters
  • values ({U64}): The values to perform the operation on.
Returns
  • result (U64): The result of the operation.
bitu64:bnor
function bitu64:bnor(n: U64): U64

Performs a bitwise NOR operation on the given value.

Parameters
  • n (U64): The value to perform the operation on.
Returns
  • result (U64): The result of the operation.
bitu64:bor
function bitu64:bor(values: {U64}): U64

Performs a bitwise OR operation on the given values.

Parameters
  • values ({U64}): The values to perform the operation on.
Returns
  • result (U64): The result of the operation.
bitu64:bxor
function bitu64:bxor(values: {U64}): U64

Performs a bitwise XOR operation on the given values.

Parameters
  • values ({U64}): The values to perform the operation on.
Returns
  • result (U64): The result of the operation.
bitu64:btest
function bitu64:btest(values: {U64}): bool

Tests if the bitwise AND of the given values is not zero.

Parameters
  • values ({U64}): The values to perform the operation on.
Returns
  • result (bool): True if the bitwise AND of the values is not zero, false otherwise.
bitu64:extract
function bitu64:extract(n: U64, f: u64, w: u64): U64

Extracts a field from a value.

Parameters
  • n (U64): The value to extract the field from.
  • f (u64): The field to extract.
  • w (u64): The width of the field to extract.
Returns
  • result (U64): The extracted field.
bitu64:lrotate
function bitu64:lrotate(n: U64, i: i64): U64

Rotates a value left or right.

Parameters
  • n (U64): The value to rotate.
  • i (i64): The amount to rotate by.
Returns
  • result (U64): The rotated value.
bitu64:lshift
function bitu64:lshift(n: U64, i: i64): U64

Shifts a value left or right.

Parameters
  • n (U64): The value to shift.
  • i (i64): The amount to shift by.
Returns
  • result (U64): The shifted value.
bitu64:replace
function bitu64:replace(n: U64, v: U64, f: u64, w: u64): U64

Replaces a field in a value.

Parameters
  • n (U64): The value to replace the field in.
  • v (U64): The value to replace the field with.
  • f (u64): The field to replace.
  • w (u64): The width of the field to replace.
Returns
  • result (U64): The value with the field replaced.
bitu64:rrotate
function bitu64:rrotate(n: U64, i: i64): U64

Rotates a value left or right.

Parameters
  • n (U64): The value to rotate.
  • i (i64): The amount to rotate by.
Returns
  • result (U64): The rotated value.
bitu64:rshift
function bitu64:rshift(n: U64, i: i64): U64

Shifts a value left or right.

Parameters
  • n (U64): The value to shift.
  • i (i64): The amount to shift by.
Returns
  • result (U64): The shifted value.

Methods

U64

function U64(value: u64): U64

Creates a new U64.

Parameters

  • value (u64): The value of the U64.

Returns

  • u64 (U64): The U64 value.

I64

function I64(value: i64): I64

Creates a new I64.

Parameters

  • value (i64): The value of the I64.

Returns

  • i64 (I64): The I64 value.

Primitives

u8

type u8 = number

An unsigned 8-bit integer. Note: u8 arrays ({u8}) are often used to represent an array of bytes in AntiRaid

Constraints

  • range: The range of values this number can take on (accepted values: 0-255)

u16

type u16 = number

An unsigned 16-bit integer.

Constraints

  • range: The range of values this number can take on (accepted values: 0-65535)

u32

type u32 = number

An unsigned 32-bit integer.

Constraints

  • range: The range of values this number can take on (accepted values: 0-4294967295)

u64

type u64 = number

An unsigned 64-bit integer. Note that most, if not all, cases of i64 in the actual API are either string or the I64 custom type from typesext

Constraints

  • range: The range of values this number can take on (accepted values: 0-18446744073709551615)

i8

type i8 = number

A signed 8-bit integer.

Constraints

  • range: The range of values this number can take on (accepted values: -128-127)

i16

type i16 = number

A signed 16-bit integer.

Constraints

  • range: The range of values this number can take on (accepted values: -32768-32767)

i32

type i32 = number

A signed 32-bit integer.

Constraints

  • range: The range of values this number can take on (accepted values: -2147483648-2147483647)

i64

type i64 = number

A signed 64-bit integer. Note that most, if not all, cases of i64 in the actual API are either string or the I64 custom type from typesext

Constraints

  • range: The range of values this number can take on (accepted values: -9223372036854775808-9223372036854775807)

f32

type f32 = number

A 32-bit floating point number.

Constraints

  • range: The range of values this number can take on (accepted values: IEEE 754 single-precision floating point)

f64

type f64 = number

A 64-bit floating point number.

Constraints

  • range: The range of values this number can take on (accepted values: IEEE 754 double-precision floating point)

bool

type bool = boolean

A boolean value.


char

type char = string

A single Unicode character.

Constraints

  • length: The length of the string (accepted values: 1)

string

type string = string

A UTF-8 encoded string.

Constraints

  • encoding: Accepted character encoding (accepted values: UTF-8 only)

function

type function = function

A Lua function.


Methods

array

function array(...: unknown): {unknown}

Helper method to create an array from a list of tables, setting the array_metatable on the result.

Parameters

  • ... (unknown): The elements used to form the array.

Returns

Types

Event

An event that has been dispatched to the template. This is what args is in the template.

Fields

  • title (string): The title name of the event.
  • base_name (string): The base name of the event.
  • name (string): The name of the event.
  • data (unknown): The data of the event.
  • is_deniable (boolean): Whether the event can be denied.
  • uid (string): The unique identifier ID of the event. Will be guaranteed to be unique at a per-guild level.
  • author (string?): The author of the event, if any. If there is no known author, this field will either be nil or null.

TemplatePragma

TemplatePragma contains the pragma of the template. Note that the list of fields below in non-exhaustive as templates can define extra fields on the pragma as well

{
  "lang": "lua",
  "allowed_caps": []
}

Fields

  • lang (string): The language of the template.
  • allowed_caps ({string}): The allowed capabilities provided to the template.

TemplateData

TemplateData is a struct that represents the data associated with a template token. It is used to store the path and pragma of a template token.

{
  "path": "test",
  "template": {
    "Named": "foo"
  },
  "pragma": {
    "lang": "lua",
    "allowed_caps": []
  }
}

Fields

  • path (string): The path of the template token.
  • pragma (TemplatePragma): The pragma of the template.

TemplateContext

TemplateContext is a struct that represents the context of a template. Stores 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 security purposes.

Fields

  • template_data (TemplateData): The data associated with the template.