Class AccountLinkingService
- Namespace
- FishMMO.DiscordBot.Services
- Assembly
- FishMMO-DiscordBot.dll
Manages Discord-to-game account linking via verification codes. Users request a link with a character name, receive a code, type it in-game, and the polling service confirms the link when the code appears in chat.
public sealed class AccountLinkingService : IDisposable
- Inheritance
-
AccountLinkingService
- Implements
- Inherited Members
Constructors
AccountLinkingService(BotConfigurationService, ILogger<AccountLinkingService>)
Initializes a new instance of the AccountLinkingService class.
public AccountLinkingService(BotConfigurationService botConfigService, ILogger<AccountLinkingService> logger)
Parameters
botConfigServiceBotConfigurationServiceloggerILogger<AccountLinkingService>
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
GetLinkedAccount(ulong)
Gets the linked account for a Discord user, if any.
public LinkedAccount? GetLinkedAccount(ulong discordUserId)
Parameters
discordUserIdulong
Returns
HasPendingVerification(ulong)
Checks if a Discord user has a pending verification.
public bool HasPendingVerification(ulong discordUserId)
Parameters
discordUserIdulong
Returns
StartLinkRequest(ulong, string)
Starts a link request for the given Discord user and character name. Returns the verification code the user must type in-game.
public string? StartLinkRequest(ulong discordUserId, string characterName)
Parameters
discordUserIdulongThe Discord user ID.
characterNamestringThe character name claimed by the user.
Returns
- string
The verification code, or null if the user already has a linked account.
TryVerifyFromChat(string, string, string)
Checks whether a chat message from the game contains a pending verification code. If it matches, confirms the link and returns the associated Discord user ID.
public ulong? TryVerifyFromChat(string characterName, string accountName, string message)
Parameters
characterNamestringThe character name that sent the message.
accountNamestringThe game account name.
messagestringThe chat message content.
Returns
- ulong?
The Discord user ID if verification succeeded; null otherwise.
Unlink(ulong)
Removes a linked account for the specified Discord user.
public bool Unlink(ulong discordUserId)
Parameters
discordUserIdulong
Returns
- bool
True if the account was unlinked.