1.5.0 • Published 7 months ago

discord-afk-js v1.5.0

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

discord-afk-js

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

Install

  • NPM
npm i discord-afk-js

Requirements

Quick example

const { afk } = require('discord-afk-js');
const reason = args.join(' ') || 'No Reason';
afk.set(message.author.id, [Date.now(), reason]);
message.reply(`${message.member} now afk!\nReason: ${reason}`);

More Example

  • bot.js
const { Events } = require('discord.js');
const { afk } = require('discord-afk-js');
const moment = require('moment');

client.on(Events.MessageCreate, async(message) => {
  const member = message.mentions.members.first();
  const data = afk.get(member.id);
  if(data) {
    const [timestamp, reason] = data;
    const timeago = moment(timestamp).fromNow();
    message.reply(`${member} afk right now, Reason: ${reason} ${timeago}`)
  };
  const getdata = afk.get(message.author.id);
  if(getdata) {
    afk.delete(message.author.id);
    message.reply(`${message.member} removed you from afk`);
  };
});
  • afk.js
//example using events
const { afk } = require('discord-afk-js');

module.exports = {
  name: 'afk',

  run: async(client, message, args) => {
    const reason = args.join(' ') || 'No Reason';
    afk.set(message.author.id, [Date.now(), reason]);
    message.reply(`${message.member} now afk!\nReason: ${reason}`);
  },
};

//example without using events
const { Events } = require('discord.js');
const { afk } = require('discord-afk-js');

client.on(Events.MessageCreate, async(message) => {
  const reason = args.join(' ') || 'No Reason';
  afk.set(message.author.id, [Date.now(), reason]);
  message.reply(`${message.member} now afk!\nReason: ${reason}`);
});

Changelog | Migrating to discord-afk-js

- removing unused depencies

+ fix known security major
+ added update notifier
+ added error handling

Join our Discord server

License & Copyright

This Project under MIT License
© 2019 - 2023 CyraTeam. All Rights Reserved
1.5.0

7 months ago

1.4.9

7 months ago

1.4.8

8 months ago

1.4.7

10 months ago

1.4.6

11 months ago

1.4.5

12 months ago

1.4.4

12 months ago

1.4.3

12 months ago

1.4.2

12 months ago

1.4.1

12 months ago

1.4.0

12 months ago

1.3.8

1 year ago

1.3.6

1 year ago

1.3.4

1 year ago

1.3.2

1 year ago

1.2.8

1 year ago

1.2.4

1 year ago

1.2.0

1 year ago

1.1.4

1 year ago

1.1.2

1 year ago

1.1.0

1 year ago

1.0.4-beta

1 year ago

1.0.2-beta

1 year ago

1.0.0

1 year ago