如何标记机器人的所有者
How to tag the owner of the bot
您好,我正在制作一个机器人来说明机器人的信息,但我希望它将我标记为所有者。
var owner = [ <@574798611552927745> ];
let argsS = message.content.substring(PREFIX.length).split(" ");
if (argsS[1] === 'version') {
message.channel.send('The **Mafia Bot** is currently at version: **' + version + '**!');
} else {
message.channel.send(`**The Mafia Bot** was made by ${owner}`);
}
break;
虽然我不能使用 <@
,也没有其他我能找到的标记我的方法。
您可以手动标记使用方式 在字符串中:"<@574798611552927745>"
。
但这不是一个好方法:每次有人使用该命令时,您都会收到通知(除非您禁用提及的通知,但随后您会失去真正的提及),并且,如果您希望该机器人在其他公会中可用, 如果与您无关的人看到它,它将显示 "invalid user"。
最好的方法是只显示你的 name#1234
标签,或者,如果你真的想,只在你在公会中时提及你。
const owner = await client.fetchUser('user id here');
// Always show the tag
message.channel.send(owner.tag);
// Show the tag only if you're in the guild
let areYouInGuild = !!message.guild.member(owner);
message.channel.send(areYouInGuild ? owner : owner.tag);
// Always tag you
message.channel.send(owner);
您好,我正在制作一个机器人来说明机器人的信息,但我希望它将我标记为所有者。
var owner = [ <@574798611552927745> ];
let argsS = message.content.substring(PREFIX.length).split(" ");
if (argsS[1] === 'version') {
message.channel.send('The **Mafia Bot** is currently at version: **' + version + '**!');
} else {
message.channel.send(`**The Mafia Bot** was made by ${owner}`);
}
break;
虽然我不能使用 <@
,也没有其他我能找到的标记我的方法。
您可以手动标记使用方式 在字符串中:"<@574798611552927745>"
。
但这不是一个好方法:每次有人使用该命令时,您都会收到通知(除非您禁用提及的通知,但随后您会失去真正的提及),并且,如果您希望该机器人在其他公会中可用, 如果与您无关的人看到它,它将显示 "invalid user"。
最好的方法是只显示你的 name#1234
标签,或者,如果你真的想,只在你在公会中时提及你。
const owner = await client.fetchUser('user id here');
// Always show the tag
message.channel.send(owner.tag);
// Show the tag only if you're in the guild
let areYouInGuild = !!message.guild.member(owner);
message.channel.send(areYouInGuild ? owner : owner.tag);
// Always tag you
message.channel.send(owner);