Documentation ¶
Index ¶
- Variables
- func HashUserID(userID string, salt []byte) (hash string, err error)
- type Tick
- type Vote
- func (v *Vote) AddReactions(s *discordgo.Session) error
- func (v *Vote) AsEmbed(s *discordgo.Session, voteState ...VoteState) (*discordgo.MessageEmbed, error)
- func (v *Vote) AsField() *discordgo.MessageEmbedField
- func (v *Vote) Close(s *discordgo.Session, voteState VoteState) error
- func (v *Vote) Marshal() (string, error)
- func (v *Vote) SetExpire(s *discordgo.Session, d time.Duration, tp timeprovider.Provider) error
- func (v *Vote) Tick(s *discordgo.Session, userID string, tick int) (err error)
- type VoteState
Constants ¶
This section is empty.
Variables ¶
var VoteEmotes = strings.Fields("\u0031\u20E3 \u0032\u20E3 \u0033\u20E3 \u0034\u20E3 \u0035\u20E3 \u0036\u20E3 \u0037\u20E3 \u0038\u20E3 \u0039\u20E3 \u0030\u20E3")
VoteEmotes contains the emotes used to tick a vote.
var VotesRunning = map[string]Vote{}
VotesRunning maps running vote IDs to their vote instances.
Functions ¶
Types ¶
type Vote ¶
type Vote struct { ID string MsgID string CreatorID string GuildID string ChannelID string Description string ImageURL string Expires time.Time Possibilities []string Ticks map[string]*Tick }
Vote wraps the information and current state of a vote and its ticks.
func Unmarshal ¶
Unmarshal tries to deserialize a raw data string to a Vote object. Errors occured during deserialization are returned as well.
func (*Vote) AddReactions ¶
AddReactions adds the reactions to the votes message for each selection possibility.
Vote emotes are used from VoteEmotes.
func (*Vote) AsEmbed ¶
func (v *Vote) AsEmbed(s *discordgo.Session, voteState ...VoteState) (*discordgo.MessageEmbed, error)
AsEmbed creates a discordgo.MessageEmbed from the vote. If voteState is passed, the state will be displayed as well. Otherwise, it will be assumed that the vote is open.
If voteState is VoteStateClosed or VoteStateExpired, a pie chart will be generated representing the distribution of vote ticks and sent as image to the channel.
func (*Vote) AsField ¶
func (v *Vote) AsField() *discordgo.MessageEmbedField
AsField creates a discordgo.MessageEmbedField from the vote information.
func (*Vote) Marshal ¶
Marshal serializes the vote to a raw data string.
The vote object is encoded to a byte array using the gob encoder and then encoded to a base64 string.