mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2024-09-19 12:18:48 -04:00
Refactor
This commit is contained in:
parent
ab46361489
commit
f8dae72411
4 changed files with 21 additions and 6 deletions
|
@ -1,6 +1,6 @@
|
|||
namespace DiscordChatExporter.Models
|
||||
{
|
||||
public class Channel
|
||||
public partial class Channel
|
||||
{
|
||||
public string Id { get; }
|
||||
|
||||
|
@ -23,4 +23,12 @@
|
|||
return Name;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Channel
|
||||
{
|
||||
public static Channel CreateDeletedChannel(string id)
|
||||
{
|
||||
return new Channel(id, "deleted-channel", null, ChannelType.GuildTextChat);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
namespace DiscordChatExporter.Models
|
||||
{
|
||||
public class Role
|
||||
public partial class Role
|
||||
{
|
||||
public string Id { get; }
|
||||
|
||||
|
@ -17,4 +17,12 @@
|
|||
return Name;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Role
|
||||
{
|
||||
public static Role CreateDeletedRole(string id)
|
||||
{
|
||||
return new Role(id, "deleted-role");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -121,7 +121,7 @@ namespace DiscordChatExporter.Services
|
|||
// Get role mentions
|
||||
var mentionedRoles = token["mention_roles"]
|
||||
.Values<string>()
|
||||
.Select(i => _roleCache.GetOrDefault(i) ?? new Role(i, "deleted-role"))
|
||||
.Select(i => _roleCache.GetOrDefault(i) ?? Role.CreateDeletedRole(id))
|
||||
.ToArray();
|
||||
|
||||
// Get channel mentions
|
||||
|
@ -129,8 +129,7 @@ namespace DiscordChatExporter.Services
|
|||
.Cast<Match>()
|
||||
.Select(m => m.Groups[1].Value)
|
||||
.ExceptBlank()
|
||||
.Select(i => _channelCache.GetOrDefault(i) ??
|
||||
new Channel(i, "deleted-channel", null, ChannelType.GuildTextChat))
|
||||
.Select(i => _channelCache.GetOrDefault(i) ?? Channel.CreateDeletedChannel(id))
|
||||
.ToArray();
|
||||
|
||||
return new Message(id, type, author, timeStamp, editedTimeStamp, content, attachments,
|
||||
|
|
|
@ -188,7 +188,7 @@ namespace DiscordChatExporter.Services
|
|||
return ExportAsHtmlAsync(filePath, log, css);
|
||||
}
|
||||
|
||||
throw new NotImplementedException();
|
||||
throw new ArgumentOutOfRangeException(nameof(format));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue