const opcode = { dispatch: 0, heartbeat: 1, identify: 2, presence_update: 3, voice_update: 4, resume: 6, reconnect: 7, invalid_session: 9, hello: 10, heartbeat_ack: 11, } export def "op heartbeat" [seq?: int] { { "op": $opcode.heartbeat, "d": $seq, } } export def "op identify" [token: string, intents: int] { { "op": $opcode.identify, "d": { token: $token, intents: $intents, properties: { os: (sys host | get name), browser: "discord.nu", device: "discord.nu", }, }, } } export def "op resume" [token: string, session_id: string, seq: int] { { "op": $opcode.resume, "d": { token: $token, session_id: $session_id, seq: $seq, }, } } export def send-message [channel_id: string] { let data = $in let headers = { Authorization: $"Bot ($env.BOT_TOKEN)", } let url = $"https://discord.com/api/v9/channels/($channel_id)/messages" http post --content-type application/json --headers $headers $url $data }