Skip to content
This repository has been archived by the owner on Mar 15, 2024. It is now read-only.

A Simple example that shows how to connect with discord gateway and make API requests.

Notifications You must be signed in to change notification settings

PasinduDushan/Discord-Gateway-Example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This code has been archieved

Discord Gateway Example

You can connect with discord gateway and make requests to it using this code. This code contains most basic structures that you can use.

This code use latest version of discord Gateway (v9) and latest version of discord API (v9). This code can be updated anytime. Video tutorial of this code will be added soon

Setup for code

  1. Clone this repository.
git clone https://github.com/PasinduDushan/Discord-Gateway-Example
  1. Add your bot TOKEN inside the .env file.
  2. Open up your terminal, Go to file directory and type npm i.
  3. Type npm start in the terminal.

After you enter the npm start command, you should be connected to the discord gateway. You have to get a responce like this when you connect to the gateway.

{
  t: null,
  s: null,
  op: 10,
  d: {
    heartbeat_interval: 41250,
    _trace: [ '["gateway-prd-main-4xgr",{"micros":0.0}]' ]
  }
}

After the above responce you will get bunch of more responces like READY, GUILD_CREATE.

More details

This is the base knowledge that you should have to interact with discord Gateway and discord API. This process is the actual thing happening inside packages like discord.js under the hood. Connecting to the discord gateway is really easy but requesting is kind of complex. You can learn how to send requests to discord gateway and receive requests from it. This code contains how you can send an API request to the discord gateway, receieve it and POST it to discord chat. Also because this code written in the latest version of discord API, So you can create slash commands and buttons also.

This is basically a DISCORD BOT made without any packages like discord.js, Made just using discord gateway and discord API.

Developer Details

Discord - CoolDudeBonker#6655
Github - PasinduDushan

If you have any questions about this code or if you want support for running your own instance, I'll be really happy to help you. You can contact me via Discord at any time.

Contributing

  1. Fork & clone the repository, and make sure you're on the master branch
  2. Run npm ci
  3. Code your magic
  4. Run npm test to run ESLint and ensure any JSDoc changes are valid
  5. Submit a pull request

About

A Simple example that shows how to connect with discord gateway and make API requests.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published