LogoAntiRaid

@antiraid-ext/appcommands

API reference for @antiraid-ext/appcommands

@antiraid-ext/appcommands

Types

ParsedApplicationCommand

Parsed application command type created using `parseApplicationCommand`

Raw Type
--- Parsed application command type created using \`parseApplicationCommand\`
type ParsedApplicationCommand = {
	--- The base name of the slash command
	baseName: string,

	--- The command name list of the slash command
	nameList: {string},

	--- The inner data of the interaction
	data: discord.InteractionDataObject,

	--- The inner options of the slash command
	options: {ResolvedOption}
}
PropTypeDescription
baseName
The base name of the slash command
nameList
The command name list of the slash command
data
The inner data of the interaction
options
The inner options of the slash command

ResolvedOption

An option that is resolved from the slash command interaction options.

Note that Subcommand and SubcommandGroup will probably not be observed unless resolveOption is called directly outside

of parseApplicationCommand due to the extra parsing logic in `parseApplicationCommand` that unwraps subcommands and subcommand groups.

Raw Type
--- An option that is resolved from the slash command interaction options.
---
--- Note that Subcommand and SubcommandGroup will probably not be observed unless resolveOption is called directly outside
--- of parseApplicationCommand due to the extra parsing logic in \`parseApplicationCommand\` that unwraps subcommands and subcommand groups.
type ResolvedOption = {
	name: string,

	value: ResolvedValue,

	focused: boolean,

	isMentionable: boolean
}
PropTypeDescription
name
-
value
-
focused
-
isMentionable
-

ResolvedValue

Raw Type
type ResolvedValue = {
	kind: "Subcommand",

	options: {ResolvedOption}
} | {
	kind: "SubcommandGroup",

	options: {ResolvedOption}
} | {
	kind: "String",

	value: string
} | {
	kind: "Integer",

	value: number
} | {
	kind: "Boolean",

	value: boolean
} | {
	kind: "User",

	user: discord.UserObject,

	member: discord.GuildMemberObject?
} | {
	kind: "Channel",

	channel: discord.ChannelObject
} | {
	kind: "Role",

	role: discord.GuildRoleObject
} | {
	kind: "Number",

	value: number
} | {
	kind: "Attachment",

	attachment: discord.AttachmentObject
} | {
	kind: "Unresolved",

	type: "User" | "Channel" | "Role" | "Mentionable" | "Attachment",

	id: string
}

Union with variants:

Variant 1
PropTypeDescription
kind
'Subcommand'
-
options
-
Variant 2
PropTypeDescription
kind
'SubcommandGroup'
-
options
-
Variant 3
PropTypeDescription
kind
'String'
-
value
-
Variant 4
PropTypeDescription
kind
'Integer'
-
value
-
Variant 5
PropTypeDescription
kind
'Boolean'
-
value
-
Variant 6
PropTypeDescription
kind
'User'
-
user
-
member?
-
Variant 7
PropTypeDescription
kind
'Channel'
-
channel
-
Variant 8
PropTypeDescription
kind
'Role'
-
role
-
Variant 9
PropTypeDescription
kind
'Number'
-
value
-
Variant 10
PropTypeDescription
kind
'Attachment'
-
attachment
-
Variant 11
PropTypeDescription
kind
'Unresolved'
-
type
('User' | 'Channel' | 'Role' | 'Mentionable' | 'Attachment')
-
id
-

ParsedCommandDataArgument

ParsedCommandDataArgument is the type of a parsed command data argument

Raw Type
--- ParsedCommandDataArgument is the type of a parsed command data argument
type ParsedCommandDataArgument = {
	name: string,

	description: string,

	type: "String" | "Integer" | "Boolean" | "User" | "Channel" | "Role" | "Number" | "Attachment",

	required: boolean,

	choices: {discord.ApplicationCommandOptionChoiceObject}?,

	min_length: number?,

	max_length: number?
}
PropTypeDescription
name
-
description
-
type
('String' | 'Integer' | 'Boolean' | 'User' | 'Channel' | 'Role' | 'Number' | 'Attachment')
-
required
-
choices?
-
min_length?
-
max_length?
-

ParsedCommandData

ParsedCommandData is the parsed ``discordRestTypes.CreateGuildApplicationCommandRequest``

Raw Type
--- ParsedCommandData is the parsed \`\`discordRestTypes.CreateGuildApplicationCommandRequest\`\`
type ParsedCommandData = {
	name: string,

	description: string?,

	options: {ParsedCommandDataArgument},

	subcommands: {ParsedCommandData}
}
PropTypeDescription
name
-
description?
-
options
-
subcommands
-

AppCommandDataLike

Raw Type
type AppCommandDataLike = {
	name: string,

	description: string?,

	options: {discord.ApplicationCommandOptionObject}?
}
PropTypeDescription
name
-
description?
-
options?
-

Functions

resolveOptions

Resolves discords option into a more type-safe structure for handling slash commands

Function Signature
--- Resolves discords option into a more type-safe structure for handling slash commands
function resolveOptions(opts: {discord.ApplicationCommandInteractionDataOptionObject}, resolved: discord.ResolvedDataStructure) -> {ResolvedOption} end

Arguments

opts

{discord.ApplicationCommandInteractionDataOptionObject}

resolved

discord.ResolvedDataStructure

Returns

ret1

{ResolvedOption}

parseApplicationCommand

Parses a/an application/slash command from an AntiRaid interaction create event into a parsed slash command object.

Function Signature
--- Parses a/an application/slash command from an AntiRaid interaction create event into a parsed slash command object.
function parseApplicationCommand(interaction: discord.InteractionObject) -> ParsedApplicationCommand? end

Arguments

interaction

discord.InteractionObject

Returns

ret1

ParsedApplicationCommand?

parseApplicationCommandData

Parses a command data object from a discordRestTypes.CreateGuildApplicationCommandRequest into a parsed command data object.

Function Signature
--- Parses a command data object from a discordRestTypes.CreateGuildApplicationCommandRequest into a parsed command data object.
function parseApplicationCommandData(data: AppCommandDataLike) -> ParsedCommandData end

Arguments

data

AppCommandDataLike

Returns

ret1

ParsedCommandData

Last updated on