-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext.js
65 lines (64 loc) · 1.96 KB
/
next.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
57
58
59
60
61
62
63
64
65
exports.getScriptManifest = function () {
return {
name: 'Queue - Next',
description: '!next # GAME',
author: 'S1D3WYZ',
version: '0.0.1',
};
};
exports.getDefaultParameters = function () {
return new Promise((resolve) => {
resolve({
queueLocation: {
type: 'filepath',
description: 'Whereis queue.json?',
secondaryDescription: `(Suggested:) %APPDATA%\\Firebot\\v5\\profiles\\Main Profile\\scripts\\queue.json`,
},
});
});
};
exports.run = function (runRequest) {
return new Promise((resolve) => {
const response = { success: false, errorMessage: '', effects: [] },
logger = runRequest.modules.logger,
fs = runRequest.modules.fs,
queueFile = runRequest.parameters.queueLocation,
queue = JSON.parse(fs.readFileSync(queueFile)),
context = runRequest.command.args[0] ? runRequest.command.args[0] : 0;
try {
switch (context) {
case 0:
logger.error(`${context}`);
response.effects.push({
type: EffectType.CHAT,
message: `Please include # of players for the next game`,
});
break;
default:
let pos = 0;
queue.playing = queue.waiting.slice(pos, context);
queue.waiting.splice(pos, context);
logger.info(queue.playing);
logger.info(queue.waiting);
response.effects.push(
{
type: EffectType.TEXT_TO_FILE,
filepath: queueFile,
writeMode: 'replace',
text: JSON.stringify(queue),
},
{
type: EffectType.CHAT,
message: `${queue.playing.length} new players, ${queue.waiting.length} waiting. Queue is ${queue.status}`,
}
);
break;
}
} catch (error) {
response.errorMessage = error;
}
// logger.error(runRequest.response.errorMessage);
response.success = true;
resolve(response);
});
};