glyde/api/user

A user id is never a major parameter, so every /users/... route shares one bucket per method and path.

Types

Which way get_current_user_guilds pages, by guild id. One value, because Discord does not say what it does with both.

pub type GuildCursor {
  GuildsBefore(id.Id(id.Guild))
  GuildsAfter(id.Id(id.Guild))
}

Constructors

  • GuildsBefore(id.Id(id.Guild))

    Guilds whose id sorts below this one.

  • GuildsAfter(id.Id(id.Guild))

    Guilds whose id sorts above this one.

Values

pub fn create_dm(body: body.Body) -> rest.Call(channel.Channel)

POST /users/@me/channels, opening a DM. Safe to call again: Discord returns the existing channel when there is one. Discord also blocks a bot that opens a lot of DM channels quickly from opening any more, so keep the channel id rather than reopening before every message. Build the body with payload/user.create_dm_body.

pub fn get_current_user() -> rest.Call(user.CurrentUser)

GET /users/@me, the bot’s own user. A CurrentUser, which carries verified and email that a plain User does not have.

pub fn get_current_user_guild_member(
  guild: id.Id(id.Guild),
) -> rest.Call(member.GuildMember)

GET /users/@me/guilds/{guild.id}/member, the bot’s own membership of one guild. The guild is a plain segment here, not the major parameter: this is a /users route, and every one of them shares a bucket.

pub fn get_current_user_guilds(
  cursor cursor: option.Option(GuildCursor),
  limit limit: option.Option(Int),
  with_counts with_counts: Bool,
) -> rest.Call(List(guild.UserGuild))

GET /users/@me/guilds, the guilds the bot is in. A UserGuild and not a Guild: the answer is nine keys, and owner and permissions come from nowhere else. Discord caps limit at 200 and defaults it to 200.

pub fn get_user(user: id.Id(id.User)) -> rest.Call(user.User)
pub fn leave_guild(guild: id.Id(id.Guild)) -> rest.Call(Nil)

DELETE /users/@me/guilds/{guild.id}, leaving a guild. Discord answers 204 whether or not the bot was in it.

Search Document