public async Task BallAdd([Summary("The type of response (+/-/?)")] char ballSymbol, [Remainder][Summary("The actual response")] string msg) { msg = msg + " [" + ballSymbol + "]"; ulong gid = this.Context.Guild.Id; string ballType = "neutrals"; if (_positiveChars.Contains(ballSymbol)) { ballType = "positives"; } else if (_negativeChars.Contains(ballSymbol)) { ballType = "negatives"; } bool success = await FunStorage.Insert8ballFor(gid, ballType, msg); if (success) { await this.Context.Message.AddReactionAsync(new Emoji("👌")); } else { await this.Context.Message.AddReactionAsync(new Emoji("👎")); } }
public async Task BallShow() { bool result = await this.Context.IsOwner(); if (!result) { return; } var ballResults = await FunStorage.Get8BallFor(this.Context.Guild.Id); string msg = ""; foreach (var subcategory in ballResults) { foreach (var lineitem in subcategory) { msg += lineitem + '\n'; Console.WriteLine(lineitem); } } await this.ReplyAsync(msg); }
public async Task BallShake() { SocketUser author = this.Context.Message.Author; // Get the question - arbitrarily, question must have been in the previous 10 messages (parsing for politeness) IEnumerable <IMessage> previousMessages = await this.Context.Channel.GetMessagesAsync(10).Flatten(); List <IMessage> authoredMessages = new List <IMessage>(); foreach (IMessage previousMessage in previousMessages) { if (previousMessage.Author.Id == author.Id) { authoredMessages.Add(previousMessage); } } bool beNice = false; authoredMessages.Remove(authoredMessages.First()); // "please" indicates politeness if (authoredMessages.Count > 0 && authoredMessages.First().Content.ToUpper().Contains("PLEASE")) { beNice = true; } string eightballPath = Path.Combine(EntryPoint.RunningFolder, "8ball"); string rawPosResponses = File.ReadAllText(Path.Combine(eightballPath, "positive.txt")); string rawNegResponses = File.ReadAllText(Path.Combine(eightballPath, "negative.txt")); string rawNeutResponses = File.ReadAllText(Path.Combine(eightballPath, "neutral.txt")); BallGlobalPositiveResponses = rawPosResponses.Split('\n').ToList(); BallGlobalNegativeResponses = rawNegResponses.Split('\n').ToList(); var ballResults = await FunStorage.Get8BallFor(this.Context.Guild.Id); List <string> localPosResponses = ballResults[0]; localPosResponses.AddRange(BallGlobalPositiveResponses); List <string> localNegResponses = ballResults[1]; localNegResponses.AddRange(BallGlobalNegativeResponses); List <List <string> > responses = new List <List <string> > { localPosResponses, localNegResponses, }; // If we aren't being nice in response to politeness, add the neutral responses if (!beNice) { BallGlobalNeutralResponses = rawNeutResponses.Split('\n').ToList(); List <string> localNeutResponses = ballResults[2]; localNeutResponses.AddRange(BallGlobalNeutralResponses); responses.Append(localNeutResponses); responses.Append(localNeutResponses); //This is not a typo. } List <string> randList = // Get a random 8ball list responses[ballRandom.Next(responses.Count)]; // Select a random response string rand = randList[ballRandom.Next(randList.Count)]; string shakingMessage = "*shooka shooka...*"; if (beNice) { shakingMessage += "_❤️..._"; } int editDelay = 1000; if (ballRandom.Next(10) > 8) { shakingMessage += " **KA-KRASH?!**"; editDelay += 1500; } // Setup the initial message var message = await this.Context.Channel.SendMessageAsync(shakingMessage); // Pretend to think await Task.Delay(editDelay); // Replace the initial message (edit) with the 8ball message await message.ModifyAsync(msg => msg.Content = rand); }