Nostrum.Struct.Channel (nostrum v0.11.0-dev)

View Source

Struct and helper functions for working with channels.

Channel Struct

The channel struct is used by Nostrum to represent a Discord Channel Object. More information can be found on the Discord API Channel Documentation.

The struct can have one of several forms depending on the type of channel. You can read more about the individual channel types below.

A typical channel would appear as:

%Nostrum.Struct.Channel{
  guild_id: 766435015768539156,
  id: 827333533688397865,
  name: "announcements",
  nsfw: false,
  permission_overwrites: [],
  position: 1,
  type: 5,
}

The channel struct implements String.Chars protocol through the mention/1 function. This example uses our channel from the previous code block.

channel |> to_string()
"<#766435015768539156>"

Channel Caching

Channels are cached within the guild object they are a member of. To fetch a cached channel you should use the Nostrum.Cache.ChannelGuildMapping cache to map a cache to a guild ID.

Once you have a guild ID, you can use the Nostrum.Cache.GuildCache to fetch the guild and all channels, then use the Nostrum.Struct.Guild.channels/0 field to find the channel.

Note on DM Channels

The Nostrum.Cache.ChannelGuildMapping by design only caches a mapping of channels to their respective guilds, and the stored channel object sits within the Nostrum.Cache.GuildCache.

Due to how Direct Message channels work (no CHANNEL_CREATE events, not sent in any gateway events, etc.), we make no attempt to store direct message channels within any of the built-in Nostrum caching adapters.

If you wish to implement this functionality yourself, you will have to fetch the channel details from the API by looking at the channel_id field of received message objects, you can then store these details in your own choice of caching system (ETS, Mnesia, etc.).

Example

> guild_id = Nostrum.Cache.ChannelGuildMapping.get(1229955694258684005)
1226944827137069107
> {:ok, guild} = Nostrum.Cache.GuildCache.get(guild_id)
{:ok,
  %Nostrum.Struct.Guild{
    id: 1226944827137069107,
    name: "Craig Cat Zone",
    ...
}}
> guild.channels[channel_id].name
"cat-general"

Helper Functions

This module contains two functions for assisting with channel structs. mention/1 to convert the channel into a mention as a string, and link/1 to convert the channel into a hyperlink as a string. Further details and examples are detailed in the Functions section of this module.

Api Functions

The Nostrum Api contains numerous functions related to channels. Notable functions relating to channels are shown below.

Note: This is not an exhaustive list, for full details please see the Nostrum.Api module documentation.

Channel Types

Channels take the shape of various types depending on their use and not all fields are always used. The currently implemented channel types are detailed below. The type of channel is determined by the :type field.

This diagram represents the regular channel types 0, 2, 5 and 13.

Discord Channels

The currently implemented channel types are:

Channel Type
0GUILD_TEXTA text channel within a server
1DMA direct message between users
2GUILD_VOICEA voice channel within a server
3GROUP_DMA direct message between multiple users
4GUILD_CATEGORYA category that contains up to 50 channels
5GUILD_NEWSA channel that users can follow and crosspost
6GUILD_STOREA channel to sell games on Discord
10GUILD_NEWS_THREADA temporary sub-channel within a news channel
11GUILD_PUBLIC_THREADA temporary sub-channel within a text channel
12GUILD_PRIVATE_THREADA temporary private sub-channel within a text channel
13GUILD_STAGE_VOICEA voice channel for hosting events with an audience
15GUILD_FORUM_A channel that can only contain threads

You can use one of the Nostrum.Constants.ChannelType methods.

More information about Discord Channel Types can be found on the Discord API Channel Type Documentation.

Summary

Types

The id of the application that created a group direct message or thread.

When the thread was archived.

The threads archived status.

Archive duration for the thread in minutes.

The bitate of the voice channel.

A partial channel object representing a channel mention.

Default duration for newly created threads in minutes.

The default layout for posts in a GUILD_FORUM channel.

An object that specifies the emoji to use as the default way to react to a forum post.

The default sort order for posts in a GUILD_FORUM channel.

The :rate_limit_per_user which will be applied to threads created in the channel, in seconds.

Type 1 partial channel object representing a direct message.

User thread settings, currently only used for notifications.

A map representing a tag for use in forum channels.

Type 3 partial channel object representing a group direct message.

Type 4 partial channel object representing a channel category.

guild_channel() deprecated

Guild channel types

Type 15 a guild forum channel.

The id of the guild the channel is located in.

Type 5 partial channel object representing a news channel.

Type 10 partial channel object representing a news thread.

Type 12 partial channel object representing a private thread.

Type 11 partial channel object representing a standard thread.

Type 13 channel object representing a stage channel.

Type 6 partial channel object representing a store channel.

Type 0 partial channel object representing a text channel within a guild.

Type 2 partial channel object representing an audio channel within a guild.

The hash of the channels icon.

The id of the channel object.

When the user joined the thread.

The id of the last message sent in the channel.

Timestamp for the last pinned message.

The threads locked status.

Present when the bot joins a thread.

Approximate count of members in a thread, capped at 50.

Approximate count of messages in a thread, capped at 50.

The name of the channel.

Included only in the THREAD_CREATE event.

Whether the NSFW setting is enabled for this channel.

The id of the user of a group direct message or thread.

The id of the parent channel that this channel is located under.

A list of permission overwrites applied to the channel.

Computed permissions of the invoking user.

The position of the channel in the sidebar of the guild.

The users rate limit.

A list of users in a group DM.

Region id for the channel.

t()

All valid channel types.

text_channel() deprecated

All valid text channels.

Thread-specific fields not needed by other channels.

The topic of the channel.

The type of channel.

User id of the threads creator.

The user limit of a voice channel.

The video quality mode of the channel.

voice_channel() deprecated

A Nostrum.Struct.Channel that represents a voice channel

Functions

Convert a channel into a mention.

Types

application_id()

@type application_id() :: Nostrum.Snowflake.t() | nil

The id of the application that created a group direct message or thread.

This applies to bot created channels.

applied_tags()

(since 0.7.0)
@type applied_tags() :: [Nostrum.Snowflake.t()] | nil

archive_timestamp()

(since 0.5.0)
@type archive_timestamp() :: DateTime.t() | nil

When the thread was archived.

archived()

(since 0.5.0)
@type archived() :: boolean()

The threads archived status.

auto_archive_duration()

(since 0.5.0)
@type auto_archive_duration() :: integer()

Archive duration for the thread in minutes.

  • 60, 1 hour
  • 1440, 24 hours
  • 4320, 3 days
  • 10080, 7 days

bitrate()

@type bitrate() :: integer()

The bitate of the voice channel.

channel_mention()

@type channel_mention() :: %Nostrum.Struct.Channel{
  application_id: term(),
  applied_tags: term(),
  available_tags: term(),
  bitrate: term(),
  default_auto_archive_duration: term(),
  default_forum_layout: term(),
  default_reaction_emoji: term(),
  default_sort_order: term(),
  default_thread_rate_limit_per_user: term(),
  guild_id: guild_id(),
  icon: term(),
  id: id(),
  last_message_id: term(),
  last_pin_timestamp: term(),
  member: term(),
  member_count: term(),
  message_count: term(),
  name: name(),
  newly_created: term(),
  nsfw: term(),
  owner_id: term(),
  parent_id: term(),
  permission_overwrites: term(),
  permissions: term(),
  position: term(),
  rate_limit_per_user: term(),
  recipients: term(),
  rtc_region: term(),
  thread_metadata: term(),
  topic: term(),
  type: type(),
  user_limit: term(),
  video_quality_mode: term()
}

A partial channel object representing a channel mention.

More information about the Discord Channel Mention Object can be found at the Discord API Channel Mention Object Documentation.

default_auto_archive_duration()

(since 0.5.0)
@type default_auto_archive_duration() :: integer()

Default duration for newly created threads in minutes.

  • 60, 1 hour
  • 1440, 24 hours
  • 4320, 3 days
  • 10080, 7 days

default_forum_layout()

(since 0.10.1)
@type default_forum_layout() :: integer() | nil

The default layout for posts in a GUILD_FORUM channel.

default_reaction_emoji()

(since 0.7.0)
@type default_reaction_emoji() ::
  %{emoji_id: Nostrum.Snowflake.t() | nil, emoji_name: String.t() | nil} | nil

An object that specifies the emoji to use as the default way to react to a forum post.

:emoji_id and :emoji_name are mutually exclusive

default_sort_order()

(since 0.10.1)
@type default_sort_order() :: integer() | nil

The default sort order for posts in a GUILD_FORUM channel.

default_thread_rate_limit_per_user()

(since 0.7.0)
@type default_thread_rate_limit_per_user() :: integer() | nil

The :rate_limit_per_user which will be applied to threads created in the channel, in seconds.

dm_channel()

@type dm_channel() :: %Nostrum.Struct.Channel{
  application_id: term(),
  applied_tags: term(),
  available_tags: term(),
  bitrate: term(),
  default_auto_archive_duration: term(),
  default_forum_layout: term(),
  default_reaction_emoji: term(),
  default_sort_order: term(),
  default_thread_rate_limit_per_user: term(),
  guild_id: term(),
  icon: term(),
  id: id(),
  last_message_id: last_message_id(),
  last_pin_timestamp: last_pin_timestamp(),
  member: term(),
  member_count: term(),
  message_count: term(),
  name: term(),
  newly_created: term(),
  nsfw: term(),
  owner_id: term(),
  parent_id: term(),
  permission_overwrites: term(),
  permissions: term(),
  position: term(),
  rate_limit_per_user: term(),
  recipients: recipients(),
  rtc_region: term(),
  thread_metadata: term(),
  topic: term(),
  type: 1,
  user_limit: term(),
  video_quality_mode: term()
}

Type 1 partial channel object representing a direct message.

flags()

(since 0.5.0)
@type flags() :: integer()

User thread settings, currently only used for notifications.

forum_tag()

(since 0.7.0)
@type forum_tag() :: %{
  id: Nostrum.Snowflake.t(),
  name: String.t(),
  moderated: boolean(),
  emoji_id: Nostrum.Snowflake.t() | nil,
  emoji_name: String.t() | nil
}

A map representing a tag for use in forum channels.

:moderated indicates whether the tag can only be added or removed by moderators. :emoji_id and :emoji_name are mutually exclusive and indicate the emoji used to represent the tag.

group_dm_channel()

@type group_dm_channel() :: %Nostrum.Struct.Channel{
  application_id: application_id(),
  applied_tags: term(),
  available_tags: term(),
  bitrate: term(),
  default_auto_archive_duration: term(),
  default_forum_layout: term(),
  default_reaction_emoji: term(),
  default_sort_order: term(),
  default_thread_rate_limit_per_user: term(),
  guild_id: term(),
  icon: icon(),
  id: id(),
  last_message_id: last_message_id(),
  last_pin_timestamp: term(),
  member: term(),
  member_count: term(),
  message_count: term(),
  name: name(),
  newly_created: term(),
  nsfw: term(),
  owner_id: owner_id(),
  parent_id: term(),
  permission_overwrites: term(),
  permissions: term(),
  position: term(),
  rate_limit_per_user: term(),
  recipients: recipients(),
  rtc_region: term(),
  thread_metadata: term(),
  topic: term(),
  type: 3,
  user_limit: term(),
  video_quality_mode: term()
}

Type 3 partial channel object representing a group direct message.

guild_category_channel()

@type guild_category_channel() :: %Nostrum.Struct.Channel{
  application_id: term(),
  applied_tags: term(),
  available_tags: term(),
  bitrate: term(),
  default_auto_archive_duration: term(),
  default_forum_layout: term(),
  default_reaction_emoji: term(),
  default_sort_order: term(),
  default_thread_rate_limit_per_user: term(),
  guild_id: guild_id(),
  icon: term(),
  id: id(),
  last_message_id: term(),
  last_pin_timestamp: term(),
  member: term(),
  member_count: term(),
  message_count: term(),
  name: name(),
  newly_created: term(),
  nsfw: nsfw(),
  owner_id: term(),
  parent_id: parent_id(),
  permission_overwrites: permission_overwrites(),
  permissions: term(),
  position: position(),
  rate_limit_per_user: term(),
  recipients: term(),
  rtc_region: term(),
  thread_metadata: term(),
  topic: term(),
  type: 4,
  user_limit: term(),
  video_quality_mode: term()
}

Type 4 partial channel object representing a channel category.

Note: Other channels parent_id field refers to this type of object.

guild_channel()

This type is deprecated. See t.0.

Guild channel types

guild_forum_channel()

(since 0.7.0)
@type guild_forum_channel() :: %Nostrum.Struct.Channel{
  application_id: term(),
  applied_tags: term(),
  available_tags: [forum_tag()],
  bitrate: term(),
  default_auto_archive_duration: term(),
  default_forum_layout: default_forum_layout(),
  default_reaction_emoji: default_reaction_emoji(),
  default_sort_order: default_sort_order(),
  default_thread_rate_limit_per_user: default_thread_rate_limit_per_user(),
  guild_id: guild_id(),
  icon: term(),
  id: id(),
  last_message_id: last_message_id(),
  last_pin_timestamp: term(),
  member: term(),
  member_count: term(),
  message_count: term(),
  name: name(),
  newly_created: term(),
  nsfw: nsfw(),
  owner_id: term(),
  parent_id: parent_id(),
  permission_overwrites: permission_overwrites(),
  permissions: term(),
  position: position(),
  rate_limit_per_user: rate_limit_per_user(),
  recipients: term(),
  rtc_region: term(),
  thread_metadata: term(),
  topic: term(),
  type: type(),
  user_limit: term(),
  video_quality_mode: term()
}

Type 15 a guild forum channel.

guild_id()

@type guild_id() :: Nostrum.Struct.Guild.id()

The id of the guild the channel is located in.

guild_news_channel()

(since 0.5.0)
@type guild_news_channel() :: %Nostrum.Struct.Channel{
  application_id: term(),
  applied_tags: term(),
  available_tags: term(),
  bitrate: term(),
  default_auto_archive_duration: default_auto_archive_duration(),
  default_forum_layout: term(),
  default_reaction_emoji: term(),
  default_sort_order: term(),
  default_thread_rate_limit_per_user: term(),
  guild_id: guild_id(),
  icon: term(),
  id: id(),
  last_message_id: last_message_id(),
  last_pin_timestamp: term(),
  member: term(),
  member_count: term(),
  message_count: term(),
  name: name(),
  newly_created: term(),
  nsfw: nsfw(),
  owner_id: term(),
  parent_id: parent_id(),
  permission_overwrites: permission_overwrites(),
  permissions: term(),
  position: position(),
  rate_limit_per_user: term(),
  recipients: term(),
  rtc_region: term(),
  thread_metadata: term(),
  topic: topic(),
  type: 5,
  user_limit: term(),
  video_quality_mode: term()
}

Type 5 partial channel object representing a news channel.

guild_news_thread_channel()

(since 0.5.0)
@type guild_news_thread_channel() :: %Nostrum.Struct.Channel{
  application_id: term(),
  applied_tags: term(),
  available_tags: term(),
  bitrate: term(),
  default_auto_archive_duration: term(),
  default_forum_layout: term(),
  default_reaction_emoji: term(),
  default_sort_order: term(),
  default_thread_rate_limit_per_user: term(),
  guild_id: guild_id(),
  icon: term(),
  id: id(),
  last_message_id: last_message_id(),
  last_pin_timestamp: term(),
  member: term(),
  member_count: member_count(),
  message_count: message_count(),
  name: name(),
  newly_created: newly_created(),
  nsfw: term(),
  owner_id: owner_id(),
  parent_id: parent_id(),
  permission_overwrites: term(),
  permissions: term(),
  position: term(),
  rate_limit_per_user: rate_limit_per_user(),
  recipients: term(),
  rtc_region: term(),
  thread_metadata: thread_metadata(),
  topic: term(),
  type: type(),
  user_limit: term(),
  video_quality_mode: term()
}

