👨‍💻Quick Start

You can use npm, yarn or pnpm to install de djs-protofy library

How to install

npm i djs-protofy

If you use sharding, you must place the code below in the main client file, not in the ShardingManager

require("djs-protofy/init");

JavaScript and TypeScript

require("djs-protofy/init");
const { ChannelType, Client, GatewayIntentBits } = require("discord.js");

const client = new Client({ intents: [GatewayIntentBits.Guilds] });

client.on("messageCreate", async (message) => {

  if (message.content === "-ping") {
    const channel = client.channels.getById(string, ChannelType.GuildText);
    if (channel) await channel.send({ content: "pong" });
  }

});

client.login();

Using with sharding

/sharding.js
require("dotenv/config");
const { ShardingManager } = require("discord.js");

const manager = new ShardingManager("shard.js");

manager.spawn();
/shard.js
require("djs-protofy/init");
const { Client, GatewayIntentBits } = require("discord.js");

const client = new Client({ intents: [GatewayIntentBits.Guilds] });

client.on("ready", () => {
  console.log("ready");
  
  client.users.getById(string); // User | undefined
});

client.login();

Last updated