Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
 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.");
         }
     }
 }
Ejemplo n.º 3
0
 public async Task RestartCmd(string name)
 {
     _service.Restart(name);
     await ReplyAsync($"{name} timer restarted.");
 }
Ejemplo n.º 4
0
        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;
        }
Ejemplo n.º 5
0
 public void  Restart()
 {
     myTimer.Restart(); myTimerService.Restart(this);
 }