Discord has a Spotify integration that allows you to send rich embed messages which allow other people who have connected their Spotify account to listen along with you. The discoverability of these isn't great so in the Party Corgi Network Discord server we've implemented bot functionality to automatically pin these messages to the
#listening-party channel as seen below.
We do this using Rust and Serenity. Serenity's EventHandler trait can be used to implement a function that gets called whenever a new message is sent. The key point here is that
Messages have kinds, which represent what kind of message it is and that Spotify has it's own
MessageActivityKind::LISTEN value to identify relevant messages.
Using this and the useful helpers on
Message, we can
.pin() the message in question automatically whenever someone posts a listening party.
We don't return any useful values although we'll add error handling messages as well as adding the event information to our Honeycomb instrumentation in the future.