dlivetv-unofficial-api

2.2.0 • Public • Published



Discord GitHub npm npm

dlivetv-unofficial-api is a wrapping API for the graphql hidden api provided from dlive.tv with a focus on ease of use and on performance.

Prerequisites

  • Access token is required to use this module. Create an account on dlive.tv then follow our wiki tutorial to get your token

Installation

dlivetv-unofficial-api is free and easy to install

npm install dlivetv-unofficial-api --save

You can install it in yarn too

yarn add dlivetv-unofficial-api

First Usage

const  { Dlive } = require('dlivetv-unofficial-api')
 
const displayName = 'displayName' // Our streamer displayname (https://dlive.tv/displayName)
const accessKey = 'YOUR KEY' // Our access key (https://dlive.timedot.cc/tutorials#get-my-access-token)
 
// Chat cooldown
const coolDown = 3000 // 3 seconds
 
// Parameter 1: displayName
// Parameter 2: Your access key for sending messages
let example = new Dlive(displayName, accessKey)
 
example.on('ChatText', (message) => {
  console.log(`Messages in Channel ${example.getChannel}${message.content}`)
 
  if (message.content === '!song') {
    example.sendMessage('Currently no track available...').then((result) => {
      console.log('Message sended!')
      console.log(result)
    }).catch((error) => {
      console.log(`Error while sending message! ${error}`)
      // Now we can use our function to try to resend, at this point you would directly use our own function. Please do not use this example in productive use, because it is ...
      sendMessage('Currently no track available...')
    })
  }
})
 
example.on('ChatFollow', (message) => {
  // Say thanks to this user for his follow!
  sendMessage(`Thanks for the follow, @${message.sender.displayname}`)
})
 
example.on('ChatGift', (message) => {
  // Say thanks to this user for his gift!
  sendMessage(`Thanks for ${message.amount}${message.gift}, @${message.sender.displayname}`)
})
 
// Get our channel information
example.getChannelInformation('pewdiepie' /* enter a displayname */).then((result) => {
  console.log(result)
}).catch(console.log)
 
example.util.getRisingCreators().then((result) => { // Let's see who's on the top of the ladder
  console.log(result)
}).catch(console.log)
 
function sendMessage (message) {
  example.sendMessage(message).catch((error) => {
    console.log(`Oh no.. error! ${error} - Retry in ${coolDown / 1000} seconds!`)
    setTimeout(sendMessage, coolDown, message)
  })
}

Documentation

You can find more examples and functions. For more information visit our wiki.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Acknowledgements

See also

  • C# version of dlivetv-unofficial-api

Readme

Keywords

none

Package Sidebar

Install

npm i dlivetv-unofficial-api

Weekly Downloads

20

Version

2.2.0

License

MIT

Unpacked Size

132 kB

Total Files

14

Last publish

Collaborators

  • carbowix
  • timedotcc