diff --git a/PluralKit.Core/Dispatch/DispatchModels.cs b/PluralKit.Core/Dispatch/DispatchModels.cs index dc389694..20a7170b 100644 --- a/PluralKit.Core/Dispatch/DispatchModels.cs +++ b/PluralKit.Core/Dispatch/DispatchModels.cs @@ -42,7 +42,6 @@ namespace PluralKit.Core public DispatchEvent Event; public string SystemId; public string? EntityId; - public ulong? GuildId; public string SigningToken; public JObject? EventData; } @@ -57,7 +56,6 @@ namespace PluralKit.Core o.Add("signing_token", data.SigningToken); o.Add("system_id", data.SystemId); o.Add("id", data.EntityId); - o.Add("guild_id", data.GuildId.ToString()); o.Add("data", data.EventData); return new StringContent(JsonConvert.SerializeObject(o), Encoding.UTF8, "application/json"); diff --git a/PluralKit.Core/Dispatch/DispatchService.cs b/PluralKit.Core/Dispatch/DispatchService.cs index ac29c9ec..7a17f37e 100644 --- a/PluralKit.Core/Dispatch/DispatchService.cs +++ b/PluralKit.Core/Dispatch/DispatchService.cs @@ -174,8 +174,7 @@ namespace PluralKit.Core data.Event = DispatchEvent.UPDATE_SYSTEM_GUILD; data.SigningToken = system.WebhookToken; data.SystemId = system.Uuid.ToString(); - data.GuildId = guild_id; - data.EventData = patch.ToJson(memberRef); + data.EventData = patch.ToJson(memberRef, guild_id); _logger.Debug("Dispatching webhook for system {SystemId} in guild {GuildId}", system.Id, guild_id); await DoPostRequest(system.Id, system.WebhookUrl, data.GetPayloadBody()); @@ -194,8 +193,7 @@ namespace PluralKit.Core data.SigningToken = system.WebhookToken; data.SystemId = system.Uuid.ToString(); data.EntityId = member.Uuid.ToString(); - data.GuildId = guild_id; - data.EventData = patch.ToJson(); + data.EventData = patch.ToJson(guild_id); _logger.Debug("Dispatching webhook for member {MemberId} (system {SystemId}) in guild {GuildId}", member.Id, system.Id, guild_id); await DoPostRequest(system.Id, system.WebhookUrl, data.GetPayloadBody()); diff --git a/PluralKit.Core/Models/PKSystem.cs b/PluralKit.Core/Models/PKSystem.cs index e743c9fc..ca4da41b 100644 --- a/PluralKit.Core/Models/PKSystem.cs +++ b/PluralKit.Core/Models/PKSystem.cs @@ -104,7 +104,7 @@ namespace PluralKit.Core { // todo: should this be moved to a different JSON model? o.Add("webhook_url", system.WebhookUrl); - o.Add("webhook_token", system.WebhookToken); + // o.Add("webhook_token", system.WebhookToken); var p = new JObject(); diff --git a/PluralKit.Core/Models/Patch/MemberGuildPatch.cs b/PluralKit.Core/Models/Patch/MemberGuildPatch.cs index 9b463128..60a5e7ef 100644 --- a/PluralKit.Core/Models/Patch/MemberGuildPatch.cs +++ b/PluralKit.Core/Models/Patch/MemberGuildPatch.cs @@ -39,10 +39,12 @@ namespace PluralKit.Core return patch; } - public JObject ToJson() + public JObject ToJson(ulong guild_id) { var o = new JObject(); + o.Add("guild_id", guild_id.ToString()); + if (DisplayName.IsPresent) o.Add("display_name", DisplayName.Value); diff --git a/PluralKit.Core/Models/Patch/SystemGuildPatch.cs b/PluralKit.Core/Models/Patch/SystemGuildPatch.cs index 366ac033..3be8abbf 100644 --- a/PluralKit.Core/Models/Patch/SystemGuildPatch.cs +++ b/PluralKit.Core/Models/Patch/SystemGuildPatch.cs @@ -56,10 +56,12 @@ namespace PluralKit.Core return patch; } - public JObject ToJson(string memberRef) + public JObject ToJson(string memberRef, ulong guild_id) { var o = new JObject(); + o.Add("guild_id", guild_id.ToString()); + if (ProxyEnabled.IsPresent) o.Add("proxying_enabled", ProxyEnabled.Value); diff --git a/docs/content/api/dispatch.md b/docs/content/api/dispatch.md index a37070eb..b1749f6b 100644 --- a/docs/content/api/dispatch.md +++ b/docs/content/api/dispatch.md @@ -29,11 +29,8 @@ PluralKit will send invalid requests to your endpoint, with `PING` event type, o |signing_token|string|the [signing token](#security) for your webhook URL| |system_id|string|the system ID associated with this event| |id|string?|the ID of the entity referenced by the event (can be a system/member/group/switch/Discord user ID)| -|guild_id|snowflake?*|the ID of the guild where this event occurred| |data|object?|event data| -\* only sent for guild settings update events. in message create events, the guild id is sent in the `data` object as `guild` key - ## Dispatch Events |name|description|content of `data` object|notes| diff --git a/docs/content/api/models.md b/docs/content/api/models.md index fef43bc5..e1319b76 100644 --- a/docs/content/api/models.md +++ b/docs/content/api/models.md @@ -104,6 +104,7 @@ Every PluralKit entity has two IDs: a short (5-character) ID and a longer UUID. |key|type|notes| |---|---|---| +|guild_id|snowflake|only sent if the guild ID isn't already known (in dispatch payloads)| |proxying_enabled|boolean|| |autoproxy_mode|autoproxy mode enum|| |autoproxy_member|?string|must be set if autoproxy_mode is `member`| @@ -123,5 +124,6 @@ Every PluralKit entity has two IDs: a short (5-character) ID and a longer UUID. |key|type|notes| |---|---|---| +|guild_id|snowflake|only sent if the guild ID isn't already known (in dispatch payloads)| |display_name|?string|100-character limit| |avatar_url|?string|256-character limit, must be a publicly-accessible URL|