43 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!Wdym “not working”?
Are you even checking that the audit log is related to channel overwrites?
Previously, I could restore old PermissionOverwrites settings using the audit log.
But now you get an error?
yes
No it works but it just creates PermissionOverwrites without the old features
Does this event not trigger itself?
Looks like a recipe for botception
we are checking to make sure that it is not the bot itself that is doing this
Can you show the entire event?
I thought the overwrite id was in the entry.extra object
entry.extra object has 4 types of Role | GuildMember | { id: Snowflake; name: string; type: AuditLogOptionsType.Role } | { id: Snowflake; type: AuditLogOptionsType.Member };
Depends on the audit log type
depends on whether permissionOverwrites itself, which we touch, is cached as I understand it, and not on what you say
Discord Developer Portal
Discord Developer Portal — API Docs for Bots and Developers
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
in d.js it doesn't work like that, we may receive a role object or { id: Snowflake; name: string; type: AuditLogOptionsType.Role }
if cached then there will be a role object if we deleted the role rights if not then what is above
GitHub
discord.js/packages/discord.js/src/structures/GuildAuditLogsEntry.j...
A powerful JavaScript library for interacting with the Discord API - discordjs/discord.js
Defaults to a raw object if it’s not cached
id is guaranteed regardless
Would suck if it was referring to a member who left the Guild otherwise
I made such a crutch for now because in other events the audit log does not always arrive either
You can use the in operator for a quick type guard
if ("type" in extra) typeOverwrite = extra.type
Would be nice to have an easier type guard for this tho
?
Maybe
entry.actionTypeIs(ActionType.…)
Yeayes
Honestly, I don’t see anything blatantly wrong
When you say it’s created w/o the old data, do you mean all permissions are neutral/middle
yes
Can you log allow, deny, and changes?
when i did this it started working
and now you need to specify channel.permissionOverwrites.edit(extra.id, { AddReactions: false });
which is a bit annoying because I don't get the same information from the audit log
It’s prob easier to set them all at once
Just gotta make sure that race coeditions don’t occur
another option is to simply do it in the library itself
Although, it prob isn’t hard to make a function that converts between the two types easily
Gl keeping that code working in future updates
Oh, PermissionOverwrites.resolve alr exists
It's hard for me to translate, I don't understand everything, can you explain?
Or is that the wrong way
Gl what is this
and I understood
not quite like that, some rights I need are old
then this decision remains for now
Good luck
yes, thank you, I already understood ahahahaha
I rly don’t think it’s that hard to convert to an perm overwrite option object
Could do some micro optimizations to do a single loop
The assignment isn’t correct in the forEach
Also if ur gonna do that, just throw the array into Object.from entries
Oh, I see
Assignment still is incorrect tho. deny should be set to false
Then you just add the all flags at the beginning of the array
but I would still like a simpler option and not do this
Prob just make a utility function