diff --git a/src/Discord.Net/DiscordClient.Messages.cs b/src/Discord.Net/DiscordClient.Messages.cs index d49e2c08f..7ab332235 100644 --- a/src/Discord.Net/DiscordClient.Messages.cs +++ b/src/Discord.Net/DiscordClient.Messages.cs @@ -138,7 +138,7 @@ namespace Discord ChannelId = channel.Id, IsTextToSpeech = isTextToSpeech }); - msg.IsQueued = true; + msg.State = MessageState.Queued; if (text.Length > MaxMessageSize) throw new ArgumentOutOfRangeException(nameof(text), $"Message must be {MaxMessageSize} characters or less."); @@ -314,9 +314,10 @@ namespace Discord _messages.Remap(msg.Id, response.Id); msg.Id = response.Id; msg.Update(response); - } - msg.IsQueued = false; - msg.HasFailed = hasFailed; + msg.State = MessageState.Normal; + } + else + msg.State = MessageState.Failed; RaiseMessageSent(msg); } await Task.Delay(interval).ConfigureAwait(false); diff --git a/src/Discord.Net/Models/Message.cs b/src/Discord.Net/Models/Message.cs index 7cffb483d..71c5e83c7 100644 --- a/src/Discord.Net/Models/Message.cs +++ b/src/Discord.Net/Models/Message.cs @@ -6,6 +6,12 @@ using System.Linq; namespace Discord { + public enum MessageState : byte + { + Normal = 0, + Queued, + Failed + } public sealed class Message : CachedObject { public sealed class Attachment : File @@ -98,11 +104,9 @@ namespace Discord public bool IsAuthor => _client.CurrentUserId == _user.Id; /// Returns true if the message was sent as text-to-speech by someone with permissions to do so. public bool IsTTS { get; private set; } - /// Returns true if the message is still in the outgoing message queue. - public bool IsQueued { get; internal set; } - /// Returns true if the message was rejected by the server. - public bool HasFailed { get; internal set; } - /// Returns the raw content of this message as it was received from the server.. + /// Returns the state of this message. Only useful if UseMessageQueue is true. + public MessageState State { get; internal set; } + /// Returns the raw content of this message as it was received from the server. public string RawText { get; private set; } /// Returns the content of this message with any special references such as mentions converted. public string Text { get; private set; } @@ -155,14 +159,14 @@ namespace Discord [JsonIgnore] public Channel Channel => _channel.Value; [JsonProperty] - private long? ChannelId { get { return _channel.Id; } set { _channel.Id = value; } } + private long? ChannelId => _channel.Id; private readonly Reference _channel; /// Returns the author of this message. [JsonIgnore] public User User => _user.Value; [JsonProperty] - private long? UserId { get { return _user.Id; } set { _user.Id = value; } } + private long? UserId => _user.Id; private readonly Reference _user; internal Message(DiscordClient client, long id, long channelId, long userId)