diff options
| author | 8cy <[email protected]> | 2020-04-19 06:40:16 -0700 |
|---|---|---|
| committer | 8cy <[email protected]> | 2020-04-19 06:40:16 -0700 |
| commit | ed6e347bbcce356bde0cfeba498dab3d39a6c946 (patch) | |
| tree | 419225e81e9a3967ccf6f385a6e1c9c204d0b19c /src/commands/2b2t | |
| parent | link favi, v7.2.4 (diff) | |
| download | dep-core-test-2b2t.tar.xz dep-core-test-2b2t.zip | |
fix on a rainy day, added most of the supporttest-2b2t
issue, TypeError: Cannot read property 'end' of undefined when trying to stop
Diffstat (limited to 'src/commands/2b2t')
| -rw-r--r-- | src/commands/2b2t/2b2t.ts | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/src/commands/2b2t/2b2t.ts b/src/commands/2b2t/2b2t.ts new file mode 100644 index 0000000..453ec43 --- /dev/null +++ b/src/commands/2b2t/2b2t.ts @@ -0,0 +1,80 @@ +import { Command, CommandoMessage } from 'discord.js-commando'; +import { MessageEmbed } from 'discord.js'; +import { stop } from '../../2b2w/main.js' +//const queuing = require('../../2b2w/main.js') +import http from 'http'; +process.chdir('./2b2w/') + +global.queueData = ""; +function update() { + http.get('http://localhost/update', (resp) => { + let data = ''; + resp.on('data', (chunk) => { + data += chunk; + }); + resp.on('end', () => { + queueData = JSON.parse(data); + console.log(`Recieved data: ${queueData.place}`); + if (queueData.place === 'None' || queueData.place === 'undefined') { + queueData = 'Please allow a moment or the data to update'; + } + }); + }).on('error', (err) => { + queueData = 'error' + }); + setTimeout(update, 5 * 1000); + //setTimeout(timedDiscordUpdate, 30 * 1000) +} + +module.exports = class TwoB2T2B2t extends Command { + constructor(client) { + super(client, { + name: '2b2t', + aliases: ['2b', '2b2w', '2l2w'], + group: '2b2t', + memberName: '2b2t', + description: '', + args: [ + { + key: 'actionOp', + prompt: 'Would you like to update, start or stop?', + type: 'string' + } + ] + }); + } + run(msg: CommandoMessage, { actionOp }) { + if (actionOp == 'update') { + let emb = new MessageEmbed() + .setColor(0xFFCC4D) + .setTitle('2bored2wait Discord Bridge') + .setDescription('Start and stop the queue from Discord.') + .addFields( + { name: 'Position', value: `You are in position **${queueData.place}**.` }, + { name: 'ETA', value: `Estimated time until login: **${queueData.ETA}**` } + ) + .setTimestamp(new Date()) + + msg.say(emb); + } else if (actionOp == 'start') { + let emb = new MessageEmbed() + .setColor(0xFFCC4D) + .setTitle('2bored2wait Discord Bridge') + .setDescription('Start and stop the queue from Discord.') + .addField('Queue', 'Queue is starting up. Please allow 15 seconds to update.') + .setTimestamp(new Date()) + setTimeout(update, 5 * 1000) + msg.channel.send(emb); + } else if (actionOp == 'stop') { + let emb = new MessageEmbed() + .setColor(0xFFCC4D) + .addField('Queue', 'Queue is **stopped**.') + .setTimestamp(new Date()) + + stop() + msg.say(emb); + } else { + msg.reply('That was not an option.') + } + } +};
\ No newline at end of file |