Closed ZbonaL closed 7 years ago
Great idea. See the file util/module.inc.ban. I think you can just change target.ban(1); to target.setMute(1); (line 7) as a fast trick. Discord.js setMute documentation
If that doesn't work, try creating a new "muted users" role that has no writing permissions, then instead of target.ban, use target.setRole(["id of the just created role"]).
I'll try to implement a configurable ban/kick/mute switch to the next version of the bot.
Ok cool, I will try that.
I tried both ways couldnt get it to work: this is what i tried for the second part: `.module.exports = () => {
const module = {};
module.execute = (target) => {
if (target.setRole("316601940068925440")) {
// var muteRole = setRole("");
const mute = target.addRole("316601940068925440");
mute.then((value) => {
console.log(`${target.user.username} was muted.`);
return true;
}).catch((reason) => {
console.log(`mute of ${target.user.username} failed: ${reason}`);
return false;
})
}
return false;
};
return module;
}; `
I tried the following code:
module.exports = () => {
const module = {};
module.execute = (target) => {
const role = target.addRole('316668100361846796');
role.then(() => {
console.log(`${target.user.username} was muted.`);
return true;
}).catch((reason) => {
console.log(`Mute of ${target.user.username} failed: ${reason}`);
return false;
});
};
return module;
};
And it worked for me.
\@muted
ok thanks for the help
So I found another issue, The issue is that after being unmuted the bot will mute someone as soon as they start typing again.
That is because the bot thinks the person should still be punished, as it reflects the previous messages of the users to the new message. Easy way to cancel the punishment is to reboot the bot as it has no long-term memory.
However, we can also clear the user log immediately after the punishment has occurred. Try this on tunneler.js, line ~108:
if (Ban.execute(target)) {
// Ban successful.
if (!settingsContainer['enable_quiet_mode']) {
Message.channel.send(`${Strings.util.antispam.success_0}` +
`${target.user.username}` +
`${Strings.util.antispam.success_1}`);
}
AntiSpam.clearUserHistory(sourceId, Message.author.id);
}
Note the new AntiSpam.clearUserHistory line.
I've tried it but it doesnt seem to be working
Ok, I researched a bit and got it working.
First of all, there seems to be a bug that needs to be fixed. In module.inc.antispam line 130 module.isSpam = (uId, gId, messageObject, settingsContainer) => {
should be: module.isSpam = (gId, uId, messageObject, settingsContainer) => {
.
Second, you need to add return true;
to module.inc.ban, line 14. Currently it can't reach the clearUserHistory line we added above as the Ban.execute(target) returns undefined/false.
Hope this helps.
i see
Hey,
I'm in a progress of creating a refreshed version (0.96) of the bot's first release (0.95). You can already download a working copy from here: https://github.com/ahoys/tunnelerjs/tree/alpha
The refreshed version includes all the features discussed above. See the readme for "Example: muting a user as a punishment".
Make sure to remove the old version of the bot before adding a new one so that there won't be any conflicts. Also, it is a good idea to backup auth.json and settings.json so you don't have to setup everything from the beginning (do not replace the new settings.json entirely as it holds new setting strings).
I'll release a new stable build after I've tested the new version for a few days. I'll inform you if there are any bug fixes / changes that require updating the bot.
ok cool
I know that this was closed but I was wondering if it was possible to make a timed mute. What I mean is when the mute roll is given the a timer starts and after it ends it removes the role. I did play around with setTimeout but it wouldnt work in the mute/ban file because of module.exports, do you know a way to handle that?
Hey, I investigated and the following seems to do the trick:
const target = Message.member;
setTimeout(() => {
if (Punish.execute(target, settingsContainer)) {
// Punish successful.
if (!settingsContainer['enable_quiet_mode']) {
Message.channel.send(`${Strings.util.antispam.success_0}` +
`${target.user.username}` +
`${Strings.util.antispam.success_1}`);
}
AntiSpam.clearUserHistory(sourceId, Message.author.id);
}
}, 5120);
This goes into tunneler.js.
Thanks
I tried it but it didnt seem to work.
const target = Message.member; setTimeout(() => { if (Mute.execute(target)) { // Mute successful. if (!settingsContainer['enable_quiet_mode']) { Message.channel.send(
${Strings.util.antispam.success_0}+
${target.user.username}+
${Strings.util.antispam.success_1}); } AntiSpam.clearUserHistory(sourceId, Message.author.id); } }, 1000);
Make sure you have the latest version of the branch (0.9.6). Your code seems to be different from the one I pasted above.
The tweak may have some side-effects, like the bot may attempt to set the role multiple times as the 'to-be-muted' user keeps talking after the bot has decided about the punishment.
Hi I'm wondering how to change the ban file to mute people instead.