且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何检查是否提到了某个用户

更新时间:2023-12-02 23:36:04

您可以使用 Mentions#members#has 使用成员的ID来检查是否有提及,以及该成员是否为一个提及.

You can use Mentions#members#has using the member's id to check if there were any mentions, and if the member was one of the mentions.

const mentions = message.mentions.members;

if (!mentions) return message.channel.send('No Mentions Error Message.');

if (mentions.has('796406791323516999')) {
  message.channel.bulkDelete(1);
  message.channel.send('User mention was detected');
}