Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const tm = require("tmi.js");
- const options = {
- options: {
- debug: true,
- },
- connection: {
- cluster: "aws",
- reconnect: true,
- },
- identity: {
- username: "some_kind_of_cheese",
- password: "",
- },
- channels: ["MeACheese"],
- };
- const client = new tmi.client(options);
- client.connect();
- const os = require('os');//uptime command - system uptime
- const prefixSmart = "?";
- const smartcmd = [
- {
- name: prefixSmart + "uptime",
- aliases: prefixSmart + "up",
- invocation: async (channel, user, message, args) => {
- try{ //check the code for errors and send them to catch
- function format(seconds){
- function pad(s){
- return (s < 10 ? '0' : '') + s;
- }
- var hours = Math.floor(seconds / (60*60));
- var minutes = Math.floor(seconds % (60*60) / 60);
- var seconds = Math.floor(seconds % 60);
- return hours + 'h ' + minutes + 'm ' + seconds + "s";
- }
- var uptime = process.uptime();
- const os = require('os');
- const up = os.uptime() / 3600; //system uptime in hours
- const up2 = os.uptime() / 86400; //system uptime in days
- var linecount = require('linecount')
- const lines = await new Promise((resolve, reject) => { //line count
- linecount('./haxk.js', (err, count) => {
- if (err) {
- reject(err);
- }
- else{
- resolve(count);
- }
- });
- });
- //return message to client.say
- return user["display-name"] +
- ", my dank code is running for " + format(uptime) +
- " and has " + lines + " lines FeelsDankMan ," +
- " also my system runs for: " + up.toFixed(1) +
- "h (" + up2.toFixed(2) + " days)";
- } catch(err) { //catch errors and optionally send error message to chat
- return user['display-name'] +
- ", " +
- err +
- " FeelsDankMan !!!";
- }
- }
- },
- ];
- try {
- smartcmd.forEach(async smart => {
- if
- (
- (message.startsWith(smart.name) && message.split(" ")[0] == smart.name) ||
- //if message starts with command name, return command invocation (contents)
- (smart.aliases && message.startsWith(smart.aliases))
- ) {
- let result = await smart.invocation(channel, user);
- if (repeatedMessages[channel] === result) { //if previous message was the same, send next message with unicode bypass
- result += " \u{E0000}";
- }
- repeatedMessages[channel] = result;
- client.say(channel, result);
- }
- });
- });
- } catch(err) { //send errors to chat
- return user['display-name'] +
- ", " +
- err +
- " FeelsDankMan !!!";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement