public async Task AddPoints(CommandContext context) { if (context is null) { throw new ArgumentNullException(nameof(context)); } if (context.User.IsBot) { return; } var GuildId = context.Guild.Id; var UserId = context.User.Id; ulong Points = (ulong)_rand.Next(10, 20); var statistics = await _statisticsRepository.GetUserStatistics(GuildId, UserId); if (statistics is null) { statistics = new UserStatistic() { UserId = UserId, GuildId = GuildId, Score = Points, LastScoredMessage = DateTime.Now }; await _statisticsRepository.AddUserStatistic(statistics); } else { if ((DateTime.Now - statistics.LastScoredMessage).Minutes < 2) { return; } statistics.Score += Points; await _statisticsRepository.UpdateStatistics(statistics); } var user = (context.User as SocketGuildUser); var roles = await _statisticsRepository.GetRankRewards(GuildId); var userRoles = ( from reward in roles join userRole in context.Guild.Roles on reward.RoleId equals userRole.Id where reward.ReqScore <= statistics.Score orderby reward.ReqScore select userRole).ToArray(); if (userRoles.Length <= 0) { return; } IEnumerable <IRole> rolesToRemove = userRoles[0..^ 1];