【问题标题】:Bot not creating channel - Discord.js机器人没有创建频道 - Discord.js
【发布时间】:2023-04-10 20:04:01
【问题描述】:

每当我尝试使用我的机器人创建频道时,它都不会创建频道。

let name = 'DING'
message.guild.createChannel(name, 'text')

它发送错误“类型:值“文本”不是 int。”有了这个,我假设文本必须变成一个整数,但是这段代码在过去有效,并创建了一个具有该名称的文本通道。甚至文档也显示了我正在做的确切事情。怎么了?

【问题讨论】:

    标签: javascript discord discord.js


    【解决方案1】:

    查看discord.js.org 的文档,您会发现create channel method 的文档不是您想的那样。

    我想你会想要的是:

    let name = 'DING'
    message.guild.createChannel(name, { type: 'text' })
      .then(console.log)
      .catch(console.error);
    

    别忘了.catch(),这样你就知道promise是否被拒绝并发生错误。

    【讨论】:

    • 这给了我一个类似的错误:type: Value "{u'type': u'text'}" is not int.
    • 奇怪...你能分享更多你的代码吗?我感觉你的代码出了点问题
    • 这是我的 github 存储库 - 所需信息在 bot.js 中 - 我将在这里分享一些代码,但如果信息似乎不够,您可以随意查看:@ 987654323@我认为这是必要的信息:client.on('message', message => { if (message.content.toLowerCase().includes('however')) { let name = 'Conditioned' let guild = message.guild guild.createChannel(name, { type: 'text' }) .then(console.log) .catch(console.error) } }我认为这可能是Discord.js版本的问题。
    • 听起来很可能,我似乎看不出该代码块有任何问题。
    猜你喜欢
    • 2021-11-05
    • 2021-12-08
    • 2020-07-17
    • 2020-10-24
    • 2020-08-09
    • 2021-01-06
    • 2017-03-18
    • 2019-01-31
    • 2023-03-27
    相关资源
    最近更新 更多