crux_structs v0.2.3 Crux.Structs.Channel View Source
Represents a Discord Channel Object.
List of where every property can be present:
| Property | Text (0) | DM (1) | Voice (2) | Group (3) | Category (4) | News (5) |
|---|---|---|---|---|---|---|
| application_id | no | no | no | yes | no | no |
| bitrate | no | no | yes | no | no | no |
| guild_id | yes | no | yes | no | yes | yes |
| icon | no | no | no | yes | no | no |
| id | yes | yes | yes | yes | yes | yes |
| last_message_id | yes | yes | no | yes | no | yes |
| last_pin_timestamp | yes | yes | no | yes | no | yes |
| name | yes | no | yes | yes | yes | yes |
| nsfw | yes | no | no | no | no | yes |
| owner_id | no | no | no | yes | no | no |
| parent_id | yes | no | yes | no | no | yes |
| permission_overwrites | yes | no | yes | no | yes | yes |
| position | yes | no | yes | no | yes | yes |
| rate_limit_per_user | yes | no | no | no | no | no |
| recipients | no | yes<br>(One Element) | no | yes | no | no |
| topic | yes | no | yes | no | yes | yes |
| type | 0 | 1 | 2 | 3 | 4 | 5 |
| user_limit | no | no | yes | no | no | no |
Differences opposed to the Discord API Object:
:recipientsis a MapSet of user ids
Link to this section Summary
Types
All available types that can be resolved into a channel id.
All available types that can be resolved into a channel position.
| Type | ID | Description |
|---|---|---|
| GUILD_TEXT | 0 | A text channel within a guild. |
| DM | 1 | A direct text channel between two users. |
| GUILD_VOICE | 2 | A voice channel withing a guild. |
| GROUP_DM | 3 | A direct channel between multiple users.<br>Bots do not have access to those. |
| GUILD_CATEGORY | 4 | An organizational category. |
| GUILD_NEWS | 5 | A text channel users can follow and crosspost messages to.<br>Bots can not publish messages. |
| GUILD_STORE | 6 | A channel in which game developers can sell their game.<br>Bots can not interact with those. |
For more information see the Discord Developer Documentation.
Functions
Creates a t:Crux.Structs.Channel.t/0 struct from raw data.
Resolves the id of a t:Crux.Structs.Channel.t/0.
Resolves a t:position_resolvable/0 into a channel position.
Converts a t:Crux.Structs.Channel.t/0 into its discord mention format.
Link to this section Types
Specs
id_resolvable() :: Crux.Structs.Message.t() | Crux.Structs.Channel.t() | Crux.Structs.Snowflake.t() | String.t()
All available types that can be resolved into a channel id.
Specs
position_resolvable() :: Crux.Structs.Channel.t() | %{channel: id_resolvable(), position: integer()} | {id_resolvable(), integer()} | %{id: id_resolvable(), position: integer()}
All available types that can be resolved into a channel position.
Specs
t() :: %Crux.Structs.Channel{
application_id: Crux.Structs.Snowflake.t(),
bitrate: integer(),
guild_id: Crux.Structs.Snowflake.t(),
icon: String.t(),
id: Crux.Structs.Snowflake.t(),
last_message_id: Crux.Structs.Snowflake.t(),
last_pin_timestamp: String.t(),
name: String.t(),
nsfw: boolean(),
owner_id: Crux.Structs.Snowflake.t(),
parent_id: Crux.Structs.Snowflake.t(),
permission_overwrites: %{
optional(Crux.Structs.Snowflake.t()) => Crux.Structs.Overwrite.t()
},
position: integer(),
rate_limit_per_user: integer(),
recipients: MapSet.t(Crux.Structs.Snowflake.t()),
topic: String.t(),
type: type(),
user_limit: non_neg_integer()
}
Specs
type() :: non_neg_integer()
| Type | ID | Description |
|---|---|---|
| GUILD_TEXT | 0 | A text channel within a guild. |
| DM | 1 | A direct text channel between two users. |
| GUILD_VOICE | 2 | A voice channel withing a guild. |
| GROUP_DM | 3 | A direct channel between multiple users.<br>Bots do not have access to those. |
| GUILD_CATEGORY | 4 | An organizational category. |
| GUILD_NEWS | 5 | A text channel users can follow and crosspost messages to.<br>Bots can not publish messages. |
| GUILD_STORE | 6 | A channel in which game developers can sell their game.<br>Bots can not interact with those. |
For more information see the Discord Developer Documentation.
Link to this section Functions
Specs
Creates a t:Crux.Structs.Channel.t/0 struct from raw data.
Automatically invoked by
Crux.Structs.create/2
Specs
resolve_id(id_resolvable()) :: Crux.Structs.Snowflake.t() | nil
Resolves the id of a t:Crux.Structs.Channel.t/0.
Automatically invoked by
Crux.Structs.resolve_id/2.
iex> %Crux.Structs.Message{channel_id: 222079895583457280}
...> |> Crux.Structs.Channel.resolve_id()
222079895583457280
iex> %Crux.Structs.Channel{id: 222079895583457280}
...> |> Crux.Structs.Channel.resolve_id()
222079895583457280
iex> 222079895583457280
...> |> Crux.Structs.Channel.resolve_id()
222079895583457280
iex> "222079895583457280"
...> |> Crux.Structs.Channel.resolve_id()
222079895583457280
Specs
resolve_position(position_resolvable()) :: %{id: Crux.Structs.Snowflake.t(), position: integer()} | nil
Resolves a t:position_resolvable/0 into a channel position.
Examples
iex> %Crux.Structs.Channel{id: 222079895583457280, position: 5}
...> |> Crux.Structs.Channel.resolve_position()
%{id: 222079895583457280, position: 5}
iex> {%Crux.Structs.Channel{id: 222079895583457280}, 5}
...> |> Crux.Structs.Channel.resolve_position()
%{id: 222079895583457280, position: 5}
iex> {222079895583457280, 5}
...> |> Crux.Structs.Channel.resolve_position()
%{id: 222079895583457280, position: 5}
iex> %{id: 222079895583457280, position: 5}
...> |> Crux.Structs.Channel.resolve_position()
%{id: 222079895583457280, position: 5}
iex> %{channel: 222079895583457280, position: 5}
...> |> Crux.Structs.Channel.resolve_position()
%{id: 222079895583457280, position: 5}
iex> {nil, 5}
...> |> Crux.Structs.Channel.resolve_position()
nil
Specs
to_mention(user :: Crux.Structs.Channel.t()) :: String.t()
Converts a t:Crux.Structs.Channel.t/0 into its discord mention format.
Example
iex> %Crux.Structs.Channel{id: 316880197314019329}
...> |> Crux.Structs.Channel.to_mention()
"<#316880197314019329>"