#SocketGuild.GetUser returns null after bot restart

1 messages · Page 1 of 1 (latest)

sturdy moth
#

Hey so I have a bot that uses modals and buttons to interact with banned users. If we ban a user it sends them a DM to join another server (appeal server) before banning them. Whenever an appeal is submitted through the bot it sends an embed to the main server appeal channel. If its approved or denied I want to automatically kick the user from the appeal discord server they joined. I'm using SocketGuild.GetUser() to get the user from the appeal server. This works as long as the user joined the server while the bot was running. If they submit an appeal and the bot crashes or gets restarted, SocketGuild.GetUser returns null. Both the guild and user id have values, but the user returns null. Any idea why when the bot restarts after the user joined the appeal server they return null? Here is the part of the code that handles it.

solid vigil
#

you need to cache users on bot startup

#

add GuildMembers intent if you haven't already
& do AlwaysDownloadUsers = true in DiscordSocketConfig

sturdy moth
#

wow can't believe solution was that easy, thank you so much!