andersfylling / disgord

Go module for interacting with the documented Discord's bot interface; Gateway, REST requests and voice
BSD 3-Clause "New" or "Revised" License
502 stars 71 forks source link

chore: allow CreateInteractionResponse.Data to continue being nil #479

Closed beachasaurus-rex closed 2 years ago

beachasaurus-rex commented 2 years ago

Description

Previously in v0.33.0, InteractionResponse.Data could be nil, which worked for interaction response types InteractionCallbackUpdateMessage and InteractionCallbackDeferredUpdateMessage, which do not need to send data to discord in the interaction response; however, interaction responses that actually created messages with files were not supported.

In v0.34.0, that was alleviated; however now, CreateInteractionResponse.Data must not be nil in order for CreateInteractionResponse.prepare() to function properly, so this broke for interaction responses that don't need to send data. I added a section to CreateInteractionResponse.prepare() that returns the data necessary for CreateInteractionResponse.Data == nil to work for interaction types as before.

Edit: Apparently, I misunderstood how the CreateInteractionResponse.Data gets used by discord for interaction response types InteractionCallbackUpdateMessage and InteractionCallbackDeferredUpdateMessage (i.e. me definitely overthinking it). However, I still think it makes sense to allow CreateInteractionResponse.Data to be nil when being sent since that conforms more with discord's docs.

If you take a look at the discord documentation on the interaction response structure, data is optional, so I think it makes sense if support for CreateInteractionResponse.Data being nil continues.

Breaking Change?

no

Benchmarks

Checklist: