From 425538ab0cc4f3c31beb2ed47b58d5278e472987 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Mon, 4 Dec 2017 10:58:42 -0500 Subject: [PATCH] ascii art --- Commands/AsciiArt.cs | 9 ++++++--- Commands/Misc.cs | 18 ++++++++++++++++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/Commands/AsciiArt.cs b/Commands/AsciiArt.cs index b5c549f..6815520 100644 --- a/Commands/AsciiArt.cs +++ b/Commands/AsciiArt.cs @@ -1,6 +1,7 @@ using Discord.Commands; using Microsoft.Extensions.Configuration; using System.IO; +using System.Linq; using System.Threading.Tasks; namespace dotbot.Commands @@ -20,10 +21,12 @@ namespace dotbot.Commands [Remainder] [Summary("text to convert")] string ArtString ) { if (fontName == "list") { - return await ReplyAsync($"available fonts for use with `{_config["prefix"]}ascii`:\n```{string.Join(", ", Directory.GetFiles("Fonts").Select(Path.GetFileNameWithoutExtension))}```"); + await ReplyAsync($"available fonts for use with `{_config["prefix"]}ascii`:\n```{string.Join(", ", Directory.GetFiles("Fonts").ToList().Select(Path.GetFileNameWithoutExtension))}```"); } else if (File.Exists($"Fonts/{fontName}.flf")) { - var font = new WenceyWang.FIGlet.FIGletFont(File.Open($"Fonts/{fontName}.flf")); - await ReplyAsync($"```\n{(new WenceyWang.FIGlet.AsciiArt(ArtString, font: font)).ToString()}\n```"); + using (FileStream fs = File.OpenRead($"Fonts/{fontName}.flf")) { + var font = new WenceyWang.FIGlet.FIGletFont(fs); + await ReplyAsync($"```\n{(new WenceyWang.FIGlet.AsciiArt(ArtString, font: font)).ToString()}\n```"); + } } else { await ReplyAsync($"```\n{(new WenceyWang.FIGlet.AsciiArt(fontName + ArtString)).ToString()}\n```"); } diff --git a/Commands/Misc.cs b/Commands/Misc.cs index 5a1baf3..df4e060 100644 --- a/Commands/Misc.cs +++ b/Commands/Misc.cs @@ -1,4 +1,5 @@ -using Discord.Commands; +using Discord; +using Discord.Commands; using Microsoft.Extensions.Configuration; using System; using System.Collections.Generic; @@ -16,6 +17,7 @@ namespace dotbot.Commands _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) @@ -24,6 +26,7 @@ namespace dotbot.Commands 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) @@ -40,10 +43,12 @@ namespace dotbot.Commands 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) { + await Context.Message.DeleteAsync(); var responses = new List { "It is certain", @@ -67,8 +72,17 @@ namespace dotbot.Commands "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()}**"); } + + + [Command("avatar")] + [Summary("displays a user's profile picture")] + public async Task SendAvatar([Summary("user to get pfp for")] IUser mentionedUser = null) + { + var user = mentionedUser ?? Context.User; + await ReplyAsync($"the avatar for {user.Mention} is at {user.GetAvatarUrl(size: 1024)}"); + } + } }