Nostrum.Struct.Channel (Nostrum v0.4.6) 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

Specs

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

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

Specs

bitrate() :: integer()

The bitrate of the voice channel

Specs

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.

Specs

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.

Specs

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.

Specs

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

Specs

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

The id of the channel's guild

Specs

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.

Specs

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.

Specs

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

The icon hash of the channel

Specs

The channel's id

Specs

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

Id of the last message sent

Specs

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

When the last pinned message was pinned

Specs

name() :: String.t()

The name of the channel

Specs

nsfw() :: boolean()

If the channel is nsfw

Specs

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

The id of the DM creator

Specs

parent_id() :: id() | nil

The id of the parent category for a channel

Link to this type

permission_overwrites()

View Source

Specs

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

The list of overwrites

Specs

position() :: integer()

The ordered position of the channel

Specs

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

The recipients of the DM

Specs

Specs

text_channel() :: guild_text_channel() | dm_channel() | group_dm_channel()

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

Specs

topic() :: String.t()

Current channel topic

Specs

user_limit() :: integer()

The user limit of the voice channel

Specs

voice_channel() :: guild_voice_channel()

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

Link to this section Functions

Specs

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>"