laurin amiet
laurin amiet

Reputation: 15

Sending a DM to a specific user

Hello

what i want to do

Hello, i am trying to send a DM to a user who is triggering the following function:

    if message.content.startswith("!help"):
        await message.author.send("hello")

After a User sends !help into any of the discord server channels, i want the bot to send the user the message Hello as a DM

The problem

I dont get any errors theres just nothing happening if i type !help in a chat

Im a beginner so im happy for all the help i can get =)

Upvotes: -1

Views: 63

Answers (1)

Ironkey
Ironkey

Reputation: 2607

you shouldn't be using on_message to check for things like this. You should be handling this as a command.

assuming you have set up commands correctly...

import discord

from discord.ext import commands

client = commands.Bot(command_prefix=";")
client.remove_command('help')

...

@client.command()
async def help(ctx):
    await ctx.author.send("something")

...

Upvotes: 0

Related Questions