discord-php / DiscordPHP

An API to interact with the popular messaging app Discord
MIT License
977 stars 236 forks source link

Unnecessary manage_roles flag in Channel.php #1115

Closed PakToPack closed 1 year ago

PakToPack commented 1 year ago

Environment

Describe the bug In Channel.php there is a check, whether bot has manage_roles permission. But that is unnecessary, because the bot can do overwrites if it has manage_channels permission.

To Reproduce Steps to reproduce the behavior:

$game_channel->setPermissions($part, array_keys($allow_player), array_keys($deny_cp))->done(function () use ($part, &$added_players, $discord, $player) {
                                $added_players[] = $player['discord_id'];
                                $discord->logger->info((sprintf("Allowed to watch game channel for PLAYER %s", $part->displayname)));
                            },

Expected behavior Add role/member to permission_overwrites

Screenshots https://imgur.com/kJ78qCu

Additional context Maybe I am mistaken. But official documentation for discord API does not require this permission. And it did work without this in V7

SQKo commented 1 year ago

I removed the exception code and it still don't work

[2023-05-06T16:20:22.421946+00:00] DiscordPHP.DEBUG: BUCKET putchannels/872531139275919423/permissions/:overwrite_id queued REQ PUT channels/872531139275919423/permissions/275546238290493440
[2023-05-06T16:20:22.945568+00:00] DiscordPHP.WARNING: REQ PUT channels/872531139275919423/permissions/275546238290493440 failed: Discord\Http\Exceptions\NoPermissionsException: Forbidden - {
    "message": "Missing Permissions",
    "code": 50013
}

Using same code as yours, and bot only has manage_channel permission in the channel gambar

Additional context Maybe I am mistaken. But official documentation for discord API does not require this permission. And it did work without this in V7

You are probably mistaken, the API says clearly it requires the manage_roles (aka manage permissions in the channel)

https://discord.com/developers/docs/resources/channel#edit-channel-permissions

gambar

PakToPack commented 1 year ago

Ok, understood. Closed :)

You actually right. manage_roles is in fact needed