1st command

v2
Kit Kasune 2 years ago
parent 8e8df4dadc
commit e3eb892ee4
  1. 7
      src/handle/runtime/commands/bot/ping.js
  2. 7
      src/handle/runtime/events/messageCreate.js
  3. 2
      src/handle/runtime/events/ready.js
  4. 3
      src/handle/startup/collect/commands.js
  5. 2
      src/handle/startup/collect/events.js
  6. 3
      src/handle/startup/run/hello.js
  7. 21
      src/json/config.json

@ -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,5 +1,5 @@
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);

@ -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