Skip to content

Commit

Permalink
Fix newlines not working
Browse files Browse the repository at this point in the history
  • Loading branch information
fieu committed Jun 25, 2020
1 parent fd878d7 commit eb6c9db
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions app/Commands/WebhookSendCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ class WebhookSendCommand extends Command
protected $description = 'Send a Discord webhook (message or embed)';

/**
* Set webhook URL
*
* @var string
*/
* Set webhook URL
*
* @var string
*/
protected $url;

/**
Expand Down Expand Up @@ -99,7 +99,7 @@ private function pipeline(WebhookClient $webhook)
$this->error('Error: The description must be 2048 characters maximum.');
exit(1);
} else {
$embed->description($this->option('description'));
$embed->description(str_replace('\n', "\n", $this->option('description')));
}
if (count($this->option('field')) > 25) {
$this->error('Error: You may have 25 fields maximum.');
Expand All @@ -108,24 +108,24 @@ private function pipeline(WebhookClient $webhook)
for ($i = 0; $i != count($this->option('field')); $i++) {
$ex = explode(', ', $this->option('field')[$i]);
if (count($ex) != 2 && count($ex) != 3) {
$this->error("Error: You must pass at least 2 arguments to field #". ($i + 1));
$this->error("Error: You must pass at least 2 arguments to field #" . ($i + 1));
$this->printFieldUsage();
exit(1);
}
if (!empty($ex[2])) {
if ($ex[2] != "true" && $ex[2] != "false") {
$this->error("Error: You must pass true or false as the 3rd argument to field #". ($i + 1));
$this->error("Error: You must pass true or false as the 3rd argument to field #" . ($i + 1));
$this->printFieldUsage();
exit(1);
}
$ex[2] = ($ex[2] == "true") ? true : false;
if (strlen($ex[0]) > 256) {
$this->error("Error: Too many characters in parameter 1 of field #". ($i + 1));
$this->error("Error: Too many characters in parameter 1 of field #" . ($i + 1));
$this->printFieldUsage();
exit(1);
}
if (strlen($ex[1]) > 1024) {
$this->error("Error: Too many characters in parameter 2 of field #". ($i + 1));
$this->error("Error: Too many characters in parameter 2 of field #" . ($i + 1));
$this->printFieldUsage();
exit(1);
}
Expand Down Expand Up @@ -294,8 +294,7 @@ private function getValidWebhook(): bool
*/
private function is_embed(): bool
{
return (
$this->option('title') ||
return ($this->option('title') ||
$this->option('description') ||
$this->option('color') ||
$this->option('thumbnail') ||
Expand All @@ -305,7 +304,6 @@ private function is_embed(): bool
$this->option('image') ||
$this->option('footer') ||
$this->option('footer-icon') ||
$this->option('timestamp')
);
$this->option('timestamp'));
}
}

0 comments on commit eb6c9db

Please sign in to comment.