Skip to content

Instantly share code, notes, and snippets.

@ha6000
Last active February 14, 2020 12:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ha6000/3d35ee4f9de61b938c17ca749623d79c to your computer and use it in GitHub Desktop.
Save ha6000/3d35ee4f9de61b938c17ca749623d79c to your computer and use it in GitHub Desktop.
const dotenv = require('dotenv');
const clientOptionsDefaults = {
token: undefined,
logChannel: undefined
};
class missingLogChannelError extends Error {
constructor() {
super('Log Channel not found.');
this.name = 'missingLogChannel';
};
};
const colors = {
green: 0x84ed47
}
module.exports = {
Handler: class {
constructor(Discord) {
this.Discord = Discord;
const logChannelReadyEmbed = new this.Discord.RichEmbed({
title: 'Bot Ready',
color: colors.green
})
// I have a feeling something here doesent send the right things to Client
class Client
extends Discord.Client {
constructor(options) {
super();
this.opts = clientOptionsDefaults;
this.opts = Object.assign(this.opts, options);
// removes options from the arguments (IDK if it will work)
if (options.token) {
this.on('ready', () => {
console.log(`${this.username} is ready`);
// checks if log channel is a option
if (options.logChannel) {
// gets the log channel
const logChannel = this.channels.get(options.logChannel);
// checks if its a valid log channel
if (logChannel) {
logChannelReadyEmbed.setDescription(`${this.user.username} is ready.`);
} else {
throw new missingLogChannelError();
};
}
});
this.login(this.opts.token);
};
};
}
this.Discord.Client = Client;
};
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment