这首先是我的代码:
if (command === "detain") {
let member = message.mentions.members.first();
let det = new Discord.RichEmbed();
detainer = message.member;
let role = message.guild.roles.find(r => r.name === "Detained");
var a = function none() {
if (!member.roles.find(r => r.name === "Court")) {
message.members.removeRole(message.guild.roles.find(r => r.name === "Officer")).catch(console.error);
member.removeRole(role).catch(console.error);
det.setDescription("${message.author}, you have been impeached because no judges approved this detainment in the 5 minutes.");
}
};
if (args.length < 2) {
det.setDescription("Please add the reason this user has been detained.");
} else {
if (!message.member.roles.find(r => r.name === "Officer") && !message.member.roles.find(r => r.name === "Chief of Police")) {
det.setDescription("You must be an officer to use this command.");
} else {
det.setDescription(message.member + ", I have detained " + member + ". A judge must **!!approve** this detain within **5 minutes** or you will be IMPEACHED!");
member.addRole(role).catch(console.error);
setTimeout(a, 300000);
}
}
message.channel.send(det);
}
if (command === "approve") {
let member = message.mentions.members.first();
let detained = message.guild.roles.find(r => r.name === "Detained");
const approve = new Discord.RichEmbed();
if (message.member.roles.find(r => r.name === "Judge") || message.member.roles.find(r => r.name === "Chief Justice")) {
if (member.roles.find(r => r.name === "Detained")) {
member.removeRole(detained).catch(console.error);
member.addRole(message.guild.roles.find(r => r.name === "Court"));
approve.setDescription("${message.author}, " + member + " has been PUT IN COURT.");
let roleName = message.guild.roles.find(r => r.name === "Judge");
let membersWithJudge = message.guild.members.filter(member => {
return member.roles.find("name", roleName);
}).map(member => {
return member.user.username;
});
var membersWithActualJudge = membersWithJudge.filter(e => e !== message.member);
var judgeNum = (Math.random() * ((membersWithActualJudge.length) - 1) + 1)-1;
var judgeToUse = membersWithActualJudge[judgeNum];
var cj = message.guild.roles.find(r => r.name === "Chief Justice");
var cp = message.guild.roles.find(r => r.name === "Chief of Police");
message.guild.createChannel(detainer + "-vs-" + member, {
type: 'text',
permissionOverwrites: [{
id: 644313191962247178,
deny: ['SEND_MESSAGES'],
},
{
id: detainer.id,
allow: ['SEND_MESSAGES'],
},
{
id: cj.id,
allow: ['SEND_MESSAGES'],
},
{
id: cp.id,
allow: ['SEND_MESSAGES'],
},
],
});
let category = message.guild.channels.find(c => c.name == "Court" && c.type == "category"),
channel = message.guild.channels.find(c => c.name == (detainer + "-vs-" + member));
if (category && channel) {
channel.setParent(category.id);
const sendThing = new Discord.RichEmbed().setTitle("Court case: " + detainer + " vs. " + member + ". \n" + judgeToUse + " will be looking over this case.");
sendThing.setDescription(judgeToUse + ", remember to read the laws, rights, and interpretations before delivering your verdict.");
sendThing.addField("And always remember, feel free to ping [CENSORED], the President, or VP to get any help needed.");
channel.send(sendThing);
approve.setDescriiption("Approved successfully.");
}
} else {
approve.setDescription("This user is not detained.");
}
} else {
approve.setDescription("You must be a Judge to use this command.");
}
message.channel.send(approve);
}
所以基本上,我想要一个扣留命令和一个批准命令。有人将用户保留在静音的地方,而其他人则批准了。然后,它应该创建一个全新的频道并在其中搜索内容。这里的问题是1.我无法获取@everyone角色ID,2.无法在全球范围内存储该保持器,并且3. $ {message.author}无法正常工作。
我实际上没有太多其他东西了,但是请先感谢