/// <summary> /// Raised when the client connects to Discord. /// <para> /// Restarts the <see cref="TimerService"/> and logs that the client has connected. /// </para> /// </summary> /// <returns>No object or value is returned by this method when it completes.</returns> private Task ConnectedEventHandler() { Console.WriteLine($"\n{DateTime.Now}\nCLIENT CONNECTED\n"); _timerService.Restart(); return(Task.CompletedTask); }
public async Task fmrestarttimerAsync() { if (await _adminService.HasCommandAccessAsync(Context.User, UserType.Admin)) { try { _timer.Restart(); await ReplyAsync("Timer restarted"); } catch (Exception e) { _logger.LogError(e.Message, Context.Message.Content, Context.User.Username, Context.Guild?.Name, Context.Guild?.Id); await ReplyAsync("The timer service cannot be loaded. Please wait for the bot to fully load."); } } }
public async Task RestartCmd(string name) { _service.Restart(name); await ReplyAsync($"{name} timer restarted."); }
private void Initialise() { if (DoOnce) { return; } try { var config = new AIConfiguration(Tokens.Load().DialogFlowToken, SupportedLanguage.English); _apiAi = new ApiAi(config); } catch { // } try { foreach (var guild in _client.Guilds) { try { var guildconfig = GuildConfig.GetServer(guild); try { if (guildconfig.Levels.LevellingEnabled) { Levels.Add(new LevellingObj { GuildID = guildconfig.GuildId, Users = guildconfig.Levels.Users }); } if (guildconfig.AutoMessage.Any()) { AutomessageList.Add(new AutoMessages { GuildID = guildconfig.GuildId, Channels = guildconfig.AutoMessage }); } } catch (Exception e) { Console.WriteLine(e); } if (guildconfig.PartnerSetup.banned) { continue; } if (!guildconfig.PartnerSetup.IsPartner || !(_client.GetChannel(guildconfig.PartnerSetup.PartherChannel) is IMessageChannel)) { continue; } Console.WriteLine($"{guild.Id} Added to Timers"); TimerService.AcceptedServers.Add(guild.Id); } catch (Exception e) { Console.WriteLine(e); } } } catch { // } _service.Restart(); Console.WriteLine("DoOnce Completed."); DoOnce = true; }
public void Restart() { myTimer.Restart(); myTimerService.Restart(this); }