Type 10 partial channel object representing a news thread.

guild_private_thread_channel()

(since 0.5.0)
@type guild_private_thread_channel() :: %Nostrum.Struct.Channel{
  application_id: term(),
  applied_tags: term(),
  available_tags: term(),
  bitrate: term(),
  default_auto_archive_duration: term(),
  default_forum_layout: term(),
  default_reaction_emoji: term(),
  default_sort_order: term(),
  default_thread_rate_limit_per_user: term(),
  guild_id: guild_id(),
  icon: term(),
  id: id(),
  last_message_id: last_message_id(),
  last_pin_timestamp: term(),
  member: term(),
  member_count: member_count(),
  message_count: message_count(),
  name: name(),
  newly_created: newly_created(),
  nsfw: term(),
  owner_id: owner_id(),
  parent_id: parent_id(),
  permission_overwrites: term(),
  permissions: term(),
  position: term(),
  rate_limit_per_user: rate_limit_per_user(),
  recipients: term(),
  rtc_region: term(),
  thread_metadata: thread_metadata(),
  topic: term(),
  type: type(),
  user_limit: term(),
  video_quality_mode: term()
}

Type 12 partial channel object representing a private thread.

guild_public_thread_channel()

(since 0.5.0)
@type guild_public_thread_channel() :: %Nostrum.Struct.Channel{
  application_id: term(),
  applied_tags: applied_tags(),
  available_tags: term(),
  bitrate: term(),
  default_auto_archive_duration: term(),
  default_forum_layout: term(),
  default_reaction_emoji: term(),
  default_sort_order: term(),
  default_thread_rate_limit_per_user: term(),
  guild_id: guild_id(),
  icon: term(),
  id: id(),
  last_message_id: last_message_id(),
  last_pin_timestamp: term(),
  member: term(),
  member_count: member_count(),
  message_count: message_count(),
  name: name(),
  newly_created: newly_created(),
  nsfw: term(),
  owner_id: owner_id(),
  parent_id: parent_id(),
  permission_overwrites: term(),
  permissions: term(),
  position: term(),
  rate_limit_per_user: rate_limit_per_user(),
  recipients: term(),
  rtc_region: term(),
  thread_metadata: thread_metadata(),
  topic: term(),
  type: type(),
  user_limit: term(),
  video_quality_mode: term()
}

Type 11 partial channel object representing a standard thread.

guild_stage_voice_channel()

(since 0.5.0)
@type guild_stage_voice_channel() :: %Nostrum.Struct.Channel{
  application_id: term(),
  applied_tags: term(),
  available_tags: term(),
  bitrate: term(),
  default_auto_archive_duration: term(),
  default_forum_layout: term(),
  default_reaction_emoji: term(),
  default_sort_order: term(),
  default_thread_rate_limit_per_user: term(),
  guild_id: guild_id(),
  icon: term(),
  id: id(),
  last_message_id: last_message_id(),
  last_pin_timestamp: term(),
  member: term(),
  member_count: member_count(),
  message_count: message_count(),
  name: name(),
  newly_created: term(),
  nsfw: term(),
  owner_id: owner_id(),
  parent_id: parent_id(),
  permission_overwrites: term(),
  permissions: term(),
  position: term(),
  rate_limit_per_user: rate_limit_per_user(),
  recipients: term(),
  rtc_region: term(),
  thread_metadata: thread_metadata(),
  topic: term(),
  type: type(),
  user_limit: term(),
  video_quality_mode: term()
}

