Skip to content

A containerized code execution webserver and discord bot.

License

Notifications You must be signed in to change notification settings

nickheyer/DiscoCode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

DiscoCode

image

Your friendly neighborhood containerized code execution web server and discord bot.

Safe and secure. Powered by Piston. Includes a REST API for code running, user admin, and database management.



General Requirements

Running the discord bot requires a discord developer account, and a bot created/invited (via your developer account) to your chosen discord server.


Installation (Recommended Method)

Linux (Fully Automated)

curl https://github.com/raw/nickheyer/DiscoCode/main/auto_install_update.sh -o auto_install_update.sh && sudo bash auto_install_update.sh

Other Operating Systems (Windows, Mac, etc.)

Download Docker Image (Recommended - x86_64 Architecture)
docker image pull nickheyer/discocode:latest
OR Download Docker Image (ARM64, aarch64 Architecture, ie: Raspberry-Pi, Mac M1, etc.)
docker image pull nickheyer/discocode_rpi:latest
Run Docker Container
docker run -d -p 6565:6565 --name discocode nickheyer/discocode
The server within the docker container can be accessed locally at http://127.0.0.1:6565


Installation From Source (Not Recommended)

Prerequisites, Dependencies, and Requirements

NOTE: Installation from source using Windows has been deprecated with the introduction of web-socket functionality, gevent, and other integral parts of this application that are not currently supported by Microsoft.

  1. Python - Download and install Python here. Make sure that you choose "Add Python to environmental variables" during installation.
  2. Git - Download and install Git here

Next Steps

  1. Change directory to preferred install location
cd /where/you/want/this/installed
  1. Clone DiscoCode
git clone https://github.com/nickheyer/DiscoCode
  1. Change directory to DiscoCode
cd ./discocode
  1. Install Requirements
pip install -r requirements.txt
  1. Run Migrations
python manage.py migrate
  1. Run DiscoCode
sh ./run.sh


General Instructions

Accessing The Web-UI

You will need to get the IP address of the computer hosting DiscoCode. On Windows, you would typically type ipconfig on the host machine and look for your ipv4.

If you would like to access DiscoCode remotely, as in not on the same network as the host machine, you will need to do some port forwarding to expose port 6565 to the internet. Run into trouble? Feel free to join the Discord!


Configuration

DiscoCode requires a small amount of configuration before you can begin making requests. Discord Token for example.


To get your Discord Token, go to the "bot" tab in your developer portal. You may need to click "reset Token" and/or enter authentication code if you have 2FA enabled. Make sure to enable all Privileged Gateway Intents)

Peek 2023-05-22 22-06

If you haven't already, now is also a good time to invite the bot to the server or servers you would like to monitor, you can do that via the Discord Developer Portal. Admin access is the only level we have tested. Anything less may result in errors.

Peek 2023-04-07 20-01



Usage

Add Yourself As An Admin

In the Web UI, click "Users". Add yourself as a user, but before confirming, change "Non-Admin" to "Admin". Your username should match your Discord username. These are automatically populated in the search bar when the bot is running and can see other users.

Test That The Bot Is Running

Type the following into a discord chat message that the bot can see:

!dc help

Features 🌟

  • Multi-Language Support: Execute code in a plethora of languages - from mainstream ones like Python, Java, C++, JavaScript, to esoteric ones like Rockstar, Cow, and Lolcode.

  • Containerized Execution: Ensures safe and isolated code execution environment.

  • Discord Integration: Directly execute code from Discord with an easy-to-use command system.

  • User Roles and Authorization: Manage permissions with roles like admin, user, unrestricted, and owner.

  • User Debug Information: Quickly access user roles and registered commands.

How to Use πŸ“˜

To execute code, use the prefix for code execution ($ by default), followed by three backticks and the language that you would like to code in. Then, on a new line below that, you can start writing code. End it with a new line and another three backticks.

  $```python
  print("Hello, DiscoCode!")
  ```

Contributing πŸ’Ό

Feel free to fork this repository, add your features or improvements and create a pull request. We are excited to see your creative ideas!

License πŸ“„

This project is licensed under the MIT License - see the LICENSE.md file for details.

Happy Coding! πŸš€

About

A containerized code execution webserver and discord bot.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published