Skip to content
This repository has been archived by the owner on Nov 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #80 from RileCraft/Unstable
Browse files Browse the repository at this point in the history
Fix: Check if directories exist
  • Loading branch information
RileCraft authored Jan 27, 2024
2 parents 2154e68 + bfadbd4 commit cd12ae5
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<p align="center">
<img src="https://media.discordapp.net/attachments/774290264764055582/1093484780525469757/A_banner_for_a_discord_bots_template_made_using_discord.js.png" height="200" width="400"><br>
<img src="https://img.shields.io/badge/version-9.0.0-05122A?style=for-the-badge">
<img src="https://img.shields.io/badge/version-9.0.1-05122A?style=for-the-badge">
<a href="https://discord.gg/VStdRr8nP2"><img src="https://img.shields.io/badge/discord-invite-5865f2?style=for-the-badge&logo=discord&logoColor=white"></a>
<img src="https://img.shields.io/github/issues/RileCraft/DiscordBot-Template.svg?style=for-the-badge">
<img src="https://img.shields.io/github/forks/RileCraft/DiscordBot-Template.svg?style=for-the-badge">
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "discordbot-template",
"version": "9.0.0",
"version": "9.0.1",
"description": "Just your average discord bot handler.",
"main": "bot.js",
"type": "module",
Expand Down
1 change: 1 addition & 0 deletions src/structures/managers/buttonCommands.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { fileReader } from "../../utils/fileReader.js";

export const ButtonManager = async(client, rootPath) => {
const buttonCommandFiles = fileReader(`${rootPath}/src/interactions/buttons`);
if (!buttonCommandFiles.length) return;

for (const buttonCommandFile of buttonCommandFiles) {
const buttonCommand = (await import(buttonCommandFile))?.Button;
Expand Down
1 change: 1 addition & 0 deletions src/structures/managers/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { fileReader } from "../../utils/fileReader.js";

export const EventManager = async(client, rootPath) => {
const eventFiles = fileReader(`${rootPath}/src/events`);
if (!eventFiles.length) return;

for (const event of eventFiles) {
const clientEvent = (await import(event))?.Event;
Expand Down
1 change: 1 addition & 0 deletions src/structures/managers/messageCommands.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { fileReader } from "../../utils/fileReader.js";

export const MessageCMDManager = async(client, rootPath) => {
const messageCommandsFiles = fileReader(`${rootPath}/src/messageCommands`);
if (!messageCommandsFiles.length) return;

for (const messageCommandFile of messageCommandsFiles) {
const messageCommand = (await import(messageCommandFile))?.MsgCommand;
Expand Down
1 change: 1 addition & 0 deletions src/structures/managers/modalForms.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { fileReader } from "../../utils/fileReader.js";

export const ModalManager = async(client, rootPath) => {
const modalFormFiles = fileReader(`${rootPath}/src/interactions/modalForms`);
if (!modalFormFiles.length) return;

for (const modalFormFile of modalFormFiles) {
const modalForm = (await import(modalFormFile))?.Modal;
Expand Down
1 change: 1 addition & 0 deletions src/structures/managers/selectMenus.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { fileReader } from "../../utils/fileReader.js";

export const SelectMenuManager = async(client, rootPath) => {
const selectMenuFiles = fileReader(`${rootPath}/src/interactions/selectMenus`);
if (!selectMenuFiles.length) return;

for (const selectMenuFile of selectMenuFiles) {
const selectMenu = (await import(selectMenuFile))?.Menu;
Expand Down
3 changes: 2 additions & 1 deletion src/utils/fileReader.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { readdirSync, statSync } from "fs";
import { existsSync, readdirSync, statSync } from "fs";
import path from "path";

export const fileReader = (dir) => {
if (!existsSync(dir)) return [];
const files = [];
const directoryData = readdirSync(dir);

Expand Down

0 comments on commit cd12ae5

Please sign in to comment.