-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
51 lines (40 loc) · 2.09 KB
/
Copy pathindex.js
File metadata and controls
51 lines (40 loc) · 2.09 KB
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
const { Client } = require('discord.js');
const { prefix, token, gameRoom} = require('./config');
const client = new Client();
const C4 = require('./Connect4');
client.once('ready', () => {
console.log(`Logged in as ${client.user.tag}`);
});
// Create game
var game;
var rooms = [gameRoom,"622801138692915212"];
client.on('message', async message => {
if(message.author.bot || message.channel.type == "dm") return
// if(!rooms.includes(message.channel.id)) return
let msg = message.content.toLowerCase();
if(msg == `${prefix}connect4` || msg == `${prefix}c4`) {
game = new C4(message.channel.id);
}
});
client.on('message', message => {
if(message.channel.id != "617407223395647520") return
let attach = (message.attachments).array();
// attach.forEach(attachments => console.log(attachments.url));
game.currentGame(attach[0].url);
})
/* Handles reactions to the game
Takes the vertical; axis value, channel id, user's avatarUrl, and message object */
client.on('messageReactionAdd', async (reaction, user) => {
if(user.bot || game.over) return
if(reaction.emoji.id === "621304998428672010") await game.fallcoin(1, user.id, user.displayAvatarURL, reaction.message);
if(reaction.emoji.id === "621304999938359306") await game.fallcoin(2, user.id, user.displayAvatarURL, reaction.message);
if(reaction.emoji.id === "621304999883833347") await game.fallcoin(3, user.id, user.displayAvatarURL, reaction.message);
if(reaction.emoji.id === "621304999057817601") await game.fallcoin(4, user.id, user.displayAvatarURL, reaction.message);
if(reaction.emoji.id === "621304999171063809") await game.fallcoin(5, user.id, user.displayAvatarURL, reaction.message);
if(reaction.emoji.id === "621304999451951105") await game.fallcoin(6, user.id, user.displayAvatarURL, reaction.message);
if(reaction.emoji.id === "621304998919274506") await game.fallcoin(7, user.id, user.displayAvatarURL, reaction.message);
reaction.remove(user);
});
// Logs in the client
client.login(token);
module.exports = client;