Compare commits

..

No commits in common. '3182903c77eb9e7636ae3d8ec31de3f8178b101a' and '245603472639904111b5f8bc4e860aeb1358b200' have entirely different histories.

  1. 2
      .gitignore
  2. 9
      bot.js
  3. 114
      package-lock.json
  4. 7
      src/db/connect.js
  5. 19
      src/handle/startup/run/login.js
  6. 12
      src/json/config.json

2
.gitignore vendored

@ -7,5 +7,3 @@ api/**/*
api/ api/
.idea/**/* .idea/**/*
/man.js /man.js
.history/
.history/**/*

@ -21,14 +21,9 @@ const startBot = async () => {
const loggers = log(client); const loggers = log(client);
Object.keys(loggers).forEach(logger => client[logger] = loggers[logger]); Object.keys(loggers).forEach(logger => client[logger] = loggers[logger]);
client.log(client.utils.gr(client.config.randResp.clistart), {color: "#78d9f8", source: "NATS"}, true, true); //natsuki's wakeup log client.log(client.utils.gr(client.config.randResp.clistart), {color: "#78d9f8", source: "NATS"});
await require('./src/handle/startup/run/login')(client); //log in to discord
await require('./src/db/connect')(client); //connect to database
}; };
startBot().catch(() => { startBot();
console.log("\nWell this is awkward.\n");
}); // TODO add a .catch() and flag to recover the process
// feels like there isn't a function name to do this justice :joy: // feels like there isn't a function name to do this justice :joy:
// to do list: // to do list:

114
package-lock.json generated

