1

I'm trying to create a command that formats your code on Discord with a given language,

by sending the formatted string:

f"```{language}\n{code}\n```"

The function prototype is :

def format(ctx, language, *code)

And I'm typing on Discord for example :

!format c int function(int x)
{
  return x;
}

But when I tried to print out the code arg, there is no \n in the list and the bot message is on a single line.

I also tried with quotation marks around my message, and this worked for keeping \n but if my code contains another quotation mark it ends the code arg, and throws an error for the remaining part.

Is there a way to get the complete message including newlines?

flipjacob
  • 60
  • 1
  • 6
Sylvwar
  • 11
  • 3

1 Answers1

0

You need to change your OS sed option so you could get newline or tab characters back.

loponly
  • 1
  • 1
  • your answer is ok, but next time please refrain from adding links only to other answers, provide some code snippets referring to it here as well/ – bhucho Oct 31 '20 at 14:30
  • I didn't quite understand where's the solution with sed, the answers run the sed command on a file and replace newlines with something else. But I don't have any file, my Discord command parameters are given to my function with the Discord API. How could I run the sed command before my function ? – Sylvwar Oct 31 '20 at 16:43