DiscordAccount Model

What is the DiscordAccount model?

Jakyeru\Larascord\Models\DiscordAccount represents a row in the larascord_accounts table. It holds the Discord profile and a user_id foreign key pointing at your user model.

Retrieving an account

use Jakyeru\Larascord\Models\DiscordAccount;
 
$account = DiscordAccount::forUser(auth()->user());
 
$account = DiscordAccount::forDiscordId('81384788765712384');
 
$account = auth()->user()->discordAccount;

The discordAccount relationship requires the InteractsWithDiscord trait on your user model. forUser and forDiscordId do not.

Attributes

AttributeTypeDescription
user_idmixedThe primary key of the linked user.
discord_idstringThe user's Discord ID.
usernamestringThe user's unique Discord username.
global_namestringThe user's global display name.
display_namestringglobal_name, falling back to username.
tagstringThe user's tag, for example jakye or jakye#0001.
discriminatorstringThe user's discriminator.
emailstringThe e-mail address of the Discord account.
avatarstringThe avatar hash.
verifiedboolWhether the e-mail address is verified.
bannerstringThe banner hash.
banner_colorstringThe banner color.
accent_colorstringThe accent color.
localestringThe user's locale.
mfa_enabledboolWhether the user has multifactor authentication enabled.
premium_typeintThe user's Nitro subscription type.
public_flagsintThe user's public flags.

display_name and tag are accessors. The remaining attributes are columns of the larascord_accounts table.

Relationships

$account->user;
 
$account->accessToken;

Methods

The account exposes the Discord API methods documented in InteractsWithDiscord Trait.

$account->getAvatar(['size' => 64]);
$account->getAccessToken();
$account->refreshAccessToken();
$account->getGuilds();
$account->getGuildMember('81384788765712384');
$account->joinGuild('81384788765712384');
$account->getConnections();

revoke

⚠️

This method revokes the OAuth2 access token with Discord and deletes the row from larascord_accounts. The linked user is not deleted.

/**
* Revoke the access token and delete the account.
*
* @return bool
* @throws Illuminate\Http\Client\RequestException
*/