public async Task MainAsync() { using (StreamReader tfile = File.OpenText("config.json")){ dynamic config = JsonConvert.DeserializeObject(tfile.ReadToEnd()); char tempPrefix = config.prefix ?? '`'; int tempLevel = config.logLevel ?? 3; CLIENT_ID = config.clientId ?? "NONE"; CLIENT_SECRET = config.clientSecret ?? "NONE"; RKEY = config.riotKey ?? throw (new ArgumentNullException("No Riot API Key (riotKey in config file) given!")); BOT_TOKEN = config.botToken ?? throw (new ArgumentNullException("No Discord Bot token (botKey in config file) given!")); CommandHandlingService.setLog(tempLevel); CommandHandlingService.setPrefix(tempPrefix); } await CommandHandlingService.Logger(new LogMessage(LogSeverity.Info, "Config", $"Prefix set to:'{CommandHandlingService.Prefix}'")); using (var services = ConfigServices()){ main_client = services.GetRequiredService <DiscordSocketClient>(); services.GetRequiredService <CommandService>().Log += Logger; rapi = services.GetRequiredService <RapiInfo>(); main_client.Log += Logger; await main_client.LoginAsync(TokenType.Bot, BOT_TOKEN); await main_client.StartAsync(); await services.GetRequiredService <Services.CommandHandlingService>().InitializeAsync(); await Task.Delay(-1); } }
public async Task upLeague() { RapiInfo rapi = allServices["rapi"] as RapiInfo; await Context.Channel.SendMessageAsync($"Current patch: {rapi.patchNum}"); await rapi.updateLeaguePatch(); await ReplyAsync($"New patch: {rapi.patchNum}"); }
public Search(RapiInfo rpi) { _rapi = rpi; }
public DebugCommands(RapiInfo rapi, CommandHandlingService handlerService) { allServices = new Dictionary <string, object>(); allServices.Add("rapi", rapi); allServices.Add("commandHandler", handlerService); }
public General(CommandHandlingService handlingService, RapiInfo rapi) { _handler = handlingService; _rapi = rapi; }