I want to create a command like - /announcement
but I want to send message to every user of server in which bot is like:
Server a - will send
Server B - will send too by triggering one command, is this possible?
I want to create a command like - /announcement
but I want to send message to every user of server in which bot is like:
Server a - will send
Server B - will send too by triggering one command, is this possible?
You can use client.users
to get all the users that have been cached then you can do the following:
client.users.cache.forEach(user => {
user.send('hello')
})
Alternatively, you could loop through all your guilds using client.guilds
and while looping through them, loop through their members and send them messages.
client.guilds.cache.forEach(guild => {
guild.members.cache.forEach(member => {
member.send('hello')
})
})
Note: depending on the amount of users, this will take a long time to finish and will cause your bot to lag, along with the high chance of getting rate limited.