第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何為此事件添加冷卻時間或速率限制?不和諧.py

如何為此事件添加冷卻時間或速率限制?不和諧.py

海綿寶寶撒 2023-07-11 13:55:27
@commands.Cog.listener()    async def on_message(self, message):        user_in  = message.content.lower()        if "gn" in  user_in.split(" ") or "good night" in user_in :            if message.author.bot: return            if not message.guild: return            await message.channel.send(f"Good Night, <@{message.author.id}>")我需要知道如何為此事件添加冷卻時間,以便人們dont發(fā)送垃圾郵件gn或晚安
查看完整描述

1 回答

?
慕村225694

TA貢獻1880條經(jīng)驗 獲得超4個贊

查看完整回答
反對 回復(fù) 2023-07-11
?
千萬里不及你

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)建嵌入,使代碼更干凈,以便捕獲錯誤,并確保它不會被冷卻映射垃圾郵件。


查看完整回答
反對 回復(fù) 2023-07-11
  • 1 回答
  • 0 關(guān)注
  • 127 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號