diff --git a/ChaosBot/Discord/Modules/User/Fortune.cs b/ChaosBot/Discord/Modules/User/Fortune.cs new file mode 100644 index 0000000..1908073 --- /dev/null +++ b/ChaosBot/Discord/Modules/User/Fortune.cs @@ -0,0 +1,60 @@ +using System; +using System.Text; +using System.Diagnostics; +using System.Threading.Tasks; +using ChaosBot.ConfigHelpers; +using ChaosBot.Discord.PreConditions; +using Discord; +using Discord.Commands; +using Microsoft.Extensions.Configuration; + +namespace ChaosBot.Discord.Modules.User +{ + public class Fortune : ModuleBase + { + [Command("fortune")] + [CheckCommandPerm("User")] + public async Task ShowInfo() + { + try + { + var sb = new StringBuilder(); + var embed = new EmbedBuilder(); + Configuration config = new Configuration(); + + var process = new Process() + { + StartInfo = new ProcessStartInfo + { + FileName = "fortune", + RedirectStandardOutput = true, + UseShellExecute = false, + CreateNoWindow = true, + } + }; + + process.Start(); + string fortuneResult = process.StandardOutput.ReadToEnd(); + process.WaitForExit(); + + embed.WithColor(new Color(255, 255, 0)); + embed.Title = "Fortune"; + sb.AppendLine(fortuneResult); + + /* + * Add the string to the Embed + */ + embed.Description = sb.ToString(); + + /* + * Reply with the Embed created above + */ + await ReplyAsync(null, false, embed.Build()); + } + catch(Exception ex) + { + LoggingFacade.Exception(ex); + } + } + } +}