如何让命令首先提及 ID 为“973182673306660885”的角色
How do I make a command give the first mention a role with the ID "973182673306660885"
我试过了,但不知何故“msg.mentions.users.first.addRole 不是函数”
let BotBanRole = msg.guild.roles.cache.find(r => r.id === "973182673306660885");
const FMT = msg.mentions.users.first();
if (msg.content.startsWith('$BotBan')) {
if (FMT === undefined) {
msg.reply('Did not detect user')
return; // Do not proceed, there is no user.
}
const FM = FMT.username;
// Do stuff with the username
msg.mentions.users.first.addRole(BotBanRole);
msg.reply('Bot Banned ' + FM.tag)
}
你很接近,试一试。
const BotBanRole = msg.guild.roles.cache.find(r => r.id === "973182673306660885");
const FMT = msg.mentions.members.first();
if (msg.content.startsWith('$BotBan')) {
if (!FMT) {
msg.reply('Did not detect user')
return;
} else {
FMT.roles.add(BotBanRole);
msg.reply(`Bot Banned ${FMT.user.username}`)
}
}
let BotBanRole = msg.guild.roles.cache.get("973182673306660885");
const FMT = msg.mentions.members.first();
if (msg.content.startsWith('$BotBan')) {
if (!msg.mentions.members.first()) {
msg.reply('Did not detect user')
return; // Do not proceed, there is no user.
}
const FM = FMT.user;
// Do stuff with the username
FMT.roles.add(BotBanRole);
msg.reply('Bot Banned ' + FM.tag)
}
我编辑了你的代码,如果它是 v13,它是这样工作的。
我试过了,但不知何故“msg.mentions.users.first.addRole 不是函数”
let BotBanRole = msg.guild.roles.cache.find(r => r.id === "973182673306660885");
const FMT = msg.mentions.users.first();
if (msg.content.startsWith('$BotBan')) {
if (FMT === undefined) {
msg.reply('Did not detect user')
return; // Do not proceed, there is no user.
}
const FM = FMT.username;
// Do stuff with the username
msg.mentions.users.first.addRole(BotBanRole);
msg.reply('Bot Banned ' + FM.tag)
}
你很接近,试一试。
const BotBanRole = msg.guild.roles.cache.find(r => r.id === "973182673306660885");
const FMT = msg.mentions.members.first();
if (msg.content.startsWith('$BotBan')) {
if (!FMT) {
msg.reply('Did not detect user')
return;
} else {
FMT.roles.add(BotBanRole);
msg.reply(`Bot Banned ${FMT.user.username}`)
}
}
let BotBanRole = msg.guild.roles.cache.get("973182673306660885");
const FMT = msg.mentions.members.first();
if (msg.content.startsWith('$BotBan')) {
if (!msg.mentions.members.first()) {
msg.reply('Did not detect user')
return; // Do not proceed, there is no user.
}
const FM = FMT.user;
// Do stuff with the username
FMT.roles.add(BotBanRole);
msg.reply('Bot Banned ' + FM.tag)
}
我编辑了你的代码,如果它是 v13,它是这样工作的。