votes

package
v0.0.0-...-9c88e82 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 1, 2018 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bot

type Bot struct {
	Log *zap.Logger
	// contains filtered or unexported fields
}

Bot for creating and managing votes

func New

func New(log *zap.Logger) *Bot

New bot with logger

func (*Bot) AddMessageHandler

func (b *Bot) AddMessageHandler(cmd string, f msgFunc)

AddMessageHandler to Bot

func (*Bot) AddReactionHandler

func (b *Bot) AddReactionHandler(title string, f reactFunc)

AddReactionHandler to Bot

func (*Bot) MessageCreate

func (b *Bot) MessageCreate(s *discordgo.Session, m *discordgo.MessageCreate)

MessageCreate Event Handler

func (*Bot) ReactionAdd

func (b *Bot) ReactionAdd(s *discordgo.Session, m *discordgo.MessageReactionAdd)

ReactionAdd Event Handler

func (*Bot) Ready

func (b *Bot) Ready(s *discordgo.Session, event *discordgo.Ready)

Ready Event Handler

func (*Bot) ResetDemocracy

func (b *Bot) ResetDemocracy(c *discordgo.Channel, s *discordgo.Session, m *discordgo.MessageCreate)

ResetDemocracy for the provied guild

type Vote

type Vote struct {
	Guild       string
	ID          string
	CurrentID   string
	Title       string
	Description string
	Author      string
	Created     time.Time
	Expires     time.Time
	Pro         int
	Con         int
}

Vote stores a primitive Vote object

func (*Vote) Embed

Embed from Vote

type VoteHandler

type VoteHandler struct {
	// contains filtered or unexported fields
}

VoteHandler for primitive votes

func NewVoteHandler

func NewVoteHandler(log *zap.Logger) *VoteHandler

NewVoteHandler for channel

func (*VoteHandler) AddVoteEntry

func (v *VoteHandler) AddVoteEntry(vote Vote, author string, value bool) error

AddVoteEntry for user

func (*VoteHandler) DeleteVote

func (v *VoteHandler) DeleteVote(vote Vote) error

DeleteVote from guild

func (*VoteHandler) DeleteVoteEntries

func (v *VoteHandler) DeleteVoteEntries(vote Vote) error

DeleteVoteEntries from guild

func (*VoteHandler) GetVote

func (v *VoteHandler) GetVote(guild, id string) (Vote, error)

GetVote by (current) ID

func (*VoteHandler) GetVoteCount

func (v *VoteHandler) GetVoteCount(vote Vote) (Vote, error)

GetVoteCount for vote

func (*VoteHandler) InitDB

func (v *VoteHandler) InitDB(host, name, user, password string) error

InitDB for persisting votes

func (*VoteHandler) InsertVote

func (v *VoteHandler) InsertVote(vote Vote) error

InsertVote to guild

func (*VoteHandler) MessageCallback

func (v *VoteHandler) MessageCallback(s *discordgo.Session, m *discordgo.MessageCreate, r result)

MessageCallback for handling errors and success messages

func (*VoteHandler) React

React Handler

func (*VoteHandler) ReadVotes

func (v *VoteHandler) ReadVotes(guild string) ([]Vote, error)

ReadVotes for guild

func (*VoteHandler) ReloadVotes

ReloadVotes to channel

func (*VoteHandler) UpdateVote

func (v *VoteHandler) UpdateVote(id string, vote Vote) error

UpdateVote to guild

func (*VoteHandler) UpdateVoteEntry

func (v *VoteHandler) UpdateVoteEntry(vote Vote, author string, value bool) error

UpdateVoteEntry for user

func (*VoteHandler) Vote

Vote Message Handler

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL