mirror of
https://github.com/arthur-pbty/selfbot-discord.git
synced 2026-06-16 15:57:10 +02:00
init sb
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
module.exports = function loadCommands(client: any, dir: string) {
|
||||
let count = 0;
|
||||
fs.readdirSync(path.join(__dirname, dir)).forEach((file: string) => {
|
||||
const filePath = path.join(__dirname, dir, file);
|
||||
if (fs.statSync(filePath).isDirectory()) {
|
||||
count += loadCommands(client, path.join(dir, file));
|
||||
} else if (file.endsWith('.js') || file.endsWith('.ts')) {
|
||||
try {
|
||||
delete require.cache[require.resolve(filePath)];
|
||||
const command = require(filePath);
|
||||
const fileName = file.replace(/\.js|\.ts/g, '');
|
||||
command.name = fileName;
|
||||
if (!command.category) {
|
||||
const parentDir = path.basename(path.dirname(filePath));
|
||||
command.category = parentDir === 'commands' ? 'other' : parentDir;
|
||||
}
|
||||
client.commands.set(fileName, command);
|
||||
if (command.aliases) {
|
||||
command.aliases.forEach((alias: string) => {
|
||||
client.commands.set(alias, command);
|
||||
});
|
||||
}
|
||||
count++;
|
||||
} catch (error) {
|
||||
console.error(`Failed to load file: ${filePath}`);
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
});
|
||||
return count;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import { Client } from 'discord.js';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
module.exports = function loadEvents(client: Client, dir: string): number {
|
||||
let count = 0;
|
||||
fs.readdirSync(path.join(__dirname, dir)).forEach((file: string) => {
|
||||
const filePath = path.join(__dirname, dir, file);
|
||||
if (fs.statSync(filePath).isDirectory()) {
|
||||
loadEvents(client, path.join(dir, file));
|
||||
} else if (file.endsWith('.js') || file.endsWith('.ts')) {
|
||||
delete require.cache[require.resolve(filePath)];
|
||||
const event = require(filePath);
|
||||
if (typeof event.execute === 'function') {
|
||||
client.on(event.name, (...args: any[]) => event.execute(...args, client)); // Specify the type of 'args' as an array of any type
|
||||
count++;
|
||||
} else {
|
||||
console.error(`Event ${event.name} does not have an execute method.`);
|
||||
}
|
||||
}
|
||||
});
|
||||
return count;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
const { Collection } = require('discord.js')
|
||||
const { Client } = require('discord.js-selfbot-v13');
|
||||
|
||||
const loadEvents = require("./loadEvents");
|
||||
const loadCommands = require("./loadCommands");
|
||||
|
||||
module.exports = function run(token: string) {
|
||||
const client = new Client({ checkUpdate: false });
|
||||
|
||||
client.events = new Collection();
|
||||
client.commands = new Collection();
|
||||
|
||||
console.log(`${loadEvents(client, '..\\events')} events loaded`);
|
||||
console.log(`${loadCommands(client, '..\\commands')} commands loaded`);
|
||||
|
||||
client.login(token);
|
||||
};
|
||||
Reference in New Issue
Block a user