This repository has been archived by the owner on Jul 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
56 lines (48 loc) · 1.68 KB
/
index.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
54
55
56
const Discord = require('discord.js');
const SnakeGame = require('./snake-game');
const HangmanGame = require('./hangman-game');
const MinesweeperGame = require('./minesweeper');
const Connect4 = require('./connect4');
const express = require('express');
const client = new Discord.Client(["MANAGE_MESSAGES"]);
const snakeGame = new SnakeGame(client);
const hangman = new HangmanGame(client);
const minesweeper = new MinesweeperGame(client);
const connect4 = new Connect4(client);
client.on('ready', () => {
console.log('Logged in as ${client.user.tag}!');
});
client.on('message', msg => {
if (msg.content === '!nsnake') {
snakeGame.newGame(msg);
}
else if (msg.content === '!nhangman') {
hangman.newGame(msg);
}
else if (msg.content === '!nconnect4') {
connect4.newGame(msg);
}
else if (msg.content.toLowerCase() === '!nminesweeper') {
minesweeper.newGame(msg);
}
else if (msg.content.toLowerCase() === '!nhelp') {
const embed = new Discord.MessageEmbed()
.setColor('#fc2eff')
.setTitle('Help - Commands')
.setDescription("!nsnake - Play Snake\n!nhangman - Play Hangman\n!nconnect4 - Play Connect4\n!nminesweeper - Play Minesweeper")
.setTimestamp();
msg.channel.send(embed);
}
});
client.login(process.env.BOT_TOKEN);
const app = express()
const port = 3030
app.get('/', (req, res) => {
res.send('<script>window.close();</script>');
if (req.query.col && req.query.row) {
minesweeper.makeMove(parseInt(req.query.col), parseInt(req.query.row));
}
})
app.listen(port, () => {
console.log('Example app listening at http://localhost:${port}');
})