Skip to content

Commit ffc803e

Browse files
committed
Added --isbound command
1 parent dab5360 commit ffc803e

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/bot.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ const MessageReceiver = require("./network/messageReceiver.js");
55
const MessageTransmitter = require("./network/messageTransmitter.js");
66

77
class Bot {
8-
#commands = ["--bindchannel", "--unbindchannel"].sort();
8+
#commands = ["--bindchannel", "--unbindchannel", "--isbound"].sort();
99
#commandHelp = {
1010
"--bindchannel": "Binds this text channel to the MC server chat",
11-
"--unbindchannel": "Unbinds this text channel to the MC server chat"
11+
"--unbindchannel": "Unbinds this text channel to the MC server chat",
12+
"--isbound": "Checks if this text channel is bound to the MC server chat"
1213
};
1314
#msgRecv;
1415
#txAddress;
@@ -30,7 +31,7 @@ class Bot {
3031
client.on("ready", () => {
3132
console.log("Connected as " + client.user.tag);
3233
client.user.setActivity("type --help for help");
33-
34+
3435
// Reads from this.#BOUND_CHANNELS_FILE and if it doesn't exist, it creates it, if it does exist, it binds all the channels
3536
fs.stat(this.#BOUND_CHANNELS_FILE, (err, _) => (err != null) ? fs.writeFile(this.#BOUND_CHANNELS_FILE, "[]", err => err && console.log(err)) : fs.readFile(this.#BOUND_CHANNELS_FILE, (_, data) => JSON.parse(data.toString()).forEach(async channelID => this.#msgRecv.bindChannel(await client.channels.fetch(channelID)))));
3637
});
@@ -54,6 +55,9 @@ class Bot {
5455
case "--unbindchannel":
5556
this.#msgRecv.unbindChannel(msg.channel);
5657
break;
58+
case "--isbound":
59+
msg.channel.send(this.#msgRecv.isBound(msg.channel));
60+
break;
5761
case "--help":
5862
var response = "";
5963
this.#commands.forEach(commandStr => response += `\`${commandStr}\`: ${this.#commandHelp[commandStr]}\n`);

0 commit comments

Comments
 (0)