Exemplo n.º 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());
        }
Exemplo n.º 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;
        }
Exemplo n.º 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;
        }
Exemplo n.º 5
0
 internal StatsDHelper(IPrefixProvider prefixProvider, IStatsd statsdClient)
 {
     _prefixProvider = prefixProvider;
     _statsdClient = statsdClient;
 }
Exemplo n.º 6
0
 public DiscordBotSharder(TokenType tokenType, string token, IPrefixProvider prefixProvider, DiscordBotSharderConfiguration configuration = null)
     : base(new DiscordSharder(tokenType, token, configuration ??= new DiscordBotSharderConfiguration()), prefixProvider, configuration)
Exemplo n.º 7
0
 public DiscordBot(RestDiscordClient restClient, IPrefixProvider prefixProvider, DiscordBotConfiguration configuration = null)
     : base(new DiscordClient(restClient, configuration ??= new DiscordBotConfiguration()), prefixProvider, configuration)
Exemplo n.º 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;
 }
Exemplo n.º 9
0
 internal StatsDHelper(IPrefixProvider prefixProvider, IStatsd statsdClient)
 {
     _prefixProvider = prefixProvider;
     _statsdClient   = statsdClient;
 }