From 0479d443b8bd43acc13ce8073ad61df46ca4ce29 Mon Sep 17 00:00:00 2001 From: Christopher Darnell Date: Thu, 29 Apr 2021 03:18:25 -0700 Subject: [PATCH] Completed welcome message functionality. Need to add notes and descriptions. Redid the SLAP command. Reformatted most of the general Commands output to be embeded instead. Moved a few class level fields to Program. Changed affected code accordingly. --- README.md | 7 +- StarsiegeBot/Commands.cs | 393 +++++++++++++++------------- StarsiegeBot/EventTriggers.cs | 13 +- StarsiegeBot/Program.cs | 33 ++- StarsiegeBot/Starsiege/Functions.cs | 9 +- StarsiegeBot/Starsiege/Quickchat.cs | 1 + StarsiegeBot/WelcomeMessage.cs | 97 ++++++- 7 files changed, 344 insertions(+), 209 deletions(-) diff --git a/README.md b/README.md index afdb79a..2a6a9a3 100644 --- a/README.md +++ b/README.md @@ -1 +1,6 @@ -# DiscordBot \ No newline at end of file +# DiscordBot + +## Setup + +The bot tokens + diff --git a/StarsiegeBot/Commands.cs b/StarsiegeBot/Commands.cs index 6155ce4..40de816 100644 --- a/StarsiegeBot/Commands.cs +++ b/StarsiegeBot/Commands.cs @@ -6,6 +6,7 @@ using DSharpPlus.CommandsNext.Attributes; using DSharpPlus.Entities; using System.Text.RegularExpressions; using System.Linq; +using System.Collections.Generic; namespace StarsiegeBot { @@ -14,35 +15,103 @@ namespace StarsiegeBot // this class depends a lot on the random stuff. so make it class level. private readonly Random rnd = new Random(); - // start: neo wanted this shit.... - private readonly string[] insult = { - "> {0} slaps {1} around a bit with a large trout.", - "> {0} puts a jellyfish on {1}'s head.", - "> {0} slaps {1} around a bit with the mustache of Caanon.", - "> {0} slaps {1} around a bit with a questionable rubber object.", - "> {0} slaps {1} around a bit with a rubber chicken." + // Master insult list. + private readonly string[] InsultMaster = { + "{0} slaps {1} around a bit with a large trout.", + "{0} puts a jellyfish on {1}'s head.", + "{0} slaps {1} around a bit with the mustache of Caanon.", + "{0} slaps {1} around a bit with a questionable rubber object.", + "{0} slaps {1} around a bit with a rubber chicken." }; - private uint insultIndex; - public string Insult { - get { - if (insultIndex >= insult.Length) { - insultIndex = 0; - } - return insult[insultIndex++ % insult.Length]; - } - } - // end: neo's shit. + private List InsultCopy; public Commands() { // Let the console know we've loaded basic commands. Console.WriteLine("Basic Commands Loaded"); + InsultCopy = InsultMaster.ToList(); } + [Command("8ball"), Aliases(new String[] { "ball", "8" })] + [Description("The Magic 8-Ball is a fortune-telling or seeking advice")] + public async Task Eightball(CommandContext ctx, [RemainingText, Description("Your question to the 8 ball")] String remainingText = "") + { + await ctx.TriggerTypingAsync(); + // Load all the traditional 8-Ball answers into an array. + string[] results = new string[] { "It is certain.", "It is decidedly so.", "Without a doubt.", "Yes - definitely.", "You may rely on it.", "As I see it, yes.", "Most likely.", "Outlook good.", "Yes.", "Signs point to yes.", "Reply hazy, try again", "Ask again later.", "Better not tell you now.", "Cannot predict now.", "Concentrate and ask again.", "Don't count on it.", "My reply is no.", "My sources say no", "Outlook not so good.", "Very doubtful." }; + // give the end user the randomly choosen result. + DiscordEmbedBuilder embed = new DiscordEmbedBuilder + { + Description = results[rnd.Next(0, results.Length)], + Color = Program.colours[rnd.Next(0, Program.colours.Length)] + }; + await ctx.RespondAsync(embed); + } + [Command("about")] + [Description("Gives some basic info about the bot")] + public async Task About(CommandContext ctx) + { + await ctx.TriggerTypingAsync(); + // delcare an embed builder. + DiscordEmbedBuilder embed = new DiscordEmbedBuilder(); + // Title the ebemd with the bot's name and discrim. + embed.WithTitle("About " + ctx.Client.CurrentUser.Username + "#" + ctx.Client.CurrentUser.Discriminator); + // add the bot's avatar as the Thumbnail. + embed.WithThumbnail(ctx.Client.CurrentUser.GetAvatarUrl(DSharpPlus.ImageFormat.Png, 32)); + // Add a bit of color... the color from the member's top most role. + embed.WithColor(ctx.Member.Color); + // output various data abotu the bot. + embed.AddField("D#+ Ver", ctx.Client.VersionString, true); + embed.AddField("Guild Count", ctx.Client.Guilds.Count.ToString(), true); + embed.AddField("Ping", ctx.Client.Ping.ToString(), true); + embed.AddField("Shard Count", ctx.Client.ShardCount.ToString(), true); + embed.AddField("Shard", ctx.Client.ShardId.ToString(), true); + embed.Color = Program.colours[rnd.Next(0, Program.colours.Length)]; + // list all the owners of the bot. + string owners = ""; + foreach (DiscordUser owner in ctx.Client.CurrentApplication.Owners) + { + owners += owner.Username + "#" + owner.Discriminator + "\r\n"; + } + embed.AddField("Owner(s)", owners, false); + // send the data to the end user. + await ctx.RespondAsync(embed); + } + [Command("coin")] + [Description("Flips a coin for ya!")] + public async Task Coinflip(CommandContext ctx) + { + // We're going to randomly select heads or tails and then give it to the user. + await ctx.TriggerTypingAsync(); + string[] choices = { "heads", "tails" }; + DiscordEmbedBuilder embed = new DiscordEmbedBuilder + { + Description = "The coin landed on... " + choices[rnd.Next(0, choices.Length)], + Color = Program.colours[rnd.Next(0, Program.colours.Length)] + }; + await ctx.RespondAsync(embed); + } + [Command("credits")] + [Description("Shows all those that have helped with my bot(s) over the years!")] + public async Task Credits(CommandContext ctx) + { + await ctx.TriggerTypingAsync(); + // just some people that have helped me build the bot. + string credits = "```asciidoc\r\n= CREDITS (Outdated) =\r\n" + + "• UndeadShadow :: Flood Protection. Keepign teh bot from killing itself, and others.\r\n" + + "• Da_D_Master :: For giving me my start in my first couple bots, and being a friendly rival.\r\n" + + "• ThinkExist & Bored.com :: Quotes for the Quote Database\r\n" + + "• Hanibal, TaMeD, Liquid- :: For awlays proving the points of others.\r\n" + + "• Neo :: For all their hard work on all the things I've ever asked about.\r\n" + + "• Alias :: For helping me learn how to make IRC bots back in the day.\r\n" + + "• Drake, Eledore :: Supporting the development of the bot and supplying code for it.\r\n" + + "\r\n```"; + await ctx.RespondAsync(credits); + } [Command("dice"), Aliases("r", "d", "roll")] [Description("A classic dice throwing command. Limited to 1 use per 2 seconds. Format: d ")] [Cooldown(1, 2, CooldownBucketType.Guild)] - public async Task Dice(CommandContext ctx, [RemainingText,Description("XdY")] String throwing = "d") + public async Task Dice(CommandContext ctx, [RemainingText, Description("XdY")] String throwing = "d") { // let the end user know the bot is doing something... await ctx.TriggerTypingAsync(); @@ -95,7 +164,7 @@ namespace StarsiegeBot dieResult += roll; } // If the end user is rolling more than 10 of any kind of die, dont show the results of the rolls. Just - if(volume < 11) + if (volume < 11) dieResults = $"{volume}d{sides}: Total: " + dieResult + " Avg: " + Math.Round(dieResult * 1.0 / volume, 2) + " Results: " + dieResults; else dieResults = $"{volume}d{sides}: Total: " + dieResult + " Avg: " + Math.Round(dieResult * 1.0 / volume, 2); @@ -108,7 +177,6 @@ namespace StarsiegeBot else await ctx.RespondAsync(overallResults); } - [Command("random")] [Description("Random number generator.")] public async Task Random(CommandContext ctx, [Description("Lowest number choice. (Inclusive)")] int min, [Description("Highest Number Choice. (Inclusive)")] int max) @@ -119,53 +187,91 @@ namespace StarsiegeBot int i = Math.Min(min, max); int a = Math.Max(min, max) + 1; // output the results - await ctx.RespondAsync($"🎲 Your random number is: {rnd.Next(i, a)}"); + DiscordEmbedBuilder embed = new DiscordEmbedBuilder + { + Description = $"🎲 Your random number is: {rnd.Next(i, a)}", + Color = Program.colours[rnd.Next(0, Program.colours.Length)] + }; + await ctx.RespondAsync(embed); } - [Command("random")] public async Task Random(CommandContext ctx) { await ctx.TriggerTypingAsync(); // some one didn't read the HELP file on Random. Explain it to them. - await ctx.RespondAsync($"Gives you a random number between