在特定类别discord.js中创建频道

发布于 2025-02-08 21:30:52 字数 218 浏览 1 评论 0原文

如何在特定类别中创建频道? 我尝试了一下:

reaction.message.guild.channels.create(`ticket-${user.name}`).setParent(config.ticket_categorie)

但是它在没有任何类别的情况下在顶部创建了频道。

How can I create a channel in specific category?
I tried this:

reaction.message.guild.channels.create(`ticket-${user.name}`).setParent(config.ticket_categorie)

But it created the channel at the top without any category.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

风和你 2025-02-15 21:30:52

您可以创建一个频道,然后将其分配给x类别:

reaction.message.guild.channels.create("CHANNEL_NAME")
  .then(channel => {
    channel.setParent("CATEGORY_ID");
  })
  .catch(err => {
    console.log(err)
  });

You can create a channel, and then assign it to x category like this:

reaction.message.guild.channels.create("CHANNEL_NAME")
  .then(channel => {
    channel.setParent("CATEGORY_ID");
  })
  .catch(err => {
    console.log(err)
  });
唱一曲作罢 2025-02-15 21:30:52

我想,如果您在创建和使用的setparent中使用一个。在返回创建函数(即通道)的返回中,则将应用类别。这个问题提到了这一点,以及一种将其与第12版LIB一起使用的方法。另外,您应该在setParent上使用类别ID,似乎您正在使用类别的名称,这可能是问题所在。

添加频道

,根据此其他链接,您可以使用<< strong> parent 选项作为第二个参数传递到创建函数的第二个参数,以提供通道所属的类别ID:使用parent选项与创建

I guess that if you use a .then in create and used setParent on the return of the create function (which is the channel) the category would be applied. This question mentions this, as well as a way of using it with the 12th version of the lib. Also you should use the category id at setParent, it seems you're using the name of the category, which could be the problem.

add channel to category

And according to this other link, you could use the parent option passed as the second parameter to the create function to provide a category id that the channel belongs: Use parent option with create

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文