diff --git a/Discord/Controller/EventController.cs b/Discord/Controller/EventController.cs index ced3d3a..d01f5e2 100644 --- a/Discord/Controller/EventController.cs +++ b/Discord/Controller/EventController.cs @@ -60,12 +60,15 @@ namespace Discord.Controller { methods.AddRange(type.GetMethods()); } - EventControllerAttribute? attribute; + List>? attribute; foreach (var method in methods) { - attribute = method.GetCustomAttribute>(); - if (attribute is not null && EqualityComparer.Default.Equals(attribute.Event, category)) - method.Invoke(null, new object[] { ids, e }); + attribute = method.GetCustomAttributes>().ToList(); + foreach (var attr in attribute) + { + if (EqualityComparer.Default.Equals(attr.Event, category)) + method.Invoke(null, new object[] { ids, e }); + } } } } diff --git a/Discord/Helpers/Timer.cs b/Discord/Helpers/Timer.cs new file mode 100644 index 0000000..37425f9 --- /dev/null +++ b/Discord/Helpers/Timer.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Cryptography; +using System.Text; +using System.Threading.Tasks; + +namespace Discord.Helpers +{ + internal class Timer + { + private System.Threading.Timer? timer; + public void SetUpTimer(TimeSpan alertTime,object passingObject, Action method) + { + DateTime current = DateTime.Now; + TimeSpan timeToGo = alertTime - current.TimeOfDay; + if (timeToGo < TimeSpan.Zero) + { + return;//time already passed + } + this.timer = new System.Threading.Timer(x => + { + method.Invoke(passingObject); + }, null, timeToGo, Timeout.InfiniteTimeSpan); + } + } +}