【发布时间】:2021-07-29 00:16:16
【问题描述】:
所以我为我的机器人制作了一个动态帮助菜单,我需要它来忽略某些命令,例如帮助命令本身,这里的 Info 命令是代码;
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
}
如果您确实知道如何做到这一点,请帮助我并告诉我,如果您不理解我的问题,请告诉我,如果需要,我会更好地为您解释。
【问题讨论】:
标签: javascript discord discord.js bots