Giter Site home page Giter Site logo

itsryu / darkcord Goto Github PK

View Code? Open in Web Editor NEW

This project forked from liy77/darkcord

1.0 0.0 0.0 4.44 MB

A WIP NodeJS Library to interact with discord api

Home Page: https://darkcord.denkylabs.com/

License: MIT License

JavaScript 0.19% TypeScript 96.69% CSS 1.40% SCSS 0.68% Astro 1.04%

darkcord's Introduction


darkcord


Tests status

About

Darkcord is a Node.js module to easily interact with Discord API.

Installation

Node.js 16.9.0 or newer is required to installation.

npm install darkcord
yarn add darkcord
pnpm add darkcord

Example Usage

Gateway Example

import { Client, Constants } from "darkcord";

const GatewayIntentBits = Constants.GatewayIntentBits;
const ClientIntents =
  GatewayIntentBits.Guilds |
  GatewayIntentBits.GuildMessage |
  GatewayIntentBits.MessageContent;

const client = new Client("token", {
  gateway: {
    intents: ClientIntents,
  },
});

client.on("ready", () => {
  console.log(`Connected to Discord Gateway`);
});

client.on("interactionCreate", async (interaction) => {
  if (interaction.isCommand()) {
    await interaction.reply({ content: "Pong!" });
  }
});

client.connect();

HTTP Interactions Example

import { InteractionClient } from "darkcord";

const client = new InteractionClient("public key", {
  rest: {
    token: "token",
  },
  webserver: {
    port: 8080,
  },
});

client.on("connect", () => {
  console.log("Listening on port 8080");
});

client.on("interactionCreate", async (interaction) => {
  if (interaction.isCommand()) {
    await interaction.reply({ content: "Pong!" });
  }
});

client.connect();

Voice

Install voice packages

npm install shoukaku
yarn add shoukaku
pnpm add shoukaku

npm install kazagumo
yarn add kazagumo
pnpm add kazagumo
Spotify
npm install kazagumo-spotify
yarn add kazagumo-spotify
pnpm add kazagumo-spotify
import { Client } from "darkcord";
import { Lava } from "@darkcord/lava";

const Nodes = [
  {
    name: "Node 1",
    url: "localhost:2333",
    auth: "youshallnotpass",
    secure: false,
  },
];

const voicePlugin = Lava({
  nodes: Nodes,
  defaultSearchEngine: "youtube",
});

const client = new Client("token", {
  gateway: {
    intents: YOUR_INTENTS,
  },
  plugins: [voicePlugin],
});

client.lava.lavalink.on("ready", (node) =>
  console.log(`Node ${node} is Ready`),
);

client.lava.on("playerStart", (player) => {
  client.channels.cache.get(player.textId).createMessage({
    content: `Now playing **${track.title}** by **${track.author}**`,
  });
});

client.on("ready", () => console.log("Client is Ready"));

client.connect();

Useful Links

darkcord's People

Contributors

liy77 avatar

Stargazers

Victor avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.