我如何才能让我的不和谐机器人DM成员和我自己?

2024-03-29 12:47:56 发布

您现在位置:Python中文网/ 问答频道 /正文

如果可能的话,我如何让我的discord bot(在python中)给DM另一个用户和发送命令的人(告诉他们说了什么)?你知道吗

编辑:解决了,谢谢Patrick Haugh-https://stackoverflow.com/users/6779307/patrick-haugh 顺便说一句,这是我的代码,以防其他人有同样的问题:

@client.command()
async def dm(ctx, user: discord.User, *, message=None):
    if message == None:
        await ctx.send('You need to put a message')
    else:
        await user.send(message)
        await ctx.channel.purge(limit=1)
        await ctx.send('DM Sent')
        await ctx.author.send('"' + message + '"' + ' sent to ' + str(user))
        # just so i can see every dm (a bit creepy ik but hey it's my bot so i'll do it)
        print('"' + message + '"' + ' sent to ' + str(user))

Tags: tononesendmessagesobotitdm