Skip to content

Channels

Marco Cusano edited this page May 7, 2019 · 3 revisions

bulkDelete external-link

Delete multiple messages in a single request. This endpoint can only be used on guild channels and requires the MANAGE_MESSAGES permission. Returns a 204 empty response on success.

$discord->channels->bulkDelete("CHANNEL_ID");

create external-link

Create a new channel object for the guild. Requires the MANAGE_CHANNELS permission. Returns the new channel object on success.

$params = array(
    "name" => "channel-name",
    "type" => 0
);
$discord->channels->createMessage("GUILD_ID", $params);

createInvite external-link

Create a new invite object for the channel. Only usable for guild channels. Requires the CREATE_INSTANT_INVITE permission. All JSON parameters for this route are optional, however the request body is not. If you are not sending any fields, you still have to send an empty JSON object ({}). Returns an invite object.

$params = array(
    "max_age" => 0,
    "unique" => true
);
$discord->channels->createInvite("CHANNEL_ID", $params);

createMessage external-link

Post a message to a guild text or DM channel. If operating on a guild channel, this endpoint requires the SEND_MESSAGES permission to be present on the current user. If the tts field is set to true, the SEND_TTS_MESSAGES permission is required for the message to be spoken. Returns a message object.

// Example 1
$params = array( "content" : "Write your message here, with <@USER_ID> if needed!" );
$discord->channels->createMessage("CHANNEL_ID", $params);

// Example 2
$params = array(
    "embed" => {
        "title" => "Embed Title",
        "url" => "https://www.marcocusano.dev",
        "description" => "Write here your embed description"
    }
);
$discord->channels->send("CHANNEL_ID", $params);

delete external-link

Delete a channel, or close a private message. Requires the MANAGE_CHANNELS permission for the guild. Deleting a category does not delete its child channels; they will have their parent_id removed and a Channel Update Gateway event will fire for each of them. Returns a channel object on success.

$discord->channels->delete("CHANNEL_ID");

deleteMessage external-link

Delete a message. If operating on a guild channel and trying to delete a message that was not sent by the current user, this endpoint requires the MANAGE_MESSAGES permission. Returns a 204 empty response on success.

$discord->channels->deleteMessage("CHANNEL_ID", "MESSAGE_ID");

deletePin external-link

Delete a pinned message in a channel. Requires the MANAGE_MESSAGES permission. Returns a 204 empty response on success.

$discord->channels->deleteMessage("CHANNEL_ID", "MESSAGE_ID");

deleteReactions external-link

Deletes all reactions on a message. This endpoint requires the 'MANAGE_MESSAGES' permission to be present on the current user.

$discord->channels->deleteReactions("CHANNEL_ID", "MESSAGE_ID");

edit external-link

Update a channels settings. Requires the MANAGE_CHANNELS permission for the guild. Returns a channel on success, and a 400 BAD REQUEST on invalid parameters.

$params = array(
    "name" => "new-channel-name",
    "parent_id" => "category_id"
);
$discord->channels->edit("CHANNEL_ID", $params);

editMessage external-link

Edit a previously sent message. You can only edit messages that have been sent by the current user. Returns a message object.

$params = array( "content" => "Message edited successfully!" );
$discord->channels->editMessage("CHANNEL_ID", "MESSAGE_ID", $params);

get external-link

Get a channel by ID. Returns a channel object.

$discord->channels->get("CHANNEL_ID");

message external-link

Returns a specific message in the channel. If operating on a guild channel, this endpoint requires the READ_MESSAGE_HISTORY permission to be present on the current user. Returns a message object on success.

$discord->channels->message("CHANNEL_ID", "MESSAGE_ID");

messageReactions external-link

Get a list of users that reacted with this emoji. Returns an array of user objects on success.

// Example 1
$discord->channels->messageReactions("CHANNEL_ID", "MESSAGE_ID");
// Example 2
$discord->channels->reactions("CHANNEL_ID", "MESSAGE_ID");

messages external-link

Returns the messages for a channel. If operating on a guild channel, this endpoint requires the VIEW_CHANNEL permission to be present on the current user. If the current user is missing the READ_MESSAGE_HISTORY permission in the channel then this will return no messages (since they cannot read the message history). Returns an array of message objects on success.

$discord->channels->messages("CHANNEL_ID");

pin external-link

Pin a message in a channel. Requires the MANAGE_MESSAGES permission. Returns a 204 empty response on success.

$discord->channels->pin("CHANNEL_ID", "MESSAGE_ID");

pins external-link

Returns all pinned messages in the channel as an array of message objects.

$discord->channels->pins("CHANNEL_ID");

react external-link

Create a reaction for the message. emoji takes the form of name:id for custom guild emoji, or Unicode characters. This endpoint requires the READ_MESSAGE_HISTORY permission to be present on the current user. Additionally, if nobody else has reacted to the message using this emoji, this endpoint requires the ADD_REACTIONS permission to be present on the current user. Returns a 204 empty response on success.

// Example 1
$discord->channels->react("CHANNEL_ID", "MESSAGE_ID", "EMOJI");
// Example 2
$discord->channels->createReaction("CHANNEL_ID", "MESSAGE_ID", "EMOJI");

EMOJI parameter must be in the following format: name:emoji_id;