DiscordState

package
v0.3.0-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2016 License: GPL-2.0 Imports: 2 Imported by: 8

Documentation

Overview

Package DiscordState is an abstraction layer that gives proper structs and functions to get and set the current state of the cli server

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Session

type Session struct {
	Username  string
	Password  string
	DiscordGo *discordgo.Session
	Guilds    []*discordgo.Guild
}

Session contains the 'state' of the attached server

func NewSession

func NewSession(Username, Password string) *Session

NewSession Creates a new Session

func (*Session) NewState

func (Session *Session) NewState(GuildID string, MessageAmount int) (*State, error)

NewState (constructor) attaches a new state to the Guild inside a Session, and fills it.

func (*Session) Start

func (Session *Session) Start() error

Start attaches a discordgo listener to the Sessions and fills it.

func (*Session) Update

func (Session *Session) Update() error

Update updates the session, this reloads the Guild list

type State

type State struct {
	Guild         *discordgo.Guild
	Channel       *discordgo.Channel
	Channels      []*discordgo.Channel
	Members       map[string]*discordgo.Member
	Messages      []*discordgo.Message
	Session       *Session
	MessageAmount int  //Amount of Messages to keep in State
	Enabled       bool //Toggles State for Event handling
}

State is the current state of the attached client

func (*State) AddMember

func (State *State) AddMember(Member *discordgo.Member)

AddMember adds Member to State

func (*State) AddMessage

func (State *State) AddMessage(Message *discordgo.Message)

AddMessage adds Message to State

func (*State) DelMember

func (State *State) DelMember(Member *discordgo.Member)

DelMember deletes Member from State

func (*State) DelMessage

func (State *State) DelMessage(Message *discordgo.Message)

DelMessage deletes Message from State

func (*State) EditMessage

func (State *State) EditMessage(Message *discordgo.Message)

EditMessage edits Message inside State

func (*State) RetrieveMessages

func (State *State) RetrieveMessages(Amount int) error

RetrieveMessages retrieves last N Messages and puts it in state

func (*State) SetChannel

func (State *State) SetChannel(ID string)

SetChannel sets the channel of the current State

Jump to

Keyboard shortcuts

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