TypeError: message.guild.channels.find(...).then 不是函数

编程入门 行业动态 更新时间:2024-10-21 14:33:50
本文介绍了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 use then 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 不是函数

本文发布于:2023-10-30 04:17:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1541738.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:函数   message   TypeError   guild   find

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!