discord

asterai

Discord bot integration for asterai

v0.1.0 Public
Provides a REST API for sending messages and retrieving bot user info, and connects to the Discord Gateway WebSocket to listen for incoming messages and fan them out to subscriber components. Environment variables: - DISCORD_TOKEN (required) — Discord bot token - DISCORD_INCOMING_HANDLER_COMPONENTS (optional) — Comma-separated list of component names that export asterai:discord/incoming-handler@0.1.0. These receive `on-message` calls when a Discord message arrives via the Gateway. If `DISCORD_INCOMING_HANDLER_COMPONENTS` is unset or empty, the component operates in send-only mode (no WebSocket connection is opened, will not listen for incoming messages).

Interface

Exports
asterai:discord/types@0.1.0
asterai:discord/api@0.1.0
get-self()
send-message(contentstring, channel-idstring)
wasi:cli/run@0.2.0
run()
asterai:host-ws/incoming-handler@0.1.0
on-open(idconnection-id)
on-message(idconnection-id, datalist<u8>)
on-close(idconnection-id, codeu16, reasonstring)
on-error(idconnection-id, messagestring)
Imports
asterai:host/api@1.0.0
asterai:host-ws/connection@0.1.0
wasi:io/poll@0.2.6
wasi:clocks/monotonic-clock@0.2.6
wasi:io/error@0.2.6
wasi:io/streams@0.2.6
wasi:http/types@0.2.4
wasi:http/outgoing-handler@0.2.4
wasi:cli/environment@0.2.6
wasi:cli/exit@0.2.6
wasi:cli/stderr@0.2.6
wasi:random/insecure-seed@0.2.6