How to Discord JavaScript Console

Anika Tabassum Era Feb 15, 2024
How to Discord JavaScript Console

Discord is a social messaging platform where countless people interact every day. But this interaction is possible through the interface that has been appointed.

Other than that, the main functions are run in the back. In this section, we will try to send a typical text message to a recipient through the console panel with JavaScript.

Use JavaScript Console to Message in Discord Inbox

For this experiment, we will choose Discord to open in the browser. We will initially select a recipient and grab the user_id/ channel_id/ server_id.

While selecting a receiver and going to the inbox, you will find many digits in the rear portion of the URL. That specific number is the user_id or equivalent.

The user_id can be retrieved by going to Settings -> Advanced -> Enable Developer Mode. Then go to your profile and hit the option ... to copy the id.

Let’s store the id in a different place.

The next job is to send a message via the Discord interface. After sending the message, open up the Developer Tools section by pressing F12.

When the Inspect section opens, go to the Network segment. There will be some sessions created already.

So, pick the latest (the bottom one usually) named message and click on that. A panel pops up right below with the title header.

Click header, and after searching, you will find the Request Header having the authorization and its value.

Save it for the next steps. Let’s check the images.

Discord URL

Developer Tools

Now we will open the console and add the authorization code as the token. It is good to clear all the verification processes that require logging in to the Discord profile.

You can disable all the security issues. Else it might create a problem for accessing the account.

We will add the receiver user_id in our console code and pass the URL. Let’s jump to the code with the necessary Request Headers.

Code Snippet:

message = 'Hi!';

token = 'Nzk0O...some_string';

channel_id = '84...some_digits';

channel_url = `https://discord.com/api/v9/channels/${channel_id}/messages`

request = new XMLHttpRequest();
request.withCredentials = true;
request.open('POST', channel_url);
request.setRequestHeader('authorization', token);
request.setRequestHeader('accept', '/');
request.setRequestHeader('authority', 'discord.com');
request.setRequestHeader('content-type', 'application/json');
request.send(JSON.stringify({content: message}));

Output:

Discord Message

Thus, we can also send messages to Discord inboxes via JavaScript consoles. The main facts are the token, URL, and recipient user_id.

If you do not select the receiver from your friend list, you will get a 404 error describing the id as unknown.

Anika Tabassum Era avatar Anika Tabassum Era avatar

Era is an observer who loves cracking the ambiguos barriers. An AI enthusiast to help others with the drive and develop a stronger community.

LinkedIn Facebook

Related Article - JavaScript Console