Nostrum.Api.User (nostrum v0.11.0-dev)

View Source

Functions for interacting with the Discord API's user endpoints.

See: https://discord.com/developers/docs/resources/user

Summary

Functions

Create a new DM channel with a user.

Creates a new group DM channel.

Functions

create_dm(user_id)

(since 0.10.1)

Create a new DM channel with a user.

If successful, returns {:ok, dm_channel}. Otherwise, returns a Nostrum.Api.error/0.

Examples

Nostrum.Api.User.create_dm(150061853001777154)
{:ok, %Nostrum.Struct.Channel{type: 1}}

create_group_dm(access_tokens, nicks)

(since 0.10.1)
@spec create_group_dm([String.t()], %{
  optional(Nostrum.Struct.User.id()) => String.t()
}) ::
  Nostrum.Api.error() | {:ok, Nostrum.Struct.Channel.group_dm_channel()}

Creates a new group DM channel.

If successful, returns {:ok, group_dm_channel}. Otherwise, returns a Nostrum.Api.error/0.

access_tokens are user oauth2 tokens. nicks is a map that maps a user id to a nickname.

Examples

Nostrum.Api.User.create_group_dm(["6qrZcUqja7812RVdnEKjpzOL4CvHBFG"], %{41771983423143937 => "My Nickname"})
{:ok, %Nostrum.Struct.Channel{type: 3}}

get(user_id)

(since 0.10.1)

Gets a user by its Nostrum.Struct.User.id/0.

If the request is successful, this function returns {:ok, user}, where user is a Nostrum.Struct.User. Otherwise, returns {:error, reason}.