1
0
mirror of https://github.com/chylex/Discord-History-Tracker.git synced 2024-10-17 17:42:51 +02:00

Compare commits

..

2 Commits

Author SHA1 Message Date
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 21 additions and 6 deletions

View File

@ -110,16 +110,20 @@ class DISCORD {
const messages = []; const messages = [];
for (const ele of this.getMessageElements()) { 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; return messages;
} catch (e) { } catch (e) {
console.error(e); console.error("[DHT] Error retrieving messages.", e);
return []; return [];
} }
} }

View File

@ -71,4 +71,15 @@ class DOM {
key = keys.find(key => key.startsWith("__reactProps$")); key = keys.find(key => key.startsWith("__reactProps$"));
return key ? ele[key] : null; 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 { namespace DHT.Utils {
static class Version { static class Version {
public const string Tag = "36.1.0.0"; public const string Tag = "36.2.0.0";
} }
} }