如何获取频道ID?

时间:2020-08-28 15:30:58

标签: discord.js

因此,我有一些代码可以创建一个临时通道,我想要它,因此当它打开时,我可以将嵌入发送到临时通道。这是当前的脚本:

bot.on('message', msg =>{
      if(msg.content === (`${prefix}tempchannel`)) {
            var server = msg.guild;
            var name = msg.author.username;

            server.channels.create(`${name} temp channel.`, { reason: `Temp channel for ${name}` })

            msg.channel.send('Created a temp channel for you! Check your unreads.')

        }})```
 Could someone help me please?

1 个答案:

答案 0 :(得分:0)

GuildChannelManager.create()返回所创建频道的承诺。

server.channels
  .create(`${name}-temp-channel`, { reason: `Temp channel for ${name}` })
  .then((channel) => channel.send("This is a new channel")); // channel callback