mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-04-27 16:25:36 +00:00
Use C#9 features
This commit is contained in:
@@ -19,7 +19,7 @@ namespace DiscordChatExporter.Domain.Discord
|
||||
private readonly HttpClient _httpClient;
|
||||
private readonly AuthToken _token;
|
||||
|
||||
private readonly Uri _baseUri = new Uri("https://discord.com/api/v6/", UriKind.Absolute);
|
||||
private readonly Uri _baseUri = new("https://discord.com/api/v6/", UriKind.Absolute);
|
||||
|
||||
public DiscordClient(HttpClient httpClient, AuthToken token)
|
||||
{
|
||||
|
||||
@@ -47,17 +47,14 @@ namespace DiscordChatExporter.Domain.Discord.Models
|
||||
|
||||
public partial class Attachment
|
||||
{
|
||||
private static readonly HashSet<string> ImageFileExtensions =
|
||||
new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
||||
{".jpg", ".jpeg", ".png", ".gif", ".bmp", ".webp"};
|
||||
private static readonly HashSet<string> ImageFileExtensions = new(StringComparer.OrdinalIgnoreCase)
|
||||
{".jpg", ".jpeg", ".png", ".gif", ".bmp", ".webp"};
|
||||
|
||||
private static readonly HashSet<string> VideoFileExtensions =
|
||||
new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
||||
{".mp4", ".webm"};
|
||||
private static readonly HashSet<string> VideoFileExtensions = new(StringComparer.OrdinalIgnoreCase)
|
||||
{".mp4", ".webm"};
|
||||
|
||||
private static readonly HashSet<string> AudioFileExtensions =
|
||||
new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
||||
{".mp3", ".wav", ".ogg", ".flac", ".m4a"};
|
||||
private static readonly HashSet<string> AudioFileExtensions = new(StringComparer.OrdinalIgnoreCase)
|
||||
{".mp3", ".wav", ".ogg", ".flac", ".m4a"};
|
||||
|
||||
public static Attachment Parse(JsonElement json)
|
||||
{
|
||||
|
||||
@@ -60,6 +60,6 @@ namespace DiscordChatExporter.Domain.Discord.Models.Common
|
||||
|
||||
public partial struct FileSize
|
||||
{
|
||||
public static FileSize FromBytes(long bytes) => new FileSize(bytes);
|
||||
public static FileSize FromBytes(long bytes) => new(bytes);
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,6 @@ namespace DiscordChatExporter.Domain.Discord.Models.Common
|
||||
|
||||
public partial class IdBasedEqualityComparer
|
||||
{
|
||||
public static IdBasedEqualityComparer Instance { get; } = new IdBasedEqualityComparer();
|
||||
public static IdBasedEqualityComparer Instance { get; } = new();
|
||||
}
|
||||
}
|
||||
@@ -24,8 +24,7 @@ namespace DiscordChatExporter.Domain.Discord.Models
|
||||
|
||||
public partial class Guild
|
||||
{
|
||||
public static Guild DirectMessages { get; } =
|
||||
new Guild("@me", "Direct Messages", GetDefaultIconUrl());
|
||||
public static Guild DirectMessages { get; } = new("@me", "Direct Messages", GetDefaultIconUrl());
|
||||
|
||||
private static string GetDefaultIconUrl() =>
|
||||
"https://cdn.discordapp.com/embed/avatars/0.png";
|
||||
|
||||
@@ -31,8 +31,7 @@ namespace DiscordChatExporter.Domain.Discord.Models
|
||||
|
||||
public partial class Member
|
||||
{
|
||||
public static Member CreateForUser(User user) =>
|
||||
new Member(user, null, Array.Empty<string>());
|
||||
public static Member CreateForUser(User user) => new(user, null, Array.Empty<string>());
|
||||
|
||||
public static Member Parse(JsonElement json)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user