Skip to content

Commit

Permalink
Merge pull request #18 from muricans/mbot-testing
Browse files Browse the repository at this point in the history
Mbot testing
  • Loading branch information
muricans authored May 26, 2019
2 parents 592d6fc + 9fd2aa9 commit 421759a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
24 changes: 15 additions & 9 deletions commands/mod/mute.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ module.exports = {
description: 'Keeps a player from chatting for specified time.',
args: true,
minArgs: 2,
/**
*
* @param {Discord.Message} message
* @param {*} args
* @param {*} client
*/
execute(message, args, client) {
const canKick = message.channel.permissionsFor(message.member).has("KICK_MEMBERS");
if (!canKick) {
Expand Down Expand Up @@ -54,18 +60,14 @@ module.exports = {
hours = Math.floor(minutes / 60);
}
out = minutes >= 60 ? `${hours} hour(s)` : `${minutes} minute(s)`;
muted.set(mention.id, mil);
this.mutes.set(mention.id, Date.now());
setTimeout(() => muted.delete(mention.id), mil);
muteMember(muted, mention.id, mil, message.guild.member(mention));
return message.channel.send(`${message.author} muted ${mention} for ${out}!`);
} else if (args[1].includes("hour")) {
const hours = (parseInt(args[1]));
sec = (hours * 3600);
mil = (sec * 1000);
out = `${hours} hour(s)`;
muted.set(mention.id, mil);
this.mutes.set(mention.id, Date.now());
setTimeout(() => muted.delete(mention.id), mil);
muteMember(muted, mention.id, mil, message.guild.member(mention));
return message.channel.send(`${message.author} muted ${mention} for ${out}!`);
} else {
sec = (parseInt(args[1]));
Expand All @@ -74,10 +76,14 @@ module.exports = {
minutes = Math.floor(sec / 60);
}
out = sec >= 60 ? `${minutes} minute(s)` : `${sec} second(s)`;
muted.set(mention.id, mil);
this.mutes.set(mention.id, Date.now());
setTimeout(() => muted.delete(mention.id), mil);
muteMember(muted, mention.id, mil, message.guild.member(mention));
return message.channel.send(`${message.author} muted ${mention} for ${out}!`);
}
},
}

function muteMember(muted, id, mil, member) {
module.exports.mutes.set(id, Date.now());
muted.set(id, mil);
setTimeout(() => muted.delete(id), mil);
}
6 changes: 6 additions & 0 deletions commands/mod/unmute.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
const mute = require('./mute');
const Discord = require('discord.js');

module.exports = {
name: 'unmute',
usage: '<user>',
description: 'Unmute a muted user.',
args: true,
minArgs: 1,
/**
*
* @param {Discord.Message} message
* @param {*} args
*/
execute(message, args) {
const canKick = message.channel.permissionsFor(message.member).has("KICK_MEMBERS");
if (!canKick) {
Expand Down

0 comments on commit 421759a

Please sign in to comment.