#How to get the user who triggered an event?
1 messages · Page 1 of 1 (latest)
could read the audit log entry
You have to read the audit log entry
I thought
But the event doesn't work
It won't do anything
I tried to set moderation intent, but it was useless
Nothing changed
show your code
# Intents
intents = discord.Intents.default()
intents.message_content = True
intents.guilds = True
bot = discord.Bot(help_command = None, intents=intents)
...
# The code
@commands.Cog.listener()
async def on_audit_log_entry(entry):
print(entry)
guilds is part of default, you don't need to set it
oh, I thought you were talking about the channel delete event
Yes, I know
Ohh no
That's working
My bot can't read audit logs
That's the problem
yea well then give it permissions for that
I did...I had given it moderation intent and it didn't work
And the bot has administrator permission
ah
So it must access it
And the cog you put that in is loaded for sure?
Hm, not sure why it doesn't work then
Maybe someone else knows why
Could it be a library bug?
Highly doubt it
Just get the audit log on the event.
@commands.Cog.listener()
without a self?
.rtfm guild.audit
I'm p sure that doesn't need a self (?)
In a cog it does ;3
how did you load the cog?
I copypasted only the intents part
I forgot to write self
But I have it in my code
cogs = [
"module1",
"module2"
]
for cog in cogs:
bot.load_extension(f"cogs.{cog}")
you can also do bot.load_extensions("cogs/")
not sure if that's the exact right syntax, I can't check my code rn, but just because it's simpler to manage a lot of cogs this way
I tried it, it threw an error
yea I'll send the right one in a bit, not too important rn tho
But that's okay, I have a cogs folder and all cogs in there
Why not
Soo, what should I do with that event?
cause your cogs are being loaded and that's not part of the issue rn :)
do you have that event in the same cog as the other event that works?
that'd be my only guess apart from that, if that's not the issue I'd just say do what dark said and get the audit log entry when the channel delete event is called
Yess, I meant it's always useful to know something new :D
That syntax you wanted to show me
ye I'll send it when I can check my code
Yes, I have multiple events
And all of them works
Except the audit log one
client.load_extension("cogs", recursive=True)
if you want to load all the cogs in one folder
without any hard coding list
my way was bot.load_extensions("cogs"), but you have to do bot.load_extensions("cogs.subfolder") for any subfolders
Cool thing
By the way, did you come up with a solution to that event?
show me the event pls
(how you code it)
Okay, one minute
import discord
from discord.ext import commands
class Events(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.Cog.listener()
async def on_audit_log_entry(self, entry):
print(entry)
def setup(bot):
bot.add_cog(Events(bot))
For example
Did u tried on_raw_audit log v
This one
Yes, this one works
Thank you