TypeError: message.guild.channels.find(…).then is not a function

元气小坏坏 提交于 2021-02-11 17:23:12

问题


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.')
        })

回答1:


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 does not return a Promise, so you cannot use then on it.

Your solution would be:

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.');


来源:https://stackoverflow.com/questions/61193433/typeerror-message-guild-channels-find-then-is-not-a-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!