DiscordPHP Documentation

Message extends Part
in package

A message which is posted to a Discord text channel.

Tags
link
https://discord.com/developers/docs/resources/channel#message-object
since
2.0.0

Table of Contents

ACTIVITY_JOIN  = 1
ACTIVITY_JOIN_REQUEST  = 5
ACTIVITY_LISTEN  = 3
ACTIVITY_SPECTATE  = 2
CHANNEL_FOLLOW_ADD  = self::TYPE_CHANNEL_FOLLOW_ADD
CHANNEL_PINNED_MESSAGE  = self::TYPE_CHANNEL_PINNED_MESSAGE
FLAG_CROSSPOSTED  = 1 << 0
FLAG_EPHEMERAL  = 1 << 6
FLAG_FAILED_TO_MENTION_SOME_ROLES_IN_THREAD  = 1 << 8
FLAG_HAS_THREAD  = 1 << 5
FLAG_IS_CROSSPOST  = 1 << 1
FLAG_LOADING  = 1 << 7
FLAG_SOURCE_MESSAGE_DELETED  = 1 << 3
FLAG_SUPPRESS_EMBED  = 1 << 2
FLAG_URGENT  = 1 << 4
GUILD_DISCOVERY_DISQUALIFIED  = self::TYPE_GUILD_DISCOVERY_DISQUALIFIED
GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING  = self::TYPE_GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING
GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING  = self::TYPE_GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING
GUILD_DISCOVERY_REQUALIFIED  = self::TYPE_GUILD_DISCOVERY_REQUALIFIED
GUILD_MEMBER_JOIN  = self::TYPE_USER_JOIN
REACT_DELETE_ALL  = 0
REACT_DELETE_EMOJI  = 3
REACT_DELETE_ID  = 2
REACT_DELETE_ME  = 1
TYPE_APPLICATION_COMMAND  = self::TYPE_CHAT_INPUT_COMMAND
TYPE_AUTO_MODERATION_ACTION  = 24
TYPE_CALL  = 3
TYPE_CHANNEL_FOLLOW_ADD  = 12
TYPE_CHANNEL_ICON_CHANGE  = 5
TYPE_CHANNEL_NAME_CHANGE  = 4
TYPE_CHANNEL_PINNED_MESSAGE  = 6
TYPE_CHAT_INPUT_COMMAND  = 20
TYPE_CONTEXT_MENU_COMMAND  = 23
TYPE_DEFAULT  = 0
TYPE_GUILD_BOOST  = 8
TYPE_GUILD_BOOST_TIER_1  = 9
TYPE_GUILD_BOOST_TIER_2  = 10
TYPE_GUILD_BOOST_TIER_3  = 11
TYPE_GUILD_DISCOVERY_DISQUALIFIED  = 14
TYPE_GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING  = 17
TYPE_GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING  = 16
TYPE_GUILD_DISCOVERY_REQUALIFIED  = 15
TYPE_GUILD_INVITE_REMINDER  = 22
TYPE_NORMAL  = self::TYPE_DEFAULT
TYPE_RECIPIENT_ADD  = 1
TYPE_RECIPIENT_REMOVE  = 2
TYPE_REPLY  = 19
TYPE_ROLE_SUBSCRIPTION_PURCHASE  = 25
TYPE_THREAD_CREATED  = 18
TYPE_THREAD_STARTER_MESSAGE  = 21
TYPE_USER_ADDED  = self::TYPE_RECIPIENT_ADD
TYPE_USER_JOIN  = 7
TYPE_USER_REMOVED  = self::TYPE_RECIPIENT_REMOVE
USER_PREMIUM_GUILD_SUBSCRIPTION  = self::TYPE_GUILD_BOOST
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_1  = self::TYPE_GUILD_BOOST_TIER_1
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_2  = self::TYPE_GUILD_BOOST_TIER_2
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3  = self::TYPE_GUILD_BOOST_TIER_3
$activity  : object|null
$application  : object|null
$application_id  : string|null
$attachments  : Collection|array<string|int, Attachment>
$author  : User|null
$channel  : Channel|Thread
$channel_id  : string
$components  : Collection|array<string|int, Component>|null
$content  : string
$created  : bool
Is the part already created in the Discord servers?
$crossposted  : bool
$edited_timestamp  : Carbon|null
$embeds  : Collection|array<string|int, Embed>
$ephemeral  : bool
$failed_to_mention_some_roles_in_thread  : bool
$flags  : int|null
$guild  : Guild|null
$guild_id  : string|null
$has_thread  : bool
$id  : string
$interaction  : MessageInteraction|null
$is_crosspost  : bool
$link  : string|null
$loading  : bool
$member  : Member|null
$mention_channels  : Collection|array<string|int, Channel>
$mention_everyone  : bool
$mention_roles  : Collection|array<string|int, Role>
$mentions  : Collection|array<string|int, User>
$message_reference  : object|null
$nonce  : string|null
$pinned  : bool
$position  : int|null
$reactions  : ReactionRepository
$referenced_message  : Message|null
$scriptData  : mixed
Custom script data.
$source_message_deleted  : bool
$sticker_items  : Collection|array<string|int, Sticker>|null
$suppress_embeds  : bool
$thread  : Thread|null
$timestamp  : Carbon
$tts  : bool
$type  : int
$urgent  : bool
$user_id  : string|null
$webhook_id  : string|null
$attributes  : array<string|int, mixed>
The parts attributes.
$discord  : Discord
The Discord client.
$factory  : Factory
The factory.
$fillable  : array<string|int, mixed>
The parts fillable attributes.
$hidden  : array<string|int, mixed>
Attributes that are hidden from debug info.
$http  : Http
The HTTP client.
$repositories  : array<string|int, mixed>
An array of repositories that can exist in a part.
$repositories_cache  : array<string|int, mixed>
An array of repositories.
$visible  : array<string|int, mixed>
Attributes which are visible from debug info.
__construct()  : mixed
Create a new part instance.
__debugInfo()  : array<string|int, mixed>
Handles debug calls from var_dump and similar functions.
__get()  : mixed
Handles dynamic get calls onto the part.
__serialize()  : array<string|int, mixed>
__set()  : void
Handles dynamic set calls onto the part.
__toString()  : string
Converts the part to a string.
__unserialize()  : void
addEmbed()  : ExtendedPromiseInterface<string|int, Message>
Adds an embed to the message.
createReactionCollector()  : ExtendedPromiseInterface<string|int, Collection<string|int, MessageReaction>>
Creates a reaction collector for the message.
crosspost()  : ExtendedPromiseInterface<string|int, Message>
Crossposts the message to any following channels (publish announcement).
delayedDelete()  : ExtendedPromseInterface
Deletes the message after a delay.
delayedReply()  : ExtendedPromiseInterface<string|int, Message>
Replies to the message after a delay.
delete()  : ExtendedPromiseInterface
Deletes the message from the channel.
deleteReaction()  : ExtendedPromiseInterface
Deletes a reaction.
edit()  : ExtendedPromiseInterface<string|int, Message>
Edits the message.
fetch()  : ExtendedPromiseInterface<string|int, self>
Fetches any missing information about the part from Discord's servers.
fill()  : void
Fills the parts attributes from an array.
getCreatableAttributes()  : array<string|int, mixed>
Returns the attributes needed to create.
getLinkAttribute()  : string|null
Returns the message link attribute.
getPublicAttributes()  : array<string|int, mixed>
Returns an array of public attributes.
getRawAttributes()  : array<string|int, mixed>
Returns an array of raw attributes.
getRepositoryAttributes()  : array<string|int, mixed>
Gets the attributes to pass to repositories.
getUpdatableAttributes()  : array<string|int, mixed>
Returns the updatable attributes.
isDeletable()  : bool
Whether this type of message can be deleted (not due to permission).
isPartial()  : bool
Whether the part is considered partial i.e. missing information which can be fetched from Discord.
jsonSerialize()  : array<string|int, mixed>
Provides data when the part is encoded into JSON. Used for JsonSerializable.
offsetExists()  : bool
Checks if an attribute exists via key. Used for ArrayAccess.
offsetGet()  : mixed
Gets an attribute via key. Used for ArrayAccess.
offsetSet()  : void
Sets an attribute via key. Used for ArrayAccess.
offsetUnset()  : void
Unsets an attribute via key. Used for ArrayAccess.
react()  : ExtendedPromiseInterface
Reacts to the message.
reply()  : ExtendedPromiseInterface<string|int, Message>
Replies to the message.
serialize()  : string|null
Serializes the data. Used for Serializable.
startThread()  : ExtendedPromiseInterface<string|int, Thread>
Starts a public thread from the message.
unserialize()  : void
Unserializes some data and stores it. Used for Serializable.
afterConstruct()  : void
Called after the part has been constructed.
getAttachmentsAttribute()  : Collection|array<string|int, Attachment>
Returns any attached files.
getAuthorAttribute()  : User|null
Returns the author attribute.
getChannelAttribute()  : Channel|Thread
Returns the channel attribute.
getComponentsAttribute()  : Collection|array<string|int, Component>|null
Returns the components attribute.
getCrosspostedAttribute()  : bool
Gets the crossposted attribute.
getEditedTimestampAttribute()  : Carbon|null
Returns the edited_timestamp attribute.
getEmbedsAttribute()  : Collection<string|int, Embed>
Returns the embed attribute.
getEphemeralAttribute()  : bool
Gets the ephemeral attribute.
getFailedToMentionSomeRolesInThreadAttribute()  : bool
Gets the failed to mention some roles in thread attribute.
getGuildAttribute()  : Guild|null
Returns the guild which the channel that the message was sent in belongs to.
getHasThreadAttribute()  : bool
Gets the has thread attribute.
getInteractionAttribute()  : MessageInteraction|null
Gets the interaction which triggered the message (application commands).
getIsCrosspostAttribute()  : bool
Gets the is_crosspost attribute.
getLoadingAttribute()  : bool
Gets the loading attribute.
getMemberAttribute()  : Member|null
Returns the member attribute.
getMentionChannelsAttribute()  : Collection|array<string|int, Channel>
Gets the mention_channels attribute.
getMentionRolesAttribute()  : Collection<string|int, ?\Discord\Parts\Guild\Role>
Returns the mention_roles attribute.
getMentionsAttribute()  : Collection|array<string|int, User>
Returns the mention attribute.
getReferencedMessageAttribute()  : Message|null
Gets the referenced message attribute, if present.
getSourceMessageDeletedAttribute()  : bool
Gets the source_message_deleted attribute.
getStickerItemsAttribute()  : Collection|array<string|int, Sticker>|null
Returns the sticker_items attribute.
getSuppressEmbedsAttribute()  : bool
Gets the suppress_embeds attribute.
getThreadAttribute()  : Thread|null
Returns the thread that was started from this message, includes thread member object.
getTimestampAttribute()  : Carbon|null
Returns the timestamp attribute.
getUrgentAttribute()  : bool
Gets the urgent attribute.
getUserIdAttribute()  : string|null
Returns the `user_id` attribute.
setReactionsAttribute()  : void
Sets the reactions attribute.
_edit()  : ExtendedPromiseInterface
checkForMutator()  : string|false
Checks if there is a mutator present.
getAttribute()  : mixed
Gets an attribute on the part.
setAttribute()  : void
Sets an attribute on the part.
studly()  : string
Converts a string to studlyCase.

