Beispiel #1
0
 public UserRecordMessage(SocketGuildUser user, UserRecord record)
 {
     EmbedBuilder = new EmbedBuilder()
     {
         Author = new EmbedAuthorBuilder()
         {
             Name    = user.ToString(),
             IconUrl = user.GetAvatarUrl() ?? user.GetDefaultAvatarUrl(),
         },
         Title       = "User record overview",
         Description = $"{record.Warnings.Count} warnings, {record.Mutes.Count} mutes.",
         Color       = Color.LightGrey,
     };
 }
Beispiel #2
0
        /// <summary>Checks whether a user is abusing commands.</summary>
        /// <returns>True if the user should be rate limited due to command abuse.</summary>
        public static bool CheckForCommandAbuse(SocketCommandContext context)
        {
            const int numOfCommandsToCheck = 12;

            UserRecord record = GetUserRecord(
                DataManager.AllGuildData[context.Guild.Id].Moderator,
                context.Message.Author.Id);

            record.CommandExecutedDateTimes.Add(context.Message.Timestamp);

            if (record.CommandExecutedDateTimes.Count < numOfCommandsToCheck)
            {
                return(false);
            }
            record.CommandExecutedDateTimes.Truncate(numOfCommandsToCheck);

            // Represents the time difference between a set number of commands (numOfCommandsToCheck).
            TimeSpan difference = context.Message.Timestamp.Subtract(record.CommandExecutedDateTimes[0]);

            return(difference < TimeSpan.FromSeconds(30));
        }