TypeError:message.guild.channels.find(...).那么不是一个函数 [英] TypeError: message.guild.channels.find(...).then is not a function

查看:26
本文介绍了TypeError:message.guild.channels.find(...).那么不是一个函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我从下面的代码中得到的错误: TypeError:message.guild.channels.find(...).则不是函数

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.

查找不会返回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(...).那么不是一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