Constants

ACTIVITY_JOIN

public mixed ACTIVITY_JOIN = 1

ACTIVITY_JOIN_REQUEST

public mixed ACTIVITY_JOIN_REQUEST = 5

ACTIVITY_LISTEN

public mixed ACTIVITY_LISTEN = 3

ACTIVITY_SPECTATE

public mixed ACTIVITY_SPECTATE = 2

CHANNEL_FOLLOW_ADD

public mixed CHANNEL_FOLLOW_ADD = self::TYPE_CHANNEL_FOLLOW_ADD
Tags
deprecated
10.0.0

Use Message::TYPE_CHANNEL_FOLLOW_ADD

CHANNEL_PINNED_MESSAGE

public mixed CHANNEL_PINNED_MESSAGE = self::TYPE_CHANNEL_PINNED_MESSAGE
Tags
deprecated
10.0.0

Use Message::TYPE_CHANNEL_PINNED_MESSAGE

FLAG_CROSSPOSTED

public mixed FLAG_CROSSPOSTED = 1 << 0

FLAG_EPHEMERAL

public mixed FLAG_EPHEMERAL = 1 << 6

FLAG_FAILED_TO_MENTION_SOME_ROLES_IN_THREAD

public mixed FLAG_FAILED_TO_MENTION_SOME_ROLES_IN_THREAD = 1 << 8

FLAG_HAS_THREAD

public mixed FLAG_HAS_THREAD = 1 << 5

FLAG_IS_CROSSPOST

public mixed FLAG_IS_CROSSPOST = 1 << 1

FLAG_LOADING

public mixed FLAG_LOADING = 1 << 7

FLAG_SOURCE_MESSAGE_DELETED

public mixed FLAG_SOURCE_MESSAGE_DELETED = 1 << 3

FLAG_SUPPRESS_EMBED

public mixed FLAG_SUPPRESS_EMBED = 1 << 2

FLAG_URGENT

public mixed FLAG_URGENT = 1 << 4

GUILD_DISCOVERY_DISQUALIFIED

public mixed GUILD_DISCOVERY_DISQUALIFIED = self::TYPE_GUILD_DISCOVERY_DISQUALIFIED
Tags
deprecated
10.0.0

Use Message::TYPE_GUILD_DISCOVERY_DISQUALIFIED

GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING

public mixed GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING = self::TYPE_GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING
Tags
deprecated
10.0.0

Use Message::TYPE_GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING

GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING

public mixed GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING = self::TYPE_GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING
Tags
deprecated
10.0.0

Use Message::TYPE_GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING

GUILD_DISCOVERY_REQUALIFIED

public mixed GUILD_DISCOVERY_REQUALIFIED = self::TYPE_GUILD_DISCOVERY_REQUALIFIED
Tags
deprecated
10.0.0

