【发布时间】:2022-07-19 05:30:53
【问题描述】:
我刚刚将我的 discord.js 从 v13 更新到 v14,有很多错误。
意图错误:
const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
],
});
// Intents.FLAGS.GUILDS,
// ^
//
// TypeError: Cannot read properties of undefined (reading 'FLAGS')
const client = new Client({
intents: ['GUILDS', 'GUILD_MEMBERS', 'GUILD_MESSAGES'],
});
// throw new RangeError(ErrorCodes.BitFieldInvalid, bit);
//
// RangeError [BitFieldInvalid]: Invalid bitfield flag or number: GUILDS.
interactions 的错误:
if (interaction.isCommand()) {}
// TypeError: interaction.isCommand is not a function
if (interaction.isButton()) {}
// TypeError: interaction.isButton is not a function
if (interaction.isAutocomplete()) {}
// TypeError: interaction.isAutocomplete is not a function
if (interaction.isMessageComponent()) {}
// TypeError: interaction.isMessageComponent is not a function
if (interaction.isModalSubmit()) {}
// TypeError: interaction.isModalSubmit is not a function
渠道错误:
if (message.channel.isText()) {}
// TypeError: channel.isText is not a function
if (message.channel.isVoice()) {}
// TypeError: channel.isVoice is not a function
if (message.channel.isDM()) {}
// TypeError: channel.isDM is not a function
if (message.channel.isCategory()) {}
// TypeError: channel.isCategory is not a function
构建器和嵌入错误:
const embed = new MessageEmbed();
// const embed = new MessageEmbed();
// ^
//
// TypeError: MessageEmbed is not a constructor
const button = new MessageButton();
// const button = new MessageButton();
// ^
//
// TypeError: MessageButton is not a constructor
const actionRow = new MessageActionRow();
// const actionRow = new MessageActionRow();
// ^
//
// TypeError: MessageActionRow is not a constructor
const selectMenu = new MessageSelectMenu();
// const selectMenu = new MessageSelectMenu();
// ^
//
// TypeError: MessageSelectMenu is not a constructor
const textInput = new TextInputComponent();
// const textInput = new TextInputComponent();
// ^
//
// TypeError: TextInputComponent is not a constructor
【问题讨论】:
标签: javascript discord discord.js