Bot Crashing After a non permission user runds command

client.on('messageCreate', (message) => { // Check if the message starts with "!announce" and the author has the 'ADMINISTRATOR' permission if (message.content.startsWith('!news') && message.member.permissions.has('OWNER')) { // Extract the announcement message const announcement = message.content.slice('!news'.length).trim();
// Replace 'announcements' with the name of the channel where you want to send announcements const announcementChannel = message.guild.channels.cache.find((channel) => channel.name === 'general');
if (announcementChannel && announcement) { announcementChannel.send(announcement); } else { message.reply('Announcement channel not found or announcement message is empty.'); } } });
3 Replies
d.js toolkit
d.js toolkit13mo ago
- 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!
Broken
BrokenOP13mo ago
Discord JS v 14. Javascript.
Daro
Daro13mo ago
what exactly is the error, and what permission is missing?
Want results from more Discord servers?
Add your server