Discord
in package
Discord utility class
Tags
Table of Contents
Properties
Methods
- botRequest() : false|string
- Make a request to the Discord bot.
- getDiscordRoleId() : null|int
- Get the associated NamelessMC group ID for a Discord role.
- getGuildId() : string|null
- getLanguageTerm() : string
- Get a language term for the Discord Integration module.
- getRoles() : array<string|int, mixed>
- Get cached Discord roles.
- isBotSetup() : bool
- saveRoles() : void
- Cache Discord roles.
- updateDiscordRoles() : false|array<string|int, mixed>
- Update a user's roles in the Discord guild.
Properties
$_discord_integration_language
private
static Language
$_discord_integration_language
Instance of Language class for translations
$_is_bot_setup
private
static bool
$_is_bot_setup
Whether the Discord bot is set up properly
Methods
botRequest()
Make a request to the Discord bot.
public
static botRequest(string $url[, string|null $body = null ]) : false|string
Parameters
- $url : string
-
URL of the Discord bot instance
- $body : string|null = null
-
Body of the request
Return values
false|string —Response from the Discord bot or false if the request failed
getDiscordRoleId()
Get the associated NamelessMC group ID for a Discord role.
public
static getDiscordRoleId(DB $db, int $nameless_group_id) : null|int
Parameters
- $db : DB
-
Instance of DB class
- $nameless_group_id : int
-
The ID of the NamelessMC group
Return values
null|int —The Discord role ID for the NamelessMC group
getGuildId()
public
static getGuildId() : string|null
Return values
string|null —Discord guild ID for this site
getLanguageTerm()
Get a language term for the Discord Integration module.
public
static getLanguageTerm(string $term[, array<string|int, mixed> $variables = [] ]) : string
Parameters
- $term : string
-
Term to search for
- $variables : array<string|int, mixed> = []
-
Variables to replace in the term
Return values
string —Language term from the language file
getRoles()
Get cached Discord roles.
public
static getRoles() : array<string|int, mixed>
Return values
array<string|int, mixed> —Cached Discord roles
isBotSetup()
public
static isBotSetup() : bool
Return values
bool —Whether the Discord bot is set up properly
saveRoles()
Cache Discord roles.
public
static saveRoles(mixed $roles) : void
Parameters
- $roles : mixed
-
Discord roles to cache
updateDiscordRoles()
Update a user's roles in the Discord guild.
public
static updateDiscordRoles(User $user, array<string|int, mixed> $added, array<string|int, mixed> $removed) : false|array<string|int, mixed>
Parameters
- $user : User
-
The user whose roles to update
- $added : array<string|int, mixed>
-
Array of Discord role IDs to add
- $removed : array<string|int, mixed>
-
Array of Discord role IDs to remove
Return values
false|array<string|int, mixed> —Roles added and removed with their status. False if error