将DM发送给特定用户

时间:2020-11-12 14:53:31

标签: python function discord discord.py dm

你好

我想做什么

您好,我正在尝试向触发以下功能的用户发送DM:

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

用户将!help发送到任何不和谐的服务器通道中后,我希望该漫游器向用户发送消息Hello作为DM

问题

我没有收到任何错误,如果我在聊天中输入!help,则什么也没有发生

我是一个初学者,所以我为我可以获得的所有帮助感到高兴=)

1 个答案:

答案 0 :(得分:0)

您不应该使用on_message检查类似这样的事情。您应该将其作为命令来处理。

假设您已正确设置命令...

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

...