Type 13 channel object representing a stage channel.

guild_store_channel()

(since 0.5.0)
@type guild_store_channel() :: %Nostrum.Struct.Channel{
  application_id: term(),
  applied_tags: term(),
  available_tags: term(),
  bitrate: term(),
  default_auto_archive_duration: term(),
  default_forum_layout: term(),
  default_reaction_emoji: term(),
  default_sort_order: term(),
  default_thread_rate_limit_per_user: term(),
  guild_id: guild_id(),
  icon: term(),
  id: id(),
  last_message_id: term(),
  last_pin_timestamp: term(),
  member: term(),
  member_count: term(),
  message_count: term(),
  name: name(),
  newly_created: term(),
  nsfw: nsfw(),
  owner_id: term(),
  parent_id: parent_id(),
  permission_overwrites: permission_overwrites(),
  permissions: term(),
  position: position(),
  rate_limit_per_user: term(),
  recipients: term(),
  rtc_region: term(),
  thread_metadata: term(),
  topic: term(),
  type: type(),
  user_limit: term(),
  video_quality_mode: term()
}

Type 6 partial channel object representing a store channel.

guild_text_channel()

@type guild_text_channel() :: %Nostrum.Struct.Channel{
  application_id: term(),
  applied_tags: term(),
  available_tags: term(),
  bitrate: term(),
  default_auto_archive_duration: default_auto_archive_duration(),
  default_forum_layout: term(),
  default_reaction_emoji: term(),
  default_sort_order: term(),
  default_thread_rate_limit_per_user: term(),
  guild_id: guild_id(),
  icon: term(),
  id: id(),
  last_message_id: last_message_id(),
  last_pin_timestamp: term(),
  member: term(),
  member_count: term(),
  message_count: term(),
  name: name(),
  newly_created: term(),
  nsfw: nsfw(),
  owner_id: term(),
  parent_id: parent_id(),
  permission_overwrites: permission_overwrites(),
  permissions: term(),
  position: position(),
  rate_limit_per_user: rate_limit_per_user(),
  recipients: term(),
  rtc_region: term(),
  thread_metadata: term(),
  topic: topic(),
  type: type(),
  user_limit: term(),
  video_quality_mode: term()
}

Type 0 partial channel object representing a text channel within a guild.

guild_voice_channel()

@type guild_voice_channel() :: %Nostrum.Struct.Channel{
  application_id: term(),
  applied_tags: term(),
  available_tags: term(),
  bitrate: bitrate(),
  default_auto_archive_duration: term(),
  default_forum_layout: term(),
  default_reaction_emoji: term(),
  default_sort_order: term(),
  default_thread_rate_limit_per_user: term(),
  guild_id: guild_id(),
  icon: term(),
  id: id(),
  last_message_id: term(),
  last_pin_timestamp: term(),
  member: term(),
  member_count: term(),
  message_count: term(),
  name: name(),
  newly_created: term(),
  nsfw: nsfw(),
  owner_id: term(),
  parent_id: parent_id(),
  permission_overwrites: permission_overwrites(),
  permissions: term(),
  position: position(),
  rate_limit_per_user: term(),
  recipients: term(),
  rtc_region: rtc_region(),
  thread_metadata: term(),
  topic: term(),
  type: 2,
  user_limit: user_limit(),
  video_quality_mode: term()
}

Type 2 partial channel object representing an audio channel within a guild.

icon()

@type icon() :: String.t() | nil

The hash of the channels icon.

id()

@type id() :: Nostrum.Snowflake.t()

The id of the channel object.

join_timestamp()

(since 0.5.0)
@type join_timestamp() :: DateTime.t()

When the user joined the thread.

last_message_id()

@type last_message_id() :: Nostrum.Struct.Message.id() | nil

The id of the last message sent in the channel.

For GUILD_FORUM channels, this is the last thread created in the channel.

last_pin_timestamp()

@type last_pin_timestamp() :: DateTime.t() | nil