Use Message::TYPE_GUILD_DISCOVERY_REQUALIFIED

GUILD_MEMBER_JOIN

public mixed GUILD_MEMBER_JOIN = self::TYPE_USER_JOIN
Tags
deprecated
7.1.0

Use Message::TYPE_USER_JOIN

REACT_DELETE_ALL

public mixed REACT_DELETE_ALL = 0

REACT_DELETE_EMOJI

public mixed REACT_DELETE_EMOJI = 3

REACT_DELETE_ID

public mixed REACT_DELETE_ID = 2

REACT_DELETE_ME

public mixed REACT_DELETE_ME = 1

TYPE_APPLICATION_COMMAND

public mixed TYPE_APPLICATION_COMMAND = self::TYPE_CHAT_INPUT_COMMAND
Tags
deprecated
10.0.0

Use Message::TYPE_CHAT_INPUT_COMMAND

TYPE_AUTO_MODERATION_ACTION

public mixed TYPE_AUTO_MODERATION_ACTION = 24

TYPE_CALL

public mixed TYPE_CALL = 3

TYPE_CHANNEL_FOLLOW_ADD

public mixed TYPE_CHANNEL_FOLLOW_ADD = 12

TYPE_CHANNEL_ICON_CHANGE

public mixed TYPE_CHANNEL_ICON_CHANGE = 5

TYPE_CHANNEL_NAME_CHANGE

public mixed TYPE_CHANNEL_NAME_CHANGE = 4

TYPE_CHANNEL_PINNED_MESSAGE

public mixed TYPE_CHANNEL_PINNED_MESSAGE = 6

TYPE_CHAT_INPUT_COMMAND

public mixed TYPE_CHAT_INPUT_COMMAND = 20

TYPE_CONTEXT_MENU_COMMAND

public mixed TYPE_CONTEXT_MENU_COMMAND = 23

TYPE_DEFAULT

public mixed TYPE_DEFAULT = 0

TYPE_GUILD_BOOST

public mixed TYPE_GUILD_BOOST = 8

TYPE_GUILD_BOOST_TIER_1

public mixed TYPE_GUILD_BOOST_TIER_1 = 9

TYPE_GUILD_BOOST_TIER_2

public mixed TYPE_GUILD_BOOST_TIER_2 = 10

TYPE_GUILD_BOOST_TIER_3

public mixed TYPE_GUILD_BOOST_TIER_3 = 11

TYPE_GUILD_DISCOVERY_DISQUALIFIED

public mixed TYPE_GUILD_DISCOVERY_DISQUALIFIED = 14

TYPE_GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING

public mixed TYPE_GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING = 17

TYPE_GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING

public mixed TYPE_GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING = 16

TYPE_GUILD_DISCOVERY_REQUALIFIED

public mixed TYPE_GUILD_DISCOVERY_REQUALIFIED = 15

TYPE_GUILD_INVITE_REMINDER

public mixed TYPE_GUILD_INVITE_REMINDER = 22

TYPE_NORMAL

public mixed TYPE_NORMAL = self::TYPE_DEFAULT
Tags
deprecated
10.0.0

Use Message::TYPE_DEFAULT

TYPE_RECIPIENT_ADD

public mixed TYPE_RECIPIENT_ADD = 1

TYPE_RECIPIENT_REMOVE

public mixed TYPE_RECIPIENT_REMOVE = 2

TYPE_REPLY

public mixed TYPE_REPLY = 19

TYPE_ROLE_SUBSCRIPTION_PURCHASE

public mixed TYPE_ROLE_SUBSCRIPTION_PURCHASE = 25

TYPE_THREAD_CREATED

public mixed TYPE_THREAD_CREATED = 18

TYPE_THREAD_STARTER_MESSAGE

public mixed TYPE_THREAD_STARTER_MESSAGE = 21

TYPE_USER_ADDED

public mixed TYPE_USER_ADDED = self::TYPE_RECIPIENT_ADD
Tags
deprecated
10.0.0

Use Message::TYPE_RECIPIENT_ADD

TYPE_USER_JOIN

public mixed TYPE_USER_JOIN = 7

TYPE_USER_REMOVED

public mixed TYPE_USER_REMOVED = self::TYPE_RECIPIENT_REMOVE
Tags
deprecated
10.0.0

Use Message::TYPE_RECIPIENT_REMOVE

