diff --git a/src/commands/afk.js b/src/commands/afk.js new file mode 100644 index 0000000..565e793 --- /dev/null +++ b/src/commands/afk.js @@ -0,0 +1,15 @@ +const {addCommand} = require("../lib/command"); + +addCommand("A", "toggles AFK mode", function () { + if (comcord.state.afk == true) { + comcord.state.afk = false; + comcord.client.editStatus("online"); + comcord.client.editAFK(false); + console.log(""); + } else { + comcord.state.afk = true; + comcord.client.editStatus("idle"); + comcord.client.editAFK(true); + console.log(""); + } +}); diff --git a/src/commands/send.js b/src/commands/send.js index b067c17..b53d96c 100644 --- a/src/commands/send.js +++ b/src/commands/send.js @@ -24,6 +24,13 @@ function sendMode() { comcord.state.currentChannel, input ); + + if (comcord.state.afk == true) { + comcord.state.afk = false; + comcord.client.editStatus("online"); + comcord.client.editAFK(false); + console.log(""); + } } catch (err) { console.log(""); } diff --git a/src/index.js b/src/index.js index a5c0de4..284fc9d 100644 --- a/src/index.js +++ b/src/index.js @@ -7,12 +7,14 @@ process.title = "comcord"; global.comcord = { state: { + startTime: Date.now(), currentGuild: null, currentChannel: null, nameLength: 2, inPrompt: false, messageQueue: [], lastChannel: new Map(), + afk: false, }, commands: {}, }; @@ -35,6 +37,7 @@ const {listGuilds} = require("./commands/listGuilds"); require("./commands/switchGuild"); // loads listChannels and listUsers require("./commands/switchChannel"); //loads listUsers require("./commands/history"); // includes extended history +require("./commands/afk"); process.stdin.setRawMode(true); process.stdin.resume(); @@ -50,6 +53,16 @@ client.once("ready", function () { comcord.state.nameLength = client.user.username.length + 2; listGuilds(); + + client.editStatus("online", [ + { + application_id: "1026163285877325874", + name: "comcord", + timestamps: { + start: comcord.state.startTime, + }, + }, + ]); }); client.on("error", function () {});