mirror of
https://github.com/Stone-Red-Code/Discord_Simple-Embed-Bot.git
synced 2026-09-04 09:06:05 +02:00
Improved 'Token not found' error message
This commit is contained in:
Binary file not shown.
@@ -9,8 +9,7 @@ namespace Discord_Simple_Embed_Bot
|
|||||||
{
|
{
|
||||||
public class Program
|
public class Program
|
||||||
{
|
{
|
||||||
public static void Main()
|
public static void Main() => new Program().MainAsync().GetAwaiter().GetResult();
|
||||||
=> new Program().MainAsync().GetAwaiter().GetResult();
|
|
||||||
|
|
||||||
public async Task MainAsync()
|
public async Task MainAsync()
|
||||||
{
|
{
|
||||||
@@ -21,13 +20,14 @@ namespace Discord_Simple_Embed_Bot
|
|||||||
string token = File.ReadAllText(tokenPath);
|
string token = File.ReadAllText(tokenPath);
|
||||||
if (string.IsNullOrWhiteSpace(token))
|
if (string.IsNullOrWhiteSpace(token))
|
||||||
{
|
{
|
||||||
await Logging.Log(new LogMessage(LogSeverity.Critical, "Main", "Please put the Bot-Token into: " + tokenPath));
|
await Logging.Log(new LogMessage(LogSeverity.Critical, "Main", "", new ArgumentNullException("Token", $"Bot-Token not found! Put the Bot-Token into: '{tokenPath}'")));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DiscordSocketClient _client = new DiscordSocketClient();
|
DiscordSocketClient _client = new DiscordSocketClient();
|
||||||
_client.Log += Logging.Log;
|
_client.Log += Logging.Log;
|
||||||
_client.MessageReceived += Client_MessageReceived;
|
_client.MessageReceived += Client_MessageReceived;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await _client.LoginAsync(TokenType.Bot, token, false);
|
await _client.LoginAsync(TokenType.Bot, token, false);
|
||||||
@@ -42,8 +42,6 @@ namespace Discord_Simple_Embed_Bot
|
|||||||
|
|
||||||
//Block this task until the program is closed.
|
//Block this task until the program is closed.
|
||||||
await Task.Delay(-1);
|
await Task.Delay(-1);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task Client_MessageReceived(SocketMessage messageParam)
|
private async Task Client_MessageReceived(SocketMessage messageParam)
|
||||||
@@ -56,9 +54,12 @@ namespace Discord_Simple_Embed_Bot
|
|||||||
{
|
{
|
||||||
public static Task Log(LogMessage msg)
|
public static Task Log(LogMessage msg)
|
||||||
{
|
{
|
||||||
Console.ForegroundColor = GetColor(msg.Severity);
|
lock (Console.Out)
|
||||||
Console.WriteLine(msg.ToString());
|
{
|
||||||
Console.ResetColor();
|
Console.ForegroundColor = GetColor(msg.Severity);
|
||||||
|
Console.WriteLine(msg.ToString());
|
||||||
|
Console.ResetColor();
|
||||||
|
}
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user