【发布时间】:2022-01-12 01:12:13
【问题描述】:
所以我尝试了很多方法将频道锁定为特定角色,这是我的尝试代码之一:
锁定频道
const Command = require("../structures/Command.js");
const { Permissions } = require('discord.js');
module.exports = new Command({
name: "lock",
description: "lock the channel that the command is executed",
async run(message, args, client) {
if (message.author.bot) return;
if (message.member.permissions.has(Permissions.FLAGS.ADMINISTRATOR)){
let role = message.guild.roles.cache(r => r.id === "895151537511362600");
role.overwritePermissions(UserResolvable, {
VIEW_CHANNEL: true,
SEND_MESSAGES: false,
READ_MESSAGE_HISTORY: true,
ATTACH_FILES: false
});
} else message.reply(`why do you want to use a mod command when you're not a mod`)
}
});
解锁:
const Command = require("../structures/Command.js");
const { Permissions } = require('discord.js');
module.exports = new Command({
name: "unlock",
description: "unlock the channel that the command is executed",
async run(message, args, client) {
if (message.author.bot) return;
if (message.member.permissions.has(Permissions.FLAGS.ADMINISTRATOR)){
let role = message.guild.roles.cache(r => r.id === "895151537511362600");
role.overwritePermissions(UserResolvable, {
VIEW_CHANNEL: true,
SEND_MESSAGES: true,
READ_MESSAGE_HISTORY: true,
ATTACH_FILES: true
});
} else message.reply(`why do you want to use a mod command when you're not a mod`)
}
});
它不起作用,还返回一个错误说UserResolvable is not defined
我也试过this method 还是不行
【问题讨论】:
-
您链接的问题的答案是“//传递 'UserResolvable' 类型的东西,如 Wiki 中所述!”换句话说,将其替换为用户可解析的
标签: javascript discord.js