Table of Contents

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

accountName string
cancellationToken CancellationToken

Returns

Task<DatabaseResult<bool>>

FetchLinkByDiscordUserAsync(long, CancellationToken)

The account a Discord user is linked to, or null.

Task<DatabaseResult<DiscordAccountLink?>> FetchLinkByDiscordUserAsync(long discordUserId, CancellationToken cancellationToken = default)

Parameters

discordUserId long
cancellationToken CancellationToken

Returns

Task<DatabaseResult<DiscordAccountLink?>>

FetchPendingDeliveriesAsync(int, CancellationToken)

DMs owed and not yet claimed, oldest account first.

Task<DatabaseResult<IReadOnlyList<DiscordVerificationDelivery>>> FetchPendingDeliveriesAsync(int limit, CancellationToken cancellationToken = default)

Parameters

limit int
cancellationToken CancellationToken

Returns

Task<DatabaseResult<IReadOnlyList<DiscordVerificationDelivery>>>

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

discordUsername string
cancellationToken CancellationToken

Returns

Task<DatabaseResult<IReadOnlyList<DiscordVerificationDelivery>>>

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

accountName string
discordUserId long
discordUsername string
cancellationToken CancellationToken

Returns

Task<DatabaseResult>

UNIQUE_VIOLATION when 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

accountName string
discordUserId long
cancellationToken CancellationToken

Returns

Task<DatabaseResult>

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

accountName string

The account.

reason string

Why it did not send, for staff.

countAttempt bool

True 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.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<DatabaseResult>

UnlinkAsync(long, CancellationToken)

Removes a Discord user's link. True when there was one.

Task<DatabaseResult<bool>> UnlinkAsync(long discordUserId, CancellationToken cancellationToken = default)

Parameters

discordUserId long
cancellationToken CancellationToken

Returns

Task<DatabaseResult<bool>>