コード例 #1
0
ファイル: Bot.cs プロジェクト: davidhenshaw/basic_discord_bot
        public async Task MainAsync()
        {
            _client     = new DiscordSocketClient();
            _configJson = await Utility.ImportJson <ConfigJson>("config.json");

            _quips = await Utility.ImportJson <QuipsService>("quips.json");

            _commands = new CommandService();

            _services = new ServiceCollection();
            _services.AddSingleton(_client);
            _services.AddSingleton(_commands);
            _services.AddSingleton(_configJson);
            _services.AddSingleton(_quips);
            _services.AddSingleton <CommandHandler>();
            _services.AddSingleton <StartupService>();


            IServiceProvider provider = _services.BuildServiceProvider();

            SubscribeToClientEvents();

            await provider.GetRequiredService <CommandHandler>().InstallCommandsAsync();

            await provider.GetRequiredService <StartupService>().SignInToDiscord();

            // await forever
            await Task.Delay(-1);
        }
コード例 #2
0
 public TestModule(CommandService service, ConfigJson configJson, QuipsService quips, DiscordSocketClient client)
 {
     _client     = client;
     _service    = service;
     _configJson = configJson;
     _quips      = quips;
 }