discord.js - DISCORD.JS 如何使用@user 进行验证
问题描述
client.on('message', msg => {
if(msg.content.startsWith('^approvedpr'))
(What do I put here)?
});
我尝试了其他人的所有代码,但没有成功。
解决方案
msg.author.send
您可以通过查看消息类文档了解您可以执行的所有操作,向其他用户发送 DM 。
client.on('message', msg => {
if (msg.content.startsWith('^approvedpr') {
msg.author.send("Whatever");
};
};
编辑:如果您尝试 DM 提及的用户,您可以使用msg.mentions.users
(文档链接)
client.on('message', msg => {
if (msg.content.startsWith('^approvedpr') {
//Get the first user that was mentioned
const mention = msg.mentions.users.first();
//Send them a DM
mention.send("Whatever");
};
};
推荐阅读
- flutter - 我的小部件不在中心事件中,它被中心小部件包裹
- javascript - VUE如何唤起keydown方法
- python - 在模板中使用 Django 的静态函数定位媒体文件时出现问题
- gis - Altair:如何使用 Altair.chart.project 类型中未列出的投影系统绘制等值线?
- excel - Microsoft Excel - 精确关键字搜索 - (从一组逗号分隔的关键字短语中搜索关键字短语)
- c# - Visual Studio 2015 带回异常窗口
- c# - out in **out string [][] teams** 是什么意思
- mysql - WAMP 不会更改 MySQL 版本
- regex - 带有移动正斜杠的 htaccess 短网址
- json - 为什么我的文本字符串会给出两个不同的 Sha 256 结果?