Skip to content

Commit

Permalink
Merge pull request #344 from VelvetToroyashi/velvet/message-update-ob…
Browse files Browse the repository at this point in the history
…ject

Message updates are now full messages .
  • Loading branch information
Nihlus authored Nov 3, 2024
2 parents 5e7bfc5 + 2258871 commit 1b3c84a
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace Remora.Discord.API.Abstractions.Gateway.Events;
/// Represents the creation of a message.
/// </summary>
[PublicAPI]
public interface IMessageUpdate : IPartialMessage, IGatewayEvent
public interface IMessageUpdate : IMessage, IGatewayEvent
{
/// <summary>
/// Gets the ID of the guild the message was sent in.
Expand All @@ -48,8 +48,8 @@ public interface IMessageUpdate : IPartialMessage, IGatewayEvent
/// <summary>
/// Gets a list of users mentioned in the message.
/// </summary>
new Optional<IReadOnlyList<IUserMention>> Mentions { get; }
new IReadOnlyList<IUserMention> Mentions { get; }

/// <inheritdoc/>
Optional<IReadOnlyList<IUser>> IPartialMessage.Mentions => this.Mentions.Map<IReadOnlyList<IUser>>(u => u);
IReadOnlyList<IUser> IMessage.Mentions => this.Mentions;
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,26 @@ namespace Remora.Discord.API.Gateway.Events;
[PublicAPI]
public record MessageUpdate
(
Optional<Snowflake> GuildID = default,
Optional<IPartialGuildMember> Member = default,
Optional<IReadOnlyList<IUserMention>> Mentions = default,
Optional<Snowflake> ID = default,
Optional<Snowflake> ChannelID = default,
Optional<IUser> Author = default,
Optional<string> Content = default,
Optional<DateTimeOffset> Timestamp = default,
Optional<DateTimeOffset?> EditedTimestamp = default,
Optional<bool> IsTTS = default,
Optional<bool> MentionsEveryone = default,
Optional<IReadOnlyList<Snowflake>> MentionedRoles = default,
Optional<IReadOnlyList<IChannelMention>> MentionedChannels = default,
Optional<IReadOnlyList<IAttachment>> Attachments = default,
Optional<IReadOnlyList<IEmbed>> Embeds = default,
Optional<IReadOnlyList<IReaction>> Reactions = default,
Optional<string> Nonce = default,
Optional<bool> IsPinned = default,
Optional<Snowflake> WebhookID = default,
Optional<MessageType> Type = default,
Optional<Snowflake> GuildID,
Optional<IPartialGuildMember> Member,
IReadOnlyList<IUserMention> Mentions,
Snowflake ID,
Snowflake ChannelID,
IUser Author,
string Content,
DateTimeOffset Timestamp,
DateTimeOffset? EditedTimestamp,
bool IsTTS,
bool MentionsEveryone,
IReadOnlyList<Snowflake> MentionedRoles,
Optional<IReadOnlyList<IChannelMention>> MentionedChannels,
IReadOnlyList<IAttachment> Attachments,
IReadOnlyList<IEmbed> Embeds,
Optional<IReadOnlyList<IReaction>> Reactions,
Optional<string> Nonce,
bool IsPinned,
Optional<Snowflake> WebhookID,
MessageType Type,
Optional<IMessageActivity> Activity = default,
Optional<IPartialApplication> Application = default,
Optional<Snowflake> ApplicationID = default,
Expand Down
6 changes: 3 additions & 3 deletions Remora.Discord.Commands/Responders/CommandResponder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public virtual async Task<Result> RespondAsync
CancellationToken ct = default
)
{
if (!gatewayEvent.Content.TryGet(out var content))
if (string.IsNullOrEmpty(gatewayEvent.Content))
{
return Result.FromSuccess();
}
Expand All @@ -150,7 +150,7 @@ public virtual async Task<Result> RespondAsync
return Result.FromSuccess();
}

if (gatewayEvent.EditedTimestamp.IsDefined(out var edited))
if (gatewayEvent.EditedTimestamp is { } edited)
{
// Check if the edit happened in the last three seconds; if so, we'll assume this isn't some other
// change made to the message object
Expand All @@ -166,7 +166,7 @@ public virtual async Task<Result> RespondAsync
return Result.FromSuccess();
}

return await ExecuteCommandAsync(content, context, ct);
return await ExecuteCommandAsync(gatewayEvent.Content, context, ct);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,60 @@
"id": "999999999999999999",
"channel_id": "999999999999999999",
"guild_id": "999999999999999999",
"author": {
"username": "none",
"discriminator": "9999",
"id": "999999999999999999",
"avatar": "68b329da9893e34099c7d8ad5cb9c940"
},
"content": "none",
"timestamp": "1970-01-01T00:00:00.000000+00:00",
"edited_timestamp": "1970-01-01T00:00:00.000000+00:00",
"tts": true,
"mention_everyone": true,
"mention_roles": [
"999999999999999999"
],
"mention_channels": [
{
"id": "999999999999999999",
"guild_id": "999999999999999999",
"type": 1,
"name": "none"
}
],
"attachments": [
{
"id": "999999999999999999",
"filename": "file.png",
"size": 0,
"url": "https://www.example.org",
"proxy_url": "https://www.example.org"
}
],
"embeds": [
{}
],
"reactions": [
{
"count": 1,
"count_details": {
"burst": 1,
"normal": 2
},
"me": true,
"me_burst": true,
"emoji": { },
"burst_colors": [
"#ffffff",
"#e30f8a"
]
}
],
"nonce": "none",
"pinned": true,
"webhook_id": "999999999999999999",
"type": 1,
"mentions": [
{
"id": "999999999999999999",
Expand Down

0 comments on commit 1b3c84a

Please sign in to comment.