feature: Add inline replies (#1659)

* Add inline replies

* Missed a few things

* Change xml docs, IUserMessage, and other changes

* Missed one when changing

* Fix referencedMessage author
This commit is contained in:
Paulo
2020-11-22 00:43:38 -03:00
committed by GitHub
parent 25d5d36772
commit e3850e1e8f
32 changed files with 239 additions and 132 deletions

View File

@@ -110,7 +110,7 @@ namespace Discord.WebSocket
}
internal static SocketMessage Create(DiscordSocketClient discord, ClientState state, SocketUser author, ISocketMessageChannel channel, Model model)
{
if (model.Type == MessageType.Default)
if (model.Type == MessageType.Default || model.Type == MessageType.Reply)
return SocketUserMessage.Create(discord, state, author, channel, model);
else
return SocketSystemMessage.Create(discord, state, author, channel, model);
@@ -152,7 +152,7 @@ namespace Discord.WebSocket
Reference = new MessageReference
{
GuildId = model.Reference.Value.GuildId,
ChannelId = model.Reference.Value.ChannelId,
InternalChannelId = model.Reference.Value.ChannelId,
MessageId = model.Reference.Value.MessageId
};
}

View File

@@ -17,6 +17,7 @@ namespace Discord.WebSocket
{
private bool _isMentioningEveryone, _isTTS, _isPinned, _isSuppressed;
private long? _editedTimestampTicks;
private IUserMessage _referencedMessage;
private ImmutableArray<Attachment> _attachments = ImmutableArray.Create<Attachment>();
private ImmutableArray<Embed> _embeds = ImmutableArray.Create<Embed>();
private ImmutableArray<ITag> _tags = ImmutableArray.Create<ITag>();
@@ -45,6 +46,8 @@ namespace Discord.WebSocket
public override IReadOnlyCollection<SocketRole> MentionedRoles => _roleMentions;
/// <inheritdoc />
public override IReadOnlyCollection<SocketUser> MentionedUsers => _userMentions;
/// <inheritdoc />
public IUserMessage ReferencedMessage => _referencedMessage;
internal SocketUserMessage(DiscordSocketClient discord, ulong id, ISocketMessageChannel channel, SocketUser author, MessageSource source)
: base(discord, id, channel, author, source)
@@ -131,6 +134,9 @@ namespace Discord.WebSocket
_tags = MessageHelper.ParseTags(text, Channel, guild, _userMentions);
model.Content = text;
}
if (model.ReferencedMessage.IsSpecified && model.ReferencedMessage.Value != null)
_referencedMessage = RestUserMessage.Create(Discord, Channel, Author, model.ReferencedMessage.Value);
}
/// <inheritdoc />