mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-05-22 10:55:15 -04:00
Normalize namings ("...Type" -> "...Kind")
This commit is contained in:
parent
de773467b6
commit
d4eba75036
9 changed files with 47 additions and 47 deletions
|
@ -16,8 +16,8 @@ namespace DiscordChatExporter.Cli.Commands.Base
|
||||||
|
|
||||||
private AuthToken GetAuthToken() => new(
|
private AuthToken GetAuthToken() => new(
|
||||||
IsBotToken
|
IsBotToken
|
||||||
? AuthTokenType.Bot
|
? AuthTokenKind.Bot
|
||||||
: AuthTokenType.User,
|
: AuthTokenKind.User,
|
||||||
TokenValue
|
TokenValue
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -4,19 +4,19 @@ namespace DiscordChatExporter.Core.Discord
|
||||||
{
|
{
|
||||||
public class AuthToken
|
public class AuthToken
|
||||||
{
|
{
|
||||||
public AuthTokenType Type { get; }
|
public AuthTokenKind Kind { get; }
|
||||||
|
|
||||||
public string Value { get; }
|
public string Value { get; }
|
||||||
|
|
||||||
public AuthToken(AuthTokenType type, string value)
|
public AuthToken(AuthTokenKind kind, string value)
|
||||||
{
|
{
|
||||||
Type = type;
|
Kind = kind;
|
||||||
Value = value;
|
Value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AuthenticationHeaderValue GetAuthenticationHeader() => Type switch
|
public AuthenticationHeaderValue GetAuthenticationHeader() => Kind switch
|
||||||
{
|
{
|
||||||
AuthTokenType.Bot => new AuthenticationHeaderValue("Bot", Value),
|
AuthTokenKind.Bot => new AuthenticationHeaderValue("Bot", Value),
|
||||||
_ => new AuthenticationHeaderValue(Value)
|
_ => new AuthenticationHeaderValue(Value)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
namespace DiscordChatExporter.Core.Discord
|
namespace DiscordChatExporter.Core.Discord
|
||||||
{
|
{
|
||||||
public enum AuthTokenType
|
public enum AuthTokenKind
|
||||||
{
|
{
|
||||||
User,
|
User,
|
||||||
Bot
|
Bot
|
|
@ -12,14 +12,14 @@ namespace DiscordChatExporter.Core.Discord.Data
|
||||||
{
|
{
|
||||||
public Snowflake Id { get; }
|
public Snowflake Id { get; }
|
||||||
|
|
||||||
public ChannelType Type { get; }
|
public ChannelKind Kind { get; }
|
||||||
|
|
||||||
public bool IsTextChannel => Type is
|
public bool IsTextChannel => Kind is
|
||||||
ChannelType.GuildTextChat or
|
ChannelKind.GuildTextChat or
|
||||||
ChannelType.DirectTextChat or
|
ChannelKind.DirectTextChat or
|
||||||
ChannelType.DirectGroupTextChat or
|
ChannelKind.DirectGroupTextChat or
|
||||||
ChannelType.GuildNews or
|
ChannelKind.GuildNews or
|
||||||
ChannelType.GuildStore;
|
ChannelKind.GuildStore;
|
||||||
|
|
||||||
public bool IsVoiceChannel => !IsTextChannel;
|
public bool IsVoiceChannel => !IsTextChannel;
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ namespace DiscordChatExporter.Core.Discord.Data
|
||||||
|
|
||||||
public Channel(
|
public Channel(
|
||||||
Snowflake id,
|
Snowflake id,
|
||||||
ChannelType type,
|
ChannelKind kind,
|
||||||
Snowflake guildId,
|
Snowflake guildId,
|
||||||
ChannelCategory category,
|
ChannelCategory category,
|
||||||
string name,
|
string name,
|
||||||
|
@ -43,7 +43,7 @@ namespace DiscordChatExporter.Core.Discord.Data
|
||||||
string? topic)
|
string? topic)
|
||||||
{
|
{
|
||||||
Id = id;
|
Id = id;
|
||||||
Type = type;
|
Kind = kind;
|
||||||
GuildId = guildId;
|
GuildId = guildId;
|
||||||
Category = category;
|
Category = category;
|
||||||
Name = name;
|
Name = name;
|
||||||
|
@ -56,15 +56,15 @@ namespace DiscordChatExporter.Core.Discord.Data
|
||||||
|
|
||||||
public partial class Channel
|
public partial class Channel
|
||||||
{
|
{
|
||||||
private static ChannelCategory GetFallbackCategory(ChannelType channelType) => new(
|
private static ChannelCategory GetFallbackCategory(ChannelKind channelKind) => new(
|
||||||
Snowflake.Zero,
|
Snowflake.Zero,
|
||||||
channelType switch
|
channelKind switch
|
||||||
{
|
{
|
||||||
ChannelType.GuildTextChat => "Text",
|
ChannelKind.GuildTextChat => "Text",
|
||||||
ChannelType.DirectTextChat => "Private",
|
ChannelKind.DirectTextChat => "Private",
|
||||||
ChannelType.DirectGroupTextChat => "Group",
|
ChannelKind.DirectGroupTextChat => "Group",
|
||||||
ChannelType.GuildNews => "News",
|
ChannelKind.GuildNews => "News",
|
||||||
ChannelType.GuildStore => "Store",
|
ChannelKind.GuildStore => "Store",
|
||||||
_ => "Default"
|
_ => "Default"
|
||||||
},
|
},
|
||||||
null
|
null
|
||||||
|
@ -75,7 +75,7 @@ namespace DiscordChatExporter.Core.Discord.Data
|
||||||
var id = json.GetProperty("id").GetString().Pipe(Snowflake.Parse);
|
var id = json.GetProperty("id").GetString().Pipe(Snowflake.Parse);
|
||||||
var guildId = json.GetPropertyOrNull("guild_id")?.GetString().Pipe(Snowflake.Parse);
|
var guildId = json.GetPropertyOrNull("guild_id")?.GetString().Pipe(Snowflake.Parse);
|
||||||
var topic = json.GetPropertyOrNull("topic")?.GetString();
|
var topic = json.GetPropertyOrNull("topic")?.GetString();
|
||||||
var type = (ChannelType) json.GetProperty("type").GetInt32();
|
var kind = (ChannelKind) json.GetProperty("type").GetInt32();
|
||||||
|
|
||||||
var name =
|
var name =
|
||||||
// Guild channel
|
// Guild channel
|
||||||
|
@ -87,9 +87,9 @@ namespace DiscordChatExporter.Core.Discord.Data
|
||||||
|
|
||||||
return new Channel(
|
return new Channel(
|
||||||
id,
|
id,
|
||||||
type,
|
kind,
|
||||||
guildId ?? Guild.DirectMessages.Id,
|
guildId ?? Guild.DirectMessages.Id,
|
||||||
category ?? GetFallbackCategory(type),
|
category ?? GetFallbackCategory(kind),
|
||||||
name,
|
name,
|
||||||
position ?? json.GetPropertyOrNull("position")?.GetInt32(),
|
position ?? json.GetPropertyOrNull("position")?.GetInt32(),
|
||||||
topic
|
topic
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
{
|
{
|
||||||
// https://discord.com/developers/docs/resources/channel#channel-object-channel-types
|
// https://discord.com/developers/docs/resources/channel#channel-object-channel-types
|
||||||
// Order of enum fields needs to match the order in the docs.
|
// Order of enum fields needs to match the order in the docs.
|
||||||
public enum ChannelType
|
public enum ChannelKind
|
||||||
{
|
{
|
||||||
GuildTextChat = 0,
|
GuildTextChat = 0,
|
||||||
DirectTextChat,
|
DirectTextChat,
|
|
@ -9,7 +9,7 @@ using JsonExtensions.Reading;
|
||||||
namespace DiscordChatExporter.Core.Discord.Data
|
namespace DiscordChatExporter.Core.Discord.Data
|
||||||
{
|
{
|
||||||
// https://discord.com/developers/docs/resources/channel#message-object-message-types
|
// https://discord.com/developers/docs/resources/channel#message-object-message-types
|
||||||
public enum MessageType
|
public enum MessageKind
|
||||||
{
|
{
|
||||||
Default = 0,
|
Default = 0,
|
||||||
RecipientAdd = 1,
|
RecipientAdd = 1,
|
||||||
|
@ -27,7 +27,7 @@ namespace DiscordChatExporter.Core.Discord.Data
|
||||||
{
|
{
|
||||||
public Snowflake Id { get; }
|
public Snowflake Id { get; }
|
||||||
|
|
||||||
public MessageType Type { get; }
|
public MessageKind Kind { get; }
|
||||||
|
|
||||||
public User Author { get; }
|
public User Author { get; }
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ namespace DiscordChatExporter.Core.Discord.Data
|
||||||
|
|
||||||
public Message(
|
public Message(
|
||||||
Snowflake id,
|
Snowflake id,
|
||||||
MessageType type,
|
MessageKind kind,
|
||||||
User author,
|
User author,
|
||||||
DateTimeOffset timestamp,
|
DateTimeOffset timestamp,
|
||||||
DateTimeOffset? editedTimestamp,
|
DateTimeOffset? editedTimestamp,
|
||||||
|
@ -70,7 +70,7 @@ namespace DiscordChatExporter.Core.Discord.Data
|
||||||
Message? referencedMessage)
|
Message? referencedMessage)
|
||||||
{
|
{
|
||||||
Id = id;
|
Id = id;
|
||||||
Type = type;
|
Kind = kind;
|
||||||
Author = author;
|
Author = author;
|
||||||
Timestamp = timestamp;
|
Timestamp = timestamp;
|
||||||
EditedTimestamp = editedTimestamp;
|
EditedTimestamp = editedTimestamp;
|
||||||
|
@ -97,21 +97,21 @@ namespace DiscordChatExporter.Core.Discord.Data
|
||||||
var timestamp = json.GetProperty("timestamp").GetDateTimeOffset();
|
var timestamp = json.GetProperty("timestamp").GetDateTimeOffset();
|
||||||
var editedTimestamp = json.GetPropertyOrNull("edited_timestamp")?.GetDateTimeOffset();
|
var editedTimestamp = json.GetPropertyOrNull("edited_timestamp")?.GetDateTimeOffset();
|
||||||
var callEndedTimestamp = json.GetPropertyOrNull("call")?.GetPropertyOrNull("ended_timestamp")?.GetDateTimeOffset();
|
var callEndedTimestamp = json.GetPropertyOrNull("call")?.GetPropertyOrNull("ended_timestamp")?.GetDateTimeOffset();
|
||||||
var type = (MessageType) json.GetProperty("type").GetInt32();
|
var kind = (MessageKind) json.GetProperty("type").GetInt32();
|
||||||
var isPinned = json.GetPropertyOrNull("pinned")?.GetBoolean() ?? false;
|
var isPinned = json.GetPropertyOrNull("pinned")?.GetBoolean() ?? false;
|
||||||
var messageReference = json.GetPropertyOrNull("message_reference")?.Pipe(MessageReference.Parse);
|
var messageReference = json.GetPropertyOrNull("message_reference")?.Pipe(MessageReference.Parse);
|
||||||
var referencedMessage = json.GetPropertyOrNull("referenced_message")?.Pipe(Parse);
|
var referencedMessage = json.GetPropertyOrNull("referenced_message")?.Pipe(Parse);
|
||||||
|
|
||||||
var content = type switch
|
var content = kind switch
|
||||||
{
|
{
|
||||||
MessageType.RecipientAdd => "Added a recipient.",
|
MessageKind.RecipientAdd => "Added a recipient.",
|
||||||
MessageType.RecipientRemove => "Removed a recipient.",
|
MessageKind.RecipientRemove => "Removed a recipient.",
|
||||||
MessageType.Call =>
|
MessageKind.Call =>
|
||||||
$"Started a call that lasted {callEndedTimestamp?.Pipe(t => t - timestamp).Pipe(t => (int) t.TotalMinutes) ?? 0} minutes.",
|
$"Started a call that lasted {callEndedTimestamp?.Pipe(t => t - timestamp).Pipe(t => (int) t.TotalMinutes) ?? 0} minutes.",
|
||||||
MessageType.ChannelNameChange => "Changed the channel name.",
|
MessageKind.ChannelNameChange => "Changed the channel name.",
|
||||||
MessageType.ChannelIconChange => "Changed the channel icon.",
|
MessageKind.ChannelIconChange => "Changed the channel icon.",
|
||||||
MessageType.ChannelPinnedMessage => "Pinned a message.",
|
MessageKind.ChannelPinnedMessage => "Pinned a message.",
|
||||||
MessageType.GuildMemberJoin => "Joined the server.",
|
MessageKind.GuildMemberJoin => "Joined the server.",
|
||||||
_ => json.GetPropertyOrNull("content")?.GetString() ?? ""
|
_ => json.GetPropertyOrNull("content")?.GetString() ?? ""
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ namespace DiscordChatExporter.Core.Discord.Data
|
||||||
|
|
||||||
return new Message(
|
return new Message(
|
||||||
id,
|
id,
|
||||||
type,
|
kind,
|
||||||
author,
|
author,
|
||||||
timestamp,
|
timestamp,
|
||||||
editedTimestamp,
|
editedTimestamp,
|
||||||
|
|
|
@ -126,7 +126,7 @@ namespace DiscordChatExporter.Core.Discord
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
var categories = responseOrdered
|
var categories = responseOrdered
|
||||||
.Where(j => j.GetProperty("type").GetInt32() == (int) ChannelType.GuildCategory)
|
.Where(j => j.GetProperty("type").GetInt32() == (int) ChannelKind.GuildCategory)
|
||||||
.Select((j, index) => ChannelCategory.Parse(j, index + 1))
|
.Select((j, index) => ChannelCategory.Parse(j, index + 1))
|
||||||
.ToDictionary(j => j.Id.ToString(), StringComparer.Ordinal);
|
.ToDictionary(j => j.Id.ToString(), StringComparer.Ordinal);
|
||||||
|
|
||||||
|
|
|
@ -192,7 +192,7 @@ namespace DiscordChatExporter.Core.Exporting.Writers
|
||||||
// Channel
|
// Channel
|
||||||
_writer.WriteStartObject("channel");
|
_writer.WriteStartObject("channel");
|
||||||
_writer.WriteString("id", Context.Request.Channel.Id.ToString());
|
_writer.WriteString("id", Context.Request.Channel.Id.ToString());
|
||||||
_writer.WriteString("type", Context.Request.Channel.Type.ToString());
|
_writer.WriteString("type", Context.Request.Channel.Kind.ToString());
|
||||||
_writer.WriteString("categoryId", Context.Request.Channel.Category.Id.ToString());
|
_writer.WriteString("categoryId", Context.Request.Channel.Category.Id.ToString());
|
||||||
_writer.WriteString("category", Context.Request.Channel.Category.Name);
|
_writer.WriteString("category", Context.Request.Channel.Category.Name);
|
||||||
_writer.WriteString("name", Context.Request.Channel.Name);
|
_writer.WriteString("name", Context.Request.Channel.Name);
|
||||||
|
@ -218,7 +218,7 @@ namespace DiscordChatExporter.Core.Exporting.Writers
|
||||||
|
|
||||||
// Metadata
|
// Metadata
|
||||||
_writer.WriteString("id", message.Id.ToString());
|
_writer.WriteString("id", message.Id.ToString());
|
||||||
_writer.WriteString("type", message.Type.ToString());
|
_writer.WriteString("type", message.Kind.ToString());
|
||||||
_writer.WriteString("timestamp", message.Timestamp);
|
_writer.WriteString("timestamp", message.Timestamp);
|
||||||
_writer.WriteString("timestampEdited", message.EditedTimestamp);
|
_writer.WriteString("timestampEdited", message.EditedTimestamp);
|
||||||
_writer.WriteString("callEndedTimestamp", message.CallEndedTimestamp);
|
_writer.WriteString("callEndedTimestamp", message.CallEndedTimestamp);
|
||||||
|
|
|
@ -111,7 +111,7 @@ namespace DiscordChatExporter.Gui.ViewModels
|
||||||
|
|
||||||
if (_settingsService.LastToken is not null)
|
if (_settingsService.LastToken is not null)
|
||||||
{
|
{
|
||||||
IsBotToken = _settingsService.LastToken.Type == AuthTokenType.Bot;
|
IsBotToken = _settingsService.LastToken.Kind == AuthTokenKind.Bot;
|
||||||
TokenValue = _settingsService.LastToken.Value;
|
TokenValue = _settingsService.LastToken.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ namespace DiscordChatExporter.Gui.ViewModels
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var token = new AuthToken(
|
var token = new AuthToken(
|
||||||
IsBotToken ? AuthTokenType.Bot : AuthTokenType.User,
|
IsBotToken ? AuthTokenKind.Bot : AuthTokenKind.User,
|
||||||
tokenValue
|
tokenValue
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue