DiscordGroupSyncInjector
in package
implements
GroupSyncInjector, BatchableGroupSyncInjector
Discord group sync injector implementation.
Tags
Table of Contents
Interfaces
- GroupSyncInjector
- Provides a baseline for custom group sync injectors.
- BatchableGroupSyncInjector
- Represents a GroupSyncInjector which can add multiple groups to a {@see User} at once.
Methods
- addGroup() : bool
- Add this group to the user on your service.
- batchAddGroups() : false|array<string|int, mixed>
- Add multiple groups to a user at once.
- batchRemoveGroups() : false|array<string|int, mixed>
- Remove multiple groups from a user at once.
- getColumnName() : string
- Get the name of the column to store this injector's group ID in, in the database.
- getColumnType() : string
- Get the MySQL type to create the column with.
- getModule() : string
- Get the name of the module this injector belongs to.
- getName() : string
- Get a "friendly name" of this injector.
- getNotEnabledMessage() : string
- Get the message to display in place of the group dropdown on the Group Sync page.
- getSelectionOptions() : array<string|int, mixed>
- Get a list of groups available for this injector.
- getValidationMessages() : array<string|int, mixed>
- Get specific error messages to display for each validation rule their form submission does not meet.
- getValidationRules() : array<string|int, mixed>
- Get an array of rules to validate Group Sync creation/update requests with for this group.
- removeGroup() : bool
- Remove this group from the user.
- shouldEnable() : bool
- Determine if this injector should be enabled or not.
Methods
addGroup()
Add this group to the user on your service.
public
addGroup(User $user, mixed $group_id) : bool
Can do anything in here (go for a walk, call your API, write a book, etc), as long as the user gets the group applied on your service!
Parameters
- $user : User
-
Instance of affected NamelessMC user.
- $group_id : mixed
-
Native group ID to use for lookup on your service.
Return values
bool —Whether the group was successfully added or not
batchAddGroups()
Add multiple groups to a user at once.
public
batchAddGroups(User $user, array<string|int, mixed> $group_ids) : false|array<string|int, mixed>
Parameters
- $user : User
-
The user to add groups to
- $group_ids : array<string|int, mixed>
-
Array of native group IDs to remove
Return values
false|array<string|int, mixed> —Array of group IDs and the status of the operation for each, or false if error
batchRemoveGroups()
Remove multiple groups from a user at once.
public
batchRemoveGroups(User $user, array<string|int, mixed> $group_ids) : false|array<string|int, mixed>
Parameters
- $user : User
-
The user to remove groups from
- $group_ids : array<string|int, mixed>
-
Array of native group IDs to remove
Return values
false|array<string|int, mixed> —Array of group IDs and the status of the operation for each, or false if error
getColumnName()
Get the name of the column to store this injector's group ID in, in the database.
public
getColumnName() : string
Return values
string —Column name
getColumnType()
Get the MySQL type to create the column with.
public
getColumnType() : string
Example: bigint, varchar(64)...
Return values
string —Column type
getModule()
Get the name of the module this injector belongs to.
public
getModule() : string
Return values
string —Module name
getName()
Get a "friendly name" of this injector.
public
getName() : string
Used on Group Sync page as the label for the dropdown.
Return values
string —Friendly name
getNotEnabledMessage()
Get the message to display in place of the group dropdown on the Group Sync page.
public
getNotEnabledMessage(Language $language) : string
Parameters
- $language : Language
-
The logged in user's language to use for translations.
Return values
string —Not enabled message
getSelectionOptions()
Get a list of groups available for this injector.
public
getSelectionOptions() : array<string|int, mixed>
Returned array must be in the shape of:.
[
'id' => ID of the group used by your service to apply the group by.
'name' => Name of group to display in the dropdown on the Group Sync page.
]
Return values
array<string|int, mixed>getValidationMessages()
Get specific error messages to display for each validation rule their form submission does not meet.
public
getValidationMessages(Language $language) : array<string|int, mixed>
Can return an empty array to use automatically generated messages.
Parameters
- $language : Language
-
The logged-in user's language to use for translations.
Return values
array<string|int, mixed> —Validation error messages
getValidationRules()
Get an array of rules to validate Group Sync creation/update requests with for this group.
public
getValidationRules() : array<string|int, mixed>
Should not be an issue unless people edit the input values in Inspect Element before submitting, simply a safety measure.
Should be using the constants from the Validate
class.
Return values
array<string|int, mixed> —Validation rules
removeGroup()
Remove this group from the user.
public
removeGroup(User $user, mixed $group_id) : bool
Parameters
- $user : User
-
Instance of affected NamelessMC user.
- $group_id : mixed
-
Native group ID to use for lookup on your service.
Return values
bool —Whether the group was successfully removed or not
shouldEnable()
Determine if this injector should be enabled or not.
public
shouldEnable() : bool
The GroupSyncManager will check if this injector's module is enabled or not.
Return values
bool —Whether to enable this injector or not.