Created
February 14, 2020 07:39
-
-
Save ha6000/9564a4e9c813a66ab18d281d84f25f68 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.options = clientOptionsDefaults; | |
this.options = Object.assign(this.options, 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.options.token); | |
}; | |
}; | |
} | |
this.Discord.Client = Client; | |
}; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment