light command
This commit is contained in:
parent
9eda4abcf7
commit
6c7bbc2304
7 changed files with 378 additions and 232 deletions
|
@ -1,24 +1,40 @@
|
|||
import {CommandInitializer, Command} from "../parser.js";
|
||||
import parse, {instructions} from "../lights/light_parser.js";
|
||||
import { CommandInitializer, Command } from '../parser.js';
|
||||
import parse, { initialize, instructions } from '../lights/light_parser.js';
|
||||
import req from '../lights/request.js';
|
||||
|
||||
const initializer = new CommandInitializer();
|
||||
|
||||
class LightsParser extends Command {
|
||||
init(ctx, log) {
|
||||
this.log = log;
|
||||
}
|
||||
name = "lights";
|
||||
func(msg, args, ctx) {
|
||||
let instructions = parse(args[0]);
|
||||
init(ctx, log) {
|
||||
this.log = log;
|
||||
initialize(ctx);
|
||||
}
|
||||
name = 'lights';
|
||||
whitelist = true;
|
||||
func(msg, args, ctx) {
|
||||
if (!args.length) {
|
||||
msg.channel.createMessage('no args found.');
|
||||
return;
|
||||
}
|
||||
let instructions = parse(args[0]);
|
||||
|
||||
this.log.debug(instructions);
|
||||
let res = "```\n";
|
||||
instructions.forEach(instruction => {
|
||||
res += JSON.stringify(instruction) + "\n";
|
||||
});
|
||||
res += "```";
|
||||
msg.channel.createMessage(`parsed instructions:\n${res}`);
|
||||
}
|
||||
this.log.debug(instructions);
|
||||
let res = '```\n';
|
||||
instructions.forEach((instruction) => {
|
||||
res += JSON.stringify(instruction) + '\n';
|
||||
});
|
||||
res += '```';
|
||||
msg.channel.createMessage(`parsed instructions:\n${res}`);
|
||||
req(
|
||||
instructions.filter((i) => i.valid),
|
||||
(response) => {
|
||||
msg.channel.createMessage(`${response.statusCode}`);
|
||||
},
|
||||
(error) => {
|
||||
msg.channel.createMessage(`error.`);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
initializer.addCommand(new LightsParser());
|
||||
|
||||
|
|
18
cmd/reg.js
18
cmd/reg.js
|
@ -1,14 +1,18 @@
|
|||
import {CommandInitializer, Command} from "../parser.js";
|
||||
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());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue