コード例 #1
0
 public CommandHandler(DiscordSocketClient client, CommandService commands, ConfigJson configFile, IServiceProvider provider)
 {
     _provider = provider;
     _commands = commands;
     _client   = client;
     _json     = configFile;
 }
コード例 #2
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);
        }
コード例 #3
0
 public TestModule(CommandService service, ConfigJson configJson, QuipsService quips, DiscordSocketClient client)
 {
     _client     = client;
     _service    = service;
     _configJson = configJson;
     _quips      = quips;
 }
コード例 #4
0
 public StartupService(DiscordSocketClient client, ConfigJson config)
 {
     _client     = client;
     _configJson = config;
 }