【问题标题】:How to get id of created category?如何获取已创建类别的 id?
【发布时间】:2021-04-29 17:03:36
【问题描述】:

如何从新创建的类别中获取类别 ID?

message.guild.channels.create(`???? | ${args[0]}`, { type: 'category' });

【问题讨论】:

    标签: javascript discord discord.js bots


    【解决方案1】:

    .create() 方法返回一个Promise。 从这个意义上说,我们可以在异步函数中等待它的创建,或者简单地使用.then() 函数将新创建的类别作为一个对象,并返回它的 id。

    /**
    * const category = await message.guild.channels.create(`? | ${args[0]}`, { type: 'category' });
    * console.log(category.id)
    */
    message.guild.channels.create(`? | ${args[0]}`, { type: 'category' })
    .then(category => console.log(category.id));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-08-14
      • 2011-07-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-05
      • 2021-07-03
      相关资源
      最近更新 更多