Example #1
0
        public ReplyContext(IMessageChannel channel, IUser user, IDependencyFactory factory, ILogger logger)
        {
            Channel = channel;
            User    = user;
            Client  = factory.Get <DiscordSocketClient>();
            Logger  = logger;

            var settings = factory.Get <ISettingManager>();

            GeneralUserSetting = settings.GetContext(User).Get <GeneralUserSetting>();
            var guildSetting = settings.GetContext(Guild)?.Get <GeneralGuildSetting>();
            var formatter    = factory.WithInstance(GeneralUserSetting).Construct <ValueFormatter>();
            var textManager  = factory.Get <ITextResourceManager>();

            TextResource = textManager.GetForLanguage(guildSetting?.PreferredLanguage ?? GeneralUserSetting.Language, GeneralUserSetting.FormatType);

            OnSend += (s, m) => Task.CompletedTask;
        }
Example #2
0
        public ModifyContext(IUserMessage message, IUser user, IDependencyFactory factory, ILogger logger)
        {
            Message   = message;
            Text      = (RawString)message.Content;
            Embedable = Commands.Embedable.FromEmbed(message.Embeds.FirstOrDefault(e => e.Type == EmbedType.Rich) as Embed);
            Logger    = logger;

            User   = user;
            Client = factory.Get <DiscordSocketClient>();

            var settings = factory.Get <ISettingManager>();

            GeneralUserSetting = settings.GetContext(User).Get <GeneralUserSetting>();
            var guildSetting = settings.GetContext(Guild)?.Get <GeneralGuildSetting>();
            var formatter    = factory.GetOrStore <ValueFormatter>();
            var textManager  = factory.Get <ITextResourceManager>();

            TextResource = textManager.GetForLanguage(guildSetting?.PreferredLanguage ?? GeneralUserSetting.Language, GeneralUserSetting.FormatType);

            OnModify += (s, m) => Task.CompletedTask;
        }
Example #3
0
        internal void Install(ICommandContext context, IDependencyFactory factory)
        {
            Context = context;

            Logger          = factory.Get <ILogger>();
            Database        = factory.Get <IDatabase>();
            Bot             = factory.Get <BotClient>();
            CommandService  = factory.Get <ICommandService>();
            Scheduler       = factory.Get <IScheduler>();
            SettingsManager = factory.Get <ISettingManager>();
            Downloader      = factory.Get <IDownloader>();

            StartReplyTimer();
        }
Example #4
0
        internal CommandContext(IUserMessage message, IDependencyFactory factory)
        {
            Client  = factory.Get <DiscordSocketClient>();
            Message = message;
            Channel = message.Channel;
            Author  = message.Author;
            Guild   = (message.Channel as IGuildChannel)?.Guild;

            var settingManager = factory.GetOrStore <ISettingManager>();

            _globalSettings  = new Lazy <ISettingContext>(() => settingManager.GetContext(settingManager.Global));
            _channelSettings = new Lazy <ISettingContext>(() => settingManager.GetContext(Channel));
            _guildSettings   = new Lazy <ISettingContext>(() => Guild == null ? null : settingManager.GetContext(Guild));
            _userSettings    = new Lazy <ISettingContext>(() => settingManager.GetContext(Author));
            _textManager     = new Lazy <ITextResourceManager>(() => factory.GetOrStore <ITextResourceManager>());
            _formatter       = new Lazy <ValueFormatter>(() => factory.GetOrStore <ValueFormatter>());
            _textResource    = new Lazy <ITextResourceCollection>(() => TextManager.GetForLanguage(GeneralGuildSetting?.PreferredLanguage ?? GeneralUserSetting.Language, GeneralUserSetting.FormatType));
            _replier         = new Lazy <IReplier>(() => factory.GetOrStore <IReplier>());
        }