Reputation: 57
I'm trying to make my bot message a user directly if they type a certain word, for example the letter 'E', but I can't figure out how to do this. Any help is appreciated!
Upvotes: 0
Views: 1392
Reputation: 4700
You can use the Member.create_dm()
method
@bot.event
async def on_message(message):
if message.content.lower() == "e":
dmchannel = await message.author.create_dm()
await dmchannel.send("You typed E!")
Upvotes: 0
Reputation: 387
Here few points to note that :
message.channel.send(<message>)
function is used for public responses like on sever.
message.author.send(<message>)
function is used for private responses or for direct message(DM).
@bot.event
async def on_message(message):
if(message.content == 'E'):
await message.author.send('You typed E!')`enter code here`
Upvotes: 1
Reputation: 25
I'm guessing this is what you mean:
@bot.event
async def on_message(message):
if(message.content == 'E'):
await message.author.send('You typed E!')
Upvotes: 1