Lua option table. Field names match the corresponding DiscordLua option type when one exists.
animated
any
required
Passed through to the implementation as written.
Formatters.emoji
Signature
Formatters.emoji(name, id, animated)
Name
Type
Required
Behavior
name
any
required
Passed through to the implementation as written.
id
string
required
Snowflake id string.
animated
any
required
Passed through to the implementation as written.
Formatters.time
Signature
Formatters.time(timeOrSeconds, style)
Name
Type
Required
Behavior
timeOrSeconds
any
required
Passed through to the implementation as written.
style
any
optional
Passed through to the implementation as written.
Formatters.bold
Signature
Formatters.bold(content)
Name
Type
Required
Behavior
content
string|table
required
Message content string, or a send/reply payload table.
Formatters.italic
Signature
Formatters.italic(content)
Name
Type
Required
Behavior
content
string|table
required
Message content string, or a send/reply payload table.
Formatters.underline
Signature
Formatters.underline(content)
Name
Type
Required
Behavior
content
string|table
required
Message content string, or a send/reply payload table.
Formatters.strikethrough
Signature
Formatters.strikethrough(content)
Name
Type
Required
Behavior
content
string|table
required
Message content string, or a send/reply payload table.
Formatters.spoiler
Signature
Formatters.spoiler(content)
Name
Type
Required
Behavior
content
string|table
required
Message content string, or a send/reply payload table.
Formatters.inlineCode
Signature
Formatters.inlineCode(content)
Name
Type
Required
Behavior
content
string|table
required
Message content string, or a send/reply payload table.
Formatters.codeBlock
Signature
Formatters.codeBlock(languageOrContent, content)
Name
Type
Required
Behavior
languageOrContent
string|table
required
Message content string, or a send/reply payload table.
content
string|table
required
Message content string, or a send/reply payload table.
Formatters.quote
Signature
Formatters.quote(content)
Name
Type
Required
Behavior
content
string|table
required
Message content string, or a send/reply payload table.
Formatters.blockQuote
Signature
Formatters.blockQuote(content)
Name
Type
Required
Behavior
content
string|table
required
Message content string, or a send/reply payload table.
Formatters.hyperlink
Signature
Formatters.hyperlink(content, url, title)
Name
Type
Required
Behavior
content
string|table
required
Message content string, or a send/reply payload table.
url
any
required
Passed through to the implementation as written.
title
any
required
Passed through to the implementation as written.
Formatters.hideLinkEmbed
Signature
Formatters.hideLinkEmbed(url)
Name
Type
Required
Behavior
url
any
required
Passed through to the implementation as written.
Formatters.heading
Signature
Formatters.heading(content, level)
Name
Type
Required
Behavior
content
string|table
required
Message content string, or a send/reply payload table.
level
any
required
Passed through to the implementation as written.
Formatters.subtext
Signature
Formatters.subtext(content)
Name
Type
Required
Behavior
content
string|table
required
Message content string, or a send/reply payload table.
Formatters.escapeEscape
Signature
Formatters.escapeEscape(text)
Name
Type
Required
Behavior
text
any
required
Passed through to the implementation as written.
Formatters.escapeCodeBlock
Signature
Formatters.escapeCodeBlock(text)
Name
Type
Required
Behavior
text
any
required
Passed through to the implementation as written.
Formatters.escapeInlineCode
Signature
Formatters.escapeInlineCode(text)
Name
Type
Required
Behavior
text
any
required
Passed through to the implementation as written.
Formatters.escapeItalic
Signature
Formatters.escapeItalic(text)
Name
Type
Required
Behavior
text
any
required
Passed through to the implementation as written.
Formatters.escapeBold
Signature
Formatters.escapeBold(text)
Name
Type
Required
Behavior
text
any
required
Passed through to the implementation as written.
Formatters.escapeUnderline
Signature
Formatters.escapeUnderline(text)
Name
Type
Required
Behavior
text
any
required
Passed through to the implementation as written.
Formatters.escapeStrikethrough
Signature
Formatters.escapeStrikethrough(text)
Name
Type
Required
Behavior
text
any
required
Passed through to the implementation as written.
Formatters.escapeSpoiler
Signature
Formatters.escapeSpoiler(text)
Name
Type
Required
Behavior
text
any
required
Passed through to the implementation as written.
Formatters.escapeHeading
Signature
Formatters.escapeHeading(text)
Name
Type
Required
Behavior
text
any
required
Passed through to the implementation as written.
Formatters.escapeBulletedList
Signature
Formatters.escapeBulletedList(text)
Name
Type
Required
Behavior
text
any
required
Passed through to the implementation as written.
Formatters.escapeNumberedList
Signature
Formatters.escapeNumberedList(text)
Name
Type
Required
Behavior
text
any
required
Passed through to the implementation as written.
Formatters.escapeMaskedLink
Signature
Formatters.escapeMaskedLink(text)
Name
Type
Required
Behavior
text
any
required
Passed through to the implementation as written.
Formatters.escapeMarkdown
Signature
Formatters.escapeMarkdown(text, options)
Name
Type
Required
Behavior
text
any
required
Passed through to the implementation as written.
options
table
optional
Lua option table. Field names match the corresponding DiscordLua option type when one exists.
discord.util
The same helpers are also exported on the package root: discord.parseEmoji, discord.resolveColor, discord.resolveImage, discord.cleanContent, discord.fetchRecommendedShardCount, and the other names listed below.
util.class
Signature
discord.util.class(name)
Define a DiscordLua class table with callable construction and :new.
Name
Type
Required
Behavior
name
any
required
Passed through to the implementation as written.
util.subclass
Signature
discord.util.subclass(name, parent)
Performs subclass on this util. Call it from bot code when you need that operation on the current object.
Name
Type
Required
Behavior
name
any
required
Passed through to the implementation as written.
parent
any
required
Passed through to the implementation as written.
util.properties
Signature
discord.util.properties(cls, names)
Performs properties on this util. Call it from bot code when you need that operation on the current object.
Name
Type
Required
Behavior
cls
any
required
Passed through to the implementation as written.
names
any
required
Passed through to the implementation as written.
util.defineProperty
Signature
discord.util.defineProperty(cls, name, fn)
Performs define property on this util. Call it from bot code when you need that operation on the current object.
Name
Type
Required
Behavior
cls
any
required
Passed through to the implementation as written.
name
any
required
Passed through to the implementation as written.
fn
any
required
Passed through to the implementation as written.
util.isMethod
Signature
discord.util.isMethod(cls, name)
Predicate that returns whether this util matches isMethod. Use it to branch before calling type-specific methods.
Name
Type
Required
Behavior
cls
any
required
Passed through to the implementation as written.
name
any
required
Passed through to the implementation as written.
util.hasProperty
Signature
discord.util.hasProperty(target, name)
Performs has property on this util. Call it from bot code when you need that operation on the current object.
Name
Type
Required
Behavior
target
any
required
Passed through to the implementation as written.
name
any
required
Passed through to the implementation as written.
util.inheritsProperties
Signature
discord.util.inheritsProperties(cls)
Predicate that returns whether this util matches inheritsProperties. Use it to branch before calling type-specific methods.
Name
Type
Required
Behavior
cls
any
required
Passed through to the implementation as written.
util.is_builder
Signature
discord.util.is_builder(value)
Predicate that returns whether this util matches is_builder. Use it to branch before calling type-specific methods.
Name
Type
Required
Behavior
value
any
required
Passed through to the implementation as written.
util.encode_one
Signature
discord.util.encode_one(value)
Encode a single Lua value for a REST body field.
Name
Type
Required
Behavior
value
any
required
Passed through to the implementation as written.
util.encode_list
Signature
discord.util.encode_list(list)
Encode an array of values for a REST body field.
Name
Type
Required
Behavior
list
any
required
Passed through to the implementation as written.
util.is_json_null
Signature
discord.util.is_json_null(value)
Predicate that returns whether this util matches is_json_null. Use it to branch before calling type-specific methods.
Name
Type
Required
Behavior
value
any
required
Passed through to the implementation as written.
util.encode_message
Signature
discord.util.encode_message(contentOrOptions)
Encode a message send/edit payload for REST.
Name
Type
Required
Behavior
contentOrOptions
table
optional
Lua option table. Field names match the corresponding DiscordLua option type when one exists.
util.encode_poll_media
Signature
discord.util.encode_poll_media(media)
Encode poll question or answer media.
Name
Type
Required
Behavior
media
any
required
Passed through to the implementation as written.
util.encode_poll_answer
Signature
discord.util.encode_poll_answer(answer)
Encode a single poll answer.
Name
Type
Required
Behavior
answer
any
required
Passed through to the implementation as written.
util.encode_poll
Signature
discord.util.encode_poll(options)
Encode a poll object for a message payload.
Name
Type
Required
Behavior
options
table
optional
Lua option table. Field names match the corresponding DiscordLua option type when one exists.
util.resolveRoleColor
Signature
discord.util.resolveRoleColor(value)
Resolve a role color value the same way role create/edit payloads accept it.
Name
Type
Required
Behavior
value
any
required
Passed through to the implementation as written.
util.resolveRoleColors
Signature
discord.util.resolveRoleColors(colors)
Resolve a table of role color fields before encoding a role payload.
Name
Type
Required
Behavior
colors
any
required
Passed through to the implementation as written.
util.encodeRoleOptions
Signature
discord.util.encodeRoleOptions(options)
Encode role create/edit options, including colors and permissions.
Name
Type
Required
Behavior
options
table
optional
Lua option table. Field names match the corresponding DiscordLua option type when one exists.
util.parse_hex
Signature
discord.util.parse_hex(text)
Parse a hex color string into a numeric color value.
Name
Type
Required
Behavior
text
any
required
Passed through to the implementation as written.
util.resolveCode
Signature
discord.util.resolveCode(data, pattern)
Extract an invite or template code from a URL or raw code string.
Name
Type
Required
Behavior
data
any
required
Passed through to the implementation as written.
pattern
any
required
Passed through to the implementation as written.
util.resolveInviteCode
Signature
discord.util.resolveInviteCode(data)
Extract a Discord invite code from a URL or raw code string.
Name
Type
Required
Behavior
data
any
required
Passed through to the implementation as written.
util.resolveGuildTemplateCode
Signature
discord.util.resolveGuildTemplateCode(data)
Extract a guild template code from a URL or raw code string.
Name
Type
Required
Behavior
data
any
required
Passed through to the implementation as written.
util.resolveBase64
Signature
discord.util.resolveBase64(data)
Encode binary or text input as a base64 string for REST image fields.
Name
Type
Required
Behavior
data
any
required
Passed through to the implementation as written.
util.resolveImage
Signature
discord.util.resolveImage(image)
Turn a file path, data URI, or buffer into the image data DiscordLua sends on REST.
Name
Type
Required
Behavior
image
any
required
Passed through to the implementation as written.
util.toSnakeCase
Signature
discord.util.toSnakeCase(text)
Convert a camelCase identifier into snake_case for REST body keys.
Name
Type
Required
Behavior
text
any
required
Passed through to the implementation as written.
util.flatten
Signature
discord.util.flatten(obj, props)
Flatten nested option tables before encoding a REST payload.
Name
Type
Required
Behavior
obj
any
required
Passed through to the implementation as written.
props
any
required
Passed through to the implementation as written.
util.decodeURIComponent
Signature
discord.util.decodeURIComponent(text)
Performs decode uricomponent on this util. Call it from bot code when you need that operation on the current object.
Name
Type
Required
Behavior
text
any
required
Passed through to the implementation as written.
util.parseEmoji
Signature
discord.util.parseEmoji(text)
Parse an emoji mention, unicode character, or name into a table DiscordLua can send.
Name
Type
Required
Behavior
text
any
required
Passed through to the implementation as written.
util.wrapCollectibles
Signature
discord.util.wrapCollectibles(data)
Performs wrap collectibles on this util. Call it from bot code when you need that operation on the current object.
Name
Type
Required
Behavior
data
any
required
Passed through to the implementation as written.
util.wrapSharedClientTheme
Signature
discord.util.wrapSharedClientTheme(data)
Performs wrap shared client theme on this util. Call it from bot code when you need that operation on the current object.
Name
Type
Required
Behavior
data
any
required
Passed through to the implementation as written.
util.resolvePartialEmoji
Signature
discord.util.resolvePartialEmoji(emoji)
Normalize an emoji mention or id/name table into a partial emoji payload.
Name
Type
Required
Behavior
emoji
any
required
Passed through to the implementation as written.
util.resolveGuildEmoji
Signature
discord.util.resolveGuildEmoji(guild, emoji)
Resolve a guild emoji from an id, mention, or emoji object.
Name
Type
Required
Behavior
guild
any
required
Passed through to the implementation as written.
emoji
any
required
Passed through to the implementation as written.
util.makeError
Signature
discord.util.makeError(data)
Construct a DiscordLua error object from a name and message.
Name
Type
Required
Behavior
data
any
required
Passed through to the implementation as written.
util.makePlainError
Signature
discord.util.makePlainError(err)
Construct a plain error table without Discord-specific fields.