示例#1
0
        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);
            }
        }
示例#2
0
        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}");
        }
示例#3
0
 public Search(RapiInfo rpi)
 {
     _rapi = rpi;
 }
示例#4
0
 public DebugCommands(RapiInfo rapi, CommandHandlingService handlerService)
 {
     allServices = new Dictionary <string, object>();
     allServices.Add("rapi", rapi);
     allServices.Add("commandHandler", handlerService);
 }
示例#5
0
 public General(CommandHandlingService handlingService, RapiInfo rapi)
 {
     _handler = handlingService;
     _rapi    = rapi;
 }