John Hayes
John Hayes

Reputation: 35

Discord Mute Command

I am trying to work on a bot that automatically mutes someone for using a "banned word".

I've looked through a lot of code, theorized on my end, and looked through the documentation but cannot figure out how to make it work.

How do you remove a user's ability to use chat and other features without having to go through and remove all other roles with perms?

The only thing I have thought of was adding their previous roles to a database, removing them, and then when their timer is up, adding them back.

Upvotes: 0

Views: 115

Answers (1)

Neko
Neko

Reputation: 160

Instead of removing all roles you could timeout the user. It keeps all roles, even stays when rejoining the server and you can't join voice channels when you are timeout'd.

Code would be something like this:

// Time a guild member out for 5 minutes
guildMember.disableCommunicationUntil(Date.now() + (5 * 60 * 1000), 'They deserved it')
  .then(console.log)
  .catch(console.error);

Source: discord.js docs

Upvotes: 2

Related Questions