Compare commits

..

2 Commits

Author SHA1 Message Date
Kit Kasune e3eb892ee4 1st command 2 years ago
Kit Kasune 8e8df4dadc ready api 2 years ago
  1. 14
      src/api/index.js
  2. 7
      src/handle/runtime/commands/bot/ping.js
  3. 7
      src/handle/runtime/events/messageCreate.js
  4. 4
      src/handle/runtime/events/ready.js
  5. 3
      src/handle/startup/collect/commands.js
  6. 2
      src/handle/startup/collect/events.js
  7. 3
      src/handle/startup/run/hello.js
  8. 21
      src/json/config.json

@ -1,7 +1,13 @@
const express = require('express');
const api = express();
api.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."));
api.get('/natsuki', (req, res) => res.send("You've reached Natsuki's API. Receiving this 200 reply indicates that Natsuki is online."));
module.exports = (client) => {
const api = express();
client.api = {wubzy: {}, natsuki: {}};
client.api.wubzy.app = api;
const server = api.listen(4072, () => console.log(`Ready at ${server.address().address}:${server.address().port}`));
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/: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}`));
};

@ -0,0 +1,7 @@
module.exports = {
name: "ping",
aliases: ["p"],
async run(client, message, args, cmd) {
message.reply("Pong! This is Natsuki v2 you're speaking with \\*tips hat*");
}
};

@ -1,3 +1,5 @@
const chalk = require('chalk');
module.exports = async (client, message) => {
if (!message.content || !message.content.length) {return;} //privileged intent fallback
@ -20,4 +22,9 @@ module.exports = async (client, message) => {
cmd.name = args.shift(); //the command without the prefix
cmd.msg = args.join(" ");
cmd.args = message.content.trim().slice(prefixUsed.length).trim().split(/ +/gm).slice(1); //args but preserves text state and newlines
let cmdToRun = client.commands.get(cmd.name) || client.commands.get(client.aliases.get(cmd.name));
if (!cmdToRun) {return;}
try {cmdToRun.run(client, message, args, cmd).catch(e => client.error(`There was an error in the ${cmdToRun.name} command.`, 0, 1, e, '\n'));}
catch (e) {client.error(`There was an error in the ${cmdToRun.name} command.`, 0, 1, e, '\n');}
};

@ -1,6 +1,8 @@
module.exports = async client => {
client.basePrefix = client.config.options.dev ? client.config.options.prefix || "n!" : "n?";
client.basePrefix = client.config.options.dev ? client.config.options.prefix || client.config.bot.devPrefix : client.config.bot.prefix;
require('../../startup/run/hello')(client); // startup info
require('../../startup/run/setstatus')(client);
require('../../../api/index')(client);
};

@ -48,5 +48,6 @@ module.exports = async client => {
readDirs.forEach(dir => client.log(`Read from directory ${chalk.green(dir)}`, {source: 'proc'}));
console.log('');
Object.keys(conflictingAliases).forEach(alias => client.warn(`Alias ${chalk.white(alias)} appears on ${client.utils.as(conflictingAliases[alias].length, 'command')} ${chalk.white(conflictingAliases[alias].join(chalk.yellow(', ')))}`));
client.log(`Loaded ${chalk.white(client.commands.size)} command${client.utils.s(client.commands.size)}!`, {color: 'blue', source: 'boot'}, 1, 1);
if (Object.keys(conflictingAliases).length) {console.log('')};
client.log(`Loaded ${chalk.white(client.commands.size)} command${client.utils.s(client.commands.size)}!`, {color: 'blue', source: 'boot'}, 0, 1);
};

@ -26,7 +26,7 @@ module.exports = async client => {
const eventName = file.split('.')[0];
client.removeAllListeners(eventName);
client.on(eventName, event.bind(null, client));
client.log(`Loaded ${chalk.white(eventName)} event`, {color: 'blueBright', source: 'boot', sourceColor: 'blue'});
client.log(`Loaded event ${chalk.white(eventName)}`, {color: 'blueBright', source: 'boot', sourceColor: 'blue'});
}
catch (e) {
client.error(`Failed to read file ${chalk.white(file)}`);

@ -6,6 +6,7 @@ const gs = require('gradient-string');
module.exports = client => {
client.log(`Logged in as ${gs.instagram(client.user.username)}. ${chalk.greenBright(`[${chalk.grey(client.user.id)}]`)}`);
client.log(`Time: ${chalk.blueBright(moment().format('MMMM d, YYYY - HH:MM:SS'))}`);
client.log(`Running on ${chalk.blueBright(client.guilds.cache.size)} ${chalk.blue("servers")} and interacting with about ${chalk.blueBright(client.users.cache.size)} ${chalk.blue("users")}.`);
client.log(`This ${chalk.blue('heap')} has ${chalk.blueBright((process.memoryUsage().heapTotal / (1024 ** 2)).toFixed(2))}MB allocated; The ${chalk.blue('machine')} has ${chalk.blueBright((os.totalmem() / (1024 ** 3)).toFixed(2))}GB (${chalk.blueBright((os.freemem() / (1024 ** 3)).toFixed(2))}GB free)`);
client.log(`Running on ${chalk.blueBright(client.guilds.cache.size)} ${chalk.blue("servers")} and interacting with about ${chalk.blueBright(client.users.cache.size)} ${chalk.blue("users")}.`);
client.log(`Listening for prefix ${chalk.greenBright(client.basePrefix)} || ${chalk.greenBright(`${client.basePrefix}help`)} to get started!`);
};

@ -1,4 +1,17 @@
{
"bot": {
"name": "Natsuki",
"consoleName": "NATS",
"prefix": "n?",
"devPrefix": "n!"
},
"embed": {
"colors": {
"base": "c375f0",
"success": "23d534",
"fail": "d52334"
}
},
"log": {
"suffix": ">>",
"defaultLevel": 1,
@ -7,10 +20,10 @@
"warn": "yellowBright",
"success": "greenBright",
"notice": "#8521a0",
"primary": "blueBright",
"secondary": "white",
"altprimary": "",
"altsecondary": ""
"primary": "blue",
"secondary": "green",
"altprimary": "blueBright",
"altsecondary": "greenBright"
}
}
}
Loading…
Cancel
Save