Discord.Net icon indicating copy to clipboard operation
Discord.Net copied to clipboard

SpeakingUpdated only triggering once per user

Open n1kPLV opened this issue 5 years ago • 9 comments

A few months ago every time somebody in a channel with the bot connected to started or stopped to speak, the SpeakingUpdated event on the audioClient was triggered. But now it only gets triggered the first time a user in a channel starts to speak. Is there anything I need to do to reset the event trigger or is this a bug with the API?

n1kPLV avatar Dec 11 '19 14:12 n1kPLV

Can you provide example code for us to replicate the bug?

jnccd avatar Jun 01 '20 17:06 jnccd

Here is some example code for the Audio side:

public class AudioService
{
    private readonly DiscordSocketClient _discord;

    public AudioService(IServiceProvider services)
    {
        _discord = services.GetRequiredService<DiscordSocketClient>();
    }

    public async Task JoinAudio(IGuild guild, IVoiceChannel target)
    {
        var audioClient = await target.ConnectAsync();
        audioClient.SpeakingUpdated  += AudioClient_SpeakingUpdated;
    }

    private async Task AudioClient_SpeakingUpdated(ulong userID, bool speaking)
    {
        Task<SocketUser> user = Task.Run(() => _discord.GetUser(userID));
        Console.WriteLine((await user).Username + (speaking ? " started" : " stopped") + " speaking");
    }
}

A proof-of-concept project can be found here. It will only produce output like this even when speaking is interrupted (green circle in Discord disappears):

20:22:59 Discord     Discord.Net v2.2.0 (API v6)
20:23:00 Gateway     Connecting
20:23:00 Gateway     Connected
20:23:01 Gateway     Ready
20:23:15 Audio #1    Connecting
20:23:15 Audio #1    Unknown OpCode (Hello)
20:23:15 Audio #1    Connected
n1kPLV started speaking

Edit: Clarified the example Code and fixed some typos

n1kPLV avatar Jun 01 '20 18:06 n1kPLV

I also have the same issue. I am able to receive audio bytes on the AudioInStream for the user, but the SpeakingUpdated events don't fire more than once.

monodop avatar Sep 17 '20 05:09 monodop

Still seeing this issue as of today. Trying to determine when the user has started and stopped speaking but this event only fires once when the user starts speaking.

Thelnquisitor avatar Dec 25 '20 21:12 Thelnquisitor

Just ran into this as well.

Also cannot connect to foxbot.me at all to grab opus.dll files - bit skunked there as well.

Any updates on this issue?

Fenrisul avatar Jan 09 '21 08:01 Fenrisul

Still seeing this issue. The event is fired once when the user starts speaking.

Nights87 avatar Feb 02 '21 10:02 Nights87

I found same issue was occured another library.

https://github.com/discordjs/discord.js/issues/3524

Thus, I think maybe this issue isn't this library's problem. then Discord's problem.

Tokeiya avatar Feb 07 '21 04:02 Tokeiya

If you go to the link supplied in that issue to another issue, one user describes the event firing twice.

https://github.com/discordjs/discord.js/issues/3524#issuecomment-540898469

Need some input from the lib developers, would be useful to know if this is an actual issue on the library side or Discord's side.

Thelnquisitor avatar Feb 07 '21 06:02 Thelnquisitor

Anyone found a fix for this yet?

Somfic avatar Jul 28 '22 23:07 Somfic