jkomoros / flux-bot

Discord bot for GALE-x
3 stars 1 forks source link

Be more efficient about processing when channelUpdate #15

Open jkomoros opened 3 years ago

jkomoros commented 3 years ago

That happens ALL the time, every time a channel has its position changed.

One idea is to have the channel indexes have very large gaps, and when the channels are updated, only update the index if necessary to get it in the right order. And then skip channels whose position numbers don't need to be udpated.

jkomoros commented 3 years ago

https://github.com/Rapptz/discord.py/issues/2392#issuecomment-707455919 documents the oddities of position parameter.

Note that every time you reorder int he discord ui, it renumbers other channels in the category consectuvively, so any clever scheme to leave lots of gaps would be overwritten by that often

jkomoros commented 3 years ago

Another approach is to blow away the guildInfo cache when channelUpdate happens and then regenerate it on demand. That will allow it to update fewer times than the number of guild updates in genearl