Skip to content
This repository was archived by the owner on Oct 28, 2024. It is now read-only.

HTTP POST Request Example

Jens Møller edited this page Nov 25, 2019 · 11 revisions

The bot supports the use of HTTP POST requests, to do certain things. This could be useful, if you want to make your own panel, or an app to manage the bot.
You can create commands, update the activity, game and many things via HTTP POST

Using NodeJS

In this example, we run a POST request in NodeJS, to create a new command called test, to set the game to BEEP BOOP, and to set the status to Do Not Disturb.

const http = require('http')

const data = JSON.stringify( {
    "add_command":{
		"test": "hello world"
	},
	"set_status":{
		"game": "BEEP BOOP",
		"online": "DO_NOT_DISTURB"
	}
  })

const options = {
  hostname: '127.0.0.1',
  port: 1337,
  path: '/api/v1/request',
  method: 'POST',
  headers: {
    'content-type': 'application/json',
	'token': '**TOKEN FOUND IN CONFIG**'
  }
}

const req = http.request(options, (res) => {
  console.log(`statusCode: ${res.statusCode}`)

  res.on('data', (d) => {
    process.stdout.write(d)
  })
})

req.on('error', (error) => {
  console.error(error)
})

req.write(data)
req.end()

Clone this wiki locally