blob: c95e664c15535cc8e075e95e38e9e676390e72b5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
import { Client } from "./sys/events";
import { buildHandler } from "./sys/handler";
import { commands } from "./commands";
/**
* We instanciate our nova broker client.
*/
const emitter = new Client({
transport: {
additionalEvents: [],
nats: {
servers: ["localhost:4222"],
},
queue: "nova-worker-common",
},
rest: {
api: "http://localhost:8090/api",
},
});
// We register our slash command handler.
emitter.on("interactionCreate", buildHandler(commands));
// Simple message handler
emitter.on("messageCreate", (message) => {
if (message.content === "~ping") {
message.client.channels.createMessage(message.channel_id, {
content: `Bonjour! <@${message.author.id}>`,
});
}
});
// We connect ourselves to the nova nats broker.
emitter.start().catch(console.log);
|