Skip to content

Commit

Permalink
Add the new poll attribute to Message types
Browse files Browse the repository at this point in the history
Adds the new poll key to the Message structures we have, as well as
mentioning that the Api.create_message methods take the new `poll` attribute.
  • Loading branch information
jb3 committed Apr 13, 2024
1 parent 125bd92 commit 64f2848
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/nostrum/api.ex
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,9 @@ defmodule Nostrum.Api do
* `:embeds` (`t:Nostrum.Struct.Embed.t/0`) - a list of embedded rich content
* `:allowed_mentions` (`t:allowed_mentions/0`) - see the allowed mentions type documentation
* `:message_reference` (`map`) - See "Message references" below
* `:poll` (`t:Nostrum.Struct.Message.Poll.t/0`) - A poll object to send with the message
At least one of the following is required: `:content`, `:file`, `:embeds`.
At least one of the following is required: `:content`, `:file`, `:embeds`, `:poll`.
### Message reference
Expand Down
9 changes: 8 additions & 1 deletion lib/nostrum/struct/message.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ defmodule Nostrum.Struct.Message do
Component,
Reaction,
Reference,
Sticker
Sticker,
Poll
}

alias Nostrum.{Snowflake, Util}
Expand All @@ -43,6 +44,7 @@ defmodule Nostrum.Struct.Message do
:message_reference,
:nonce,
:pinned,
:poll,
:reactions,
:referenced_message,
:sticker_items,
Expand Down Expand Up @@ -113,6 +115,9 @@ defmodule Nostrum.Struct.Message do
"""
@type interaction :: Interaction.t()

@typedoc "The poll object attached to the message"
@type poll :: Poll.t()

@typedoc "List of embedded content in the message"
@type embeds :: [Embed.t()]

Expand Down Expand Up @@ -217,6 +222,7 @@ defmodule Nostrum.Struct.Message do
message_reference: message_reference,
nonce: nonce,
pinned: pinned,
poll: poll,
reactions: reactions,
referenced_message: referenced_message,
sticker_items: sticker_items,
Expand Down Expand Up @@ -250,6 +256,7 @@ defmodule Nostrum.Struct.Message do
|> Map.update(:mentions, nil, &Util.cast(&1, {:list, {:struct, User}}))
|> Map.update(:message_reference, nil, &Util.cast(&1, {:struct, Reference}))
|> Map.update(:nonce, nil, &Util.cast(&1, Snowflake))
|> Map.update(:poll, nil, &Util.cast(&1, {:struct, Poll}))
|> Map.update(:reactions, nil, &Util.cast(&1, {:list, {:struct, Reaction}}))
|> Map.update(:referenced_message, nil, &Util.cast(&1, {:struct, __MODULE__}))
|> Map.update(:sticker_items, nil, &Util.cast(&1, {:list, {:struct, Sticker}}))
Expand Down

0 comments on commit 64f2848

Please sign in to comment.