https://github.com/liy77/darkcord
A NodeJS Library to interact with discord api
https://github.com/liy77/darkcord
api discord http http-server interactions javascript node nodejs typescript ws zlib
Last synced: 8 days ago
JSON representation
A NodeJS Library to interact with discord api
- Host: GitHub
- URL: https://github.com/liy77/darkcord
- Owner: liy77
- License: mit
- Created: 2023-01-26T09:40:04.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2024-03-23T15:42:25.000Z (almost 2 years ago)
- Last Synced: 2025-11-20T22:03:42.306Z (2 months ago)
- Topics: api, discord, http, http-server, interactions, javascript, node, nodejs, typescript, ws, zlib
- Language: TypeScript
- Homepage: https://darkcord.denkylabs.com/
- Size: 3.67 MB
- Stars: 26
- Watchers: 1
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
## About
Darkcord is a [Node.js](https://nodejs.org) module to easily interact with
[Discord API](https://discord.com/developers/docs/intro).
## Installation
**Node.js 16.9.0 or newer is required to installation.**
```sh-session
npm install darkcord
yarn add darkcord
pnpm add darkcord
```
## Example Usage
### Gateway Example
```js
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
```js
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
```sh-session
npm install shoukaku
yarn add shoukaku
pnpm add shoukaku
npm install kazagumo
yarn add kazagumo
pnpm add kazagumo
```
##### Spotify
```sh-session
npm install kazagumo-spotify
yarn add kazagumo-spotify
pnpm add kazagumo-spotify
```
```js
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
- [Website](https://darkcord.denkylabs.com)
- [GitHub](https://github.com/JustAWaifuHunter/darkcord)
- [npm](https://npmjs.com/package/darkcord)
- [Discord API Discord server](https://discord.gg/discord-api)