Better mention syntax highlighting and more

- Better mention syntax highlighting
- Added "userinfo" command
This commit is contained in:
Stone-Red-Code
2021-05-28 16:47:56 +02:00
parent 652c81defa
commit af721731ea
18 changed files with 136 additions and 26 deletions
Binary file not shown.
Binary file not shown.
+46 -1
View File
@@ -1,6 +1,7 @@
using DSharpPlus.Entities; using DSharpPlus.Entities;
using DSharpPlus; using DSharpPlus;
using Stone_Red_Utilities.ColorConsole; using Stone_Red_Utilities.ColorConsole;
using Stone_Red_Utilities.StringExtentions;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
@@ -87,7 +88,7 @@ namespace DiscordCLI
break; break;
case ChannelType.Text: case ChannelType.Text:
Console.WriteLine($" {index}. {channel.Name}"); Console.WriteLine($"{index}. {channel.Name}");
index++; index++;
break; break;
} }
@@ -183,5 +184,49 @@ namespace DiscordCLI
await Task.CompletedTask; await Task.CompletedTask;
} }
protected async Task UserInfo(string userName)
{
if (GlobalInformation.currentGuild is null)
{
ConsoleExt.WriteLine("You are not in a guild!", ConsoleColor.Red);
return;
}
if (userName is null)
{
ConsoleExt.WriteLine("User not found!", ConsoleColor.Red);
return;
}
DiscordUser discordUser = GlobalInformation.currentGuild?.Members?.FirstOrDefault(user => user.Username.EqualsIgnoreSpacesAndCase(userName));
if (discordUser is null)
{
discordUser = GlobalInformation.currentGuild?.Members?.FirstOrDefault(user => $"{user.Username}#{user.Discriminator}".EqualsIgnoreSpacesAndCase(userName));
}
if (discordUser is null)
{
discordUser = GlobalInformation.currentGuild?.Members?.FirstOrDefault(user => $"{user.Nickname}".EqualsIgnoreSpacesAndCase(userName));
}
if (discordUser is not null)
{
string infoString =
$"Username: {discordUser.Username}#{discordUser.Discriminator}" + Environment.NewLine +
$"Status: {discordUser.Presence?.Status}" + Environment.NewLine +
$"Created at: {discordUser.CreationTimestamp}" + Environment.NewLine +
$"ID: {discordUser.Id}" + Environment.NewLine +
$"Bot: {discordUser.IsBot}";
Console.WriteLine(infoString);
}
else
{
ConsoleExt.WriteLine("User not found!", ConsoleColor.Red);
}
await Task.CompletedTask;
}
} }
} }
+1
View File
@@ -29,6 +29,7 @@ namespace DiscordCLI
{ "enterg", ("enter guild args:<guild name/index>", ListGuildChannels) }, { "enterg", ("enter guild args:<guild name/index>", ListGuildChannels) },
{ "enterc", ("enter channel args:<channel name/index>", EnterChannel) }, { "enterc", ("enter channel args:<channel name/index>", EnterChannel) },
{ "enterd", ("enter DM channel args:<channel name/index>", EnterDmChannel) }, { "enterd", ("enter DM channel args:<channel name/index>", EnterDmChannel) },
{ "userinfo", ("gets information about a user:<user name>", UserInfo) },
}; };
Timer cooldownTimer = new Timer(1000); Timer cooldownTimer = new Timer(1000);
+41 -4
View File
@@ -8,6 +8,7 @@ using System.Drawing;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using System; using System;
using System.Collections.Generic;
namespace DiscordCLI namespace DiscordCLI
{ {
@@ -66,11 +67,13 @@ namespace DiscordCLI
} }
if (embed.Fields is not null) if (embed.Fields is not null)
{
foreach (DiscordEmbedField field in embed.Fields) foreach (DiscordEmbedField field in embed.Fields)
{ {
WriteTop(">>> ", Color.FromArgb(embed.Color.Value), message, true, false); WriteTop(">>> ", Color.FromArgb(embed.Color.Value), message, true, false);
WriteTop($"{field.Name}{Environment.NewLine}{field.Value}", Color.White, message, false); WriteTop($"{field.Name}{Environment.NewLine}{field.Value}", Color.White, message, false);
} }
}
} }
} }
catch (Exception ex) catch (Exception ex)
@@ -99,8 +102,8 @@ namespace DiscordCLI
if (removeText) if (removeText)
Console.Write('\r' + new string(' ', Console.WindowWidth) + '\r'); Console.Write('\r' + new string(' ', Console.WindowWidth) + '\r');
string[] words = message.Split(' '); List<string> words = message.Replace("\n", " %<newLine>%").Split(' ').ToList();
for (int i = 0; i < words.Length; i++) for (int i = 0; i < words.Count; i++)
{ {
ConsoleColor mentionColor = ConsoleColor.Black; ConsoleColor mentionColor = ConsoleColor.Black;
@@ -109,6 +112,31 @@ namespace DiscordCLI
mentionColor = ConsoleColor.DarkCyan; mentionColor = ConsoleColor.DarkCyan;
} }
if (words[i].Contains("<") && words[i].Contains(">") && !(words[i].StartsWith("<") && words[i].EndsWith(">")))
{
int index1 = words[i].IndexOf("<");
int index2 = words[i].IndexOf(">");
if (index1 < index2)
{
string part1 = words[i].Substring(0, index1);
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))
{
words.Insert(i, part1);
}
if (!string.IsNullOrEmpty(part3))
{
words.Insert(i + (string.IsNullOrEmpty(part1) ? 1 : 2), part3);
}
}
}
foreach (DiscordUser user in discordMessage.MentionedUsers) foreach (DiscordUser user in discordMessage.MentionedUsers)
{ {
if (user?.Mention is not null) if (user?.Mention is not null)
@@ -122,7 +150,16 @@ namespace DiscordCLI
else else
{ {
if (words[i].Contains("<@") && words[i].Contains('>')) if (words[i].Contains("<@") && words[i].Contains('>'))
mentionColor = ConsoleColor.Blue; {
if (ulong.TryParse(words[i].Replace("!", string.Empty).Replace("<@", string.Empty).Replace(">", string.Empty), out ulong id))
{
DiscordUser discordUser = client.GetUserAsync(id).Result;
Console.WriteLine(discordUser is null);
words[i] = words[i].Replace("<@!", "<@").Replace(discordUser.Mention, $"@{discordUser.Username}#{discordUser.Discriminator}");
mentionColor = ConsoleColor.Blue;
}
}
} }
} }
@@ -149,7 +186,7 @@ namespace DiscordCLI
} }
} }
ConsoleExt.Write(words[i] + " ", mentionColor == ConsoleColor.Black ? consoleColor : mentionColor); ConsoleExt.Write(words[i].Replace("%<newLine>%", "\n") + " ", mentionColor == ConsoleColor.Black ? consoleColor : mentionColor);
} }
ConsoleExt.Write(info, ConsoleColor.DarkGray); ConsoleExt.Write(info, ConsoleColor.DarkGray);
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -3,7 +3,8 @@
"additionalProbingPaths": [ "additionalProbingPaths": [
"C:\\Users\\David\\.dotnet\\store\\|arch|\\|tfm|", "C:\\Users\\David\\.dotnet\\store\\|arch|\\|tfm|",
"C:\\Users\\David\\.nuget\\packages", "C:\\Users\\David\\.nuget\\packages",
"C:\\Microsoft\\Xamarin\\NuGet" "C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages",
"C:\\Program Files (x86)\\Microsoft\\Xamarin\\NuGet"
] ]
} }
} }
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+46 -20
View File
@@ -1,7 +1,9 @@
# DiscordCLI # DiscordCLI
> Use Discord in the terminal > Use Discord in the terminal
## Warning ## Warning
**Use this software at your own risk!**\ **Use this software at your own risk!**\
This isn't directly a selfbot, but Discord may count it as User account automation and this is against their TOS.\ This isn't directly a selfbot, but Discord may count it as User account automation and this is against their TOS.\
I guess everything should be fine as long as you don't behave conspicuously but still proceed with caution!\ I guess everything should be fine as long as you don't behave conspicuously but still proceed with caution!\
@@ -9,44 +11,69 @@ Currently there are no known cases where a user got banned for using this Discor
Don't blame me if you get banned!\ Don't blame me if you get banned!\
I will update the above if anything changes! I will update the above if anything changes!
## Download
Releases: https://github.com/Stone-Red-Code/DiscordCLI/releases
## Usage ## Usage
1. <a href="https://github.com/Stone-Red-Code/DiscordCLI/releases">Download</a> one of the releases
1. [Download]("https://github.com/Stone-Red-Code/DiscordCLI/releases
) one of the releases
2. Execute the `DiscordCLI` file 2. Execute the `DiscordCLI` file
3. Enter your <a href="https://github.com/Tyrrrz/DiscordChatExporter/wiki/Obtaining-Token-and-Channel-IDs#how-to-get-a-user-token">User Token</a> 3. Enter your [User Token](https://github.com/Tyrrrz/DiscordChatExporter/wiki/Obtaining-Token-and-Channel-IDs#how-to-get-a-user-token">)
4. Enter one of the commands below 4. Enter one of the commands below
## Commands ## Commands
### help ### help
- lists all commands
- lists all commands
### exit ### exit
- exits application
- exits application
### logout ### logout
- deletes auth token and exits application
- deletes auth token and exits application
### guilds ### guilds
- lists all guilds you are in
- lists all guilds you are in
### dms ### dms
- lists all private channels
- lists all private channels
### channels ### channels
- lists all channels of guild
- args:<guild name/index> - lists all channels of guild
- args: \<guild name/index>
### enterg ### enterg
- enter guild
- args:<guild name/index> - enter guild
- args: \<guild name/index>
### enterc ### enterc
- enter channel
- args:<channel name/index> - enter channel
- args: \<channel name/index>
### enterd ### enterd
- enter DM channel
- args: <channel name/index> - enter DM channel
- args: \<channel name/index>
### userinfo
- gets information about a user
- args: \<user name>
## Limitations ## Limitations
DiscordCLI doesn't support everything the official Discord app does. DiscordCLI doesn't support everything the official Discord app does.
If you find a missing feature in DiscordCLI that is not listed below please tell me or create a pull request and update the list below. If you find a missing feature in DiscordCLI that is not listed below please tell me or create a pull request and update the list below.
### Current limitation: ### Current limitation
- No voice support - No voice support
- Mentions can't be created easily - Mentions can't be created easily
- You can't add/remove guilds - You can't add/remove guilds
@@ -54,4 +81,3 @@ If you find a missing feature in DiscordCLI that is not listed below please tell
- Discord online status not updating - Discord online status not updating
And probably more. And probably more.