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

Discord fails to refresh after initial configuration until server restart #2116

Open
jpd236 opened this issue May 1, 2024 · 1 comment
Open

Comments

@jpd236
Copy link
Contributor

jpd236 commented May 1, 2024

I've tested the following sequence of events twice now:

  • Create a discord server/guild
  • Create an application/bot and associate it with the guild per the instructions on the hunt edit page
  • Create a new hunt or go to a hunt edit page

I'd expect the lists of Discord channels to be populated there for the various selectors, but they're empty, even after a few minutes. Upon restarting the server the lists are populated immediately.

I see there is an observer for changes to the "disable.discord" flag here which I'd expect to trigger the refresh loop upon completing configuration.

@ebroder
Copy link
Member

ebroder commented May 4, 2024

For reference, the relevant watcher is actually the one just above the disable.discord one:

const configCursor = Settings.find({ name: "discord.bot" });
this.configObserveHandle = configCursor.observe({
added: (doc) => this.updateBotConfig(doc),
changed: (doc) => this.updateBotConfig(doc),
removed: () => this.clearBotConfig(),
});

That causes JR to establish a gateway connection to Discord, and it then listens for various change events that get delivered over the connection. It also does an initial cache of the data at startup time (because you don't get an individual channelCreate event for every channel when you first connect, which is why this works after restarting the server.

However, it looks like getting added to a guild doesn't trigger (e.g.) channelCreate messages for the channels in the guild. Instead (looking at docs), it seems like channels and roles are included in the guildCreate event, so we need to break those out somehow.

I think the cacheResource logic further down is maybe a little too clever to easily adapt to this, but that would basically be the place to start improving the behavior here.

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

No branches or pull requests

2 participants