发送dm消息discord.py时出现问题

2024-09-30 04:35:43 发布

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

我的机器人中有一个命令,允许用户向我发送匿名消息。然而,当我测试命令时,我的机器人只向我发送消息的第一个字

    @commands.command(name='msgetika', aliases=['msgmax'])
    async def msgetika(self, ctx, message1=None):
        '''Send an annonymous message to maxhatt3r'''
        if message1 is None:
            await ctx.send('Please specify a message')

        maxid = await self.bot.fetch_user('584500826450427906')
        await maxid.send('Anonymous message: ' + message1)
        msg = await ctx.send('Sending message to max.')

        await ctx.message.delete()
        await asyncio.sleep(5)

        await msg.delete()

Tags: to命令selfnonesend消息message机器人
1条回答
网友
1楼 · 发布于 2024-09-30 04:35:43

如果要捕获整个短语,需要添加*View the docs here关于如何使用它,并查看代码下面的示例

   @commands.command(name='msgetika', aliases=['msgmax'])
    async def msgetika(self, ctx, *, message1=None):

using * and args

另外,除非您使用的是旧版本的discord.py,user ids are ^{}s

maxid = await self.bot.fetch_user(584500826450427906)

相关问题 更多 >

    热门问题