parent
e3eb892ee4
commit
0ad1f98a9b
@ -1,13 +1,17 @@ |
|||||||
const express = require('express'); |
const express = require('express'); |
||||||
|
const chalk = require('chalk'); |
||||||
|
|
||||||
module.exports = (client) => { |
module.exports = (client) => { |
||||||
const api = express(); |
return new Promise(r => { |
||||||
client.api = {wubzy: {}, natsuki: {}}; |
const api = express(); |
||||||
client.api.wubzy.app = api; |
client.api = {wubzy: {}, natsuki: {}}; |
||||||
|
client.api.log = (message, type, prenl, postnl) => client.log(message, {source: 'API', sourceColor: '#1F2B56', suffix: `${type ? chalk.gray(` [${type.toUpperCase()}]`) : ''} >> `}, prenl, postnl); |
||||||
|
client.api.wubzy.app = api; |
||||||
|
|
||||||
client.api.wubzy.app.get('/', (req, res) => res.send("You've reached the wubzy.xyz API. If you're looking for Natsuki's endpoints, please append /natsuki to your query.")); |
client.api.wubzy.app.get('/', (req, res) => res.send("You've reached the wubzy.xyz API. If you're looking for Natsuki's endpoints, please append /natsuki to your query.")); |
||||||
client.api.wubzy.app.get('/natsuki', (req, res) => res.send("You've reached Natsuki's status endpoint. Receiving this 200 reply indicates that Natsuki is online. If you're looking for the Natsuki API, it has been moved to natsuki.app")); |
client.api.wubzy.app.get('/natsuki', (req, res) => res.send("You've reached Natsuki's status endpoint. Receiving this 200 reply indicates that Natsuki is online. If you're looking for the Natsuki API, it has been moved to natsuki.app")); |
||||||
client.api.wubzy.app.get('/natsuki/:any?', (req, res) => res.status(301).send("Natsuki's API permanently resides at natsuki.app")); |
client.api.wubzy.app.get('/natsuki/:any?', (req, res) => res.status(301).send("Natsuki's API permanently resides at natsuki.app")); |
||||||
|
|
||||||
client.api.wubzy.server = client.api.wubzy.app.listen(4072, () => console.log(`Ready at ${client.api.wubzy.server.address().address}:${client.api.wubzy.server.address().port}`)); |
client.api.wubzy.server = client.api.wubzy.app.listen(4072, () => {client.api.log(`API ready at ${client.api.wubzy.server.address().address.replace('::', 'localhost')}:${client.api.wubzy.server.address().port}`, 'boot', false, true); r();}); |
||||||
|
}); |
||||||
}; |
}; |
@ -1,6 +1,7 @@ |
|||||||
module.exports = { |
module.exports = { |
||||||
name: "ping", |
name: "ping", |
||||||
aliases: ["p"], |
aliases: ["p"], |
||||||
|
syntax: '`ping`', |
||||||
async run(client, message, args, cmd) { |
async run(client, message, args, cmd) { |
||||||
message.reply("Pong! This is Natsuki v2 you're speaking with \\*tips hat*"); |
message.reply("Pong! This is Natsuki v2 you're speaking with \\*tips hat*"); |
||||||
} |
} |
||||||
|
@ -1,8 +1,10 @@ |
|||||||
module.exports = async client => { |
module.exports = async client => { |
||||||
client.basePrefix = client.config.options.dev ? client.config.options.prefix || client.config.bot.devPrefix : client.config.bot.prefix; |
client.basePrefix = client.config.options.dev ? client.config.options.prefix || client.config.bot.devPrefix : client.config.bot.prefix; |
||||||
|
|
||||||
|
await require('../../../api/index')(client); |
||||||
|
|
||||||
require('../../startup/run/hello')(client); // startup info
|
require('../../startup/run/hello')(client); // startup info
|
||||||
require('../../startup/run/setstatus')(client); |
require('../../startup/run/setstatus')(client); |
||||||
|
|
||||||
require('../../../api/index')(client); |
client.log(client.utils.gr(client.config.randResp.cliloaded), {color: "#78d9f8", source: client.config.bot.consoleName}, true, true); //natsuki doing some more complaining
|
||||||
}; |
}; |
@ -1,8 +1,11 @@ |
|||||||
const chalk = require('chalk'); |
const chalk = require('chalk'); |
||||||
|
|
||||||
module.exports = e => { |
module.exports = (client, e, p) => { |
||||||
console.log(`#######################################\n\n${chalk.grey('[NATS]')} >> ${chalk.hex('#78d9f8')("Well this is awkward.")}\n`); |
console.log(`#######################################\n\n[${chalk.grey(client.config.bot.consoleName)}] >> ${chalk.hex('#78d9f8')("Well this is awkward.")}\n`); |
||||||
console.log(`${chalk.bold.redBright.underline("There was an error that killed Natsuki's process.")}\n${chalk.redBright("See available stack trace and error information below.")}\n`); |
console.log(`${chalk.bold.redBright.underline(`There was an error that killed ${client.utils.ps(client.config.bot.name)} process.`)}\n${chalk.redBright("See available stack trace and error information below.")}\n`); |
||||||
|
if (p) { |
||||||
|
client.log("This exception originates from an unhandled, uncaught promise rejection. Ya doofus.", 0, 0, 1); |
||||||
|
} |
||||||
console.error(e); |
console.error(e); |
||||||
console.log(`\n#######################################\n\n${chalk.grey('[NATS]')} >> ${chalk.hex('#78d9f8')("Back to sleepies...")}`); |
console.log(`\n#######################################`); |
||||||
}; |
}; |
@ -0,0 +1,13 @@ |
|||||||
|
const errorhandler = require("../log/errorhandler"); |
||||||
|
const chalk = require('chalk'); |
||||||
|
|
||||||
|
module.exports = client => { |
||||||
|
process.on('unhandledRejection', (e, p) => { //nested promise rejections like to be icky so this should catch them all
|
||||||
|
errorhandler(client, e, p); |
||||||
|
return process.exit(1); //i guess this handler does keep the event loop running but i'll adopt a zero-tolerance policy for unhandled rejections
|
||||||
|
}); // gotta catch 'em all
|
||||||
|
process.on('exit', code => { |
||||||
|
client.log("Back to sleepies...", {color: "#78d9f8", source: client.config.bot.consoleName}, true); |
||||||
|
return console.log(chalk.grey(`Exit code ${chalk.white(code)}`)); |
||||||
|
}); |
||||||
|
}; |
Loading…
Reference in new issue