Suppose there is a server and I have a slash command by which a user can send an embed message. In that command, it have a option to choose in which channel you want to send that embed message and I want to ensure that if a user can send message in the channel they provided in slash command options then only they are able to use that slash command.
I hope someone know how to do this.
thanks in advance!
>Solution :
If you have a channel in channel, a guild in guild, and a user in user, you can get the perms like this:
const permissions = channel.permissionsFor(guild.members.cache.get(user.id));
If you already have the member (as member):
const permissions = channel.permissionsFor(member);
Then you can just check if they have the permissions:
if (permissions.has(PermissionsBitField.Flags.SendMessages)) {
// member has perms to send in the channel
}
See this page in the guide.