admin管理员组文章数量:1289868
How to properly tag a user using message.channel.send in discord.js?
Here is my code:
function replaceAll(str, find, replacer) {
return str.replace(new RegExp(find, 'g'), replacer);
}
Bot.on('message', (message) => {
var mcontent = message.content;
var mauth = message.author;
var mtag = mauth.tag;
if (mcontent.includes("@p")) {
var newmsg = replaceAll(mcontent, "@p", "@" + mtag);
message.delete();
message.channel.send(newmsg);
});
And, it prints this: (By the way, I am hieyou1#6009) [with the message.delete(); disabled]
No console logs are present when I execute.
How to properly tag a user using message.channel.send in discord.js?
Here is my code:
function replaceAll(str, find, replacer) {
return str.replace(new RegExp(find, 'g'), replacer);
}
Bot.on('message', (message) => {
var mcontent = message.content;
var mauth = message.author;
var mtag = mauth.tag;
if (mcontent.includes("@p")) {
var newmsg = replaceAll(mcontent, "@p", "@" + mtag);
message.delete();
message.channel.send(newmsg);
});
And, it prints this: (By the way, I am hieyou1#6009) [with the message.delete(); disabled]
No console logs are present when I execute.
Share Improve this question edited Jun 21, 2018 at 13:01 panta82 2,7213 gold badges21 silver badges38 bronze badges asked Jun 20, 2018 at 23:38 MikeyMikey 3141 gold badge5 silver badges20 bronze badges1 Answer
Reset to default 7Mentions from the bot is a little bit different. You need to use <@userid>
.
But Discord.JS has a cleaner way to mention a user, instead of using message.author.tag
, just use message.author
. That will tag the user that sent the message.
message.channel.send(`Hey ${message.author} how's it going?`);
Or with the old way to concatenate the string:
message.channel.send("Hey " + message.author + " how's it going?");
本文标签: javascriptHow to properly tag a user using messagechannelsend in discordjsStack Overflow
版权声明:本文标题:javascript - How to properly tag a user using message.channel.send in discord.js - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741480979a2381170.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论