
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
discord-afk-js
Advanced tools
discord-afk-js package is a convenient tool for creating AFK commands without the need for a database
discord-afk-js is a JavaScript library created to facilitate the management of AFK (Away From Keyboard) status within Discord bots. This library is designed to simplify the process of tracking and handling AFK users in a Discord server without the need for an external database.
To start using discord-afk-js, you can install it through npm, the Node.js package manager. Open your terminal and run the following command:
npm install discord-afk-js
discord-afk-js offers a straightforward way to manage AFK users in your Discord bot. Below is an example of how to utilize the AfkClient class:
const { AfkClient } = require('discord-afk-js');
// Create an instance of AfkClient
const afk = new AfkClient();
// ================================================================
// Checking if a user is AFK without time
afk.setUser({ id: 'id1', reason: 'Afk Playing Game' });
const [reason, time] = await afk.getReason('id1');
if (afk.findUser('id1')) {
console.log('User is marked as AFK'); // console: User is marked as AFK
console.log('AFK Message:', `${reason} ${time}`); // console: AFK Message: Afk Playing Game a few seconds ago
}
// ================================================================
// Adding a user to AFK status without reason
afk.setUser({ id: 'id2' });
if (afk.findUser('id2')) {
console.log('User is marked as AFK'); // console: User is marked as AFK
const [reason, time] = await afk.getReason('id2');
console.log('AFK Message:', `${reason} ${time}`); // console: AFK Message: No Reason a few seconds ago
}
// ================================================================
// Get reason without array
afk.setUser({ id: 'id3' });
const reason = await afk.getReason('id3');
console.log(reason); // console: No Reason a few seconds ago
//================================================================
// Removing a user from AFK status
afk.removeUser('user123');
In the code snippet above, we start by importing the AfkClient class. After creating an instance of this class, we demonstrate how to add a user to the AFK list, check their AFK status, and remove them from AFK status.
+ change afk to AfkClient for import
+ afk.addUser() -> afk.setUser()
+ afk.deleteUser() -> afk.removeUser()
+ afk.getReason()
This project is open-source and is licensed under the MIT License. You can find more details about the license in the LICENSE.md file included in the project.
With this comprehensive readme, you have a clear and detailed guide on how to use the discord-afk-js library to manage AFK status in your Discord bot.
FAQs
discord-afk-js package is a convenient tool for creating AFK commands without the need for a database
The npm package discord-afk-js receives a total of 0 weekly downloads. As such, discord-afk-js popularity was classified as not popular.
We found that discord-afk-js demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.