示例#1
0
        public async Task StartAsync()
        {
            _client         = new DiscordSocketClient();
            _commands       = new CommandService();
            _weatherservice = new weatherservice();

            // Avoid hard coding your token. Use an external source instead in your code.
            string token = "NDI1NjU2MTQ1OTYxNTQ5ODI0.DZKmsw.NJJH2OP7th-rGtnEyHnikj1pv5U";



            _services = new ServiceCollection()
                        .AddSingleton(_client)
                        .AddSingleton(_commands)
                        .AddSingleton(_weatherservice)
                        .BuildServiceProvider();

            await InstallCommandsAsync();

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

            await _client.StartAsync();

            await Task.Delay(-1);
        }
示例#2
0
 public Misc(weatherservice ser)
 {
     _weatherService = ser;
 }