discord-self-lite
v0.1.8
Published
Lightweight Discord selfbot library
Maintainers
Readme
discord-self-lite
A lightweight Discord selfbot library for Node.js with minimal dependencies.
Installation
npm install discord-self-liteQuick Start
const { Client } = require("discord-self-lite");
const client = new Client();
// Login with your user token
client.login("YOUR_TOKEN_HERE");
client.on("ready", (data) => {
console.log(`Logged in as ${data.user.username}`);
});
client.on("messageCreate", async (message) => {
if (message.content === "!ping") {
await message.reply("Pong!");
}
});Features
- ✅ WebSocket connection to Discord Gateway
- ✅ REST API integration
- ✅ Message sending and replying
- ✅ Message reactions
- ✅ Button clicking (with custom IDs or indices)
- ✅ Channel and message fetching
- ✅ Webhook support - Send messages to Discord webhooks
- ✅ Minimal dependencies (only
ws)
API Reference
Client
const { Client } = require("discord-self-lite");
const client = new Client();Methods
client.login(token)- Login with user tokenclient.getChannel(channelId)- Get cached channelclient.fetchChannel(channelId)- Fetch channel from APIclient.fetchMessage(channelId, messageId)- Fetch specific message
Properties
client.user- Current user object (available after ready event)client.guilds- Map of cached guild instancesclient.channels- Map of cached channel instancesclient.sessionId- Session ID from Discord
Events
ready- Fired when client is readymessageCreate- Fired when a message is created
User
Methods
user.setStatus(status)- Set user status ('online', 'idle', 'dnd', 'invisible')user.setPresence(presence)- Set full presence datauser.setActivity(activity)- Set user activity
Properties
user.id- User IDuser.username- Usernameuser.discriminator- Discriminator (4-digit number)user.avatar- Avatar hash
Message
Methods
message.reply(content, options)- Reply to the messagemessage.react(emoji)- React to the messagemessage.clickButton(identifier)- Click a button on the messageidentifiercan be:nullor omitted: clicks first buttonnumber: clicks button at index (0-based)string: clicks button with custom ID
Properties
message.content- Message contentmessage.author- Message authormessage.channel- Message channelmessage.guild- Message guild (null for DMs)message.components- Message components (buttons, etc.)
Channel
Methods
channel.send(content, options)- Send a message to the channelchannel.fetchMessages(options)- Fetch messages from the channel
Properties
channel.id- Channel IDchannel.name- Channel namechannel.type- Channel type
Guild
Methods
guild.getChannels()- Get cached channels for this guildguild.fetchChannels()- Fetch all channels for this guild from APIguild.getChannel(channelId)- Get a specific channel from cacheguild.fetchChannel(channelId)- Fetch a specific channel from API
Properties
guild.id- Guild IDguild.name- Guild nameguild.icon- Guild icon hashguild.ownerId- Guild owner ID
WebhookClient
Send messages to Discord webhooks with support for embeds and more.
const { WebhookClient } = require("discord-self-lite");
const webhook = new WebhookClient("YOUR_WEBHOOK_URL", {
username: "My Bot",
avatarURL: "https://example.com/avatar.png",
});Constructor
new WebhookClient(url, options)- Create a webhook clienturl- Discord webhook URLoptions.username- Default username for messagesoptions.avatarURL- Default avatar URL for messages
Methods
webhook.send(content, options)- Send a message (supports text, embeds, and objects)webhook.edit(messageId, content, options)- Edit a messagewebhook.delete(messageId)- Delete a messagewebhook.fetchMessage(messageId)- Fetch a message
Static Methods
WebhookClient.createEmbed(data)- Create an embed objectWebhookClient.parseURL(url)- Parse webhook URL to get ID and token
Examples
Basic Bot
const { Client } = require("discord-self-lite");
const client = new Client();
client.login("YOUR_TOKEN_HERE");
client.on("ready", (data) => {
console.log(`Ready as ${data.user.username}`);
});
client.on("messageCreate", async (message) => {
if (message.content.startsWith("!echo ")) {
const text = message.content.slice(6);
await message.reply(text);
}
});Button Interaction
client.on("messageCreate", async (message) => {
if (message.components && message.components.length > 0) {
// Click first button
await message.clickButton();
// Click button by index
await message.clickButton(1);
// Click button by custom ID
await message.clickButton("confirm_button");
}
});Fetching Messages
const channel = await client.fetchChannel("CHANNEL_ID");
const messages = await channel.fetchMessages({ limit: 50 });
console.log(`Fetched ${messages.length} messages`);Webhook Usage
const { WebhookClient } = require("discord-self-lite");
// Create webhook client
const webhook = new WebhookClient("YOUR_WEBHOOK_URL", {
username: "My Bot",
avatarURL: "https://example.com/avatar.png",
});
// Send simple message
await webhook.send("Hello from webhook!");
// Send with embed
const embed = WebhookClient.createEmbed({
title: "Test Embed",
description: "This is a test embed",
color: 0x00ff00,
fields: [
{ name: "Field 1", value: "Value 1", inline: true },
{ name: "Field 2", value: "Value 2", inline: true },
],
});
await webhook.send("Check out this embed!", { embeds: [embed] });
// Send object payload (new flexible way)
await webhook.send({
content: "Multiple embeds!",
embeds: [embed1, embed2],
username: "Multi-Embed Bot",
});
// Send just embeds
await webhook.send({ embeds: [embed] });
// Send array of embeds
await webhook.send([embed1, embed2]);Important Notes
⚠️ Selfbots are against Discord's Terms of Service
This library is for educational purposes only. Using selfbots can result in account termination. Use at your own risk.
