Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/423.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在disccord.js中获取/获取最近创建的频道?_Javascript_Discord.js - Fatal编程技术网

Javascript 如何在disccord.js中获取/获取最近创建的频道?

Javascript 如何在disccord.js中获取/获取最近创建的频道?,javascript,discord.js,Javascript,Discord.js,我正在制作一个机器人,它执行LTM命令!创造。它应该做的是创建一个它所做的频道。然后,在命令中设置的时间之后,应该转到专用通道。我做了所有的事情,但我不知道如何获得刚刚创建的频道。这是它的命令 const name = message.content.replace('LTM!create ', '') message.guild.channels .create(name, { type: 'text'

我正在制作一个机器人,它执行LTM命令!创造。它应该做的是创建一个它所做的频道。然后,在命令中设置的时间之后,应该转到专用通道。我做了所有的事情,但我不知道如何获得刚刚创建的频道。这是它的命令

        const name = message.content.replace('LTM!create ', '')


        message.guild.channels
            .create(name, {
                type: 'text',
            })
            .then((channel) => {
                const categoryId = '850420491915493387'
                channel.setParent(categoryId)
            })


        console.log(message.author)
        const Embed = new Discord.MessageEmbed()
            .setTitle('LTM created!')
            .setFooter('created by' + " " + message.author.username)
            .setColor('#FFD700')

        message.channel.send(Embed)


        setTimeout(() => {
            const private_channel = client.channels.cache.get("CHANNEL_ID");
            private_channel.updateOverwrite(message.guild.id, {
                SEND_MESSAGES: false
            })


        }, 10000)
    })```
与通道解析。您可以使用
async
/
wait
或将代码放入
中。然后()
调用访问此频道

等待
/
异步

const newChannel=wait message.guild.channels.create(名称,{type:“text”});
newChannel.updateOverwrite(message.guild.id{
发送消息:false
});
.then()

message.guild.channels.create(名称,{type:“text”})。然后((newChannel)=>{
newChannel.updateOverwrite(message.guild.id{
发送消息:false
});
});

我就是这么做的,pastebin.com/LFySR2us。但是我得到了一个错误,无法读取undefined@theusafHmm的属性'updateOverwrite'。我真的不知道它为什么这么做。我刚刚尝试了那个精确的代码,它工作正常。也许你不能在setTimeout中使用它?可能是。这对我来说没有意义,但是试着把它从setTimeout中去掉,看看它是否仍然会产生那个错误