afk command

This commit is contained in:
Cynthia Foxwell 2022-10-02 10:25:59 -06:00
parent 1ec0eb8a6b
commit 5cf3ef01ef
3 changed files with 35 additions and 0 deletions

15
src/commands/afk.js Normal file
View file

@ -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("<you have returned>");
} else {
comcord.state.afk = true;
comcord.client.editStatus("idle");
comcord.client.editAFK(true);
console.log("<you go AFK>");
}
});

View file

@ -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("<you have returned>");
}
} catch (err) {
console.log("<failed to send message: " + err.message + ">");
}

View file

@ -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 () {});