Skip to content

Commit d51be1a

Browse files
committed
Added reload slashcommand
1 parent b779308 commit d51be1a

File tree

15 files changed

+71
-56
lines changed

15 files changed

+71
-56
lines changed

src/data/config.js.template

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
const config = {
22
bot: {
3+
prefix : '!',
34
token: 'TOKEN',
45
owner: '0',
56
},
6-
mysql: {
7-
host: 'HOST',
8-
port: 'PORT',
9-
user: 'USER',
10-
password: 'PASSWORD',
11-
database: 'DATABASE',
12-
},
137
};
148

159
export default config;

src/handlers/buttons.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,27 @@ import chalk from 'chalk';
33

44
async function loadButtons(client) {
55
client.buttons.clear();
6+
let files = 0;
67
const buttonFiles = readdirSync('./src/interactions/buttons').filter(file => file.endsWith('.js'));
8+
if (!buttonFiles) return;
79
for (let i = 0; i < buttonFiles.length; i++) {
810
const button = await import(`../interactions/buttons/${buttonFiles[i]}?${Date.now()}`);
911
await client.buttons.set(button.default.id, button.default);
1012
console.log(chalk.greenBright(`[BUTTON] Loaded ${(chalk.yellow(buttonFiles[i]))} with button ${(chalk.yellow(button.default.id))}`));
13+
files++;
1114
}
1215
const buttonFolders = readdirSync('./src/interactions/buttons', { withFileTypes: true }).filter(file => file.isDirectory());
16+
if (!buttonFolders) return;
1317
for (let i = 0; i < buttonFolders.length; i++) {
1418
const buttonFiles = readdirSync(`./src/interactions/buttons/${buttonFolders[i].name}`).filter(file => file.endsWith('.js'));
1519
for (let j = 0; j < buttonFiles.length; j++) {
1620
const button = await import(`../interactions/buttons/${buttonFolders[i].name}/${buttonFiles[j]}`);
1721
await client.buttons.set(button.default.id, button.default);
1822
console.log(chalk.greenBright(`[BUTTON] Loaded ${(chalk.yellow(buttonFiles[j]))} with button ${(chalk.yellow(button.default.id))}`));
23+
files++;
1924
}
2025
}
26+
return files;
2127
}
2228

2329
export default { loadButtons };

src/handlers/contextMenus.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,27 @@ import chalk from 'chalk';
33

44
async function loadContextMenus(client) {
55
client.contextMenus.clear();
6+
let files = 0;
67
const contextMenus = readdirSync('./src/interactions/contextMenus').filter(file => file.endsWith('.js'));
8+
if (!contextMenus) return;
79
for (let i = 0; i < contextMenus.length; i++) {
810
const menus = await import(`../interactions/contextMenus/${contextMenus[i]}?${Date.now()}`);
911
client.contextMenus.set(menus.default.data.toJSON().name, menus.default);
1012
console.log(chalk.greenBright(`[CONTEXTMENU] Loaded ${chalk.yellow(contextMenus[i])} with command ${chalk.yellow(menus.default.data.toJSON().name)}`));
13+
files++;
1114
}
1215
const contextMenuFolders = readdirSync('./src/interactions/contextMenus', { withFileTypes: true }).filter(file => file.isDirectory());
16+
if (!contextMenuFolders) return;
1317
for (let i = 0; i < contextMenuFolders.length; i++) {
1418
const contextMenus = readdirSync(`./src/interactions/contextMenus/${contextMenuFolders[i].name}`).filter(file => file.endsWith('.js'));
1519
for (let j = 0; j < contextMenus.length; j++) {
1620
const menus = await import(`../interactions/contextMenus/${contextMenuFolders[i].name}/${contextMenus[j]}`);
1721
client.contextMenus.set(menus.default.data.toJSON().name, menus.default);
1822
console.log(chalk.greenBright(`[CONTEXTMENU] Loaded ${chalk.yellow(contextMenus[j])} with command ${chalk.yellow(menus.default.data.toJSON().name)}`));
23+
files++;
1924
}
2025
}
26+
return files;
2127
}
2228

