public TrendModule(IServiceProvider services) { _Logger = services.GetService <ILogger <TrendModule> >(); _TrendHelper = services.GetRequiredService <ITrendHelper>(); _FunctionWrapper = services.GetRequiredService <IFunctionWrapper>(); _Config = services.GetService <IConfigurationWrapper>(); }
public TopClipsModule(ITopClipsModuleHelper topClipsModuleHelper, IFunctionWrapper functionWrapper, ILogger <TopClipsModule> log, IConfigurationWrapper configWrapper) { _TopClipsModuleHelper = topClipsModuleHelper; _FunctionWrapper = functionWrapper; _Log = log; _ConfigWrapper = configWrapper; }
public FunctionWithWrapper(IFunctionWrapper wrapper, FunctionEnvironment functionEnvironment, IOptions <MyConfiguration> myConfiguration, IOptions <MyOtherConfiguration> myOtherConfiguration) { _wrapper = wrapper; _functionEnvironment = functionEnvironment; _myConfiguration = myConfiguration.Value; _myOtherConfiguration = myOtherConfiguration.Value; }
public async Task Run() { var config = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json") .AddEnvironmentVariables() .Build(); _ConfigWrapper = new ConfigurationWrapper(config); _ListenToOnlyTheseChannels = _ConfigWrapper.Get <List <ulong> >("ListenToOnlyTheseChannels"); _FunctionWrapper = new FunctionWrapper(_ConfigWrapper); _DiscordClient = new DiscordSocketClient(); var trendHelper = new TrendHelper(_ConfigWrapper); trendHelper.PrefixUpdated += TrendHelper_PrefixUpdated; _Services = new ServiceCollection() .AddSingleton(_DiscordClient) .AddSingleton <ITrendHelper>(trendHelper) .AddSingleton(_FunctionWrapper) .AddSingleton(_ConfigWrapper) .AddLogging(s => s.AddConsole()) .BuildServiceProvider(); _Logger = _Services.GetService <ILogger <Bot> >(); _DiscordClient.Log += Log; await LogInAsync(); await StartAsync(); _Commands = new CommandService(); await _Commands.AddModulesAsync(Assembly.GetEntryAssembly(), _Services); DetermineModuleNames(); _DiscordClient.MessageReceived += MessageReceived; _DiscordClient.JoinedGuild += JoinedGuild; _DiscordClient.LeftGuild += LeftGuild; await _DiscordClient.SetGameAsync(_ConfigWrapper["PlayingGame"]); _PrefixDictionary = await _FunctionWrapper.GetPrefixDictionaryAsync(); }