forked from Supositware/Haha-Yes
updated the change from discord v12 and akairo v8
parent
d2d4fda926
commit
bda3ea4765
@ -1,33 +1,49 @@
|
||||
const { AkairoClient } = require('discord-akairo');
|
||||
const { token, prefix, ownerID, statsChannel } = require('./config.json');
|
||||
const { AkairoClient, CommandHandler, InhibitorHandler, ListenerHandler } = require('discord-akairo');
|
||||
const { token, prefix, ownerID } = require('./config.json');
|
||||
|
||||
const client = new AkairoClient({
|
||||
|
||||
class hahaYesClient extends AkairoClient {
|
||||
constructor() {
|
||||
super({
|
||||
ownerID: ownerID,
|
||||
}, {
|
||||
disableEveryone: true
|
||||
});
|
||||
|
||||
this.commandHandler = new CommandHandler(this, {
|
||||
directory: './commands/',
|
||||
prefix: prefix,
|
||||
commandUtil: true,
|
||||
commandUtilLifetime: 600000,
|
||||
allowMention: true,
|
||||
handleEdits: true,
|
||||
});
|
||||
|
||||
this.inhibitorHandler = new InhibitorHandler(this, {
|
||||
directory: './inhibitors/',
|
||||
emitters: {
|
||||
process
|
||||
},
|
||||
commandUtil: true,
|
||||
commandUtilLifetime: 600000,
|
||||
commandDirectory: './commands/',
|
||||
inhibitorDirectory: './inhibitors/',
|
||||
listenerDirectory: './listeners/'
|
||||
}, {
|
||||
disableEveryone: true
|
||||
});
|
||||
|
||||
// Ready messages dosent work on the listeners event for some reasons
|
||||
client.on('ready', async () => {
|
||||
// Send stats to the console
|
||||
console.log(`\x1b[32mLogged in as \x1b[34m${client.user.tag}\x1b[0m! (\x1b[33m${client.user.id}\x1b[0m)`);
|
||||
console.log(`Ready to serve in \x1b[33m${client.channels.size}\x1b[0m channels on \x1b[33m${client.guilds.size}\x1b[0m servers, for a total of \x1b[33m${client.users.size}\x1b[0m users. \x1b${client.readyAt}\x1b[0m`);
|
||||
// Send stats to the 'stats' channel in the support server if its not the test bot
|
||||
if (client.user.id == 377563711927484418) {
|
||||
const channel = client.channels.get(statsChannel);
|
||||
channel.send(`Ready to serve in ${client.channels.size} channels on ${client.guilds.size} servers, for a total of ${client.users.size} users. ${client.readyAt}`);
|
||||
client.user.setActivity(`${prefix} feedback <feedback> to tell me what you think of the bot! | ${prefix} help`); }
|
||||
});
|
||||
});
|
||||
|
||||
this.listenerHandler = new ListenerHandler(this, {
|
||||
directory: './listeners/'
|
||||
});
|
||||
|
||||
this.listenerHandler.setEmitters({
|
||||
commandHandler: this.commandHandler,
|
||||
inhibitorHandler: this.inhibitorHandler,
|
||||
listenerHandler: this.listenerHandler
|
||||
});
|
||||
|
||||
this.commandHandler.useInhibitorHandler(this.inhibitorHandler);
|
||||
this.commandHandler.useListenerHandler(this.listenerHandler);
|
||||
|
||||
this.listenerHandler.loadAll();
|
||||
this.inhibitorHandler.loadAll();
|
||||
this.commandHandler.loadAll();
|
||||
}
|
||||
}
|
||||
|
||||
const client = new hahaYesClient();
|
||||
client.login(token);
|
@ -1,16 +0,0 @@
|
||||
const { Listener } = require('discord-akairo');
|
||||
|
||||
class UnhandledRejectionListener extends Listener {
|
||||
constructor() {
|
||||
super('unhandledRejection', {
|
||||
eventName: 'unhandledRejection',
|
||||
emitter: 'process'
|
||||
});
|
||||
}
|
||||
|
||||
exec(error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = UnhandledRejectionListener;
|
@ -0,0 +1,26 @@
|
||||
const { Listener } = require('discord-akairo');
|
||||
const { prefix, statsChannel } = require('../config.json');
|
||||
|
||||
|
||||
class ReadyListener extends Listener {
|
||||
constructor() {
|
||||
super('ready', {
|
||||
emitter: 'client',
|
||||
event: 'ready'
|
||||
});
|
||||
}
|
||||
|
||||
async exec() {
|
||||
// Send stats to the console
|
||||
console.log(`\x1b[32mLogged in as \x1b[34m${this.client.user.tag}\x1b[0m! (\x1b[33m${this.client.user.id}\x1b[0m)`);
|
||||
console.log(`Ready to serve in \x1b[33m${this.client.channels.size}\x1b[0m channels on \x1b[33m${this.client.guilds.size}\x1b[0m servers, for a total of \x1b[33m${this.client.users.size}\x1b[0m users. \x1b${this.client.readyAt}\x1b[0m`);
|
||||
// Send stats to the 'stats' channel in the support server if its not the test bot
|
||||
if (this.client.user.id == 377563711927484418) {
|
||||
const channel = this.client.channels.get(statsChannel);
|
||||
channel.send(`Ready to serve in ${this.client.channels.size} channels on ${this.client.guilds.size} servers, for a total of ${this.client.users.size} users. ${this.client.readyAt}`);
|
||||
this.client.user.setActivity(`${prefix} feedback <feedback> to tell me what you think of the bot! | ${prefix} help`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ReadyListener;
|
Loading…
Reference in New Issue