forked from Thomas-Smyth/Original-SquadJS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
63 lines (50 loc) · 1.72 KB
/
index.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
// Import Dependencies
const Discord = require('discord.js');
// Init Discord Bot
const client = new Discord.Client();
// Import App and SquadServer Classes
const src = process.env.NODE_ENV === 'production' ? './build' : './src';
const ServerManager = require(src).Application;
const SquadServer = require(src).SquadServer;
// Import Plugins
const SeedingMessagePlugin = require(src).SeedingMessage;
const DiscordStatusMessagePlugin = require(src).DiscordStatusMessage;
const LayerSelectorPlugin = require(src).LayerSelector;
const MapVotePlugin = require(src).MapVote;
// Init App
const app = new ServerManager();
// Add Servers to App
const ServerName = new SquadServer(
'ServerName', // needs to be unique across all servers
'IP Addr', // host address of server
7787, // query port
27165, // rcon port
'Rcon Password' // rcon password
);
app.addServer(ServerName);
// Init Plugins
const SeedingMessage = new SeedingMessagePlugin();
const LayerSelector = new LayerSelectorPlugin();
LayerSelector.layerFilter();
const MapVote = new MapVotePlugin(client, LayerSelector, {
'Map Vote Channel ID': ServerName
});
const DiscordStatusMessage = new DiscordStatusMessagePlugin(client, {
ServerName: [{ channelID: 'Channel ID', messageID: 'Message ID' }]
});
// Add Plugins
app.addPlugin(SeedingMessage.plugin());
app.addPlugin(LayerSelector.plugin());
app.addPlugin(MapVote.plugin());
app.addPlugin(DiscordStatusMessage.plugin());
// Start App
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
app.watch();
MapVote.newVoteMessage(ServerName.id);
});
client.on('error', (err) => {
console.log(`An error occurs with the Discord Bot: ${err.message}`);
});
// Login Bot
client.login('Discord Bot Login Token');