Voice: Added intent adders into constructor

This commit is contained in:
diamondburned 2020-11-12 18:55:05 -08:00
parent 456692da93
commit f85aac09be
1 changed files with 7 additions and 0 deletions

View File

@ -52,6 +52,9 @@ func NewVoiceFromToken(token string) (*Voice, error) {
// NewVoice creates a new Voice repository wrapped around a state. The function
// will also automatically add the GuildVoiceStates intent, as that is required.
//
// This function will add the Guilds and GuildVoiceStates intents into the state
// in order to receive the needed events.
func NewVoice(s *state.State) *Voice {
v := &Voice{
State: s,
@ -59,6 +62,10 @@ func NewVoice(s *state.State) *Voice {
ErrorLog: defaultErrorHandler,
}
// Register the voice intents.
s.Gateway.AddIntents(gateway.IntentGuilds)
s.Gateway.AddIntents(gateway.IntentGuildVoiceStates)
// Add the required event handlers to the session.
v.closers = []func(){
s.AddHandler(v.onVoiceStateUpdate),