Skip to content

Instantly share code, notes, and snippets.

@supershadoe
Created August 29, 2022 21:11
Show Gist options
  • Save supershadoe/cd3ced74ffb1ef1b4e4dbafe85a4d5e0 to your computer and use it in GitHub Desktop.
Save supershadoe/cd3ced74ffb1ef1b4e4dbafe85a4d5e0 to your computer and use it in GitHub Desktop.
Hosting a discord bot on termux using hikari
  • Disable battery optimization for termux
  • Install termux:widgets plugin from GitHub (optional)
  • Install python and git using pkg i python git
  • Install virtualenv using system pip
  • Clone your bot's code or copy it from your device storage by first setting up file access using termux-setup-storage.
  • Create a venv for your project
  • Install all dependencies including hikari using the venv pip

Do not install uvloop as that doesn't work well with termux.

  • Now, try running your bot. If it works, then you can follow the optional instructions.

Optional instructions for better startup of bot

Make sure that termux:widgets is installed.

Look up the relevant linux commands by yourself. You should atleast know basic shell navigation and how ton use a console based text editor to use termux.

  • Create a .shortcuts folder and icons folder inside it.
  • Copy your bot's discord avatar and place it in icons folder (by copying from storage/downloads).
  • Now, make a shell script with the name of your bot alone and make it executable by chmod. Here, add initialization code for the bot with the shebang at the top of file as #!/data/data/com.termux/files/usr/bin/sh
  • Now go to your home screen and long press to add a widget -> Select termux:widgets -> Select your shell script for bot init.

Now you have a custom icon on homescreen which you can tap on to turn on your bot with a single tap. This is extremely useful in case of aggressive app killers like Samsung. (even with battery opt off for termux)

@Matthiasarther254
Copy link

Good

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