Timestamp for the last pinned message.

locked()

(since 0.5.0)
@type locked() :: boolean()

The threads locked status.

member()

(since 0.5.0)
@type member() :: %{
  id: id(),
  user_id: user_id(),
  join_timestamp: join_timestamp(),
  flags: flags()
}

Present when the bot joins a thread.

Note: This is omitted on threads that the bot can immediately access on :GUILD_CREATE events received.

member_count()

(since 0.5.0)
@type member_count() :: integer() | nil

Approximate count of members in a thread, capped at 50.

message_count()

(since 0.5.0)
@type message_count() :: integer() | nil

Approximate count of messages in a thread, capped at 50.

name()

@type name() :: String.t()

The name of the channel.

newly_created()

(since 0.5.1)
@type newly_created() :: boolean() | nil

Included only in the THREAD_CREATE event.

nsfw()

@type nsfw() :: boolean()

Whether the NSFW setting is enabled for this channel.

owner_id()

@type owner_id() :: Nostrum.Struct.User.id()

The id of the user of a group direct message or thread.

This applies to user created channels.

parent_id()

@type parent_id() :: id() | nil

The id of the parent channel that this channel is located under.

For threads, that is the channel that contains the thread. For regular channels, it is the category that the channel is located under.

permission_overwrites()

@type permission_overwrites() :: [Nostrum.Struct.Overwrite.t()]

A list of permission overwrites applied to the channel.

permissions()

(since 0.5.0)
@type permissions() :: String.t()

Computed permissions of the invoking user.

Permissions for the invoking user in the channel, including overwrites, only included when part of the resolved data received on a slash command interaction

position()

@type position() :: integer()

The position of the channel in the sidebar of the guild.

rate_limit_per_user()

(since 0.5.0)
@type rate_limit_per_user() :: integer() | nil

The users rate limit.

Amount of seconds a user has to wait before sending another message (0-21600); bots, as well as users with the permission manage_messages or manage_channel, are unaffected

recipients()

@type recipients() :: [Nostrum.Struct.User.t()]

A list of users in a group DM.

rtc_region()

(since 0.5.0)
@type rtc_region() :: String.t() | nil

Region id for the channel.

More information about region ids can be found on the Discord API Voice Region Object Documentation.

t()

All valid channel types.

text_channel()

This type is deprecated. See t.0.
@type text_channel() :: guild_text_channel() | dm_channel() | group_dm_channel()

All valid text channels.

thread_metadata()

(since 0.5.0)
@type thread_metadata() :: %{
  archived: archived(),
  auto_archive_duration: auto_archive_duration(),
  archive_timestamp: archive_timestamp(),
  locked: boolean(),
  invitable: boolean() | nil,
  create_timestamp: DateTime.t() | nil
}

Thread-specific fields not needed by other channels.

topic()

@type topic() :: String.t()

The topic of the channel.

type()

@type type() :: integer()

The type of channel.

More information about Discord Channel Types can be found under the types on the Discord API Channel Type Documentation.

user_id()

(since 0.5.0)
@type user_id() :: Nostrum.Snowflake.t() | nil

User id of the threads creator.

user_limit()

@type user_limit() :: integer()

The user limit of a voice channel.

video_quality_mode()

(since 0.5.0)
@type video_quality_mode() :: integer() | nil

The video quality mode of the channel.

More information about video quality modes can be found on the Discord API Video Quality Mode Documentation.

voice_channel()

This type is deprecated. See t:guild_voice_channel/0.
@type voice_channel() :: guild_voice_channel()

A Nostrum.Struct.Channel that represents a voice channel

Functions

mention(channel)

@spec mention(t()) :: String.t()

Convert a channel into a mention.

Handles the conversion of a Nostrum.Struct.Channel into the required format to mention the channel within a message. Mentioning the channel will provide a clickable link to take the user to the channel.

Parameters

Examples

channel
|> Nostrum.Struct.Channel.mention()
"<#381889573426429952>"