private MessageBuilder threePartMessage(string EmbedTitle, string FieldTitle, string FieldValue, uint Color) { EmbedBuilder.Reset(); FieldBuilder.Reset(); MessageBuilder.Reset(); MessageBuilder.Username = AdminLogs.Instance.Config.Username; MessageBuilder.AvatarUrl = "https://discordapp.com/assets/1cbd08c76f8af6dddce02c5138971129.png"; FieldBuilder.Inline = true; FieldBuilder.Name = FieldTitle; FieldBuilder.Value = FieldValue; EmbedBuilder.AddField(FieldBuilder.Build()); EmbedBuilder.Color = Color; EmbedBuilder.Title = EmbedTitle; MessageBuilder.AddEmbed(EmbedBuilder.Build()); return(MessageBuilder); }
private async void CsServerMatchEndAsync(object sender, MatchEndEventArgs e) { var eb = new EmbedBuilder { Title = $"Match complete {e.MapName} {e.CTName}({e.CTScore}) {e.TName}({e.TScore})", ThumbnailUrl = "https://cdn.discordapp.com/attachments/546946476836782090/546955027210829825/no_backround.png", Color = Color.Teal }; var fieldBuilder = new EmbedFieldBuilder { Name = $"Match Info https://play.esea.net/match/{e.MatchId}", Value = "field" }; eb.AddField("Stats available: ", fieldBuilder.Build()); eb.WithFooter($"Use command \"{Config.Prefix}{CommandConstants.Help}\" to list all available commands"); await(await GetChannelAsync(e.Guild, ChannelNames.MatchCard) as ISocketMessageChannel).SendMessageAsync(string.Empty, false, eb.Build()); }
private Dictionary <string, Action <CommandRequest> > GenerateCommands() { return(new Dictionary <string, Action <CommandRequest> >() { { CommandConstants.AddServer, async(commandRequest) => { if (commandRequest.NeedHelp) { var eb = new EmbedBuilder { Title = $"{CommandConstants.AddServer}", ThumbnailUrl = "https://cdn.discordapp.com/attachments/546946476836782090/546955027210829825/no_backround.png", Color = Color.Teal }; var fieldBuilder = new EmbedFieldBuilder { Name = "Adds a server to the tracking list", Value = "field" }; eb.AddField("Usage", fieldBuilder.Build()); eb.WithFooter($"Use command \"{Config.Prefix}{CommandConstants.Help}\" to list all available commands"); eb.Description = $"{Config.Prefix}{CommandConstants.AddServer} 123.456.789.10:12345 rconPassword"; await commandRequest.Message.Channel.SendMessageAsync(string.Empty, false, eb.Build()); } else { await GetChannelAsync(commandRequest.Guild, ChannelNames.Admin); await commandRequest.Message.DeleteAsync(); if (commandRequest.Message.Channel.Name != ChannelNames.Admin) { var adminChannel = await GetChannelAsync(commandRequest.Guild, ChannelNames.Admin) as IChannel; await commandRequest.Message.Channel.SendMessageAsync($"That command must be used in {MentionUtils.MentionChannel(adminChannel.Id)}"); } else { var guild = GuildManagers.FirstOrDefault(x => x.Guild.Id == commandRequest.Guild.Id); var server = guild.Servers.FirstOrDefault(x => x.IpAddress == commandRequest.Arguments[1]); if (server != null) { await commandRequest.Message.Channel.SendMessageAsync($"That server (ID: {server.ID}) is already being followed. Use {Config.Prefix}{CommandConstants.ServerList} to find it"); } else { bool error = false; var ipPort = commandRequest.Arguments[1].Split(':'); if (ipPort.Length != 2) { error = true; } if (commandRequest.Arguments.Length != 3) { error = true; } if (!error) { var ip = ipPort[0]; var port = Convert.ToUInt16(ipPort[1]); server = new CsServer(ip, port, commandRequest.Arguments[2], Config, guild, guild.ServerId); await server.InitializeRconAsync(); if (server.Authed) { var eb = new EmbedBuilder { Title = $"Server Added ✅", ThumbnailUrl = "https://cdn.discordapp.com/attachments/546946476836782090/546955027210829825/no_backround.png", Color = Color.Teal }; var idField = new EmbedFieldBuilder { Name = $"{server.ID}", Value = "field" }; var ipField = new EmbedFieldBuilder { Name = $"{ip}:{port}", Value = "field" }; eb.AddField("ID", idField.Build()); eb.AddField("IP Address", ipField.Build()); eb.WithFooter($"Use command \"{Config.Prefix}{CommandConstants.Help}\" to list all available commands"); await commandRequest.Message.Channel.SendMessageAsync(string.Empty, false, eb.Build()); server.ChatMessageEventArgs += CsServerChatMessageAsync; server.MatchStartEventArgs += CsServerMatchLiveAsync; server.TacMessageEventArgs += CsServerTacPauseAsync; server.TechMessageEventArgs += CsServerTechPauseAsync; server.MatchSwapSidesEventArgs += CsServerSwapSidesAsync; server.UnpauseMessageEventArgs += CsServerUnpauseAsync; server.ScoreUpdateEventsArgs += CsServerScoreUpdateAsycAsync; server.OnGenericUpdateEventArgs += CsServerGenericBroadcastUpdateAsync; server.MatchEndEventArgs += CsServerMatchEndAsync; guild.Servers.Add(server); guild.ServerId++; } else { var eb = new EmbedBuilder { Title = $"❌ FAILED TO AUTHENTICATE ❌", ThumbnailUrl = "https://cdn.discordapp.com/attachments/546946476836782090/546955027210829825/no_backround.png", Color = Color.Teal }; var reasonField = new EmbedFieldBuilder { Name = $"Failed to authenticate, make sure rcon password is correct", Value = "field" }; eb.AddField("Reason", reasonField.Build()); eb.WithFooter($"Use command \"{Config.Prefix}{CommandConstants.Help}\" to list all available commands"); await commandRequest.Message.Channel.SendMessageAsync(string.Empty, false, eb.Build()); } } else { await commandRequest.Message.Channel.SendMessageAsync($"Command syntax is incorrect. Use {Config.Prefix}{CommandConstants.AddServer} 123.45.678:12345 rconPassword"); } } } } } }, { CommandConstants.ServerList, async(commandRequest) => { if (commandRequest.NeedHelp) { var eb = new EmbedBuilder { Title = $"{CommandConstants.AddServer}", ThumbnailUrl = "https://cdn.discordapp.com/attachments/546946476836782090/546955027210829825/no_backround.png", Color = Color.Teal }; var fieldBuilder = new EmbedFieldBuilder { Name = "Lists all servers being tracked on this discord server", Value = "field" }; eb.AddField("Usage", fieldBuilder.Build()); eb.WithFooter($"Use command \"{Config.Prefix}{CommandConstants.Help}\" to list all available commands"); eb.Description = $"{Config.Prefix}{CommandConstants.ServerList}"; await commandRequest.Message.Channel.SendMessageAsync(string.Empty, false, eb.Build()); } else { await ValidateBotCategoryAsync(commandRequest); await ValidateAdminChannel(commandRequest); if (commandRequest.Message.Channel.Name != ChannelNames.Admin) { var adminChannel = await GetChannelAsync(commandRequest.Guild, ChannelNames.Admin) as IChannel; await commandRequest.Message.Channel.SendMessageAsync($"That command must be used in {MentionUtils.MentionChannel(adminChannel.Id)}"); } else { var serverList = string.Empty; var guild = GuildManagers.FirstOrDefault(x => x.Guild.Id == commandRequest.Guild.Id); foreach (var server in guild.Servers) { serverList = $"{serverList} [{server.ID}] {server.IpAddress}\n"; } serverList = $"```\n{serverList}\n```"; await commandRequest.Message.Channel.SendMessageAsync(serverList); } } } }, { CommandConstants.Help, async(commandRequest) => { var commandList = string.Empty; foreach (var key in Commands.Keys.Where(x => x != CommandConstants.Help)) { commandList = $"{commandList} {key}\n"; } commandList = $"```\n{commandList}\n {Config.Prefix}CommandName Help for more information```"; await commandRequest.Message.Channel.SendMessageAsync(commandList); } } }); }