简体   繁体   中英

Discord.js users without avatars crash the bot

Hello I have a very serious problem, if someone uses commands in my bot his avatar shows up but people who do not have an avatar after using the command crash the bot because the bot can not send their avatar which causes errors, I hope this is enough code (it is a footer with embed)

${message.author.avatarURL({ size: 1024, dynamic: true })}

Simple fix. Use User#displayAvatarURL() instead, This will handle default avatars instead of throwing an error.

${message.author.displayAvatarURL({ size: 1024, dynamic: true })}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM