Skip to main content

How to Use Puppeteer With Your NodeJS Discord Bot

1. Select a NodeJS Version

Within the Startup page on your panel, select your desired NodeJS version (you must select the Docker image from Cybrancee). This must also be for a NodeJS version that is 18 or later.

Cybrancee panel NodeJS versions

2. Add ‘puppeteer’ to ‘ADDITIONAL NODE PACKAGES’ Field

Cybrancee panel NodeJS startup screen, with fields outlined

3. Select ‘Reinstall Server’

Select the ‘Settings‘ Tab and scroll down

Cybrancee_Panel_Settings_Tab_Reinstall

4. Select the Drop-Down Menu


5. Select the ‘Delete current files and reinstall server‘ Reinstall Option

Cybrancee_Options_Re-Install
Delete current files and reinstall serverWipes all current files and performs a clean reinstall. Useful when you want a completely fresh start, whilst keeping any settings configured on the startup page.

6. Select ‘Continue’

Cybrancee_Select_Continue

7. Select ‘Confirm reinstall’


8. Puppeteer is Now Installed and Enabled

When you use Puppeteer, you will need to include the following parameters and includes within your code:

Python
const puppeteer = require('puppeteer');

(async () => {
    const browser = await puppeteer.launch({
        args: ['--no-sandbox'],
  	});
  
  	//EXAMPLE USAGE
    const page = await browser.newPage();
    await page.goto('https://cybrancee.com');
    
    console.log(await page.title())
    
    
    await page.waitForSelector('xpath///*[@id="domain-search"]/span/input');
    await page.type('xpath///*[@id="domain-search"]/span/input', 'andreisawesome.com');
    
    await page.click('xpath///*[@id="domain-search"]/span/button[1]')
    
    await page.waitForNavigation();
    
    console.log(await page.title())
    
    await page.waitForSelector('xpath///*[@id="primaryLookupResult"]/div[2]/div/div[1]/i');
    
    let available = await page.waitForSelector('xpath///*[@id="primaryLookupResult"]/div[2]/div/div[2]/div[1]');
    
    const value = await available.evaluate(el => el.innerText);
    
    console.log(value)
	    
    await browser.close();
})();

Discord Bot Hosting

Starts at $1.49

External link icon
Was this article helpful?
Please Share Your Feedback
How Can We Improve This Article?
Table of Contents