Javascript 从帮助列表中隐藏nsfw命令
我还没有看到任何答案 我正在寻找一种方法来隐藏我为discord.js bot使用的任何nsfw命令。 我希望它仅在执行帮助命令的通道标记为nsfw时显示 因此,如果通道标记为nsfw,它将显示nsfw类别和命令。如果未标记nsfw,则隐藏nsfw类别和命令 谢谢你给我的任何帮助 这将显示每个命令及其各自的类别 这是我的帮助命令代码-Javascript 从帮助列表中隐藏nsfw命令,javascript,Javascript,我还没有看到任何答案 我正在寻找一种方法来隐藏我为discord.js bot使用的任何nsfw命令。 我希望它仅在执行帮助命令的通道标记为nsfw时显示 因此,如果通道标记为nsfw,它将显示nsfw类别和命令。如果未标记nsfw,则隐藏nsfw类别和命令 谢谢你给我的任何帮助 这将显示每个命令及其各自的类别 这是我的帮助命令代码- const { stripIndents } = require("common-tags"); module.exports = { name: "h
const { stripIndents } = require("common-tags");
module.exports = {
name: "help",
category: "info",
description: "Tells you the commads currently able to be used",
run: async (client, message, args) => {
if(args[0]){
return getCMD(client, message, args[0]);
}else{
return getALL(client, message);
}
}
}
function getALL(client, message){
const embed = new RichEmbed()
.setColor("RANDOM")
.setThumbnail(message.guild.iconURL)
const commands = (category) => {
return client.commands
.filter(cmd => cmd.category === category)
.map(cmd => `**|-** \`${cmd.name}\``)
.join("\n");
}
const info = client.categories
.map(cat => stripIndents`**${cat[0].toUpperCase() + cat.slice(1)}** \n${commands(cat)}`)
.reduce((string, category) => string + "\n" + category);
return message.channel.send(embed.setDescription(info));
}
function getCMD(client, message, input){
const embed = new RichEmbed()
const cmd = client.commands.get(input.toLowerCase()) || client.commands.get(client.aliases.get(input.toLowerCase()));
let info = `No Information found for command **${input.toLowerCase()}**`;
if(!cmd){
return message.channel.send(embed.setColor("#ff0000").setDescription(info));
}
if(cmd.name) info = `**Command Name -** ${cmd.name}`;
if(cmd.aliases) info += `\n**Aliases -** ${cmd.aliases.map(a => `\`${a}\``).join(", ")}`;
if(cmd.description) info += `**\nDescription -** ${cmd.description}`;
if(cmd.category) info += `**\nCategory -** ${cmd.category}`;
if(cmd.usage) {
info += `**\nUsage -** ${cmd.usage}`
embed.setFooter(`Syntax <> = Required, [] = Optional`);
}
embed.setThumbnail(message.guild.iconURL);
return message.channel.send(embed.setColor("GREEN").setDescription(info));
}
const{stripeindents}=require(“公共标记”);
module.exports={
姓名:“帮助”,
类别:“信息”,
description:“告诉您当前可以使用的commads”,
运行:异步(客户端、消息、参数)=>{
如果(参数[0]){
返回getCMD(客户端,消息,参数[0]);
}否则{
返回getALL(客户端、消息);
}
}
}
函数getALL(客户端、消息){
const embed=新的RichEmbed()
.setColor(“随机”)
.set缩略图(message.guild.iconURL)
常量命令=(类别)=>{
返回client.com命令
.filter(cmd=>cmd.category==category)
.map(cmd=>`**-***\`${cmd.name}\`)
.加入(“\n”);
}
const info=client.categories
.map(cat=>stripIndents`**${cat[0].toUpperCase()+cat.slice(1)}**\n${commands(cat)}`)
.reduce((字符串,类别)=>字符串+“\n”+类别);
返回message.channel.send(embed.setDescription(info));
}
函数getCMD(客户端、消息、输入){
const embed=新的RichEmbed()
const cmd=client.commands.get(input.toLowerCase())| | client.commands.get(client.alias.get(input.toLowerCase());
let info=`未找到命令**${input.toLowerCase()}**`的信息;
如果(!cmd){
返回message.channel.send(embed.setColor(“#ff0000”).setDescription(info));
}
if(cmd.name)info=`**Command name-**${cmd.name}`;
if(cmd.aliases)info+=`\n**aliases-**${cmd.aliases.map(a=>`\${a}\`)。join(“,”);
if(cmd.description)info+=`**\n说明-**${cmd.description}`;
if(cmd.category)info+=`**\n类别-**${cmd.category}`;
if(命令用法){
info+=`**\nUsage-**${cmd.usage}`
setFooter(`Syntax=Required,[]=Optional`);
}
embed.set缩略图(message.guild.iconURL);
返回message.channel.send(embed.setColor(“绿色”).setDescription(info));
}
单向创建排除arr,如果命令通道nsfw flag=false,则在此处按下“nsfw”,然后在过滤器上检查它
const{stripeindents}=require(“公共标记”);
module.exports={
姓名:“帮助”,
类别:“信息”,
description:“告诉您当前可以使用的commads”,
运行:异步(客户端、消息、参数)=>{
如果(参数[0]){
返回getCMD(客户端,消息,参数[0]);
}否则{
返回getALL(客户端、消息);
}
}
}
函数getALL(客户端、消息){
设ExcludeCategoryAr=[];
如果(!message.channel.nsfw)excludeCategoryArr.push('nsfw')除外
const embed=新的RichEmbed()
.setColor(“随机”)
.set缩略图(message.guild.iconURL)
常量命令=(类别)=>{
返回client.com命令
.filter(cmd=>cmd.category===category&&!excludeCategoryar.includes(cmd.category))
.map(cmd=>`**-***\`${cmd.name}\`)
.加入(“\n”);
}
const info=client.categories
.filter(类别=>!excludeCategoryArr.includes(类别))
.map(cat=>stripIndents`**${cat[0].toUpperCase()+cat.slice(1)}**\n${commands(cat)}`)
.reduce((字符串,类别)=>字符串+“\n”+类别);
返回message.channel.send(embed.setDescription(info));
}
函数getCMD(客户端、消息、输入){
const embed=新的RichEmbed()
const cmd=client.commands.get(input.toLowerCase())| | client.commands.get(client.alias.get(input.toLowerCase());
let info=`未找到命令**${input.toLowerCase()}**`的信息;
如果(!cmd){
返回message.channel.send(embed.setColor(“#ff0000”).setDescription(info));
}
if(cmd.category=='nsfw'&&!message.channel.nsfw){
返回消息.reply('我不能在非nsfw通道中显示NSWF命令')
}
if(cmd.name)info=`**Command name-**${cmd.name}`;
if(cmd.aliases)info+=`\n**aliases-**${cmd.aliases.map(a=>`\${a}\`)。join(“,”);
if(cmd.description)info+=`**\n说明-**${cmd.description}`;
if(cmd.category)info+=`**\n类别-**${cmd.category}`;
if(命令用法){
info+=`**\nUsage-**${cmd.usage}`
setFooter(`Syntax=Required,[]=Optional`);
}
embed.set缩略图(message.guild.iconURL);
返回message.channel.send(embed.setColor(“绿色”).setDescription(info));
}
如果可能的话,我试图找出如何隐藏我对管理员的命令,因此,如果管理员执行了帮助命令If将显示对他们的调节命令,我似乎无法找到答案。这就是我正在使用或试图使用的if(cmd.category=='moderation'&&!message.member.haspmission(“管理员”){return message.channel.send(“您没有使用这些的权限”)}