Interface IDiscordAccountService
- Namespace
- FishMMO.Database.Npgsql.Services.Interfaces
- Assembly
- FishMMO-DB.dll
The Discord bot's side of an account: delivering the one verification DM, and the account link.
public interface IDiscordAccountService
Remarks
Codes are issued by PersistDiscordVerifyCodeAsync(string, int, CancellationToken) and redeemed by PersistVerifiedByCodeAsync(string, int, CancellationToken), alongside email and SMS. This service only moves a delivery through claimed, sent or released; see DiscordVerification for why a claim is never reclaimed.
Methods
ClaimDeliveryAsync(string, CancellationToken)
Takes one account's DM to send it. False when it has been sent, is already taken, is no longer owed (the account verified another way), or has used up its attempts.
Task<DatabaseResult<bool>> ClaimDeliveryAsync(string accountName, CancellationToken cancellationToken = default)
Parameters
accountNamestringcancellationTokenCancellationToken
Returns
FetchLinkByDiscordUserAsync(long, CancellationToken)
The account a Discord user is linked to, or null.
Task<DatabaseResult<DiscordAccountLink?>> FetchLinkByDiscordUserAsync(long discordUserId, CancellationToken cancellationToken = default)
Parameters
discordUserIdlongcancellationTokenCancellationToken
Returns
FetchPendingDeliveriesAsync(int, CancellationToken)
DMs owed and not yet claimed, oldest account first.
Task<DatabaseResult<IReadOnlyList<DiscordVerificationDelivery>>> FetchPendingDeliveriesAsync(int limit, CancellationToken cancellationToken = default)
Parameters
limitintcancellationTokenCancellationToken
Returns
FetchPendingDeliveriesForUsernameAsync(string, CancellationToken)
DMs owed to one Discord username: what the bot asks when a member joins the server.
Task<DatabaseResult<IReadOnlyList<DiscordVerificationDelivery>>> FetchPendingDeliveriesForUsernameAsync(string discordUsername, CancellationToken cancellationToken = default)
Parameters
discordUsernamestringcancellationTokenCancellationToken
Returns
LinkAsync(string, long, string?, CancellationToken)
Links an account to a Discord user, replacing any earlier link on that account.
Task<DatabaseResult> LinkAsync(string accountName, long discordUserId, string? discordUsername, CancellationToken cancellationToken = default)
Parameters
accountNamestringdiscordUserIdlongdiscordUsernamestringcancellationTokenCancellationToken
Returns
- Task<DatabaseResult>
UNIQUE_VIOLATIONwhen that Discord user is already linked to a different account.
MarkDeliveredAsync(string, long, CancellationToken)
Records that the DM was delivered, and to which Discord user. No further DM is ever sent for the account.
Task<DatabaseResult> MarkDeliveredAsync(string accountName, long discordUserId, CancellationToken cancellationToken = default)
Parameters
accountNamestringdiscordUserIdlongcancellationTokenCancellationToken
Returns
ReleaseDeliveryAsync(string, string, bool, CancellationToken)
Gives a claimed DM back unsent, recording why.
Task<DatabaseResult> ReleaseDeliveryAsync(string accountName, string reason, bool countAttempt, CancellationToken cancellationToken = default)
Parameters
accountNamestringThe account.
reasonstringWhy it did not send, for staff.
countAttemptboolTrue when Discord refused the message, which counts towards MaxSendAttempts. False when the player simply is not reachable yet (not in the server), which does not.
cancellationTokenCancellationTokenCancellation token.
Returns
UnlinkAsync(long, CancellationToken)
Removes a Discord user's link. True when there was one.
Task<DatabaseResult<bool>> UnlinkAsync(long discordUserId, CancellationToken cancellationToken = default)
Parameters
discordUserIdlongcancellationTokenCancellationToken