@ -47,9 +47,9 @@
} }
}, },
"node_modules/@discordjs/builders/node_modules/discord-api-types": { "node_modules/@discordjs/builders/node_modules/discord-api-types": {
"version": "0.37.16", "version": "0.37.14",
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.16.tgz", "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.14.tgz",
"integrity": "sha512-H0FDY6+ww4YZe1+L+2ERWU3KsVSInWLvK0TeImhiTi49DXff8sFLnqqnEiEdMEhwFlkQMUIe4xL5Py046s+Ksg==" "integrity": "sha512-byBH7SfDCMJwxdqeS8k5sihltH88/YPhuwx+vF2cftSxFLdxyHyU/ZxDL3bq+LB2c4ls/TymE76/ISlLfniUXg=="
}, },
"node_modules/@discordjs/collection": { "node_modules/@discordjs/collection": {
"version": "1.2.0", "version": "1.2.0",
@ -78,9 +78,9 @@
} }
}, },
"node_modules/@discordjs/rest/node_modules/discord-api-types": { "node_modules/@discordjs/rest/node_modules/discord-api-types": {
"version": "0.37.16", "version": "0.37.14",
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.16.tgz", "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.14.tgz",
"integrity": "sha512-H0FDY6+ww4YZe1+L+2ERWU3KsVSInWLvK0TeImhiTi49DXff8sFLnqqnEiEdMEhwFlkQMUIe4xL5Py046s+Ksg==" "integrity": "sha512-byBH7SfDCMJwxdqeS8k5sihltH88/YPhuwx+vF2cftSxFLdxyHyU/ZxDL3bq+LB2c4ls/TymE76/ISlLfniUXg=="
}, },
"node_modules/@discordjs/util": { "node_modules/@discordjs/util": {
"version": "0.1.0", "version": "0.1.0",
@ -163,9 +163,9 @@
} }
}, },
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "18.11.9", "version": "18.11.3",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.9.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.3.tgz",
"integrity": "sha512-CRpX21/kGdzjOpFsZSkcrXMGIBWMGNIHXXBVFSH+ggkftxg+XYP20TESbh+zFvFj3EQOl5byk0HTRn1IL6hbqg==" "integrity": "sha512-fNjDQzzOsZeKZu5NATgXUPsaFaTxeRgFXoosrHivTl8RGeV733OLawXsGfEk9a8/tySyZUyiZ6E8LcjPFZ2y1A=="
}, },
"node_modules/@types/tinycolor2": { "node_modules/@types/tinycolor2": {
"version": "1.4.3", "version": "1.4.3",
@ -338,13 +338,13 @@
} }
}, },
"node_modules/canvas": { "node_modules/canvas": {
"version": "2.10.2", "version": "2.10.1",
"resolved": "https://registry.npmjs.org/canvas/-/canvas-2.10.2.tgz", "resolved": "https://registry.npmjs.org/canvas/-/canvas-2.10.1.tgz",
"integrity": "sha512-FSmlsip0nZ0U4Zcfht0qBJqDhlfGuevTZKE8h+dBOYrJjGvY3iqMGSzzbvkaFhvMXiVxfcMaPHS/kge++T5SKg==", "integrity": "sha512-29pIjn9uwTUsIgJUNd7GXxKk8sg4iyJwLm1wIilNIqX1mVzXSc2nUij9exW1LqNpis1d2ebMYfMqTWcokZ4pdA==",
"hasInstallScript": true, "hasInstallScript": true,
"dependencies": { "dependencies": {
"@mapbox/node-pre-gyp": "^1.0.0", "@mapbox/node-pre-gyp": "^1.0.0",
"nan": "^2.17.0", "nan": "^2.15.0",
"simple-get": "^3.0.3" "simple-get": "^3.0.3"
}, },
"engines": { "engines": {
@ -547,14 +547,14 @@
} }
}, },
"node_modules/discord.js/node_modules/discord-api-types": { "node_modules/discord.js/node_modules/discord-api-types": {
"version": "0.37.16", "version": "0.37.14",
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.16.tgz", "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.14.tgz",
"integrity": "sha512-H0FDY6+ww4YZe1+L+2ERWU3KsVSInWLvK0TeImhiTi49DXff8sFLnqqnEiEdMEhwFlkQMUIe4xL5Py046s+Ksg==" "integrity": "sha512-byBH7SfDCMJwxdqeS8k5sihltH88/YPhuwx+vF2cftSxFLdxyHyU/ZxDL3bq+LB2c4ls/TymE76/ISlLfniUXg=="
}, },
"node_modules/discord.js/node_modules/ws": { "node_modules/discord.js/node_modules/ws": {
"version": "8.11.0", "version": "8.9.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz", "resolved": "https://registry.npmjs.org/ws/-/ws-8.9.0.tgz",
"integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==", "integrity": "sha512-Ja7nszREasGaYUYCI2k4lCKIRTt+y7XuqVoHR44YpI49TtryyqbqvDMn5eqfW7e6HzTukDRIsXqzVHScqRcafg==",
"engines": { "engines": {
"node": ">=10.0.0" "node": ">=10.0.0"
}, },
@ -1574,9 +1574,9 @@
} }
}, },
"node_modules/tar": { "node_modules/tar": {
"version": "6.1.12", "version": "6.1.11",
"resolved": "https://registry.npmjs.org/tar/-/tar-6.1.12.tgz", "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.11.tgz",
"integrity": "sha512-jU4TdemS31uABHd+Lt5WEYJuzn+TJTCBLljvIAHZOz6M9Os5pJ4dD+vRFLxPa/n3T0iEFzpi+0x1UfuDZYbRMw==", "integrity": "sha512-an/KZQzQUkZCkuoAA64hM92X0Urb6VpRhAFllDzz44U2mcD5scmT3zBc4VgVpkugF580+DQn8eAFSyoQt0tznA==",
"dependencies": { "dependencies": {
"chownr": "^2.0.0", "chownr": "^2.0.0",
"fs-minipass": "^2.0.0", "fs-minipass": "^2.0.0",
@ -1586,7 +1586,7 @@
"yallist": "^4.0.0" "yallist": "^4.0.0"
}, },
"engines": { "engines": {
"node": ">=10" "node": ">= 10"
} }
}, },
"node_modules/tinycolor2": { "node_modules/tinycolor2": {
@ -1633,9 +1633,9 @@
"integrity": "sha512-hvE+ZYXuINrx6Ei6D6hz+PTim0Uf++dYbK9FFifLNwQj+RwKquhQpn868yZsCtJYiclZF1u8l6WZxxKi+vv7Rg==" "integrity": "sha512-hvE+ZYXuINrx6Ei6D6hz+PTim0Uf++dYbK9FFifLNwQj+RwKquhQpn868yZsCtJYiclZF1u8l6WZxxKi+vv7Rg=="
}, },
"node_modules/tslib": { "node_modules/tslib": {
"version": "2.4.1", "version": "2.4.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.1.tgz", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz",
"integrity": "sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA==" "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ=="
}, },
"node_modules/typical": { "node_modules/typical": {
"version": "5.2.0", "version": "5.2.0",
@ -1651,9 +1651,9 @@
"integrity": "sha512-z4o1fvKUojIWh9XuaVLUDdf86RQiq13AC1dmHbTpoyuu+bquHms76v16CjycCbec87J7z0k//SiQVk0sMdFmpQ==" "integrity": "sha512-z4o1fvKUojIWh9XuaVLUDdf86RQiq13AC1dmHbTpoyuu+bquHms76v16CjycCbec87J7z0k//SiQVk0sMdFmpQ=="
}, },
"node_modules/undici": { "node_modules/undici": {
"version": "5.12.0", "version": "5.11.0",
"resolved": "https://registry.npmjs.org/undici/-/undici-5.12.0.tgz", "resolved": "https://registry.npmjs.org/undici/-/undici-5.11.0.tgz",
"integrity": "sha512-zMLamCG62PGjd9HHMpo05bSLvvwWOZgGeiWlN/vlqu3+lRo3elxktVGEyLMX+IO7c2eflLjcW74AlkhEZm15mg==", "integrity": "sha512-oWjWJHzFet0Ow4YZBkyiJwiK5vWqEYoH7BINzJAJOLedZ++JpAlCbUktW2GQ2DS2FpKmxD/JMtWUUWl1BtghGw==",
"dependencies": { "dependencies": {
"busboy": "^1.6.0" "busboy": "^1.6.0"
}, },
@ -1754,9 +1754,9 @@
}, },
"dependencies": { "dependencies": {
"discord-api-types": { "discord-api-types": {
"version": "0.37.16", "version": "0.37.14",
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.16.tgz", "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.14.tgz",
"integrity": "sha512-H0FDY6+ww4YZe1+L+2ERWU3KsVSInWLvK0TeImhiTi49DXff8sFLnqqnEiEdMEhwFlkQMUIe4xL5Py046s+Ksg==" "integrity": "sha512-byBH7SfDCMJwxdqeS8k5sihltH88/YPhuwx+vF2cftSxFLdxyHyU/ZxDL3bq+LB2c4ls/TymE76/ISlLfniUXg=="
} }
} }
}, },
@ -1781,9 +1781,9 @@
}, },
"dependencies": { "dependencies": {
"discord-api-types": { "discord-api-types": {
"version": "0.37.16", "version": "0.37.14",
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.16.tgz", "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.14.tgz",
"integrity": "sha512-H0FDY6+ww4YZe1+L+2ERWU3KsVSInWLvK0TeImhiTi49DXff8sFLnqqnEiEdMEhwFlkQMUIe4xL5Py046s+Ksg==" "integrity": "sha512-byBH7SfDCMJwxdqeS8k5sihltH88/YPhuwx+vF2cftSxFLdxyHyU/ZxDL3bq+LB2c4ls/TymE76/ISlLfniUXg=="
} }
} }
}, },
@ -1850,9 +1850,9 @@
} }
}, },
"@types/node": { "@types/node": {
"version": "18.11.9", "version": "18.11.3",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.9.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.3.tgz",
"integrity": "sha512-CRpX21/kGdzjOpFsZSkcrXMGIBWMGNIHXXBVFSH+ggkftxg+XYP20TESbh+zFvFj3EQOl5byk0HTRn1IL6hbqg==" "integrity": "sha512-fNjDQzzOsZeKZu5NATgXUPsaFaTxeRgFXoosrHivTl8RGeV733OLawXsGfEk9a8/tySyZUyiZ6E8LcjPFZ2y1A=="
}, },
"@types/tinycolor2": { "@types/tinycolor2": {
"version": "1.4.3", "version": "1.4.3",
@ -1975,12 +1975,12 @@
} }
}, },
"canvas": { "canvas": {
"version": "2.10.2", "version": "2.10.1",
"resolved": "https://registry.npmjs.org/canvas/-/canvas-2.10.2.tgz", "resolved": "https://registry.npmjs.org/canvas/-/canvas-2.10.1.tgz",
"integrity": "sha512-FSmlsip0nZ0U4Zcfht0qBJqDhlfGuevTZKE8h+dBOYrJjGvY3iqMGSzzbvkaFhvMXiVxfcMaPHS/kge++T5SKg==", "integrity": "sha512-29pIjn9uwTUsIgJUNd7GXxKk8sg4iyJwLm1wIilNIqX1mVzXSc2nUij9exW1LqNpis1d2ebMYfMqTWcokZ4pdA==",
"requires": { "requires": {
"@mapbox/node-pre-gyp": "^1.0.0", "@mapbox/node-pre-gyp": "^1.0.0",
"nan": "^2.17.0", "nan": "^2.15.0",
"simple-get": "^3.0.3" "simple-get": "^3.0.3"
} }
}, },
@ -2126,14 +2126,14 @@
}, },
"dependencies": { "dependencies": {
"discord-api-types": { "discord-api-types": {
"version": "0.37.16", "version": "0.37.14",
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.16.tgz", "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.14.tgz",
"integrity": "sha512-H0FDY6+ww4YZe1+L+2ERWU3KsVSInWLvK0TeImhiTi49DXff8sFLnqqnEiEdMEhwFlkQMUIe4xL5Py046s+Ksg==" "integrity": "sha512-byBH7SfDCMJwxdqeS8k5sihltH88/YPhuwx+vF2cftSxFLdxyHyU/ZxDL3bq+LB2c4ls/TymE76/ISlLfniUXg=="
}, },
"ws": { "ws": {
"version": "8.11.0", "version": "8.9.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz", "resolved": "https://registry.npmjs.org/ws/-/ws-8.9.0.tgz",
"integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==", "integrity": "sha512-Ja7nszREasGaYUYCI2k4lCKIRTt+y7XuqVoHR44YpI49TtryyqbqvDMn5eqfW7e6HzTukDRIsXqzVHScqRcafg==",
"requires": {} "requires": {}
} }
} }
@ -2858,9 +2858,9 @@
} }
}, },
"tar": { "tar": {
"version": "6.1.12", "version": "6.1.11",
"resolved": "https://registry.npmjs.org/tar/-/tar-6.1.12.tgz", "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.11.tgz",
"integrity": "sha512-jU4TdemS31uABHd+Lt5WEYJuzn+TJTCBLljvIAHZOz6M9Os5pJ4dD+vRFLxPa/n3T0iEFzpi+0x1UfuDZYbRMw==", "integrity": "sha512-an/KZQzQUkZCkuoAA64hM92X0Urb6VpRhAFllDzz44U2mcD5scmT3zBc4VgVpkugF580+DQn8eAFSyoQt0tznA==",
"requires": { "requires": {
"chownr": "^2.0.0", "chownr": "^2.0.0",
"fs-minipass": "^2.0.0", "fs-minipass": "^2.0.0",
@ -2904,9 +2904,9 @@
"integrity": "sha512-hvE+ZYXuINrx6Ei6D6hz+PTim0Uf++dYbK9FFifLNwQj+RwKquhQpn868yZsCtJYiclZF1u8l6WZxxKi+vv7Rg==" "integrity": "sha512-hvE+ZYXuINrx6Ei6D6hz+PTim0Uf++dYbK9FFifLNwQj+RwKquhQpn868yZsCtJYiclZF1u8l6WZxxKi+vv7Rg=="
}, },
"tslib": { "tslib": {
"version": "2.4.1", "version": "2.4.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.1.tgz", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz",
"integrity": "sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA==" "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ=="
}, },
"typical": { "typical": {
"version": "5.2.0", "version": "5.2.0",
@ -2919,9 +2919,9 @@
"integrity": "sha512-z4o1fvKUojIWh9XuaVLUDdf86RQiq13AC1dmHbTpoyuu+bquHms76v16CjycCbec87J7z0k//SiQVk0sMdFmpQ==" "integrity": "sha512-z4o1fvKUojIWh9XuaVLUDdf86RQiq13AC1dmHbTpoyuu+bquHms76v16CjycCbec87J7z0k//SiQVk0sMdFmpQ=="
}, },
"undici": { "undici": {
"version": "5.12.0", "version": "5.11.0",
"resolved": "https://registry.npmjs.org/undici/-/undici-5.12.0.tgz", "resolved": "https://registry.npmjs.org/undici/-/undici-5.11.0.tgz",
"integrity": "sha512-zMLamCG62PGjd9HHMpo05bSLvvwWOZgGeiWlN/vlqu3+lRo3elxktVGEyLMX+IO7c2eflLjcW74AlkhEZm15mg==", "integrity": "sha512-oWjWJHzFet0Ow4YZBkyiJwiK5vWqEYoH7BINzJAJOLedZ++JpAlCbUktW2GQ2DS2FpKmxD/JMtWUUWl1BtghGw==",
"requires": { "requires": {
"busboy": "^1.6.0" "busboy": "^1.6.0"
} }

@ -7,16 +7,17 @@ const ora = require('../util/log/ora');
module.exports = async client => { module.exports = async client => {
const auth = client.auth; const auth = client.auth;
const t = Date.now(); const t = Date.now();
client.misc = {};
client.misc.dbconnected = false; client.misc.dbconnected = false;
await ora(chalk.blueBright.bold.underline("Connecting to MongoDB..."), await ora(chalk.blueBright.bold.underline("Connecting to MongoDB..."),
mongoose.connect(`mongodb+srv://${auth.database.user}:${auth.database.password}@${auth.database.cluster}.3jpp4.mongodb.net/test`, { mongoose.connect(`mongodb+srv://${auth.database.user}:${auth.database.password}@${auth.database.cluster}.3jpp4.mongodb.net/test`, {
useFindAndModify: false, useNewUrlParser: true, dbName: auth.database.name, useUnifiedTopology: true, useCreateIndex: true useFindAndModify: false, useNewUrlParser: true, dbName: auth.database.name, useUnifiedTopology: true, useCreateIndex: true
}) })
).catch((e) => client.error("Failed to connect to mongoose!! Error below.", 0, true, true, e)) ).catch((e) => log(client).error("Failed to connect to mongoose!! Error below.", 0, true, true, e))
.then(() => {client.misc.dbconnected = true;}); .then(() => {client.misc.dbconnected = true;});
if (!client.misc.dbconnected) { if (!client.misc.dbconnected) {
client.warn("Database not connected, considering runtime to be unusable and exiting.", 0, true, true); log(client).warn("Database not connected, considering runtime to be unusable and exiting.", 0, true, true);
throw new Error(); throw new Error();
} }
return client.success(`Connected to Mongo Database in ${chalk.white(`${Date.now() - t}ms`)}.`); return log(client).success(`Connected to Mongo Database in ${chalk.white(`${Date.now() - t}ms`)}.`);
}; };

@ -1,19 +0,0 @@
const chalk = require('chalk');
const ora = require('../../../util/log/ora');
module.exports = async (client) => {
const t = Date.now();
client.misc = {};
client.misc.dscconnected = false;
await ora(`Waking up Natsuki... ${chalk.blueBright.bold.underline("(Connecting to Discord...)")}`,
client.login(client.auth.token)
).catch((e) => client.error("Failed to connect to Discord!! Error below.", 0, true, true, e))
.then(() => {client.misc.dscconnected = true;});
if (!client.misc.dscconnected) {
client.warn("Discord not connected, considering runtime to be unusable and exiting.", 0, true, true);
throw new Error();
}
return client.success(`Connected to Discord in ${chalk.white(`${Date.now() - t}ms`)}.`);
};

@ -3,12 +3,12 @@
"suffix": ">>", "suffix": ">>",
"defaultLevel": 1, "defaultLevel": 1,
"colors": { "colors": {
"error": "redBright", "error": "",
"warn": "yellowBright", "warn": "",
"success": "greenBright", "success": "",
"notice": "#8521a0", "notice": "",
"primary": "blueBright", "primary": "",
"secondary": "white", "secondary": "",
"altprimary": "", "altprimary": "",
"altsecondary": "" "altsecondary": ""
} }

Loading…
Cancel
Save