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

whats.js

v1.2.1

Published

a simple whatsapp package interface same as discord.js

Downloads

57

Readme

Whatsapp.js | whats.js

Please Consider Joining My Discord Support Server

Why You Should Use Whats.js

Whats.js is simple package that allow you to use whatsapp-web as nodejs client. Using @adiwajshing/baileys ( Modifed )

Change Log ( Latest Release 1.1.1 )

  • Bug Fixed.
  • Check Change Log v1.1.1

Join Pls

Installation

npm i whats.js@latest

Examples

Simple Source To Start Your Bot

const whatsapp = require("whats.js");
const client = new whatsapp();

Simple Ready Event Listener

const whatsapp = require("whats.js");

const client = new whatsapp();
client.once("ready",async client=>{
  console.log(`Account Is Ready , Number : ${client.user.number} , Name : ${client.user.name}`);
})

Simple Message Event Listener

const whatsapp = require("whats.js");
const client = new whatsapp();
client.on("message",async message=>{
  
  if(message.content =="Hi"){
    await message.markAsRead();       // Mark The Message As Read
    message.reply("Hello World");     // Reply In Same Channel "Group/UserDM"
    message.reply("Don't Tell AnyOne But Im a bot ...",true); // Reply In DM.
  }
})

Docs

Client

| PROPERTIES | METHODS | EVENTS | | ---------- | ---------------------- | --------------------------------------- | | | login | ready | | | | message | | | | messageUpdate | | | | messageDelete | | | | reactionCreate |

Events

Ready Event

Emitted when the client becomes ready to start working. | PARAMETER | TYPE | DESCRIPTION | | --------- | --------------------- | --------------- | | client | User | The Client Data |

Message Event

Emitted whenever a message is created. | PARAMETER | TYPE | DESCRIPTION | | --------- | --------------------------- | ------------------------ | | message | Message | The Created Message Data |

MessageUpdate Event

* Event Still Not Ready Yet.

MessageDelete Event

* Event Still Not Ready Yet.

ReactionCreate Event

* Event Still Not Ready Yet.

login method

Call This Function To Login The Client To WA-WEB Socket Server Required *

client.login();

Classes

User Class

An Object For User's Data. | PROPERTIES | METHODS | | ----------------------------------- | -------------------------------------- | | id | send | | Number | startActivity | | name | |

.id

Current Client's ID As String.

.number

Current Client's Number As String.

.name

Current Client's Name As String.

.send(MessageTypes)

Send A Message To User With Parameter MessageTypes or String Required *, Return MessageClass Of New Message Sent By Client (Cause Circular Class Error Deprecated).

await user.send(`Hi There Using Whats.js 💜.`); // Content OR MessageType Object.

.startActivity(activity)

Start Activity In Current User's DM Such As Typing,Recording,...etc String.

await user.startActivity(`recording`); // Client Will Show Recording Status At The User's Dm

Message Class

An Object of Message instanse. | PROPERTIES | METHODS | | -------------------------------------- | -------------------------------------------- | | content | reply | | id | markAsRead | | Author | react | | channel | unReact | | media | forward | | | isMediaMessage | | | isButtonResponse | | | isListResponse |

.content

Returns Message Content As String.

.id

Returns Message ID As String.

.reply(MessageTypes,Dm)

Reply To Message With Parameters MessageTypes or String Required * And Reply In Dm Boolean, Return MessageClass Of New Message Sent By Client.

await message.reply(`Hi There Using Whats.js 💜.`,true); // First Content OR MessageType Object, Then Boolean True Or False (Default).

.markAsRead()

Mark A Message As Read (Two blue Ticks), No Parameters.

await message.markAsRead();

.react(Emoji)

React To A Message With An Emoji, Parameters String Emoji Default : 👀.

await message.react("🍟"); // Fries Are The Best.

.unReact()

UnReact To Previous Reacted Message.

await message.unReact();

.forward(User)

Forward Message To Another User Parameter Must Be User Required * .

await message.forward(myOtherAccount);

.isMediaMessage()

Returns True When Its Media Message.

.isButtonResponse()

Returns True When Its Button Response.

.isListResponse()

Returns True When Its List Response.

Channel Class

| PROPERTIES | METHODS | | ---------------------------- | ---------------------------------------------- | | id | send | | | startActivity | | | awaitMessages |

.id

Returns Channel ID As String.

.send(MessageTypes)

Send A Message In Channel With Parameter MessageTypes or String Required *, Return MessageClass Of New Message Sent By Client (Cause Circular Class Error Deprecated).

await channel.send(`Hi There Using Whats.js 💜.`); // Content OR MessageType Object.

.startActivity(activity)

Start Activity In Current Channel Such As Typing,Recording,...etc String.

await user.startActivity(`recording`); // Client Will Show Recording Status At The Channel

.awaitMessages(filter,maxResults,time)

Create A Message Collector With Filter And Max Results And Time. Parameters Function Of Messages Filter, Number Max Number Of Results Collected, Time To Stop Collecting Messages.

let filter = message=> !isNaN(message.content);
let collected = await channel.awaitMessages(filter,1,10000); // Collect Only One Number Content Message In 10,000ms = 10s;
console.log(collected);

Media Class

| PROPERTIES | METHODS | | ---------------------------------- | ---------------------------- | | name | isAudio | | format | isImage | | | isVideo | | | buffer | | | saveFile |

.name

Returns Media File Name As String.

.format

Returns Media File Format As String.

.isAudio()

Returns True If Media File Is An Audio File.

.isImage()

Returns True If Media File Is An Image File.

.isVideo()

Returns True If Media File Is A Video File.

.buffer()

Async Function That Returns Buffer Of The Media File.

await media.buffer(); // returns Buffer.

.saveFile(fileName,path)

Save File In Certain Path And Name Parameters FileName String, Path String Default : fileName = Media.name, path = Root Project Path.

await media.saveFile("Video.mp4","./videos"); 

Types

Activity Types

unavailable, available, composing, recording, paused

Message Types

MessageAttachment

This Class Can Be Used To Send A File With .send(MessageTypes)/.send(MessageTypes)/.reply(MessageTypes)

usage
const attachment = new client.MessageAttachment(path,fileName);
message.reply(Attachment);

MessageButtons

This Type Of Messages Doesn't Show Up For Other WA User Anymore So Its Deprecated *

Deprecated

MessageContact

This is A contact Card Message, Users Can Add Any Contact Quickly Using This Type Of Message.

usage
const contact = new client.MessageContact().setContactName("WA.js Developer").addContact("ASTA","967778117520","X Design Co."); // Parameters Can Be Used Within Class Constructor
message.reply(contact);

MessageLocation

This is A Location On Map Message, You Can Send A Location Using The Latitude,Longitude.

usage
const location = new client.MessageLocation(48.05,12.85); // Latitude,Longitude
channel.send(location);
// Markdowns Will Be More Detailed Soon I Want To Sleep Now LoL