discord-csharp / Contacts

Your friendly neighborhood C# Discord server bot
MIT License
7 stars 3 forks source link

[FEATURE] Snippet Compilation/Execution #5

Open Jimmacle opened 7 years ago

Jimmacle commented 7 years ago

It would be nice to be able to compile and run small code snippets from within Discord and have it send the console feedback when it completes. I already have progress on a system for it so I can help put it into the bot once I make it safe to use.

mastorm commented 7 years ago

Are you working on this? Because i already have a lot of code for exactly this. We just need to secure it.

ghost commented 7 years ago

Is something like this what you had in mind? http://www.mono-project.com/docs/tools+libraries/tools/repl/

It's pretty straightforward to implement and I can contribute (including role checks.)

mastorm commented 7 years ago

@CsharpOnLinuxDev The idea would be to just have stuff like

~run Console.WriteLine("Hello World");

ghost commented 7 years ago

Would it be better to have a delimiter so a larger snippet could be executed like so?

~run ~ for (int A = 0; A < 10; A++) { Console.WriteLine(A); A++; } ~

jmazouri commented 7 years ago

A more elegant solution would be to put it in a code block, as in triple backticks.

nemec commented 7 years ago

If you want to expand this beyond C# it may be a good idea to take a page from Reddit's compilebot, which uses the Ideone API to compile/run - that would solve the security problem, since they have their own security built in.

You can put the language name in a codeblock to identify which language to compile under.

```csharp
Console.WriteLine("Hello World");
```