discord.js-rest v1.0.2
discord.js-rest | A Discord Rest Libary with zero Caching
Discord Rest | A libary, which allows you to connect to the Gateway and interact with the Discord Api with Rest Requests. Get the full control back with 0% Cache.
This Libary is usefull for Big Bots or Bots with less functionalities, since they often have their own Handler or do not need everything
Why?
The Discord.js library is bloated up with a lot of structures and some useless cache properties, which likely are never used. As your Bot grows or when you are searching after a minimalistic Solution, the package can be optimal, because it was just made for connecting to the Discord GateWay (Client Login), recieving all Discord Events and moreover doing Rest requests for sending message, creating channels, adding roles and more... This Solution can be comfortable for advanced Coders, which makes their own Custom Solutions for Caching.
If you need help feel free to join our discord server. We will provied you all help ☺
Download
You can download it from npm:
npm i discord.js-rest
Changes:
When you interested transforming your code from 'X Libary' to discord.js-rest, you have to know there will be a lot of breaking Changes
- There is no Structures such as
client.guilds
orclient
- No Caching | Custom Caching in Plan
- You recieve Discord Packets, which are delivered as Objects on the Event
- Event Names are Discord Event Names such as
MESSAGE_CREATE
instead ofmessage
- Do not use this Package, when you do not have any know-how of rest
- You can use the routeBuilder, which has been copied from discord.js, e.g
client.api.channels[channel_id].messages.post({ data})
- There is no premade functions for interacting with the Api
Example
The Example below shows, how discord.js-rest works and what you can do with Data you get. Sharding works too, you can use the ShardingManager of the Discord.js Library
const {token} = require('./config.json')
const Discord= require('discord.js-rest')
const client = new Discord.Client({intents: ['GUILDS', 'GUILD_MESSAGES' ]})
client.on('READY',(packet) =>{
client.user = packet.d.user;
console.log('Bot Ready')
})
client.on('debug', console.log)
client.on('MESSAGE_CREATE',(packet) => {
if(!packet.d) return;
if(!packet.d.author) return;
if(packet.d.author.id === client.user.id) return;
if(packet.d.content === '!hello'){
const data = {content: `Hello`}
client.api.channels[packet.d.channel_id].messages.post({ data}).catch(e => console.log(e))
}
console.log(packet.d) //Log out the Data, when you want to see the structure
})
client.login(token)
Route Build Paths
This Part is currently on work, you can look into the Discord.js libary and its internal code
A Custom Caching Option is currently on work!
Credits:
All Credits goes to the libary 'discord.js' and their contributers. This Package is a unbloated version of the Libary, which allows you to connect to the Gateway, Listen to Events and do rest requests.