npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

discord-afk-js

v1.5.3

Published

discord-afk-js package is a convenient tool for creating AFK commands without the need for a database

Downloads

53

Readme

discord-afk-js

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.

Requirements

Installation

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

Usage

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.

Changelog | Migrating to discord-afk-js

+ change afk to AfkClient for import
+ afk.addUser() -> afk.setUser()
+ afk.deleteUser() -> afk.removeUser()
+ afk.getReason()

License

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.

Discord Servers