diff --git a/Myriad/Gateway/GatewayIntent.cs b/Myriad/Gateway/GatewayIntent.cs index ca0c8e66..9739413d 100644 --- a/Myriad/Gateway/GatewayIntent.cs +++ b/Myriad/Gateway/GatewayIntent.cs @@ -17,5 +17,6 @@ public enum GatewayIntent GuildMessageTyping = 1 << 11, DirectMessages = 1 << 12, DirectMessageReactions = 1 << 13, - DirectMessageTyping = 1 << 14 + DirectMessageTyping = 1 << 14, + MessageContent = 1 << 15, } \ No newline at end of file diff --git a/Myriad/Gateway/ShardConnection.cs b/Myriad/Gateway/ShardConnection.cs index 2d62b8b1..158762b5 100644 --- a/Myriad/Gateway/ShardConnection.cs +++ b/Myriad/Gateway/ShardConnection.cs @@ -80,7 +80,7 @@ public class ShardConnection: IAsyncDisposable return null; } - private Uri GetConnectionUri(string baseUri) => new UriBuilder(baseUri) { Query = "v=9&encoding=json" }.Uri; + private Uri GetConnectionUri(string baseUri) => new UriBuilder(baseUri) { Query = "v=10&encoding=json" }.Uri; private async Task CloseInner(WebSocketCloseStatus closeStatus, string? description) { diff --git a/Myriad/Rest/DiscordApiClient.cs b/Myriad/Rest/DiscordApiClient.cs index 7b1f509f..7fd89356 100644 --- a/Myriad/Rest/DiscordApiClient.cs +++ b/Myriad/Rest/DiscordApiClient.cs @@ -11,7 +11,7 @@ namespace Myriad.Rest; public class DiscordApiClient { public const string UserAgent = "DiscordBot (https://github.com/xSke/PluralKit/tree/main/Myriad/, v1)"; - private const string DefaultApiBaseUrl = "https://discord.com/api/v9"; + private const string DefaultApiBaseUrl = "https://discord.com/api/v10"; private readonly BaseRestClient _client; public EventHandler<(string, int, long)> OnResponseEvent; diff --git a/Myriad/Rest/Types/Requests/MessageEditRequest.cs b/Myriad/Rest/Types/Requests/MessageEditRequest.cs index fb2b7cb5..e662eb65 100644 --- a/Myriad/Rest/Types/Requests/MessageEditRequest.cs +++ b/Myriad/Rest/Types/Requests/MessageEditRequest.cs @@ -11,7 +11,7 @@ public record MessageEditRequest public Optional Content { get; init; } [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] - public Optional Embed { get; init; } + public Optional Embeds { get; init; } [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] public Optional Flags { get; init; } diff --git a/Myriad/Rest/Types/Requests/MessageRequest.cs b/Myriad/Rest/Types/Requests/MessageRequest.cs index 4128defc..80506f64 100644 --- a/Myriad/Rest/Types/Requests/MessageRequest.cs +++ b/Myriad/Rest/Types/Requests/MessageRequest.cs @@ -8,6 +8,6 @@ public record MessageRequest public object? Nonce { get; set; } public bool Tts { get; set; } public AllowedMentions? AllowedMentions { get; set; } - public Embed? Embed { get; set; } + public Embed[]? Embeds { get; set; } public MessageComponent[]? Components { get; set; } } \ No newline at end of file diff --git a/PluralKit.Bot/CommandSystem/Context/Context.cs b/PluralKit.Bot/CommandSystem/Context/Context.cs index acfbe4e7..71f97315 100644 --- a/PluralKit.Bot/CommandSystem/Context/Context.cs +++ b/PluralKit.Bot/CommandSystem/Context/Context.cs @@ -89,7 +89,7 @@ public class Context var msg = await Rest.CreateMessage(Channel.Id, new MessageRequest { Content = text, - Embed = embed, + Embeds = embed != null ? new[] { embed } : null, // Default to an empty allowed mentions object instead of null (which means no mentions allowed) AllowedMentions = mentions ?? new AllowedMentions() }); diff --git a/PluralKit.Bot/Commands/Misc.cs b/PluralKit.Bot/Commands/Misc.cs index 6597ec67..fa618f7a 100644 --- a/PluralKit.Bot/Commands/Misc.cs +++ b/PluralKit.Bot/Commands/Misc.cs @@ -133,6 +133,6 @@ public class Misc .Timestamp(process.StartTime.ToString("O")); await ctx.Rest.EditMessage(msg.ChannelId, msg.Id, - new MessageEditRequest { Content = "", Embed = embed.Build() }); + new MessageEditRequest { Content = "", Embeds = new[] { embed.Build() } }); } } \ No newline at end of file diff --git a/PluralKit.Bot/Handlers/ReactionAdded.cs b/PluralKit.Bot/Handlers/ReactionAdded.cs index 0d52e6ef..482aa39c 100644 --- a/PluralKit.Bot/Handlers/ReactionAdded.cs +++ b/PluralKit.Bot/Handlers/ReactionAdded.cs @@ -171,22 +171,21 @@ public class ReactionAdded: IEventHandler try { var dm = await _dmCache.GetOrCreateDmChannel(evt.UserId); - if (msg.Member != null) - await _rest.CreateMessage(dm, new MessageRequest - { - Embed = await _embeds.CreateMemberEmbed( - msg.System, - msg.Member, - guild, - LookupContext.ByNonOwner, - DateTimeZone.Utc - ) - }); - await _rest.CreateMessage( - dm, - new MessageRequest { Embed = await _embeds.CreateMessageInfoEmbed(msg, true) } - ); + var embeds = new List(); + + if (msg.Member != null) + embeds.Add(await _embeds.CreateMemberEmbed( + msg.System, + msg.Member, + guild, + LookupContext.ByNonOwner, + DateTimeZone.Utc + )); + + embeds.Add(await _embeds.CreateMessageInfoEmbed(msg, true)); + + await _rest.CreateMessage(dm, new MessageRequest { Embeds = embeds.ToArray() }); } catch (ForbiddenException) { } // No permissions to DM, can't check for this :( diff --git a/PluralKit.Bot/Interactive/BaseInteractive.cs b/PluralKit.Bot/Interactive/BaseInteractive.cs index c1bd3670..c2ae33ee 100644 --- a/PluralKit.Bot/Interactive/BaseInteractive.cs +++ b/PluralKit.Bot/Interactive/BaseInteractive.cs @@ -67,7 +67,7 @@ public abstract class BaseInteractive new MessageRequest { Content = content, - Embed = embed, + Embeds = embed != null ? new[] { embed } : null, AllowedMentions = mentions, Components = GetComponents() }); diff --git a/PluralKit.Bot/Modules.cs b/PluralKit.Bot/Modules.cs index bf176dd5..c5440386 100644 --- a/PluralKit.Bot/Modules.cs +++ b/PluralKit.Bot/Modules.cs @@ -38,7 +38,8 @@ public class BotModule: Module GatewayIntent.GuildEmojis | GatewayIntent.GuildMessages | GatewayIntent.GuildWebhooks | - GatewayIntent.GuildMessageReactions + GatewayIntent.GuildMessageReactions | + GatewayIntent.MessageContent }; }).AsSelf().SingleInstance(); builder.RegisterType().AsSelf().SingleInstance(); diff --git a/PluralKit.Bot/Services/ErrorMessageService.cs b/PluralKit.Bot/Services/ErrorMessageService.cs index 3c47cf3e..9b151f86 100644 --- a/PluralKit.Bot/Services/ErrorMessageService.cs +++ b/PluralKit.Bot/Services/ErrorMessageService.cs @@ -62,7 +62,7 @@ public class ErrorMessageService try { await _rest.CreateMessage(channelId, - new MessageRequest { Content = $"> **Error code:** `{errorId}`", Embed = embed.Build() }); + new MessageRequest { Content = $"> **Error code:** `{errorId}`", Embeds = new[] { embed.Build() } }); _logger.Information("Sent error message to {ChannelId} with error code {ErrorId}", channelId, errorId); _metrics.Measure.Meter.Mark(BotMetrics.ErrorMessagesSent, "sent"); diff --git a/PluralKit.Bot/Services/LogChannelService.cs b/PluralKit.Bot/Services/LogChannelService.cs index 1cea61a1..202069af 100644 --- a/PluralKit.Bot/Services/LogChannelService.cs +++ b/PluralKit.Bot/Services/LogChannelService.cs @@ -51,7 +51,7 @@ public class LogChannelService oldContent); var url = $"https://discord.com/channels/{proxiedMessage.Guild.Value}/{proxiedMessage.Channel}/{proxiedMessage.Mid}"; - await _rest.CreateMessage(logChannelId.Value, new MessageRequest { Content = url, Embed = embed }); + await _rest.CreateMessage(logChannelId.Value, new MessageRequest { Content = url, Embeds = new[] { embed } }); } private async Task GetAndCheckLogChannel(MessageContext ctx, Message trigger, diff --git a/PluralKit.Bot/Utils/ContextUtils.cs b/PluralKit.Bot/Utils/ContextUtils.cs index d26ef1ec..4cfd4597 100644 --- a/PluralKit.Bot/Utils/ContextUtils.cs +++ b/PluralKit.Bot/Utils/ContextUtils.cs @@ -174,7 +174,7 @@ public static class ContextUtils // Edit the embed with the new page var embed = await MakeEmbedForPage(currentPage); - await ctx.Rest.EditMessage(msg.ChannelId, msg.Id, new MessageEditRequest { Embed = embed }); + await ctx.Rest.EditMessage(msg.ChannelId, msg.Id, new MessageEditRequest { Embeds = new[] { embed } }); } } catch (TimeoutException)