[英]Saving variable of a message in discord.js
i like to save my sended DM to a user in a local variable.我喜欢将我发送的 DM 保存到本地变量中的用户。 How can I do this?我怎样才能做到这一点? I would like to react on that message, but if I use.then() after or before the required.catch()-block, the log says "Cannot send messages to this user", without it, I can send the message..我想对该消息做出反应,但如果我在 required.catch() 块之后或之前使用.then(),日志会显示“无法向该用户发送消息”,没有它,我可以发送消息。 .
Thank you!!谢谢!!
Code:代码:
client.users.cache
.get(memb.id)
.send(emb5)
.catch((msb) => {
write("Error");
})
.then((msg) => {
msg.react(one);
});
one is the emoji...一个是表情符号...
If you are in an async function you can put the message in a variable like this:如果您在异步 function中,则可以将消息放入如下变量中:
const user = await client.users.fetch(mem.id); // Fetching the user
const awaitedMessage = await user.send(emb5); // Send the message to the user
awaitedMessage.react(one); // React the sent message
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.