commit
b93cf373bc
8 changed files with 0 additions and 226 deletions
|
@ -1,16 +0,0 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const discord_js_1 = require("discord.js");
|
||||
class DiscordClient extends discord_js_1.Client {
|
||||
constructor(options) {
|
||||
super(options);
|
||||
this._commands = new discord_js_1.Collection();
|
||||
this._events = new discord_js_1.Collection();
|
||||
this._prefix = '!';
|
||||
}
|
||||
get commands() { return this._commands; }
|
||||
get events() { return this._events; }
|
||||
get prefix() { return this._prefix; }
|
||||
set prefix(prefix) { this._prefix = prefix; }
|
||||
}
|
||||
exports.default = DiscordClient;
|
|
@ -1,26 +0,0 @@
|
|||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const BaseCommand_1 = __importDefault(require("../../utils/structures/BaseCommand"));
|
||||
class TestCommand extends BaseCommand_1.default {
|
||||
constructor() {
|
||||
super('test', 'testing', []);
|
||||
}
|
||||
run(client, message, args) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
message.channel.send('Test command works');
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.default = TestCommand;
|
|
@ -1,37 +0,0 @@
|
|||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const BaseEvent_1 = __importDefault(require("../../utils/structures/BaseEvent"));
|
||||
class MessageEvent extends BaseEvent_1.default {
|
||||
constructor() {
|
||||
super('message');
|
||||
}
|
||||
run(client, message) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (message.author.bot)
|
||||
return;
|
||||
if (message.content.startsWith(client.prefix)) {
|
||||
const [cmdName, ...cmdArgs] = message.content
|
||||
.slice(client.prefix.length)
|
||||
.trim()
|
||||
.split(/\s+/);
|
||||
const command = client.commands.get(cmdName);
|
||||
if (command) {
|
||||
command.run(client, message, cmdArgs);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.default = MessageEvent;
|
|
@ -1,26 +0,0 @@
|
|||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const BaseEvent_1 = __importDefault(require("../../utils/structures/BaseEvent"));
|
||||
class ReadyEvent extends BaseEvent_1.default {
|
||||
constructor() {
|
||||
super('ready');
|
||||
}
|
||||
run(client) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
console.log('Bot has logged in.');
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.default = ReadyEvent;
|
25
src/index.js
25
src/index.js
|
@ -1,25 +0,0 @@
|
|||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const registry_1 = require("./utils/registry");
|
||||
const slappey_json_1 = __importDefault(require("../slappey.json"));
|
||||
const client_1 = __importDefault(require("./client/client"));
|
||||
const discord_js_1 = require("discord.js");
|
||||
const client = new client_1.default({ intents: [discord_js_1.Intents.FLAGS.GUILDS, discord_js_1.Intents.FLAGS.GUILD_MESSAGES] });
|
||||
(() => __awaiter(void 0, void 0, void 0, function* () {
|
||||
client.prefix = slappey_json_1.default.prefix || client.prefix;
|
||||
yield (0, registry_1.registerCommands)(client, '../commands');
|
||||
yield (0, registry_1.registerEvents)(client, '../events');
|
||||
yield client.login(slappey_json_1.default.token);
|
||||
}))();
|
|
@ -1,74 +0,0 @@
|
|||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.registerEvents = exports.registerCommands = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const fs_1 = require("fs");
|
||||
function registerCommands(client, dir = '') {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const filePath = path_1.default.join(__dirname, dir);
|
||||
const files = yield fs_1.promises.readdir(filePath);
|
||||
for (const file of files) {
|
||||
const stat = yield fs_1.promises.lstat(path_1.default.join(filePath, file));
|
||||
if (stat.isDirectory())
|
||||
registerCommands(client, path_1.default.join(dir, file));
|
||||
if (file.endsWith('.js') || file.endsWith('.ts')) {
|
||||
const { default: Command } = yield Promise.resolve().then(() => __importStar(require(path_1.default.join(dir, file))));
|
||||
const command = new Command();
|
||||
client.commands.set(command.getName(), command);
|
||||
command.getAliases().forEach((alias) => {
|
||||
client.commands.set(alias, command);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.registerCommands = registerCommands;
|
||||
function registerEvents(client, dir = '') {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const filePath = path_1.default.join(__dirname, dir);
|
||||
const files = yield fs_1.promises.readdir(filePath);
|
||||
for (const file of files) {
|
||||
const stat = yield fs_1.promises.lstat(path_1.default.join(filePath, file));
|
||||
if (stat.isDirectory())
|
||||
registerEvents(client, path_1.default.join(dir, file));
|
||||
if (file.endsWith('.js') || file.endsWith('.ts')) {
|
||||
const { default: Event } = yield Promise.resolve().then(() => __importStar(require(path_1.default.join(dir, file))));
|
||||
const event = new Event();
|
||||
client.events.set(event.getName(), event);
|
||||
client.on(event.getName(), event.run.bind(event, client));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.registerEvents = registerEvents;
|
|
@ -1,13 +0,0 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
class BaseCommand {
|
||||
constructor(name, category, aliases) {
|
||||
this.name = name;
|
||||
this.category = category;
|
||||
this.aliases = aliases;
|
||||
}
|
||||
getName() { return this.name; }
|
||||
getCategory() { return this.category; }
|
||||
getAliases() { return this.aliases; }
|
||||
}
|
||||
exports.default = BaseCommand;
|
|
@ -1,9 +0,0 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
class BaseEvent {
|
||||
constructor(name) {
|
||||
this.name = name;
|
||||
}
|
||||
getName() { return this.name; }
|
||||
}
|
||||
exports.default = BaseEvent;
|
Reference in a new issue