Reputation: 33
i created a global chat bot, but i have a problem with mute command
if(command === "mute") {
if(!message.member.hasPermission("ADMINISTRATOR")){
return message.channel.send("Nie masz permisji do tej komendy!")
}
const user = message.mentions.members.first()
if(!user){
message.channel.send("Musisz kogoś oznaczyć")
}
let mute = db.get(`mute_${message.guild.id}_${user.id}`)
if(mute === null) {
db.set(`mute_${message.guild.id}_${user.id}`, 1)
user.send(`${user.id} został zmutowany`)
}
}
here is the code, the point is that if you want to mute someone, the user can still write and I don't know how to fix it
Upvotes: 1
Views: 196
Reputation: 2220
You never really mute the person. You only put it into the database but you also have to tell Discord that this user is muted. There are two options you can do:
You can set explicit permission in every channel of the server to mute the person. The problem with this approach is that if you create a new channel while a person is muted they can still write in this channel.
You could make a config entry that allows admins to set a mute role. When you execute the mute command this role will be added to the user. That has the benefit that when a new channel is created, they are still muted. It would also make an unmute command easier.
Upvotes: 1