-
Notifications
You must be signed in to change notification settings - Fork 0
/
handyFunctions.js
32 lines (30 loc) · 1.21 KB
/
handyFunctions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
module.exports = {
async reloadCommands (client, cmd) {
const oldCommand = client.commands.get(cmd) || client.commands.find(a => a.aliases && a.aliases.includes(cmd));
if (process.env.debug && oldCommand) {
try {
delete require.cache[require.resolve(`@root/commands/${oldCommand.name}.js`)]; //Delete the old command
client.commands.delete(oldCommand.name);
const reloadedCommand = require(`@root/commands/${oldCommand.name}.js`); //Load the new command
client.commands.set(reloadedCommand.name, reloadedCommand);
} catch (err) {
console.log(err);
}
}
},
initWebserver(client) {
const express = require('express');
const app = express();
const port = 3000;
const address = "0.0.0.0";
app.get('/', (req, res) => {
res.send(`
<img src=${client.user.avatarURL()}>
This webpage is served as a test page to see if the bot is up and running!
`);
});
app.listen(port, address, () => console.log(`Webserver listening at http://${address}:${port}`)).on("error", (err) => {
console.log(`Failed to open web server with code: "${err.code}"`);
});
}
}