#custom code for the bot

7 messages · Page 1 of 1 (latest)

molten prairie
#

Hello, I'm go be creating a bot soon, I have a question, so I'm using ChatGPT to help me with custom code, but what version should I use?

woeful perchBOT
#
  • What's your exact discord.js npm list discord.js and node node -v version?
  • Not a discord.js issue? Check out #1081585952654360687.
  • Consider reading #how-to-get-help to improve your question!
  • Explain what exactly your issue is.
  • Post the full error stack trace, not just the top part!
  • Show your code!
  • Issue solved? Press the button!
molten prairie
#

Here's the code, not sure if it's right

const Discord = require('discord.js');
const client = new Discord.Client();

client.on('message', message => {
  if (!message.content.startsWith('/')) return; // Check if the message starts with '/'

  const args = message.content.slice(1).trim().split(' ');
  const command = args.shift().toLowerCase();

  if (command === 'punish') {
    // Check if the user has permission to use this command
    if (!message.member.hasPermission('ADMINISTRATOR')) {
      return message.reply('You do not have permission to use this command.');
    }

    // Parse arguments
    const username = args[0];
    const rank = args[1];
    const punishment = args[2];
    const reason = args.slice(3).join(' ');
    const duration = args[4];
    const note = args.slice(5).join(' ');
    const approvedBy = message.author.username;

    // Check if all required arguments are provided
    if (!username || !rank || !punishment || !reason || !duration || !note || !approvedBy) {
      return message.reply('Please provide all the required arguments: Username, Rank, Punishment, Reason, Duration, Note, Approved by.');
    }

    // Check if punishment is zero tolerance policy and if user mentioned
    if (punishment.toLowerCase() === 'zero tolerance policy') {
      const mentionedUser = message.mentions.users.first();
      if (!mentionedUser) {
        return message.reply('You need to mention the user when using zero tolerance policy.');
      }
    }

    // Perform action based on the punishment
    // Here you can add your logic to apply the punishment, like adding a role, sending a message, etc.

    message.channel.send(`Punishment applied to ${username} for ${reason}. Approved by ${approvedBy}.`);
  }
});

client.login('your-bot-token');
worthy bison
#

you should always try to use the latest version, and do not use ChatGPT since it's very outdated

molten prairie
worthy bison
#

sure i guess