USER_PREMIUM_GUILD_SUBSCRIPTION

public mixed USER_PREMIUM_GUILD_SUBSCRIPTION = self::TYPE_GUILD_BOOST
Tags
deprecated
7.1.0

Use Message::TYPE_GUILD_BOOST

USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_1

public mixed USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_1 = self::TYPE_GUILD_BOOST_TIER_1
Tags
deprecated
7.1.0

Use Message::TYPE_GUILD_BOOST_TIER_1

USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_2

public mixed USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_2 = self::TYPE_GUILD_BOOST_TIER_2
Tags
deprecated
7.1.0

Use Message::TYPE_GUILD_BOOST_TIER_2

USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3

public mixed USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3 = self::TYPE_GUILD_BOOST_TIER_3
Tags
deprecated
7.1.0

Use Message::TYPE_GUILD_BOOST_TIER_3

Properties

$activity

public object|null $activity

Current message activity. Requires rich presence.

$application

public object|null $application

Application of message. Requires rich presence.

$application_id

public string|null $application_id

If the message is a response to an Interaction, this is the id of the interaction's application.

$author

public User|null $author

The author of the message. Will be a webhook if sent from one.

$channel_id

public string $channel_id

The unique identifier of the channel that the message was went in.

$components

public Collection|array<string|int, Component>|null $components

Sent if the message contains components like buttons, action rows, or other interactive components.

$content

public string $content

The content of the message if it is a normal message.

$created

Is the part already created in the Discord servers?

public bool $created = false

Whether the part has been created.

$crossposted read-only

public bool $crossposted

Message has been crossposted.

$edited_timestamp

public Carbon|null $edited_timestamp

A timestamp of when the message was edited, or null.

$ephemeral read-only

public bool $ephemeral

Whether this message is only visible to the user who invoked the Interaction.

$failed_to_mention_some_roles_in_thread read-only

public bool $failed_to_mention_some_roles_in_thread

This message failed to mention some roles and add their members to the thread.

$flags

public int|null $flags

Message flags.

$guild read-only

public Guild|null $guild

The guild that the message was sent in.

$guild_id

public string|null $guild_id

The unique identifier of the guild that the channel the message was sent in belongs to.

$has_thread read-only

public bool $has_thread

Whether this message has an associated thread, with the same id as the message.

$id

public string $id

The unique identifier of the message.

$is_crosspost read-only

public bool $is_crosspost

Message is a crosspost from another channel.

public string|null $link

Returns a link to the message.

$loading read-only

public bool $loading

Whether this message is an Interaction Response and the bot is "thinking".

$member

public Member|null $member

The member that sent this message, or null if it was in a private message.

$mention_everyone

public bool $mention_everyone

Whether the message contained an @everyone mention.

$mention_roles

public Collection|array<string|int, Role> $mention_roles

A collection of roles that were mentioned in the message.

$mentions

public Collection|array<string|int, User> $mentions

A collection of the users mentioned in the message.

$message_reference

public object|null $message_reference

Message that is referenced by this message.

$nonce

public string|null $nonce

A randomly generated string that provides verification for the client. Not required.

$pinned

public bool $pinned

Whether the message is pinned to the channel.

$position

public int|null $position

A generally increasing integer (there may be gaps or duplicates) that represents the approximate position of the message in a thread, it can be used to estimate the relative position of the message in a thread in company with total_message_sent on parent thread.

$referenced_message

public Message|null $referenced_message

The message that is referenced in a reply.

$scriptData

Custom script data.

public mixed $scriptData

Used for storing custom information, used by end products.

Tags
deprecated
10.0.0

Relying on this variable with dynamic caching is discouraged.

$source_message_deleted read-only

public bool $source_message_deleted

Source message for this message has been deleted.

$suppress_embeds read-only

public bool $suppress_embeds

Do not include embeds when serializing message.

$thread

public Thread|null $thread

The thread that was started from this message, includes thread member object.

$timestamp

public Carbon $timestamp

A timestamp of when the message was sent.

$tts

public bool $tts

Whether the message was sent as a text-to-speech message.

$type

public int $type

The type of message.

$urgent read-only

public bool $urgent

Message is urgent.

$user_id read-only

public string|null $user_id

The user id of the author.

$webhook_id

public string|null $webhook_id

ID of the webhook that made the message, if any.

$attributes

The parts attributes.

protected array<string|int, mixed> $attributes = []

The parts attributes and content.

$discord

The Discord client.

protected Discord $discord

Client.

$fillable

The parts fillable attributes.

