Since the big migration to v1.0, send_message
no longer exists.
Instead, they've migrated to .send()
on each respective endpoint (members, guilds etc).
An example for v1.0 would be:
async def on_message(self, message):
if message.content == '!verify':
await message.author.send("Your message goes here")
Which would DM the sender of !verify
. Like wise, you could do:
for guild in client.guilds:
for channel in guild.channels:
channel.send("Hey yall!")
If you wanted to send a "hi yall" message to all your servers and all the channels that the bot is in.
Since it might not have been entirely clear (judging by a comment), the tricky part might get the users identity handle from the client/session. If you need to send a message to a user that hasn't sent a message, and there for is outside of the on_message
event. You will have to either:
- Loop through your channels and grab the handle based on some criteria
- Store user handles/entities and access them with a internal identifier
But the only way to send to a user, is through the client identity handle which, in on_message
resides in message.author
, or in a channel that's in guild.channels[index].members[index]
. To better understand this, i recommend reading the official docs on how to send a DM?.