Skip to content

Commit

Permalink
[Fix] Removed the previous loop and required the the function to regi…
Browse files Browse the repository at this point in the history
…ster the player events
  • Loading branch information
naseif committed Sep 30, 2021
1 parent 59c6a31 commit 5281fd3
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ const client = new Client({
],
restRequestTimeout: 30000,
});

const { playerEvents } = require("./playerEvents/player");
const { Player } = require("discord-player");
const player = new Player(client);
client.player = player;
client.commands = new Collection();
client.logger = logger;
playerEvents(client.player);

// All commands!
const allCommandsFolders = fs.readdirSync("./commands");
Expand Down Expand Up @@ -47,17 +48,6 @@ for (const file of eventFiles) {
}
}

// Loop through the discord-player events and require them

const playerEvents = fs
.readdirSync("./playerEvents")
.filter((file) => file.endsWith(".js"));

for (const file of playerEvents) {
const event = require(`./playerEvents/${file}`);
player.on(event.name, event.execute);
}

// Initialize the client on interaction
client.on("interactionCreate", async (interaction) => {
if (!interaction.isCommand()) return;
Expand Down

0 comments on commit 5281fd3

Please sign in to comment.