Nostrum v0.4.0 Nostrum.Struct.Channel View Source

Struct representing a Discord guild channel.

A Nostrum.Struct.Channel represents all 5 types of channels. Each channel has a field :type with any of the following values:

  • 0 - GUILD_TEXT
  • 1 - DM
  • 2 - GUILD_VOICE
  • 3 - GROUP_DM
  • 4 - GUILD_CATEGORY

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

Mentioning Channels in Messages

A Nostrum.Struct.Channel can be mentioned in message content using the String.Chars protocol or mention/1.

channel = %Nostrum.Struct.Channel{id: 381889573426429952}
Nostrum.Api.create_message!(184046599834435585, "#{channel}")
%Nostrum.Struct.Message{content: "<#381889573426429952>"}

channel = %Nostrum.Struct.Channel{id: 280085880452939778}
Nostrum.Api.create_message!(280085880452939778, "#{Nostrum.Struct.Channel.mention(channel)}")
%Nostrum.Struct.Message{content: "<#280085880452939778>"}

Link to this section Summary

Types

The application id of the group DM creator if it is bot-created

The bitrate of the voice channel

A Nostrum.Struct.Channel that represents a channel category in a guild.

A Nostrum.Struct.Channel that represents a DM channel.

A Nostrum.Struct.Channel that represents a group DM channel.

A Nostrum.Struct.Channel that represents a channel in a guild.

The id of the channel's guild

A Nostrum.Struct.Channel that represents a text channel in a guild.

A Nostrum.Struct.Channel that represents a voice channel in a guild.

The icon hash of the channel

The channel's id

Id of the last message sent

When the last pinned message was pinned

The name of the channel

If the channel is nsfw

The id of the DM creator

The id of the parent category for a channel

The list of overwrites

The ordered position of the channel

The recipients of the DM

t()

A Nostrum.Struct.Channel that represents a text channel.

Current channel topic

The user limit of the voice channel

A Nostrum.Struct.Channel that represents a voice channel.

Link to this section Types

Link to this type

application_id() View Source
application_id() :: Nostrum.Snowflake.t() | nil

The application id of the group DM creator if it is bot-created

The bitrate of the voice channel

Link to this type

channel_category() View Source
channel_category() :: %Nostrum.Struct.Channel{
  application_id: nil,
  bitrate: nil,
  guild_id: guild_id(),
  icon: nil,
  id: id(),
  last_message_id: nil,
  last_pin_timestamp: nil,
  name: name(),
  nsfw: nsfw(),
  owner_id: nil,
  parent_id: parent_id(),
  permission_overwrites: permission_overwrites(),
  position: position(),
  recipients: nil,
  topic: nil,
  type: 4,
  user_limit: nil
}

A Nostrum.Struct.Channel that represents a channel category in a guild.

Link to this type

dm_channel() View Source
dm_channel() :: %Nostrum.Struct.Channel{
  application_id: nil,
  bitrate: nil,
  guild_id: nil,
  icon: nil,
  id: id(),
  last_message_id: last_message_id(),
  last_pin_timestamp: nil,
  name: nil,
  nsfw: nil,
  owner_id: nil,
  parent_id: nil,
  permission_overwrites: nil,
  position: nil,
  recipients: recipients(),
  topic: nil,
  type: 1,
  user_limit: nil
}

A Nostrum.Struct.Channel that represents a DM channel.

Link to this type

group_dm_channel() View Source
group_dm_channel() :: %Nostrum.Struct.Channel{
  application_id: application_id(),
  bitrate: nil,
  guild_id: nil,
  icon: icon(),
  id: id(),
  last_message_id: last_message_id(),
  last_pin_timestamp: nil,
  name: name(),
  nsfw: nil,
  owner_id: owner_id(),
  parent_id: nil,
  permission_overwrites: nil,
  position: nil,
  recipients: recipients(),
  topic: nil,
  type: 3,
  user_limit: nil
}

A Nostrum.Struct.Channel that represents a group DM channel.

A Nostrum.Struct.Channel that represents a channel in a guild.

The id of the channel's guild

Link to this type

guild_text_channel() View Source
guild_text_channel() :: %Nostrum.Struct.Channel{
  application_id: nil,
  bitrate: nil,
  guild_id: guild_id(),
  icon: nil,
  id: id(),
  last_message_id: last_message_id(),
  last_pin_timestamp: last_pin_timestamp(),
  name: name(),
  nsfw: nsfw(),
  owner_id: nil,
  parent_id: parent_id(),
  permission_overwrites: permission_overwrites(),
  position: position(),
  recipients: nil,
  topic: topic(),
  type: 0,
  user_limit: nil
}

A Nostrum.Struct.Channel that represents a text channel in a guild.

Link to this type

guild_voice_channel() View Source
guild_voice_channel() :: %Nostrum.Struct.Channel{
  application_id: nil,
  bitrate: bitrate(),
  guild_id: guild_id(),
  icon: nil,
  id: id(),
  last_message_id: nil,
  last_pin_timestamp: nil,
  name: name(),
  nsfw: nsfw(),
  owner_id: nil,
  parent_id: parent_id(),
  permission_overwrites: permission_overwrites(),
  position: position(),
  recipients: nil,
  topic: nil,
  type: 2,
  user_limit: user_limit()
}

A Nostrum.Struct.Channel that represents a voice channel in a guild.

The icon hash of the channel

The channel's id

Link to this type

last_message_id() View Source
last_message_id() :: Nostrum.Snowflake.t() | nil

Id of the last message sent

Link to this type

last_pin_timestamp() View Source
last_pin_timestamp() :: String.t() | nil

When the last pinned message was pinned

The name of the channel

If the channel is nsfw

The id of the DM creator

Link to this type

parent_id() View Source
parent_id() :: Nostrum.Snowflake.t() | nil

The id of the parent category for a channel

Link to this type

permission_overwrites() View Source
permission_overwrites() :: [Nostrum.Struct.Overwrite.t()]

The list of overwrites

Link to this type

position() View Source
position() :: integer()

The ordered position of the channel

The recipients of the DM

A Nostrum.Struct.Channel that represents a text channel.

Current channel topic

Link to this type

user_limit() View Source
user_limit() :: integer()

The user limit of the voice channel

Link to this type

voice_channel() View Source
voice_channel() :: guild_voice_channel()

A Nostrum.Struct.Channel that represents a voice channel.

Link to this section Functions

Link to this function

mention(channel) View Source
mention(t()) :: String.t()

Formats a Nostrum.Struct.Channel into a mention.

Examples

iex> channel = %Nostrum.Struct.Channel{id: 381889573426429952}
...> Nostrum.Struct.Channel.mention(channel)
"<#381889573426429952>"