TypeError: message.guild.channels.find(...).then is not a function(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 不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:TypeError: message.guild.channels.find(...).then 不是函数


- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- Flexslider 箭头未正确显示 2022-01-01
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
- 400或500级别的HTTP响应 2022-01-01
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- Fetch API 如何获取响应体? 2022-01-01
- 失败的 Canvas 360 jquery 插件 2022-01-01
- addEventListener 在 IE 11 中不起作用 2022-01-01
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01