-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #534 from Kraigie/jb3/polls
Add support for polls
- Loading branch information
Showing
18 changed files
with
519 additions
and
14 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
defmodule Nostrum.Struct.Event.PollVoteChange do | ||
@moduledoc """ | ||
Represents an addition or removal of a vote from a Discord poll. | ||
For polls where multiple answers were selected, one of these events will be fired for each vote. | ||
""" | ||
alias Nostrum.Util | ||
|
||
alias Nostrum.Struct.{Channel, Guild, Message, User} | ||
|
||
defstruct [:user_id, :channel_id, :message_id, :guild_id, :answer_id, :type] | ||
|
||
@typedoc "ID of the user that has voted" | ||
@type user_id :: User.id() | ||
|
||
@typedoc "ID of the channel the vote took place in" | ||
@type channel_id :: Channel.id() | ||
|
||
@typedoc "ID of the message the poll was attached to" | ||
@type message_id :: Message.id() | ||
|
||
@typedoc "ID of the guild the poll is in (unless it is a private channel)" | ||
@type guild_id :: Guild.id() | ||
|
||
@typedoc "ID corresponding to the answer_id in the `t:Nostrum.Struct.Message.Poll.answers/0` list" | ||
@type answer_id :: integer | ||
|
||
@typedoc "Whether the vote was an addition or removal for a vote of the option" | ||
@type type :: :add | :remove | ||
|
||
@typedoc "Event representing a addition or 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 = Map.new(map, fn {k, v} -> {Util.maybe_to_atom(k), v} end) | ||
|
||
struct(__MODULE__, new) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.