public async Task List() { var guild = ((IGuildUser)Context.Message.Author).Guild; var guildObject = JsonConvert.DeserializeObject <DiscordServer>(File.ReadAllText(Constants.ConfigRootDirectory + Constants.GuildDirectory + guild.Id + ".json")); string twitch = ""; string youtube = ""; string beam = ""; string hitbox = ""; string picarto = ""; string vidMe = ""; int count = 0; if (guildObject.PicartoChannels != null && guildObject.PicartoChannels.Count > 0) { foreach (var streamer in guildObject.PicartoChannels) { if (count == 0) { picarto += streamer; } else { picarto += ", " + streamer; } count++; } } count = 0; if (guildObject.ServerTwitchChannelIds != null && guildObject.ServerTwitchChannelIds.Count > 0) { foreach (var streamer in guildObject.ServerTwitchChannelIds) { var twitchChannel = await _twitchManager.GetTwitchChannelById(streamer); var name = twitchChannel == null ? streamer + " (Streamer Not Found)" : twitchChannel.DisplayName; if (count == 0) { twitch += name; } else { twitch += ", " + name; } count++; } } count = 0; if (guildObject.ServerYouTubeChannelIds != null && guildObject.ServerYouTubeChannelIds.Count > 0) { foreach (var streamer in guildObject.ServerYouTubeChannelIds) { var channel = await _youtubeManager.GetYouTubeChannelSnippetById(streamer); if (count == 0) { youtube += (channel.items.Count > 0 ? channel.items[0].snippet.title + " (" + streamer + ")" : streamer); } else { youtube += ", " + (channel.items.Count > 0 ? channel.items[0].snippet.title + " (" + streamer + ")" : streamer); } count++; } } count = 0; if (guildObject.ServerBeamChannels != null && guildObject.ServerBeamChannels.Count > 0) { foreach (var streamer in guildObject.ServerBeamChannels) { if (count == 0) { beam += streamer; } else { beam += ", " + streamer; } count++; } } count = 0; if (guildObject.ServerHitboxChannels != null && guildObject.ServerHitboxChannels.Count > 0) { foreach (var streamer in guildObject.ServerHitboxChannels) { if (count == 0) { hitbox += streamer; } else { hitbox += ", " + streamer; } count++; } } if (guildObject.ServerVidMeChannels != null && guildObject.ServerVidMeChannels.Count > 0) { foreach (var streamer in guildObject.ServerVidMeChannels) { if (count == 0) { vidMe += streamer; } else { vidMe += ", " + streamer; } count++; } } count = 0; var ownerYouTube = "Not Set"; if (!string.IsNullOrEmpty(guildObject.OwnerYouTubeChannelId)) { var channel = await _youtubeManager.GetYouTubeChannelSnippetById(guildObject.OwnerYouTubeChannelId); if (channel != null && channel.items.Count > 0) { ownerYouTube = channel.items[0].snippet.title + " (" + guildObject.OwnerYouTubeChannelId + ")"; } } var ownerVidMe = "Not Set"; if (!string.IsNullOrEmpty(guildObject.OwnerVidMeChannel)) { ownerVidMe = guildObject.OwnerVidMeChannel; } string info = "```Markdown\r\n" + "# Server Configured Channels\r\n" + "- Mixer: " + beam + "\r\n" + "- Picarto: " + picarto + "\r\n" + "- Smashcast: " + hitbox + "\r\n" + "- Twitch: " + twitch + "\r\n" + "- VidMe: " + vidMe + "\r\n" + "- YouTube: " + youtube + "\r\n" + "- Owner Mixer: " + (string.IsNullOrEmpty(guildObject.OwnerBeamChannel) ? "Not Set" : guildObject.OwnerBeamChannel) + "\r\n" + "- Owner Picarto: " + (string.IsNullOrEmpty(guildObject.OwnerPicartoChannel) ? "Not Set" : guildObject.OwnerPicartoChannel) + "\r\n" + "- Owner Smashcast: " + (string.IsNullOrEmpty(guildObject.OwnerHitboxChannel) ? "Not Set" : guildObject.OwnerHitboxChannel) + "\r\n" + "- Owner Twitch: " + (string.IsNullOrEmpty(guildObject.OwnerTwitchChannel) ? "Not Set" : guildObject.OwnerTwitchChannel) + "\r\n" + "- Owner VidMe: " + ownerVidMe + "\r\n" + "- Owner YouTube: " + ownerYouTube + "\r\n" + "```\r\n"; await Context.Channel.SendMessageAsync(StringUtilities.ScrubChatMessage(info)); }
public async Task List() { var guild = ((IGuildUser)Context.Message.Author).Guild; var guildObject = JsonConvert.DeserializeObject <DiscordServer>(File.ReadAllText(_botSettings.DirectorySettings.ConfigRootDirectory + _botSettings.DirectorySettings.GuildDirectory + guild.Id + ".json")); List <string> twitch = new List <string>(); List <string> youtube = new List <string>(); List <string> beam = new List <string>(); List <string> hitbox = new List <string>(); List <string> picarto = new List <string>(); List <string> vidMe = new List <string>(); List <string> mobCrush = new List <string>(); if (guildObject.PicartoChannels != null && guildObject.PicartoChannels.Count > 0) { foreach (var streamer in guildObject.PicartoChannels) { picarto.Add(streamer); } } if (guildObject.ServerTwitchChannelIds != null && guildObject.ServerTwitchChannelIds.Count > 0) { foreach (var streamer in guildObject.ServerTwitchChannelIds) { var twitchChannel = await _twitchManager.GetTwitchChannelById(streamer); if (twitchChannel != null) { var name = twitchChannel == null ? streamer + " (Streamer Not Found)" : twitchChannel.DisplayName; twitch.Add(name); } } } if (guildObject.ServerYouTubeChannelIds != null && guildObject.ServerYouTubeChannelIds.Count > 0) { foreach (var streamer in guildObject.ServerYouTubeChannelIds) { var channel = await _youtubeManager.GetYouTubeChannelSnippetById(streamer); youtube.Add((channel.items.Count > 0 ? channel.items[0].snippet.title + " (" + streamer + ")" : streamer)); } } if (guildObject.ServerBeamChannels != null && guildObject.ServerBeamChannels.Count > 0) { foreach (var streamer in guildObject.ServerBeamChannels) { beam.Add(streamer); } } if (guildObject.ServerHitboxChannels != null && guildObject.ServerHitboxChannels.Count > 0) { foreach (var streamer in guildObject.ServerHitboxChannels) { hitbox.Add(streamer); } } if (guildObject.ServerVidMeChannels != null && guildObject.ServerVidMeChannels.Count > 0) { foreach (var streamer in guildObject.ServerVidMeChannels) { vidMe.Add(streamer); } } if (guildObject.ServerMobcrushIds != null && guildObject.ServerMobcrushIds.Count > 0) { foreach (var streamer in guildObject.ServerMobcrushIds) { var channel = await _mobCrushManager.GetMobcrushChannelById(streamer); if (channel != null) { mobCrush.Add(channel.name); } } } var ownerYouTube = "Not Set"; if (!string.IsNullOrEmpty(guildObject.OwnerYouTubeChannelId)) { var channel = await _youtubeManager.GetYouTubeChannelSnippetById(guildObject.OwnerYouTubeChannelId); if (channel != null && channel.items.Count > 0) { ownerYouTube = channel.items[0].snippet.title + " (" + guildObject.OwnerYouTubeChannelId + ")"; } } var ownerVidMe = "Not Set"; if (!string.IsNullOrEmpty(guildObject.OwnerVidMeChannel)) { ownerVidMe = guildObject.OwnerVidMeChannel; } var ownerMobcrush = "Not Set"; if (!string.IsNullOrEmpty(guildObject.OwnerMobcrushId)) { var channel = await _mobCrushManager.GetMobcrushChannelById(guildObject.OwnerMobcrushId); if (channel != null) { ownerMobcrush = channel.name; } } var beamString = string.Join(", ", beam); var picartoString = string.Join(", ", picarto); var hitboxString = string.Join(", ", hitbox); var twitchString = string.Join(", ", twitch); var vidMeString = string.Join(", ", vidMe); var youtubeString = string.Join(", ", youtube); var mobcrushString = string.Join(", ", mobCrush); var ownerBeam = (string.IsNullOrEmpty(guildObject.OwnerBeamChannel) ? "Not Set" : guildObject.OwnerBeamChannel); var ownerPicartor = (string.IsNullOrEmpty(guildObject.OwnerPicartoChannel) ? "Not Set" : guildObject.OwnerPicartoChannel); var ownerSmashcast = (string.IsNullOrEmpty(guildObject.OwnerHitboxChannel) ? "Not Set" : guildObject.OwnerHitboxChannel); var ownerTwitch = (string.IsNullOrEmpty(guildObject.OwnerTwitchChannel) ? "Not Set" : guildObject.OwnerTwitchChannel); string info = string.Format("```Markdown\r\n" + "# Server Configured Channels\r\n" + "- Mixer: {0}\r\n" + "- Mobcrush: {12}\r\n" + "- Picarto: {1}\r\n" + "- Smashcast: {2}\r\n" + "- Twitch: {3}\r\n" + "- VidMe: {4}\r\n" + "- YouTube: {5}\r\n" + "- Owner Mixer: {6}\r\n" + "- Owner Mobcrush: {13}\r\n" + "- Owner Picarto: {7}\r\n" + "- Owner Smashcast: {8}\r\n" + "- Owner Twitch: {9}\r\n" + "- Owner VidMe: {10}\r\n" + "- Owner YouTube: {11}\r\n" + "```\r\n", beamString, picartoString, hitboxString, twitchString, vidMeString, youtubeString, ownerBeam, ownerPicartor, ownerSmashcast, ownerTwitch, ownerVidMe, ownerYouTube, mobcrushString, ownerMobcrush); if (info.Length > 2000) { await Context.Channel.SendMessageAsync(StringUtilities.ScrubChatMessage(info.Substring(0, 1900) + "\r\n```")); await Context.Channel.SendMessageAsync(StringUtilities.ScrubChatMessage("```Markdown\r\n" + info.Substring(1901))); } else { await Context.Channel.SendMessageAsync(StringUtilities.ScrubChatMessage(info)); } }