admin管理员组文章数量:1291024
I just want to use my Discord.JS bot to get the first attachment in a message (MessageAttatchment object), simply put. I have already tried this, but it just seems to crash immediately.
var Attachment = (message.attachments)
if (Attatchment){
console.log( Attatchment.array()[0] )
console.log( Attatchment.array()[0].url )
}
The crash might not be due to this, it could be due to relevant code surrounding the area, but this is not a problem, since if I find a solution, that relevant code will bee irrelevant.
I just want to use my Discord.JS bot to get the first attachment in a message (MessageAttatchment object), simply put. I have already tried this, but it just seems to crash immediately.
var Attachment = (message.attachments)
if (Attatchment){
console.log( Attatchment.array()[0] )
console.log( Attatchment.array()[0].url )
}
The crash might not be due to this, it could be due to relevant code surrounding the area, but this is not a problem, since if I find a solution, that relevant code will bee irrelevant.
Share Improve this question asked Dec 19, 2018 at 2:40 Wasabi ThumbsWasabi Thumbs 3451 gold badge3 silver badges8 bronze badges 2-
2
You seem to have misspelt
Attachment
in most of your code. – Nick Commented Dec 19, 2018 at 2:47 - Well, that might fix things...! Let me try that! – Wasabi Thumbs Commented Dec 20, 2018 at 3:41
2 Answers
Reset to default 4I know this is 2 years old, but I think I might of found the problem. You seem to have mistyped the variable attachment, instead of attachment, you types in attatchment.
This is how the code should look like. Although, not sure if there may be more errors, this code snippet just fixes the typos.
var Attachment = (message.attachments)
if (Attachment){
console.log( Attachment.array()[0] )
console.log( Attachment.array()[0].url )
}
There is a ment on it that does point it out, but they haven't considered it as an answer.
Tip: Always try to check for typos in your code, that is the most mon problem. Use the Find tool in a text editor to help find typos.
There's a
Attachment
class in discord.js. So, it will create a conflict between variables definitions. You should rename it to something else!
本文标签: javascriptDiscordJS Get First Attachment in MessageStack Overflow
版权声明:本文标题:javascript - Discord.JS Get First Attachment in Message - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741504060a2382213.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论