Compare commits
3 Commits
3ed56b7927
...
00c3fa8219
| Author | SHA1 | Date | |
|---|---|---|---|
| 00c3fa8219 | |||
| 610ca41195 | |||
| 827dafbb99 |
@@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
# 1800queue
|
# 1800queue
|
||||||
|
|
||||||
|
## Invite info
|
||||||
|
|
||||||
|
needs: create commands/send messages
|
||||||
|
|
||||||
## Prerequirements
|
## Prerequirements
|
||||||
|
|
||||||
Download and install [Node.js](https://nodejs.org/en/)
|
Download and install [Node.js](https://nodejs.org/en/)
|
||||||
|
|||||||
8
dist/discord.js
vendored
8
dist/discord.js
vendored
@@ -6,8 +6,8 @@ const v9_1 = require("discord-api-types/v9");
|
|||||||
// list of commands to register with discord
|
// list of commands to register with discord
|
||||||
const commands = [
|
const commands = [
|
||||||
{
|
{
|
||||||
name: 'queue',
|
name: 'open',
|
||||||
description: 'initialize a queue for this channel',
|
description: 'open a queue for this channel',
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
type: 4,
|
type: 4,
|
||||||
@@ -22,6 +22,10 @@ const commands = [
|
|||||||
name: 'close',
|
name: 'close',
|
||||||
description: 'close the queue for this channel'
|
description: 'close the queue for this channel'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'queue',
|
||||||
|
description: 'view queue info'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'join',
|
name: 'join',
|
||||||
description: 'join the active queue'
|
description: 'join the active queue'
|
||||||
|
|||||||
4
dist/queue.js
vendored
4
dist/queue.js
vendored
@@ -33,7 +33,7 @@ if (!fs.existsSync('./queues.json'))
|
|||||||
const _QUEUE = fs.readFileSync('./queues.json').toString(), QUEUE = new Map();
|
const _QUEUE = fs.readFileSync('./queues.json').toString(), QUEUE = new Map();
|
||||||
try {
|
try {
|
||||||
let queueJson = JSON.parse(_QUEUE);
|
let queueJson = JSON.parse(_QUEUE);
|
||||||
for (let channelId of queueJson) {
|
for (let channelId in queueJson) {
|
||||||
let { teamsize } = queueJson[channelId];
|
let { teamsize } = queueJson[channelId];
|
||||||
if (teamsize)
|
if (teamsize)
|
||||||
QUEUE.set(channelId, { teamsize, players: [] });
|
QUEUE.set(channelId, { teamsize, players: [] });
|
||||||
@@ -50,7 +50,7 @@ async function checkQueue(channel) {
|
|||||||
let info = QUEUE.get(channel.id);
|
let info = QUEUE.get(channel.id);
|
||||||
if (!info)
|
if (!info)
|
||||||
return;
|
return;
|
||||||
if (info.players.length > info.teamsize) {
|
if (info.players.length >= info.teamsize) {
|
||||||
let team = info.players.splice(0, info.teamsize).map(m => m.toString());
|
let team = info.players.splice(0, info.teamsize).map(m => m.toString());
|
||||||
let embed = new discord_js_1.MessageEmbed()
|
let embed = new discord_js_1.MessageEmbed()
|
||||||
.setTitle('Team')
|
.setTitle('Team')
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import { Routes } from 'discord-api-types/v9';
|
|||||||
// list of commands to register with discord
|
// list of commands to register with discord
|
||||||
const commands = [
|
const commands = [
|
||||||
{
|
{
|
||||||
name: 'queue',
|
name: 'open',
|
||||||
description: 'initialize a queue for this channel',
|
description: 'open a queue for this channel',
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
type: 4, //INTEGER
|
type: 4, //INTEGER
|
||||||
@@ -20,6 +20,11 @@ const commands = [
|
|||||||
name: 'close',
|
name: 'close',
|
||||||
description: 'close the queue for this channel'
|
description: 'close the queue for this channel'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: 'queue',
|
||||||
|
description: 'view queue info'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'join',
|
name: 'join',
|
||||||
description: 'join the active queue'
|
description: 'join the active queue'
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ try {
|
|||||||
|
|
||||||
let queueJson = JSON.parse(_QUEUE);
|
let queueJson = JSON.parse(_QUEUE);
|
||||||
|
|
||||||
for (let channelId of queueJson) {
|
for (let channelId in queueJson) {
|
||||||
let {teamsize} = queueJson[channelId] as queueInfoBase;
|
let {teamsize} = queueJson[channelId] as queueInfoBase;
|
||||||
if (teamsize)
|
if (teamsize)
|
||||||
QUEUE.set(channelId, { teamsize, players: [] })
|
QUEUE.set(channelId, { teamsize, players: [] })
|
||||||
@@ -44,7 +44,7 @@ async function checkQueue(channel: TextChannel) {
|
|||||||
if (!info)
|
if (!info)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (info.players.length > info.teamsize) {
|
if (info.players.length >= info.teamsize) {
|
||||||
|
|
||||||
let team = info.players.splice(0, info.teamsize).map(m => m.toString());
|
let team = info.players.splice(0, info.teamsize).map(m => m.toString());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user