javascript - How to create a discord.js lock command - Stack Overflow

I'm trying to create a lock and unlock mand for my discord.js bot. How would I be able to do this?

I'm trying to create a lock and unlock mand for my discord.js bot. How would I be able to do this?

I want to make it so when I do >lock it takes permission away from Verified to SEND_MESSAGES.

Then if I do >unlock, it unlocks the channel.

I'm trying to create a lock and unlock mand for my discord.js bot. How would I be able to do this?

I want to make it so when I do >lock it takes permission away from Verified to SEND_MESSAGES.

Then if I do >unlock, it unlocks the channel.

Share Improve this question edited May 27, 2020 at 8:25 Peyman Mohamadpour 18k24 gold badges92 silver badges101 bronze badges asked May 26, 2020 at 19:07 SP73SP73 4157 silver badges18 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 2

In your function, you just need to call the following lines to remove the permissions,

const role = guild.roles.find("name", "Verified ");

role.permissions.remove('SEND_MESSAGES')

and to give them back, just put the following lines under the mand:

const role = guild.roles.find("name", "Verified ");

role.permissions.add('SEND_MESSAGES')

If you want to understand why this will work, here are some relevant docs links: role, permissions, and the permissions flags.

EDIT: To change the permissions for the specific channels, just do:

const role = guild.roles.find("name", "Verified ");

message.channel.overwritePermissions(role,{ 'SEND_MESSAGES': false })

and to give them back, you would do the following

const role = guild.roles.find("name", "Verified ");

message.channel.overwritePermissions(role,{ 'SEND_MESSAGES': true})

I guess you need this

const role2 = message.guild.roles.cache.find(role => role.name === 'Member') 
message.channel.updateOverwrite(role2,{ 'SEND_MESSAGES': false}) 
message.channel.send("Successfully locked **${message.channel.name}**")

and this for unlock

const role = message.guild.roles.cache.find(role => role.name === 'Member') 
message.channel.updateOverwrite(role,{ 'SEND_MESSAGES': true})   
message.channel.send("Successfully unlocked **${message.channel.name}**")

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745253967a4618843.html

相关推荐

  • javascript - How to create a discord.js lock command - Stack Overflow

    I'm trying to create a lock and unlock mand for my discord.js bot. How would I be able to do this?

    2小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信