Skip to content

Instantly share code, notes, and snippets.

@rigwild
Last active April 9, 2022 20:37
Show Gist options
  • Save rigwild/28f5d9479e3e122070e27db84e104719 to your computer and use it in GitHub Desktop.
Save rigwild/28f5d9479e3e122070e27db84e104719 to your computer and use it in GitHub Desktop.
This has moved to https://github.com/rigwild/discord-self-bot-console --- A simple Discord Self-bot using console
// Due to some interest, I created a proper repo.
// Check it out! :)
// https://github.com/rigwild/discord-self-bot-console
@BryanBarrera
Copy link

BryanBarrera commented Jan 20, 2021

@SkellyM386 thanks so much, your update worked as expected. I appreciate this!

@DeadLyBro
Copy link

How can we send a message like Ping Pong?
User1: ping
We: pong

@rigwild
Copy link
Author

rigwild commented Jan 20, 2021

actually if we can i'd like to message you guys since your interested in client botting cause right now im working on a more nodejs version of a user/client bot thats similar to discord.js except that its a user bot and its got the ability to read all the json data that goes in and out requests and responses it can even using this example automatically get your user token and be able to accomplish more its just im just one person and i dont know the user api like rigwild does. the plan is to make this and then publish it as a package. and im not afraid of discord since their bot detection isn't that good.

I am not interested in doing full client botting right now, sorry. This is only intended to run small script manually from the console.

How can we send a message like Ping Pong?
User1: ping
We: pong

This is using HTTP queries, so there is no WebSocket event listener like in Discord.js. You can use api.getMessages and search for a message if you want.


Cleaned the thread a bit.

@DeadLyBro
Copy link

DeadLyBro commented Jan 20, 2021

This is using HTTP queries, so there is no WebSocket event listener like in Discord.js. You can use api.getMessages and search for a message if you want.

Yeah i want like this api.getMessages and post message but I don't know how to do it, can you tell me?

@rigwild
Copy link
Author

rigwild commented Jan 20, 2021

ok so @BryanBarrera so apparently im a dummy and the api for users is almost exactly the same as the discord api if not actually the same

It is indeed the same API. In fact, you can use the discord.js package with your user token (v11.3.2 and below though, they deprecated user token support starting v11.4.0).

@eschanze
Copy link

Hello,
First of all, thanks for this resource.
I wanted to know how to loop through the messages once you call getMessages; any help would be appreciated.
Thanks in advance.

@DeadLyBro
Copy link

DeadLyBro commented Feb 23, 2021

Hello,
First of all, thanks for this resource.
I wanted to know how to loop through the messages once you call getMessages; any help would be appreciated.
Thanks in advance.

I wan't know too. Please help us guys.

@DeadLyBro
Copy link

I don't understand: send a message. Can you help me

setup = async () => {
  // Send a message
  const test2 = await api.sendMessage('your-channel-id-here', 'your-message-here')
  console.log(test2)
  await delay(3000)
}
setup()

edit your-channel-id-here and your-message-here and send with console.

@beppe9000
Copy link

beppe9000 commented Feb 23, 2021

is there a way to obtain the authtoken programmatically in javascript ? anyone knows how it's stored ?
also, can this be used on discord's website too ?

@Minigugus
Copy link

is there a way to obtain the authtoken programmatically in javascript ? anyone knows how it's stored ?
also, can this be used on discord's website too ?

Discord don't really want users to automate theirs accounts... More than a year ago the authentication token was just stored in the localStorage, which means it was pretty easy to get. But due to its success, their found a way to remove the token while the app is open, and even remove the global localStorage object to make sure it cannot be accessed via the console. Too many users got their tokens stolen with this technique.

Another solution, a bit hacky, maybe be to hook the fetch (or XMLHTTPRequest) function to intercept the Authorization header, but it still require the app to send a request, and it wont work if they keep a local copy of the fetch function.

I wanted to know how to loop through the messages once you call getMessages; any help would be appreciated.

Functions like sendMessages and so on here just call the API as defined on the Discord website, e.g. https://discord.com/developers/docs/resources/channel#get-channel-messages. They use a filter mechanism based on a reference id to handle pagination, so you have to get for instance the 50 latest messages, that start again by passing the lowest (oldest) message id as the before parameter, and so on. But I'm not sure it works indefinitely, and I assume their abuse system is aware about that...

@Omar-Aljohani
Copy link

Omar-Aljohani commented Apr 26, 2021

Can I make this script fetch a message like if someone sent ping I replay pong?
a script start when the event new message in a channel occurs gets the message and makes the message.content == "ping"
and if that happened I start the function api.sendMessage('channel_id', 'pong')

@rigwild
Copy link
Author

rigwild commented Apr 26, 2021

@5rbsh518 this does not support the WebSocket events API.
You can try to check the recent messages using api.getMessages every x seconds and check if a message start with pong.

@Omar-Aljohani
Copy link

Omar-Aljohani commented Apr 26, 2021

Wouldn't that get me banned if I requested messages every 1 second or 2 seconds?

I will request a maximum of 5 messages if I'll spam it

@rigwild
Copy link
Author

rigwild commented Apr 26, 2021

I don't know, maybe. I have used this script multiple times in the past to delete 100k+ messages of mine accross private messages and servers and never got banned.
But I can't garantee anything.

@varshithmee
Copy link

Hi, I have no experience with JS and so I am unable to debug it. I tried using the script on console and I am getting an error saying 'delay is not defined'.

@beppe9000
Copy link

I am looking at ways to extract the auth token by a web extension...

@rigwild
Copy link
Author

rigwild commented Jun 13, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment