Code Monkey home page Code Monkey logo

discord-afk-js's Introduction

node-current npm npm latest GitHub Repo stars Discord Visitor Issues Commit

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');
const moment = require('moment');

// Create an instance of AfkClient
const afk = new AfkClient();

// Checking if a user is AFK without time
const reason = args.join(' ') || 'No Reason';
afk.addUser('user123', reason);

if (afk.findUser('user123')) {
  console.log('User is marked as AFK'); // console: User is marked as AFK
  console.log('AFK Message:', afk.afkMessage('user123')); // console: AFK Message: No Reason
}
// or
// Adding a user to AFK status with time
const reason = args.join(' ') || 'No Reason';
afk.addUser('user123', [Date.now(), reason]);

if (afk.findUser('user123')) {
  console.log('User is marked as AFK'); // console: User is marked as AFK
  const data = afk.findMessage('user123');

  const [ time, reason ] = data;
  const timeago = moment(time).fromNow();

  console.log('AFK Message:', `${reason} ${timeago}`); // console: AFK Message: 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.

API

The discord-afk-js library provides a set of methods for working with AFK status using the AfkClient class.

Changelog | Migrating to discord-afk-js

+ change afk to AfkClient for import
+ afk.set() -> afk.addUser()
+ afk.delete() -> afk.removeUser()
+ afk.get() -> afk.findUser()
+ afk.findMessage()

License

This project is open-source and is licensed under the Apache-2.0. 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

Discord

discord-afk-js's People

Contributors

brokenedtzjs avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

redsun123

discord-afk-js's Issues

error on v1.4.5

Describe the bug

  • afk.search()
  • afk.set()
  • afk.remove()
  • is not function

for now recommended to use v1.4.3 first

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.