Skip to content

Commit

Permalink
fix slash command contexts not working and deprecate guild_subscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
krisppurg committed Aug 14, 2024
1 parent 8a570f9 commit d176db0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
15 changes: 11 additions & 4 deletions dimscord/gateway.nim
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,7 @@ proc identify(s: Shard) {.async, used.} =
"browser": &libName,
"device": &libName
}),
"compress": &defined(discordCompress),
"guild_subscriptions": &s.client.guildSubscriptions
"compress": &defined(discordCompress)
}

if s.client.max_shards > 1:
Expand Down Expand Up @@ -735,7 +734,7 @@ proc startSession*(discord: DiscordClient,
## `giGuilds, giGuildMessages, giDirectMessages, giGuildVoiceStates, giMessageContent`
##
## - `large_threshold` The number that would be considered a large guild (50-250).
## - `guild_subscriptions` Whether or not to receive presence_update, typing_start events.
## - `guild_subscriptions` **DEPRECATED** Whether or not to receive presence_update, typing_start events.
## - `autoreconnect` Whether the client should reconnect whenever a network error occurs.
## - `max_message_size` Max message JSON size (MESSAGE_CREATE) the client should cache in bytes.
## - `large_message_threshold` Max message limit (MESSAGE_CREATE)
Expand All @@ -754,7 +753,15 @@ proc startSession*(discord: DiscordClient,
log("Warning: giMessageContent not specified this might cause issues.")

discord.largeThreshold = large_threshold
discord.guildSubscriptions = guild_subscriptions
if guild_subscriptions:
log("Warning: guild_subscriptions is deprecated.")
discord.intents = discord.intents + {
giGuildMessageTyping,
giDirectMessageTyping,
giGuildPresences
}
discord.guildSubscriptions = true

discord.max_shards = max_shards.get(-1)
discord.gatewayVersion = gateway_version
# when defined(discordv8):
Expand Down
4 changes: 4 additions & 0 deletions dimscord/objects.nim
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,10 @@ proc `%%*`*(a: ApplicationCommand): JsonNode =
"name": a.name,
"type": commandKind.ord
}
if a.contexts.isSome:
result["contexts"] = %a.contexts.get.mapIt(ord it)
if a.integration_types.isSome:
result["integration_types"] = %a.integration_types.get.mapIt(ord it)
if a.nsfw.isSome: result["nsfw"] = %*a.nsfw.get
if a.name_localizations.isSome:
result["name_localizations"] = %*a.name_localizations
Expand Down

0 comments on commit d176db0

Please sign in to comment.