gaato/discord/bot does not have a README file
pub(all) suberror BotError {
FatallyClosed(code~ : Int)
InvalidShardConfig(message~ : String)
SessionStartLimitExceeded(required~ : Int, remaining~ : Int, reset_after_ms~ : Int64)
} derive(Debug)pub struct Bot {
// private fields
}fn Bot::Bot(app : App, token~ : String, intents? : Intents, client? : Client, gateway_url? : String, shards? : ShardConfig, compress? : Bool, identify_queue? : &IdentifyQueue) -> Botfn Bot::middleware(self : Bot, middleware : async (GatewayCtx, Event, async (Event) -> Unit) -> Unit) -> Unitpub struct EventType[T] {
// private fields
}pub struct Events {
}fn Events::application_command_permissions_update() -> EventType[GuildApplicationCommandPermissions]test "install a reaction role feature" {
fn install_reaction_role(bot : @bot.Bot, role_id : @model.RoleId) -> Unit {
bot.on(@bot.Events::message_reaction_add(), (ctx, event) => {
guard event.guild_id is Some(guild_id) else { return }
guard event.emoji.name.to_option() == Some("✅") else { return }
if event.user_id == ctx.ready().user.id {
return
}
ctx
.app()
.http()
.add_member_role(
guild_id,
event.user_id,
role_id,
audit_reason="reaction role",
)
})
bot.on(@bot.Events::message_reaction_remove(), (ctx, event) => {
guard event.guild_id is Some(guild_id) else { return }
guard event.emoji.name.to_option() == Some("✅") else { return }
ctx
.app()
.http()
.remove_member_role(
guild_id,
event.user_id,
role_id,
audit_reason="reaction role removed",
)
})
}
ignore(install_reaction_role)
}pub struct GatewayCtx {
// private fields
}async fn GatewayCtx::join_voice(self : GatewayCtx, guild_id : Id[GuildMarker], channel_id : Id[ChannelMarker], self_mute? : Bool, self_deaf? : Bool, timeout_ms? : Int, telemetry? : (VoiceTelemetry) -> Unit) -> VoiceConnectionfn GatewayCtx::member_ref(self : GatewayCtx, guild_id : Id[GuildMarker], user_id : Id[UserMarker]) -> MemberRefasync fn GatewayCtx::resolve_channel(self : GatewayCtx, channel_id : Id[ChannelMarker]) -> Channel raise DiscordHttpErrorlet channel = ctx.resolve_channel(event.message.channel_id)
let is_thread = match channel.typ {
AnnouncementThread | PublicThread | PrivateThread => true
_ => false
}async fn[T] GatewayCtx::wait_for(self : GatewayCtx, event_type : EventType[T], predicate : (T) -> Bool, timeout_ms? : Int) -> T?async fn GatewayCtx::wait_for_component(self : GatewayCtx, custom_id~ : String, timeout_ms? : Int) -> ComponentCtx?Install
Download zipAn experimental Discord library for MoonBit: typed APIs, a native gateway with voice (DAVE E2EE), and JS/serverless HTTP interactions.
Dependencies