דילוג לתוכן
  • חוקי הפורום
  • פופולרי
  • לא נפתר
  • משתמשים
  • חיפוש גוגל בפורום
  • צור קשר
עיצובים
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • ברירת מחדל (ללא עיצוב (ברירת מחדל))
  • ללא עיצוב (ברירת מחדל)
כיווץ
מתמחים טופ
  1. דף הבית
  2. קטגוריות בהרצה
  3. תכנות
  4. Python
  5. עזרה הדדית - Python
  6. בעיה | discord.py on_message_delete לא תמיד עובד

בעיה | discord.py on_message_delete לא תמיד עובד

מתוזמן נעוץ נעול הועבר עזרה הדדית - Python
4 פוסטים 2 כותבים 73 צפיות 1 עוקבים
  • מהישן לחדש
  • מהחדש לישן
  • הכי הרבה הצבעות
תגובה
  • תגובה כנושא
התחברו כדי לפרסם תגובה
נושא זה נמחק. רק משתמשים עם הרשאות מתאימות יוכלו לצפות בו.
  • Y מנותק
    Y מנותק
    Yehuda 1
    כתב ב נערך לאחרונה על ידי Yehuda 1
    #1

    בספרייה discord.py יש את האיוונט on_message_delete הבעיה היא שלפעמים הוא עובד ולפעמים לא כאילו יש לו מצבי רוח כל שאר האיוונטים עובדים חלק למישהו יש פיתרון לזה? (יש לבוט גישות מלאות)

    אשמח לעזרה ממש דחוף

    צדיק תמיםצ תגובה 1 תגובה אחרונה
    0
    • Y מנותק
      Y מנותק
      Yehuda 1
      כתב ב נערך לאחרונה על ידי Yehuda 1
      #2

      הקוד:

      import nextcord
      from nextcord.ext import commands
      
      
      class MainLogs(commands.Cog):
          def __init__(self, client: commands.Bot):
              self.client = client
      
          @commands.Cog.listener()
          async def on_ready(self):
              guild = self.client.get_guild(int(open('./data/guild_id', 'r').read()))
              channel = nextcord.utils.get(guild.channels,
                                           id=int(open('./data/logs_channel', 'r').read()))
      
              audit_old = guild.audit_logs(limit=1)
              finish = False
              async for i in audit_old:
                  audit_old = i
              while not finish:
                  audit_new = guild.audit_logs(limit=1)
                  async for log in audit_new:
                      audit_new = log
                  if audit_new != audit_old:
                      if audit_new.action == nextcord.AuditLogAction.message_delete:
                          print('Message deleted')
                  audit_old = audit_new
      
      
      def setup(client):
          client.add_cog(MainLogs(client))
      
      

      גם הקוד הזה לא עובד:

      import nextcord
      from nextcord.ext import commands
      import datetime
      
      def GetLogsChannel(guild):
          channel = nextcord.utils.get(guild.channels, id=int(open(r'./data/logs_channel', 'r').read()))
          return channel
      
      
      class MessageDelete(commands.Cog):
          def __init__(self, client):
              self.client = client
      
          @commands.Cog.listener('on_message_delete')
          async def on_message_delete(self, message: nextcord.Message):
              log_channel = GetLogsChannel(message.guild)
              audit_logs = await message.guild.audit_logs(limit=1).flatten()
              for entry in audit_logs:
                  if entry.action == nextcord.AuditLogAction.message_delete:
                      print('message deleted')
                      deleter = entry.user
                      embed = nextcord.Embed(title='Message deleted',
                                             description=f'{deleter.mention} Deleted message by {message.author.mention} '
                                                         f'at {message.channel.mention}',
                                             color=0x0366fc)
                      embed.add_field(name='Message content:', value=message.content)
                      embed.timestamp = datetime.datetime.now()
                      embed.set_footer(text=f'Crazy Party Logs \u200b',
                                       icon_url='https://cdn.discordapp.com/attachments/111430432223527'
                                                '3287/1142212995460640828/unknown.png')
                      await log_channel.send(embed=embed)
      
      
      def setup(client: commands.Bot):
          client.add_cog(MessageDelete(client))
      
      תגובה 1 תגובה אחרונה
      0
      • Y Yehuda 1

        בספרייה discord.py יש את האיוונט on_message_delete הבעיה היא שלפעמים הוא עובד ולפעמים לא כאילו יש לו מצבי רוח כל שאר האיוונטים עובדים חלק למישהו יש פיתרון לזה? (יש לבוט גישות מלאות)

        אשמח לעזרה ממש דחוף

        צדיק תמיםצ מנותק
        צדיק תמיםצ מנותק
        צדיק תמים
        מדריכים
        כתב ב נערך לאחרונה על ידי
        #3

        @Yehuda-1 מהתיעוד:

        Called when a message is deleted. If the message is not found in the
        internal message cache, then this event will not be called.
        Messages might not be in cache if the message is too old
        or the client is participating in high traffic guilds.
        If this occurs increase the max_messages parameter

        תנסה...

        רוצה לזכור קריאת שמע בזמן? לחץ כאן! || אתר שכולו מדריכים

        Y תגובה 1 תגובה אחרונה
        1
        • צדיק תמיםצ צדיק תמים

          @Yehuda-1 מהתיעוד:

          Called when a message is deleted. If the message is not found in the
          internal message cache, then this event will not be called.
          Messages might not be in cache if the message is too old
          or the client is participating in high traffic guilds.
          If this occurs increase the max_messages parameter

          תנסה...

          Y מנותק
          Y מנותק
          Yehuda 1
          כתב ב נערך לאחרונה על ידי
          #4

          @צדיק-תמים תודה רבה זה עזר באמת.

          תגובה 1 תגובה אחרונה
          1

          • התחברות

          • אין לך חשבון עדיין? הרשמה

          • התחברו או הירשמו כדי לחפש.
          • פוסט ראשון
            פוסט אחרון
          0
          • חוקי הפורום
          • פופולרי
          • לא נפתר
          • משתמשים
          • חיפוש גוגל בפורום
          • צור קשר