public static async Task ChannelCreated(ChannelCreateEventArgs e, DiscordClient client) { try { var log = await client.Guilds.FirstOrDefault().Value.GetAuditLogsAsync(1, null, AuditLogActionType.ChannelCreate); if (!log.FirstOrDefault().UserResponsible.IsBot) { await client.SendMessageAsync(e.Guild.Channels.Where(x => x.Name == "general").FirstOrDefault(), "Nocsak! Új " + "kommunikációs csatorna " + e.Channel.Name + " néven!"); } } catch (Exception ex) { logger.Error(ex.Message); } }
public async Task GetLeagueStanding(CommandContext ctx, string league = "") { logger.Debug(ctx.User.Username + "called Standing!"); var service = ServiceContainer.Container.Resolve <IFootballDataService>(); if (String.IsNullOrEmpty(league)) { await ctx.RespondAsync("Paraméterként add meg a liga nevét bogárka!", false, null); await ctx.RespondAsync("Elérhető bajnokságok: " + service.GetLeagueNames()); return; } var leagueList = service.GetLeagueNames().Split(' ').ToList(); league = leagueList.Find(x => x.ToLower() == league.ToLower()); var validLeagueName = service.ValidateLeagueName(league); if (!validLeagueName) { await ctx.RespondAsync("Ejha! A liga neve hibádzik!"); return; } try { var result = await service.GetLeagueStanding(league, Program.config.footballDataEndpoint, Program.config.footballDataKey); await ctx.RespondAsync(result); } catch (Exception e) { logger.Error(e.Message); await ctx.RespondAsync("Hiba történt az adatok lekérésében!"); } }