You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Discord机器人memberinfo命令报错:TypeError: files?.map不是函数

修复Discord.js memberinfo命令的TypeError错误

错误原因

问题确实出在你定位的代码行:

await interaction.editReply({embeds: [Embed], files:{imageAttachment}});

Discord.js要求files参数传入AttachmentBuilder实例的数组,但你这里传了一个对象{imageAttachment},对象没有map方法,导致内部处理时抛出TypeError。

修复方法

将files的值改为数组形式,直接传入创建好的imageAttachment:

await interaction.editReply({embeds: [Embed], files: [imageAttachment]});

补充说明

在Discord.js v14及后续版本中,无论是发送消息还是编辑交互回复,files参数都必须是数组类型——即使只有单个附件,也需要用数组包裹,这是Discord API的规范要求,确保附件能被正确解析和处理。

内容的提问来源于stack exchange,提问作者MrAplex

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.27 20:42:18