finish migration of lights script to backend

This commit is contained in:
jane 2021-06-04 23:51:59 -04:00
parent be73eaa4cd
commit 8b6116e0cc
2 changed files with 38 additions and 17 deletions

View File

@ -3,29 +3,50 @@ import { CommandInitializer, Command } from '../parser.js';
const initializer = new CommandInitializer();
class PingCommand extends Command {
name = 'ping';
func(msg, args, ctx) {
msg.channel.createMessage('p').then((m) => {
m.edit(
`rtt: ${Math.floor(m.timestamp - msg.timestamp)}, gateway: ${
ctx.bot.shards.get(ctx.bot.guildShardMap[ctx.bot.channelGuildMap[msg.channel.id]] || 0).latency
}`
);
});
}
name = 'ping';
func(msg, args, ctx) {
msg.channel.createMessage('p').then((m) => {
m.edit(
`rtt: ${Math.floor(m.timestamp - msg.timestamp)}, gateway: ${ctx.bot.shards.get(ctx.bot.guildShardMap[ctx.bot.channelGuildMap[msg.channel.id]] || 0).latency
}`
);
});
}
}
initializer.addCommand(new PingCommand());
class RestartCommand extends Command {
name = 'restart';
func(msg, args, ctx) {
msg.channel.createMessage('restarting.').then(() => {
process.exit();
});
}
name = 'restart';
func(msg, args, ctx) {
msg.channel.createMessage('restarting.').then(() => {
process.exit();
});
}
}
initializer.addCommand(new RestartCommand());
class EvalCommand extends Command {
name = 'eval';
whitelist = true;
func(msg, args, ctx) {
log.debug('evaluating ' + args[0]);
let result;
try {
result = eval(args[0]);
} catch (e) {
result = e.stack;
}
log.debug('result is: \n' + result);
if (String.valueOf(result).length <= 1999) {
msg.channel.createMessage('```\n' + result + '```\n');
} else {
msg.channel.createMessage('result too long, see logs');
}
}
}
initializer.addCommand(new EvalCommand());
export default initializer;

View File

@ -39,7 +39,7 @@ export default function req(data, callback, errorCallback) {
client.write(string_data);
})
client.on('data', (dat) => {
callback(dat);
callback(String(dat));
client.destroy();
})