JSPM

  • Created
  • Published
  • Downloads 13
  • Score
    100M100P100Q62862F

Package Exports

  • darkcord
  • darkcord/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (darkcord) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme


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 Voice from "darkcord/voice"

const Nodes = [{
    name: 'darkcord-player',
    url: 'localhost:2333',
    auth: 'youshallnotpass',
    secure: false
}];

const voicePlugin = Voice(Nodes, {
    defaultSearchEngine: "youtube"
})

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

client.voice.lavalink.on("ready", () => console.log("Lavalink is Ready"))

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

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

client.connect()