Are you sure you haven’t updated your discord.js version and you’re still using v12?
Channel types in v13 are now uppercase and align with Discord’s naming conventions. See below the changes:
channel type | v12 | v13 |
---|---|---|
DM channel | dm |
DM |
group DM channel | N/A | GROUP_DM |
guild text channel | text |
GUILD_TEXT |
guild text channel’s public thread channel | N/A | GUILD_PUBLIC_THREAD |
guild text channel’s private thread channel | N/A | GUILD_PRIVATE_THREAD |
guild voice channel | voice |
GUILD_VOICE |
guild stage voice channel | N/A | GUILD_STAGE_VOICE |
guild category channel | category |
GUILD_CATEGORY |
guild news channel | news |
GUILD_NEWS |
guild news channel’s public thread channel | N/A | GUILD_NEWS_THREAD |
guild store channel | store |
GUILD_STORE |
generic channel of unknown type | unknown |
UNKNOWN |
It means, that if you want to check if the channel
‘s type
is DM, you need to use:
if (msg.channel.type === 'DM')
There are some changes in v14 too. You can use the ChannelType
enums:
const { ChannelType, Client } = require('discord.js');
// ..
if (message.channel.type === ChannelType.DM)