Channel - discord-php/DiscordPHP GitHub Wiki
Channels can be either part of Guild (Server), Group Channel (Group Direct Message), User Private Channel (Direct Message).
use Discord\Parts\Channel\Channel;A Channel can be either a text or voice channel on a Discord guild.
- 
MessageRepository Only in Text Channels $channel->messages
- 
OverwriteRepository $channel->overwrites
- ThreadRepository Incoming in v7
- 
WebhookRepository $channel->webhooks
- 
VoiceMemberRepository as MemberRepository Only in Voice Channels $channel->members
Requires GUILD intent
Your BOT must have manage_channels permission
You must first get the Guild object to use the code below
Create a text channel #mychannel with topic "Welcome to my channel!" with NSFW off:
$newchannel = $guild->channels->create([
    'name' => 'mychannel',
    // All other options are optional
    'type' => Channel::TYPE_TEXT,
    'topic' => 'Welcome to my channel!',
    'nsfw' => false,
    // more options in Docs
]);
$guild->channels->save($newchannel)->then(function (Channel $channel) {
    echo 'Created a new text channel - ID: ', $channel->id;
})->done();https://discord.com/developers/docs/resources/guild#create-guild-channel
Change 123123123123123123 below with the Channel ID you want to retrieve
Cached, synchronous:
$channel = $discord->getChannel('123123123123123123');You must first get the Guild object to use the code below
Cached, synchronous:
$channel = $guild->channels->get('id', '123123123123123123');If the code above returns null, you may need to fetch it first (Promise, asynchronous):
$guild->channels->fetch('123123123123123123')->then(function (Channel $channel) {
    // ...
})->done();https://discord.com/developers/docs/resources/channel#get-channel
Channel can be also retrieved from related objects:
- 
Message $channel = $message->channel;channel where the message is on
- 
Invite $channel = $invite->channel;channel where the invite is made for
- 
Webhook $channel = $webhook->channel;channel where the webhook belongs to
Your BOT must have send_messages permission
Send "Hello world!" to the $channel:
$channel->sendMessage('Hello world!');https://discord.com/developers/docs/resources/channel#create-message
Your BOT must have move_members permission
You must first get the Member object to use the code below
Move the $member to the $channel:
$channel->moveMember($member)->then(function () {
    // ...
})->done();Or, change 123123123123123123 below with the Member ID:
$channel->moveMember('123123123123123123')->then(function () {
    // ...
})->done();https://discord.com/developers/docs/resources/guild#modify-guild-member
Your BOT must have manage_roles permission
You must first get the Member object to use the code below
Set $member permission in the $channel to allow send messages, attach files, but deny add reaction:
$channel->setPermissions($member, [
    'send_messages',
    'attach_files',
], [
    'add_reactions',
])
->then(function () {
    // ...
})
->done();https://discord.com/developers/docs/resources/channel#edit-channel-permissions
You can update channel properties like the name, topic, nsfw, slowmode, etc
Your BOT must have manage_channels permission
You must first get the Guild and the Channel object to use the code below
Rename a text channel to #mycoolchannel:
$myChannel = $guild->channels->get('123123123123123123');
$myChannel->name = 'mycoolchannel';
$guild->channels->save($myChannel)->then(function (Channel $channel) {
    echo 'Renamed my channel to: ', $channel->name;
})->done();https://discord.com/developers/docs/resources/channel#modify-channel
Your BOT must have manage_channels permission
You must first get the Guild object to use the code below. You can either use the Channel object or the snowflake ID
$guild->channels->delete('123123123123123123')->then(function (Channel $channel) {
    echo 'Deleted channel: ', $channel->name;
})->done();https://discord.com/developers/docs/resources/channel#deleteclose-channel