toluschr / BetterDiscord-Animated-Status

Animate your Discord Status with this BetterDiscord Plugin
MIT License
256 stars 489 forks source link

Fix for the latest loading Issue (Load() could not be fired.) #158

Closed CS1o closed 9 months ago

CS1o commented 10 months ago

Notice taken

Discord Version

250759

Discord Release Channel

stable

BetterDiscord Version

1.9.6

Plugin Version

v0.13.2

The Plugin doesn't load anymore. So here is the Fix:

You need to got into the Discord Plugins section and at the Plugin click on the Edit Pencil. Or you can open the Plugin Folder and edit the Script with Notepad++.

in the Script at line 28 it looks like this:

this.modules = this.modules || (() => {
    let m = []
    webpackChunkdiscord_app.push([['AnimatedStatus'], {}, e => { m = m.concat(Object.values(e.c)) }])
    return m
})();

Change it to:

this.modules = this.modules || (() => {
    let m = [];
    webpackChunkdiscord_app.push([['AnimatedStatus'], {}, e => {
    m = m.concat(Object.values(e.c || {}));
}]);
return m;
})();

After that click the save icon in discord or in Notepad++. Then restart Discord. If the error appears again after clicking save, just click it again and restart Discord again. Important: You have to enable the Plugin in Discord after the Changes!

What was the Solution?

I asked ChapGPT-3.5 the following: "I have an error in a discord plugin thats used to switch the discord status message in realtime. The plugin is written in JavaScript. Its called Animated_Status.plugin.js. Its code is the following:" "Here i pasted the complete script"

"this is the error code when launching discord with that plugin:"

load() couldnt be executed.
TypeError: Cannot convert undefined or null to object
    at Function.values (<anonymous>)
    at eval (betterdiscord://plugins/Animated_Status.plugin.js:32:85)
    at e (https://discord.com/assets/sentry.0131fa21e133e3196ef4.js:1:7629)
    at s.handlePush (betterdiscord/renderer.js:5:52230)
    at WebpackModules.handlePush (betterdiscord://plugins/0PluginLibrary.plugin.js:3189:24)
    at eval (betterdiscord://plugins/Animated_Status.plugin.js:32:28)
    at AnimatedStatus.load (betterdiscord://plugins/Animated_Status.plugin.js:34:5)
    at A.initializeAddon (betterdiscord/renderer.js:5:34026)
    at A.loadAddon (betterdiscord/renderer.js:5:7528)
    at A.loadAddon (betterdiscord/renderer.js:5:32573)
    at A.loadAllAddons (betterdiscord/renderer.js:5:9835)
    at A.initialize (betterdiscord/renderer.js:5:4215)
    at A.initialize (betterdiscord/renderer.js:5:31772)
    at Object.startup (betterdiscord/renderer.js:5:364062)

"What do i need to change in the code to make it work again?"

This was the answer:

"It looks like the issue is with the way the plugin is trying to access the values of the webpackChunkdiscord_app variable. The error is occurring at line 32 in the load method. The code attempts to concatenate the values of e.c (which is expected to be an object with modules) into the m array.

The error suggests that e.c is undefined or null, and trying to convert it to an object results in the TypeError.

To fix this issue, you can add some defensive checks to ensure that e.c is not undefined or null before attempting to access its values. Here's an updated version of the relevant code:"

javascript

// Replace the existing modules assignment with the following code
this.modules = this.modules || (() => {
    let m = [];
    webpackChunkdiscord_app.push([['AnimatedStatus'], {}, e => {
        m = m.concat(Object.values(e.c || {}));
    }]);
    return m;
})();

"This modification adds || {} after e.c to provide an empty object as a fallback if e.c is undefined or null. This should prevent the TypeError and allow the plugin to load without errors.

After making this change, try reloading the plugin and see if the issue persists. If you encounter any other issues or have further questions, feel free to ask!"

11Moge-ko commented 10 months ago

Thankss!!!

Otashido commented 10 months ago

Works 👍 thank you

HyperHitystic commented 10 months ago

Truly a savior. Thanks a lot

MrSenet commented 10 months ago

image I had this problem; I tried adding your code to the plugin script, but the plugin still throws an error:

TypeError: Cannot read properties of undefined (reading 'exports') at AnimatedStatus.load (betterdiscord://plugins/Animated_Status.plugin.js:42:85) at A.initializeAddon (betterdiscord/renderer.js:5:34026) at A.loadAddon (betterdiscord/renderer.js:5:7528) at A.loadAddon (betterdiscord/renderer.js:5:32573) at A.loadAllAddons (betterdiscord/renderer.js:5:9835) at A.initialize (betterdiscord/renderer.js:5:4215) at A.initialize (betterdiscord/renderer.js:5:31772) at Object.startup (betterdiscord/renderer.js:5:364062)

TheSolenOne commented 10 months ago

Thank you so much sir

Mokarth commented 10 months ago

thank you

JIFO0 commented 10 months ago

Big thanks!!

Calypn commented 10 months ago

actual life saver, tysm!!

Deurklink123 commented 10 months ago

Thanks for the fix!

Crycrab commented 10 months ago

Thanks, it fixes the load() error but it has whipped/does not show old entries/status's. Anyone know a way to get them back/show them (I have a copy of the old master folder if anyone would know where the status's are stored thx)

CS1o commented 10 months ago

Thanks, it fixes the load() error but it has whipped/does not show old entries/status's. Anyone know a way to get them back/show them (I have a copy of the old master folder if anyone would know where the status's are stored thx)

Hey, this issue didnt happened for me or the others. As changing just the plugin code shouldn't delete the Status. All the Status Entries are located in: "C:\Users\YourUserName\AppData\Roaming\BetterDiscord\plugins\AnimatedStatus.config.json" Hope that helps.

CS1o commented 10 months ago

@MrSenet I would advise to Install BetterDiscord again. Even if its the same Version, just overwrite. Then redownload the script and change the code. That should work.

MrSenet commented 10 months ago

@CS1o This is essentially the first thing I did. But I tried again, it didn't help me.

Crycrab commented 9 months ago

Thanks, it fixes the load() error but it has whipped/does not show old entries/status's. Anyone know a way to get them back/show them (I have a copy of the old master folder if anyone would know where the status's are stored thx)

Hey, this issue didnt happened for me or the others. As changing just the plugin code shouldn't delete the Status. All the Status Entries are located in: "C:\Users\YourUserName\AppData\Roaming\BetterDiscord\plugins\AnimatedStatus.config.json" Hope that helps.

Where in the file are they? And how do I open it?, I've been opening it with Notepad++ but found no status's. Do I need to open it with some javascript editor?

thx

Crycrab commented 9 months ago

Thanks, it fixes the load() error but it has whipped/does not show old entries/status's. Anyone know a way to get them back/show them (I have a copy of the old master folder if anyone would know where the status's are stored thx)

Hey, this issue didnt happened for me or the others. As changing just the plugin code shouldn't delete the Status. All the Status Entries are located in: "C:\Users\YourUserName\AppData\Roaming\BetterDiscord\plugins\AnimatedStatus.config.json" Hope that helps.

Where in the file are they? And how do I open it?, I've been opening it with Notepad++ but found no status's. Do I need to open it with some javascript editor?

thx

wait crap no nevermind found it

THANK YOU!!!!!!!!!!!!!!

I had/have 100+ entrys that I really didn't want to have to type out again thank you!

esiclass commented 9 months ago

you're a legend man

parzival-space commented 9 months ago

Maybe someone should create PR with this fix