Skip to content

Commit 4389f4f

Browse files
committed
Added standard for rxPort and made foreign address and port customizable
1 parent 15c1054 commit 4389f4f

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

src/bot.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,20 @@ class Bot {
1010
"--unbindchannel": "Unbinds this text channel to the MC server chat"
1111
};
1212
#msgRecv;
13+
#txAddress;
14+
#txPort;
1315

1416
/**
1517
* Creates a new instance of this bot
1618
* @param {String} discordToken The bot token you got from discord
17-
* @param {number} port The port the bot should listen on
19+
* @param {number} rxPort The port the bot should listen on
20+
* @param {String} txAddress The host name of the plugin
21+
* @param {number} txPort The port the plugin is listening on
1822
*/
19-
constructor(discordToken, port) {
20-
this.#msgRecv = new MessageReceiver(port);
23+
constructor(discordToken, rxPort = 500, txAddress = "127.0.0.1", txPort = 501) {
24+
this.#txAddress = txAddress;
25+
this.#txPort = txPort;
26+
this.#msgRecv = new MessageReceiver(rxPort);
2127

2228
client.on("ready", () => {
2329
console.log("Connected as " + client.user.tag);
@@ -53,8 +59,8 @@ class Bot {
5359
break;
5460

5561
MessageTransmitter.transmit(
56-
"127.0.0.1",
57-
501,
62+
this.#txAddress,
63+
this.#txPort,
5864
{
5965
sender: msg.member.displayName,
6066
message: msg.content

0 commit comments

Comments
 (0)