Skip to content

Commit

Permalink
Added timed mutes (timeout)
Browse files Browse the repository at this point in the history
  • Loading branch information
CSP02 committed Mar 18, 2022
1 parent 74b464d commit ada2398
Showing 1 changed file with 36 additions and 11 deletions.
47 changes: 36 additions & 11 deletions commands/Moderation/mute.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//MUTE COMMAND

const mongo = require('../../schemas/mongo')
const warnShema = require('../../schemas/schema')

Expand All @@ -18,25 +16,52 @@ module.exports = {
if (modOrAdmin) {
const target = message.mentions.users.first()
if (target) {
let mainRole = message.guild.roles.cache.find(role => role.name === 'member') || message.guild.roles.cache.find(role => role.name === 'shrimp');
let mutedRole = message.guild.roles.cache.find(role => role.name === 'Muted');


memberTarget = message.guild.members.cache.get(target.id)
if (memberTarget.permissions.has('MUTE_MEMBERS') && !message.member.permissions.has('ADMINISTRATOR')) {
if (memberTarget.permissions.has('VIEW_AUDIT_LOG') && !message.member.permissions.has('ADMINISTRATOR')) {
message.channel.send('Be a good mod.');
}
else if (!args[1]) {

}
else {
memberTarget.roles.add(mutedRole.id)


let time
if (!isNaN(args[1])) {
time = args[1]
timeUnits = args[2]
if (!args[2]) {
return message.channel.send("mention the units of time\n's' for seconds, 'm' for minutes, 'hr' for hours, 'd' for days and 'w' for weeks")
}
switch (timeUnits) {
case 's':
time = args[1] * 1000
break
case 'm':
time = args[1] * 60 * 1000
break
case 'hr':
time = args[1] * 60 * 60 * 1000
break
case 'd':
time = args[1] * 24 * 60 * 60 * 1000
break
case 'w':
time = args[1] * 7 * 24 * 60 * 60 * 1000
break
default:
return message.channel.send("invalid units\n's' for seconds, 'm' for minutes, 'hr' for hours, 'd' for days and 'w' for weeks")
}
const tar = message.mentions.users.first()
let mem = message.guild.members.cache.get(tar.id)
mem.timeout(time, args.slice(3).join(' '))
} else {
memberTarget.roles.add(mutedRole.id)
}
const guildId = message.guild.id;
const userId = target.id;
let reason = 'Undefined'
if (args[1]) {
if (args[1] && !isNaN(args[1])) {
reason = args.slice(3).join(' ')
} else {
reason = args.slice(1).join(' ')
}
var infrID = parseInt('1', 10);
Expand Down

0 comments on commit ada2398

Please sign in to comment.