chylex / Discord-History-Tracker

Desktop app & browser script that saves Discord chat history into a file, and an offline viewer that displays the file.
https://dht.chylex.com
MIT License
475 stars 83 forks source link

Error (Unknown channel) #204

Closed IDKhowToScript closed 2 years ago

IDKhowToScript commented 2 years ago

Console log: Error retrieving selected channel. TypeError: Cannot read properties of null (reading 'innerText') at DISCORD.getSelectedChannel (:16:3326) at onMessagesUpdated (:181:24) at :226:4 at Object.setIsTracking (:96:1274) at HTMLButtonElement. (:54:399) at HTMLButtonElement.r (a6a298b843663048d662.js:145:559)

using chrome 105.0.5195.127

Tried: Restarting DHT Clearing browser cache Switching application (web/app) Trying different server Use another database Restarting PC

TheRealUkey commented 2 years ago

Having the same issue for the first time. Tried to:

Seems like initially it scrapes the first page and getting the error once needed to scroll.

chylex commented 2 years ago

Released an update for the desktop app, I'll deal with the browser-only version later.

FireMario211 commented 2 years ago

The issue is because of the querySelector using nav header h1[class*='name-'], as it's considered null. Rewriting it to check if it's in a guild, and iterating through the children of nav header [class*='headerContent-'] fixes this.

for (const child of r(document.querySelector("nav header [class*='headerContent-']")).children) {
    if (child && child.props && child.props.guild) {
        guild = child.props.guild;
        break
    }
}
chylex commented 2 years ago

I will update the browser-only version tomorrow. Fixing code is the easy part, it's the testing + build + deployment + wiki that are the most tedious and time-consuming parts of updating the browser-only version (and honestly, automating the process is not really worth it, since the browser-only version is only getting occasional critical fixes).