gaato/discord/interaction does not have a README file
struct Echo {
text : String
times : Int64?
}
impl @interaction.CommandModel for Echo with fn from_options(options) {
{ text: options.string("text"), times: options.int_opt("times"), }
}pub(all) suberror OptionError {
MissingOption(name~ : String)
WrongType(name~ : String, expected~ : String)
MissingResolved(name~ : String, kind~ : String)
} derive(Debug)pub struct Arg[A] {
// private fields
}test "make a command option optional" {
let args = @interaction.Args::of(
@interaction.arg_string(name="note", description="Optional note").optional(),
)
json_inspect(args.definitions(), content=[
{
"type": 3,
"name": "note",
"description": "Optional note",
"required": false,
},
])
}pub struct Args[A] {
// private fields
}fn[A] Args::custom(definitions~ : Array[CommandOption], decode~ : (CommandOptions) -> A raise) -> Args[A]test "compose defaulting and validation into an argument spec" {
let args = @interaction.Args::of(
@interaction.arg_int(
name="times",
description="Repeat count",
min=1L,
max=5L,
)
.with_default(1L)
.validate(value => if value <= 5L { None } else { Some("too large") }),
)
json_inspect(args.definitions(), content=[
{
"type": 4,
"name": "times",
"description": "Repeat count",
"required": false,
"min_value": 1,
"max_value": 5,
},
])
}pub struct CommandOptions {
// private fields
}fn CommandOptions::channel(self : CommandOptions, name : String) -> Id[ChannelMarker] raise OptionErrorfn CommandOptions::channel_opt(self : CommandOptions, name : String) -> Id[ChannelMarker]? raise OptionErrorfn CommandOptions::mentionable(self : CommandOptions, name : String) -> Id[GenericMarker] raise OptionErrorfn CommandOptions::mentionable_opt(self : CommandOptions, name : String) -> Id[GenericMarker]? raise OptionErrorfn CommandOptions::role_opt(self : CommandOptions, name : String) -> Id[RoleMarker]? raise OptionErrorfn CommandOptions::user_opt(self : CommandOptions, name : String) -> Id[UserMarker]? raise OptionErrorpub(all) struct CommandSpec {
name : String
name_localizations : Map[String, String]?
description : String
description_localizations : Map[String, String]?
typ : ApplicationCommandType
options : Array[CommandOption]
default_member_permissions : Permissions?
nsfw : Bool?
integration_types : Array[ApplicationIntegrationType]?
contexts : Array[InteractionContextType]?
} derive(Debug)impl ToJson for CommandSpecfn CommandSpec::message(name : String, default_member_permissions? : Permissions, nsfw? : Bool, integration_types? : Array[ApplicationIntegrationType], contexts? : Array[InteractionContextType], name_localizations? : Map[String, String]) -> CommandSpecfn CommandSpec::slash(name : String, description : String, options? : Array[CommandOption], default_member_permissions? : Permissions, nsfw? : Bool, integration_types? : Array[ApplicationIntegrationType], contexts? : Array[InteractionContextType], name_localizations? : Map[String, String], description_localizations? : Map[String, String]) -> CommandSpecfn CommandSpec::user(name : String, default_member_permissions? : Permissions, nsfw? : Bool, integration_types? : Array[ApplicationIntegrationType], contexts? : Array[InteractionContextType], name_localizations? : Map[String, String]) -> CommandSpecpub(all) struct SuggestCtx {
interaction : Interaction
options : CommandOptions
guild_id : Id[GuildMarker]?
locale : String?
}pub struct SuggestHandler {
// private fields
}async fn SuggestHandler::suggest(self : SuggestHandler, ctx : SuggestCtx, input : SuggestInput) -> Array[CommandOptionChoice]pub struct SuggestInput {
// private fields
}fn arg_attachment(name~ : String, description~ : String, name_localizations? : Map[String, String], description_localizations? : Map[String, String]) -> Arg[Attachment]fn arg_channel(name~ : String, description~ : String, channel_types? : Array[ChannelType], name_localizations? : Map[String, String], description_localizations? : Map[String, String]) -> Arg[Id[ChannelMarker]]fn arg_int(name~ : String, description~ : String, min? : Int64, max? : Int64, choices? : Array[CommandOptionChoice], suggest? : async (SuggestCtx, Int64) -> Array[CommandOptionChoice], name_localizations? : Map[String, String], description_localizations? : Map[String, String]) -> Arg[Int64]fn arg_mentionable(name~ : String, description~ : String, name_localizations? : Map[String, String], description_localizations? : Map[String, String]) -> Arg[Id[GenericMarker]]fn arg_number(name~ : String, description~ : String, min? : Double, max? : Double, choices? : Array[CommandOptionChoice], suggest? : async (SuggestCtx, Double) -> Array[CommandOptionChoice], name_localizations? : Map[String, String], description_localizations? : Map[String, String]) -> Arg[Double]fn arg_role(name~ : String, description~ : String, name_localizations? : Map[String, String], description_localizations? : Map[String, String]) -> Arg[Id[RoleMarker]]fn arg_string(name~ : String, description~ : String, choices? : Array[CommandOptionChoice], min_length? : Int, max_length? : Int, suggest? : async (SuggestCtx, String) -> Array[CommandOptionChoice], name_localizations? : Map[String, String], description_localizations? : Map[String, String]) -> Arg[String]fn arg_user(name~ : String, description~ : String, name_localizations? : Map[String, String], description_localizations? : Map[String, String]) -> Arg[Id[UserMarker]]fn attachment_option(name : String, description : String, required? : Bool, name_localizations? : Map[String, String], description_localizations? : Map[String, String]) -> CommandOptionfn boolean_option(name : String, description : String, required? : Bool, name_localizations? : Map[String, String], description_localizations? : Map[String, String]) -> CommandOptionfn button(custom_id~ : String, label? : String, style? : ButtonStyle, emoji? : Emoji, disabled? : Bool) -> Componentfn channel_option(name : String, description : String, required? : Bool, channel_types? : Array[ChannelType], name_localizations? : Map[String, String], description_localizations? : Map[String, String]) -> CommandOptionfn channel_select(custom_id~ : String, placeholder? : String, min_values? : Int, max_values? : Int, disabled? : Bool, channel_types? : Array[ChannelType]) -> Componentfn int_choice(name : String, value : Int64, name_localizations? : Map[String, String]) -> CommandOptionChoicefn integer_option(name : String, description : String, required? : Bool, choices? : Array[CommandOptionChoice], min_value? : Int64, max_value? : Int64, autocomplete? : Bool, name_localizations? : Map[String, String], description_localizations? : Map[String, String]) -> CommandOptionfn mentionable_option(name : String, description : String, required? : Bool, name_localizations? : Map[String, String], description_localizations? : Map[String, String]) -> CommandOptionfn mentionable_select(custom_id~ : String, placeholder? : String, min_values? : Int, max_values? : Int, disabled? : Bool) -> Componentfn number_choice(name : String, value : Double, name_localizations? : Map[String, String]) -> CommandOptionChoicefn number_option(name : String, description : String, required? : Bool, choices? : Array[CommandOptionChoice], min_value? : Double, max_value? : Double, autocomplete? : Bool, name_localizations? : Map[String, String], description_localizations? : Map[String, String]) -> CommandOptionfn role_option(name : String, description : String, required? : Bool, name_localizations? : Map[String, String], description_localizations? : Map[String, String]) -> CommandOptionfn role_select(custom_id~ : String, placeholder? : String, min_values? : Int, max_values? : Int, disabled? : Bool) -> Componentfn select_option(label~ : String, value~ : String, description? : String, emoji? : Emoji, default? : Bool) -> SelectOptionfn string_choice(name : String, value : String, name_localizations? : Map[String, String]) -> CommandOptionChoicefn string_option(name : String, description : String, required? : Bool, choices? : Array[CommandOptionChoice], min_length? : Int, max_length? : Int, autocomplete? : Bool, name_localizations? : Map[String, String], description_localizations? : Map[String, String]) -> CommandOptionfn string_select(custom_id~ : String, options~ : Array[SelectOption], placeholder? : String, min_values? : Int, max_values? : Int, disabled? : Bool) -> Componentfn sub_command(name : String, description : String, options? : Array[CommandOption], name_localizations? : Map[String, String], description_localizations? : Map[String, String]) -> CommandOptionfn sub_command_group(name : String, description : String, sub_commands : Array[CommandOption], name_localizations? : Map[String, String], description_localizations? : Map[String, String]) -> CommandOptionfn text_input(custom_id~ : String, style? : TextInputStyle, placeholder? : String, min_length? : Int, max_length? : Int, required? : Bool, value? : String) -> Componentfn user_option(name : String, description : String, required? : Bool, name_localizations? : Map[String, String], description_localizations? : Map[String, String]) -> CommandOptionInstall
Download zipAn experimental Discord library for MoonBit: typed APIs, a native gateway with voice (DAVE E2EE), and JS/serverless HTTP interactions.
Dependencies