protected array<string|int, mixed> $fillable = [ 'id', 'channel_id', 'author', 'content', 'timestamp', 'edited_timestamp', 'tts', 'mention_everyone', 'mentions', 'mention_roles', 'mention_channels', 'attachments', 'embeds', 'nonce', 'pinned', 'webhook_id', 'type', 'activity', 'application', 'application_id', 'message_reference', 'flags', 'referenced_message', 'interaction', 'thread', 'components', 'sticker_items', 'position', // @internal 'guild_id', 'member', // repositories 'reactions', ]

The array of attributes that can be mass-assigned.

$hidden

Attributes that are hidden from debug info.

protected array<string|int, mixed> $hidden = []

Attributes that are hidden from public.

$http

The HTTP client.

protected Http $http

Client.

$repositories

An array of repositories that can exist in a part.

protected array<string|int, mixed> $repositories = ['reactions' => \Discord\Repository\Channel\ReactionRepository::class]

Repositories.

$repositories_cache

An array of repositories.

protected array<string|int, mixed> $repositories_cache = []

$visible

Attributes which are visible from debug info.

protected array<string|int, mixed> $visible = []

Methods

__construct()

Create a new part instance.

public __construct(Discord $discord[, array<string|int, mixed> $attributes = [] ][, bool $created = false ]) : mixed
Parameters
$discord : Discord

The Discord client.

$attributes : array<string|int, mixed> = []

An array of attributes to build the part.

$created : bool = false

Whether the part has already been created.

Return values
mixed

__debugInfo()

Handles debug calls from var_dump and similar functions.

public __debugInfo() : array<string|int, mixed>
Tags
throws
Exception
see
Part::getPublicAttributes()

This function forwards onto getPublicAttributes.

Return values
array<string|int, mixed>

An array of public attributes.

__get()

Handles dynamic get calls onto the part.

public __get(string $key) : mixed
Parameters
$key : string

The attributes key.

Tags
throws
Exception
see
Part::getAttribute()

This function forwards onto getAttribute.

Return values
mixed

The value of the attribute.

__serialize()

public __serialize() : array<string|int, mixed>
Return values
array<string|int, mixed>

__set()

Handles dynamic set calls onto the part.

public __set(string $key, mixed $value) : void
Parameters
$key : string

The attributes key.

$value : mixed

The attributes value.

Tags
see
self::setAttribute()

This function forwards onto setAttribute.

Return values
void

__toString()

Converts the part to a string.

public __toString() : string
Tags
throws
Exception
see
Part::getPublicAttributes()

This function encodes getPublicAttributes into JSON.

Return values
string

A JSON string of attributes.

__unserialize()

public __unserialize(array<string|int, mixed> $data) : void
Parameters
$data : array<string|int, mixed>
Return values
void

addEmbed()

Adds an embed to the message.

public addEmbed(Embed $embed) : ExtendedPromiseInterface<string|int, Message>
Parameters
$embed : Embed
Return values
ExtendedPromiseInterface<string|int, Message>

createReactionCollector()

Creates a reaction collector for the message.

public createReactionCollector(callable $filter[, array<string|int, mixed> $options = [] ]) : ExtendedPromiseInterface<string|int, Collection<string|int, MessageReaction>>
Parameters
$filter : callable

The filter function. Returns true or false.

$options : array<string|int, mixed> = []
Return values
ExtendedPromiseInterface<string|int, Collection<string|int, MessageReaction>>

crosspost()

Crossposts the message to any following channels (publish announcement).

public crosspost() : ExtendedPromiseInterface<string|int, Message>
Tags
link
https://discord.com/developers/docs/resources/channel#crosspost-message
throws
RuntimeException

Message has already been crossposted.

throws
NoPermissionsException

Missing permission: send_messages if this message author is the bot. manage_messages if this message author is other user.

Return values
ExtendedPromiseInterface<string|int, Message>

delayedDelete()

Deletes the message after a delay.

public delayedDelete(int $delay[, TimerInterface &$timer = null ]) : ExtendedPromseInterface
Parameters
$delay : int

Time to delay the delete by, in milliseconds.

$timer : TimerInterface = null

Delay timer passed by reference.

Tags
see
Message::deleteMessage()
Return values
ExtendedPromseInterface

delayedReply()

Replies to the message after a delay.

public delayedReply(string|MessageBuilder $message, int $delay[, TimerInterface &$timer = null ]) : ExtendedPromiseInterface<string|int, Message>
Parameters
$message : string|MessageBuilder

Reply message to send after delay.

$delay : int

Delay after text will be sent in milliseconds.

$timer : TimerInterface = null

Delay timer passed by reference.

Tags
see
Message::reply()
Return values
ExtendedPromiseInterface<string|int, Message>

deleteReaction()

Deletes a reaction.

public deleteReaction(int $type[, Emoji|string|null $emoticon = null ][, string|null $id = null ]) : ExtendedPromiseInterface
Parameters
$type : int

The type of deletion to perform.

$emoticon : Emoji|string|null = null

The emoticon to delete (if not all).

$id : string|null = null

The user reaction to delete (if not all).

Tags
link
https://discord.com/developers/docs/resources/channel#delete-own-reaction
link
https://discord.com/developers/docs/resources/channel#delete-user-reaction
throws
UnexpectedValueException

Invalid reaction $type.

throws
NoPermissionsException

Missing manage_messages permission when deleting others reaction.

Return values
ExtendedPromiseInterface

fetch()

Fetches any missing information about the part from Discord's servers.

public fetch() : ExtendedPromiseInterface<string|int, self>
Tags
throws
RuntimeException

The part is not fetchable.

Return values
ExtendedPromiseInterface<string|int, self>

fill()

Fills the parts attributes from an array.

public fill(array<string|int, mixed> $attributes) : void
Parameters
$attributes : array<string|int, mixed>

An array of attributes to build the part.

Return values
void

getCreatableAttributes()

Returns the attributes needed to create.

public getCreatableAttributes() : array<string|int, mixed>
Return values
array<string|int, mixed>

getLinkAttribute()

Returns the message link attribute.

public getLinkAttribute() : string|null
Return values
string|null

getPublicAttributes()

Returns an array of public attributes.

public getPublicAttributes() : array<string|int, mixed>
Tags
throws
Exception
Return values
array<string|int, mixed>

An array of public attributes.

getRawAttributes()

Returns an array of raw attributes.

public getRawAttributes() : array<string|int, mixed>
Return values
array<string|int, mixed>

Raw attributes.

getRepositoryAttributes()

Gets the attributes to pass to repositories.

public getRepositoryAttributes() : array<string|int, mixed>
Return values
array<string|int, mixed>

Attributes.

isDeletable()

Whether this type of message can be deleted (not due to permission).

public isDeletable() : bool
Return values
bool

true if this message can be deleted.

isPartial()

Whether the part is considered partial i.e. missing information which can be fetched from Discord.

public isPartial() : bool
Return values
bool

jsonSerialize()

Provides data when the part is encoded into JSON. Used for JsonSerializable.

public jsonSerialize() : array<string|int, mixed>
Tags
throws
Exception
see
Part::getPublicAttributes()

This function forwards onto getPublicAttributes.

Return values
array<string|int, mixed>

An array of public attributes.

offsetExists()

Checks if an attribute exists via key. Used for ArrayAccess.

public offsetExists(string $key) : bool
Parameters
$key : string

The attribute key.

Return values
bool

Whether the offset exists.

offsetGet()

Gets an attribute via key. Used for ArrayAccess.

public offsetGet(string $key) : mixed
Parameters
$key : string

The attribute key.

Tags
throws
Exception
see
Part::getAttribute()

This function forwards onto getAttribute.

Return values
mixed

offsetSet()

Sets an attribute via key. Used for ArrayAccess.

public offsetSet(string $key, mixed $value) : void
Parameters
$key : string

The attribute key.

$value : mixed

The attribute value.

Tags
see
Part::setAttribute()

This function forwards onto setAttribute.

Return values
void

offsetUnset()

Unsets an attribute via key. Used for ArrayAccess.

public offsetUnset(string $key) : void
Parameters
$key : string

The attribute key.

Return values
void

serialize()

Serializes the data. Used for Serializable.

public serialize() : string|null
Return values
string|null

A string of serialized data.

startThread()

Starts a public thread from the message.

public startThread(array<string|int, mixed> $options[, string|null $reason = null ]) : ExtendedPromiseInterface<string|int, Thread>
Parameters
$options : array<string|int, mixed>

Thread params.

$reason : string|null = null

Reason for Audit Log.

Tags
link
https://discord.com/developers/docs/resources/channel#start-thread-from-message
throws
RuntimeException

Channel type is not guild text or news.

throws
NoPermissionsException

Missing create_public_threads permission to create or manage_threads permission to set rate_limit_per_user.

since
10.0.0

Arguments for $name and $auto_archive_duration are now inside $options

Return values
ExtendedPromiseInterface<string|int, Thread>

unserialize()

Unserializes some data and stores it. Used for Serializable.

public unserialize(string $data) : void
Parameters
$data : string

Some serialized data.

Tags
see
Part::setAttribute()

The unserialized data is stored with setAttribute.

Return values
void

afterConstruct()

Called after the part has been constructed.

protected afterConstruct() : void
Return values
void

getAuthorAttribute()

Returns the author attribute.

protected getAuthorAttribute() : User|null
Return values
User|null

The author of the message.

getChannelAttribute()

Returns the channel attribute.

protected getChannelAttribute() : Channel|Thread
Return values
Channel|Thread

The channel or thread the message was sent in.

getCrosspostedAttribute()

Gets the crossposted attribute.

protected getCrosspostedAttribute() : bool
Return values
bool

getEditedTimestampAttribute()

Returns the edited_timestamp attribute.

protected getEditedTimestampAttribute() : Carbon|null
Tags
throws
Exception
Return values
Carbon|null

The time that the message was edited.

getEphemeralAttribute()

Gets the ephemeral attribute.

protected getEphemeralAttribute() : bool
Return values
bool

getFailedToMentionSomeRolesInThreadAttribute()

Gets the failed to mention some roles in thread attribute.

protected getFailedToMentionSomeRolesInThreadAttribute() : bool
Return values
bool

getGuildAttribute()

Returns the guild which the channel that the message was sent in belongs to.

protected getGuildAttribute() : Guild|null
Return values
Guild|null

getHasThreadAttribute()

Gets the has thread attribute.

protected getHasThreadAttribute() : bool
Return values
bool

getIsCrosspostAttribute()

Gets the is_crosspost attribute.

protected getIsCrosspostAttribute() : bool
Return values
bool

getLoadingAttribute()

Gets the loading attribute.

protected getLoadingAttribute() : bool
Return values
bool

getMemberAttribute()

Returns the member attribute.

protected getMemberAttribute() : Member|null
Return values
Member|null

The member that sent the message, or null if it was in a private message.

getMentionRolesAttribute()

Returns the mention_roles attribute.

protected getMentionRolesAttribute() : Collection<string|int, ?\Discord\Parts\Guild\Role>
Return values
Collection<string|int, ?\Discord\Parts\Guild\Role>

The roles that were mentioned. null role only contains the ID in the collection.

getMentionsAttribute()

Returns the mention attribute.

protected getMentionsAttribute() : Collection|array<string|int, User>
Return values
Collection|array<string|int, User>

The users that were mentioned.

getReferencedMessageAttribute()

Gets the referenced message attribute, if present.

protected getReferencedMessageAttribute() : Message|null
Return values
Message|null

getSourceMessageDeletedAttribute()

Gets the source_message_deleted attribute.

protected getSourceMessageDeletedAttribute() : bool
Return values
bool

getStickerItemsAttribute()

Returns the sticker_items attribute.

protected getStickerItemsAttribute() : Collection|array<string|int, Sticker>|null
Return values
Collection|array<string|int, Sticker>|null

Partial stickers.

getSuppressEmbedsAttribute()

Gets the suppress_embeds attribute.

protected getSuppressEmbedsAttribute() : bool
Return values
bool

getThreadAttribute()

Returns the thread that was started from this message, includes thread member object.

protected getThreadAttribute() : Thread|null
Tags
since
10.0.0

This only returns a thread that was started on this message, not the thread of the message.

since
7.0.0
Return values
Thread|null

getTimestampAttribute()

Returns the timestamp attribute.

protected getTimestampAttribute() : Carbon|null
Tags
throws
Exception
Return values
Carbon|null

The time that the message was sent.

getUrgentAttribute()

Gets the urgent attribute.

protected getUrgentAttribute() : bool
Return values
bool

getUserIdAttribute()

Returns the `user_id` attribute.

protected getUserIdAttribute() : string|null
Return values
string|null

setReactionsAttribute()

Sets the reactions attribute.

protected setReactionsAttribute(array<string|int, mixed>|null $reactions) : void
Parameters
$reactions : array<string|int, mixed>|null
Return values
void

checkForMutator()

Checks if there is a mutator present.

private checkForMutator(string $key, string $type) : string|false
Parameters
$key : string

The attribute name to check.

$type : string

Either get or set.

Return values
string|false

Either a string if it is callable or false.

getAttribute()

Gets an attribute on the part.

private getAttribute(string $key) : mixed
Parameters
$key : string

The key to the attribute.

Tags
throws
Exception
Return values
mixed

Either the attribute if it exists or void.

setAttribute()

Sets an attribute on the part.

private setAttribute(string $key, mixed $value) : void
Parameters
$key : string

The key to the attribute.

$value : mixed

The value of the attribute.

Return values
void

studly()

Converts a string to studlyCase.

private static studly(string $string) : string

This is a port of updated Laravel's implementation, a non-regex with static cache. The Discord\studly() is kept due to unintended bug and we do not want to introduce BC by replacing it. This method is private static as we may move it outside this class in future.

Parameters
$string : string

The string to convert.

Tags
since
10.0.0
Return values
string

Search results