disclient
TypeScript icon, indicating that this package has built-in type declarations

2.0.14 • Public • Published

image not available

What is this?

disclient is a discord api wrapper in which you can use it to post or recieve requests to the discord gateway, and the discord api

How do i Install?

npm i disclient --save
yarn add --save disclient

Join our Discord server now!

Better to explain with examples

Logging in :

const { Client } = require("disclient");
const bot = new Client("SECRET-TOKEN");

bot.build().then(() => {
  console.log("bot logged in")
});

Events :

const { Client } = require("disclient");
const bot = new Client("SECRET-TOKEN");

bot.on("READY", () => {
  console.log("Bot logged in");
});
 
// it was not good to console.log after the bot.build() function so just do the console.log in the READY event.
bot.build();

Listening to Messages :

const { Client } = require("disclient");
const bot = new Client("SECRET-TOKEN");

bot.on("READY", () => {
  console.log(`${bot.user.tag} is online`);
});

bot.on("MESSAGE_CREATE", async (message) => {
  console.log(message.content);
});

bot.build();

Creating Messages :

const { Client } = require("disclient");
const bot = new Client("SECRET-TOKEN");

bot.on("READY", () => {
  console.log(`${bot.user.tag} is online`);
});

bot.on("MESSAGE_CREATE", async (message) => {
  if(message.content === "!ping"){
    message.channel.sendMessage("Pong!")
  }
});

bot.build();

Replying to message :

const { Client } = require("disclient");
const bot = new Client("SECRET-TOKEN");

bot.on("READY", () => {
  console.log(`${bot.user.tag} is online`);
});

bot.on("MESSAGE_CREATE", async (message) => {
  if(message.content === "!hello"){
    message.channel.reply("Hello World");
  }
});

bot.build();

Sending Embeds :

const { Client, Embed } = require("disclient");
const bot = new Client("SECRET-TOKEN");

bot.on("READY", () => {
  console.log(`${bot.user.tag} is online`);
});

bot.on("MESSAGE_CREATE", async (message) => {
  if(message.content === "!ping"){
    const embed = new Embed()
    embed.setTitle("Pong!")
    embed.setDescription("This is the desc")
    const embed1 = embed.create();

    message.channel.sendMessage("Some Message", { embeds: [embed1] });
  }
});

bot.build();

Reacting to Message :

const { Client } = require("disclient");
const bot = new Client("SECRET-TOKEN");

bot.on("READY", () => {
  console.log(`${bot.user.tag} is online`);
});

bot.on("MESSAGE_CREATE", async (message) => {
  if(message.content === "!react"){
    message.react("😂");
  }
});

bot.build();

Contributors

  • Don Baba#1818
  • SAURABH#0777
  • ΔH〢< Ayaan />#0001
  • BOYFIE#8831

© tsdon0001 2021

Package Sidebar

Install

npm i disclient

Weekly Downloads

20

Version

2.0.14

License

Apache-2.0

Unpacked Size

91.3 kB

Total Files

45

Last publish

Collaborators

  • ayaanatri
  • saurabh777
  • tsdon0001
  • boyfie