Socket
Socket
Sign inDemoInstall

discord-slim

Package Overview
Dependencies
1
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    discord-slim

Lightweight Discord client for Node.js.


Version published
Maintainers
1
Created

Readme

Source

Discord Slim

V2 IS UNDER DEVELOPMENT!

Contains breaking changes and incompatible with V1.
Dev version is unstable and can have bugs!
API is unfinished and may be changed with further updates.

V2 main features

  • Typed actions API instead of manual requests.
  • Typed events API instead of manual packet handling.
  • Actions is now independent from the client.

Support & suggestions server

https://discord.gg/drsXkP8R4h

Before you start

Node.js 12+ is required!

Make sure you have some understaning of Discord API.

Installation

Note: NPM version may be out-of-date and not contain latest repo commits.

npm i discord-slim@dev

Usage example

const
    Discord = require('discord-slim'),
    Actions = Discord.Actions,
    Events = Discord.Helpers.Events,
    Intents = Discord.Helpers.Intents,
    client = new Discord.Client(),
    authorization = new Discord.Authorization('token'),
    requestOptions = { authorization };

client.on('connect', () => console.log('Connection established.'));
client.on('disconnect', (code) => console.error(`Disconnect. (${code})`));
client.on('warn', console.warn);
client.on('error', console.error);
client.on('fatal', (e) => { console.error(e); process.exit(1); });

client.events.on(Events.MESSAGE_CREATE, (message) => {
    if(message.author.id == client.user.id) return;
    if(message.content.toLowerCase().indexOf('hello bot') < 0) return;
    Actions.Message.Create(message.channel_id, {
        content: `Hi, <@${message.author.id}>!`,
        message_reference: {
            channel_id: message.channel_id,
            message_id: message.id,
        },
    }, requestOptions);
});

client.Connect(authorization, Intents.GUILDS | Intents.GUILD_MESSAGES);

Build from source

Install typescript package from npm and run tsc.

FAQs

Last updated on 29 Mar 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc