trying to handle music

This commit is contained in:
DeSqBlocki
2024-08-02 13:25:06 +02:00
parent a74e19be5a
commit 2925fb59dd
42 changed files with 3708 additions and 1 deletions
+20
View File
@@ -0,0 +1,20 @@
const fs = require('node:fs')
const path = require('node:path')
module.exports = (client) => {
const buttonsFoldersPath = path.join(__dirname, '../buttons');
const buttonsFolders = fs.readdirSync(buttonsFoldersPath);
let buttonCount = 0
for (const folder of buttonsFolders) {
const buttonsPath = path.join(buttonsFoldersPath, folder);
const buttonsFiles = fs.readdirSync(buttonsPath).filter(file => file.endsWith('.js'));
for (const file of buttonsFiles) {
buttonCount++
const filePath = path.join(buttonsPath, file);
const button = require(filePath);
if ('execute' in button) {
client.buttons.set(button.name, button);
}
}
}
console.log(`[${buttonCount}] Button(s) initialized`)
}
+42
View File
@@ -0,0 +1,42 @@
// ich hab das einfach _commands genannt, damit es beim Startup als erstes initialisiert wird.
const { REST, Routes } = require('discord.js')
const fs = require('node:fs')
const path = require('node:path')
module.exports = (client) => {
let commands = [] // only used for REST API
const foldersPath = path.join(__dirname, '../commands');
const commandFolders = fs.readdirSync(foldersPath);
for (const folder of commandFolders) {
// Grab all the command files from the commands directory you created earlier
const commandsPath = path.join(foldersPath, folder);
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
// Grab the SlashCommandBuilder#toJSON() output of each command's data for deployment
for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const command = require(filePath);
if ('data' in command && 'execute' in command) {
commands.push(command.data.toJSON());
client.commands.set(command.data.name, command);
} else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
}
}
}
const rest = new REST().setToken(process.env.D_Token);
(async () => {
try {
console.log(`Started refreshing ${commands.length} application (/) commands.`);
// The put method is used to fully refresh all commands in the guild with the current set
const data = await rest.put(
Routes.applicationGuildCommands(process.env.D_ID, process.env.D_GuildID),
{ body: commands },
);
console.log(`Successfully reloaded ${data.length} application (/) commands.`);
} catch (error) {
// And of course, make sure you catch and log any errors!
console.error(error);
}
})();
}
+18
View File
@@ -0,0 +1,18 @@
const fs = require('node:fs')
const path = require('node:path')
module.exports = (client) => {
const eventsPath = path.join(__dirname, '../events')
const eventFiles = fs.readdirSync(eventsPath).filter(file => file.endsWith('.js'))
for (const file of eventFiles) {
const filePath = path.join(eventsPath, file)
const event = require(filePath)
if (event.once) {
client.once(event.name, (...args) => event.execute(...args))
// added client to commomerate global usage
} else {
client.on(event.name, (...args) => event.execute(...args))
// added client to commomerate global usage
}
}
}
+29
View File
@@ -0,0 +1,29 @@
const fs = require('node:fs')
const path = require('node:path')
module.exports = (client) => {
const legacyFoldersPath = path.join(__dirname, '../legacyCommands');
const legacyCommandFolders = fs.readdirSync(legacyFoldersPath);
let legacyCount = 0
let aliasCount = 0
for (const folder of legacyCommandFolders) {
const commandsPath = path.join(legacyFoldersPath, folder);
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
legacyCount++
const filePath = path.join(commandsPath, file);
const command = require(filePath);
if ('execute' in command) {
client.legacyCommands.set(command.name, command);
}
if (command.aliases && Array.isArray(command.aliases)) {
command.aliases.forEach(alias => {
aliasCount++
client.aliases.set(alias, command.name)
})
}
}
}
console.log(`[${aliasCount}] Aliase(s) initialized`)
console.log(`[${legacyCount}] Legacy Command(s) initialized`)
}
+20
View File
@@ -0,0 +1,20 @@
const fs = require('node:fs')
const path = require('node:path')
module.exports = (client) => {
const selectMenusFoldersPath = path.join(__dirname, '../selectMenus');
const selectMenusFolders = fs.readdirSync(selectMenusFoldersPath);
let selectMenuCount = 0
for (const folder of selectMenusFolders) {
const Path = path.join(selectMenusFoldersPath, folder);
const Files = fs.readdirSync(Path).filter(file => file.endsWith('.js'));
for (const file of Files) {
selectMenuCount++
const filePath = path.join(Path, file);
const button = require(filePath);
if ('execute' in button) {
client.selectMenus.set(button.name, button);
}
}
}
console.log(`[${selectMenuCount}] Select Menu(s) initialized`)
}