我正在尝试发出锁定命令,这是我的代码:
module.exports = {
name: "lock",
description: "Lock",
async run(client, message, args) {
if (!message.member.hasPermission("KICK_MEMBERS")) return message.channel.send('You can\'t use that!')
function lock(message) {
let channel = message.channel;
let roles = message.guild.roles;
let testRole = roles.find('Verified');
channel.overwritePermissions(
testRole, {
'SEND_MESSAGES': false
},
'Competitive has Ended'
)
lock(message).catch(error => console.log(error));
}
message.channel.send('Channel Locked')
}
}
但是,在运行此代码时,我没有收到机器人的响应,也没有执行该功能。我也没有任何错误。玩具可以帮我吗?预先感谢!
答案 0 :(得分:0)
您定义了一个函数lock
,但是在错误的地方调用了它。您尝试在函数本身内调用lock函数,这将不起作用。如果将代码更改为以下代码,则它应该可以工作:
if (!message.member.hasPermission("KICK_MEMBERS")) return message.channel.send('You can\'t use that!')
function lock(message) {
let channel = message.channel;
let roles = message.guild.roles;
let testRole = roles.find('Verified');
channel.overwritePermissions(
testRole, {
'SEND_MESSAGES': false
},
'Competitive has Ended'
)
}
lock(message).catch(error => console.log(error));
message.channel.send('Channel Locked')