Skip to content

Commit

Permalink
Add new typing for new gateway events to consumer
Browse files Browse the repository at this point in the history
  • Loading branch information
jb3 committed Apr 14, 2024
1 parent 594eb47 commit 22ee041
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/nostrum/consumer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ defmodule Nostrum.Consumer do
MessageReactionRemove,
MessageReactionRemoveAll,
MessageReactionRemoveEmoji,
PollVoteChange,
Ready,
SpeakingUpdate,
ThreadListSync,
Expand Down Expand Up @@ -325,6 +326,17 @@ defmodule Nostrum.Consumer do
Dispatched when member(s) are added or removed from a thread
"""
@type thread_members_update :: {:THREAD_MEMBERS_UPDATE, ThreadMembersUpdate.t(), WSState.t()}

@typedoc """
Dispatched when a user adds a vote to a poll.
"""
@type message_poll_vote_add :: {:MESSAGE_POLL_VOTE_ADD, PollVoteChange.t(), WSState.t()}

@typedoc """
Dispatched when a user removes a vote from a poll.
"""
@type message_poll_vote_remove :: {:MESSAGE_POLL_VOTE_REMVE, PollVoteChange.t(), WSState.t()}

@type event ::
auto_moderation_rule_create
| auto_moderation_rule_delete
Expand Down Expand Up @@ -364,6 +376,8 @@ defmodule Nostrum.Consumer do
| message_reaction_remove
| message_reaction_remove_all
| message_ack
| message_poll_vote_add
| message_poll_vote_remove
| presence_update
| ready
| resumed
Expand Down
10 changes: 10 additions & 0 deletions lib/nostrum/struct/event/poll_vote_change.ex
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ defmodule Nostrum.Struct.Event.PollVoteChange do
@typedoc "Whether the vote was an add or removal for the option"
@type type :: :add | :remove

@typedoc "Event representing a add/removal of a vote from a poll"
@type t :: %__MODULE__{
user_id: user_id,
channel_id: channel_id,
message_id: message_id,
guild_id: guild_id,
answer_id: answer_id,
type: type
}

@doc false
def to_struct(map) do
new =
Expand Down

0 comments on commit 22ee041

Please # to comment.