How to host your Discord bot 24/7 on an Android Device

Was about to say this lol.

Why would you use an emulator to host a discord bot when you can do it natively?

7 Likes

If you were hell-bent on hosting on Android, you could use an emulator. Otherwise, no reason ¯_ツ)_/¯

2 Likes

When i use cd /storage/emulated/0/DiscordBOT
It says its not a directory, and i cant figure out why it says that

You need to make the directory first!

mkdir -p /storage/emulated/0/DiscordBOT
3 Likes

(I know this is 8 days old, but still)

Would this belong in #tutorials?

1 Like

Defiantly it’s not a glitch project. Also it would be cool if there was a way to sync the android version with the glitch version using git

Well, you could turn your phone into a git repo (via command line or an app like this) and then use git hooks to restart your bot.

I have been struggling for about 2 hours and I’m extremely frustrated I have done all the steps properly and I’m extremely confused EVERYTIME I do node index.js this displays I’ve tried to do mkdir -p /storage/emulated/0/DiscordBOT and cd /storage/emulated/0/DiscordBOT then bot NOTHING IS WORKING PLEASE HELP

npm i discord.js

1 Like

You want me to try npm i discord.js ?

1 Like

Omg npm install discord.js worked thanks so much

1 Like

One thing that could be added is how to set it up with PM2 for easier restarts, starts, reloads, etc.

How would I do that? I’m a rookie to javascript and ofc discordjs but what is pm2 and how do I use it?

PM2 is a production process manager for Node.js applications with a built-in load balancer. It allows you to keep applications alive forever, to reload them without downtime and to facilitate common system admin tasks.

Also, I was asking if @Daw588 might add this to his post.

3 Likes

Oh that sounds cool I’ll look it up to see if I can add it to my bot thank you

No, sorry for the confusion, I wasn’t meaning to talk to you that’s my bad and I should have made that more clear.

I was meaning that JavaScript (the user) could use PM2 instead of using only node so processes could be managed more easily.

Edit: I accidentally said “cleaning” instead of “meaning” lol.

1 Like

Ummm is there anyway to install sequelize and sqlite3 on termux let me know Cuse I am making a currency bot please help

Helpful Note: Android uses Linux which means you should be able to run tons of different commands and if you ever wanna take a look at the Android source code (and contribute if you want to) go here: https://source.android.com/

But when I do
cd ~ then npm install sequelize it works when i return to my bot file using cd /storage/emulated/0/DiscordBOT and use nodemon it says

[nodemon] 2.0.4
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node bot.js`
internal/modules/cjs/loader.js:1032
  throw err;
  ^

Error: Cannot find module 'sequelize'
Require stack:
- /storage/emulated/0/discordBOT/dbObjects.js
- /storage/emulated/0/discordBOT/server.js
- /storage/emulated/0/discordBOT/bot.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1029:15)
    at Function.Module._load (internal/modules/cjs/loader.js:898:27)
    at Module.require (internal/modules/cjs/loader.js:1089:19)
    at require (internal/modules/cjs/helpers.js:73:18)
    at Object.<anonymous> (/storage/emulated/0/discordBOT/dbObjects.js👍19)
    at Module._compile (internal/modules/cjs/loader.js:1200:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
    at Module.load (internal/modules/cjs/loader.js:1049:32)
    at Function.Module._load (internal/modules/cjs/loader.js:937:14)
    at Module.require (internal/modules/cjs/loader.js:1089:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/storage/emulated/0/discordBOT/dbObjects.js',
    '/storage/emulated/0/discordBOT/server.js',
    '/storage/emulated/0/discordBOT/bot.js'
  ]
}
[nodemon] app crashed - waiting for file changes before starting...```