【发布时间】:2021-10-10 03:09:20
【问题描述】:
module.exports = {
name: "mute",
description: "Use this to mute members",
execute: async function (msg, arg) {
const muterole = await msg.guild.roles.cache.find((r) => r.name == "Mute");
let promise = new Promise(async function (resolve, reject) {
if (muterole) {
resolve(commandmute(msg, arg));
} else {
reject(createrole(msg, arg));
}
});
async function createrole(msg, arg) {
msg.guild.roles.create({
data: {
name: "Mute",
},
reason: "This is a mute role created by the bot ",
});
const tole = msg.guild.roles.cache.find((r) => r.name == "Mute");
const ch1 = msg.guild.channels.cache.forEach((ch, msg) => {
if ((ch = msg.guild.channels.type("text"))) {
ch.updateOverwrite(tole, { VIEW_MESSAGES: true, SEND_MESSAGES: true });
}
msg.reply("It seems that the server doesnt have a Mute role so the bot has created one ");
msg.reply("Successfully created the role");
});
}
function commandmute(msg, arg) {}
},
};
所以我使用 promise 来检查服务器是否具有静音角色,如果没有,它将传递给一个函数,该函数将创建一个名为“静音”的角色。
现在的问题是我无法弄清楚如何更改频道中角色的权限,以使具有上述角色的用户无法发送消息。
另外,我无法通过 role.id 获取角色的 id。 它显示未定义。
【问题讨论】:
-
我没有看到你在任何地方定义
role。它在哪里?
标签: javascript node.js discord discord.js