| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,13 +9,8 @@ namespace DSharpPlus.Entities | |||
| 9 | 9 | /// <summary> | |
| 10 | 10 | /// Represents an OAuth2 application. | |
| 11 | 11 | /// </summary> | |
| 12 | - public sealed class DiscordApplication : SnowflakeObject, IEquatable<DiscordApplication> | ||
| 12 | + public sealed class DiscordApplication : DiscordMessageApplication, IEquatable<DiscordApplication> | ||
| 13 | 13 | { | |
| 14 | - /// <summary> | ||
| 15 | - /// Gets the application's description. | ||
| 16 | - /// </summary> | ||
| 17 | - public string Description { get; internal set; } | ||
| 18 | - | ||
| 19 | 14 | /// <summary> | |
| 20 | 15 | /// Gets the application's summary. | |
| 21 | 16 | /// </summary> | |
@@ -24,19 +19,14 @@ public sealed class DiscordApplication : SnowflakeObject, IEquatable<DiscordAppl | |||
| 24 | 19 | /// <summary> | |
| 25 | 20 | /// Gets the application's icon. | |
| 26 | 21 | /// </summary> | |
| 27 | - public string Icon | ||
| 22 | + public override string Icon | ||
| 28 | 23 | => !string.IsNullOrWhiteSpace(this.IconHash) ? $"https://cdn.discordapp.com/app-icons/{this.Id.ToString(CultureInfo.InvariantCulture)}/{this.IconHash}.png?size=1024" : null; | |
| 29 | 24 | ||
| 30 | 25 | /// <summary> | |
| 31 | 26 | /// Gets the application's icon hash. | |
| 32 | 27 | /// </summary> | |
| 33 | 28 | public string IconHash { get; internal set; } | |
| 34 | 29 | ||
| 35 | - /// <summary> | ||
| 36 | - /// Gets the application's name. | ||
| 37 | - /// </summary> | ||
| 38 | - public string Name { get; internal set; } | ||
| 39 | - | ||
| 40 | 30 | /// <summary> | |
| 41 | 31 | /// Gets the application's allowed RPC origins. | |
| 42 | 32 | /// </summary> | |
@@ -70,7 +60,7 @@ public string Icon | |||
| 70 | 60 | /// <summary> | |
| 71 | 61 | /// Gets this application's cover image URL. | |
| 72 | 62 | /// </summary> | |
| 73 | - public string CoverImageUrl | ||
| 63 | + public override string CoverImageUrl | ||
| 74 | 64 | => $"https://cdn.discordapp.com/app-icons/{this.Id.ToString(CultureInfo.InvariantCulture)}/{this.CoverImageHash}.png?size=1024"; | |
| 75 | 65 | ||
| 76 | 66 | /// <summary> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,6 +7,7 @@ | |||
| 7 | 7 | using Newtonsoft.Json; | |
| 8 | 8 | using System.Globalization; | |
| 9 | 9 | using System.Linq; | |
| 10 | + using DSharpPlus.Enums; | ||
| 10 | 11 | ||
| 11 | 12 | namespace DSharpPlus.Entities | |
| 12 | 13 | { | |
@@ -17,6 +18,11 @@ public class DiscordMessage : SnowflakeObject, IEquatable<DiscordMessage> | |||
| 17 | 18 | { | |
| 18 | 19 | internal DiscordMessage() | |
| 19 | 20 | { | |
| 21 | + if (this.Application != null) | ||
| 22 | + this.Application.Discord = this.Discord as DiscordClient; | ||
| 23 | + if (this.Reference != null) | ||
| 24 | + this.Reference._client = this.Discord as DiscordClient; | ||
| 25 | + | ||
| 20 | 26 | this._attachmentsLazy = new Lazy<IReadOnlyList<DiscordAttachment>>(() => new ReadOnlyCollection<DiscordAttachment>(this._attachments)); | |
| 21 | 27 | this._embedsLazy = new Lazy<IReadOnlyList<DiscordEmbed>>(() => new ReadOnlyCollection<DiscordEmbed>(this._embeds)); | |
| 22 | 28 | this._mentionedChannelsLazy = new Lazy<IReadOnlyList<DiscordChannel>>(() => { | |
@@ -76,7 +82,7 @@ public DiscordChannel Channel | |||
| 76 | 82 | => (this.Discord as DiscordClient)?.InternalGetCachedChannel(this.ChannelId); | |
| 77 | 83 | ||
| 78 | 84 | /// <summary> | |
| 79 | - /// Gets ID of the channel in which the message was sent. | ||
| 85 | + /// Gets the ID of the channel in which the message was sent. | ||
| 80 | 86 | /// </summary> | |
| 81 | 87 | [JsonProperty("channel_id", NullValueHandling = NullValueHandling.Ignore)] | |
| 82 | 88 | public ulong ChannelId { get; internal set; } | |
@@ -234,6 +240,24 @@ public IReadOnlyList<DiscordReaction> Reactions | |||
| 234 | 240 | [JsonProperty("type", NullValueHandling = NullValueHandling.Ignore)] | |
| 235 | 241 | public MessageType? MessageType { get; internal set; } | |
| 236 | 242 | ||
| 243 | + /// <summary> | ||
| 244 | + /// Gets the message activity in the Rich Presence embed. | ||
| 245 | + /// </summary> | ||
| 246 | + [JsonProperty("activity", NullValueHandling = NullValueHandling.Ignore)] | ||
| 247 | + public DiscordMessageActivity Activity { get; internal set; } | ||
| 248 | + | ||
| 249 | + /// <summary> | ||
| 250 | + /// Gets the message application in the Rich Presence embed. | ||
| 251 | + /// </summary> | ||
| 252 | + [JsonProperty("application", NullValueHandling = NullValueHandling.Ignore)] | ||
| 253 | + public DiscordMessageApplication Application { get; internal set; } | ||
| 254 | + | ||
| 255 | + /// <summary> | ||
| 256 | + /// Gets the original message reference from the crossposted message. | ||
| 257 | + /// </summary> | ||
| 258 | + [JsonProperty("message_reference", NullValueHandling = NullValueHandling.Ignore)] | ||
| 259 | + public DiscordMessageReference Reference { get; internal set; } | ||
| 260 | + | ||
| 237 | 261 | /// <summary> | |
| 238 | 262 | /// Gets whether the message originated from a webhook. | |
| 239 | 263 | /// </summary> | |
@@ -466,50 +490,4 @@ public override int GetHashCode() | |||
| 466 | 490 | public static bool operator !=(DiscordMessage e1, DiscordMessage e2) | |
| 467 | 491 | => !(e1 == e2); | |
| 468 | 492 | } | |
| 469 | - | ||
| 470 | - /// <summary> | ||
| 471 | - /// Indicates the type of the message. | ||
| 472 | - /// </summary> | ||
| 473 | - public enum MessageType : int | ||
| 474 | - { | ||
| 475 | - /// <summary> | ||
| 476 | - /// Indicates a regular message. | ||
| 477 | - /// </summary> | ||
| 478 | - Default = 0, | ||
| 479 | - | ||
| 480 | - /// <summary> | ||
| 481 | - /// Message indicating a recipient was added to a group direct message. | ||
| 482 | - /// </summary> | ||
| 483 | - RecipientAdd = 1, | ||
| 484 | - | ||
| 485 | - /// <summary> | ||
| 486 | - /// Message indicating a recipient was removed from a group direct message. | ||
| 487 | - /// </summary> | ||
| 488 | - RecipientRemove = 2, | ||
| 489 | - | ||
| 490 | - /// <summary> | ||
| 491 | - /// Message indicating a call. | ||
| 492 | - /// </summary> | ||
| 493 | - Call = 3, | ||
| 494 | - | ||
| 495 | - /// <summary> | ||
| 496 | - /// Message indicating a group direct message channel rename. | ||
| 497 | - /// </summary> | ||
| 498 | - ChannelNameChange = 4, | ||
| 499 | - | ||
| 500 | - /// <summary> | ||
| 501 | - /// Message indicating a group direct message channel icon change. | ||
| 502 | - /// </summary> | ||
| 503 | - ChannelIconChange = 5, | ||
| 504 | - | ||
| 505 | - /// <summary> | ||
| 506 | - /// USER pinned a message to this channel. | ||
| 507 | - /// </summary> | ||
| 508 | - ChannelPinnedMessage = 6, | ||
| 509 | - | ||
| 510 | - /// <summary> | ||
| 511 | - /// Message when a guild member joins. Most frequently seen in newer, smaller guilds. | ||
| 512 | - /// </summary> | ||
| 513 | - GuildMemberJoin = 7 | ||
| 514 | - } | ||
| 515 | 493 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,24 @@ | |||
| 1 | + using Newtonsoft.Json; | ||
| 2 | + | ||
| 3 | + namespace DSharpPlus.Entities | ||
| 4 | + { | ||
| 5 | + /// <summary> | ||
| 6 | + /// Represents a Rich Presence activity. | ||
| 7 | + /// </summary> | ||
| 8 | + public class DiscordMessageActivity | ||
| 9 | + { | ||
| 10 | + /// <summary> | ||
| 11 | + /// Gets the activity type. | ||
| 12 | + /// </summary> | ||
| 13 | + [JsonProperty("type")] | ||
| 14 | + public int Type { get; internal set; } | ||
| 15 | + | ||
| 16 | + /// <summary> | ||
| 17 | + /// Gets the party id of the activity. | ||
| 18 | + /// </summary> | ||
| 19 | + [JsonProperty("party_id")] | ||
| 20 | + public string PartyId { get; internal set; } | ||
| 21 | + | ||
| 22 | + internal DiscordMessageActivity() { } | ||
| 23 | + } | ||
| 24 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,38 @@ | |||
| 1 | + using Newtonsoft.Json; | ||
| 2 | + | ||
| 3 | + namespace DSharpPlus.Entities | ||
| 4 | + { | ||
| 5 | + /// <summary> | ||
| 6 | + /// Represents a Rich Presence application. | ||
| 7 | + /// </summary> | ||
| 8 | + public class DiscordMessageApplication : SnowflakeObject | ||
| 9 | + { | ||
| 10 | + /// <summary> | ||
| 11 | + /// Gets the ID of this application's cover image. | ||
| 12 | + /// </summary> | ||
| 13 | + [JsonProperty("cover_image")] | ||
| 14 | + public virtual string CoverImageUrl { get; internal set; } | ||
| 15 | + | ||
| 16 | + /// <summary> | ||
| 17 | + /// Gets the application's description. | ||
| 18 | + /// </summary> | ||
| 19 | + [JsonProperty("description")] | ||
| 20 | + public string Description { get; internal set; } | ||
| 21 | + | ||
| 22 | + /// <summary> | ||
| 23 | + /// Gets the ID of the application's icon. | ||
| 24 | + /// </summary> | ||
| 25 | + [JsonProperty("icon")] | ||
| 26 | + public virtual string Icon { get; internal set; } | ||
| 27 | + | ||
| 28 | + /// <summary> | ||
| 29 | + /// Gets the application's name. | ||
| 30 | + /// </summary> | ||
| 31 | + [JsonProperty("name")] | ||
| 32 | + public string Name { get; internal set; } | ||
| 33 | + | ||
| 34 | + internal DiscordMessageApplication() { } | ||
| 35 | + | ||
| 36 | + | ||
| 37 | + } | ||
| 38 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,78 @@ | |||
| 1 | + using Newtonsoft.Json; | ||
| 2 | + using System; | ||
| 3 | + | ||
| 4 | + namespace DSharpPlus.Entities | ||
| 5 | + { | ||
| 6 | + /// <summary> | ||
| 7 | + /// Represents data from the original message. | ||
| 8 | + /// </summary> | ||
| 9 | + public class DiscordMessageReference | ||
| 10 | + { | ||
| 11 | + /// <summary> | ||
| 12 | + /// Gets the original message. | ||
| 13 | + /// </summary> | ||
| 14 | + [JsonIgnore] | ||
| 15 | + public DiscordMessage Message { get; internal set; } | ||
| 16 | + | ||
| 17 | + /// <summary> | ||
| 18 | + /// Gets the channel of the original message. | ||
| 19 | + /// </summary> | ||
| 20 | + [JsonIgnore] | ||
| 21 | + public DiscordChannel Channel { get; internal set; } | ||
| 22 | + | ||
| 23 | + /// <summary> | ||
| 24 | + /// Gets the guild of the original message. | ||
| 25 | + /// </summary> | ||
| 26 | + [JsonIgnore] | ||
| 27 | + public DiscordGuild Guild { get; internal set; } | ||
| 28 | + | ||
| 29 | + [JsonProperty("message_id")] | ||
| 30 | + internal ulong? messageId { get; set; } | ||
| 31 | + | ||
| 32 | + [JsonProperty("channel_id")] | ||
| 33 | + internal ulong channelId { get; set; } | ||
| 34 | + | ||
| 35 | + [JsonProperty("guild_id")] | ||
| 36 | + internal ulong? guildId { get; set; } | ||
| 37 | + | ||
| 38 | + [JsonIgnore] | ||
| 39 | + internal DiscordClient _client { get; set; } | ||
| 40 | + | ||
| 41 | + internal DiscordMessageReference() | ||
| 42 | + { | ||
| 43 | + if (this.guildId.HasValue) | ||
| 44 | + if (this._client._guilds.TryGetValue(this.guildId.Value, out var g)) | ||
| 45 | + this.Guild = g; | ||
| 46 | + | ||
| 47 | + else this.Guild = new DiscordGuild | ||
| 48 | + { | ||
| 49 | + Id = this.guildId.Value, | ||
| 50 | + Discord = this._client, | ||
| 51 | + }; | ||
| 52 | + | ||
| 53 | + var channel = this._client.InternalGetCachedChannel(this.channelId); | ||
| 54 | + | ||
| 55 | + if (channel == null) | ||
| 56 | + this.Channel = new DiscordChannel | ||
| 57 | + { | ||
| 58 | + Id = this.channelId, | ||
| 59 | + GuildId = this.guildId.Value, | ||
| 60 | + Discord = this._client | ||
| 61 | + }; | ||
| 62 | + | ||
| 63 | + else this.Channel = channel; | ||
| 64 | + | ||
| 65 | + this.Message = new DiscordMessage | ||
| 66 | + { | ||
| 67 | + ChannelId = this.channelId, | ||
| 68 | + Discord = this._client | ||
| 69 | + }; | ||
| 70 | + | ||
| 71 | + if (messageId.HasValue) | ||
| 72 | + if (this._client.MessageCache.TryGet(m => m.Id == messageId.Value && m.ChannelId == channelId, out var msg)) | ||
| 73 | + this.Message = msg; | ||
| 74 | + | ||
| 75 | + else this.Message.Id = this.messageId.Value; | ||
| 76 | + } | ||
| 77 | + } | ||
| 78 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,28 @@ | |||
| 1 | + namespace DSharpPlus.Enums | ||
| 2 | + { | ||
| 3 | + /// <summary> | ||
| 4 | + /// Indicates the type of MessageActivity for the Rich Presence. | ||
| 5 | + /// </summary> | ||
| 6 | + public enum MessageActivityType | ||
| 7 | + { | ||
| 8 | + /// <summary> | ||
| 9 | + /// Invites the user to join. | ||
| 10 | + /// </summary> | ||
| 11 | + Join = 1, | ||
| 12 | + | ||
| 13 | + /// <summary> | ||
| 14 | + /// Invites the user to spectate. | ||
| 15 | + /// </summary> | ||
| 16 | + Spectate = 2, | ||
| 17 | + | ||
| 18 | + /// <summary> | ||
| 19 | + /// Invites the user to listen. | ||
| 20 | + /// </summary> | ||
| 21 | + Listen = 3, | ||
| 22 | + | ||
| 23 | + /// <summary> | ||
| 24 | + /// Allows user to request to join. | ||
| 25 | + /// </summary> | ||
| 26 | + JoinRequest = 4 | ||
| 27 | + } | ||
| 28 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments