嵌入不发送,我没有错误
the embed do not send and i didint have errors
@commands.has_permissions(administrator=True)
@bot.command()
async def ban(ctx, member : discord.Member, *, reason=None):
await member.send (f"{member.mention} text {ctx.guild.name} for the reason: {reason} ")
await member.ban(reason=reason)
await ctx.send (title=f"**__text:__**", description=f"{member.mention} \n **text:** \n *{reason}*", timestamp=datetime.datetime.utcnow(),color=discord.Color.blue()) .embed.set_footer (text="text ", icon_url="url")
if reason is None:
reason = f"{member.mention} was banned without reasons {ctx.guild.name} "
return reason
我没有错误,嵌入没有发送
我会推荐你一个更好的部门,以尽量减少错误的来源。最好的方法是定义一个嵌入。
看看下面的代码:
@commands.has_permissions(administrator=True)
@bot.command()
async def ban(ctx, member : discord.Member, *, reason=None):
await member.send(f"{member.mention} text {ctx.guild.name} for the reason: {reason} ")
await member.ban(reason=reason)
embed = discord.Embed(color=discord.Color.blue())
embed.title = "__Text__" # Title is always bold
embed.description = f"{member.mention} \n **text:** \n *{reason}*"
embed.timestamp = datetime.datetime.utcnow() # New timestamp
embed.set_footer(text="This is a test", icon_url="PassUrl")
await ctx.send (embed=embed) # Send defined embed
if reason is None:
reason = f"{member.mention} was banned without reasons {ctx.guild.name} "
return await ctx.send(f"{reason}")
还要注意适当的缩进,可能空格过多等。
也许还可以查看 docs 以及如何创建有效的嵌入。
@commands.has_permissions(administrator=True)
@bot.command()
async def ban(ctx, member : discord.Member, *, reason=None):
await member.send (f"{member.mention} text {ctx.guild.name} for the reason: {reason} ")
await member.ban(reason=reason)
await ctx.send (title=f"**__text:__**", description=f"{member.mention} \n **text:** \n *{reason}*", timestamp=datetime.datetime.utcnow(),color=discord.Color.blue()) .embed.set_footer (text="text ", icon_url="url")
if reason is None:
reason = f"{member.mention} was banned without reasons {ctx.guild.name} "
return reason
我没有错误,嵌入没有发送
我会推荐你一个更好的部门,以尽量减少错误的来源。最好的方法是定义一个嵌入。
看看下面的代码:
@commands.has_permissions(administrator=True)
@bot.command()
async def ban(ctx, member : discord.Member, *, reason=None):
await member.send(f"{member.mention} text {ctx.guild.name} for the reason: {reason} ")
await member.ban(reason=reason)
embed = discord.Embed(color=discord.Color.blue())
embed.title = "__Text__" # Title is always bold
embed.description = f"{member.mention} \n **text:** \n *{reason}*"
embed.timestamp = datetime.datetime.utcnow() # New timestamp
embed.set_footer(text="This is a test", icon_url="PassUrl")
await ctx.send (embed=embed) # Send defined embed
if reason is None:
reason = f"{member.mention} was banned without reasons {ctx.guild.name} "
return await ctx.send(f"{reason}")
还要注意适当的缩进,可能空格过多等。
也许还可以查看 docs 以及如何创建有效的嵌入。