Ejemplo n.º 1
0
    public async Task <IResult> DeleteBanAsync(long banID)
    {
        var getBan = await _bans.GetBanAsync(_context.GuildID.Value, banID);

        if (!getBan.IsSuccess)
        {
            return(getBan);
        }

        var ban = getBan.Entity;

        // This has to be done before the warning is actually deleted - otherwise, the lazy loader is removed and
        // navigation properties can't be evaluated
        var notifyResult = await _logging.NotifyUserUnbannedAsync(ban, _context.User.ID);

        if (!notifyResult.IsSuccess)
        {
            return(notifyResult);
        }

        var deleteBan = await _bans.DeleteBanAsync(ban);

        if (!deleteBan.IsSuccess)
        {
            return(deleteBan);
        }

        return(await _guildAPI.RemoveGuildBanAsync(_context.GuildID.Value, ban.User.DiscordID));
    }