Пример #1
0
        public async Task Start()
        {
            // open or create our database (if it doesn't exist)
            _database = new LiteDatabase(Program.GlobalConfiguration.Data.LiteDatabasePath);

            // add our startup date
            var startup = _database.GetCollection <StartupEvent>("startup");

            startup.Insert(new StartupEvent()
            {
                Time = DateTime.Now
            });

            // starts our client
            // we use LogSeverity.Debug because more info the better
            m_client = new DiscordSocketClient(new DiscordSocketConfig()
            {
                LogLevel = Discord.LogSeverity.Info
            });

            _commands    = new CommandService();
            messageRetry = new MessageRetryService(m_client);

            // log in as a bot using our connection token
            await m_client.LoginAsync(TokenType.Bot, Program.GlobalConfiguration.Data.ConnectionToken);

            await m_client.StartAsync();

            // dependency injection
            _services = new ServiceCollection()
                        .AddSingleton(m_client)
                        .AddSingleton(_commands)
                        .AddSingleton(_database)
                        .AddSingleton(new CounterService(_database, m_client))
                        .AddSingleton(new ReminderService(m_client, _database))
                        .AddSingleton(new TagService(_database))
                        .AddSingleton(new SpookeningService(m_client, _database, Program.GlobalConfiguration.Data.SpookyConfigJson))
                        .AddSingleton(messageRetry)
                        .AddSingleton(new MinesweeperSolutionService())
                        .AddSingleton(new CourseService(m_client))
                        .BuildServiceProvider();

            await InstallCommandsAsync();

            messageRetry.OnCommandRetryHandler += commandMessageUpdated;

            // set up our logging function
            m_client.Log += Log;

            // show an invite link when we are ready to go
            m_client.Ready += Client_Ready;

            // set some help text
            await m_client.SetGameAsync($"Type {GlobalConfiguration.CommandPrefix}Help");

            // wait indefinitely
            await Task.Delay(-1);
        }
Пример #2
0
 public RetryModuleBase(MessageRetryService messageRetry)
 {
     this.messageRetry = messageRetry;
 }
Пример #3
0
 public MinesweeperCommand(MessageRetryService retryService, MinesweeperSolutionService solutions) : base(retryService)
 {
     random         = new Random();
     this.solutions = solutions;
 }
Пример #4
0
 public MsdnCommands(MessageRetryService retry) : base(retry)
 {
 }
Пример #5
0
 public RetryExampleCommand(MessageRetryService retry) : base(retry)
 {
 }
Пример #6
0
 public BasicCommands(CommandService commands, MessageRetryService retryService) : base(retryService)
 {
     _commandService = commands;
 }