我想发送带有嵌入禁止命令的消息(Discord.py)

时间:2021-06-29 07:20:46

标签: python discord.py

在 4. 和 5. 行我需要帮助。它不发送嵌入。

@Bot.command()
@has_permissions(ban_members=True)
async def ban(ctx, member : discord.Member=None, reason=None):
    if member == None or member == ctx.message.author:
        embed1 = discord.Embed(title="ERROR:", description="You can not ban yourself.", color=0x00ff00)
        await ctx.send(embed=embed1)
        return
    if reason == None: 
        reason = 'Nothing.'
    await ctx.guild.ban(member, reason=reason)
    await ctx.channel.send(f"{ctx.message.author} banned {member} from server. Reason:{reason}")```

1 个答案:

答案 0 :(得分:1)

await ctx.guild.ban(member, reason=reason)

期望被禁止的用户,而不是成员。 试试

await member.ban(reason=reason)

喜欢记录的here


@Bot.command()
@has_permissions(ban_members=True)
async def ban(ctx, member : discord.Member=None, reason=None):
    if member == None or member == ctx.message.author:
        embed1 = discord.Embed(title="ERROR:", description="You can not ban yourself.", color=0x00ff00)
        await ctx.send(embed=embed1)
        return
    if reason == None: 
        reason = 'Nothing.'
    await member.ban(reason=reason)
    await ctx.channel.send(f"{ctx.message.author} banned {member} from server. Reason:{reason}")