Not finding an announcement channel

Hello, I dont know why, but it seems like it doesnt find the announcement channel.
const banGlobalChannelId = '1123739036394201188';

const banGlobalChannel = client.channels.cache.get(banGlobalChannelId);
if (banGlobalChannel && (banGlobalChannel.type === 'GUILD_TEXT' || banGlobalChannel.type === 'GUILD_ANNOUNCEMENT')) {
const filter = (interaction) => interaction.customId === 'ban_globally';
const collector = banGlobalChannel.createMessageComponentCollector({ filter, time: 60000 });
const banGlobalChannelId = '1123739036394201188';

const banGlobalChannel = client.channels.cache.get(banGlobalChannelId);
if (banGlobalChannel && (banGlobalChannel.type === 'GUILD_TEXT' || banGlobalChannel.type === 'GUILD_ANNOUNCEMENT')) {
const filter = (interaction) => interaction.customId === 'ban_globally';
const collector = banGlobalChannel.createMessageComponentCollector({ filter, time: 60000 });
8 Replies
d.js toolkit
d.js toolkit17mo ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
Squid
Squid17mo ago
channel types in v14 are members of the ChannelType enum, not strings e.g. 'GUILD_TEXT' => ChannelType.GuildText with ChannelType imported from discord.js
Cgx
CgxOP17mo ago
So I have to replace it with ChannelType.GuildText?
if (banGlobalChannel && (banGlobalChannel.type === ChannelType.GuildText || banGlobalChannel.type === ChannelType.Announcement)) {
^

ReferenceError: ChannelType is not defined
if (banGlobalChannel && (banGlobalChannel.type === ChannelType.GuildText || banGlobalChannel.type === ChannelType.Announcement)) {
^

ReferenceError: ChannelType is not defined
???
monbrey
monbrey17mo ago
You need to import the enum from discord.js
Cgx
CgxOP17mo ago
Wait what
monbrey
monbrey17mo ago
ChannelType is part of discord.js How do you import discord.js currently?
Cgx
CgxOP17mo ago
const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, SlashCommandBuilder, TextChannel, NewsChannel, ChannelType } = require('discord.js');
const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, SlashCommandBuilder, TextChannel, NewsChannel, ChannelType } = require('discord.js');
Added channel type now
monbrey
monbrey17mo ago
cool
Want results from more Discord servers?
Add your server