我有一个静音系统discord.js的疑问
我的静音系统有问题。如果我发送+MUTE @member
它不会发挥作用。
client.on('message', message => {
if (message.content === "+mute") {
if (!message.member.permissions.has("MANAGE_ROLES")) {
return message.reply({content: `You need permissions to use command`})
const mutedRole = message.guild.roles.cache.get('<986283559092359228>');
if (!mutedRole)
return message.reply('There is no Muted role on this server');
const member = message.mentions.members.first();
member.roles.add(role);
message.channel.send(member + 'has Been Muted');
} else {
message.channel.send("You didn't mention the user to mute!")
}
}
})
I have a problem with my mute system. If I send +mute @member
it doesn't give a role.
client.on('message', message => {
if (message.content === "+mute") {
if (!message.member.permissions.has("MANAGE_ROLES")) {
return message.reply({content: `You need permissions to use command`})
const mutedRole = message.guild.roles.cache.get('<986283559092359228>');
if (!mutedRole)
return message.reply('There is no Muted role on this server');
const member = message.mentions.members.first();
member.roles.add(role);
message.channel.send(member + 'has Been Muted');
} else {
message.channel.send("You didn't mention the user to mute!")
}
}
})
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您将静音角色定义为
mutedrole
,但是当您赋予会员一个角色时 - 您使用角色
不存在的角色,因此解决方案很简单,更改成员.roles.add(role);
tomember.roles.add(mutedRole);
You define your mute role as
mutedRole
, but when you give member a role - you userole
, which doesn't exist, so solution is simple, changemember.roles.add(role);
tomember.roles.add(mutedRole);
您只需要在定义muterole时写下角色ID,因此请将其更改
为
proam.Add()
中的相同名称mutedrole
,然后使用try/try/捕获
,因为机器人不能扮演高于其最高角色的角色,因此请尝试:要添加,您
还需要检查用户是否已经具有
mutedrole
或不You need to write only the role ID when defining muteRole, so change this
To this
Then use the same name
mutedRole
inrole.add()
and usetry/catch
because the bot cannot give a role that is higher than its highest role, so try:Just to add, you can directly do
You also need to check if the user has the
mutedRole
already or not