cmd.user.timeout

Applies a timeout to a guild member, preventing them from sending messages or joining voice channels for the specified duration.

JavaScript
const { cmd } = require("syntx.js");

await cmd.user.timeout({ user, time, reason }, message);

Parameters

ParameterTypeRequiredDescription
userstringYesThe ID of the member to timeout.
timestring | numberYesDuration of the timeout. Accepts a human-readable string (e.g. "10m", "1h", "7d") or a number of milliseconds. Maximum is 28 days.
reasonstringNoAudit log reason for the timeout.
messagediscord.js Message | InteractionYesA guild message or interaction, used to access the guild.

Duration format

The time parameter uses the ms library format:

StringDuration
"30s"30 seconds
"10m"10 minutes
"1h"1 hour
"1d"1 day
"7d"7 days

Returns

This function does not return a value.

Example

JavaScript
client.command({
  name: "timeout",
  content: async (message) => {
    const id = cmd.message.mentioned(message, 1);
    if (!id) return message.reply("Please mention a user.");

    await cmd.user.timeout(
      {
        user: id,
        time: "1h",
        reason: "Spamming in chat",
      },
      message
    );

    message.reply(`<@${id}> has been timed out for 1 hour.`);
  },
});

Warning

The bot must have the Moderate Members permission, and its highest role must be above the target's highest role. Exceeding 28 days throws a SyntxError.