Skip to content

Commit

Permalink
fix message reference bug
Browse files Browse the repository at this point in the history
  • Loading branch information
krisppurg committed Aug 6, 2024
1 parent 91f529c commit 8a570f9
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions dimscord/restapi/message.nim
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,18 @@ proc sendMessage*(api: RestApi, channel_id: string;
"tts": tts,
}
if message_reference.isSome:
payload["message_reference"] = %*{
"fail_if_not_exists":message_reference.get.fail_if_not_exists.get true
var mf = %*{
"type": int message_reference.get.kind,
"fail_if_not_exists":message_reference.get.fail_if_not_exists.get true
}
if message_reference.get.channel_id.isSome:
mf["channel_id"] = %message_reference.get.channel_id.get
if message_reference.get.message_id.isSome:
mf["message_id"] = %message_reference.get.message_id.get
if message_reference.get.guild_id.isSome:
mf["guild_id"] = %message_reference.get.guild_id.get

payload["message_reference"] = mf

if sticker_ids.len > 0: payload["sticker_ids"] = %sticker_ids
if embeds.len > 0: payload["embeds"] = %embeds
Expand All @@ -37,7 +46,7 @@ proc sendMessage*(api: RestApi, channel_id: string;
payload["poll"] = %poll.get
payload["poll"]["layout_type"] = %int(poll.get.layout_type)
if enforce_nonce.isSome: payload["enforce_nonce"] = %enforce_nonce.get
payload.loadOpt(allowed_mentions, nonce, message_reference)
payload.loadOpt(allowed_mentions, nonce)

if components.len > 0:
payload["components"] = newJArray()
Expand Down

0 comments on commit 8a570f9

Please sign in to comment.