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
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
TYPE_EVERYONE
public
mixed
TYPE_EVERYONE
= 'everyone'
TYPE_ROLE
public
mixed
TYPE_ROLE
= 'roles'
TYPE_USER
public
mixed
TYPE_USER
= 'users'
Properties
$parse
public
ExCollectionInterface
$parse
An array of allowed mention types to parse from the content.
$replied_user
public
bool
$replied_user
For replies, whether to mention the author of the message being replied to (default false).
$roles
public
ExCollectionInterface
$roles
Array of role_ids to mention (Max size of 100).
$users
public
ExCollectionInterface
$users
Array of user_ids to mention (Max size of 100).
$parse
An array of allowed mention types to parse from the content.
protected
ExCollectionInterface|null
$parse
$replied_user
For replies, whether to mention the author of the message being replied to (default false).
protected
bool|null
$replied_user
$roles
Array of role_ids to mention (Max size of 100).
protected
ExCollectionInterface|null
$roles
$users
Array of user_ids to mention (Max size of 100).
protected
ExCollectionInterface|null
$users
Methods
addParse()
Adds a type to the list of allowed mentioned types.
public
addParse(string ...$items) : self
Parameters
- $items : string
Tags
Return values
selfaddRole()
Adds a role to the list of allowed mentioned roles.
public
addRole(string ...$items) : self
Parameters
- $items : string
Tags
Return values
selfaddUser()
Adds a user to the list of allowed mentioned users.
public
addUser(string ...$items) : self
Parameters
- $items : string
Tags
Return values
selfclearParse()
Clears the list of allowed mentioned types.
public
clearParse() : self
Return values
selfclearRoles()
Clears the list of allowed mentioned roles.
public
clearRoles() : self
Return values
selfclearUsers()
Clears the list of allowed mentioned users.
public
clearUsers() : self
Return values
selfdisallowAllMentions()
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
selfgetParse()
Retrieves the list of allowed mentioned types.
public
getParse() : ExCollectionInterface|null
Return values
ExCollectionInterface|nullgetRoles()
Retrieves the list of allowed mentioned roles.
public
getRoles() : ExCollectionInterface|null
Return values
ExCollectionInterface|nullgetUsers()
Retrieves the list of allowed mentioned users.
public
getUsers() : ExCollectionInterface|null
Return values
ExCollectionInterface|nulljsonSerialize()
{@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
staticnone()
Creates a new allowed mention with all mention types disallowed.
public
static none() : static
Return values
staticremoveParse()
Removes a specific type from the list of allowed mentioned types.
public
removeParse(string ...$parse) : self
Parameters
- $parse : string
Return values
selfremoveRoles()
Removes a specific role from the list of allowed mentioned roles.
public
removeRoles(string ...$roles) : self
Parameters
- $roles : string
Return values
selfremoveUser()
Removes a specific user from the list of allowed mentioned users.
public
removeUser(string ...$users) : self
Parameters
- $users : string
Return values
selfsetParse()
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
Return values
selfsetRepliedUser()
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
selfsetRoles()
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
Return values
selfsetUsers()
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