-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.js
53 lines (50 loc) · 1.48 KB
/
main.js
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
const Discord = require('discord.js');
const client = new Discord.Client();
const {
Board,
Thermometer,
Led,
Piezo
} = require("johnny-five");
const AsciiTable = require("ascii-table");
const board = new Board();
board.on("ready", () => {
const led = new Led(13);
const piezo = new Piezo(3);
const thermometer = new Thermometer({
controller: "LM35",
pin: "A0"
});
client.on('message', msg => {
const {
celsius,
fahrenheit,
kelvin
} = thermometer;
if (msg.content === "led-open") return led.on()
if (msg.content === "led-close") return led.off()
if (msg.content === "weather-degrees") {
var table = new AsciiTable()
table
.addRow('°C:', celsius)
.addRow('°F:', fahrenheit)
.addRow('K:', kelvin)
let embed = new Discord.MessageEmbed()
.setDescription(`\`\`\`${table.toString()}\`\`\``)
msg.channel.send(embed)
} else if (msg.content === "music") {
led.blink();
board.repl.inject({
piezo: piezo
});
piezo.play({
song: "E D F D A - A A A A G G G G - - C D F D G - G G G G F F F F - -",
beats: 1 / 4,
tempo: 100
});
} else if (msg.content == "music-close") {
led.stop()
}
});
})
client.login('Token'); //Token Here