youtube-bot.js
v1.0.1
Published
Welcome to youtube-bot.js! ========================== This is a package made designed to make a youtube bot for live streams ========================== ### Features - **Message Event** Track messages sent by users in the live stream - **Channel Id finder*
Readme
Welcome to youtube-bot.js!
This is a package made designed to make a youtube bot for live streams
Features
- Message Event Track messages sent by users in the live stream
- Channel Id finder Automatically find channel id's by simply using their username (they have to have sent a message in the stream)
- Token Refresher Automatically Refresh your access_token with tokenRefresh()
Using the package
- Have a tokens.json like this
{
"access_token": "",
"refresh_token": "",
"scope": "",
"token_type": "",
"expiry_date": 1735083162760
}- And a credentials.json like this
{
"client_id":"",
"project_id":"",
"auth_uri":"https://accounts.google.com/o/oauth2/auth",
"token_uri":"https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs",
"client_secret":"",
"redirect_uris":[""]
}- Heres a basic setup of the package in index.js
const { YouTubeClient } = require('yt-bot.js');
const prefix = '.'
const client = new YouTubeClient({
credentials: './credentials.json',
tokens: './tokens.json',
prefix: prefix
});
client.on('ready', async () => {
console.log(`Logged in as ${client.name}!`)
await client.join('STREAM_ID');
})
client.tokenRefresh().then(() => {
client.initialize();
})- And here is a basic example of a command which is automatically handled by the package
client.command({
name: 'hi',
response: 'hello'
})
client.command({
name: 'hi',
execute: async () => {
client.send('hi')
}
})- Heres a simple example of the message event
client.onMessage(async (data) => {
console.log(`${data.author.displayName}: ${data.content}`);
});- You can also send messages by using the send() function
client.send('Hello, world!')