I'm working on a User Discord Bot in Python .If the bot owner types !DM @user
then the bot will DM the user that was mentioned by the owner.
@client.event
async def on_message(message):
if message.content.startswith('!DM'):
msg = 'This Message is send in DM'
await client.send_message(message.author, msg)
The easiest way to do this is with the
discord.ext.commands
extension. Here we use a converter to get the target user, and a keyword-only argument as an optional message to send them: