shardlab / discordrb

Discord API for Ruby
MIT License
519 stars 96 forks source link

Allow kicking user from voice channels with `Server.move` by passing `nil` for `channel_id` #185

Open gregdan3 opened 1 year ago

gregdan3 commented 1 year ago

Discord.js and discordpy both support this feature by passing their equivalent of nil:

discordrb's equivalent, Server.move, evaluates the channel's ID and fails if nil is passed.

Admittedly, I don't immediately see how this is possible via the API, as the modify user voice state endpoint doesn't allow for a null channel id.

https://discord.com/developers/docs/resources/guild#modify-current-user-voice-state

Still, given this is implemented in two other libraries, it must be possible.

Sobsz commented 1 year ago

Confusingly, the relevant request is actually Modify Guild Member, as Modify User Voice State is stated to only work on stage channels. The former's documentation states:

If the channel_id is set to null, this will force the target user to be disconnected from voice.

swarley commented 1 year ago

Howdy, you've identified an issue that we've been living with for a while due to some poor design in our API handler that the rest of the library depends on.

Basically, we don't have a way to send a null value to the HTTP API because we compact out null values just before sending the request.

I'm going to look into a workaround to make this sort of thing possible in v3 before we switch to work on v4

Dakurei commented 1 year ago

I randomly found this, and in fact it's easily possible since the acceptance of PR #113

It's been a while since the method no longer deletes values at nil, but as it was on the v3.4.2 gem doc, and not the 'main' branch one (as the issue link suggests), it wasn't noticed.

All it takes is one character to solve the problem 🤣 allow_kick_from_voice

I can send a quick PR if needed 👍