mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-04-09 21:02:35 +00:00
Automatically detect token kind (#764)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Threading.Tasks;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using CliFx;
|
||||
using CliFx.Attributes;
|
||||
using CliFx.Infrastructure;
|
||||
@@ -9,21 +10,14 @@ namespace DiscordChatExporter.Cli.Commands.Base;
|
||||
public abstract class TokenCommandBase : ICommand
|
||||
{
|
||||
[CommandOption("token", 't', IsRequired = true, EnvironmentVariable = "DISCORD_TOKEN", Description = "Authentication token.")]
|
||||
public string TokenValue { get; init; } = "";
|
||||
public string Token { get; init; } = "";
|
||||
|
||||
[CommandOption("bot", 'b', EnvironmentVariable = "DISCORD_TOKEN_BOT", Description = "Authenticate as a bot.")]
|
||||
[CommandOption("bot", 'b', EnvironmentVariable = "DISCORD_TOKEN_BOT", Description = "This option doesn't do anything. Kept for backwards compatibility.")]
|
||||
[Obsolete("This option doesn't do anything. Kept for backwards compatibility.")]
|
||||
public bool IsBotToken { get; init; }
|
||||
|
||||
private AuthToken? _authToken;
|
||||
private AuthToken AuthToken => _authToken ??= new AuthToken(
|
||||
IsBotToken
|
||||
? AuthTokenKind.Bot
|
||||
: AuthTokenKind.User,
|
||||
TokenValue
|
||||
);
|
||||
|
||||
private DiscordClient? _discordClient;
|
||||
protected DiscordClient Discord => _discordClient ??= new DiscordClient(AuthToken);
|
||||
protected DiscordClient Discord => _discordClient ??= new DiscordClient(Token);
|
||||
|
||||
public abstract ValueTask ExecuteAsync(IConsole console);
|
||||
}
|
||||
@@ -61,7 +61,7 @@ public class GuideCommand : ICommand
|
||||
|
||||
// Wiki link
|
||||
using (console.WithForegroundColor(ConsoleColor.White))
|
||||
console.Output.WriteLine("For more information, check out the wiki:");
|
||||
console.Output.WriteLine("If you have questions or issues, please refer to the wiki:");
|
||||
using (console.WithForegroundColor(ConsoleColor.DarkCyan))
|
||||
console.Output.WriteLine("https://github.com/Tyrrrz/DiscordChatExporter/wiki");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user