Overwrite - discord-php/DiscordPHP GitHub Wiki
Overwrites are part of Channel. Also known as "Channel Permissions" in Discord.
use Discord\Parts\Channel\Overwrite;
You must first get the Channel object to use the code below. Change 123123123123123123
below with the User ID or Role ID
Cached, synchronous:
$overwrite = $channel->overwrites->get('id', '123123123123123123');
Your BOT must have manage_roles
permission
You must first get the Channel object and the Member object to use the code below
Set $member
permission in the $channel
to allow send messages, attach files, but deny add reaction:
$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)->then(function () {
// ...
})->done();
https://discord.com/developers/docs/resources/channel#edit-channel-permissions