Kraigie / nostrum

Elixir Discord Library
https://kraigie.github.io/nostrum/
MIT License
587 stars 125 forks source link

Documentation improvement: Message nonce #539

Open jchristgit opened 2 months ago

jchristgit commented 2 months ago

Our message struct has a lot of fields, and most of them are just a waste of memory, processing power, and my energy.

One field whose purpose, besides wasting memory, processing power and my energy, is unclear to me, is the nonce field of the message struct. The documentation helpfully states:

Validates if a message was sent

As a user, this explains nothing. It can be a string or it can be nil. If it is a string, does it contain a written, GPG-signed confirmation from Jason Citron that the message was successfully sent? Does he manually sign these by hand, or does he have a bot in the Gateway that does it for him? Is it instead a notice of delivery stamped off by Craig's favourite cat "I don't think favourites"? What can users expect from this? Is this even something that we should surface to the user?

jb3 commented 2 months ago

In an upcoming Discord API change, the enforcement of this parameter will become mandatory:

image

I think all we really need to do is on an outbound message attach a random string, up to 25 characters, or a snowflake that we generate. We don't need to store this, we just need to attach it to outbound messages. Of course, we should also let users override this if they desire.

We should set enforce_nonce to true to adopt the enforcement behavior before it becomes the default.