@antiraid-core/plugins/datastores
API reference for @antiraid-core/plugins/datastores
@antiraid-core/plugins/datastores
Types
DataStore
A Base DataStore object.
Raw Type
--- A Base DataStore object.
type DataStore = {
--- The name of the DataStore
name: string,
--- Whether or not a specific operation needs capabilities (either \`\`datastore:{name}\`\` or \`\`datastore:{name}:{operation}\`\`)
needs_caps: (op: string) -> boolean,
--- The methods exposed by the DataStore
methods: () -> {string}
}
Prop | Type | Description |
---|---|---|
needs_caps | Whether or not a specific operation needs capabilities (either ``datastore:{name}`` or ``datastore:{name}:{operation}``) | |
methods | The methods exposed by the DataStore | |
name | The name of the DataStore |
CopyDataStore
Datastore to copy a KhronosValue to another KhronosValue
Raw Type
--- Datastore to copy a KhronosValue to another KhronosValue
type CopyDataStore = DataStore & {
copy: (...: ...khronosvalue.KhronosValue) -> khronosvalue.KhronosValue
}
Intersection with variants:
Variant 1
Variant 2
Prop | Type | Description |
---|---|---|
copy | - |
StatsStore
Datastore providing basic statistics
Raw Type
--- Datastore providing basic statistics
type StatsStore = DataStore & {
--- @yields
---
--- Returns the statistics of the bot.
stats: () -> {
total_cached_guilds: number,
total_guilds: number,
total_users: number,
last_started_at: datetime.DateTime
}
}
Intersection with variants:
Variant 1
Variant 2
LinksStore
Raw Type
type LinksStore = DataStore & {
links: () -> {
support_server: string,
api_url: string,
frontend_url: string,
docs_url: string
},
event_list: () -> {string}
}
Intersection with variants:
Variant 1
Variant 2
Spawn
Jobserver
Raw Type
-- Jobserver
type Spawn = {
--- The name of the job
name: string,
--- The data to be used in the job
data: khronosvalue.KhronosValue,
--- Whether or not to create the job if it does not exist
create: boolean,
--- Whether or not to execute the job immediately
execute: boolean,
--- If create is false, this is required
id: string?
}
Prop | Type | Description |
---|---|---|
name | The name of the job | |
data | The data to be used in the job | |
create | Whether or not to create the job if it does not exist | |
execute | Whether or not to execute the job immediately | |
id? | If create is false, this is required |
Statuses
Jobsrver Status
Raw Type
--- Jobsrver Status
type Statuses = {
level: string,
msg: string,
--- Timestamp in seconds
ts: number,
--- ptional list of fields to ignore
bot_display_ignore: {string}?,
-- Extra information as a key-value map
extra_info: {
[string]: khronosvalue.KhronosValue
}
}
Prop | Type | Description |
---|---|---|
level | - | |
msg | - | |
ts | Timestamp in seconds | |
bot_display_ignore? | ptional list of fields to ignore | |
extra_info | - |
Output
Raw Type
type Output = {
filename: string,
--- Temporary flag for migrations
perguild: boolean?
}
Job
Jobserver Job
Raw Type
--- Jobserver Job
type Job = {
id: string,
name: string,
output: Output?,
fields: {
[string]: any
},
statuses: {Statuses},
guild_id: string,
expiry: datetime.TimeDelta?,
state: string,
resumable: boolean,
created_at: datetime.DateTime,
job_path: string,
job_file_path: string?
}
Prop | Type | Description |
---|---|---|
id | - | |
name | - | |
output? | - | |
fields | - | |
statuses | - | |
guild_id | - | |
expiry? | - | |
state | - | |
resumable | - | |
created_at | - | |
job_path | - | |
job_file_path? | - |
JobServerStore
Raw Type
type JobServerStore = DataStore & {
--- @yields
---
--- Spawns a new job on the jobserver returning the job ID.
spawn: (spawn: Spawn) -> string,
--- @yields
---
--- Lists all jobs created for this server
---
--- If needs_statuses is set to true, then statuses are sent, otherwise
---- the statuses will be an empty table to reduce memory consumption
list: (needs_statuses: boolean?) -> {Job},
--- @yields
---
--- Lists all jobs created for this server with the given task name
---
--- If needs_statuses is set to true, then statuses are sent, otherwise
---- the statuses will be an empty table to reduce memory consumption
list_named: (name: string, needs_statuses: boolean?) -> {Job},
--- @yields
---
--- Gets a job from jobserver given its job ID
---
--- If needs_statuses is set to true, then statuses are sent, otherwise
---- the statuses will be an empty table to reduce memory consumption
get: (id: string, needs_statuses: boolean?) -> Job,
--- @yields
---
--- Deletes a job given its job ID
delete: (id: string) -> nil
}
Intersection with variants:
Variant 1
Variant 2
Prop | Type | Description |
---|---|---|
spawn | @yields Spawns a new job on the jobserver returning the job ID. | |
list | @yields Lists all jobs created for this serverIf needs_statuses is set to true, then statuses are sent, otherwise- the statuses will be an empty table to reduce memory consumption | |
list_named | @yields Lists all jobs created for this server with the given task nameIf needs_statuses is set to true, then statuses are sent, otherwise- the statuses will be an empty table to reduce memory consumption | |
get | @yields Gets a job from jobserver given its job IDIf needs_statuses is set to true, then statuses are sent, otherwise- the statuses will be an empty table to reduce memory consumption | |
delete | @yields Deletes a job given its job ID |
Template
A Template object.
Raw Type
--- A Template object.
type Template = {
--- The name of the template
name: string,
--- The events that trigger the template
events: {string},
--- The channel to send errors to
error_channel: string?,
--- The content of the template
content: LazyContent,
--- The language of the template
language: string,
--- The capabilities allowed for this template
allowed_caps: {string},
--- The date and time when the template was created
created_at: datetime.DateTime,
--- The date and time when the template was last updated
updated_at: datetime.DateTime,
--- Whether or not the template is paused
paused: boolean
}
Prop | Type | Description |
---|---|---|
name | The name of the template | |
events | The events that trigger the template | |
error_channel? | The channel to send errors to | |
content | The content of the template | |
language | The language of the template | |
allowed_caps | The capabilities allowed for this template | |
created_at | The date and time when the template was created | |
updated_at | The date and time when the template was last updated | |
paused | Whether or not the template is paused |
CreateTemplate
A CreateTemplate object.
Raw Type
--- A CreateTemplate object.
type CreateTemplate = {
--- The name of the template
name: string,
--- The events that trigger the template
events: {string},
--- The channel to send errors to
error_channel: string?,
--- The content of the template
content: {
[string]: string
} | LazyContent,
--- The language of the template
language: string,
--- The capabilities allowed for this template
allowed_caps: {string},
--- Whether or not the template is paused
paused: boolean
}
Prop | Type | Description |
---|---|---|
name | The name of the template | |
events | The events that trigger the template | |
error_channel? | The channel to send errors to | |
content | The content of the template | |
language | The language of the template | |
allowed_caps | The capabilities allowed for this template | |
paused | Whether or not the template is paused |
TemplateStore
A TemplateStore object.
Raw Type
--- A TemplateStore object.
type TemplateStore = DataStore & {
--- @yields
---
--- Lists all templates
list: () -> {Template},
--- @yields
---
--- Gets a template by name
get: (name: string) -> Template?,
--- @yields
---
--- Creates a new template
create: (template: CreateTemplate) -> nil,
--- @yields
---
--- Updates an existing template
update: (template: CreateTemplate) -> nil,
--- @yields
---
--- Deletes a template by name
delete: (name: string) -> nil
}
Intersection with variants:
Variant 1
Variant 2
Prop | Type | Description |
---|---|---|
list | @yields Lists all templates | |
get | @yields Gets a template by name | |
create | @yields Creates a new template | |
update | @yields Updates an existing template | |
delete | @yields Deletes a template by name |
DataStoreExecutor
A datastore executor holds DataStore's
Raw Type
--- A datastore executor holds DataStore's
type DataStoreExecutor = {
StatsStore: StatsStore?,
-- AntiRaid bot only (CLI not supported)
CopyDataStore: CopyDataStore?,
-- Should be present
LinksStore: LinksStore?,
-- AntiRaid bot only (CLI not supported)
JobServerStore: JobServerStore?,
-- AntiRaid bot only (CLI not supported)
TemplateStore: TemplateStore?
}
Prop | Type | Description |
---|---|---|
StatsStore? | - | |
CopyDataStore? | - | |
LinksStore? | - | |
JobServerStore? | - | |
TemplateStore? | - |
Plugin
Raw Type
type Plugin = DataStoreExecutor
Last updated on