Closed php-wizard closed 1 year ago
The library does not support use of react/async in v7.x, The support was added in v10.x only
Also you are not supposed to use the permission constants directly like ChannelPermission::TEXT_PERMISSIONS
(they are just the bit position, not the value), you need to create the ChannelPermission object first then set the $channel_permission->text_permission_here = false
, Or Use the simple 'allow' 'deny' associative array as shown in the documentation: https://discord-php.github.io/DiscordPHP/ in the section of "Set permissions of a member or role"
// Member can send messages and attach files,
// but can't add reactions to message.
$channel->setPermissions($member, [
'send_messages',
'attach_files',
], [
'add_reactions',
])->done(function () {
// ...
});
or:
$allow = new ChannelPermission($discord, [
'send_messages' => true,
'attach_files' => true,
]);
$deny = new ChannelPermission($discord, [
'add_reactions' => true,
]);
$overwrite = $channel->overwrites->create([
'allow' => $allow,
'deny' => $deny,
]);
// Member can send messages and attach files,
// but can't add reactions to message.
$channel->setOverwrite($member, $overwrite)->done(function () {
// ...
});
Environment
Describe the bug Channel::setPermissions seems to have no effect on text channels
Additional context
I have a
Discord\Parts\Channel
instance$channel
, and a member instance, which i obtained viaNow, i am trying to "mute" the member on the channel, where for muting i mean
This is the code i have tried, which fails on text channels (and i haven't tested yet on voice channels)
When trying the above for a text channel, "muted" gets printed out like it succeeded, but actually it had no effect. I may have passed wrong values to
$channel->setPermissions()
.Now, the declaration of
Channel::setPermission()
isThe first param can be a Role or a Member, the second one seems to be the permissions i want to "unlock" (allow), and in this case no one, and the third param seems to be the permissions i want to deny. I have passed
ChannelPermission::TEXT_PERMISSIONS
, which is defined inDiscord\Parts\Permissions\Permission
(parent ofChannelPermissions
) as:So, send_messages is in the permissions i am denying, but it has no effect. I cannot figure out what's wrong, and whether it was correct to pass that
ChannelPermission::TEXT_PERMISSIONS
to the third param (or anything else i am missing). Anyone can help me? Thank you