This repository was archived by the owner on Jul 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 68
This repository was archived by the owner on Jul 11, 2024. It is now read-only.
Guild.VoiceStates not kept up to date #438
Copy link
Copy link
Open
Labels
Description
Describe the bug
Guild.VoiceStates
isn't kept up to date as new VoiceStateUpdate
events are received. It looks as though the initial value is kept from the GuildCreate
event, and never updated.
Expected behavior
It's possible this is the intended behavior (for disgord
to not track state updates). If this is the case, it would be nice to have the struct field documented to make this obvious. If it's intended, could support be added to keep it up to date?
Configuration
- Golang version: [e.g. v1.17.2]
- Using Go modules? yes
- Disgord version? v0.29
- Connected to the gateway before using REST methods? yes
Additional context
Code used to replicate the issue:
package main
import (
"context"
"os"
"github.com/andersfylling/disgord"
"github.com/sirupsen/logrus"
)
var log = &logrus.Logger{
Out: os.Stdout,
Formatter: new(logrus.TextFormatter),
Hooks: make(logrus.LevelHooks),
Level: logrus.DebugLevel,
}
func main() {
client := disgord.New(disgord.Config{
BotToken: "TRUNCATED",
Presence: &disgord.UpdateStatusPayload{
Since: nil,
Game: []*disgord.Activity{
{Name: "voice chan curator", Type: disgord.ActivityTypeGame},
},
Status: disgord.StatusOnline,
AFK: false,
},
DisableCache: false,
Logger: log,
RejectEvents: disgord.AllEventsExcept(
disgord.EvtReady,
disgord.EvtResumed,
disgord.EvtGuildCreate,
disgord.EvtGuildUpdate,
disgord.EvtGuildDelete,
disgord.EvtGuildRoleCreate,
disgord.EvtGuildRoleUpdate,
disgord.EvtGuildRoleDelete,
disgord.EvtChannelCreate,
disgord.EvtChannelUpdate,
disgord.EvtChannelDelete,
disgord.EvtVoiceStateUpdate,
),
})
gw := client.Gateway().WithContext(context.TODO())
gw.GuildCreate(func(s disgord.Session, h *disgord.GuildCreate) {
log.Infof("guild create: %d", len(h.Guild.VoiceStates))
})
gw.VoiceStateUpdate(func(s disgord.Session, h *disgord.VoiceStateUpdate) {
guild, err := s.Guild(h.GuildID).Get()
if err != nil {
panic(err)
}
log.Infof("voice state update: %d", len(guild.VoiceStates))
})
if err := gw.StayConnectedUntilInterrupted(); err != nil {
panic(err)
}
}
Important output:
[...]
INFO[0000] guild create: 0 <- guild that has no existing users in voice channels
INFO[0000] guild create: 1 <- guild that has 1 existing user in voice channel
INFO[0018] voice state update: 1 <- user left the voice channel, but VoiceStates is still showing the user in the channel
INFO[0027] voice state update: 1 <- rejoined
INFO[0029] voice state update: 1 <- left again
[...]
beachasaurus-rex and alexandregv