Esempio n. 1
0
        private async Task Initialize(string botToken, string ownerName, string ownerDiscriminator, string commandPrefix)
        {
            config = ConfigurationFile.ReadFromFile(configPath);
            if (config == null)
            {
                config = ConfigurationFile.Make(botToken, ownerName, ownerDiscriminator, commandPrefix);
                config.SaveToFile(configPath);
            }

            client = new DiscordClient(new DiscordConfiguration()
            {
                Token     = config.BotToken,
                TokenType = TokenType.Bot
            });
            client.MessageCreated += async e =>
            {
                await NotifyMessage(e);
            };
            await client.ConnectAsync();

            foreach (SavedChannel c in config.SavedChannels)
            {
                monitoredChannels.Add(await c.Get(client));
            }
            OnChannelAmountChanged(MonitoredChannelsNumber);
            while (DiscordShouldRun)
            {
                await Task.Delay(3000);
            }
            await client.DisconnectAsync();

            RunningThread = null;
            OnDisconnect();
        }