Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikasuru authored Jan 4, 2025
1 parent d7cea2e commit ae3ab7e
Show file tree
Hide file tree
Showing 4 changed files with 1,034 additions and 19 deletions.
8 changes: 5 additions & 3 deletions Config/Config.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
},
"GeneralSettings": {
"OwnerID": "",
"ShowLoadCommands": false
"ShowLoadCommands": false,
"EnableNSFW": false,
"EnableDelete": false
},
"NotificationSettings": {
"Enabled": true,
"Enabled": false,
"Webhook": ""
},
"Commands": {
Expand All @@ -35,4 +37,4 @@
]
}
}
}
}
51 changes: 36 additions & 15 deletions Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,44 @@ const { Client } = require('discord.js-selfbot-v13');
const fs = require('fs');
const path = require('path');
const Config = require("./Config/Config.json");
const scheduleCommand = require('./Commands/Schedule');
const scheduleCommand = require('./Commands/Misc/Schedule');

const client = new Client({
checkUpdate: false
});

client.commands = new Map();

function loadCommands() {
const commandsPath = path.join(__dirname, 'Commands');
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
function loadCommands(dir = 'Commands') {
const commandsPath = path.join(__dirname, dir);
const items = fs.readdirSync(commandsPath);
let loadedCount = 0;

console.log('Loading commands...');
for (const file of commandFiles) {
try {
const command = require(path.join(commandsPath, file));
client.commands.set(command.name, command);
if (Config.GeneralSettings.ShowLoadCommands == true) {
console.log(`✅: ${command.name}`);
for (const item of items) {
const itemPath = path.join(commandsPath, item);
const stat = fs.statSync(itemPath);

if (stat.isDirectory()) {
// Recursively load commands from subdirectories
loadedCount += loadCommands(path.join(dir, item));
} else if (item.endsWith('.js')) {
try {
const command = require(itemPath);
client.commands.set(command.name, command);
if (Config.GeneralSettings.ShowLoadCommands == true) {
console.log(`✅: ${command.name}`);
}
loadedCount++;
} catch (error) {
console.error(`❌: ('${item}') - `, error.message);
}
loadedCount++;
} catch (error) {
console.error(`❌: ('${file}') - `, error.message);
}
}
console.log(`${loadedCount} Command(s) loaded successfully.`);

if (dir === 'Commands') {
console.log(`Loaded ${loadedCount} commands`);
}
return loadedCount;
}

function ConfigOwnerID(userID) {
Expand Down Expand Up @@ -56,6 +67,9 @@ client.on('ready', async () => {
});

client.on('messageCreate', async (message) => {
const configPath = './Config/Config.json';
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));

try {
const prefix = Config.BotSettings.Prefix || '.';
if (message.author.id !== Config.GeneralSettings.OwnerID && !Config.BotSettings.BotAdmins.includes(message.author.id)) {
Expand All @@ -68,6 +82,13 @@ client.on('messageCreate', async (message) => {
const command = client.commands.get(commandName);
if (command) {
await command.execute(message, args, client);
if (Config.GeneralSettings.EnableDelete) {
try {
await message.delete();
} catch (deleteError) {
console.error('Error deleting message:', deleteError);
}
}
}
}
} catch (error) {
Expand Down
Loading

0 comments on commit ae3ab7e

Please sign in to comment.