Remove DEF CON 28 only stuff and rewriting the locking code to be one game per channel.
This commit is contained in:
parent
860cbc8f60
commit
4cb39bea73
19
src/index.js
19
src/index.js
@ -1,6 +1,6 @@
|
|||||||
// Load up the libraries
|
// Load up the libraries
|
||||||
const Discord = require('discord.js');
|
const Discord = require('discord.js');
|
||||||
|
const _ = require('lodash');
|
||||||
// Importing config
|
// Importing config
|
||||||
const config = require('./config.json')
|
const config = require('./config.json')
|
||||||
|
|
||||||
@ -25,15 +25,12 @@ client.on('ready', () => {
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// Makes a lock variable
|
// List of channels with currently ongoing games
|
||||||
let lock = false;
|
let lock = [];
|
||||||
|
|
||||||
client.on('message', async message => {
|
client.on('message', async message => {
|
||||||
// Message processing
|
// Message processing
|
||||||
|
|
||||||
// Only can be used in #linecon
|
|
||||||
let okchannel = client.channels.cache.get("710574818222931968")
|
|
||||||
if (!(message.channel === okchannel)) return;
|
|
||||||
|
|
||||||
// Discards messages from bots
|
// Discards messages from bots
|
||||||
if (message.author.bot) return;
|
if (message.author.bot) return;
|
||||||
@ -48,12 +45,12 @@ client.on('message', async message => {
|
|||||||
// The main function of this bot. To play games!
|
// The main function of this bot. To play games!
|
||||||
if (command === "play") {
|
if (command === "play") {
|
||||||
// Makes it so one game at a time
|
// Makes it so one game at a time
|
||||||
if (lock === true) return
|
if (lock.includes(message.channel.id)) return
|
||||||
|
|
||||||
// Makes a message saying Who wants to play?
|
// Makes a message saying Who wants to play?
|
||||||
message.channel.send("who wants to play a game?")
|
message.channel.send("who wants to play a game?")
|
||||||
.then(message => {
|
.then(message => {
|
||||||
lock = true
|
lock.push(message.channel.id)
|
||||||
// Reacts with a beach ball
|
// Reacts with a beach ball
|
||||||
message.react("739941658639990866")
|
message.react("739941658639990866")
|
||||||
.then(() => {
|
.then(() => {
|
||||||
@ -123,8 +120,8 @@ client.on('message', async message => {
|
|||||||
// When the 10s ends
|
// When the 10s ends
|
||||||
collector.on("end", () => {
|
collector.on("end", () => {
|
||||||
if (collector.users.size === 0) {
|
if (collector.users.size === 0) {
|
||||||
lock = false
|
_.pull(lock, message.channel.id)
|
||||||
return message.channel.send((players[num].toString()).slice(19)+ ' got hit in the head!');
|
return message.channel.send((players[num].toString()).slice(19) + ' got hit in the head!');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -137,7 +134,7 @@ client.on('message', async message => {
|
|||||||
})
|
})
|
||||||
collector.on("end", () => {
|
collector.on("end", () => {
|
||||||
if (collector.users.size === 0) {
|
if (collector.users.size === 0) {
|
||||||
lock = false;
|
_.pull(lock, message.channel.id)
|
||||||
return message.channel.send('Somehow ' + (players[0].toString()).slice(19) + ' got hit.');
|
return message.channel.send('Somehow ' + (players[0].toString()).slice(19) + ' got hit.');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user