public async Task EndGameInChannel(IGuild guild, IMessageChannel ChannelID) { QuoteGame game = StopQG(ChannelID.Id); if (game != null) { if (game.Guesses.Select(x => x.QuoteGuess == game.Answer).FirstOrDefault()) { var winnerID = game.Guesses.OrderBy(x => x.Timestamp).First(x => x.QuoteGuess == game.Answer); IGuildUser user = await guild.GetUserAsync(winnerID.UserID); await ChannelID.BlankEmbedAsync(new EmbedBuilder().WithOkColour() .AddField(new EmbedFieldBuilder().WithName("📣 Keyword").WithValue(game.Answer)) .AddField(new EmbedFieldBuilder().WithName("🎉 Winner").WithValue(user.Username)).Build()); } else { await ChannelID.BlankEmbedAsync(new EmbedBuilder().WithErrorColour() .AddField(new EmbedFieldBuilder().WithName("📣 Keyword").WithValue(game.Answer)) .AddField(new EmbedFieldBuilder().WithName("🎉 Winner").WithValue("Nobody. That's sad.")).Build()); } } }
public async Task EndGameInChannel(IGuild guild, IMessageChannel ChannelID, FloraRandom _random) { RNGGame game = StopRNGG(ChannelID.Id); if (game != null) { int roll = _random.Next(game.MinGuess, game.MaxGuess + 1); if (game.Guesses.Select(x => x.GuessIndex == roll).FirstOrDefault()) { var winnerID = game.Guesses.First(x => x.GuessIndex == roll); IGuildUser user = await guild.GetUserAsync(winnerID.UserID); await ChannelID.BlankEmbedAsync(new EmbedBuilder().WithOkColour() .AddField(new EmbedFieldBuilder().WithName("🎲 Roll").WithValue(roll)) .AddField(new EmbedFieldBuilder().WithName("🎉 Winner").WithValue(user.Username)).Build()); } else { await ChannelID.BlankEmbedAsync(new EmbedBuilder().WithErrorColour() .AddField(new EmbedFieldBuilder().WithName("🎲 Roll").WithValue(roll)) .AddField(new EmbedFieldBuilder().WithName("🎉 Winner").WithValue("Nobody. That's sad.")).Build()); } } }
private async Task HandleResults(string url, IMessageChannel channel) { IIqdbClient api = new IqdbClient(); IqdbApi.Models.SearchResult res; try { res = await api.SearchUrl(url); } //Too lazy to implement separate exceptions this'll do catch (Exception) { await channel.SendErrorAsync("IQDB serarch error'd. Try a different image?"); return; } //Lets get the results maybe? if (res.Matches.Where(x => x.MatchType == IqdbApi.Enums.MatchType.Best).Count() == 0) { await channel.SendErrorAsync("No source found for that image, sadly."); return; } //SWEET MOTHER OF GOD WE GOT SOMETHING EmbedBuilder e = new EmbedBuilder().WithOkColour().WithTitle("Potential Match Found").WithDescription("This is the \"best\" match according to IQDB."); EmbedFieldBuilder efb = new EmbedFieldBuilder().WithName("URL"); //We only need the best Match bestmatch = res.Matches.Where(x => x.MatchType == IqdbApi.Enums.MatchType.Best).First(); //There's gotta be a better way to do this but I'm okay with this as is string urlFix = bestmatch.Url; if (!urlFix.StartsWith("http:") && urlFix.StartsWith("//")) { urlFix = "http:" + urlFix; } //combine shit efb.WithValue(urlFix); e.AddField(efb); //Finally await channel.BlankEmbedAsync(e.Build()); }
public async Task EndGameInChannel(IGuild guild, IMessageChannel ChannelID) { PushButtonGame game = StopPBG(ChannelID.Id); if (game != null) { //Pushed int total = game.Responses.Count; int pushed = game.Responses.Where(x => x.Pushed == true).Count(); int notpushed = total - pushed; EmbedBuilder embed = new EmbedBuilder().WithOkColour() .WithTitle("Push the Button Game Results.") .WithDescription($"Would you push the button if...") .AddField(new EmbedFieldBuilder().WithName($"Pro").WithValue($"{game.Benefit}").WithIsInline(true)) .AddField(new EmbedFieldBuilder().WithName("...").WithValue("*but*").WithIsInline(true)) .AddField(new EmbedFieldBuilder().WithName($"Con?").WithValue($"{game.Consequence}?").WithIsInline(true)) .AddField(new EmbedFieldBuilder().WithName("✅ Yes").WithValue(pushed).WithIsInline(true)) .AddField(new EmbedFieldBuilder().WithName("❌ No").WithValue(notpushed).WithIsInline(true)); await ChannelID.BlankEmbedAsync(embed.Build()); } }
private async Task QuotePost(IMessage post, IMessageChannel channel) { var embed = new EmbedBuilder().WithQuoteColour().WithAuthor(x => x.WithIconUrl(post.Author.GetAvatarUrl()).WithName(post.Author.Username)).WithDescription(post.Content).WithFooter(x => x.WithText(post.Timestamp.ToString())); await channel.BlankEmbedAsync(embed.Build()); }