/// <summary>
        /// Clears the given user's default character.
        /// </summary>
        /// <param name="guildUser">The user.</param>
        /// <param name="ct">The cancellation token in use.</param>
        /// <returns>A modification result which may or may not have succeeded.</returns>
        public async Task <ModifyEntityResult> ClearDefaultCharacterAsync
        (
            IGuildUser guildUser,
            CancellationToken ct = default
        )
        {
            var getUser = await _users.GetOrRegisterUserAsync(guildUser, ct);

            if (!getUser.IsSuccess)
            {
                return(ModifyEntityResult.FromError(getUser));
            }

            var getServer = await _servers.GetOrRegisterServerAsync(guildUser.Guild, ct);

            if (!getServer.IsSuccess)
            {
                return(ModifyEntityResult.FromError(getServer));
            }

            var user   = getUser.Entity;
            var server = getServer.Entity;

            return(await _characters.ClearDefaultCharacterAsync(user, server, ct));
        }
Ejemplo n.º 2
0
    /// <summary>
    /// Clears the given user's default character.
    /// </summary>
    /// <param name="guildID">The ID of the guild the user is on.</param>
    /// <param name="userID">The ID of the discord user.</param>
    /// <param name="ct">The cancellation token in use.</param>
    /// <returns>A modification result which may or may not have succeeded.</returns>
    public async Task <Result> ClearDefaultCharacterAsync
    (
        Snowflake guildID,
        Snowflake userID,
        CancellationToken ct = default
    )
    {
        var getUser = await _users.GetOrRegisterUserAsync(userID, ct);

        if (!getUser.IsSuccess)
        {
            return(Result.FromError(getUser));
        }

        var getServer = await _servers.GetOrRegisterServerAsync(guildID, ct);

        if (!getServer.IsSuccess)
        {
            return(Result.FromError(getServer));
        }

        var user   = getUser.Entity;
        var server = getServer.Entity;

        return(await _characters.ClearDefaultCharacterAsync(user, server, ct));
    }