Doing something each time a user signs on, reading information from OAuth2 signup, and updating user avatars

Hey,

I’ve been asked to write a plugin for Discourse to better integrate with a specific community’s systems. I’m trying to write a plugin that automatically changes a user’s avatar and username depending on specific information that the Discord OAuth2 system should provide (mainly, the users discord ID).

Mainly, I’m curious about how:

  • You can have ruby listen to the “event” where a user joins the forum via Discord (the only allowed sign on method for the forum is Discord)
  • How to get the information about the user’s discord id
  • How to manually update the user’s avatar & name

I haven’t been able to find previous topics/documentation for this, but I may have just been looking in the wrong place. If so, please direct me to the correct topic/link.

Thanks in advance!
Sxribe