discordgo_voicestateupdatequeue

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2020 License: MIT Imports: 2 Imported by: 0

README

discordgo_voicestateupdatequeue

Event enhancer and queue for the DiscordGo VoiceStateUpdate event

PkgGoDev

Features

  • Cleans up raw events from Discord using an internal cache.
  • Transparently handles voice channel moves, providing them to the consumer as a leave then join event.
  • Consistently sends events with both GuildID and ChannelID. (Except for the VoiceChannelLeaveUnknownChannel event.)

Install

go get github.com/ethanent/discordgo_voicestateupdatequeue

Use

Create a channel through which to receive VoiceStateEvents.

c := make(chan *queue.VoiceStateEvent)

Create a new VoiceStateEventQueue and give it the channel.

q := queue.NewVoiceStateEventQueue(c)

Add the queue's handler to your session.

// Assuming your *discordgo.Session is called s:

s.AddHandler(q.Handler)

Then you can use the channel to receive VoiceStateEvents while the bot is running.

The events will contain a type (join, leave, leave from untracked channel, settings update) and other associated fields.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type VoiceStateEvent

type VoiceStateEvent struct {
	Type           VoiceStateEventType
	GuildID        string
	ChannelID      string
	UserID         string
	OriginalUpdate *discordgo.VoiceStateUpdate
}

VoiceStateEvent is adapted from a VoiceStateUpdate received from discordgo. It is enhanced with a cache. It makes the nature of events much more clear to the consumer. It also handles channel moves seamlessly, converting them to separate leave and join events.

type VoiceStateEventQueue

type VoiceStateEventQueue struct {
	Out chan *VoiceStateEvent
	// contains filtered or unexported fields
}

func NewVoiceStateEventQueue

func NewVoiceStateEventQueue(c chan *VoiceStateEvent) *VoiceStateEventQueue

func (*VoiceStateEventQueue) Handler

type VoiceStateEventType

type VoiceStateEventType int
const (
	// A user has joined a voice channel.
	VoiceChannelJoin VoiceStateEventType = iota

	// A user has left a tracked voice channel.
	VoiceChannelLeave

	// A user has left an untracked channel. ChannelID will not be available, but GuildID still will be.
	VoiceChannelLeaveUnknownChannel

	// A user has changed a setting (eg. mute) without switching channels.
	VoiceChannelSettingUpdate
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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