Make use of the required keyword

This commit is contained in:
Oleksii Holub
2022-12-08 03:20:28 +02:00
parent a8f89ec292
commit f3830247fe
8 changed files with 13 additions and 28 deletions

View File

@@ -16,7 +16,7 @@ public abstract class TokenCommandBase : ICommand
EnvironmentVariable = "DISCORD_TOKEN",
Description = "Authentication token."
)]
public string Token { get; init; } = "";
public required string Token { get; init; }
[Obsolete("This option doesn't do anything. Kept for backwards compatibility.")]
[CommandOption(

View File

@@ -18,7 +18,7 @@ public class ExportChannelsCommand : ExportCommandBase
IsRequired = true,
Description = "Channel ID(s)."
)]
public IReadOnlyList<Snowflake> ChannelIds { get; init; } = Array.Empty<Snowflake>();
public required IReadOnlyList<Snowflake> ChannelIds { get; init; }
public override async ValueTask ExecuteAsync(IConsole console)
{

View File

@@ -18,7 +18,7 @@ public class ExportGuildCommand : ExportCommandBase
IsRequired = true,
Description = "Guild ID."
)]
public Snowflake GuildId { get; init; }
public required Snowflake GuildId { get; init; }
public override async ValueTask ExecuteAsync(IConsole console)
{

View File

@@ -19,7 +19,7 @@ public class GetChannelsCommand : TokenCommandBase
IsRequired = true,
Description = "Guild ID."
)]
public Snowflake GuildId { get; init; }
public required Snowflake GuildId { get; init; }
public override async ValueTask ExecuteAsync(IConsole console)
{