[英]Issue with sending dm messages discord.py
我的机器人中有一个命令,允许用户向我发送匿名消息。 但是,当我测试命令时,我的机器人只会将消息的第一个单词发送给我。
@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()
如果要捕获整个短语,则需要添加*
。 在此处查看有关使用此功能的文档,并查看代码下方的示例。
@commands.command(name='msgetika', aliases=['msgmax'])
async def msgetika(self, ctx, *, message1=None):
此外,除非您使用的是旧版本的 discord.py,否则用户 ID 为int
s 。
maxid = await self.bot.fetch_user(584500826450427906)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.