Reputation: 87
I want to send a message from my discord bot to a specific user like myself using my discord id. I have tried the following code where my client object is named as bot:
bot.users.get("My Id copied from discord").send("Message to Send");
but it gives the following error in the terminal:
bot.users.get is not a function
Please help me in resolving this error. Thank you
Upvotes: 3
Views: 1672
Reputation: 5174
Since discord.js v12 you need to use cache
to access the users
collection
bot.users.cache.get('ID').send('hello')
You need to use users.fetch()
instead since the user might not be cached
const user = await bot.users.fetch('ID')
user.send('hello')
Upvotes: 2