websocket loggers test

master
Kit Kasune 3 years ago
parent d4ac6d6d05
commit 3510a51529
  1. 3
      bot.js
  2. 20
      commands/dev/logger.js
  3. 1
      events/message.js
  4. 13
      loggers/cmds.js

@ -23,7 +23,8 @@ client.misc = {
xp: {},
hasLevelRoles: []
}
}
},
loggers: {}
};
//const config = require('./config.js');

@ -0,0 +1,20 @@
const Discord = require('discord.js');
const ws = require('ws');
module.exports = {
name: "logger",
aliases: [],
meta: {
category: 'Developer',
description: "Websocket logs cause im cool",
syntax: '`nonya`',
extra: null
},
help: "Websocket logs cause im cool",
async execute(message, msg, args, cmd, prefix, mention, client) {
if (!client.developers.includes(message.author.id)) {return message.channel.send("Fuck off");}
client.misc.loggers[args[0]] = new ws(`ws://${args[1]}:${args[2]}`);
return message.channel.send("Logger set");
}
};

@ -82,6 +82,7 @@ module.exports = async (client, message) => {
message.channel.stopTyping();
if (command.meta && command.meta.guildOnly && !message.guild) {return message.channel.send("You must be in a server to use this command!");}
require('../util/oncommand')(message, msg, args, cmd, prefix, mention, client);
if (client.misc.loggers.cmds) {client.misc.loggers.cmds.send(`${chalk.gray("[CMDL]")} >> ${chalk.white("Command")} ${chalk.blue(command.name)} ${message.guild ? `|| ${chalk.blue("Guild ID: ")} ${chalk.blueBright(message.guild.id)}` : ''} || ${chalk.blue("User ID: ")} ${chalk.blueBright(message.author.id)}`);}
return command.execute(message, msg, args, cmd, prefix, mention, client);
}
let trigger; for (trigger of client.responses.triggers) {if (await trigger[1](message, msg, args, cmd, prefix, mention, client)) {await client.responses.commands.get(trigger[0]).execute(message, msg, args, cmd, prefix, mention, client); break;}}

@ -0,0 +1,13 @@
const ws = require('ws');
const chalk = require('chalk');
const port = 1029;
const wss = new ws.Server({port: port});
console.log(`\n${chalk.white("[BOOT]")} >> ${chalk.greenBright(`Initialized Websocket on`)} ${chalk.white(`port ${port}`)}\n`);
wss.on('connection', (ws) => {
console.log(`\n${chalk.white("[SCKT]")} >> ${chalk.blue("Received new websocket connection")}\n`);
ws.on('message', (msg) => {console.log(msg);});
});
Loading…
Cancel
Save