### Install discord.js-selfbot-v13 Source: https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/README.md Installs the latest version of the discord.js-selfbot-v13 package using npm. Requires Node.js 20.18.0 or newer. ```sh-session npm install discord.js-selfbot-v13@latest ``` -------------------------------- ### Basic Discord Selfbot Client Initialization Source: https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/README.md Initializes a Discord selfbot client using discord.js-selfbot-v13. This example demonstrates how to log in with a token and log a message when the client is ready. ```javascript const { Client } = require('discord.js-selfbot-v13'); const client = new Client(); client.on('ready', async () => { console.log(`${client.user.username} is ready!`); }) client.login('token'); ``` -------------------------------- ### Handle Messages and Send Responses (JavaScript) Source: https://context7.com/aiko-chan-ai/discord.js-selfbot-v13/llms.txt Shows how to handle incoming messages using the `messageCreate` event. Includes examples for simple replies, sending embeds, attachments, and reacting to messages. Ignores messages from the selfbot itself. ```javascript const { Client, MessageEmbed, MessageAttachment } = require('discord.js-selfbot-v13'); const client = new Client(); client.on('messageCreate', async (message) => { // Ignore own messages if (message.author.id === client.user.id) return; // Simple reply if (message.content === 'ping') { await message.reply('pong'); } // Send embed if (message.content === '!info') { const embed = new MessageEmbed() .setTitle('Information') .setDescription('This is an embedded message') .setColor('#0099ff') .addField('Field 1', 'Value 1', true) .addField('Field 2', 'Value 2', true) .setTimestamp(); await message.channel.send({ embeds: [embed] }); } // Send with attachment if (message.content === '!file') { const attachment = new MessageAttachment('./image.png', 'image.png'); await message.channel.send({ files: [attachment] }); } // React to message if (message.content.includes('hello')) { await message.react('👋'); } }); client.login('token'); ``` -------------------------------- ### OAuth2 and Application Authorization with discord.js-selfbot-v13 Source: https://context7.com/aiko-chan-ai/discord.js-selfbot-v13/llms.txt Explains how to authorize applications, install user-installable apps, retrieve a list of authorized applications, and deauthorize applications using their ID or token ID. Requires a valid bot token and application IDs. ```javascript const { Client } = require('discord.js-selfbot-v13'); const client = new Client(); client.on('ready', async () => { // Authorize a bot/application const authUrl = 'https://discord.com/api/oauth2/authorize?client_id=BOT_ID&permissions=8&scope=bot'; const result = await client.authorizeURL(authUrl, { guild_id: 'target_guild_id', permissions: '8', authorize: true, }); console.log('Authorization redirect:', result.location); // Install user apps (user-installable applications) await client.installUserApps('application_id'); // Get authorized applications const authorizedApps = await client.authorizedApplications(); authorizedApps.forEach((app) => { console.log(`App: ${app.application.name}`); console.log(`Scopes: ${app.scopes.join(', ')}`); }); // Deauthorize an application await client.deauthorize('application_id', 'application'); // Or by token ID await client.deauthorize('token_id', 'token'); }); client.login('token'); ``` -------------------------------- ### Basic Slash Command Source: https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/examples/SlashCommand.md Example of sending a simple slash command without any sub-commands or arguments. ```APIDOC ## Basic Slash Command ### Description Demonstrates sending a basic slash command. ### Code ```javascript await channel.sendSlash('bot_id', 'aiko') ``` ``` -------------------------------- ### Slash Command with Attachment Source: https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/examples/SlashCommand.md Example of sending a slash command that includes a file attachment. ```APIDOC ## Slash Command with Attachment ### Description Demonstrates sending a slash command with a file attachment. ### Code ```javascript const { MessageAttachment } = require('discord.js-selfbot-v13') const fs = require('fs') const a = new MessageAttachment(fs.readFileSync('./wallpaper.jpg') , 'test.jpg') await message.channel.sendSlash('718642000898818048', 'sauce', a) ``` ``` -------------------------------- ### Slash Command with Complex Arguments and Modal Handling Source: https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/examples/SlashCommand.md Example of sending a slash command with multiple string choices, undefined arguments, and handling the modal response. ```APIDOC ## Slash Command with Complex Arguments and Modal Handling ### Description Demonstrates sending a slash command with various argument types and handling modal interactions. ### Code ```javascript const channel = client.channels.cache.get('channel_id'); const response = await channel.sendSlash( 'bot_id', 'image make', 'MeinaMix - v11', 'Phone (9:16) [576x1024 | 810x1440]', '2', // String choices, not number undefined, // VAE undefined, // sdxl_refiner undefined, // sampling_method, 30, ); // Submit Modal if (!response.isMessage) { // Modal response.components[0].components[0].setValue( '1girl, brown hair, green eyes, colorful, autumn, cumulonimbus clouds', ); response.components[1].components[0].setValue( '(worst quality:1.4), (low quality:1.4), (normal quality:1.4), (ugly:1.4), (bad anatomy:1.4), (extra limbs:1.2), (text, error, signature, watermark:1.2), (bad legs, incomplete legs), (bad feet), (bad arms), (bad hands, too many hands, mutated hands), (zombie, sketch, interlocked fingers, comic, morbid), cropped, long neck, lowres, missing fingers, missing arms, missing legs, extra fingers, extra digit, fewer digits, jpeg artifacts', ); await response.reply(); } ``` ``` -------------------------------- ### Handling Bot Thinking State and Receiving Final Message Source: https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/examples/SlashCommand.md Example of how to handle cases where the bot indicates it's thinking and then waits for the final message update. ```APIDOC ## Handling Bot Thinking State and Receiving Final Message ### Description This snippet shows how to manage the 'bot is thinking...' state and asynchronously wait for the final message after a slash command. ### Code ```javascript const channel = client.channels.cache.get('id'); channel .sendSlash('289066747443675143', 'osu', 'Accolibed') .then(async (message) => { if (message.flags.has('LOADING')) { // owo is thinking... return new Promise((resolve, reject) => { let done = false; const timeout = setTimeout(() => { if (!done) { done = true; client.off('messageUpdate', onUpdate); reject('timeout'); } }, 15 * 60 * 1000); // 15m (DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE) function onUpdate(_, m) { if (_.id === message.id) { if (!done) { done = true; clearTimeout(timeout); client.off('messageUpdate', onUpdate); resolve(m); } } } client.on('messageUpdate', onUpdate); }); } else { return Promise.resolve(message); } }) .then(console.log); ``` ``` -------------------------------- ### Send Slash Command with Multiple Options and Handle Modal Response in discord.js-selfbot-v13 Source: https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/examples/SlashCommand.md Provides an example of sending a slash command with numerous arguments, including string choices and undefined values for optional parameters. It also demonstrates how to interact with a modal that is presented as a response, setting values and submitting it. ```javascript const channel = client.channels.cache.get('channel_id'); const response = await channel.sendSlash( 'bot_id', 'image make', 'MeinaMix - v11', 'Phone (9:16) [576x1024 | 810x1440]', '2', // String choices, not number undefined, // VAE undefined, // sdxl_refiner undefined, // sampling_method, 30, ); // Submit Modal if (!response.isMessage) { // Modal response.components[0].components[0].setValue( '1girl, brown hair, green eyes, colorful, autumn, cumulonimbus clouds', ); response.components[1].components[0].setValue( '(worst quality:1.4), (low quality:1.4), (normal quality:1.4), (ugly:1.4), (bad anatomy:1.4), (extra limbs:1.2), (text, error, signature, watermark:1.2), (bad legs, incomplete legs), (bad feet), (bad arms), (bad hands, too many hands, mutated hands), (zombie, sketch, interlocked fingers, comic, morbid), cropped, long neck, lowres, missing fingers, missing arms, missing legs, extra fingers, extra digit, fewer digits, jpeg artifacts', ); await response.reply(); } ``` -------------------------------- ### Slash Command with Sub Command / Sub Group Source: https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/examples/SlashCommand.md Example of sending a slash command that utilizes sub-commands or sub-groups. ```APIDOC ## Slash Command with Sub Command / Sub Group ### Description Demonstrates sending a slash command with sub-commands or sub-groups. ### Code ```javascript await channel.sendSlash('450323683840491530', 'animal chat', 'bye') ``` ``` -------------------------------- ### Utilize Utility Functions in discord.js-selfbot-v13 Source: https://context7.com/aiko-chan-ai/discord.js-selfbot-v13/llms.txt Perform various common operations using utility methods available on the client instance. This snippet shows how to use sleep/delay, fetch webhooks, stickers, sticker packs, voice regions, and guild templates, as well as refresh attachment URLs, redeem Nitro codes, check client readiness, get uptime, and retrieve the session ID. ```javascript const { Client } = require('discord.js-selfbot-v13'); const client = new Client(); client.on('ready', async () => { // Sleep/delay function await client.sleep(5000); // Wait 5 seconds // Fetch webhook const webhook = await client.fetchWebhook('webhook_id', 'webhook_token'); console.log(`Webhook: ${webhook.name}`); // Fetch sticker const sticker = await client.fetchSticker('sticker_id'); console.log(`Sticker: ${sticker.name}`); // Fetch premium sticker packs const packs = await client.fetchPremiumStickerPacks(); console.log(`Sticker packs: ${packs.size}`); // Fetch voice regions const regions = await client.fetchVoiceRegions(); console.log(`Voice regions: ${regions.map((r) => r.name).join(', ')}`); // Fetch guild template const template = await client.fetchGuildTemplate('https://discord.new/template_code'); console.log(`Template: ${template.name}`); // Refresh attachment URLs const refreshed = await client.refreshAttachmentURL( 'https://cdn.discordapp.com/attachments/...' ); console.log(`Refreshed URL: ${refreshed[0].refreshed}`); // Redeem Nitro code try { await client.redeemNitro('https://discord.gift/CODE', 'channel_id'); } catch (error) { console.log('Nitro redemption failed:', error.message); } // Check if client is ready console.log(`Client ready: ${client.isReady()}`); // Get uptime console.log(`Uptime: ${client.uptime}ms`); // Get session ID console.log(`Session ID: ${client.sessionId}`); }); client.login('token'); ``` -------------------------------- ### Initialize and Login Discord Client (JavaScript) Source: https://context7.com/aiko-chan-ai/discord.js-selfbot-v13/llms.txt Demonstrates how to initialize the Discord client and log in using a user token. Includes options for CAPTCHA solving and TOTP authentication. Requires Node.js 20.18.0+. ```javascript const { Client } = require('discord.js-selfbot-v13'); // Basic client initialization const client = new Client(); // Client with options const clientWithOptions = new Client({ // CAPTCHA solver for joining protected guilds captchaSolver: function(captcha, UA) { return solver.hcaptcha(captcha.captcha_sitekey, 'discord.com', { invisible: 1, userAgent: UA, data: captcha.captcha_rqdata, }).then(res => res.data); }, captchaRetryLimit: 3, // TOTP key for 2FA login TOTPKey: 'YOUR_TOTP_SECRET_KEY', }); // Login with token client.on('ready', async () => { console.log(`${client.user.username} is ready!`); console.log(`Logged in as ${client.user.tag}`); console.log(`In ${client.guilds.cache.size} guilds`); }); client.login('your-discord-token'); // Token can also be set via DISCORD_TOKEN environment variable ``` -------------------------------- ### Basic Discord Bot Event Handling in JavaScript Source: https://github.com/aiko-chan-ai/discord.js-selfbot-v13/wiki/Home This JavaScript snippet demonstrates how to set up a basic discord.js selfbot. It logs into a Discord account using a token, logs a 'ready' message to the console, and replies 'pong' to messages containing 'ping'. It requires the 'discord.js' library. ```javascript const Discord = require('discord.js'); const client = new Discord.Client(); client.on('ready', () => { console.log(`Logged in as ${client.user.tag}!`); }); client.on('messageCreate', msg => { if (msg.content === 'ping') { msg.reply('pong'); } }); client.login('token'); ``` -------------------------------- ### Join Voice Channel and Play Audio with discord.js-selfbot-v13 Source: https://context7.com/aiko-chan-ai/discord.js-selfbot-v13/llms.txt Demonstrates how to join a voice channel, play audio from a YouTube URL, control volume, pause/resume playback, and disconnect using discord.js-selfbot-v13. Requires `@distube/ytdl-core` for YouTube playback. ```javascript const { Client } = require('discord.js-selfbot-v13'); const ytdl = require('@distube/ytdl-core'); const client = new Client(); client.on('ready', async () => { const channel = client.channels.cache.get('voice_channel_id'); // Join voice channel const connection = await client.voice.joinChannel(channel, { selfMute: false, selfDeaf: true, selfVideo: false, }); // Play audio from YouTube const dispatcher = connection.playAudio( ytdl('https://www.youtube.com/watch?v=video_id', { quality: 'highestaudio' }) ); dispatcher.on('start', () => { console.log('Audio playing!'); // Volume control (0.0 to 1.0) dispatcher.setVolume(0.5); // Pause/Resume dispatcher.pause(); setTimeout(() => dispatcher.resume(), 5000); }); dispatcher.on('finish', () => console.log('Audio finished')); dispatcher.on('error', console.error); // Disconnect after 30 seconds setTimeout(() => connection.disconnect(), 30000); }); client.login('token'); ``` -------------------------------- ### Guild Operations with discord.js-selfbot-v13 Source: https://context7.com/aiko-chan-ai/discord.js-selfbot-v13/llms.txt Demonstrates how to join guilds using invite codes, bypass onboarding and verification steps, and fetch guild preview information. It also shows how to access guild members. Requires a valid Discord invite code and bot token. ```javascript const { Client } = require('discord.js-selfbot-v13'); const client = new Client(); client.on('ready', async () => { // Fetch invite information const invite = await client.fetchInvite('https://discord.gg/invitecode'); console.log(`Invite to: ${invite.guild.name}`); console.log(`Members: ${invite.memberCount}`); // Join a guild with invite const guild = await client.acceptInvite('https://discord.gg/invitecode', { bypassOnboarding: true, // Auto-complete onboarding bypassVerify: true, // Auto-accept rules }); console.log(`Joined guild: ${guild.name}`); // Fetch guild preview const preview = await client.fetchGuildPreview('guild_id'); console.log(`Guild: ${preview.name}, Emoji count: ${preview.emojis.size}`); // Access guild members const members = await guild.members.fetch(); console.log(`Total members fetched: ${members.size}`); }); client.login('token'); ``` -------------------------------- ### Client User Profile Management with discord.js-selfbot-v13 Source: https://context7.com/aiko-chan-ai/discord.js-selfbot-v13/llms.txt Shows how to manage a Discord user's profile, including setting the username, avatar, banner, bio, pronouns, accent color, and HyperSquad house. It also covers creating and fetching friend invites, checking burst credits, and setting a Samsung activity presence. Requires a valid bot token and potentially Nitro for banner settings. Username changes are rate-limited. ```javascript const { Client } = require('discord.js-selfbot-v13'); const client = new Client(); client.on('ready', async () => { // Set avatar await client.user.setAvatar('./avatar.png'); // Set banner (requires Nitro) await client.user.setBanner('./banner.png'); // Set username (rate limited - 2 per hour) await client.user.setUsername('NewUsername', 'current_password'); // Set global display name await client.user.setGlobalName('Display Name'); // Set about me / bio await client.user.setAboutMe('Hello! This is my bio.'); // Set pronouns await client.user.setPronouns('they/them'); // Set accent color await client.user.setAccentColor('#FF5733'); // Set HyperSquad house // 0 = Leave, 1 = Bravery, 2 = Brilliance, 3 = Balance await client.user.setHypeSquad('HOUSE_BRAVERY'); // Create friend invite const friendInvite = await client.user.createFriendInvite(); console.log(`Friend invite: discord.gg/${friendInvite.code}`); // Get all friend invites const invites = await client.user.getAllFriendInvites(); console.log(`Active friend invites: ${invites.size}`); // Check burst credits (Super Reactions) const credits = await client.user.fetchBurstCredit(); console.log(`Burst credits: ${credits}`); // Samsung Galaxy presence await client.user.setSamsungActivity('com.game.package', 'START'); }); client.login('token'); ``` -------------------------------- ### Set Rich Presence, Custom Status, and Spotify Activity with discord.js-selfbot-v13 Source: https://context7.com/aiko-chan-ai/discord.js-selfbot-v13/llms.txt This snippet demonstrates how to set a custom presence for a Discord user, including Rich Presence for games, a Custom Status with emojis, and a Spotify listening activity. It utilizes classes like RichPresence, CustomStatus, and SpotifyRPC from the discord.js-selfbot-v13 library. The presence can include various details like game name, state, timestamps, assets, and buttons. Multiple activities can be displayed simultaneously. It also shows how to set a simple activity and status. ```javascript const { Client, RichPresence, CustomStatus, SpotifyRPC } = require('discord.js-selfbot-v13'); const client = new Client(); client.on('ready', async () => { // Get external image URL for Rich Presence const externalAssets = await RichPresence.getExternal( client, '367827983903490050', // Application ID 'https://example.com/image.jpg' ); // Rich Presence (Game activity) const richPresence = new RichPresence(client) .setApplicationId('367827983903490050') .setType('PLAYING') .setName('Game Name') .setState('In Game') .setDetails('Playing Level 5') .setParty({ max: 8, current: 1 }) .setStartTimestamp(Date.now()) .setAssetsLargeImage(externalAssets[0].external_asset_path) .setAssetsLargeText('Large Image Text') .setAssetsSmallImage('373370493127884800') .setAssetsSmallText('Small Image Text') .setPlatform('desktop') .addButton('Join Game', 'https://example.com/join'); // Custom Status with emoji const customStatus = new CustomStatus(client) .setEmoji('😎') .setState('Coding something cool'); // Spotify RPC (Listening activity) const spotify = new SpotifyRPC(client) .setAssetsLargeImage('spotify:ab67616d00001e02768629f8bc5b39b68797d1bb') .setAssetsSmallImage('spotify:ab6761610000f178049d8aeae802c96c8208f3b7') .setAssetsLargeText('Album Name') .setState('Artist Name') .setDetails('Song Title') .setStartTimestamp(Date.now()) .setEndTimestamp(Date.now() + 1000 * 180) // 3 minutes .setSongId('spotify_song_id') .setAlbumId('spotify_album_id') .setArtistIds('artist_id_1', 'artist_id_2'); // Set all activities client.user.setPresence({ activities: [richPresence, customStatus, spotify], status: 'online' // online, idle, dnd, invisible }); // Simple status change client.user.setStatus('idle'); // Simple activity client.user.setActivity('discord.js', { type: 'WATCHING' }); }); client.login('token'); ``` -------------------------------- ### Create and Send Hidden URL Embeds (JavaScript) Source: https://context7.com/aiko-chan-ai/discord.js-selfbot-v13/llms.txt Illustrates the use of `WebEmbed` to create embeds with hidden URLs, which display rich content like images and videos. Demonstrates sending embeds directly or with a hidden embed URL. Requires the `discord.js-selfbot-v13` library. ```javascript const { Client, WebEmbed } = require('discord.js-selfbot-v13'); const client = new Client(); client.on('messageCreate', async (message) => { if (message.content === 'embed') { const embed = new WebEmbed() .setAuthor({ name: 'Author Name', url: 'https://google.com' }) .setColor('RED') .setDescription('This is the embed description') .setProvider({ name: 'Provider', url: 'https://google.com' }) .setTitle('Embed Title') .setURL('https://google.com') .setImage('https://i.ytimg.com/vi/example/maxresdefault.jpg') .setRedirect('https://www.youtube.com/watch?v=example') .setVideo('http://example.com/video.mp4'); // Send with hidden embed URL await message.channel.send({ content: `Check this out ${WebEmbed.hiddenEmbed}${embed}`, }); // Or send embed directly await message.channel.send({ content: `${embed}`, }); } }); client.login('token'); ``` -------------------------------- ### Proxy Configuration with discord.js-selfbot-v13 Source: https://context7.com/aiko-chan-ai/discord.js-selfbot-v13/llms.txt Details how to configure HTTP and WebSocket proxies for API requests and connections within the discord.js-selfbot-v13 client. It demonstrates setting up a WebSocket proxy using `proxy-agent` and an HTTP proxy via client options. Requires a valid proxy server address and bot token. ```javascript const { Client } = require('discord.js-selfbot-v13'); const { ProxyAgent } = require('proxy-agent'); // WebSocket proxy setup const wsProxy = new ProxyAgent({ getProxyForUrl: () => 'http://proxy.server:8080', }); const client = new Client({ ws: { agent: wsProxy, // WebSocket proxy }, http: { // API proxy (uses undici ProxyAgent) agent: 'http://my.proxy.server:8080', // Or as URL object // agent: new URL('http://my.proxy.server:8080'), // Or as options object // agent: { uri: 'http://my.proxy.server:8080' }, }, }); client.on('ready', () => { console.log(`Connected via proxy as ${client.user.tag}`); }); client.login('token'); ``` -------------------------------- ### Create and Vote on Polls with discord.js-selfbot-v13 Source: https://context7.com/aiko-chan-ai/discord.js-selfbot-v13/llms.txt Demonstrates creating polls with multiple options and handling vote events using discord.js-selfbot-v13. It includes sending a poll message, voting on specific answers, and listening for `messagePollVoteAdd` and `messagePollVoteRemove` events. ```javascript const { Client } = require('discord.js-selfbot-v13'); const client = new Client(); client.on('ready', async () => { const channel = client.channels.cache.get('channel_id'); // Create a poll const message = await channel.send({ poll: { question: { text: 'What is your favorite color?' }, answers: [ { text: 'Red', emoji: '🍎' }, { text: 'Green', emoji: '🥗' }, { text: 'Blue', emoji: '💙' }, { text: 'Yellow', emoji: '🟡' }, ], duration: 8, // Duration in hours allowMultiselect: true, // Allow multiple selections }, }); console.log('Poll created:', message.poll); // Vote on the poll (answer indices, 1-based) await message.vote(1, 3); // Vote for answers 1 and 3 }); // Handle poll vote events client.on('messagePollVoteAdd', (answer, userId) => { console.log(`User ${userId} voted for answer ${answer.id}`); }); client.on('messagePollVoteRemove', (answer, userId) => { console.log(`User ${userId} removed vote for answer ${answer.id}`); }); client.on('messageUpdate', async (oldMessage, newMessage) => { if (newMessage.poll) { console.log('Poll updated:', newMessage.poll); } }); client.login('token'); ``` -------------------------------- ### Stream Video to Voice Channel with discord.js-selfbot-v13 Source: https://context7.com/aiko-chan-ai/discord.js-selfbot-v13/llms.txt Shows how to join a voice channel with video codec settings and stream video content using discord.js-selfbot-v13. It supports screen sharing and plays video and audio streams separately. Requires ffmpeg for video processing. ```javascript const { Client } = require('discord.js-selfbot-v13'); const client = new Client(); client.on('ready', async () => { const channel = client.channels.cache.get('voice_channel_id'); // Join with video codec setting const connection = await client.voice.joinChannel(channel, { selfMute: true, selfDeaf: true, selfVideo: false, videoCodec: 'H264', }); // Create stream connection for screen sharing const stream = await connection.createStreamConnection(); const videoSource = 'http://example.com/video.mp4'; // Play video and audio separately const videoDispatcher = stream.playVideo(videoSource, { fps: 60, bitrate: 4000, }); const audioDispatcher = stream.playAudio(videoSource); videoDispatcher.on('start', () => console.log('Video playing!')); videoDispatcher.on('finish', () => console.log('Video finished')); videoDispatcher.on('error', console.error); audioDispatcher.on('start', () => console.log('Audio playing!')); audioDispatcher.on('finish', () => console.log('Audio finished')); audioDispatcher.on('error', console.error); // Pause both streams together // videoDispatcher.pause(); // audioDispatcher.pause(); }); client.login('token'); ``` -------------------------------- ### Execute Slash Commands with discord.js-selfbot-v13 Source: https://context7.com/aiko-chan-ai/discord.js-selfbot-v13/llms.txt This snippet shows how to execute slash commands from bots within text channels using discord.js-selfbot-v13. It covers basic command execution, commands with sub-commands and arguments, commands with attachments, and handling modal responses and deferred (loading) responses. The `sendSlash` method is used for sending commands, and it supports various options for arguments and response handling. ```javascript const { Client, MessageAttachment } = require('discord.js-selfbot-v13'); const client = new Client(); client.on('ready', async () => { const channel = client.channels.cache.get('channel_id'); // Basic slash command const response = await channel.sendSlash('bot_id', 'command_name'); // Slash command with sub-command await channel.sendSlash('bot_id', 'parent sub_command', 'argument1', 'argument2'); // Slash command with attachment const attachment = new MessageAttachment('./image.jpg', 'image.jpg'); await channel.sendSlash('bot_id', 'upload', attachment); // Slash command with optional arguments (use undefined to skip) await channel.sendSlash( 'bot_id', 'generate image', 'prompt text', // Required arg undefined, // Skip optional arg undefined, // Skip optional arg 30 // Provide later optional arg ); // Handle modal response const modalResponse = await channel.sendSlash('bot_id', 'modal_command'); if (!modalResponse.isMessage) { // Fill modal fields modalResponse.components[0].components[0].setValue('Input value 1'); modalResponse.components[1].components[0].setValue('Input value 2'); await modalResponse.reply(); } // Handle deferred response (bot is thinking...) channel.sendSlash('bot_id', 'slow_command').then(async (message) => { if (message.flags.has('LOADING')) { return new Promise((resolve, reject) => { const timeout = setTimeout(() => reject('timeout'), 15 * 60 * 1000); function onUpdate(oldMsg, newMsg) { if (oldMsg.id === message.id) { clearTimeout(timeout); client.off('messageUpdate', onUpdate); resolve(newMsg); } } client.on('messageUpdate', onUpdate); }); } return message; }).then(console.log); }); client.login('token'); ``` -------------------------------- ### Send Basic Slash Command with discord.js-selfbot-v13 Source: https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/examples/SlashCommand.md Demonstrates how to send a simple slash command to a channel using the `sendSlash` method. This is the most basic form of interaction, targeting a specific bot and command name. ```javascript await channel.sendSlash('bot_id', 'aiko') ``` -------------------------------- ### Handle Deferred Slash Command Responses (Loading State) in discord.js-selfbot-v13 Source: https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/examples/SlashCommand.md Explains how to handle slash command responses that initially appear as a 'loading' state (e.g., 'botname is thinking...'). It sets up a listener for message updates to capture the final resolved message, with a timeout to prevent indefinite waiting. ```javascript const channel = client.channels.cache.get('id'); channel .sendSlash('289066747443675143', 'osu', 'Accolibed') .then(async (message) => { if (message.flags.has('LOADING')) { // owo is thinking... return new Promise((resolve, reject) => { let done = false; const timeout = setTimeout(() => { if (!done) { done = true; client.off('messageUpdate', onUpdate); reject('timeout'); } }, 15 * 60 * 1000); // 15m (DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE) function onUpdate(_, m) { if (_.id === message.id) { if (!done) { done = true; clearTimeout(timeout); client.off('messageUpdate', onUpdate); resolve(m); } } } client.on('messageUpdate', onUpdate); }); } else { return Promise.resolve(message); } }) .then(console.log); ``` -------------------------------- ### Manage Discord Relationships with discord.js-selfbot-v13 Source: https://context7.com/aiko-chan-ai/discord.js-selfbot-v13/llms.txt Access and manage friends, blocked users, and friend requests using the relationships manager. This snippet demonstrates fetching all relationships, accessing different caches (friends, blocked, incoming, outgoing), setting friend nicknames, and retrieving relationship data as JSON. ```javascript const { Client } = require('discord.js-selfbot-v13'); const client = new Client(); client.on('ready', async () => { // Get all relationships await client.relationships.fetch(); // Access friends const friends = client.relationships.friendCache; console.log(`Friends: ${friends.size}`); friends.forEach((user) => { console.log(`- ${user.username}`); }); // Access blocked users const blocked = client.relationships.blockedCache; console.log(`Blocked: ${blocked.size}`); // Access incoming friend requests const incoming = client.relationships.incomingCache; console.log(`Incoming requests: ${incoming.size}`); // Access outgoing friend requests const outgoing = client.relationships.outgoingCache; console.log(`Outgoing requests: ${outgoing.size}`); // Set friend nickname await client.relationships.setNickname('user_id', 'Nickname'); // Get relationship data as JSON const relationshipData = client.relationships.toJSON(); console.log(relationshipData); }); client.login('token'); ``` -------------------------------- ### Send Voice Messages with discord.js-selfbot-v13 Source: https://context7.com/aiko-chan-ai/discord.js-selfbot-v13/llms.txt Illustrates how to send voice messages to a channel using discord.js-selfbot-v13. This involves creating a `MessageAttachment` with audio data and setting the `IS_VOICE_MESSAGE` flag. The audio file must be in `.ogg` format. ```javascript const { Client, MessageAttachment } = require('discord.js-selfbot-v13'); const client = new Client(); client.on('ready', async () => { const channel = client.channels.cache.get('channel_id'); // Create voice message attachment const voiceAttachment = new MessageAttachment( './audio.mp3', // Audio file path 'voice_message.ogg', // Must be .ogg extension { waveform: 'AAAAAAAAAAAA', // Base64 waveform data duration_secs: 5, // Duration in seconds } ); // Send as voice message await channel.send({ files: [voiceAttachment], flags: 'IS_VOICE_MESSAGE', }); }); client.login('token'); ``` -------------------------------- ### Retrieve Discord Token from Browser Console Source: https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/README.md A JavaScript snippet to be run in the Discord client's developer console (Ctrl+Shift+I) to retrieve the user's Discord token. This method is based on finding specific webpack modules and their `getToken` export. ```javascript window.webpackChunkdiscord_app.push([ [Symbol()], {}, req => { if (!req.c) return; for (let m of Object.values(req.c)) { try { if (!m.exports || m.exports === window) continue; if (m.exports?.getToken) return copy(m.exports.getToken()); for (let ex in m.exports) { if (m.exports?.[ex]?.getToken && m.exports[ex][Symbol.toStringTag] !== 'IntlMessagesProxy') return copy(m.exports[ex].getToken()); } } catch {} } }, ]); window.webpackChunkdiscord_app.pop(); console.log('%cWorked!', 'font-size: 50px'); console.log(`%cYou now have your token in the clipboard!`, 'font-size: 16px'); ``` -------------------------------- ### Send Slash Command with Attachment in discord.js-selfbot-v13 Source: https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/examples/SlashCommand.md Illustrates how to send a slash command that includes a file attachment. This involves reading a file from the local system and creating a `MessageAttachment` object to pass as an argument to `sendSlash`. ```javascript const { MessageAttachment } = require('discord.js-selfbot-v13') const fs = require('fs') const a = new MessageAttachment(fs.readFileSync('./wallpaper.jpg') , 'test.jpg') await message.channel.sendSlash('718642000898818048', 'sauce', a) ``` -------------------------------- ### TextBasedChannel.sendSlash Source: https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/examples/SlashCommand.md This method allows you to send slash commands to a specified channel. It supports various argument types, including strings, numbers, booleans, and file attachments. ```APIDOC ## POST /channels/{channel.id}/messages ### Description Sends a slash command to a text-based channel. ### Method POST ### Endpoint `/channels/{channel.id}/messages` ### Parameters #### Path Parameters - **channel.id** (Snowflake) - Required - The ID of the channel to send the command to. #### Query Parameters None #### Request Body - **user** (Snowflake | User) - Required - The ID of the bot or a User object (where User.bot === true). - **commandName** (string) - Required - The name of the command, potentially including sub-groups and sub-commands (e.g., 'command_name [sub_group] [sub]'). - **...args** (string|number|boolean|FileLike|undefined) - Optional - Additional arguments for the slash command. ### Request Example ```javascript await channel.sendSlash('bot_id', 'aiko') ``` ### Response #### Success Response (200) - **message** (Message | Modal) - The message object representing the sent command or a modal if the command requires one. #### Response Example ```json { "content": "Command sent successfully." } ``` ``` -------------------------------- ### Send Slash Command with Arguments (Sub Command/Group) in discord.js-selfbot-v13 Source: https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/examples/SlashCommand.md Shows how to send a slash command that includes arguments, potentially representing subcommands or sub-groups, along with additional string arguments. This allows for more complex command interactions. ```javascript await channel.sendSlash('450323683840491530', 'animal chat', 'bye') ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.