예제 #1
0
 public DiscordBotSharder(
     IOptions <DiscordBotSharderConfiguration> options,
     ILogger <DiscordBotSharder> logger,
     IPrefixProvider prefixes,
     ICommandQueue queue,
     CommandService commands,
     IServiceProvider services,
     DiscordClientSharder client)
     : base(options, logger, prefixes, queue, commands, services, client)
 {
 }
        protected ExtendedDiscordBot(TokenType tokenType, string token, IPrefixProvider prefixProvider, ExtendedDiscordBotConfiguration configuration = null)
            : base(tokenType, token, prefixProvider, configuration?.CopyAndConfigure() ?? new ExtendedDiscordBotConfiguration())
        {
            _configuration = configuration;
            _handlerDict   = new Dictionary <Type, IEnumerable <IHandler> >();

            typeof(DiscordBotBase).GetField("_provider", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(this,
                                                                                                                  _configuration.BaseServiceCollection
                                                                                                                  .AddSingleton(GetType(), this)
                                                                                                                  .DiscoverServices()
                                                                                                                  .BuildServiceProvider());
        }
예제 #3
0
        internal DiscordBotBase(DiscordClientBase client, IPrefixProvider prefixProvider, IDiscordBotBaseConfiguration configuration)
            : base(client)
        {
            PrefixProvider  = prefixProvider;
            _commandService = new CommandService(configuration.CommandServiceConfiguration ?? CommandServiceConfiguration.Default);
            _provider       = configuration.ProviderFactory?.Invoke(this);
            AddTypeParser(CachedRoleTypeParser.Instance);
            AddTypeParser(CachedMemberTypeParser.Instance);
            AddTypeParser(CachedUserTypeParser.Instance);
            AddTypeParser(CachedGuildChannelTypeParser <CachedGuildChannel> .Instance);
            AddTypeParser(CachedGuildChannelTypeParser <CachedTextChannel> .Instance);
            AddTypeParser(CachedGuildChannelTypeParser <CachedVoiceChannel> .Instance);
            AddTypeParser(CachedGuildChannelTypeParser <CachedCategoryChannel> .Instance);
            AddTypeParser(LocalCustomEmojiTypeParser.Instance);
            AddTypeParser(SnowflakeTypeParser.Instance);
            AddTypeParser(ColorTypeParser.Instance);
            //AddTypeParser(SanitaryContentParser.Instance);

            MessageReceived += MessageReceivedAsync;
        }
예제 #4
0
        public VerificationBot
        (
            IOptions <DiscordBotConfiguration> options,
            ILogger <DiscordBot> logger,
            IPrefixProvider prefixes,
            ICommandQueue queue,
            CommandService commands,
            IServiceProvider services,
            DiscordClient client
        ) : base(options, logger, prefixes, queue, commands, services, client)
        {
            Config = services.GetService(typeof(Config)) as Config;

            // Setup background tasks
            BackgroundTasks = new BackgroundTask[]
            {
                new GenericTask(TimeSpan.FromSeconds(5), static bot => MuteService.CheckUnmutes(bot.Config, bot.GetGuilds())),
                new GenericTask(TimeSpan.FromMinutes(5), static bot => bot.Config.Save(Program.CONFIG_FILE)),
                new CheckRunsTask(TimeSpan.FromMinutes(1))
            };

            // Setup update timer
            UpdateTimer = new Timer
            {
                AutoReset = true,
                Interval  = TimeSpan.FromSeconds(5).TotalMilliseconds
            };

            UpdateTimer.Elapsed += UpdateBackgroundTasks;

            // Hook bot events
            commands.CommandExecutionFailed += OnCommandFailed;

            ReactionAdded   += OnReactionAdded;
            ReactionRemoved += OnReactionRemoved;

            MessageUpdated += OnMessageEdited;
            MessageDeleted += OnMessageDeleted;
        }
예제 #5
0
 internal StatsDHelper(IPrefixProvider prefixProvider, IStatsd statsdClient)
 {
     _prefixProvider = prefixProvider;
     _statsdClient = statsdClient;
 }
예제 #6
0
 public DiscordBotSharder(TokenType tokenType, string token, IPrefixProvider prefixProvider, DiscordBotSharderConfiguration configuration = null)
     : base(new DiscordSharder(tokenType, token, configuration ??= new DiscordBotSharderConfiguration()), prefixProvider, configuration)
예제 #7
0
 public DiscordBot(RestDiscordClient restClient, IPrefixProvider prefixProvider, DiscordBotConfiguration configuration = null)
     : base(new DiscordClient(restClient, configuration ??= new DiscordBotConfiguration()), prefixProvider, configuration)
예제 #8
0
 public DiscordService(AbfConfigurationProvider configProvider, IPrefixProvider prefixProvider, IServiceProvider services, DiscordBotConfiguration discordConfig = null)
     : base(TokenType.Bot, configProvider.Configuration.DiscordToken, prefixProvider, discordConfig)
 {
     _logger        = LogService.GetLogger("Discord");
     _configuration = configProvider.Configuration;
 }
예제 #9
0
 internal StatsDHelper(IPrefixProvider prefixProvider, IStatsd statsdClient)
 {
     _prefixProvider = prefixProvider;
     _statsdClient   = statsdClient;
 }