Trying to make a new discord bot with the newest version of discord.js, but it has problems with its own library.
My other bots work fine with an older version but I'd like to use the newer one. I just don't know why it's not working
This is the only code I've written myself so far
import { Client, Intents } from "discord.js";
const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MEMBERS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILD_MESSAGE_REACTIONS
]
});
It says it has found 4 errors. I just don't know what to do to fix them
node_modules/discord.js/typings/index.d.ts:1503:42 - error TS2344: Type 'MappedInteractionTypes<Cached>[T]' does not satisfy the constraint 'ModalSubmitInteraction<CacheType> | MessageComponentInteraction<CacheType>'.
Type 'MessageComponentInteraction<If<Cached, "cached", CacheType>> | ButtonInteraction<If<Cached, "cached", CacheType>> | SelectMenuInteraction<...> | ModalSubmitInteraction<...>' is not assignable to type 'ModalSubmitInteraction<CacheType> | MessageComponentInteraction<CacheType>'.
Type 'ButtonInteraction<If<Cached, "cached", CacheType>>' is not assignable to type 'ModalSubmitInteraction<CacheType> | MessageComponentInteraction<CacheType>'.
Type 'ButtonInteraction<If<Cached, "cached", CacheType>>' is not assignable to type 'MessageComponentInteraction<CacheType>'.
Type 'MappedInteractionTypes<Cached>[T]' is not assignable to type 'MessageComponentInteraction<CacheType>'.
Type 'MessageComponentInteraction<If<Cached, "cached", CacheType>> | ButtonInteraction<If<Cached, "cached", CacheType>> | SelectMenuInteraction<...> | ModalSubmitInteraction<...>' is not assignable to type 'MessageComponentInteraction<CacheType>'.
Type 'ButtonInteraction<If<Cached, "cached", CacheType>>' is not assignable to type 'MessageComponentInteraction<CacheType>'.
Types of property 'channel' are incompatible.
Type 'CacheTypeReducer<If<Cached, "cached", CacheType>, GuildTextBasedChannel, GuildTextBasedChannel, GuildTextBasedChannel, TextBasedChannel>' is
not assignable to type 'GuildTextBasedChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'GuildTextBasedChannel'.
Type '[If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'GuildTextBasedChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["raw" | "cached"] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'GuildTextBasedChannel'.
Type '[If<Cached, "cached", CacheType>] extends ["raw" | "cached"] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'GuildTextBasedChannel'.
Type 'DMChannel | PartialDMChannel | NewsChannel | TextChannel | ThreadChannel | VoiceChannel' is not assignable to type 'GuildTextBasedChannel'.
Type 'DMChannel' is not assignable to type 'GuildTextBasedChannel'.
Type 'DMChannel' is missing the following properties from type 'ThreadChannel': archived, archivedAt, archiveTimestamp, _createdTimestamp, and 35 more.
Type '[If<Cached, "cached", CacheType>] extends ["raw" | "cached"] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'VoiceChannel'.
Type 'DMChannel | PartialDMChannel | NewsChannel | TextChannel | ThreadChannel | VoiceChannel' is not assignable to type 'VoiceChannel'.
Type 'DMChannel' is missing the following properties from type 'VoiceChannel': videoQualityMode, editable, speakable, nsfw, and 41 more.
Type '[If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'VoiceChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["raw" | "cached"] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'VoiceChannel'.
Type 'NewsChannel' is not assignable to type 'VoiceChannel'.
Type 'CacheTypeReducer<If<Cached, "cached", CacheType>, GuildTextBasedChannel, GuildTextBasedChannel, GuildTextBasedChannel, TextBasedChannel>' is not assignable to type 'VoiceChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'VoiceChannel'.
Type 'NewsChannel' is missing the following properties from type 'VoiceChannel': videoQualityMode, editable, speakable, setBitrate, and 8 more.
1503 } & MessageComponentCollectorOptions<MappedInteractionTypes<Cached>[T]>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/discord.js/typings/index.d.ts:1511:49 - error TS2344: Type 'MappedInteractionTypes<Cached>[T]' does not satisfy the constraint 'ModalSubmitInteraction<CacheType> | MessageComponentInteraction<CacheType>'.
Type 'MessageComponentInteraction<If<Cached, "cached", CacheType>> | ButtonInteraction<If<Cached, "cached", CacheType>> | SelectMenuInteraction<...> | ModalSubmitInteraction<...>' is not assignable to type 'ModalSubmitInteraction<CacheType> | MessageComponentInteraction<CacheType>'.
Type 'ButtonInteraction<If<Cached, "cached", CacheType>>' is not assignable to type 'ModalSubmitInteraction<CacheType> | MessageComponentInteraction<CacheType>'.
Type 'ButtonInteraction<If<Cached, "cached", CacheType>>' is not assignable to type 'MessageComponentInteraction<CacheType>'.
Type 'MappedInteractionTypes<Cached>[T]' is not assignable to type 'MessageComponentInteraction<CacheType>'.
Type 'MessageComponentInteraction<If<Cached, "cached", CacheType>> | ButtonInteraction<If<Cached, "cached", CacheType>> | SelectMenuInteraction<...> | ModalSubmitInteraction<...>' is not assignable to type 'MessageComponentInteraction<CacheType>'.
Type 'ButtonInteraction<If<Cached, "cached", CacheType>>' is not assignable to type 'MessageComponentInteraction<CacheType>'.
Types of property 'channel' are incompatible.
Type 'CacheTypeReducer<If<Cached, "cached", CacheType>, GuildTextBasedChannel, GuildTextBasedChannel, GuildTextBasedChannel, TextBasedChannel>' is
not assignable to type 'GuildTextBasedChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'GuildTextBasedChannel'.
Type '[If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'GuildTextBasedChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["raw" | "cached"] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'GuildTextBasedChannel'.
Type '[If<Cached, "cached", CacheType>] extends ["raw" | "cached"] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'GuildTextBasedChannel'.
Type 'DMChannel | PartialDMChannel | NewsChannel | TextChannel | ThreadChannel | VoiceChannel' is not assignable to type 'GuildTextBasedChannel'.
Type '[If<Cached, "cached", CacheType>] extends ["raw" | "cached"] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'VoiceChannel'.
Type 'DMChannel | PartialDMChannel | NewsChannel | TextChannel | ThreadChannel | VoiceChannel' is not assignable to type 'VoiceChannel'.
Type '[If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'VoiceChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["raw" | "cached"] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'VoiceChannel'.
Type 'NewsChannel' is not assignable to type 'VoiceChannel'.
Type 'CacheTypeReducer<If<Cached, "cached", CacheType>, GuildTextBasedChannel, GuildTextBasedChannel, GuildTextBasedChannel,
TextBasedChannel>' is not assignable to type 'VoiceChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'VoiceChannel'.
Type 'NewsChannel' is not assignable to type 'VoiceChannel'.
1511 } & MessageChannelComponentCollectorOptions<MappedInteractionTypes<Cached>[T]>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/discord.js/typings/index.d.ts:1518:35 - error TS2344: Type 'MappedInteractionTypes<Cached>[T]' does not satisfy the constraint 'Interaction<CacheType>'.
Type 'MessageComponentInteraction<If<Cached, "cached", CacheType>> | ButtonInteraction<If<Cached, "cached", CacheType>> | SelectMenuInteraction<...> | ModalSubmitInteraction<...>' is not assignable to type 'Interaction<CacheType>'.
Type 'MessageComponentInteraction<If<Cached, "cached", CacheType>>' is not assignable to type 'Interaction<CacheType>'.
Types of property 'channel' are incompatible.
Type 'CacheTypeReducer<If<Cached, "cached", CacheType>, GuildTextBasedChannel, GuildTextBasedChannel, GuildTextBasedChannel, TextBasedChannel>' is not assignable to type 'GuildTextBasedChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'GuildTextBasedChannel'.
Type '[If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'GuildTextBasedChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["raw" | "cached"] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'GuildTextBasedChannel'.
Type '[If<Cached, "cached", CacheType>] extends ["raw" | "cached"] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'GuildTextBasedChannel'.
Type 'DMChannel | PartialDMChannel | NewsChannel | TextChannel | ThreadChannel | VoiceChannel' is not assignable to type 'GuildTextBasedChannel'. Type '[If<Cached, "cached", CacheType>] extends ["raw" | "cached"] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'VoiceChannel'.
Type 'DMChannel | PartialDMChannel | NewsChannel | TextChannel | ThreadChannel | VoiceChannel' is not assignable to type 'VoiceChannel'.
Type '[If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'VoiceChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["raw" | "cached"] ? GuildTextBasedChannel : TextBasedChannel)'
is not assignable to type 'VoiceChannel'.
Type 'NewsChannel' is not assignable to type 'VoiceChannel'.
Type 'CacheTypeReducer<If<Cached, "cached", CacheType>, GuildTextBasedChannel, GuildTextBasedChannel, GuildTextBasedChannel, TextBasedChannel>' is not assignable to type 'VoiceChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'VoiceChannel'.
Type 'NewsChannel' is not assignable to type 'VoiceChannel'.
1518 InteractionCollectorOptions<MappedInteractionTypes<Cached>[T]>,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/discord.js/typings/index.d.ts:1593:27 - error TS2344: Type 'MappedInteractionTypes<Cached>[T]' does not satisfy the constraint 'Interaction<CacheType>'.
Type 'MessageComponentInteraction<If<Cached, "cached", CacheType>> | ButtonInteraction<If<Cached, "cached", CacheType>> | SelectMenuInteraction<...> | ModalSubmitInteraction<...>' is not assignable to type 'Interaction<CacheType>'.
Type 'MessageComponentInteraction<If<Cached, "cached", CacheType>>' is not assignable to type 'Interaction<CacheType>'.
Types of property 'channel' are incompatible.
Type 'CacheTypeReducer<If<Cached, "cached", CacheType>, GuildTextBasedChannel, GuildTextBasedChannel, GuildTextBasedChannel, TextBasedChannel>' is not assignable to type 'GuildTextBasedChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'GuildTextBasedChannel'.
Type '[If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'GuildTextBasedChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["raw" | "cached"] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'GuildTextBasedChannel'.
Type '[If<Cached, "cached", CacheType>] extends ["raw" | "cached"] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'GuildTextBasedChannel'.
Type 'DMChannel | PartialDMChannel | NewsChannel | TextChannel | ThreadChannel | VoiceChannel' is not assignable to type 'GuildTextBasedChannel'. Type '[If<Cached, "cached", CacheType>] extends ["raw" | "cached"] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'VoiceChannel'.
Type 'DMChannel | PartialDMChannel | NewsChannel | TextChannel | ThreadChannel | VoiceChannel' is not assignable to type 'VoiceChannel'.
Type '[If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'VoiceChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["raw" | "cached"] ? GuildTextBasedChannel : TextBasedChannel)'
is not assignable to type 'VoiceChannel'.
Type 'NewsChannel' is not assignable to type 'VoiceChannel'.
Type 'CacheTypeReducer<If<Cached, "cached", CacheType>, GuildTextBasedChannel, GuildTextBasedChannel, GuildTextBasedChannel, TextBasedChannel>' is not assignable to type 'VoiceChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'VoiceChannel'.
Type 'NewsChannel' is not assignable to type 'VoiceChannel'.
1593 ): InteractionCollector<MappedInteractionTypes<Cached>[T]>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Found 4 errors.
btw koding it in Typescript, if that makes a difference
CodePudding user response:
If you got this many error but you only wrote a short amount of code, most likely the problem came from the library itself because you've modified it or something.
To fix this you need to read the first line of your error which is:
node_modules/discord.js/typings/index.d.ts
, as you can see at the second folder(discord.js
), the library name is discord.js
, that is what you need to reinstall.
to reinstall a library, It's pretty simple, what you wanna do is to type this command in your terminal:
npm uninstall discord.js
npm install discord.js
npm uninstall <libraryName>
npm install <libraryName>
CodePudding user response:
The easiest way to fix this, is by simply ignoring it. It will not affect your code in any way, it will however ignore the error. Ignore the node_modules
folder
// tsconfig.json
{
// ...
"exclude": ["node_modules"] // any other ignored folders/files can be provided here
// ...
}