Last active
February 14, 2020 12:16
-
-
Save ha6000/3d35ee4f9de61b938c17ca749623d79c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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