How to convert code to js14?
Code is
// Import required modules
const { Client, Intents } = require('discord.js');
// Create a new client with necessary intents
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
// Replace 'YOUR_BOT_TOKEN' with your actual bot token
const BOT_TOKEN = 'MTEzNTE5NjU3NjM0ODkwOTYwOA.G-8KoH.bMI4RGNftDSQlD9J5J0aSW1eCOybnNiT4hvzkE';
// The ID of the channel where the bot will listen for messages
const TARGET_CHANNEL_ID = '1135196103537606697';
// When the bot is ready and connected to Discord
client.on('ready', () => {
console.log(Logged in as ${client.user.tag}!);
});
// Listen for messages
client.on('messageCreate', (message) => {
// Check if the message was sent in the target channel and not by the bot itself
if (message.channel.id === TARGET_CHANNEL_ID && !message.author.bot) {
// Create an embed message with the user's message content
const embed = new MessageEmbed()
.setColor('#ff0000')
.setDescription(message.content)
.addField('Radio', message.content)
.setFooter('Wagner Group CampBase Radio');
// Send the embed message
message.channel.send({ embeds: [embed] });
// Delete the user's original message
message.delete().catch((err) => console.error('Error deleting message:', err));
}
});
// Log in to Discord with your bot token
client.login(BOT_TOKEN);
6 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!by reading the docs
please refer to the guide you've been linked to, read through it and ctrl + f as you encounter further changes
[email protected]
v18.16.1
ok
also reset your token
and dont use chat gpt