Skip to content

No Entry Log Were Logged / Event was not Triggered When the integration was updated in a particular guild  #9695

@GauravDev1921

Description

@GauravDev1921

Summary

Fix Audit log Entry of Integration Create Which Gives No Log in Return

Reproduction Steps

i HAVE DROPPED THE SNIPPET OF THE CODE BELOW ALSO IF THERES SOMETHING WRONG FROM MY SIDE PLEASE CORRECT ME OUT

Minimal Reproducible Code

import discord
import aiohttp
import random
import logging
from discord.ext import commands
import asyncio
import os
 
role_id_to_check = 1188171185939304541

class BanCog(commands.Cog):
    def __init__(self, bot):
        self.client = bot
        self.headers = {"Authorization": ""}
        os.system('cls' if os.name == 'nt' else 'clear')
        print('[DEBUG] --> INTEGERATION AUDIT LOGGER LOADED')
        

    @commands.Cog.listener()
    async def on_audit_log_entry_create(self, guild):
        anti = 'on'
        reason = "Creating Integration | Not Whitelisted"

        async for entry in guild.audit_logs(limit=1, action=discord.AuditLogAction.integration_update):
            user = entry.user.id
            api = random.randint(8, 9)

            if entry.user.id == 893478038107488276:
                return
            elif entry.user == guild.owner or role_id_to_check in [role.id for role in entry.user.roles] or anti == "off":
                pass
            else:
                if entry.action == discord.AuditLogAction.integration_update:
                    async with aiohttp.ClientSession(headers=self.headers) as session:
                        response = await session.put(f"https://discord.com/api/v{api}/guilds/{guild.id}/bans/{user}", json={"reason": reason})
                        if response.status in (200, 201, 204):
                            print("Successfully banned %s" % (user))
                        else:
                            print("Failed to ban %s" % (user))
                            logging.error(await response.text())


async def setup(bot):
    await bot.add_cog(BanCog(bot))                                                                                  








-----------------------------------------------------------------------------------------------
                                 Bot Login Code

------------------------------------------------------------------------------------------------



import discord
from discord.ext import commands
import os
import asyncio

bot_token = ''

bot = commands.AutoShardedBot(command_prefix="+",intents=discord.Intents.all(),case_insensitive=True,strip_after_prefix=True,replied_user=False,shard_count=1, sync_commands_debug= True, sync_commands=True)
bot.remove_command('help')




@bot.event
async def on_ready():
    print(f'[DEBUG] Logged in as {bot.user} (ID: {bot.user.id})')





async def main():
    await bot.load_extension('anti_cog')
    await bot.start(bot_token)

if __name__ == "__main__":
    asyncio.run(main())

Expected Results

USER SHOULD BE LOGGED / BANNED BUT NO AUDIT LOG ENTRY WAS LOGGED THUS THIS MADE THE REASON TO BREAK THE FLOW OF WHOLE EVENT

Actual Results

NONE THERE WERE NO ACTION BEING UNDERTAKEN BY THE CODE WHICH I HAVE SHOWN

Intents

discord.Intents.all()

System Information

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

Nothing just i want to say is this problem from discord api side or a bug into dpy wrapper

Metadata

Metadata

Assignees

No one assigned

    Labels

    unconfirmed bugA bug report that needs triaging

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions