-1

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 =)

  • i have tried with ```@client.event @bot.command @client.event.``` and the function is ```async def on_message(message):``` – laurin amiet Nov 12 '20 at 14:55

1 Answers1

0

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")

...
Ironkey
  • 2,568
  • 1
  • 8
  • 30