#channelID code

16 messages · Page 1 of 1 (latest)

tropic whale
#

• 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.

gloomy sable
#

                    // Set a timeout to end the conversation after 30 seconds of inactivity
                    const options = { time: 30000 };

                    // Wait for the user's response
                    channel.awaitMessages(filter, options)
                        .then((collected) => {
                            // Get the first message that was collected
                            const response = collected.first();

                            // Extract the channel ID from the response
                            const channelID = response.content.match(/\d+/)[0];

                            // Export the channel ID for further usage in other modules
                            module.exports.channelID = channelID;

                            // Send a confirmation message
                            channel.send(`I'll be texting in <#${channelID}> from now on.`);
                        })
                        .catch(() => {
                            channel.send("I didn't get a response. I'll use the default channel for this guild.");
                        });
                })
                .catch((error) => {
                    console.error(`Failed to ask for channel in guild ${guild.name} (${guild.id}): ${error}`);
                });
        });
    },
};
``` channelID code I wrote but the problem is i get the error of Failed to find a text channel in guild Berra Patur (590681191682670593)
#

even there are 2 or 3 text channels it cant detect them

raven dagger
#

channel.type needs to be compared with ChannelType.GuildText in v14, what you have there is v12 code

#

Also the filter for collectors goes into the options now

gloomy sable
#

oh ok i will try that

#

thanks

#

@raven dagger hi again const { Events, ChannelType } = require("discord.js"); const channel = guild.channels.cache.find((channel) => channel.type === ChannelType.GUILD_TEXT);
// Set a timeout to end the conversation after 30 seconds of inactivity
const options = {
filter: filter,
time: 30000
};

#

i made these changes

#

still no difference 😦

#

output is still Failed to find a text channel in guild Berra Patur (590681191682670593)
Failed to find a text channel in guild Chibureshka kullanıcısının sunucusu (1082244858196009001)

#

despite there are text channels

gloomy sable
#

well i read it again and tried some things but couldnt figure out 😭

#

can you explain it a bit please

raven dagger
#

GuildText !== GUILD_TEXT