mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-03-13 02:12:59 +00:00
Add support for embeds (#46)
This commit is contained in:
committed by
Alexey Golub
parent
3b7da21c24
commit
d958f613a3
73
DiscordChatExporter.Core/Models/Embed.cs
Normal file
73
DiscordChatExporter.Core/Models/Embed.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
|
||||
// https://discordapp.com/developers/docs/resources/channel#embed-object
|
||||
|
||||
namespace DiscordChatExporter.Core.Models
|
||||
{
|
||||
public class Embed : IMentionable
|
||||
{
|
||||
public string Title { get; }
|
||||
|
||||
public string Type { get; }
|
||||
|
||||
public string Description { get; }
|
||||
|
||||
public string Url { get; }
|
||||
|
||||
public DateTime? TimeStamp { get; }
|
||||
|
||||
public Color? Color { get; }
|
||||
|
||||
public EmbedFooter Footer { get; }
|
||||
|
||||
public EmbedImage Image { get; }
|
||||
|
||||
public EmbedImage Thumbnail { get; }
|
||||
|
||||
public EmbedVideo Video { get; }
|
||||
|
||||
public EmbedProvider Provider { get; }
|
||||
|
||||
public EmbedAuthor Author { get; }
|
||||
|
||||
public IReadOnlyList<EmbedField> Fields { get; }
|
||||
|
||||
public List<User> MentionedUsers { get; }
|
||||
|
||||
public List<Role> MentionedRoles { get; }
|
||||
|
||||
public List<Channel> MentionedChannels { get; }
|
||||
|
||||
public Embed(string title, string type, string description,
|
||||
string url, DateTime? timeStamp, Color? color,
|
||||
EmbedFooter footer, EmbedImage image, EmbedImage thumbnail,
|
||||
EmbedVideo video, EmbedProvider provider, EmbedAuthor author,
|
||||
List<EmbedField> fields, List<User> mentionedUsers,
|
||||
List<Role> mentionedRoles, List<Channel> mentionedChannels)
|
||||
{
|
||||
Title = title;
|
||||
Type = type;
|
||||
Description = description;
|
||||
Url = url;
|
||||
TimeStamp = timeStamp;
|
||||
Color = color;
|
||||
Footer = footer;
|
||||
Image = image;
|
||||
Thumbnail = thumbnail;
|
||||
Video = video;
|
||||
Provider = provider;
|
||||
Author = author;
|
||||
Fields = fields;
|
||||
MentionedUsers = mentionedUsers;
|
||||
MentionedRoles = mentionedRoles;
|
||||
MentionedChannels = mentionedChannels;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Description;
|
||||
}
|
||||
}
|
||||
}
|
||||
31
DiscordChatExporter.Core/Models/EmbedAuthor.cs
Normal file
31
DiscordChatExporter.Core/Models/EmbedAuthor.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
// https://discordapp.com/developers/docs/resources/channel#embed-object-embed-author-structure
|
||||
|
||||
namespace DiscordChatExporter.Core.Models
|
||||
{
|
||||
public class EmbedAuthor
|
||||
{
|
||||
public string Name { get; }
|
||||
|
||||
public string Url { get; }
|
||||
|
||||
public string IconUrl { get; }
|
||||
|
||||
public string ProxyIconUrl { get; }
|
||||
|
||||
public EmbedAuthor(string name, string url, string iconUrl, string proxyIconUrl)
|
||||
{
|
||||
Name = name;
|
||||
Url = url;
|
||||
IconUrl = iconUrl;
|
||||
ProxyIconUrl = proxyIconUrl;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
23
DiscordChatExporter.Core/Models/EmbedField.cs
Normal file
23
DiscordChatExporter.Core/Models/EmbedField.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
// https://discordapp.com/developers/docs/resources/channel#embed-object-embed-field-structure
|
||||
|
||||
namespace DiscordChatExporter.Core.Models
|
||||
{
|
||||
public class EmbedField
|
||||
{
|
||||
public string Name { get; }
|
||||
|
||||
public string Value { get; }
|
||||
|
||||
public bool? Inline { get; }
|
||||
|
||||
public EmbedField(string name, string value, bool? inline)
|
||||
{
|
||||
Name = name;
|
||||
Value = value;
|
||||
Inline = inline;
|
||||
}
|
||||
}
|
||||
}
|
||||
28
DiscordChatExporter.Core/Models/EmbedFooter.cs
Normal file
28
DiscordChatExporter.Core/Models/EmbedFooter.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
// https://discordapp.com/developers/docs/resources/channel#embed-object-embed-footer-structure
|
||||
|
||||
namespace DiscordChatExporter.Core.Models
|
||||
{
|
||||
public class EmbedFooter
|
||||
{
|
||||
public string Text { get; }
|
||||
|
||||
public string IconUrl { get; }
|
||||
|
||||
public string ProxyIconUrl { get; }
|
||||
|
||||
public EmbedFooter(string text, string iconUrl, string proxyIconUrl)
|
||||
{
|
||||
Text = text;
|
||||
IconUrl = iconUrl;
|
||||
ProxyIconUrl = proxyIconUrl;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Text;
|
||||
}
|
||||
}
|
||||
}
|
||||
26
DiscordChatExporter.Core/Models/EmbedImage.cs
Normal file
26
DiscordChatExporter.Core/Models/EmbedImage.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
// https://discordapp.com/developers/docs/resources/channel#embed-object-embed-image-structure
|
||||
|
||||
namespace DiscordChatExporter.Core.Models
|
||||
{
|
||||
public class EmbedImage
|
||||
{
|
||||
public string Url { get; }
|
||||
|
||||
public string ProxyUrl { get; }
|
||||
|
||||
public int? Height { get; }
|
||||
|
||||
public int? Width { get; }
|
||||
|
||||
public EmbedImage(string url, string proxyUrl, int? height, int? width)
|
||||
{
|
||||
Url = url;
|
||||
ProxyUrl = proxyUrl;
|
||||
Height = height;
|
||||
Width = width;
|
||||
}
|
||||
}
|
||||
}
|
||||
20
DiscordChatExporter.Core/Models/EmbedProvider.cs
Normal file
20
DiscordChatExporter.Core/Models/EmbedProvider.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
// https://discordapp.com/developers/docs/resources/channel#embed-object-embed-provider-structure
|
||||
|
||||
namespace DiscordChatExporter.Core.Models
|
||||
{
|
||||
public class EmbedProvider
|
||||
{
|
||||
public string Name { get; }
|
||||
|
||||
public string Url { get; }
|
||||
|
||||
public EmbedProvider(string name, string url)
|
||||
{
|
||||
Name = name;
|
||||
Url = url;
|
||||
}
|
||||
}
|
||||
}
|
||||
23
DiscordChatExporter.Core/Models/EmbedVideo.cs
Normal file
23
DiscordChatExporter.Core/Models/EmbedVideo.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
// https://discordapp.com/developers/docs/resources/channel#embed-object-embed-video-structure
|
||||
|
||||
namespace DiscordChatExporter.Core.Models
|
||||
{
|
||||
public class EmbedVideo
|
||||
{
|
||||
public string Url { get; }
|
||||
|
||||
public int? Height { get; }
|
||||
|
||||
public int? Width { get; }
|
||||
|
||||
public EmbedVideo(string url, int? height, int? width)
|
||||
{
|
||||
Url = url;
|
||||
Height = height;
|
||||
Width = width;
|
||||
}
|
||||
}
|
||||
}
|
||||
17
DiscordChatExporter.Core/Models/IMentionable.cs
Normal file
17
DiscordChatExporter.Core/Models/IMentionable.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DiscordChatExporter.Core.Models
|
||||
{
|
||||
interface IMentionable
|
||||
{
|
||||
List<User> MentionedUsers { get; }
|
||||
|
||||
List<Role> MentionedRoles { get; }
|
||||
|
||||
List<Channel> MentionedChannels { get; }
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
|
||||
namespace DiscordChatExporter.Core.Models
|
||||
{
|
||||
public class Message
|
||||
public class Message : IMentionable
|
||||
{
|
||||
public string Id { get; }
|
||||
|
||||
@@ -21,17 +21,20 @@ namespace DiscordChatExporter.Core.Models
|
||||
|
||||
public IReadOnlyList<Attachment> Attachments { get; }
|
||||
|
||||
public IReadOnlyList<User> MentionedUsers { get; }
|
||||
public IReadOnlyList<Embed> Embeds { get; }
|
||||
|
||||
public IReadOnlyList<Role> MentionedRoles { get; }
|
||||
public List<User> MentionedUsers { get; }
|
||||
|
||||
public IReadOnlyList<Channel> MentionedChannels { get; }
|
||||
public List<Role> MentionedRoles { get; }
|
||||
|
||||
public List<Channel> MentionedChannels { get; }
|
||||
|
||||
public Message(string id, string channelId, MessageType type,
|
||||
User author, DateTime timeStamp,
|
||||
DateTime? editedTimeStamp, string content,
|
||||
IReadOnlyList<Attachment> attachments, IReadOnlyList<User> mentionedUsers,
|
||||
IReadOnlyList<Role> mentionedRoles, IReadOnlyList<Channel> mentionedChannels)
|
||||
IReadOnlyList<Attachment> attachments, IReadOnlyList<Embed> embeds,
|
||||
List<User> mentionedUsers, List<Role> mentionedRoles,
|
||||
List<Channel> mentionedChannels)
|
||||
{
|
||||
Id = id;
|
||||
ChannelId = channelId;
|
||||
@@ -41,6 +44,7 @@ namespace DiscordChatExporter.Core.Models
|
||||
EditedTimeStamp = editedTimeStamp;
|
||||
Content = content;
|
||||
Attachments = attachments;
|
||||
Embeds = embeds;
|
||||
MentionedUsers = mentionedUsers;
|
||||
MentionedRoles = mentionedRoles;
|
||||
MentionedChannels = mentionedChannels;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace DiscordChatExporter.Core.Models
|
||||
{
|
||||
public class User
|
||||
public partial class User
|
||||
{
|
||||
public string Id { get; }
|
||||
|
||||
@@ -33,4 +33,12 @@ namespace DiscordChatExporter.Core.Models
|
||||
return FullName;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class User
|
||||
{
|
||||
public static User CreateUnknownUser(string id)
|
||||
{
|
||||
return new User(id, 0, "Unknown", null);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user