简体   繁体   English

没有头像的 Discord.js 用户会导致机器人崩溃

[英]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.改用User#displayAvatarURL() ,这将处理默认头像而不是引发错误。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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