1 回答

TA貢獻1784條經(jīng)驗 獲得超9個贊
async def create_embed(self, ctx, err):
embed = discord.Embed(title=f"Error Caught!",color=discord.Colour.red())
embed.add_field(name=f"Info on the error.", value=f"{err}")
embed.set_thumbnail(url=self.bot.user.avatar_url_as(static_format="png"))
message_cooldown = commands.CooldownMapping.from_cooldown(1.0, 60.0, commands.BucketType.user)
bucket = message_cooldown.get_bucket(ctx.message)
retry_after = bucket.update_rate_limit()
if retry_after:
return
else:
await ctx.send(embed=embed)
這是一個很好的例子,它在函數(shù)中創(chuàng)建嵌入,使代碼更干凈,以便捕獲錯誤,并確保它不會被冷卻映射垃圾郵件。
添加回答
舉報