-
I'm trying to prevent a user from talking, using my bot. The library seems to support that with: update := discord.MemberUpdate{
Mute: &mute,
}
_, err = e.Client().Rest().UpdateMember(*e.GuildID(), u.ID, update)
if err != nil {
e.Client().Logger().Info("error updating member: ", err)
} The problem is this doesn't work if the target member isn't connected to voice. We instead get an error and the update doesn't happen.
I apply a role to the user which prevents speaking, this auto-mutes the user when they join a voice channel. However if the user is already in a voice channel, they do not get muted, we need to actually "mute" them. The core problem here is that I can't find a way to determine if the user is in a voice channel or not. Does this library have a method of determining if a user is already connected? I also considered using timeout, but I want the user to remain in the voice channel and be able to listen. EDIT: I can probably key off this error code and retry the update without the mute if thats the only way I could achieve this, but I also need to retrieve the channel that a specific user is connected to for another feature in my bot, so this would be useful there as well. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Discord sends information about who is in which voice channel in so called voice states client, err := disgo.New(token, bot.WithGatewayConfigOpts(gateway.WithIntents(other intents, gateway.IntentGuildVoiceStates)),
) There are also events when someone joins, leaves & moves a voice channel |
Beta Was this translation helpful? Give feedback.
Discord sends information about who is in which voice channel in so called voice states
To receive those events you need to enable the
gateway.IntentVoiceStates
To access them later at any time you should also enable the voice states cache via
There are also events when someone joins, leaves & moves a voice channel