Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Roles cache not setting to memory properly when it's stored outside memory but not in memory #13

Open
AwesomeStickz opened this issue Nov 1, 2022 · 3 comments

Comments

@AwesomeStickz
Copy link
Member

In https://github.com/discordeno/cache-proxy/blob/main/index.ts#L461, it's setting to bot.cache.roles.memory.set while if you have options.cacheInMemory.guilds set to true, the role must be set into the respective guild's role collection and not in the general one bot.cache.roles.memory.

@Larsundso
Copy link
Contributor

Does this still happen?

@Larsundso
Copy link
Contributor

client.cache.roles.get(963115006659026944n, 669893888856817665n)
> {
>  name: 'Role Name',
>  guildId: 669893888856817665n,
>  color: 0,
>  toggles: RoleToggles { bitfield: 1 },
>  id: 963115006659026944n,
>  permissions: 1071698255360n
> }

client.cache.roles.memory.get(963115006659026944n)
> undefined

If it does please tell how to reproduce

@AwesomeStickz
Copy link
Member Author

AwesomeStickz commented Nov 2, 2022

It should still happen, yes. The line I linked to is changed (cuz of the recent code changes) but it's this, setting straight into bot.cache.roles.memory even when it could be a guild role.

The code itself should be clear about the issue but if you want reproducible steps:

  1. Have cacheInMemory.guilds enabled
  2. Have both in memory cache and outside memory cache
  3. Keep both of these synced
  4. Delete one role from a guild (from memory but not from the cache outside memory)
  5. Now do bot.cache.roles.get(id)
  6. You'll see that there's one role set into bot.cache.roles.memory instead of setting it in that guild

Here's the fix I have in my fork: https://github.com/AwesomeStickz/dd-cache-proxy/blob/main/index.ts#L262, I didn't add that here because it's "a bit" inefficient because it'll be setting the role to the correct place (expected) and also be setting to the cache outside memory (this part is useless but idm in my fork, but maybe in here you'd want the best way so I just created it as an issue instead)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants