Skip to content

Commit

Permalink
fix: finding folders with loaders
Browse files Browse the repository at this point in the history
If your bot has not a interaction folder (like commands/, modals/), the
loaders will not crashes anymore
  • Loading branch information
Tolga1452 committed Sep 23, 2022
1 parent aa52e37 commit 6f4d720
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions load.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const commands = [];
*/
const guildCommands = {};

readdir('./interactions/commands/slash', (error, files) => { //Slash Commands
readdir('./interactions/commands/slash', (error, files = []) => { //Slash Commands
if (error) logger.error(`[CommandLoader/Slash] ${error.stack ?? error}`);

if (files.length > 0) logger.info(`[CommandLoader/Slash] Loading ${files.length} slash commands...`);
Expand All @@ -49,7 +49,7 @@ readdir('./interactions/commands/slash', (error, files) => { //Slash Commands
});
});

readdir('./interactions/commands/user', (error, files) => { //User Commands
readdir('./interactions/commands/user', (error, files = []) => { //User Commands
if (error) logger.error(`[CommandLoader/User] ${error.stack ?? error}`);

if (files.length > 0) logger.info(`[CommandLoader/User] Loading ${files.length} user commands...`);
Expand All @@ -74,7 +74,7 @@ readdir('./interactions/commands/user', (error, files) => { //User Commands
});
});

readdir('./interactions/commands/message', (error, files) => { //Message Commands
readdir('./interactions/commands/message', (error, files = []) => { //Message Commands
if (error) logger.error(`[CommandLoader/Message] ${error.stack ?? error}`);

if (files.length > 0) logger.info(`[CommandLoader/Message] Loading ${files.length} message commands...`);
Expand Down
12 changes: 6 additions & 6 deletions shard.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const interactions = {
modals: new Collection()
};

readdir('./interactions/commands/slash', (error, files) => { //Slash Commands
readdir('./interactions/commands/slash', (error, files = []) => { //Slash Commands
if (error) logger.error(`[Shard ${shard}] [InterationLoader/SlashCommands] ${error.stack ?? error}`);

if (files.length > 0) logger.info(`[Shard ${shard}] [InterationLoader/SlashCommands] Loading ${files.length} slash commands...`);
Expand All @@ -57,7 +57,7 @@ readdir('./interactions/commands/slash', (error, files) => { //Slash Commands
});
});

readdir('./interactions/commands/user', (error, files) => { //User Commands
readdir('./interactions/commands/user', (error, files = []) => { //User Commands
if (error) logger.error(`[Shard ${shard}] [InterationLoader/UserCommands] ${error.stack ?? error}`);

if (files.length > 0) logger.info(`[Shard ${shard}] [InterationLoader/UserCommands] Loading ${files.length} user commands...`);
Expand All @@ -82,7 +82,7 @@ readdir('./interactions/commands/user', (error, files) => { //User Commands
});
});

readdir('./interactions/commands/message', (error, files) => { //Message Commands
readdir('./interactions/commands/message', (error, files = []) => { //Message Commands
if (error) logger.error(`[Shard ${shard}] [InterationLoader/MessageCommands] ${error.stack ?? error}`);

if (files.length > 0) logger.info(`[Shard ${shard}] [InterationLoader/MessageCommands] Loading ${files.length} message commands...`);
Expand All @@ -107,7 +107,7 @@ readdir('./interactions/commands/message', (error, files) => { //Message Command
});
});

readdir('./interactions/components/buttons', (error, files) => { //Button Components
readdir('./interactions/components/buttons', (error, files = []) => { //Button Components
if (error) logger.error(`[Shard ${shard}] [InterationLoader/ButtonComponents] ${error.stack ?? error}`);

if (files.length > 0) logger.info(`[Shard ${shard}] [InterationLoader/ButtonComponents] Loading ${files.length} button components...`);
Expand All @@ -129,7 +129,7 @@ readdir('./interactions/components/buttons', (error, files) => { //Button Compon
});
});

readdir('./interactions/components/selectMenus', (error, files) => { //Select Menu Components
readdir('./interactions/components/selectMenus', (error, files = []) => { //Select Menu Components
if (error) logger.error(`[Shard ${shard}] [InterationLoader/SelectMenuComponents] ${error.stack ?? error}`);

if (files.length > 0) logger.info(`[Shard ${shard}] [InterationLoader/SelectMenuComponents] Loading ${files.length} select menu components...`);
Expand All @@ -151,7 +151,7 @@ readdir('./interactions/components/selectMenus', (error, files) => { //Select Me
});
});

readdir('./interactions/modals', (error, files) => { //Modals
readdir('./interactions/modals', (error, files = []) => { //Modals
if (error) logger.error(`[Shard ${shard}] [InterationLoader/Modals] ${error.stack ?? error}`);

if (files.length > 0) logger.info(`[Shard ${shard}] [InterationLoader/Modals] Loading ${files.length} modals...`);
Expand Down

0 comments on commit 6f4d720

Please sign in to comment.