调用脚本时出错。你可以寻求帮助吗?
下面,我粘贴代码和错误。
let chn = client.channels.find(channel => channel.id === '717019301357420554');
let msg = chn.fetchMessage('717369584801546273');
msg.edit(embedit);
TypeError: msg.edit is not a function
答案 0 :(得分:0)
这是v11吗?
尽管获取内容是异步的,所以您需要等待msg解析。
https://discord.js.org/#/docs/main/11.1.0/class/TextChannel?scrollTo=fetchMessage
这是您可以采取的方法:
第一个是使用await,它需要在异步函数中
let chn = client.channels.find(channel => channel.id === '717019301357420554');
let msg = await chn.fetchMessage('717369584801546273');
msg.edit(embedit);
第二个是.then
let chn = client.channels.find(channel => channel.id === '717019301357420554');
chn.fetchMessage('717369584801546273').then(msg => msg.edit(embedit));
如果要将其保存在变量中
let chn = client.channels.find(channel => channel.id === '717019301357420554');
let msg;
chn.fetchMessage('717369584801546273').then(m => msg = m);
//note you will have to wait for the promise to resolve to use
//the variable msg correctly
//any code beyond this isn't guranteed to have access to
这些是一些不好的变量名称,请不要使用chn
而不是channel
和embedit
=> embEdit
之类的缩写。但是取决于你