Giter Club home page Giter Club logo

wwebjs-sender's Introduction


















  • Name: DeathAbyss
  • BFFS: Tima, Mich.
  • Loves: you! ice cream, music and code
  • Hobbys: Bots Development/Web Development/Backend Development
  • Partner: @TwitchTheaterTv
  • Working: @TroxxBot











  • Python JavaJavaScript Typescirpt React Node.js Tmi.js  Discord.js

    Hello! My name is DeathAbyss and I enjoy creating things that live on the internet. My interest in NodeJS development started back in 2016 when I wanted to start making bots for different platforms, and keep moving forward in the world of programming. So far I have started working with Troxx Inc and I will stay, since it is the best service for bots that grows more every day, giving satisfaction to top customers.











    Hewe awe some of my
    most used s-s-sociaw things >~< xoxox


















    Stats Overview Most Used Languages


    wwebjs-sender's People

    Contributors

    lime-desu avatar xxdeathabyssxx avatar

    Stargazers

     avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

    Watchers

     avatar

    wwebjs-sender's Issues

    bug

    const { Client, LocalAuth, MessageMedia, Buttons } = require('whatsapp-web.js');
    const qrcode = require('qrcode-terminal')
    const axios = require('axios');
    const images = require('./data')
    const fs = require('fs');
    const WwebjsSender = require('@deathabyss/wwebjs-sender')

    const quotes = {
    method: 'GET',
    url: 'https://type.fit/api/quotes'
    };

    const client = new Client({
    authStrategy: new LocalAuth(),
    });

    client.on('qr', (qr) => {
    qrcode.generate(qr, { small: true })
    });

    client.on('authenticated', () => {
    console.log('Authenticated');
    });

    let chatId = ""
    client.on('message', message => {
    console.log(message.body);
    chatId = message.from;
    console.log(chatId);
    });

    //buttons
    client.on("message", (msg) => {
    if (msg.body == "!command") {
    const from = chatId
    console.log(from);
    let embed = new WwebjsSender.MessageEmbed()
    .sizeEmbed(28)
    .setTitle("✅ | Successful process!")
    .setDescription("The process has been successful!")
    .addField("✔", "To confirm")
    .addField("❌", "To cancel")
    .addFields({
    name: "Now you have 2 buttons",
    value: "✔ or ❌",
    })
    .setFooter('WwebjsSender')
    .setTimestamp();

        let button1 = new WwebjsSender.MessageButton()
            .setCustomId("confirm")
            .setLabel("✔")
    
        let button2 = new WwebjsSender.MessageButton()
            .setCustomId("cancel")
            .setLabel("❌");
    
        try {
            WwebjsSender.send({
                client: client,
                number: from,
                embed: embed,
                button: [button1, button2]
            });
        } catch (error) {
            console.log(error);
        }
    
    }
    

    });

    //Listen for incoming messages

    client.on('ready', () => {
    console.log("Client is ready");
    });

    client.initialize();
    I am building a bot using whatsapp-web.js. I want to send send buttons as replies. I made confirm that I am authenticated. I tried many ways to get buttons as replies but none of them is working. I am using @deathabyss/wwebjs-sender to get buttons in the bot. But I am not getting any replies or errors.

    Show me a way to send buttons as replies in whatsapp-web.js?

    Button with Media

    Hi, Is there any way to send the button with the media file? Kindly let me know.

    ReferenceError: id_btn is not defined

    /app/node_modules/@deathabyss/wwebjs-sender/index.js:503
    id_btn = id;
           ^
    
    ReferenceError: id_btn is not defined
    at MessageButton.setCustomId (/app/node_modules/@deathabyss/wwebjs-sender/index.js:503:14)
    at Client.<anonymous> (/app/index.js:202:18)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

    bug happens at .setCustomId("confirm")

    bug

    i se this , but nothing happends...

        case "test": {
          sendMessage(kevin, "Comando ejecutado");
          let embed = new WwebjsSender.MessageEmbed()
            .sizeEmbed(28)
            .setTitle("✅ | Successful process!")
            .setDescription("The process has been successful!")
            .addField("✔", "To confirm")
            .addField("❌", "To cancel")
            .addFields({
              name: "Now you have 2 buttons to choose!",
              value: "✔ or ❌",
            })
            .setFooter("WwebjsSender")
            .setTimestamp();
    
          let button1 = new WwebjsSender.MessageButton()
            .setCustomId("confirm")
            .setLabel("✔");
    
          let button2 = new WwebjsSender.MessageButton()
            .setCustomId("cancel")
            .setLabel("❌");
    
          WwebjsSender.send({
            client: client,
            number: from,
            embed: embed,
            button: [button1, button2],
          });
          break;
        }
    

    TypeError: Cannot read properties of null (reading 'char')

    Given Below Error
    image

    My Code Below
    `import { Client , LocalAuth,MessageMedia ,List} from 'whatsapp-web.js'//@ts-ignore
    import { MessageEmbed,MessageButton,send,Collector} from "@deathabyss/wwebjs-sender"
    import { readFileSync} from 'fs'
    import qrcode from 'qrcode-terminal'

    export const fileToBase64 = async( filepath:string) => {
    const buffedInput = "data:image/gif;base64," + await readFileSync(filepath, 'base64')
    return buffedInput
    }

    const client = new Client({
    authStrategy: new LocalAuth(),
    puppeteer: {
    headless: false ,
    ignoreDefaultArgs: ['--disable-extensions']
    }
    })

    client.on('qr', (qr) => {
    // Generate and scan this code with your phone
    console.log('QR RECEIVED')
    qrcode.generate(qr, {small: true})
    });

    client.on('ready', () => {
    console.log('Client is ready!')
    })

    client.on('message', async(msg) => {
    if (msg.body == '!ping') {
    msg.reply('pong')
    }
    else if (msg.body == 'image'){
    const base64Image = await readFileSync('./jagodasir.jpg',{encoding: 'base64'})
    const media = new MessageMedia('image/png', base64Image)
    await msg.reply(media,msg.from,{caption: 'this is my caption'})
    }
    else if (msg.body.startsWith('!send')){
    const quoted_msg = await msg.getQuotedMessage()
    if (quoted_msg){
    const command_and_number = msg.body.split(' ')
    const sanitized_number = command_and_number[1].toString().replace(/[- )(]/g, "")
    const final_number = 94${sanitized_number.substring(sanitized_number.length - 9)}
    const number_details = await client.getNumberId(final_number)
    if (number_details) {
    await quoted_msg.forward(number_details._serialized)
    //await foward_msg_return.ms
    } else {
    console.log(final_number, "\nMobile number is not registered");
    }
    }
    else{
    await msg.reply('Please Reply To A Message\n\n!send 771247221')
    }

    }
    else if (msg.body == 'list'){
        const productsList = new List(
            "Here's our list of products at 50% off",
            "View all products",
            [
              {
                title: "Products list",
                rows: [
                  { id: "apple", title: "Apple" },
                  { id: "mango", title: "Mango" },
                  { id: "banana", title: "Banana" },
                ],
              },
            ],
            "Please select a product"
          )
        await client.sendMessage(msg.from,productsList)
    }
    else if (msg.body == 'button'){
        let embed = new MessageEmbed()
            .sizeEmbed(28)
            .setTitle("✅ | Successful process!")
            .setDescription("The process has been successful!")
            .addField("✔", "To confirm")
            .addField("❌", "To cancel")
            .addFields({
                name: "Now you have 2 buttons to choose!",
                value: "✔ or ❌"
        }).setFooter("WwebjsSender").setTimestamp()
    
        let button1 = new MessageButton().setCustomId("confirm").setLabel("✔");
    
        let button2 = new MessageButton().setCustomId("cancel").setLabel("❌")
    
        await send({
            client: client,
            number: msg.from,
            embed: embed,
            button: [button1, button2]
        })
    }
    else if (msg.body == 'register'){
        let someEmbed = new MessageEmbed()
            .setTitle(`1️⃣ | What is your name?`)
            .setDescription(`Please, type your name.`)
            .setFooter(`Question!`)
            .setTimestamp()
            .sizeEmbed(24);
    
        let anotherEmbed = new MessageEmbed()
        .setTitle(`2️⃣ | What is your age?`)
        .setDescription(`Please, type your age.`)
        .setFooter(`Question!`)
        .setTimestamp()
        .sizeEmbed(24);
    
        let collect = new Collector({
            client: client,
            chat: await msg.getChat(),
            time: 10000,
            number: msg.from,
            max: [20, 3],
            question: ["🔐 What is your name?", "🚨 What is your age?"],
            embed: [someEmbed, anotherEmbed]
        })
        //@ts-ignore
        collect.on("message", async (msg) => {
        let body = msg.body;
        console.log(body);
        });
    
        await collect.initialize();
    
        let resultMessageQuestion = await collect.messageQuestionCollcetor();
    
        let resultEmbedQuestion = await collect.embedQuestionCollector();
    
        console.log(resultMessageQuestion, resultEmbedQuestion);
    }
    

    })

    client.initialize()`

    Button is not working

    I have use same example code. if I have send message with button then not working.
    if I have remove button then send message

    let embed = new WwebjsSender.MessageEmbed()
    .sizeEmbed(28)
    .setTitle("✅ | Successful process!")
    .setDescription("The process has been successful!")
    .addField("✔", "To confirm")
    .addField("❌", "To cancel")
    .addFields({
    name: "Now you have 2 buttons to choose!",
    value: "✔ or ❌",
    })
    .setFooter("WwebjsSender")
    .setTimestamp();

        let button1 = new WwebjsSender.MessageButton()
            .setCustomId("confirm")
            .setLabel("✔");
    
        let button2 = new WwebjsSender.MessageButton()
            .setCustomId("cancel")
            .setLabel("❌");
    
        WwebjsSender.send({
            client: client,
            number: from,
            embed: embed,
            button: [button1, button2],
        }); 
    

    help

    How do i send a message collector in dms?

    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.