Safe and secure. Powered by Piston. Includes a REST API for code running, user admin, and database management.
Running the discord bot requires a discord developer account, and a bot created/invited (via your developer account) to your chosen discord server.
curl https://raw.githubusercontent.com/nickheyer/DiscoCode/main/auto_install_update.sh -o auto_install_update.sh && sudo bash auto_install_update.sh
docker image pull nickheyer/discocode:latest
docker image pull nickheyer/discocode_rpi:latest
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
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.
- Python - Download and install Python here. Make sure that you choose "Add Python to environmental variables" during installation.
- Git - Download and install Git here
- Change directory to preferred install location
cd /where/you/want/this/installed
- Clone DiscoCode
git clone https://github.com/nickheyer/DiscoCode
- Change directory to DiscoCode
cd ./discocode
- Install Requirements
pip install -r requirements.txt
- Run Migrations
python manage.py migrate
- Run DiscoCode
sh ./run.sh
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!
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
)
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.
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.
Type the following into a discord chat message that the bot can see:
!dc help
-
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.
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!")
```
Feel free to fork this repository, add your features or improvements and create a pull request. We are excited to see your creative ideas!
This project is licensed under the MIT License - see the LICENSE.md file for details.
Happy Coding! π