python - 嵌入形式的不和谐私人消息不起作用
问题描述
我想创建一个命令,使用 .helpDM 向用户发送嵌入的帮助
如您所见,我以事件形式尝试过。
@client.event
async def on_message(helpDM):
embed=discord.Embed(title='Hello',colour = discord.Colour.orange())
embed.add_field(name='Bomb', value=f'Deletes Messages in chat\n .bomb 100', inline=False)
embed.add_field(name='Luck', value=f'Like 8ball fourtune teller', inline=False)
embed.add_field(name='Tof', value=f'True or False', inline=False)
embed.add_field(name='Hitme', value=f'See me holy face', inline=False)
embed.add_field(name='Monkey', value=f'Random pic of monkey monkey', inline=False)
embed.add_field(name='Whois', value=f'Userinfo', inline=False)
embed.add_field(name='coin', value=f'Flips a coin', inline=False)
embed.add_field(name='Dice', value=f'Random number from 1 to 6', inline=False)
embed.add_field(name='Randomnumber', value=f'Gives you a random number from 1 to 100', inline=False)
embed.add_field(name='Meme', value=f'Random meme?', inline=False)
embed.add_field(name='Say', value=f'Says what ever you want the bot to say', inline=False)
embed.add_field(name='Kick', value=f'Kicks user (Needs Admin)', inline=False)
embed.add_field(name='Ban', value=f'Bans user (Needs Admin', inline=False)
embed.add_field(name='Unban', value=f'Revokes ban from user. (Needs Admin)', inline=False)
embed.add_field(name='Prefix', value=f'Changes prefix e.g .prefix !', inline=False)
await client.send_message(embed=embed)
# cllient.whisper wont work to
命令形式:
@client.command()
async def helpDMM(ctx, member: discord.Member=None):
embed=discord.Embed(title='Hello',colour = discord.Colour.orange())
embed.add_field(name='Bomb', value=f'Deletes Messages in chat\n .bomb 100', inline=False)
embed.add_field(name='Luck', value=f'Like 8ball fourtune teller', inline=False)
embed.add_field(name='Tof', value=f'True or False', inline=False)
embed.add_field(name='Hitme', value=f'See me holy face', inline=False)
embed.add_field(name='Monkey', value=f'Random pic of monkey monkey', inline=False)
embed.add_field(name='Whois', value=f'Userinfo', inline=False)
embed.add_field(name='coin', value=f'Flips a coin', inline=False)
embed.add_field(name='Dice', value=f'Random number from 1 to 6', inline=False)
embed.add_field(name='Randomnumber', value=f'Gives you a random number from 1 to 100', inline=False)
embed.add_field(name='Meme', value=f'Random meme?', inline=False)
embed.add_field(name='Say', value=f'Says what ever you want the bot to say', inline=False)
embed.add_field(name='Kick', value=f'Kicks user (Needs Admin)', inline=False)
embed.add_field(name='Ban', value=f'Bans user (Needs Admin', inline=False)
embed.add_field(name='Unban', value=f'Revokes ban from user. (Needs Admin)', inline=False)
embed.add_field(name='Prefix', value=f'Changes prefix e.g .prefix !', inline=False)
await client.whisper(embed=embed)
错误,
await client.send_message(embed=embed) AttributeError: 'Bot' object has no attribute 'send_message'
请注意,耳语也是如此……
解决方案
使用 discord.py 重写版本,您应该使用<channel>.send()
而不是<channel>.send_message()
推荐阅读
- excel - 将excel中的一列数字转换成多列
- java - 缺少通过 Java-Wrapper 向 Z3 添加表达式的批量模式
- python - matplotlib 中默认随机颜色
- isabelle - 为什么 Isabelle/HOL 2018 显示错误而没有错误消息?
- amazon-web-services - 是否可以生成 AWS Aurora MySql serverless 的图表
- ios - Swift:将文件从共享扩展上传到 Firebase 存储
- java - 找不到 xml 的 Jersey messagebodywriter
- python - 使用同时分配交换python列表中的元素时出错
- firebase - Firestore - 查询与列表中的值匹配的所有文档(如 SQL IN)
- firebase - 安全规则:在一个文档中存储唯一的用户名