messageCreate event (help system)

const { EmbedBuilder, ChannelType } = require('discord.js');

module.exports = {
name: 'messageCreate',
on: true,
execute(channel, message){
console.log('Message')
if(message.content.includes('@Yara')) return true;
if(channel.type !== ChannelType.DM) return;
const whatTypeHelpEmbed = new EmbedBuilder()
.setColor('Red')
.setTitle('Hello!')
.setDescription('Please select one of the options below.\n\n> 1️⃣ - I have a question about something.\n> 2️⃣ - I have a complaint about an issue.')
message.author.send({ embeds: [whatTypeHelpEmbed]}).then(() => {
whatTypeHelpEmbed.react('1️⃣')
whatTypeHelpEmbed.react('2️⃣')
})
}
}
const { EmbedBuilder, ChannelType } = require('discord.js');

module.exports = {
name: 'messageCreate',
on: true,
execute(channel, message){
console.log('Message')
if(message.content.includes('@Yara')) return true;
if(channel.type !== ChannelType.DM) return;
const whatTypeHelpEmbed = new EmbedBuilder()
.setColor('Red')
.setTitle('Hello!')
.setDescription('Please select one of the options below.\n\n> 1️⃣ - I have a question about something.\n> 2️⃣ - I have a complaint about an issue.')
message.author.send({ embeds: [whatTypeHelpEmbed]}).then(() => {
whatTypeHelpEmbed.react('1️⃣')
whatTypeHelpEmbed.react('2️⃣')
})
}
}
Output Nothing Please help, i do have the special thing turned on in dev and i have message content gateway bits
16 Replies
d.js docs
d.js docs2y 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.
PAdventures
PAdventures2y ago
no output in DMs output in channels on server nevermind i got it working nevermind i will get a message in dm from bot if i send a message in the server, but i can send any message and not @Yara but i cant get a message if i send something in dms
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
PAdventures
PAdventures2y ago
ye
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
PAdventures
PAdventures2y ago
ye, returns true
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
PAdventures
PAdventures2y ago
when i put if like this if(message.content.includes('@Yara')){ nothing happens
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Yinoguns
Yinoguns2y ago
I reckon you have been bamboozled by the message content privilaged intent
PAdventures
PAdventures2y ago
'Please help, i do have the special thing turned on in dev and i have message content gateway bits" so no because i have it on
const eventsPath = path.join(__dirname, 'Events');const eventFiles = fs.readdirSync(eventsPath).filter(file => file.endsWith('.js'));for (const file of eventFiles) { const event_filePath = path.join(eventsPath, file); const event = require(event_filePath); if (event.once) { client.once(event.name, (...args) => event.execute(...args)); } else { client.on(event.name, (...args) => event.execute(...args)); }}
const eventsPath = path.join(__dirname, 'Events');const eventFiles = fs.readdirSync(eventsPath).filter(file => file.endsWith('.js'));for (const file of eventFiles) { const event_filePath = path.join(eventsPath, file); const event = require(event_filePath); if (event.once) { client.once(event.name, (...args) => event.execute(...args)); } else { client.on(event.name, (...args) => event.execute(...args)); }}
const { EmbedBuilder, ChannelType } = require('discord.js');module.exports = { name: 'messageCreate', on: true, async execute(message, channel){ console.log('Message') if(!channel.type === ChannelType.DM) return; console.log(channel.type === ChannelType.DM) if(message.content === process.env.CLIENT_ID){ const whatTypeHelpEmbed = new EmbedBuilder() .setColor('Red') .setTitle('Hello!') .setDescription('Please select one of the options below.\n\n> 1️⃣ - I have a question about something.\n> 2️⃣ - I have a complaint about an issue.') const messageEmbed = await message.author.send({ embeds: [whatTypeHelpEmbed]}) messageEmbed.react('1️⃣') messageEmbed.react('2️⃣') } }}
const { EmbedBuilder, ChannelType } = require('discord.js');module.exports = { name: 'messageCreate', on: true, async execute(message, channel){ console.log('Message') if(!channel.type === ChannelType.DM) return; console.log(channel.type === ChannelType.DM) if(message.content === process.env.CLIENT_ID){ const whatTypeHelpEmbed = new EmbedBuilder() .setColor('Red') .setTitle('Hello!') .setDescription('Please select one of the options below.\n\n> 1️⃣ - I have a question about something.\n> 2️⃣ - I have a complaint about an issue.') const messageEmbed = await message.author.send({ embeds: [whatTypeHelpEmbed]}) messageEmbed.react('1️⃣') messageEmbed.react('2️⃣') } }}
error
Message
node:events:368
throw er; // Unhandled 'error' event
^

TypeError: Cannot read properties of undefined (reading 'type')
at Object.execute (/Volumes/SEB'S USB/Yara Bot/Events/helpSystem.js:8:21)
at Client.<anonymous> (/Volumes/SEB'S USB/Yara Bot/index.js:48:44)
at Client.emit (node:events:390:28)
at MessageCreateAction.handle (/Volumes/SEB'S USB/Yara Bot/node_modules/discord.js/src/client/actions/MessageCreate.js:23:14)
at Object.module.exports [as MESSAGE_CREATE] (/Volumes/SEB'S USB/Yara Bot/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/Volumes/SEB'S USB/Yara Bot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:352:31)
at WebSocketShard.onPacket (/Volumes/SEB'S USB/Yara Bot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:481:22)
at WebSocketShard.onMessage (/Volumes/SEB'S USB/Yara Bot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:321:10)
at WebSocket.onMessage (/Volumes/SEB'S USB/Yara Bot/node_modules/ws/lib/event-target.js:199:18)
at WebSocket.emit (node:events:390:28)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:251:10)
at processTicksAndRejections (node:internal/process/task_queues:85:21)
Message
node:events:368
throw er; // Unhandled 'error' event
^

TypeError: Cannot read properties of undefined (reading 'type')
at Object.execute (/Volumes/SEB'S USB/Yara Bot/Events/helpSystem.js:8:21)
at Client.<anonymous> (/Volumes/SEB'S USB/Yara Bot/index.js:48:44)
at Client.emit (node:events:390:28)
at MessageCreateAction.handle (/Volumes/SEB'S USB/Yara Bot/node_modules/discord.js/src/client/actions/MessageCreate.js:23:14)
at Object.module.exports [as MESSAGE_CREATE] (/Volumes/SEB'S USB/Yara Bot/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/Volumes/SEB'S USB/Yara Bot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:352:31)
at WebSocketShard.onPacket (/Volumes/SEB'S USB/Yara Bot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:481:22)
at WebSocketShard.onMessage (/Volumes/SEB'S USB/Yara Bot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:321:10)
at WebSocket.onMessage (/Volumes/SEB'S USB/Yara Bot/node_modules/ws/lib/event-target.js:199:18)
at WebSocket.emit (node:events:390:28)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:251:10)
at processTicksAndRejections (node:internal/process/task_queues:85:21)
i sawpped message and channel tho so how do i get channel to work k now it works but it the file wont run if i type in dms is there an event for the bot if a DM message is sent to the bot? or is it just messageCreate DM no now i do if i do this message.content === '@Yara' and i type @Yara in dms, should the bot reply or is the code wrong output <@ID> ID is bot id it works yayayayayayayayayay 🎉 how do i get reactions to work
const filter = (reaction, user) => { return ['1️⃣', '2️⃣'].includes(reaction.emoji.name) && user.id === message.author.id; }; messageEmbed.awaitReactions({ filter, max: 1, time: 60000, errors: ['time'] }) .then(collected => { const reaction = collected.first(); if (reaction.emoji.name === '1️⃣') { messageEmbed.reply('You reacted with a thumbs up.'); } else { messageEmbed.reply('You reacted with a thumbs down.'); } }) .catch(collected => { message.reply('You reacted with neither a thumbs up, nor a thumbs down.'); });
const filter = (reaction, user) => { return ['1️⃣', '2️⃣'].includes(reaction.emoji.name) && user.id === message.author.id; }; messageEmbed.awaitReactions({ filter, max: 1, time: 60000, errors: ['time'] }) .then(collected => { const reaction = collected.first(); if (reaction.emoji.name === '1️⃣') { messageEmbed.reply('You reacted with a thumbs up.'); } else { messageEmbed.reply('You reacted with a thumbs down.'); } }) .catch(collected => { message.reply('You reacted with neither a thumbs up, nor a thumbs down.'); });
after 60 sec, the message is sent but when i. react to the message, the other message -> You reacted with a thumbs up. or the other doesnt send
d.js docs
d.js docs2y ago
class ReactionManager (extends CachedManager) Manages API methods for reactions and holds their cache.
PAdventures
PAdventures2y ago
yup i have it does discrod,js have a guide that is not outdated?
d.js docs
d.js docs2y ago
guide Home: Introduction read more
PAdventures
PAdventures2y ago
discord.js Guide
Imagine a guide... that explores the many possibilities for your discord.js bot.
PAdventures
PAdventures2y ago
and not work
const { EmbedBuilder, ChannelType } = require('discord.js');module.exports = { name: 'messageCreate', on: true, async execute(message){ console.log('Message') console.log(message.content) if(message.content === '<@ID>' && message.channel.type === ChannelType.DM){ const whatTypeHelpEmbed = new EmbedBuilder() .setColor('Red') .setTitle('Hello!') .setDescription('Please select one of the options below.\n\n> 1️⃣ - I have a question about something.\n> 2️⃣ - I have a complaint about an issue.') const messageEmbed = await message.author.send({ embeds: [whatTypeHelpEmbed]}) messageEmbed.react('1️⃣') messageEmbed.react('2️⃣') const filter = (reaction, user) => { return ['1️⃣', '2️⃣'].includes(reaction.emoji.name) && user.id === message.author.id; }; messageEmbed.awaitReactions({ filter, max: 1, time: 60000, errors: ['time'] }) .then(collected => { const reaction = collected.first(); if (reaction.emoji.name === '1️⃣') { messageEmbed.reply('You reacted with a thumbs up.'); } else { messageEmbed.reply('You reacted with a thumbs down.'); } }) .catch(collected => { message.reply('You reacted with neither a thumbs up, nor a thumbs down.'); }); } }}
const { EmbedBuilder, ChannelType } = require('discord.js');module.exports = { name: 'messageCreate', on: true, async execute(message){ console.log('Message') console.log(message.content) if(message.content === '<@ID>' && message.channel.type === ChannelType.DM){ const whatTypeHelpEmbed = new EmbedBuilder() .setColor('Red') .setTitle('Hello!') .setDescription('Please select one of the options below.\n\n> 1️⃣ - I have a question about something.\n> 2️⃣ - I have a complaint about an issue.') const messageEmbed = await message.author.send({ embeds: [whatTypeHelpEmbed]}) messageEmbed.react('1️⃣') messageEmbed.react('2️⃣') const filter = (reaction, user) => { return ['1️⃣', '2️⃣'].includes(reaction.emoji.name) && user.id === message.author.id; }; messageEmbed.awaitReactions({ filter, max: 1, time: 60000, errors: ['time'] }) .then(collected => { const reaction = collected.first(); if (reaction.emoji.name === '1️⃣') { messageEmbed.reply('You reacted with a thumbs up.'); } else { messageEmbed.reply('You reacted with a thumbs down.'); } }) .catch(collected => { message.reply('You reacted with neither a thumbs up, nor a thumbs down.'); }); } }}
right 🤦 it works i just really dumb what is GatewayIntentBits.DirectMessageTyping ok