diff --git a/README.md b/README.md index 61625e6..80f9465 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,10 @@ I will update the above if anything changes! - deletes auth token and exits application +### clear + +- clears the console + ### guilds - lists all guilds you are in diff --git a/src/.vs/DiscordCLI/v16/.suo b/src/.vs/DiscordCLI/v16/.suo index b26b0af..0b11ccd 100644 Binary files a/src/.vs/DiscordCLI/v16/.suo and b/src/.vs/DiscordCLI/v16/.suo differ diff --git a/src/DiscordCLI/Commands.cs b/src/DiscordCLI/Commands.cs index 651431f..d61d2db 100644 --- a/src/DiscordCLI/Commands.cs +++ b/src/DiscordCLI/Commands.cs @@ -1,9 +1,8 @@ using DSharpPlus.Entities; using DSharpPlus; -using Stone_Red_Utilities.ColorConsole; +using Stone_Red_Utilities.ConsoleExtentions; using Stone_Red_Utilities.StringExtentions; using System.Collections.Generic; -using System.Diagnostics; using System.IO; using System.Linq; using System; @@ -213,9 +212,12 @@ namespace DiscordCLI if (discordUser is not null) { + string status = discordUser.Presence?.Status.ToString(); + status ??= "N/A"; + string infoString = $"Username: {discordUser.Username}#{discordUser.Discriminator}" + Environment.NewLine + - $"Status: {discordUser.Presence?.Status}" + Environment.NewLine + + $"Status: {status}" + Environment.NewLine + $"Created at: {discordUser.CreationTimestamp}" + Environment.NewLine + $"ID: {discordUser.Id}" + Environment.NewLine + $"Bot: {discordUser.IsBot}"; @@ -228,5 +230,11 @@ namespace DiscordCLI await Task.CompletedTask; } + + protected async Task Clear(string args) + { + Console.Clear(); + await Task.CompletedTask; + } } } \ No newline at end of file diff --git a/src/DiscordCLI/CommandsManager.cs b/src/DiscordCLI/CommandsManager.cs index 424af6a..ec76b12 100644 --- a/src/DiscordCLI/CommandsManager.cs +++ b/src/DiscordCLI/CommandsManager.cs @@ -1,5 +1,5 @@ using DSharpPlus; -using Stone_Red_Utilities.ColorConsole; +using Stone_Red_Utilities.ConsoleExtentions; using System.Collections.Generic; using System.Linq; using System; @@ -23,13 +23,14 @@ namespace DiscordCLI { { "exit", ("exits application", null) }, { "logout", ("deletes auth token and exits application", DeleteToken) }, + { "clear", ("clears the console", Clear) }, { "guilds", ("lists all guilds you are in", ListGuilds) }, { "dms", ("lists all private channels", ListDms) }, { "channels", ("lists all channels of guild args:", ListGuildChannels) }, { "enterg", ("enter guild args:", ListGuildChannels) }, { "enterc", ("enter channel args:", EnterChannel) }, { "enterd", ("enter DM channel args:", EnterDmChannel) }, - { "userinfo", ("gets information about a user:", UserInfo) }, + { "userinfo", ("gets information about a user args:", UserInfo) }, }; Timer cooldownTimer = new Timer(1000); diff --git a/src/DiscordCLI/DiscordCLI.csproj b/src/DiscordCLI/DiscordCLI.csproj index d7e6d02..191a3ad 100644 --- a/src/DiscordCLI/DiscordCLI.csproj +++ b/src/DiscordCLI/DiscordCLI.csproj @@ -3,11 +3,13 @@ Exe net5.0 + 1.0.0.0 + 1.0.0.0 - + \ No newline at end of file diff --git a/src/DiscordCLI/InputManager.cs b/src/DiscordCLI/InputManager.cs index 938d338..7723d63 100644 --- a/src/DiscordCLI/InputManager.cs +++ b/src/DiscordCLI/InputManager.cs @@ -3,6 +3,7 @@ using System.Threading.Tasks; using System; using DSharpPlus.Entities; using System.Linq; +using System.Collections.Generic; namespace DiscordCLI { @@ -10,6 +11,7 @@ namespace DiscordCLI { private readonly CommandsManager commandsManager; private readonly DiscordClient client; + private readonly List previousInputs = new List(); public const string prefix = ">"; public string Input { get; private set; } = string.Empty; @@ -21,6 +23,7 @@ namespace DiscordCLI public async Task ReadInput() { + int inputListIndex = 0; bool exit = false; bool printOverride = false; string lastInput = prefix; @@ -44,6 +47,26 @@ namespace DiscordCLI { Input = Input.Remove(Input.Length - 1); } + else if (keyInfo.Key == ConsoleKey.UpArrow) + { + if (previousInputs.Count > 0) + Input = previousInputs[previousInputs.Count - inputListIndex - 1]; + + if (inputListIndex < previousInputs.Count - 1) + inputListIndex++; + Console.CursorLeft = infoString.Length - 1; + Console.Write(Input + new string(' ', Console.WindowWidth - infoString.Length - 1)); + } + else if (keyInfo.Key == ConsoleKey.DownArrow) + { + if (previousInputs.Count > 0) + Input = previousInputs[previousInputs.Count - inputListIndex - 1]; + + if (inputListIndex > 0) + inputListIndex--; + Console.CursorLeft = infoString.Length - 1; + Console.Write(Input + new string(' ', Console.WindowWidth - infoString.Length - 1)); + } Console.Write(keyInfo.KeyChar); if (keyInfo.Key == ConsoleKey.Backspace) @@ -53,8 +76,14 @@ namespace DiscordCLI } while (keyInfo.Key != ConsoleKey.Enter); if (GlobalInformation.currentTextChannel == null && !Input.StartsWith(prefix)) + { + if (previousInputs.Count > 10) + previousInputs.RemoveAt(0); + previousInputs.Add(new string(Input)); Input = prefix + Input; + } + inputListIndex = 0; lastInput = new string(Input); Input = string.Empty; diff --git a/src/DiscordCLI/OutputManager.cs b/src/DiscordCLI/OutputManager.cs index b6dc1be..0a780e4 100644 --- a/src/DiscordCLI/OutputManager.cs +++ b/src/DiscordCLI/OutputManager.cs @@ -2,7 +2,7 @@ using ColorMine.ColorSpaces; using DSharpPlus.Entities; using DSharpPlus; -using Stone_Red_Utilities.ColorConsole; +using Stone_Red_Utilities.ConsoleExtentions; using System.Diagnostics; using System.Drawing; using System.Linq; @@ -122,8 +122,6 @@ namespace DiscordCLI string part2 = words[i].Substring(index1, index2 - index1 + 1); string part3 = words[i].Substring(index2 + 1, words[i].Length - index2 - 1); - Debug.WriteLine(words[i] + "/" + i); - Debug.WriteLine(part1 + "/" + part2 + "/" + part3); words[i] = part2; if (!string.IsNullOrEmpty(part1)) { diff --git a/src/DiscordCLI/Program.cs b/src/DiscordCLI/Program.cs index 1193fe7..588c944 100644 --- a/src/DiscordCLI/Program.cs +++ b/src/DiscordCLI/Program.cs @@ -1,8 +1,9 @@ using DSharpPlus; -using Stone_Red_Utilities.ColorConsole; using System.IO; using System.Threading.Tasks; using System; +using DSharpPlus.Exceptions; +using Stone_Red_Utilities.ConsoleExtentions; namespace DiscordCLI { @@ -46,12 +47,13 @@ namespace DiscordCLI client.MessageCreated += Client_MessageCreated; await client.ConnectAsync(); + ConsoleExt.WriteLine("Welcome to DiscordCLI", ConsoleColor.Green); } catch (Exception ex) { - ConsoleExt.WriteLine(ex, ConsoleColor.Red); + ConsoleExt.WriteLine(ex.Message, ConsoleColor.Red); - if (ex.Message.Contains("Authentication failed")) + if (ex.InnerException is UnauthorizedException) { File.Delete(tokenPath); token = string.Empty; diff --git a/src/DiscordCLI/bin/Debug/net5.0/DiscordCLI.deps.json b/src/DiscordCLI/bin/Debug/net5.0/DiscordCLI.deps.json index 65b2315..0dd52ba 100644 --- a/src/DiscordCLI/bin/Debug/net5.0/DiscordCLI.deps.json +++ b/src/DiscordCLI/bin/Debug/net5.0/DiscordCLI.deps.json @@ -10,7 +10,7 @@ "dependencies": { "ColorMineStandard": "1.0.0", "DSharpPlus": "3.2.3", - "Stone_Red-C-Sharp-Utilities": "1.0.0.2" + "Stone_Red-C-Sharp-Utilities": "1.0.2.1" }, "runtime": { "DiscordCLI.dll": {} @@ -186,11 +186,11 @@ "runtime.ubuntu.14.04-x64.runtime.native.System.Security.Cryptography.OpenSsl/4.3.2": {}, "runtime.ubuntu.16.04-x64.runtime.native.System.Security.Cryptography.OpenSsl/4.3.2": {}, "runtime.ubuntu.16.10-x64.runtime.native.System.Security.Cryptography.OpenSsl/4.3.2": {}, - "Stone_Red-C-Sharp-Utilities/1.0.0.2": { + "Stone_Red-C-Sharp-Utilities/1.0.2.1": { "runtime": { "lib/netstandard2.1/Stone_Red-C-Sharp-Utilities.dll": { - "assemblyVersion": "1.0.0.2", - "fileVersion": "1.0.0.2" + "assemblyVersion": "1.0.2.1", + "fileVersion": "1.0.2.1" } } }, @@ -1173,12 +1173,12 @@ "path": "runtime.ubuntu.16.10-x64.runtime.native.system.security.cryptography.openssl/4.3.2", "hashPath": "runtime.ubuntu.16.10-x64.runtime.native.system.security.cryptography.openssl.4.3.2.nupkg.sha512" }, - "Stone_Red-C-Sharp-Utilities/1.0.0.2": { + "Stone_Red-C-Sharp-Utilities/1.0.2.1": { "type": "package", "serviceable": true, - "sha512": "sha512-/oH1XweI6G2VjeXuutq3XhHAPiSpotfPnsRMK0n8BXFOqG85y0AXQGaKiEdhCZZOpLHFrNY8rtLepMgLJrsY9w==", - "path": "stone_red-c-sharp-utilities/1.0.0.2", - "hashPath": "stone_red-c-sharp-utilities.1.0.0.2.nupkg.sha512" + "sha512": "sha512-QzwH0QvsDiBvCJTFroZBhN/pMEIiz0C8TNkQci+pxCbnjfTtVkxAYsgmlshCl5oHFJh7VYDLcGAULcMBARSb+w==", + "path": "stone_red-c-sharp-utilities/1.0.2.1", + "hashPath": "stone_red-c-sharp-utilities.1.0.2.1.nupkg.sha512" }, "System.AppContext/4.3.0": { "type": "package", diff --git a/src/DiscordCLI/bin/Debug/net5.0/DiscordCLI.dll b/src/DiscordCLI/bin/Debug/net5.0/DiscordCLI.dll index 8a24fe2..b6837cc 100644 Binary files a/src/DiscordCLI/bin/Debug/net5.0/DiscordCLI.dll and b/src/DiscordCLI/bin/Debug/net5.0/DiscordCLI.dll differ diff --git a/src/DiscordCLI/bin/Debug/net5.0/DiscordCLI.pdb b/src/DiscordCLI/bin/Debug/net5.0/DiscordCLI.pdb index ba57a27..edf4760 100644 Binary files a/src/DiscordCLI/bin/Debug/net5.0/DiscordCLI.pdb and b/src/DiscordCLI/bin/Debug/net5.0/DiscordCLI.pdb differ diff --git a/src/DiscordCLI/bin/Debug/net5.0/Stone_Red-C-Sharp-Utilities.dll b/src/DiscordCLI/bin/Debug/net5.0/Stone_Red-C-Sharp-Utilities.dll index 3f011f0..5a51340 100644 Binary files a/src/DiscordCLI/bin/Debug/net5.0/Stone_Red-C-Sharp-Utilities.dll and b/src/DiscordCLI/bin/Debug/net5.0/Stone_Red-C-Sharp-Utilities.dll differ diff --git a/src/DiscordCLI/bin/Debug/net5.0/ref/DiscordCLI.dll b/src/DiscordCLI/bin/Debug/net5.0/ref/DiscordCLI.dll index 4487d43..fbc1f36 100644 Binary files a/src/DiscordCLI/bin/Debug/net5.0/ref/DiscordCLI.dll and b/src/DiscordCLI/bin/Debug/net5.0/ref/DiscordCLI.dll differ diff --git a/src/DiscordCLI/obj/Debug/net5.0/DiscordCLI.assets.cache b/src/DiscordCLI/obj/Debug/net5.0/DiscordCLI.assets.cache index 56547c7..6bffc9f 100644 Binary files a/src/DiscordCLI/obj/Debug/net5.0/DiscordCLI.assets.cache and b/src/DiscordCLI/obj/Debug/net5.0/DiscordCLI.assets.cache differ diff --git a/src/DiscordCLI/obj/Debug/net5.0/DiscordCLI.csproj.CoreCompileInputs.cache b/src/DiscordCLI/obj/Debug/net5.0/DiscordCLI.csproj.CoreCompileInputs.cache index e66e0b9..2d2c45f 100644 --- a/src/DiscordCLI/obj/Debug/net5.0/DiscordCLI.csproj.CoreCompileInputs.cache +++ b/src/DiscordCLI/obj/Debug/net5.0/DiscordCLI.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -d74c436d6f045a94c6aefe230b53cf4fbca29cc5 +d66ea650fdd7843db4c6a535455ec0e4db621eb3 diff --git a/src/DiscordCLI/obj/Debug/net5.0/DiscordCLI.csprojAssemblyReference.cache b/src/DiscordCLI/obj/Debug/net5.0/DiscordCLI.csprojAssemblyReference.cache index 0a00b50..5c6f397 100644 Binary files a/src/DiscordCLI/obj/Debug/net5.0/DiscordCLI.csprojAssemblyReference.cache and b/src/DiscordCLI/obj/Debug/net5.0/DiscordCLI.csprojAssemblyReference.cache differ diff --git a/src/DiscordCLI/obj/Debug/net5.0/DiscordCLI.dll b/src/DiscordCLI/obj/Debug/net5.0/DiscordCLI.dll index 8a24fe2..b6837cc 100644 Binary files a/src/DiscordCLI/obj/Debug/net5.0/DiscordCLI.dll and b/src/DiscordCLI/obj/Debug/net5.0/DiscordCLI.dll differ diff --git a/src/DiscordCLI/obj/Debug/net5.0/DiscordCLI.genruntimeconfig.cache b/src/DiscordCLI/obj/Debug/net5.0/DiscordCLI.genruntimeconfig.cache index 09f0ac1..dbbb60b 100644 --- a/src/DiscordCLI/obj/Debug/net5.0/DiscordCLI.genruntimeconfig.cache +++ b/src/DiscordCLI/obj/Debug/net5.0/DiscordCLI.genruntimeconfig.cache @@ -1 +1 @@ -3e2c7be251ce3e62a6541dac29e1895e802a69f2 +7913be6fc5baee9a6c6e2d3d32160d2ff9b796ff diff --git a/src/DiscordCLI/obj/Debug/net5.0/DiscordCLI.pdb b/src/DiscordCLI/obj/Debug/net5.0/DiscordCLI.pdb index ba57a27..edf4760 100644 Binary files a/src/DiscordCLI/obj/Debug/net5.0/DiscordCLI.pdb and b/src/DiscordCLI/obj/Debug/net5.0/DiscordCLI.pdb differ diff --git a/src/DiscordCLI/obj/Debug/net5.0/ref/DiscordCLI.dll b/src/DiscordCLI/obj/Debug/net5.0/ref/DiscordCLI.dll index 4487d43..fbc1f36 100644 Binary files a/src/DiscordCLI/obj/Debug/net5.0/ref/DiscordCLI.dll and b/src/DiscordCLI/obj/Debug/net5.0/ref/DiscordCLI.dll differ diff --git a/src/DiscordCLI/obj/DiscordCLI.csproj.nuget.dgspec.json b/src/DiscordCLI/obj/DiscordCLI.csproj.nuget.dgspec.json index 890a858..17004dd 100644 --- a/src/DiscordCLI/obj/DiscordCLI.csproj.nuget.dgspec.json +++ b/src/DiscordCLI/obj/DiscordCLI.csproj.nuget.dgspec.json @@ -56,7 +56,7 @@ }, "Stone_Red-C-Sharp-Utilities": { "target": "Package", - "version": "[1.0.0.2, )" + "version": "[1.0.2.1, )" } }, "imports": [ diff --git a/src/DiscordCLI/obj/project.assets.json b/src/DiscordCLI/obj/project.assets.json index 4843fd1..f34bb17 100644 --- a/src/DiscordCLI/obj/project.assets.json +++ b/src/DiscordCLI/obj/project.assets.json @@ -333,7 +333,7 @@ } } }, - "Stone_Red-C-Sharp-Utilities/1.0.0.2": { + "Stone_Red-C-Sharp-Utilities/1.0.2.1": { "type": "package", "compile": { "lib/netstandard2.1/Stone_Red-C-Sharp-Utilities.dll": {} @@ -2116,17 +2116,17 @@ "runtimes/ubuntu.16.10-x64/native/System.Security.Cryptography.Native.OpenSsl.so" ] }, - "Stone_Red-C-Sharp-Utilities/1.0.0.2": { - "sha512": "/oH1XweI6G2VjeXuutq3XhHAPiSpotfPnsRMK0n8BXFOqG85y0AXQGaKiEdhCZZOpLHFrNY8rtLepMgLJrsY9w==", + "Stone_Red-C-Sharp-Utilities/1.0.2.1": { + "sha512": "QzwH0QvsDiBvCJTFroZBhN/pMEIiz0C8TNkQci+pxCbnjfTtVkxAYsgmlshCl5oHFJh7VYDLcGAULcMBARSb+w==", "type": "package", - "path": "stone_red-c-sharp-utilities/1.0.0.2", + "path": "stone_red-c-sharp-utilities/1.0.2.1", "files": [ ".nupkg.metadata", ".signature.p7s", "LICENSE", "lib/netstandard2.1/Stone_Red-C-Sharp-Utilities.dll", "lib/netstandard2.1/Stone_Red-C-Sharp-Utilities.xml", - "stone_red-c-sharp-utilities.1.0.0.2.nupkg.sha512", + "stone_red-c-sharp-utilities.1.0.2.1.nupkg.sha512", "stone_red-c-sharp-utilities.nuspec" ] }, @@ -5871,7 +5871,7 @@ "net5.0": [ "ColorMineStandard >= 1.0.0", "DSharpPlus >= 3.2.3", - "Stone_Red-C-Sharp-Utilities >= 1.0.0.2" + "Stone_Red-C-Sharp-Utilities >= 1.0.2.1" ] }, "packageFolders": { @@ -5931,7 +5931,7 @@ }, "Stone_Red-C-Sharp-Utilities": { "target": "Package", - "version": "[1.0.0.2, )" + "version": "[1.0.2.1, )" } }, "imports": [ diff --git a/src/DiscordCLI/obj/project.nuget.cache b/src/DiscordCLI/obj/project.nuget.cache index d28afc2..adfbcb9 100644 --- a/src/DiscordCLI/obj/project.nuget.cache +++ b/src/DiscordCLI/obj/project.nuget.cache @@ -1,6 +1,6 @@ { "version": 2, - "dgSpecHash": "XLOvAlY87TySZurLo7RL2ezpJBE2tGd1+FsXFkZDwV1NittIw9rcMhOKE+zQq9a72LifKd0qtXSCJ9fmOFQBgA==", + "dgSpecHash": "Sd5hpdPX468vitJPajPRcSMeE6uWNGkfdaCwfOPZjTBB+77H8fvWa+ejKX0QBCdfNu4FyA2bZOqgsxhGYcKcVA==", "success": true, "projectFilePath": "C:\\Users\\David\\Google Drive\\Programmieren\\DiscordCLI\\src\\DiscordCLI\\DiscordCLI.csproj", "expectedPackageFiles": [ @@ -29,7 +29,7 @@ "C:\\Users\\David\\.nuget\\packages\\runtime.ubuntu.14.04-x64.runtime.native.system.security.cryptography.openssl\\4.3.2\\runtime.ubuntu.14.04-x64.runtime.native.system.security.cryptography.openssl.4.3.2.nupkg.sha512", "C:\\Users\\David\\.nuget\\packages\\runtime.ubuntu.16.04-x64.runtime.native.system.security.cryptography.openssl\\4.3.2\\runtime.ubuntu.16.04-x64.runtime.native.system.security.cryptography.openssl.4.3.2.nupkg.sha512", "C:\\Users\\David\\.nuget\\packages\\runtime.ubuntu.16.10-x64.runtime.native.system.security.cryptography.openssl\\4.3.2\\runtime.ubuntu.16.10-x64.runtime.native.system.security.cryptography.openssl.4.3.2.nupkg.sha512", - "C:\\Users\\David\\.nuget\\packages\\stone_red-c-sharp-utilities\\1.0.0.2\\stone_red-c-sharp-utilities.1.0.0.2.nupkg.sha512", + "C:\\Users\\David\\.nuget\\packages\\stone_red-c-sharp-utilities\\1.0.2.1\\stone_red-c-sharp-utilities.1.0.2.1.nupkg.sha512", "C:\\Users\\David\\.nuget\\packages\\system.appcontext\\4.3.0\\system.appcontext.4.3.0.nupkg.sha512", "C:\\Users\\David\\.nuget\\packages\\system.buffers\\4.3.0\\system.buffers.4.3.0.nupkg.sha512", "C:\\Users\\David\\.nuget\\packages\\system.collections\\4.3.0\\system.collections.4.3.0.nupkg.sha512",