Discord-History-Tracker icon indicating copy to clipboard operation
Discord-History-Tracker copied to clipboard

Save button data?

Open TheTechRobo opened this issue 2 years ago • 10 comments

I can't seem to find the data for Discord buttons anywhere in the DB. Am I missing something?

Example: image

TheTechRobo avatar Dec 01 '21 02:12 TheTechRobo

If they're embeds, their definition should be saved. If not, then DHT doesn't save them, and probably never will. Discord has so many features now that I don't have the time or will to figure out how everything works, faithfully replicate it, and fix it every time they change something.

chylex avatar Dec 01 '21 02:12 chylex

I'd like to pick this up (but no promises). Where is the tracking script for the app stored?

TheTechRobo avatar Dec 02 '21 00:12 TheTechRobo

It's in app/Resources/Tracker. The app folder has a minify.py Python script, make sure to run it anytime you change the scripts, otherwise the app won't see the changes. If you use Rider, there is a run configuration for the Python script:

obrazek

Keep in mind that depending on how complicated it ends up being, I probably won't accept a PR because I don't want to maintain another complicated part of DHT that might get broken anytime Discord updates.

chylex avatar Dec 02 '21 00:12 chylex

By analysing the network traffic, I found that it's in the "Components" JSON key!!

image

Now I just need to figure out how DHT's code works. I doubt that the button JSON will change but if it does, it'll probably be a simple fix.

TheTechRobo avatar Dec 02 '21 01:12 TheTechRobo

Do I just have to add id: msg.components, to this or is there more?

https://github.com/chylex/Discord-History-Tracker/blob/master/app/Resources/Tracker/scripts/state.js#L223

TheTechRobo avatar Dec 02 '21 01:12 TheTechRobo

Off the top of my head, assuming you will want to store this in a new table:

  • Update database schema to create the new table
  • Bump the schema version and write a migration for older versions of the database
  • Update the Message entity to include the components
  • Update SqliteDatabaseFile to save/retrieve the components
  • Update the tracker so it sends the components to the local server
  • Update TrackMessagesEndpoint to parse out the components from the request

If you want them in the viewer, you will also need to:

  • Update ViewerJsonExport to include the components in the viewer file
  • Update the viewer scripts and styles to generate some UI for the components

chylex avatar Dec 02 '21 23:12 chylex

For starters I won't add it to the viewer. It's not important, IMO.

The following is a note for myself.

  • table can be added in https://github.com/chylex/Discord-History-Tracker/blob/master/app/Server/Database/Sqlite/Schema.cs pretty easily. only trouble is, that doesn't seem to be called on subsequent launches meaning the table wont exist if you're opening an existing db
  • migration: line 26 of the aforementioned file checks for migration i think?
  • message: this? https://github.com/chylex/Discord-History-Tracker/blob/master/app/Server/Data/Message.cs
  • https://github.com/chylex/Discord-History-Tracker/blob/master/app/Server/Database/Sqlite/SqliteDatabaseFile.cs
  • Tracker: no idea, will have to look at this folder https://github.com/chylex/Discord-History-Tracker/tree/master/app/Resources/Tracker/scripts
    • state.js seems like a fair bet
  • No idea, will have to check

TheTechRobo avatar Dec 04 '21 02:12 TheTechRobo

only trouble is, that doesn't seem to be called on subsequent launches meaning the table wont exist if you're opening an existing db

That's why the migration system exists.

chylex avatar Dec 04 '21 04:12 chylex

Yep, figured that otu later

TheTechRobo avatar Dec 04 '21 13:12 TheTechRobo

I'm no longer using this scraping tool for Discord, so I probably won't be doing this (especially since I have zero experience with .NET). If anyone wants to pick this up, my notes in a previous comment might be a good starting point.

TheTechRobo avatar Jun 18 '22 16:06 TheTechRobo

Closing in favor of #247.

chylex avatar Dec 31 '23 16:12 chylex