diff --git a/Commands/AsciiArt.cs b/Commands/AsciiArt.cs new file mode 100644 index 0000000..b9cf6c5 --- /dev/null +++ b/Commands/AsciiArt.cs @@ -0,0 +1,16 @@ +using Discord.Commands; +using System.Threading.Tasks; + +namespace dotbot.Commands +{ + public class AsciiArt : ModuleBase + { + [Command("ascii")] + [Summary("creates ascii word art")] + public async Task CreateAsciiArt([Remainder] [Summary("text to convert")] string ArtString) + { + await ReplyAsync($"```\n{(new WenceyWang.FIGlet.AsciiArt(ArtString)).ToString()}\n```"); + } + + } +} diff --git a/Commands/Help.cs b/Commands/Help.cs index 3505550..414f5e7 100644 --- a/Commands/Help.cs +++ b/Commands/Help.cs @@ -20,7 +20,6 @@ namespace dotbot.Commands [Command("help")] public async Task HelpAsync() { - string prefix = _config["prefix"]; var builder = new EmbedBuilder() { Color = new Color(114, 137, 218), @@ -34,7 +33,7 @@ namespace dotbot.Commands { var result = await cmd.CheckPreconditionsAsync(Context); if (result.IsSuccess) - description += $"{prefix}{cmd.Aliases.First()}\n"; + description += $"{_config["prefix"]}{cmd.Aliases.First()}\n"; } if (!string.IsNullOrWhiteSpace(description)) @@ -62,7 +61,6 @@ namespace dotbot.Commands return; } - string prefix = _config["prefix"]; var builder = new EmbedBuilder() { Color = new Color(114, 137, 218), @@ -82,7 +80,7 @@ namespace dotbot.Commands }); } - await ReplyAsync("", false, builder.Build()); + await ReplyAsync("", embed: builder.Build()); } } } diff --git a/Commands/Misc.cs b/Commands/Misc.cs new file mode 100644 index 0000000..5a1baf3 --- /dev/null +++ b/Commands/Misc.cs @@ -0,0 +1,74 @@ +using Discord.Commands; +using Microsoft.Extensions.Configuration; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace dotbot.Commands +{ + public class Misc : ModuleBase + { + private readonly Random _rand; + + public Misc(Random rand) + { + _rand = rand; + } + + [Command("roll")] + [Summary("rolls an n-sided die (defaults to 6-sided")] + public async Task RollDie([Summary("[number of sides]")] int sides = 6) + { + await Context.Message.DeleteAsync(); + await ReplyAsync($"{Context.User.Mention}, you rolled a {_rand.Next(1, sides)}. (d{sides})"); + } + + [Command("rand")] + [Summary("gets a random number")] + public async Task RandomInt([Summary("max number")] int max = 100) + { + await Context.Message.DeleteAsync(); + await ReplyAsync($"{Context.User.Mention}, your random number (between 1 and {max}) is {_rand.Next(1, max)}"); + } + + [Command("rand")] + [Summary("gets a random number between min and max")] + public async Task RandomInt([Summary("min number")] int min, [Summary("max number")] int max) + { + await Context.Message.DeleteAsync(); + await ReplyAsync($"{Context.User.Mention}, your random number (between {min} and {max}) is {_rand.Next(min, max)}"); + } + + [Command("8ball")] + [Summary("ask the mighty 8-ball to determine your fortunes")] + public async Task Ask8Ball([Remainder] [Summary("your question for the magic 8ball")] string question) + { + var responses = new List + { + "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", + }; + await Context.Message.DeleteAsync(); + await ReplyAsync($"{Context.User.Mention} asked: *{question}*\n\n**{responses.OrderBy(q => Guid.NewGuid()).First()}**"); + } + } +} diff --git a/Commands/Status.cs b/Commands/Status.cs index a9b9044..2223fcb 100644 --- a/Commands/Status.cs +++ b/Commands/Status.cs @@ -1,8 +1,6 @@ using Discord.Commands; using Discord.WebSocket; using System; -using System.Collections.Generic; -using System.Text; using System.Threading.Tasks; namespace dotbot.Commands @@ -11,7 +9,7 @@ namespace dotbot.Commands { [Command("hi")] [Summary("says hi")] - public async Task SayHi([Remainder] [Summary("the stuff to say")] string echo = "") + public async Task SayHi([Remainder] [Summary("the stuff to say")] string echo = ";hi") { await ReplyAsync($"hi friend! you said: \"{echo}\""); } diff --git a/Program.cs b/Program.cs index 0f93841..3d51e4e 100644 --- a/Program.cs +++ b/Program.cs @@ -15,6 +15,7 @@ namespace dotbot private DiscordSocketClient _client; private IConfigurationRoot _config; private IServiceProvider _services; + private Random _rand; public static void Main(string[] args) => new Program().StartAsync().GetAwaiter().GetResult(); @@ -36,11 +37,13 @@ namespace dotbot _client.Log += Log; + _rand = new Random(); + _services = new ServiceCollection() .AddSingleton(_client) .AddSingleton(_commands) .AddSingleton(_config) - .AddSingleton() + .AddSingleton(_rand) .BuildServiceProvider(); // install all commands from the assembly