Beispiel #1
0
        private async Task CheckConfigsAsync()
        {
            BotConfig conf = BotConfig.Load();

            if (configType == ConfigType.Individual)
            {
                foreach (var guild in GetBot().Guilds)
                {
                    IndividualConfig gconf = conf.GetConfig(guild.Id);
                    if (gconf == null)
                    {
                        gconf = conf.FreshConfig(guild.Id);
                        conf.Configs.Add(gconf);
                    }
                }
            }

            await Util.LoggerAsync(new LogMessage(LogSeverity.Info, "Gateway", $"Successfully connected to {bot.Guilds.Count} guilds"));

            conf.LastStartup = DateTime.UtcNow;
            conf.Save();

            var restart = Task.Run(async() =>
            {
                await Task.Delay(RestartEveryMs);

                // Code to restart bot
                Process.Start(AppContext.BaseDirectory + ExecutableName + ".exe");
                // Close this instance
                Environment.Exit(0);
            });
        }
Beispiel #2
0
        private async Task JoinGuildAsync(SocketGuild guild)
        {
            if (configType == ConfigType.Individual)
            {
                BotConfig conf = BotConfig.Load();

                IndividualConfig gconf = conf.GetConfig(guild.Id);
                if (gconf == null)
                {
                    gconf = conf.FreshConfig(guild.Id);
                    conf.Configs.Add(gconf);
                    conf.Save();
                }
            }
        }