Skip to content

Commit 745ef8e

Browse files
committed
Move plugin loading to where it belongs
The plugin loading code, instead of being in the DiscordReady event, has accidentally been placed in the message event. This caused plugins not to load until the first message arrives. This has been fixed by moving the code into the proper place at the end of the `ready` event handler.
1 parent f8fe4f7 commit 745ef8e

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

app.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,17 @@ function connectToDiscord() {
256256
api.misc = {
257257
serverFromChannel: discord.serverFromChannel
258258
};
259+
// Load all Plugins in the ./plugins directory
260+
var quiet_loading = true;
261+
plugin_loader.listPlugins().forEach(function (item) {
262+
var plugin_state = plugin_loader.getInitialPluginState(item);
263+
if (plugin_state === "running" || plugin_state === "loaded") {
264+
plugin_loader.loadPlugin(item, quiet_loading);
265+
}
266+
if (plugin_state === "running") {
267+
plugin_loader.startPlugin(item, quiet_loading);
268+
}
269+
});
259270
}).on("message", function (_username, _userID, _channelID, _message, _rawEvent) {
260271
api.Events.emit("message_raw", _rawEvent);
261272
if (_userID === api.client.id) {
@@ -331,18 +342,6 @@ function connectToDiscord() {
331342
api.Events.emit("chatCmd_raw", _rawEvent);
332343
api.Events.emit("chatCmd#" + cmd + "_raw", _rawEvent);
333344
}
334-
335-
// Load all Plugins in the ./plugins directory
336-
var quiet_loading = true;
337-
plugin_loader.listPlugins().forEach(function (item) {
338-
var plugin_state = plugin_loader.getInitialPluginState(item);
339-
if (plugin_state === "running" || plugin_state === "loaded") {
340-
plugin_loader.loadPlugin(item, quiet_loading);
341-
}
342-
if (plugin_state === "running") {
343-
plugin_loader.startPlugin(item, quiet_loading);
344-
}
345-
});
346345
}).on("presence", function (_username, _userID, _status, _gameName, _rawEvent) {
347346
api.Events.emit("presence", {
348347
username: _username,

0 commit comments

Comments
 (0)