Utilize a service like Piston to provide the capabilities of running/formatting/evaluating arbitrary code snippets via slash commands or app commands.
On the topic of "Why Piston?":
The only other viable option I have found is https://github.com/python-discord/snekbox but it is limited to Python code.
Piston allows for all desired languages (Rust, Swift, Python, etc.) and a lot more
No response
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too