本文介紹了TypeError: message.guild.channels.find(...).then 不是函數的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
這是我從下面的代碼中得到的錯誤:TypeError: message.guild.channels.find(...).then is not a function
This is the error I am getting from my code below: TypeError: message.guild.channels.find(...).then is not a function
message.guild.channels.find('name', `${message.author.username}-oda`).then(c => {
channel.overwritePermissions(message.member, {
CONNECT: true,
VIEW_CHANNEL: true
});
message.channel.send('All Ok.')
})
推薦答案
由于您對此答案發表評論說您使用的是 discord.js v11 而不是 v12,因此我正在根據以下 TipakA 的評論編輯我的答案.
Since you commented on this answer saying you're using discord.js v11 and not v12 I am editing my answer according to tipakA's comment below.
find
不返回 Promise,因此您不能在其上使用 then
.
find
does not return a Promise, so you cannot usethen
on it.
您的解決方案是:
const channel = message.guild.channels.find('name', `${message.author.username}-oda`);
channel.overwritePermissions(message.member, {
CONNECT: true,
VIEW_CHANNEL: true
});
message.channel.send('All Ok.');
這篇關于TypeError: message.guild.channels.find(...).then 不是函數的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!