Skip to content

Commit

Permalink
V9.0.5 Release
Browse files Browse the repository at this point in the history
  • Loading branch information
RileCraft committed Feb 9, 2024
1 parent 7415a53 commit 9d608cf
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 20 deletions.
5 changes: 3 additions & 2 deletions 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.4-05122A?style=for-the-badge">
<img src="https://img.shields.io/badge/version-9.0.5-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 All @@ -12,9 +12,10 @@
The Discord Bot Template provides a solid foundation for creating feature-rich Discord bots using Discord.js. It includes various managers for handling message commands, buttons, select menus, slash commands, context menus, and modal forms. The template offers customization options, colorful logging, and a simple code structure.

## Changelog
### IMPORTANT UPDATE 9.0.4
### IMPORTANT UPDATE 9.0.5

- **Fixed Windows Support and SlashCommands & ContextMenus not Registering.**
- Fixed subDirectories not working for commands.
- Latest Discord.js adaptation.
- Following JavaScript Naming Convention.
- Removed `node-recursive-directory` dependency.
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.4",
"version": "9.0.5",
"description": "Just your average discord bot handler.",
"main": "bot.js",
"type": "module",
Expand Down
5 changes: 2 additions & 3 deletions src/events/ready.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ActivityType } from "discord.js";
import { rootPath } from "../../bot.js";
import { pathToFileURL } from "node:url";
import { fileReader } from "../utils/fileReader.js";
import { t } from "tasai";

Expand All @@ -14,14 +13,14 @@ export const Event = {

let allSlashCommands = fileReader(`${rootPath}/src/interactions/slashCommands`);
allSlashCommands = await allSlashCommands.reduce(async (array, slash) => {
const command = (await import(pathToFileURL(slash).href))?.Slash;
const command = (await import(`file:///${slash}`))?.Slash;
if (command?.ignore || !command?.name) return array;
else return (await array).concat(slash);
}, []);

let allContextMenus = fileReader(`${rootPath}/src/interactions/contextMenus`);
allContextMenus = await allContextMenus.reduce(async (array, context) => {
const command = (await import(pathToFileURL(context).href))?.Context;
const command = (await import(`file:///${context}`))?.Context;
if (command?.ignore || !command?.name || !command?.type) return array;
else return (await array).concat(context);
}, []);
Expand Down
3 changes: 1 addition & 2 deletions src/structures/managers/buttonCommands.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { fileReader } from "../../utils/fileReader.js";
import { pathToFileURL } from "node:url";

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(pathToFileURL(buttonCommandFile).href))?.Button;
const buttonCommand = (await import(`file:///${buttonCommandFile}`))?.Button;
if (!buttonCommand) continue;

if (!buttonCommand.ignore && buttonCommand.name) client.buttonCommands.set(buttonCommand.name, buttonCommand);
Expand Down
3 changes: 1 addition & 2 deletions src/structures/managers/events.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { fileReader } from "../../utils/fileReader.js";
import { pathToFileURL } from "node:url";

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(pathToFileURL(event).href))?.Event;
const clientEvent = (await import(`file:///${event}`))?.Event;
if (!clientEvent) continue;

client.events?.set(clientEvent.name, clientEvent);
Expand Down
3 changes: 1 addition & 2 deletions src/structures/managers/messageCommands.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { fileReader } from "../../utils/fileReader.js";
import { pathToFileURL } from "node:url";

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(pathToFileURL(messageCommandFile).href))?.MsgCommand;
const messageCommand = (await import(`file:///${messageCommandFile}`))?.MsgCommand;

if (!messageCommand) continue;

Expand Down
3 changes: 1 addition & 2 deletions src/structures/managers/modalForms.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { fileReader } from "../../utils/fileReader.js";
import { pathToFileURL } from "node:url";

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(pathToFileURL(modalFormFile).href))?.Modal;
const modalForm = (await import(`file:///${modalFormFile}`))?.Modal;

if (!modalForm) continue;
if (!modalForm.ignore && modalForm.name) client.modalForms.set(modalForm.name, modalForm);
Expand Down
3 changes: 1 addition & 2 deletions src/structures/managers/selectMenus.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { fileReader } from "../../utils/fileReader.js";
import { pathToFileURL } from "node:url";

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(pathToFileURL(selectMenuFile).href))?.Menu;
const selectMenu = (await import(`file:///${selectMenuFile}`))?.Menu;

if (!selectMenu) continue;
if (!selectMenu.ignore && selectMenu.name) client.selectMenus?.set(selectMenu.name, selectMenu);
Expand Down
5 changes: 2 additions & 3 deletions src/structures/managers/slashCommands.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ApplicationCommandType, REST, Routes } from "discord.js";
import { fileReader } from "../../utils/fileReader.js";
import { pathToFileURL } from "node:url";

export const SlashManager = async(client, rootPath) => {
const allSlashCommandsFiles = fileReader(`${rootPath}/src/interactions/slashCommands`);
Expand All @@ -12,7 +11,7 @@ export const SlashManager = async(client, rootPath) => {

if (allSlashCommandsFiles.length > 0) {
for (const slashCommandFile of allSlashCommandsFiles) {
const slashCommand = (await import(pathToFileURL(slashCommandFile).href))?.Slash;
const slashCommand = (await import(`file:///${slashCommandFile}`))?.Slash;

if (!slashCommand) continue;
if (slashCommand.ignore || !slashCommand.name || !slashCommand.description) continue;
Expand Down Expand Up @@ -43,7 +42,7 @@ export const SlashManager = async(client, rootPath) => {

if (allContextMenusFiles.length > 0) {
for (const contextMenuFile of allContextMenusFiles) {
const contextMenu = (await import(pathToFileURL(contextMenuFile).href))?.Context;
const contextMenu = (await import(`file:///${contextMenuFile}`))?.Context;

if (!contextMenu) continue;
if (contextMenu.ignore || !contextMenu.name || !contextMenu.type) continue;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/fileReader.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const fileReader = (dir) => {
const stats = statSync(filePath);

if (stats.isFile() && extname(filePath) === ".js") files.push(filePath);
else if (stats.isDirectory()) files.push(...fileReader(filePath));
else if (stats.isDirectory()) files.push(...fileReader(`file:///${filePath}`));
};

return files;
Expand Down

0 comments on commit 9d608cf

Please sign in to comment.