public EmbedBuilder DetermineTypeOfMessage(string matchName) { MTGCardOutput MessageOutput = new MTGCardOutput(); var cardData = GetScryFallData.PullScryfallData(matchName); if (cardData == null) { var formattedName = FormatUserInput.FormatEntry(matchName).ToLower(); var autoComplete = GetScryFallData.PullScryFallAutoComplete(formattedName); if (autoComplete.data.Count == 0) { return(MessageOutput.DetermineFailure(0)); } else { return(MessageOutput.DetermineFailure(0, autoComplete, formattedName)); } } if (matchName.Contains('?')) { return(MessageOutput.RulingOutput(GetScryFallData.PullScryFallRuleData(cardData.Id), cardData)); } else { return(MessageOutput.CardOutput(cardData)); } }
private async Task Client_MessageRecieved(SocketMessage messageParam) { if (!(messageParam is SocketUserMessage message)) { return; } var context = new SocketCommandContext(Client, message); var getCard = new MTGCardOutput(); if (context.Message == null || context.Message.Content == "") { return; } if (context.User.IsBot) { return; } if (context.User.Id == 129804455964049408 && context.Guild.Id == 596104949503361050) { await ReactWithEmoteAsync(context.Message, "<:WeebsOut:627783662708064256>"); } if (message != null && (message.Content.Contains("[") && message.Content.Contains("]"))) { try { Regex rx = new Regex(@"\[\[(.*?)\]\]", RegexOptions.Compiled | RegexOptions.IgnoreCase); MatchCollection matches = rx.Matches(message.Content); foreach (var item in matches) { var dataOutput = new UserMessageController(item.ToString()); await context.Channel.SendMessageAsync("", false, dataOutput.MessageOutput.Build()); } } catch (Exception msg) { Console.WriteLine(ConsoleWriteOverride.AddTimeStamp(msg.Message)); await context.Channel.SendMessageAsync("", false, getCard.DetermineFailure(3).Build()); } } var argPos = 0; if (!(message.HasStringPrefix("mtg!", ref argPos) || message.HasMentionPrefix(Client.CurrentUser, ref argPos))) { return; } var result = await Commands.ExecuteAsync(context, argPos, null); if (!result.IsSuccess) { Console.WriteLine(ConsoleWriteOverride.AddTimeStamp($"Something went wrong with executing command. Text: {context.Message.Content} | Error: {result.ErrorReason}")); } }