forked from d-513/SquidCord
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
38 lines (38 loc) · 1.26 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
const Discord = require("./Discord");
exports.server = (serv) => {
const settings = serv.plugins.squidcord.settings;
require("./thrower").checkConfig(settings, serv);
Discord.login(settings.token);
Discord.setGuild(settings.guild);
Discord.setChannel(settings.channel);
if (!settings.messageColor) settings.messageColor = "BLUE";
if (!settings.serverMessage)
settings.serverMessage = "§b[Discord] §7{name}§f: §7{message}";
let syntax = settings.serverMessage.replace("&", "§");
Discord.setMessageColor(settings.messageColor);
Discord.setActivity("MineCraft!");
Discord.setChatHandler((message) => {
let msg;
msg = syntax.replace("{name}", message.author.tag);
msg = msg.replace("{message}", message.content);
serv.log(`[discord]: ${message.author.tag}: ${message.content}`);
serv.broadcast(msg);
});
};
exports.player = (player, serv) => {
player.on("chat", (message) => {
Discord.broadcast(message, player);
});
player.on("connected", () =>
Discord.playerJoined(player, {
online: serv._server.playerCount,
max: serv._server.maxPlayers,
})
);
player.on("disconnected", () =>
Discord.playerLeft(player, {
online: serv._server.playerCount,
max: serv._server.maxPlayers,
})
);
};