Mute Command With A Time

I have a ban command, but i’d like it so the user can do it for a specific time. I just have code for it to mute them member, but the person would need to use an unmute command.

How ould I make the code for muting a member for, say 10 minutes?

module.exports = {
  name: "ban",
  description: "Ban those pesky users!",
  async execute(message, args) {
    let {RichEmbed} = require("discord.js");
    if(!message.member.hasPermissions(["BAN_MEMBERS", "ADMINISTRATOR"])) return"You don't have sufficient permissions to run this command");
    let banMember = message.mentions.members.first() || message.guild.members.get(args[0]);
    if(!banMember) return"You did not provide a user to ban. Please provide a user to ban");
    let reason = args.slice(1).join(" ");
    if(!reason) reason = "No reason provided";
    if(!["BAN_MEMBERS", "ADMINISTRATOR"])) return"I do not have sufficient permissions to ban this user. Please try again.");
    banMember.send(`You have permanently been banned from ${} because: ${reason}.`).then(message.guild.ban(banMember)).catch(err => console.log(err));`**${banMember.user.tag}** has be successfully banned`).then(m => m.delete(5000));
    let banEmbed = new RichEmbed()
      .addField("Moderation Action", "ban")
      .addField("Banned Member", banMember.user.username)
      .addField("Reason", reason)
      .addField("Date:", message.createdAt.toLocaleAString());
    let modChannel = message.guild.channels.find(channel => === "mod-log");

How does it work?

Please avoid posting in old threads. You can find tutorials for discord.js commands in many places on the internet (ie. YouTube, GitHub).

1 Like