mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-05-31 14:58:22 -04:00
Make use of the required
keyword
This commit is contained in:
parent
a8f89ec292
commit
f3830247fe
8 changed files with 13 additions and 28 deletions
|
@ -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(
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -13,13 +13,9 @@
|
|||
@inherits RazorBlade.HtmlTemplate
|
||||
|
||||
@functions {
|
||||
// RazorBlade does not provide built-in support for cancellation
|
||||
// https://github.com/ltrzesniewski/RazorBlade/issues/2
|
||||
public CancellationToken CancellationToken { get; init; }
|
||||
public required ExportContext ExportContext { get; init; }
|
||||
|
||||
public ExportContext ExportContext { get; init; } = default!;
|
||||
|
||||
public IReadOnlyList<Message> Messages { get; init; } = Array.Empty<Message>();
|
||||
public required IReadOnlyList<Message> Messages { get; init; }
|
||||
}
|
||||
|
||||
@{
|
||||
|
|
|
@ -4,13 +4,9 @@
|
|||
@inherits RazorBlade.HtmlTemplate
|
||||
|
||||
@functions {
|
||||
// RazorBlade does not provide built-in support for cancellation
|
||||
// https://github.com/ltrzesniewski/RazorBlade/issues/2
|
||||
public CancellationToken CancellationToken { get; init; }
|
||||
public required ExportContext ExportContext { get; init; }
|
||||
|
||||
public ExportContext ExportContext { get; init; } = default!;
|
||||
|
||||
public long MessagesWritten { get; init; }
|
||||
public required long MessagesWritten { get; init; }
|
||||
}
|
||||
|
||||
@{
|
||||
|
|
|
@ -7,13 +7,9 @@
|
|||
@inherits RazorBlade.HtmlTemplate
|
||||
|
||||
@functions {
|
||||
// RazorBlade does not provide built-in support for cancellation
|
||||
// https://github.com/ltrzesniewski/RazorBlade/issues/2
|
||||
public CancellationToken CancellationToken { get; init; }
|
||||
public required ExportContext ExportContext { get; init; }
|
||||
|
||||
public ExportContext ExportContext { get; init; } = default!;
|
||||
|
||||
public string ThemeName { get; init; } = "Dark";
|
||||
public required string ThemeName { get; init; }
|
||||
}
|
||||
|
||||
@{
|
||||
|
|
|
@ -78,10 +78,9 @@ internal class HtmlMessageWriter : MessageWriter
|
|||
Minify(
|
||||
await new PreambleTemplate
|
||||
{
|
||||
CancellationToken = cancellationToken,
|
||||
ExportContext = Context,
|
||||
ThemeName = _themeName
|
||||
}.RenderAsync()
|
||||
}.RenderAsync(cancellationToken)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -94,10 +93,9 @@ internal class HtmlMessageWriter : MessageWriter
|
|||
Minify(
|
||||
await new MessageGroupTemplate
|
||||
{
|
||||
CancellationToken = cancellationToken,
|
||||
ExportContext = Context,
|
||||
Messages = messages
|
||||
}.RenderAsync()
|
||||
}.RenderAsync(cancellationToken)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -133,10 +131,9 @@ internal class HtmlMessageWriter : MessageWriter
|
|||
Minify(
|
||||
await new PostambleTemplate
|
||||
{
|
||||
CancellationToken = cancellationToken,
|
||||
ExportContext = Context,
|
||||
MessagesWritten = MessagesWritten
|
||||
}.RenderAsync()
|
||||
}.RenderAsync(cancellationToken)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue