DiscordPHP Documentation

AllowedMentions
in package
implements JsonSerializable

The allowed mention field allows for more granular control over mentions without various hacks to the message.

This will always validate against the message and components to avoid phantom pings (e.g. to ping everyone, you must still have @everyone in the message), and check against user/bot permissions.

Tags
link
https://discord.com/developers/docs/resources/message#allowed-mentions-object
since
10.10.1

Table of Contents

Interfaces

JsonSerializable

Constants

TYPE_EVERYONE  = 'everyone'
TYPE_ROLE  = 'roles'
TYPE_USER  = 'users'

Properties

$parse  : ExCollectionInterface
$replied_user  : bool
$roles  : ExCollectionInterface
$users  : ExCollectionInterface
$parse  : ExCollectionInterface|null
An array of allowed mention types to parse from the content.
$replied_user  : bool|null
For replies, whether to mention the author of the message being replied to (default false).
$roles  : ExCollectionInterface|null
Array of role_ids to mention (Max size of 100).
$users  : ExCollectionInterface|null
Array of user_ids to mention (Max size of 100).

Methods

addParse()  : self
Adds a type to the list of allowed mentioned types.
addRole()  : self
Adds a role to the list of allowed mentioned roles.
addUser()  : self
Adds a user to the list of allowed mentioned users.
clearParse()  : self
Clears the list of allowed mentioned types.
clearRoles()  : self
Clears the list of allowed mentioned roles.
clearUsers()  : self
Clears the list of allowed mentioned users.
disallowAllMentions()  : self
Sets the list of current allowed mention types to a new, empty ExCollectionInterface instance.
getParse()  : ExCollectionInterface|null
Retrieves the list of allowed mentioned types.
getRoles()  : ExCollectionInterface|null
Retrieves the list of allowed mentioned roles.
getUsers()  : ExCollectionInterface|null
Retrieves the list of allowed mentioned users.
jsonSerialize()  : array<string|int, mixed>
{@inheritDoc}
new()  : static
Creates a new allowed mention.
none()  : static
Creates a new allowed mention with all mention types disallowed.
removeParse()  : self
Removes a specific type from the list of allowed mentioned types.
removeRoles()  : self
Removes a specific role from the list of allowed mentioned roles.
removeUser()  : self
Removes a specific user from the list of allowed mentioned users.
setParse()  : self
Sets the list of allowed mentioned types.
setRepliedUser()  : self
Sets whether to mention the author of the message being replied to (default false).
setRoles()  : self
Sets the list of allowed mentioned roles.
setUsers()  : self
Sets the list of allowed mentioned users.

Constants

Properties

$replied_user

public bool $replied_user

For replies, whether to mention the author of the message being replied to (default false).

$replied_user

For replies, whether to mention the author of the message being replied to (default false).

protected bool|null $replied_user

Methods

addParse()

Adds a type to the list of allowed mentioned types.

public addParse(string ...$items) : self
Parameters
$items : string
Tags
throws
InvalidArgumentException

Type must be one of: roles, users, everyone

Return values
self

addRole()

Adds a role to the list of allowed mentioned roles.

public addRole(string ...$items) : self
Parameters
$items : string
Tags
throws
InvalidArgumentException

Allowed mention role must be a numeric snowflake.

Return values
self

addUser()

Adds a user to the list of allowed mentioned users.

public addUser(string ...$items) : self
Parameters
$items : string
Tags
throws
InvalidArgumentException

Allowed mention role must be a numeric snowflake.

Return values
self

clearParse()

Clears the list of allowed mentioned types.

public clearParse() : self
Return values
self

clearRoles()

Clears the list of allowed mentioned roles.

public clearRoles() : self
Return values
self

clearUsers()

Clears the list of allowed mentioned users.

public clearUsers() : self
Return values
self

disallowAllMentions()

Sets the list of current allowed mention types to a new, empty ExCollectionInterface instance.

public disallowAllMentions() : self

This effectively disallows all mentions on the message.

Return values
self

jsonSerialize()

{@inheritDoc}

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

new()

Creates a new allowed mention.

public static new() : static
Return values
static

none()

Creates a new allowed mention with all mention types disallowed.

public static none() : static
Return values
static

removeParse()

Removes a specific type from the list of allowed mentioned types.

public removeParse(string ...$parse) : self
Parameters
$parse : string
Return values
self

removeRoles()

Removes a specific role from the list of allowed mentioned roles.

public removeRoles(string ...$roles) : self
Parameters
$roles : string
Return values
self

removeUser()

Removes a specific user from the list of allowed mentioned users.

public removeUser(string ...$users) : self
Parameters
$users : string
Return values
self

setParse()

Sets the list of allowed mentioned types.

public setParse(ExCollectionInterface|array<string|int, string>|null $items) : self
Parameters
$items : ExCollectionInterface|array<string|int, string>|null
Tags
throws
InvalidArgumentException

Allowed mention type must be one of: roles, users, everyone

Return values
self

setRepliedUser()

Sets whether to mention the author of the message being replied to (default false).

public setRepliedUser([bool $replied_user = true ]) : self
Parameters
$replied_user : bool = true
Return values
self

setRoles()

Sets the list of allowed mentioned roles.

public setRoles(ExCollectionInterface|array<string|int, string>|null $items) : self
Parameters
$items : ExCollectionInterface|array<string|int, string>|null
Tags
throws
InvalidArgumentException

Allowed mention type must be one of: roles, users, everyone

Return values
self

setUsers()

Sets the list of allowed mentioned users.

public setUsers(ExCollectionInterface|array<string|int, string>|null $items) : self
Parameters
$items : ExCollectionInterface|array<string|int, string>|null
Tags
throws
InvalidArgumentException

Allowed mention type must be one of: users, users, everyone

Return values
self

        
On this page

Search results