1
0
mirror of https://github.com/chylex/Discord-History-Tracker.git synced 2025-09-15 01:32:09 +02:00

4 Commits

Author SHA1 Message Date
33f5ab7cce Release v37.0 2022-06-18 14:00:15 +02:00
b9a5664740 Fix not seeing messages after a Discord update
Closes #189
2022-06-18 13:59:29 +02:00
845ac1b0fa Release v36.2 (beta) 2022-06-06 17:08:37 +02:00
1bead42a0e Improve error handling and reporting when extracting message data 2022-06-06 17:05:20 +02:00
3 changed files with 28 additions and 11 deletions

View File

@@ -91,11 +91,13 @@ class DISCORD {
static getMessageElementProps(ele) {
const props = DOM.getReactProps(ele);
if (props.children && props.children.length >= 4) {
const childProps = props.children[3].props;
if (props.children && props.children.length) {
for (let i = 3; i < props.children.length; i++) {
const childProps = props.children[i].props;
if ("message" in childProps && "channel" in childProps) {
return childProps;
if (childProps && "message" in childProps && "channel" in childProps) {
return childProps;
}
}
}
@@ -110,16 +112,20 @@ class DISCORD {
const messages = [];
for (const ele of this.getMessageElements()) {
const props = this.getMessageElementProps(ele);
try {
const props = this.getMessageElementProps(ele);
if (props != null) {
messages.push(props.message);
if (props != null) {
messages.push(props.message);
}
} catch (e) {
console.error("[DHT] Error extracing message data, skipping it.", e, ele, DOM.tryGetReactProps(ele));
}
}
return messages;
} catch (e) {
console.error(e);
console.error("[DHT] Error retrieving messages.", e);
return [];
}
}

View File

@@ -71,4 +71,15 @@ class DOM {
key = keys.find(key => key.startsWith("__reactProps$"));
return key ? ele[key] : null;
}
/**
* Returns internal React state object of an element, or null if the retrieval throws.
*/
static tryGetReactProps(ele) {
try {
return this.getReactProps(ele);
} catch (e) {
return null;
}
}
}

View File

@@ -7,6 +7,6 @@ using DHT.Utils;
namespace DHT.Utils {
static class Version {
public const string Tag = "36.1.0.0";
public const string Tag = "37.0.0.0";
}
}