mirror of
https://github.com/diamondburned/arikawa.git
synced 2025-02-15 07:53:21 +00:00
Voice: Allow New without intents
This commit is contained in:
parent
29582d6131
commit
0d427cab71
|
@ -56,16 +56,21 @@ func NewVoiceFromToken(token string) (*Voice, error) {
|
||||||
// This function will add the Guilds and GuildVoiceStates intents into the state
|
// This function will add the Guilds and GuildVoiceStates intents into the state
|
||||||
// in order to receive the needed events.
|
// in order to receive the needed events.
|
||||||
func NewVoice(s *state.State) *Voice {
|
func NewVoice(s *state.State) *Voice {
|
||||||
|
// Register the voice intents.
|
||||||
|
s.Gateway.AddIntents(gateway.IntentGuilds)
|
||||||
|
s.Gateway.AddIntents(gateway.IntentGuildVoiceStates)
|
||||||
|
return NewVoiceWithoutIntents(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewVoice creates a new Voice repository wrapped around a state without
|
||||||
|
// modifying the given Gateway to add intents.
|
||||||
|
func NewVoiceWithoutIntents(s *state.State) *Voice {
|
||||||
v := &Voice{
|
v := &Voice{
|
||||||
State: s,
|
State: s,
|
||||||
sessions: make(map[discord.GuildID]*Session),
|
sessions: make(map[discord.GuildID]*Session),
|
||||||
ErrorLog: defaultErrorHandler,
|
ErrorLog: defaultErrorHandler,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register the voice intents.
|
|
||||||
s.Gateway.AddIntents(gateway.IntentGuilds)
|
|
||||||
s.Gateway.AddIntents(gateway.IntentGuildVoiceStates)
|
|
||||||
|
|
||||||
// Add the required event handlers to the session.
|
// Add the required event handlers to the session.
|
||||||
v.closers = []func(){
|
v.closers = []func(){
|
||||||
s.AddHandler(v.onVoiceStateUpdate),
|
s.AddHandler(v.onVoiceStateUpdate),
|
||||||
|
|
Loading…
Reference in a new issue