LorittaBot / Loritta

💁 A multipurpose, multilanguage, customizable, modular, and very cute bot for Discord! ~Making your server more awesome~
https://loritta.website/
GNU Affero General Public License v3.0
669 stars 170 forks source link

Devious Fun: Migrate Loritta from JDA to Kord #2613

Closed MrPowerGamerBR closed 2 years ago

MrPowerGamerBR commented 2 years ago

(from Bot Managers Guild)

guys i'm moving away from jda (real)

the reason I want to move away from JDA is because its cache

restarting your bot? time to process all guild create events all over again!!

This PR adds classes that looks like JDA, swims like JDA, and quacks like JDA, but pulls data from Redis instead of keeping it in memory (Somewhat, there are big changes on the classes too, they aren't a direct 1:1 copy of JDA's interfaces)

but behind the scenes it uses Kord's REST client and gateway client

mostly because I don't want to rewrite everything

also, I hate restarting the bot because it consumes identifies + takes a while because it needs to process all GuildCreate

mostly because GC pressure causing issues so I can't use all max 32 parallel logins

so my idea was like if I'm storing cache in Redis what if I stored the shard gateway session ID + seq number and when restarting the bot I can try resuming the gateway connection

however if the issue is rolling restarts, what could be done is waiting until the previous process has shut down its gw connection

you won't lose events because Discord will replay all events since sequence number here