Check that messages older than two weeks are not passed to bulk delete

This resolves #477
This commit is contained in:
Christopher F
2017-02-23 17:39:10 -05:00
parent 9d7073fafe
commit 607f478b9a
3 changed files with 11 additions and 0 deletions

View File

@@ -181,5 +181,13 @@ namespace Discord
if (msg == null) return new ArgumentException($"Value must be less than {value}", name);
else return new ArgumentException(msg, name);
}
// Bulk Delete
public static void NoMessageOlderThanTwoWeeks(ulong[] collection, string name)
{
var minimum = DateTimeUtils.ToSnowflake(DateTimeOffset.Now.Subtract(TimeSpan.FromDays(14)));
for (var i = 0; i < collection.Length; i++)
if (collection[i] <= minimum) throw new ArgumentOutOfRangeException(name, "Messages must be younger than two weeks to delete.");
}
}
}