Discord.JS 尝试更新 VoiceChannel 时出现的奇怪问题

时间:2021-07-16 13:53:23

标签: javascript node.js discord.js bots

所以我收到错误“类型:值“声音”不是整数。”尝试更新语音通道名称时,但仅在 Ubuntu 上。 message.guild.channels.cache.get('863162796262031410').setName('testing')

请注意,这在 Ubuntu 上发生,但在 Windows 上运行良好

如果有人能提供一些见解,将不胜感激。

Uncaught Promise Error:  DiscordAPIError: Invalid Form Body
 type: Value "voice" is not int.
     at RequestHandler.execute (/home/NodeJS/node_modules/discord.js/src/rest/RequestHandler.js:152:13)
     at processTicksAndRejections (node:internal/process/task_queues:93:5)
     at async RequestHandler.push (/home/NodeJS/node_modules/discord.js/src/rest/RequestHandler.js:37:14)
     at async VoiceChannel.edit (/home/NodeJS/node_modules/discord.js/src/structures/GuildChannel.js:357:21) {
   method: 'patch',
   path: '/channels/863162796262031410',
   code: 50035,
   httpStatus: 400
 } 

1 个答案:

答案 0 :(得分:0)

您可以做到这一点并且行之有效的方法是:

选项一

const voiceChannel = message.guild.channels.resolve('channel_id')
voiceChannel.setName('new_channel_name');

选项 2

const voiceChannel = message.guild.channels.resolve('channel_id');
voiceChannel.edit({
    name: 'testing',
})