glyde/gateway/presence

What the bot looks like in a member list: the dot next to its name and the line under it.

Its own module because two frames carry the same object: op 3 sends one on its own, and IDENTIFY carries the one to connect with. gateway/command and gateway/frame both need it, and frame cannot import command.

Types

The line under the bot’s name. A bot may set only name, type, URL and state.

pub type Activity {
  Playing(name: String)
  Streaming(name: String, url: String)
  Listening(name: String)
  Watching(name: String)
  Competing(name: String)
  CustomStatus(text: String)
}

Constructors

  • Playing(name: String)

    “Playing {name}”.

  • Streaming(name: String, url: String)

    “Streaming {name}”. Discord checks the URL and only twitch.tv and youtube.com links work.

  • Listening(name: String)

    “Listening to {name}”.

  • Watching(name: String)

    “Watching {name}”.

  • Competing(name: String)

    “Competing in {name}”.

  • CustomStatus(text: String)

    Just the text, with no verb in front of it.

pub type Presence {
  Presence(status: Status, activities: List(Activity), afk: Bool)
}

Constructors

The dot next to the bot’s name.

pub type Status {
  Online
  Idle(since: option.Option(Int))
  DoNotDisturb
  Invisible
  Offline
}

Constructors

  • Online
  • Idle(since: option.Option(Int))

    since is the unix milliseconds the bot went idle. It hangs off this variant because Discord’s since is null for every other status, so there is no second place it could come from.

  • DoNotDisturb
  • Invisible
  • Offline

    For a bot this looks the same to everyone else as Invisible.

Values

pub fn new(status: Status) -> Presence

A presence that is nothing but a status.

pub fn to_json(presence: Presence) -> json.Json

The object op 3 carries. IDENTIFY’s presence field takes the same one.

Search Document