Broken
Broken
DIAdiscord.js - Imagine a boo! 👻
Created by Broken on 10/29/2023 in #djs-questions
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.'); } } });
5 replies