2329
export default { loadContextMenus };

src/handlers/events.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import chalk from 'chalk';
33

44
async function loadEvents(client) {
55
const eventFiles = readdirSync('./src/events').filter(file => file.endsWith('.js'));
6+
if (!eventFiles) return;
67
for (let i = 0; i < eventFiles.length; i++) {
78
const event = await import(`../events/${eventFiles[i]}`);
89
client.on(event.default.event, event.default.execute.bind(null, client));

src/handlers/messageCommands.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import { readdirSync } from 'fs';
44
async function loadMessageCommands(client) {
55
client.messageCommands.clear();
66
client.messageCommandsAliases.clear();
7+
let files = 0;
78
const commandFiles = readdirSync('./src/interactions/messageCommands').filter(file => file.endsWith('.js'));
9+
if (!commandFiles) return;
810
for (let i = 0; i < commandFiles.length; i++) {
911
const command = await import(`../interactions/messageCommands/${commandFiles[i]}?${Date.now()}`);
1012
if (command.default.aliases) {
@@ -14,8 +16,10 @@ async function loadMessageCommands(client) {
1416
}
1517
client.messageCommands.set(command.default.name, command.default);
1618
console.log(chalk.greenBright(`[COMMAND] Loaded ${(chalk.yellow(commandFiles[i]))} with command ${(chalk.yellow(command.default.name))}`));
19+
files++;
1720
}
1821
const commandFolders = readdirSync('./src/interactions/messageCommands', { withFileTypes: true }).filter(file => file.isDirectory());
22+
if (!commandFolders) return;
1923
for (let i = 0; i < commandFolders.length; i++) {
2024
const commandFiles = readdirSync(`./src/interactions/messageCommands/${commandFolders[i].name}`).filter(file => file.endsWith('.js'));
2125
for (let j = 0; j < commandFiles.length; j++) {
@@ -27,8 +31,10 @@ async function loadMessageCommands(client) {
2731
}
2832
client.messageCommands.set(command.default.name, command.default);
2933
console.log(chalk.greenBright(`[COMMAND] Loaded ${(chalk.yellow(commandFiles[j]))} with command ${(chalk.yellow(command.default.name))}`));
34+
files++;
3035
}
3136
}
37+
return files;
3238
}
3339

3440
export default { loadMessageCommands };

src/handlers/modals.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,27 @@ import chalk from 'chalk';
33

44
async function loadModals(client) {
55
client.modals.clear();
6+
let files = 0;
67
const modalFiles = readdirSync('./src/interactions/modals').filter(file => file.endsWith('.js'));
8+
if (!modalFiles) return;
79
for (let i = 0; i < modalFiles.length; i++) {
810
const modal = await import(`../interactions/modals/${modalFiles[i]}?${Date.now()}`);
911
await client.modals.set(modal.default.id, modal.default);
1012
console.log(chalk.greenBright(`[MODAL] Loaded ${(chalk.yellow(modalFiles[i]))} with modal ${(chalk.yellow(modal.default.id))}`));
13+
files++;
1114
}
1215
const modalFolders = readdirSync('./src/interactions/modals', { withFileTypes: true }).filter(file => file.isDirectory());
16+
if (!modalFolders) return;
1317
for (let i = 0; i < modalFolders.length; i++) {
1418
const modalFiles = readdirSync(`./src/interactions/modals/${modalFolders[i].name}`).filter(file => file.endsWith('.js'));
1519
for (let j = 0; j < modalFiles.length; j++) {
1620
const modal = await import(`../interactions/modals/${modalFolders[i].name}/${modalFiles[j]}?${Date.now()}`);
1721
await client.modals.set(modal.default.id, modal.default);
1822
console.log(chalk.greenBright(`[MODAL] Loaded ${(chalk.yellow(modalFiles[j]))} with modal ${(chalk.yellow(modal.default.id))}`));
23+
files++;
1924
}
2025
}
26+
return files;
2127
}
2228

2329
export default { loadModals };

src/handlers/selectMenus.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,27 @@ import chalk from 'chalk';
33

44
async function loadSelectMenus(client) {
55
client.selectMenus.clear();
6+
let files = 0;
67
const selectMenuFiles = readdirSync('./src/interactions/selectMenus').filter(file => file.endsWith('.js'));
8+
if (!client.selectMenus) return;
79
for (let i = 0; i < selectMenuFiles.length; i++) {
810
const selectMenu = await import(`../interactions/selectMenus/${selectMenuFiles[i]}?${Date.now()}`);
911
await client.selectMenus.set(selectMenu.default.id, selectMenu.default);
1012
console.log(chalk.greenBright(`[SELECTMENU] Loaded ${(chalk.yellow(selectMenuFiles[i]))} with selectMenu ${(chalk.yellow(selectMenu.default.id))}`));
13+
files++;
1114
}
1215
const selectMenuFolders = readdirSync('./src/interactions/selectMenus', { withFileTypes: true }).filter(file => file.isDirectory());
16+
if (!selectMenuFolders) return;
1317
for (let i = 0; i < selectMenuFolders.length; i++) {
1418
const selectMenuFiles = readdirSync(`./src/interactions/selectMenus/${selectMenuFolders[i].name}`).filter(file => file.endsWith('.js'));
1519
for (let j = 0; j < selectMenuFiles.length; j++) {
1620
const selectMenu = await import(`../interactions/selectMenus/${selectMenuFolders[i].name}/${selectMenuFiles[j]}?${Date.now()}`);
1721
await client.selectMenus.set(selectMenu.default.id, selectMenu.default);
1822
console.log(chalk.greenBright(`[SELECTMENU] Loaded ${(chalk.yellow(selectMenuFiles[j]))} with selectMenu ${(chalk.yellow(selectMenu.default.id))}`));
23+
files++;
1924
}
2025
}
26+
return files;
2127
}
2228

2329
export default { loadSelectMenus };

src/handlers/slashCommands.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,27 @@ import chalk from 'chalk';
33

44
async function loadSlashCommands(client) {
55
client.slashCommands.clear();
6+
let files = 0;
67
const slashCommands = readdirSync('./src/interactions/slashCommands').filter(file => file.endsWith('.js'));
8+
if (!slashCommands) return;
79
for (let i = 0; i < slashCommands.length; i++) {
810
const commands = await import(`../interactions/slashCommands/${slashCommands[i]}?${Date.now()}`);
911
client.slashCommands.set(commands.default.data.toJSON().name, commands.default);
1012
console.log(chalk.greenBright(`[SLASHCOMMAND] Loaded ${chalk.yellow(slashCommands[i])} with command ${chalk.yellow(commands.default.data.toJSON().name)}`));
13+
files++;
1114
}
1215
const slashCommandFolders = readdirSync('./src/interactions/slashCommands', { withFileTypes: true }).filter(file => file.isDirectory());
16+
if (!slashCommandFolders) return;
1317
for (let i = 0; i < slashCommandFolders.length; i++) {
1418
const slashCommands = readdirSync(`./src/interactions/slashCommands/${slashCommandFolders[i].name}`).filter(file => file.endsWith('.js'));
1519
for (let j = 0; j < slashCommands.length; j++) {
1620
const commands = await import(`../interactions/slashCommands/${slashCommandFolders[i].name}/${slashCommands[j]}`);
1721
client.slashCommands.set(commands.default.data.toJSON().name, commands.default);
1822
console.log(chalk.greenBright(`[SLASHCOMMAND] Loaded ${chalk.yellow(slashCommands[j])} with command ${chalk.yellow(commands.default.data.toJSON().name)}`));
23+
files++;
1924
}
2025
}
26+
return files;
2127
}
2228

2329
export default { loadSlashCommands };

src/interactions/buttons/general/test.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/interactions/buttons/test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export default {
2-
id: 'testg',
2+
id: 'test',
33
async execute(client, interaction) {
4-
interaction.reply('Hello World! Button');
4+
interaction.reply('Hello World!');
55
}
66
};

0 commit comments

Comments
 (0)