动态帮助菜单,忽略某些命令 discord.js

时间:2021-05-06 16:23:47

标签: javascript discord discord.js bots

所以我为我的机器人制作了一个动态帮助菜单,我需要它来忽略某些命令,比如帮助命令本身,这里的信息命令是代码;

const Discord = require('discord.js');
const loadCommands = require('./load-commands');

module.exports = {
    commands: 'help',
    minArgs: 0,
    maxArgs: 0,
    callback: async (message, args, text, client, prefix) => {
        let Pepe = client.users.fetch('613817002334879747');
Pepe.then(function(result1) {
    var imgURL = result1.displayAvatarURL();
    let reply = ''
const commands = loadCommands()

for (const command of commands) {
  // Check for permissions
  let permissions = command.permission

  if (permissions) {
    let hasPermission = true
    if (typeof permissions === 'string') {
      permissions = [permissions]
    }

    for (const permission of permissions) {
      if (!message.member.hasPermission(permission)) {
        hasPermission = false
        break
      }
    }

    if (!hasPermission) {
      continue
    }
  }
        //Format the text
        const mainCommand = typeof command.commands === 'string' 
        ? command.commands 
        : command.commands[0]
        const { description } = command
        reply += `**${mainCommand}**\n${description}\n\n`
    }
    message.channel.send(new Discord.MessageEmbed()
    .setTitle("**Pepe's Helper**")
    .setFooter("Created by Pepe's Descendant", imgURL)
    .setDescription('Current prefix for this server is ``'+prefix+'``\nUse =info <command> to display information about the command and its usage.\n\n'+reply))
});
    },
}

所以我需要帮助您忽略某些命令的部分可能是这样的;

if (mainCommand === 'help' || mainCommand === 'info') {
//make it ignore the commands
}

如果您知道如何做到这一点,请帮助我并告诉我,如果您不明白我的问题,请告诉我,如果需要,我会更好地为您解释。

1 个答案:

答案 0 :(得分:0)

只需将 continue 添加到您的 if 语句中,它就会忽略该命令

if (mainCommand === 'help' || mainCommand === 'info') {
 continue;
}
reply += ...