让不和谐的机器人提到某人 [英] Making discord bot mention someone

查看:122
本文介绍了让不和谐的机器人提到某人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何让我的机器人在服务器上提及某人?

How do I make my bot mention someone on the server?

module.exports = {
 name: 'mention',
 description: 'this is a mention command!',
 execute(message) {
  mention = message.mentions.users.first();
  message.channel.send('Hello' + mention);
 },
};

我以为它可以用,但不能用.还有另一种提及某人的方法吗?

I thought it would work but it doesn't. Is there another way to mention someone?

推荐答案

message.mentions.users.first()返回一个对象,这就是为什么它不起作用的原因.这是提及某人的正确方法:

message.mentions.users.first() returns an object, which is why it's not working. This is the correct way to mention someone:

mention = message.mentions.users.first();
message.channel.send(`Hello <@${mention.id}>`);


为将来参考,以下是所有提及的格式:


For future reference, here are the formats for all mentions:

'<@{user.id}>' // user mention
'<#{channel.id}>' // channel mention
'<@&{role.id}>' // role mention
'<(a):{emoji.name}:{emoji.id}>' // emote (use 'a' at the front if emote is animated)

这篇关于让不和谐的机器人提到某人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