Пример #1
0
        public async Task SetModeratorAsync(ulong roleId)
        {
            _service = new GuildConfigService(Context.Guild, _context);

            _service.SetPermissionAsync(Context.Guild, Permissions.Moderator, roleId);
            await ReplyAsync($"Permission for Moderators has been successfully updated to {roleId}");
        }
Пример #2
0
        public static Task GuildAvailableEventHandlerAsync(TheGodfatherBot bot, GuildCreateEventArgs e)
        {
            LogExt.Information(bot.GetId(e.Guild.Id), "Available: {AvailableGuild}", e.Guild);
            GuildConfigService gcs = bot.Services.GetRequiredService <GuildConfigService>();

            return(gcs.IsGuildRegistered(e.Guild.Id) ? Task.CompletedTask : gcs.RegisterGuildAsync(e.Guild.Id));
        }
Пример #3
0
        public async Task ShowConfigAsync()
        {
            _service = new GuildConfigService(Context.Guild, _context);

            var res = _service.GenerateFormattedConfig(Context.Guild);

            await ReplyAsync(res);
        }
        public void InitializeService()
        {
            var bcs = new BotConfigService();

            this.Configs = new GuildConfigService(bcs, TestDbProvider.Database, false);
            this.Service = new LocalizationService(this.Configs, bcs, false);
            Assume.That(Directory.Exists(this.ValidTestDataPath), "Valid tests dir not present");
            Assume.That(Directory.Exists(this.ThrowsIOTestDataPath), "Invalid tests dir not present");
        }
 public LocalizationService(GuildConfigService gcs, BotConfigService cfg, bool loadData = true)
 {
     this.gcs           = gcs;
     this.DefaultLocale = cfg.CurrentConfiguration.Locale;
     if (loadData)
     {
         this.LoadData("Translations");
     }
 }
Пример #6
0
 public GeneralCommands(IServiceProvider services)
 {
     _commandService = services.GetRequiredService <CommandService>();
     _config         = services.GetRequiredService <IConfiguration>();
     _client         = services.GetRequiredService <DiscordSocketClient>();
     _logger         = services.GetRequiredService <LoggingService>();
     _commands       = services.GetRequiredService <CommandHandler>();
     _http           = services.GetRequiredService <HttpService>();
     _guildConfig    = services.GetRequiredService <GuildConfigService>();
 }
Пример #7
0
        public async Task LimitModuleAsync(string module)
        {
            _service = new GuildConfigService(Context.Guild, _context);

            var result = await _service.AddModuleLimitAsync(Context.Channel, module);

            if (result)
            {
                await ReplyAsync($"{module} has been granted permissions to channel {Context.Channel.Name}");
            }
        }
Пример #8
0
        public async Task RemoveLimitModuleAsync(string module)
        {
            _service = new GuildConfigService(Context.Guild, _context);

            var result = await _service.RemoveModuleLimitAsync(Context.Channel, module);

            if (result)
            {
                await ReplyAsync($"{module}'s limit has been removed from channel {Context.Channel.Name}");
            }
        }
Пример #9
0
 public CommandService(GuildConfigService gcs, LocalizationService lcs, bool loadData = true)
 {
     this.lcs      = lcs;
     this.gcs      = gcs;
     this.commands = new ConcurrentDictionary <string, CommandInfo>();
     this.modules  = new Dictionary <ModuleType, ConcurrentHashSet <string> >().ToImmutableDictionary();
     if (loadData)
     {
         this.LoadData("Translations");
     }
 }
Пример #10
0
        public static async Task GuildMemberJoinEventHandlerAsync(TheGodfatherBot bot, GuildMemberAddEventArgs e)
        {
            if (e.Guild is null)
            {
                return;
            }

            LogExt.Debug(bot.GetId(e.Guild.Id), "Member added: {Member} {Guild}", e.Member, e.Guild);

            GuildConfigService gcs  = bot.Services.GetRequiredService <GuildConfigService>();
            GuildConfig        gcfg = await gcs.GetConfigAsync(e.Guild.Id);

            await Task.Delay(TimeSpan.FromSeconds(gcfg.AntiInstantLeaveSettings.Cooldown + 1));

            if (e.Member.Guild is null)     // User left in meantime
            {
                return;
            }

            // TODO move to service
            DiscordChannel?wchn = e.Guild.GetChannel(gcfg.WelcomeChannelId);

            if (wchn is { })
Пример #11
0
 public ModerationCommands(GuildConfigService guildConfig)
 {
     _guildConfig = guildConfig;
 }
Пример #12
0
        public static DiscordChannel?GetLogChannelForGuild(this GuildConfigService service, DiscordGuild?guild)
        {
            CachedGuildConfig?gcfg = service.GetCachedConfig(guild?.Id ?? 0) ?? new CachedGuildConfig();

            return(guild is { } && gcfg.LoggingEnabled ? guild.GetChannel(gcfg.LogChannelId) : null);