#Discord.net spamming rate limit and getting me IP banned

1 messages · Page 1 of 1 (latest)

mossy helm
#

Has anyone seen discord.net do this? it is a remarkably simple project

#

the only thing I can think of that might be causing this is this

    public async Task UserVoiceStateUpdatedAsync(SocketUser socketUser, SocketVoiceState currentState, SocketVoiceState nextState)
    {
        if (nextState.VoiceChannel.Id == 801249696571850762)
        {
            await nextState.VoiceChannel.GetUser(socketUser.Id).ModifyAsync(x => x.Mute = true);
        }
        
        if (nextState.VoiceChannel == null || nextState.VoiceChannel.Id != 801249696571850762)
        {
            await nextState.VoiceChannel.GetUser(socketUser.Id).ModifyAsync(x => x.Mute = false);
        }
    }
noble siren
#

uhmm

#

that actually is an issue

#

in your code

#

.ModifyAsync(x => x.Mute = true) causes the discord to send a voice state updated event

#

and since the channel id doesn't change

#

it modifyies the user again

#

and again
and again

#

you should add a check & only modify the user if they're unmuted

mossy helm
#

ahh

#

ok i changed it to this

    public async Task UserVoiceStateUpdatedAsync(SocketUser socketUser, SocketVoiceState currentState, SocketVoiceState nextState)
    {
        if (nextState.VoiceChannel.Id == 801249696571850762)
        {
            if (nextState.IsMuted) return;
            await nextState.VoiceChannel.GetUser(socketUser.Id).ModifyAsync(x => x.Mute = true);
        }
        
        if (nextState.VoiceChannel == null || nextState.VoiceChannel.Id != 801249696571850762)
        {
            if (!nextState.IsMuted) return;
            await nextState.VoiceChannel.GetUser(socketUser.Id).ModifyAsync(x => x.Mute = false);
        }
    }

thank you

#

seeing as it knows the rate limit remaining duration it should probably not send another voice state update while its being rate limited tho