void DiscordMessage(string nick, string message) { if (message.CaselessEq(".who") || message.CaselessEq(".players") || message.CaselessEq("!players")) { Constants.Embed embed = new Constants.Embed(); embed.color = config.EmbedColor; embed.title = Server.Config.Name; Dictionary <string, List <string> > ranks = new Dictionary <string, List <string> >(); int totalPlayers = 0; List <Who.GroupPlayers> allPlayers = new List <Who.GroupPlayers>(); if (totalPlayers == 1) { embed.description = "**There is 1 player online**\n\n"; } else { embed.description = "**There are " + PlayerInfo.Online.Count + " players online**\n\n"; } if (config.zsmode && Games.ZSGame.Instance.Running) { foreach (Group grp in Group.GroupList) { allPlayers.Add(Who.Make(grp, false, ref totalPlayers)); } for (int i = allPlayers.Count - 1; i >= 0; i--) { embed.description += Who.Output(allPlayers[i]); } embed.description += "\n" + "Map: `" + Games.ZSGame.Instance.Map.name + "`"; } else { foreach (Group grp in Group.GroupList) { allPlayers.Add(Who.Make(grp, true, ref totalPlayers)); } for (int i = allPlayers.Count - 1; i >= 0; i--) { embed.description += Who.Output(allPlayers[i]); } } SendMessage(embed); return; } message = config.IngameMessage.Replace("{name}", nick).Replace("{msg}", message); Chat.Message(ChatScope.Global, message, null, (Player pl, object arg) => !pl.Ignores.IRC); }
public static void SendMessage(Constants.Embed message) { // Queue a message so the message doesn't have to wait until discord receives it to display in chat Server.Background.QueueOnce(SendMessage, message, TimeSpan.Zero); }