Skip to content

Instantly share code, notes, and snippets.

@heylastway
Created October 31, 2019 15:05
Show Gist options
  • Select an option

  • Save heylastway/09241343572f07588ae262f66f474792 to your computer and use it in GitHub Desktop.

Select an option

Save heylastway/09241343572f07588ae262f66f474792 to your computer and use it in GitHub Desktop.
const Discord = require("discord.js");
const fs = require('fs');
module.exports = class mute {
constructor(){
this.name = 'mute',
this.alias = ['tempmute'],
this.usage = 'mute';
}
run(bot, message, args){
let member = message.mentions.members.first();
var command = args[0];
var mentioned = args[1];
var days = parseInt(args[3]);
var hours = parseInt(args[4]);
var seconds = parseInt(args[5]);
if (message.member.hasPermission('MANAGE_ROLES')) {
let muterole = message.guild.roles.find(role => role.name === "Muted");
if (!message.guild) {
if (message.guild.id === '505872328538718233') {
let memberrole = message.guild.roles.find("name", "Member");
member.removeRole(memberrole);
}}
let usermsg = new Discord.RichEmbed();
usermsg.setTitle('You have been Muted.');
usermsg.setColor('76b3fc');
usermsg.setFooter('Please do not attempt to bypass');
usermsg.addField('Muted by:',
`<@${message.author.id}>`);
let mutedmsg = new Discord.RichEmbed();
mutedmsg.setTitle('User has been Muted Successfully');
mutedmsg.setColor('76b3fc');
mutedmsg.setDescription(`User muted: ${mentioned}\nMuted by: <@${message.author.id}>\nReason: ${input}`);
mutedmsg.setFooter('This mute has been logged.');
if (message.content === `${command}`) {
return message.channel.send('You did not provide a member to mute.');
}
if (message.content === `${command} ${mentioned}`) {
return message.channel.send('Please input a reason for the mute.');
}
if (message.guild.roles.find(role => role.name)) {
message.member.addRole(muterole);
if (message.content.includes (`${days}d`)) {
message.channel.send(mutedmsg);
setTimeout(() => {
member.removeRole(muterole);
usermsg.addField('Punishment Time:',
`${hours} Seconds`);
}, `${args[2]} * 86400`);
}
if (message.content.includes (`${hours}h`)) {
message.channel.send(mutedmsg);
setTimeout(() => {
member.removeRole(muterole);
usermsg.addField('Punishment Time:',
`${hours} Seconds`);
}, `${args[3]} * 3600`);
}
if (message.content.includes (`${seconds}s`)) {
message.channel.send(mutedmsg);
setTimeout(() => {
member.removeRole(muterole);
usermsg.addField('Punishment Time:',
`${seconds} Seconds`);
}, `${args[4]} * 1000`);
}
if (message.content === `${command} ${mentioned} ${input}`) {
message.member.addRole(muterole);
usermsg.addField('Muted for',
`${input}`);
usermsg.addField('Punishment Time:',
'Permenant');
message.channel.send(mutedmsg);
}
if (message.member.id === `${message.author.id}`) {
return;
}
if (message.author.id === `${mentioned}`) {
return message.member.send(usermsg);
}
message.channel.send(mutedmsg);
console.log('===========================');
console.log(`Member Muted: ${mentioned}`);
console.log(`Muted by: ${message.author.tag}`);
console.log(`Reason: ${input}`);
console.log('===========================');
} else {
message.channel.send('You do not have a `Muted` Role, This command won\'t work.');
}
} else {
message.reply('You do not have permission to do this.');
}
/////////////////////////////////////////////////
// JSON MUTE LOG
/////////////////////////////////////////////////
let jsonlogs = JSON.parse(fs.writeFileSync("./storages/mutelogs.json"));
if (!jsonlogs[message.guild.id]){
jsonlogs[message.guild.id] = {
mutedby: `${message.author.tag}`,
user: `${mentioned}`,
reason: `${input}`,
days: `${days}`,
hours: `${hours}`,
seconds: `${seconds}`,
};
}
}
};
@imalexnord

Copy link
Copy Markdown

Hey what's the prefix? How do I use the mute?

@orestis119

Copy link
Copy Markdown

BRUH

@siphyshu

Copy link
Copy Markdown

lmao

@imalexnord

Copy link
Copy Markdown

lmao

?

@SmugTheKiler

Copy link
Copy Markdown

Hey what's the prefix? How do I use the mute?

brruhhhh.... U set it up your self in index, or where I recommend doing is in config.json.

@orestis119

orestis119 commented Feb 12, 2021 via email

Copy link
Copy Markdown

@famousgangity

Copy link
Copy Markdown

how do you setup the mutelogs.json file?

@imalexnord

Copy link
Copy Markdown

Hey what's the prefix? How do I use the mute?

brruhhhh.... U set it up your self in index, or where I recommend doing is in config.json.

dont work

@0x14307

0x14307 commented Apr 24, 2021

Copy link
Copy Markdown

Hey what's the prefix? How do I use the mute?

brruhhhh.... U set it up your self in index, or where I recommend doing is in config.json.

dont work

don't use this then :)

@Iraq1337

Copy link
Copy Markdown

lel

@Gilbertindustries

Copy link
Copy Markdown

._.

@Yanis27

Yanis27 commented Jul 12, 2021

Copy link
Copy Markdown

._.

ghost commented Feb 4, 2022

Copy link
Copy Markdown

._.

@SmugTheKiler

Copy link
Copy Markdown

._.

@wsam3

wsam3 commented Feb 9, 2022

Copy link
Copy Markdown

.
_
.

@SmugTheKiler

Copy link
Copy Markdown

how do you setup the mutelogs.json file?
Why you need that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment