Пример #1
0
        public MessageHandler(TrafficRouterBot routerBot, CommandHandler commandHandler, GuildSettingsTracker settingsTracker)
        {
            _routerBot = routerBot;
            _routerBot.Client.MessageReceived += OnMessageReceived;

            _commandHandler  = commandHandler;
            _settingsTracker = settingsTracker;
        }
Пример #2
0
        public async Task InitAsync()
        {
            _client = new DiscordSocketClient();

            _client.Log              += Log;
            _client.Ready            += Ready;
            _client.ChannelDestroyed += ChannelDestroyed;
            _client.ChannelUpdated   += ChannelUpdated;

            _fileHandler          = new FileHandler();
            _guildSettingsTracker = new GuildSettingsTracker(this, _fileHandler);
            _commandHandler       = new CommandHandler(this, _guildSettingsTracker);
            _messageHandler       = new MessageHandler(this, _commandHandler, _guildSettingsTracker);

            // You will need to add a text file called "token.txt", in a dir: "exe_root\Configs\" and paste your bot token in the file.
            string[] tokenFileContent = _fileHandler.ReadAllLinesTextFile("token", ".txt");
            string   token            = string.Empty;

            if (tokenFileContent != null)
            {
                foreach (string tokenFileLine in tokenFileContent)
                {
                    token += tokenFileLine;
                }

                await _client.LoginAsync(TokenType.Bot, token);

                await _client.StartAsync();
            }
            else
            {
                Console.WriteLine("ERROR: You need to create a \"token.txt\" file under .exe-root\\Configs\\ dir.");
            }

            // Block this task until the program is closed.
            await Task.Delay(-1);
        }
Пример #3
0
 public CommandHandler(TrafficRouterBot routerBot, GuildSettingsTracker settingsTracker)
 {
     _routerBot       = routerBot;
     _settingsTracker = settingsTracker;
 }