afk command
This commit is contained in:
		
							parent
							
								
									1ec0eb8a6b
								
							
						
					
					
						commit
						5cf3ef01ef
					
				
					 3 changed files with 35 additions and 0 deletions
				
			
		
							
								
								
									
										15
									
								
								src/commands/afk.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								src/commands/afk.js
									
										
									
									
									
										Normal 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>");
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
| 
						 | 
					@ -24,6 +24,13 @@ function sendMode() {
 | 
				
			||||||
            comcord.state.currentChannel,
 | 
					            comcord.state.currentChannel,
 | 
				
			||||||
            input
 | 
					            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) {
 | 
					        } catch (err) {
 | 
				
			||||||
          console.log("<failed to send message: " + err.message + ">");
 | 
					          console.log("<failed to send message: " + err.message + ">");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										13
									
								
								src/index.js
									
										
									
									
									
								
							
							
						
						
									
										13
									
								
								src/index.js
									
										
									
									
									
								
							| 
						 | 
					@ -7,12 +7,14 @@ process.title = "comcord";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
global.comcord = {
 | 
					global.comcord = {
 | 
				
			||||||
  state: {
 | 
					  state: {
 | 
				
			||||||
 | 
					    startTime: Date.now(),
 | 
				
			||||||
    currentGuild: null,
 | 
					    currentGuild: null,
 | 
				
			||||||
    currentChannel: null,
 | 
					    currentChannel: null,
 | 
				
			||||||
    nameLength: 2,
 | 
					    nameLength: 2,
 | 
				
			||||||
    inPrompt: false,
 | 
					    inPrompt: false,
 | 
				
			||||||
    messageQueue: [],
 | 
					    messageQueue: [],
 | 
				
			||||||
    lastChannel: new Map(),
 | 
					    lastChannel: new Map(),
 | 
				
			||||||
 | 
					    afk: false,
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  commands: {},
 | 
					  commands: {},
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					@ -35,6 +37,7 @@ const {listGuilds} = require("./commands/listGuilds");
 | 
				
			||||||
require("./commands/switchGuild"); // loads listChannels and listUsers
 | 
					require("./commands/switchGuild"); // loads listChannels and listUsers
 | 
				
			||||||
require("./commands/switchChannel"); //loads listUsers
 | 
					require("./commands/switchChannel"); //loads listUsers
 | 
				
			||||||
require("./commands/history"); // includes extended history
 | 
					require("./commands/history"); // includes extended history
 | 
				
			||||||
 | 
					require("./commands/afk");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
process.stdin.setRawMode(true);
 | 
					process.stdin.setRawMode(true);
 | 
				
			||||||
process.stdin.resume();
 | 
					process.stdin.resume();
 | 
				
			||||||
| 
						 | 
					@ -50,6 +53,16 @@ client.once("ready", function () {
 | 
				
			||||||
  comcord.state.nameLength = client.user.username.length + 2;
 | 
					  comcord.state.nameLength = client.user.username.length + 2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  listGuilds();
 | 
					  listGuilds();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  client.editStatus("online", [
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      application_id: "1026163285877325874",
 | 
				
			||||||
 | 
					      name: "comcord",
 | 
				
			||||||
 | 
					      timestamps: {
 | 
				
			||||||
 | 
					        start: comcord.state.startTime,
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					  ]);
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
client.on("error", function () {});
 | 
					client.on("error", function () {});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue