internal static async Task <DateTimeOffset> GiveRateLimit(ulong userId, DateTimeOffset start, GuildConfig config, uint?overrideTime = null) { DateTimeOffset end; // update config, and set end time if (config != null) { if (config.UserRateLimitCounts.ContainsKey(userId)) { config.UserRateLimitCounts[userId] += 1; } else { config.UserRateLimitCounts.Add(userId, 1); } await config.Update(); end = start.AddMinutes(config.UserRateLimitCounts[userId] * 20); } else { end = start.AddMinutes(20); } // mute command if (overrideTime.HasValue) { end = start.AddMinutes(overrideTime.Value); } // add mute to memory if (!IsRateLimited(userId)) { RateLimitedUsers.Add(userId, end); } else { RateLimitedUsers[userId] = end; } return(end); }