ban

Bans an user from the current guild.

Syntax

ban(userID)

Parameters

  • userID : The user to ban. Value must be a valid user snowflake ID.

Permissions

Required permission which the bot must have for this function to work properly.

  • ban

Example

try {
  const msg = message.replace(commandPrefix, '').trim();

  if (!msg) {
    setResponse(`Usage : \` ${commandPrefix} [@user] \``);
  } else {
    const mention = /^<@!?(\d{17,20})>/.test(msg);

    if (!mention || !userMentions[0])
      throw new Error('Mention an user!');

    if (userMentions[0] === authorId)
      throw new Error('You can\'t ban yourself!');

    sendChannelMessage(channelId, `*<@${authorId}> bans <@${userMentions[0]}>!!*`);

    ban(userMentions[0]);
  };
} catch (err) {
  setResponse('Command Error : ` ' + err.message + ' `');
};

Screenshot_20220917_165612
InShot_20220917_172017419