Skip to content

Commit

Permalink
release v1.5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
brokenedtzjs committed Oct 13, 2024
1 parent 05990cc commit 8196be5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 19 deletions.
40 changes: 25 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,34 +37,44 @@ npm install discord-afk-js

```javascript
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(' ');
afk.setUser('user123', reason);
afk.setUser({ id: 'id1', reason: 'Afk Playing Game' });

const [reason, time] = await afk.getReason('id1');

if (afk.findUser('user123')) {
if (afk.findUser('id1')) {
console.log('User is marked as AFK'); // console: User is marked as AFK
console.log('AFK Message:', afk.getReason('user123')); // console: AFK Message: No Reason
console.log('AFK Message:', `${reason} ${time}`); // console: AFK Message: Afk Playing Game a few seconds ago
}
// or
// Adding a user to AFK status with time
const reason = args.join(' ');
afk.setUser('user123', reason);

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

const [time, reason] = data;
const timeago = moment(time).fromNow();
// 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} ${timeago}`); // console: AFK Message: No Reason a few seconds ago
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');
```
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"chalk": "^5.3.0",
"package-json": "^10.0.1",
"semver": "^7.6.0",
"moment": "^2.29.4",
"semver-diff": "^4.0.0",
"tslib": "^2.7.0"
},
Expand All @@ -79,7 +80,6 @@
"jest": "^29.7.0",
"jest-junit": "^16.0.0",
"mocha": "^10.2.0",
"moment": "^2.29.4",
"prettier": "3.3.3",
"tsd": "^0.31.2",
"turbo": "^2.1.3",
Expand Down
6 changes: 3 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8196be5

Please sign in to comment.