Skip to content
Advertisement

Check if a user can send message in a mentioned channel discord.js

I have a command which allows users to make the bot to say a message, but I would like it to be able to check whether the user is able to send messages in that channel before it sends it. Currently, I just have it locked to the MANAGE_MESSAGES permission.

Here is the code:

JavaScript

I have searched and couldn’t find much on this, any help is appreciated

Advertisement

Answer

I’m not sure if I understand your question correctly. You can check if the member has permission in a certain channel using channel.permissionFor(member).has('PERMISSION_NAME'). I’m not sure if you really wanted the user to have MANAGE_MESSAGES permission, I think SEND_MESSAGES should be enough, so I used that in my code below. I also made it a bit cleaner and added some comments:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement