discord-api-docs icon indicating copy to clipboard operation
discord-api-docs copied to clipboard

Permissions in audit log gateway event are serialized as numbers instead of strings

Open Tmpod opened this issue 7 months ago • 2 comments

Description

The docs state the following about permissions:

Permissions are stored in a variable-length integer serialized into a string, and are calculated using bitwise operations. [...] In API v8 and above, all permissions are serialized as strings, including the allow and deny fields in overwrites. [...] In API v6 (now deprecated), the permissions, allow, and deny fields in roles and overwrites are still serialized as a number

However, when receiving GUILD_AUDIT_LOG_ENTRY_CREATE events, these fields do come as integers.

This didn't seem to be the case before (I'm only noticing these errors on my bot now, at least), but I haven't tested enough to see if it's an audit log only thing.

Steps to Reproduce

  1. Change a role's permissions for a channel
  2. Receive a payload like this:
{"t":"GUILD_AUDIT_LOG_ENTRY_CREATE","s":17,"op":0,"d":{"user_id":"","target_id":"","options":{"type":"0","role_name":"","id":""},"id":"","changes":[{"new_value":"","key":"id"},{"new_value":0,"key":"type"},{"new_value":1024,"key":"allow"},{"new_value":0,"key":"deny"}],"action_type":13,"guild_id":""}}

(redacted IDs and role name)

Expected Behavior

Permissions should come serialized as strings.

Current Behavior

Permissions come serialized as numbers.

Screenshots/Videos

No response

Client and System Information

Kord Linux 64-bit

Tmpod avatar Jan 11 '24 16:01 Tmpod

https://github.com/discord/discord-api-docs/issues/6493 related (most likely) issue

Misha-133 avatar Jan 11 '24 16:01 Misha-133

Missed that, interesting bug :) Thanks!

Tmpod avatar Jan 11 '24 21:01 Tmpod