[英]How do I send a DM to a user in discord.js v13
我現在正在做的就是嘗試向自己發送一個 dm,看看我是否可以讓它工作。 我試過了:
client.users.cache.get(id).send('hi')
使用UserManager#send()
。 如果需要,這將創建一個 dm,然后發送消息
client.users.send(userId, "content")
請看這篇文章,它可以解決您的問題。
基本上它似乎發生的是get方法不像fetch那樣一致。 所以更喜歡使用 fetch 方法,它看起來像這樣:
const user = await client.users.cache.fetch(id)
user.send('hi')
如果您不在異步范圍內,則可以使用“then”方法:
client.users.cache.fetch(id)
.then((user) => user.send('hi'))
.catch(e => console.log(e))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.