public bool PreExecute(FluzzBot bot, string username, bool isAutoFire) { if (bot.RemovedCommands[username].Contains(_commandName)) { return(false); } if (_onCoolDownDict == null) { _cooldownDict = new Dictionary <string, int>(); _onCoolDownDict = new Dictionary <string, bool>(); _timerDict = new Dictionary <string, Timer>(); _timerStartDict = new Dictionary <string, DateTime>(); } if (_hasCooldown) { CheckForCooldown(username); if (!_onCoolDownDict.ContainsKey(username)) { _onCoolDownDict.Add(username, false); } if (!_onCoolDownDict[username]) { if (_hasCooldown) { if (_onCoolDownDict.ContainsKey(username)) { _onCoolDownDict[username] = true; } else { _onCoolDownDict.Add(username, true); } _timerDict[username].Interval = _cooldownDict[username] * 1000; _timerDict[username].Elapsed += (sender, args) => { _timer_Elapsed(sender, args, username); }; if (_timerStartDict.ContainsKey(username)) { _timerStartDict[username] = DateTime.Now; } else { _timerStartDict.Add(username, DateTime.Now); } _timerDict[username].Start(); return(true); } else { return(true); } } else { double secs = (DateTime.Now - _timerStartDict[username]).TotalSeconds; if (!isAutoFire) { bot.ConstructAndEnqueueMessage("I'm on cooldown for another " + Math.Floor(_cooldownDict[username] + 0.0 - secs) + " seconds", username); } return(false); } } else { return(true); } }
public void Execute(FluzzBot bot, string username) { }