+ 4

How to make bots for Discord from mobile

Hello, I want to make a mobile bot for Discord. With Termux I could keep the bot online, but when I turn off termux, it stays afk. How can I make it always active?

16th Apr 2023, 11:33 AM
nurgüll
nurgüll - avatar
24 Réponses
+ 4
Have you tried python for making discord bots? https://realpython.com/how-to-make-a-discord-bot-python/ https://www.youtube.com/watch?v=2k9x0s3awss Replit is great for making those bots. I have used it before, and it worked.
16th Apr 2023, 11:38 AM
Ugulberto Sánchez
Ugulberto Sánchez - avatar
+ 3
Its basically the same wether you use javascript or python. Take a look at my code starting from the bottom from bot.connect method call. 1. It opens the websocket connection and starts listening for op codes using the "onmessage" method. You can see the opcode if statements there. 2. After the websocket connection, discord sends us a "hello" response. We can identify this from the opcode which is 10. The "hello" response includes a interval which we need to use to send heartbeats. You can see how I start the heartbeat in the "op == 10" if statement. 2. After we get the "hello" response, we need to send "identify" request right awat. This is also done withint the same "if(op == 10)" if statement. 3. After the identify request. We will get events from the discord. Events opcode is always 0. The first event after sending the "identify" request is "ready" event. You can see how i add event listeners using "bot.on()" method. heres the code https://github.com/Tonyy18/dcbotting/blob/master/src/static/js/bot.js
16th Apr 2023, 5:19 PM
Toni Isotalo
Toni Isotalo - avatar
+ 2
Hey 👋, I advise you to use replit it is a free website where you can deploy the code... Well do some research if you have something important or like a key how to avoid it been discoverable... The code you put in replit is discoverable so people can see your code so any api key should be put in the safe file... Try to find some tutorial about it in YouTube... + I heard you are confused in between to use python or javascript... I would choose Javascript due to it is fast & asynchronous (can run many line of code at same time) ... Steps :-> 1. Create Account on Replit 2. Do some research to keep safe your api key & Change the code according to it 3. Dump your code in Replit & click Run 4. Enjoy your bot active till the last breath of Replit Server
17th Apr 2023, 9:05 AM
Sourik Ghosh
Sourik Ghosh - avatar
+ 2
Hi nurgüll , So you can use two platforms 1. Heroku 2. Replit So, Let's see them each... 1. Heroku Pros :- - Free - No one can access your code (well only you can access your code & shared ones). Cons :- - Git Version control (will charge money after some builds of the newer projects) - GitHub direct Deploy (Preferably not to use [will charge money after some builds of the newer projects]) - It will be difficult to deploy your code. - It is limited to a certain amount of projects to be deployed. 2. Replit Pros :- - Free - Collaborating is easy live Collaborating - To Deploy is easy just you can copy paste the code - Git Version control - GitHub direct Deploy - Database is there to use - Can directly code in production - People suggest changes for security Cons :- - Code is public - Code can be revised by anyone and if containing a secret key then you are screwed(You can use .env file to save your own keys i.e. Api key, Secret key ) - People may take advantage of your code or create their own bot Get one
18th Apr 2023, 6:24 AM
Sourik Ghosh
Sourik Ghosh - avatar
+ 1
Uh no, I wanted to do it with JavaScript.
16th Apr 2023, 1:20 PM
nurgüll
nurgüll - avatar
+ 1
I want to add more fun commands, not moderation. Do you think I should do it with Python or JavaScript?
16th Apr 2023, 1:21 PM
nurgüll
nurgüll - avatar
+ 1
Python is easier I think. You should use python for that
16th Apr 2023, 2:20 PM
Ugulberto Sánchez
Ugulberto Sánchez - avatar
+ 1
https://code.sololearn.com/W8E7lyx8XpMQ/?ref=app Create new application at https://discord.com/developers/applications from the left sidebar click "Bot". Next to the bot profile picture you can see your api token
16th Apr 2023, 9:11 PM
Toni Isotalo
Toni Isotalo - avatar
+ 1
Sourik Ghosh Thanks a lot, I hope I can find a way to keep it safe..
17th Apr 2023, 10:29 AM
nurgüll
nurgüll - avatar
+ 1
Sourik Ghosh You said three, what's the other one?
18th Apr 2023, 7:00 AM
nurgüll
nurgüll - avatar
+ 1
3rd?
18th Apr 2023, 7:01 AM
Sourik Ghosh
Sourik Ghosh - avatar
+ 1
It is written at the beginning of your answer, of course, there may be a typo. :D
18th Apr 2023, 7:02 AM
nurgüll
nurgüll - avatar
+ 1
nurgüll Ya I was to add vercel but I don't know about it but it uses serverless functions so it will not be able to handle the continuation of that program it will stop it... So just pick one from the above comment 😅...
18th Apr 2023, 7:06 AM
Sourik Ghosh
Sourik Ghosh - avatar
+ 1
Sourik Ghosh I understood :D If I find a way to secure my codes I will choose Replit. Heroku never looked good .
18th Apr 2023, 7:26 AM
nurgüll
nurgüll - avatar
0
Well, thanks for the resources and help.. :)
16th Apr 2023, 3:08 PM
nurgüll
nurgüll - avatar
0
Your welcome… 👍😃
16th Apr 2023, 3:09 PM
Ugulberto Sánchez
Ugulberto Sánchez - avatar
0
Toni Isotalo I will use your code as an example, thank you :)) But I still don't understand how to fully activate the bot
16th Apr 2023, 7:50 PM
nurgüll
nurgüll - avatar
0
nurgüll it calls the "init()" function token with your api key which you get from discord developer portal
16th Apr 2023, 7:53 PM
Toni Isotalo
Toni Isotalo - avatar
0
You could basically run the whole application by cloning the repository and calling: 1. npm install 2. node app.js Before those you would need to have mysql running and run those .sql scripts under the db folder
16th Apr 2023, 7:56 PM
Toni Isotalo
Toni Isotalo - avatar
0
I will make you a better example by parsing out unused stuff from the provided code
16th Apr 2023, 7:58 PM
Toni Isotalo
Toni Isotalo - avatar