All I'm doing right now is trying to send a dm to myself to see if I can get this working. I've tried:
client.users.cache.get(id).send('hi')
Use UserManager#send()
. This will create a dm if needed, then send the message
client.users.send(userId, "content")
Please take look at this post , it could resolve your problem.
Basically what it seems to happen is that the get method isn't consistent like fetch. So prefer to use the fetch method, it will look something like this:
const user = await client.users.cache.fetch(id)
user.send('hi')
if you're not in a asynchronous scope you could use the "then" approach:
client.users.cache.fetch(id)
.then((user) => user.send('hi'))
.catch(e => console.log(e))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.