diff --git a/StarsiegeBot/BotSettings.cs b/StarsiegeBot/BotSettings.cs index 9dc86ea..6800701 100644 --- a/StarsiegeBot/BotSettings.cs +++ b/StarsiegeBot/BotSettings.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.IO; using System.Text; using System.Text.RegularExpressions; +using System.Threading; using System.Threading.Tasks; namespace StarsiegeBot @@ -18,6 +19,7 @@ namespace StarsiegeBot { public static Dictionary GuildSettings; private readonly string fileName = "guildSettings.json"; + private CancellationToken cancelToken; public BotSettings() { Console.WriteLine("Bot Setting Commands Loaded"); @@ -68,6 +70,7 @@ namespace StarsiegeBot json = sr.ReadToEnd(); GuildSettings = JsonConvert.DeserializeObject>(json); } + _ = StartTimer(cancelToken); } [GroupCommand] [Description("Work in progress. Does nothing yet.")] @@ -75,6 +78,26 @@ namespace StarsiegeBot { await ctx.TriggerTypingAsync(); } + + + private async Task StartTimer(CancellationToken cancellationToken) + { + await Task.Run(async () => + { + while (true) + { + string output = JsonConvert.SerializeObject(BotSettings.GuildSettings); + await File.WriteAllTextAsync("guildsettings.json", output); + await Task.Delay(TimeSpan.FromSeconds(120), cancellationToken); + if (cancellationToken.IsCancellationRequested) + { + Console.WriteLine("Token Cancelled."); + break; + } + } + }); + } + } public class GuildSettings diff --git a/StarsiegeBot/ExperiemntalCommands.cs b/StarsiegeBot/ExperiemntalCommands.cs index 957496d..fca794e 100644 --- a/StarsiegeBot/ExperiemntalCommands.cs +++ b/StarsiegeBot/ExperiemntalCommands.cs @@ -19,109 +19,17 @@ namespace StarsiegeBot [Description("Experimental commands. May break the bot.")] class ExperiemntalCommands : BaseCommandModule { - private readonly List QuizQuestions; - private readonly Random rnd = new Random(); - public ExperiemntalCommands() + [Command("exit"), RequireOwner] + public async Task ExitProgram (CommandContext ctx) { - // Load all the Quick Chat texts and sound wav file info. - var json = ""; - using (var fs = File.OpenRead("questions.json")) - using (var sr = new StreamReader(fs, new UTF8Encoding(false))) - json = sr.ReadToEnd(); - Dictionary tempQC = JsonConvert.DeserializeObject>(json); - QuizQuestions = Enumerable.ToList(tempQC.Values); - - } - [Command("quiz")] - [Hidden] - [Description("")] - public async Task Quiz(CommandContext ctx) - { - await ctx.TriggerTypingAsync(); - DiscordEmbedBuilder embed = new DiscordEmbedBuilder(); - - int[] ids = { rnd.Next(QuizQuestions.Count), rnd.Next(QuizQuestions.Count), rnd.Next(QuizQuestions.Count), rnd.Next(QuizQuestions.Count) }; - int selection = rnd.Next(ids.Length); - int mainId = ids[selection]; - string[] options = { "a", "b", "c", "d" }; - - var correctAnswer = DiscordEmoji.FromName(ctx.Client, $":regional_indicator_{options[selection]}:"); - - Questions myQuestion = QuizQuestions[mainId]; - - embed.Description = myQuestion.Question; - - embed.AddField($":regional_indicator_{options[0]}:", QuizQuestions[ids[0]].Answers[rnd.Next(QuizQuestions[ids[0]].Answers.Length)], true); - embed.AddField($":regional_indicator_{options[1]}:", QuizQuestions[ids[1]].Answers[rnd.Next(QuizQuestions[ids[1]].Answers.Length)], true); - embed.AddField("_ _", "_ _", false); - embed.AddField($":regional_indicator_{options[2]}:", QuizQuestions[ids[2]].Answers[rnd.Next(QuizQuestions[ids[2]].Answers.Length)], true); - embed.AddField($":regional_indicator_{options[3]}:", QuizQuestions[ids[3]].Answers[rnd.Next(QuizQuestions[ids[3]].Answers.Length)], true); - - var message = await ctx.RespondAsync(embed); - foreach (var item in options) - { - var itemEmote = DiscordEmoji.FromName(ctx.Client, $":regional_indicator_{item}:"); - await message.CreateReactionAsync(itemEmote); - } - var result = message.WaitForReactionAsync(ctx.Message.Author, TimeSpan.FromSeconds(5d)); - if (!result.Result.TimedOut) - { - if (result.Result.Result.Emoji == correctAnswer) await ctx.RespondAsync("**CORRECT!!**"); - else await ctx.RespondAsync($"Sorry, the right answer was {correctAnswer}"); - } - else await ctx.RespondAsync("Sorry, time ran out!"); + await ctx.RespondAsync("Attempting a shutdown..."); + System.Environment.Exit(0); } - [Command("test")] - [Hidden] - public async Task CollectionCommand(CommandContext ctx) + [Command("Report")] + public async Task Report (CommandContext ctx) { - var message = await ctx.RespondAsync("React here!"); - var reactions = await message.CollectReactionsAsync(); - - var strBuilder = new StringBuilder(); - Dictionary winners = new Dictionary(); - Dictionary losers = new Dictionary(); - var correctEmote = reactions[0].Emoji; - foreach (var reaction in reactions) - { - foreach (var person in reaction.Users) - { - if (!correctEmote.Equals(reaction.Emoji)) - { - losers.Add(person, true); - } - else - { - winners.Add(person, true); - } - } - } - foreach (KeyValuePair pair in winners) - { - if (losers.ContainsKey(pair.Key)) - { - winners.Remove(pair.Key); - } - } - - strBuilder.AppendLine("Winners are:"); - foreach (KeyValuePair item in winners) - { - strBuilder.AppendLine(item.Key.Mention); - } - - await ctx.RespondAsync(strBuilder.ToString()); + await ctx.RespondAsync("Report not generated"); } } - - public class Questions - { - [JsonProperty("question")] - public string Question { get; private set; } - [JsonProperty("answer")] - public string[] Answers { get; private set; } - [JsonProperty("points")] - public int Points { get; private set; } - } } diff --git a/StarsiegeBot/Json/quickchats.json b/StarsiegeBot/Json/quickchats.json index ed8ca73..e277b43 100644 --- a/StarsiegeBot/Json/quickchats.json +++ b/StarsiegeBot/Json/quickchats.json @@ -2843,6 +2843,10 @@ "text":"Mr. Wizard, get me the hell out of here!", "soundFile":"mrwizard.wav" }, + "711":{ + "text":"||Hey guys, did you know that in terms of male human and female Pokémon breeding, Vaporeon is the most compatible Pokémon for humans? Not only are they in the field egg group, which is mostly comprised of mammals, Vaporeon are an average of 3”03’ tall and 63.9 pounds, this means they’re large enough to be able handle human dicks, and with their impressive Base Stats for HP and access to Acid Armor, you can be rough with one. Due to their mostly water based biology, there’s no doubt in my mind that an aroused Vaporeon would be incredibly wet, so wet that you could easily have sex with one for hours without getting sore. They can also learn the moves Attract, Baby-Doll Eyes, Captivate, Charm, and Tail Whip, along with not having fur to hide nipples, so it’d be incredibly easy for one to get you in the mood. With their abilities Water Absorb and Hydration, they can easily recover from fatigue with enough water. No other Pokémon comes close to this level of compatibility. Also, fun fact, if you pull out enough, you can make your Vaporeon turn white. Vaporeon is literally built for human dick. Ungodly defense stat+high HP pool+Acid Armor means it can take cock all day, all shapes and sizes and still come for more||", + "soundFile":"SPOILER_Vaporeon Breeding.mp3" + }, "712":{ "text":"Your mother was a dumpster.", "soundFile":"f2_dm_yourmother.wav" @@ -5356,7 +5360,7 @@ "soundFile":"sm_rajah_gd1.wav" }, "1340":{ - "text":"I'll over it.", + "text":"I'll cover it.", "soundFile":"sm_rajah_gd2.wav" }, "1341":{ @@ -7358,5 +7362,9 @@ "1840":{ "text":"Whadaya gonna do, bleed on me?", "soundFile":"mp_bleed.wav" - } -} \ No newline at end of file + }, + "6969":{ + "text":"||OOPSIE WOOPSIE!! Uwu We make a fucky wucky!! A wittle fucko boingo! The code monkeys at our headquarters are working VEWY HAWD to fix this!||", + "soundFile":"SPOILER_OOPSIE WOOPSIE.mp3" + }, +} diff --git a/StarsiegeBot/Program.cs b/StarsiegeBot/Program.cs index 02f01e8..6c8f091 100644 --- a/StarsiegeBot/Program.cs +++ b/StarsiegeBot/Program.cs @@ -30,25 +30,7 @@ namespace StarsiegeBot public DiscordClient Client { get; set; } public CommandsNextExtension Commands { get; set; } public VoiceNextExtension Voice { get; set; } - protected string BotName { get; set; } - - private async Task StartTimer(CancellationToken cancellationToken) - { - await Task.Run(async () => - { - while (true) - { - string output = JsonConvert.SerializeObject(BotSettings.GuildSettings); - await File.WriteAllTextAsync("guildSettings.json", output); - await Task.Delay(TimeSpan.FromSeconds(120), cancellationToken); - if (cancellationToken.IsCancellationRequested) - { - Console.WriteLine("Token Cancelled."); - break; - } - } - }); - } + public string BotName { get; protected set; } public static void Main(string[] args) { @@ -139,7 +121,6 @@ namespace StarsiegeBot this.Commands.RegisterCommands(); this.Commands.RegisterCommands(); //} - Task thisTimerf = StartTimer(new CancellationToken()); // let's enable voice this.Voice = this.Client.UseVoiceNext(); diff --git a/StarsiegeBot/Raven/NotFacts.cs b/StarsiegeBot/Raven/NotFacts.cs index 3ab931a..46676f0 100644 --- a/StarsiegeBot/Raven/NotFacts.cs +++ b/StarsiegeBot/Raven/NotFacts.cs @@ -16,7 +16,7 @@ namespace StarsiegeBot { private List notfacts; private bool IsEnabled; - private readonly string fileName = "notfacts.json"; + private readonly string fileName = "Json/notfacts.json"; public NotFacts() { diff --git a/StarsiegeBot/Raven/SnappleFacts.cs b/StarsiegeBot/Raven/SnappleFacts.cs index e3b645d..0fe91fe 100644 --- a/StarsiegeBot/Raven/SnappleFacts.cs +++ b/StarsiegeBot/Raven/SnappleFacts.cs @@ -16,7 +16,7 @@ namespace StarsiegeBot { private List facts; private bool IsEnabled; - private readonly string fileName = "snapple.json"; + private readonly string fileName = "Json/snapple.json"; public SnappleFacts() { @@ -32,7 +32,7 @@ namespace StarsiegeBot return; // trigger typing. await ctx.TriggerTypingAsync(); - // store our output. + // store our output. string output; // @neo, why is this here? snapId--; diff --git a/StarsiegeBot/Raven/TriviaHandler.cs b/StarsiegeBot/Raven/TriviaHandler.cs new file mode 100644 index 0000000..91594d0 --- /dev/null +++ b/StarsiegeBot/Raven/TriviaHandler.cs @@ -0,0 +1,123 @@ +using DSharpPlus.CommandsNext; +using DSharpPlus.CommandsNext.Attributes; +using DSharpPlus.Entities; +using DSharpPlus.Interactivity.Extensions; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; + +namespace StarsiegeBot.Raven +{ + class TriviaHandler : BaseCommandModule + { + private readonly List QuizQuestions; + private readonly Random rnd = new Random(); + public TriviaHandler() + { + // Load all the Quick Chat texts and sound wav file info. + var json = ""; + using (var fs = File.OpenRead("Json/questions.json")) + using (var sr = new StreamReader(fs, new UTF8Encoding(false))) + json = sr.ReadToEnd(); + Dictionary tempQC = JsonConvert.DeserializeObject>(json); + QuizQuestions = Enumerable.ToList(tempQC.Values); + + } + [Command("quiz")] + [Hidden] + [Description("")] + public async Task Quiz(CommandContext ctx) + { + await ctx.TriggerTypingAsync(); + DiscordEmbedBuilder embed = new DiscordEmbedBuilder(); + + int[] ids = { rnd.Next(QuizQuestions.Count), rnd.Next(QuizQuestions.Count), rnd.Next(QuizQuestions.Count), rnd.Next(QuizQuestions.Count) }; + int selection = rnd.Next(ids.Length); + int mainId = ids[selection]; + string[] options = { "a", "b", "c", "d" }; + + var correctAnswer = DiscordEmoji.FromName(ctx.Client, $":regional_indicator_{options[selection]}:"); + + Questions myQuestion = QuizQuestions[mainId]; + + embed.Description = myQuestion.Question; + + embed.AddField($":regional_indicator_{options[0]}:", QuizQuestions[ids[0]].Answers[rnd.Next(QuizQuestions[ids[0]].Answers.Length)], true); + embed.AddField($":regional_indicator_{options[1]}:", QuizQuestions[ids[1]].Answers[rnd.Next(QuizQuestions[ids[1]].Answers.Length)], true); + embed.AddField("_ _", "_ _", false); + embed.AddField($":regional_indicator_{options[2]}:", QuizQuestions[ids[2]].Answers[rnd.Next(QuizQuestions[ids[2]].Answers.Length)], true); + embed.AddField($":regional_indicator_{options[3]}:", QuizQuestions[ids[3]].Answers[rnd.Next(QuizQuestions[ids[3]].Answers.Length)], true); + + var message = await ctx.RespondAsync(embed); + foreach (var item in options) + { + var itemEmote = DiscordEmoji.FromName(ctx.Client, $":regional_indicator_{item}:"); + await message.CreateReactionAsync(itemEmote); + } + var result = message.WaitForReactionAsync(ctx.Message.Author, TimeSpan.FromSeconds(5d)); + if (!result.Result.TimedOut) + { + if (result.Result.Result.Emoji == correctAnswer) await ctx.RespondAsync("**CORRECT!!**"); + else await ctx.RespondAsync($"Sorry, the right answer was {correctAnswer}"); + } + else await ctx.RespondAsync("Sorry, time ran out!"); + } + + [Command("test")] + [Hidden] + public async Task CollectionCommand(CommandContext ctx) + { + var message = await ctx.RespondAsync("React here!"); + var reactions = await message.CollectReactionsAsync(); + + var strBuilder = new StringBuilder(); + Dictionary winners = new Dictionary(); + Dictionary losers = new Dictionary(); + var correctEmote = reactions[0].Emoji; + foreach (var reaction in reactions) + { + foreach (var person in reaction.Users) + { + if (!correctEmote.Equals(reaction.Emoji)) + { + losers.Add(person, true); + } + else + { + winners.Add(person, true); + } + } + } + foreach (KeyValuePair pair in winners) + { + if (losers.ContainsKey(pair.Key)) + { + winners.Remove(pair.Key); + } + } + + strBuilder.AppendLine("Winners are:"); + foreach (KeyValuePair item in winners) + { + strBuilder.AppendLine(item.Key.Mention); + } + + await ctx.RespondAsync(strBuilder.ToString()); + } + } + + public class Questions + { + [JsonProperty("question")] + public string Question { get; private set; } + [JsonProperty("answer")] + public string[] Answers { get; private set; } + [JsonProperty("points")] + public int Points { get; private set; } + } +} diff --git a/StarsiegeBot/Starsiege/DeathMessages.cs b/StarsiegeBot/Starsiege/DeathMessages.cs index bd5e8f5..0f60b44 100644 --- a/StarsiegeBot/Starsiege/DeathMessages.cs +++ b/StarsiegeBot/Starsiege/DeathMessages.cs @@ -21,7 +21,7 @@ namespace StarsiegeBot { private DeathMessageLines dmLines; private bool DeathMessagesEnabled; - private static readonly string fileName = "DeathMessages.json"; + private static readonly string fileName = "Json/deathmessages.json"; public DeathMessages() { diff --git a/StarsiegeBot/Starsiege/Functions.cs b/StarsiegeBot/Starsiege/Functions.cs index 2ec665e..6c63b8c 100644 --- a/StarsiegeBot/Starsiege/Functions.cs +++ b/StarsiegeBot/Starsiege/Functions.cs @@ -18,7 +18,7 @@ namespace StarsiegeBot { private Dictionary ssFunctions; private bool FunctionsEnabled; - private static readonly string fileName = "functions.json"; + private static readonly string fileName = "Json/functions.json"; public Functions() { Console.WriteLine("Starsiege Function Commands Loaded"); diff --git a/StarsiegeBot/Starsiege/QuickchatHandler.cs b/StarsiegeBot/Starsiege/QuickchatHandler.cs index c00a78d..99e0b81 100644 --- a/StarsiegeBot/Starsiege/QuickchatHandler.cs +++ b/StarsiegeBot/Starsiege/QuickchatHandler.cs @@ -18,7 +18,7 @@ namespace StarsiegeBot { private Dictionary quickchats; private bool IsEnabled; - private readonly string fileName = "quickchats.json"; + private readonly string fileName = "Json/quickchats.json"; public QuickchatHandler() diff --git a/StarsiegeBot/StarsiegeBot.csproj b/StarsiegeBot/StarsiegeBot.csproj index f6cdfa8..d8003c6 100644 --- a/StarsiegeBot/StarsiegeBot.csproj +++ b/StarsiegeBot/StarsiegeBot.csproj @@ -31,12 +31,18 @@ Always + + Always + Always Always + + Always +