fix merge conflight
This commit is contained in:
commit
02431357a4
|
@ -148,8 +148,8 @@ final class BenBot extends Discord
|
|||
|
||||
if (!Utils::isDM($msg) && $msg->channel->guild->id === '233603102047993856') {
|
||||
if ($str->contains('dib', false)) {
|
||||
$msg->react(':dib:284335774823088129')->otherwise(function ($e) {
|
||||
echo $e->getMessage(), PHP_EOL;
|
||||
$msg->react(":dib:284335774823088129")->otherwise(function ($e) use ($msg) {
|
||||
Utils::logError($e, $msg);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -242,9 +242,8 @@ final class Debug
|
|||
self::$bot->loop->addTimer(2, function ($timer) use ($res) {
|
||||
$res->channel->messages->delete($res);
|
||||
});
|
||||
}, function ($e) {
|
||||
echo $e->getMessage(), PHP_EOL;
|
||||
echo $e->getTraceAsString(), PHP_EOL;
|
||||
}, function ($e) use ($msg) {
|
||||
Utils::logError($e, $msg);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -136,9 +136,8 @@ final class Hangman
|
|||
'guessed_letters' => [' '],
|
||||
];
|
||||
self::$bot->hangman['readymsg'] = $msg;
|
||||
$msg->author->user->sendMessage('enter the secret word')->otherwise(function ($e) {
|
||||
echo $e->getMessage(), PHP_EOL;
|
||||
echo $e->getTraceAsString(), PHP_EOL;
|
||||
$msg->author->user->sendMessage("enter the secret word")->otherwise(function ($e) use ($msg) {
|
||||
Utils::logError($e, $msg);
|
||||
});
|
||||
Utils::send($msg, "waiting for {$msg->author} to enter a word")->then(function ($result) use ($gameid) {
|
||||
self::$bot->hangman[$gameid]['last_msg'] = $result;
|
||||
|
|
|
@ -48,7 +48,7 @@ final class Jokes
|
|||
self::$bot->http->get($url, null, [], false)->then(function ($result) use ($msg) {
|
||||
Utils::send($msg, $result->value->joke);
|
||||
}, function ($e) use ($msg) {
|
||||
Utils::send($msg, $e->getMessage());
|
||||
Utils::logError($e, $msg);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ final class Jokes
|
|||
self::$bot->http->get($url, null, ['Accept' => 'application/json'], false)->then(function ($result) use ($msg) {
|
||||
Utils::send($msg, $result->joke);
|
||||
}, function ($e) use ($msg) {
|
||||
Utils::send($msg, $e->getMessage());
|
||||
Utils::logError($e, $msg);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,21 +76,17 @@ final class Music
|
|||
self::$voiceclients[$msg->channel->guild->id] = $vc;
|
||||
$vc->playFile(self::$bot->dir."/music/$file")->then(function () use ($vc) {
|
||||
$vc->close();
|
||||
}, function ($e) {
|
||||
echo $e->getMessage(), PHP_EOL;
|
||||
echo $e->getTraceAsString(), PHP_EOL;
|
||||
}, function ($e) use ($msg) {
|
||||
Utils::logError($e, $msg);
|
||||
});
|
||||
}, function ($e) {
|
||||
echo $e->getMessage(), PHP_EOL;
|
||||
echo $e->getTraceAsString(), PHP_EOL;
|
||||
}, function ($e) use ($msg) {
|
||||
Utils::logError($e, $msg);
|
||||
});
|
||||
}, function ($e) {
|
||||
echo $e->getMessage(), PHP_EOL;
|
||||
echo $e->getTraceAsString(), PHP_EOL;
|
||||
}, function ($e) use ($msg) {
|
||||
Utils::logError($e, $msg);
|
||||
});
|
||||
}, function ($e) {
|
||||
echo $e->getMessage(), PHP_EOL;
|
||||
echo $e->getTraceAsString(), PHP_EOL;
|
||||
}, function ($e) use ($msg) {
|
||||
Utils::logError($e, $msg);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -173,7 +169,12 @@ final class Music
|
|||
$url = escapeshellarg($json->webpage_url);
|
||||
$filename = $json->id.'-'.md5($json->title).'-'.$json->duration;
|
||||
|
||||
foreach (scandir(self::$bot->dir.'/music') as $file) {
|
||||
if ($json->duration > 60 * 60) {
|
||||
$deferred->reject("video too long, sorry");
|
||||
return $deferred->promise();
|
||||
}
|
||||
|
||||
foreach (scandir(self::$bot->dir . '/music') as $file) {
|
||||
// check if we've already downloaded the file!
|
||||
if (pathinfo($file, PATHINFO_FILENAME) === $filename) {
|
||||
$deferred->resolve($file);
|
||||
|
|
|
@ -16,24 +16,37 @@ final class Utils
|
|||
|
||||
public static function send($msg, $txt, $embed = null)
|
||||
{
|
||||
return $msg->channel->sendMessage($txt, false, $embed)
|
||||
->otherwise(function ($e) use ($msg) {
|
||||
echo $e->getMessage(), PHP_EOL;
|
||||
echo $e->getTraceAsString(), PHP_EOL;
|
||||
$msg->reply("sry, an error occurred. check with <@193011352275648514>.\n```{$e->getMessage()}```");
|
||||
self::ping($e->getMessage());
|
||||
});
|
||||
return $msg->channel->sendMessage(
|
||||
$txt,
|
||||
false,
|
||||
$embed
|
||||
)->otherwise(function($e) use ($msg) {
|
||||
self::logError($e, $msg);
|
||||
});
|
||||
}
|
||||
|
||||
public static function sendFile($msg, $filepath, $filename, $txt)
|
||||
{
|
||||
return $msg->channel->sendFile($filepath, $filename, $txt)
|
||||
->otherwise(function ($e) use ($msg) {
|
||||
echo $e->getMessage(), PHP_EOL;
|
||||
echo $e->getTraceAsString(), PHP_EOL;
|
||||
$msg->reply("sry, an error occurred. check with <@193011352275648514>.\n```{$e->getMessage()}```");
|
||||
self::ping($e->getMessage());
|
||||
});
|
||||
return $msg->channel->sendFile(
|
||||
$filepath,
|
||||
$filename,
|
||||
$txt
|
||||
)->otherwise(function($e) use ($msg) {
|
||||
self::logError($e, $msg);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public static function logError($e, $msg = null)
|
||||
{
|
||||
echo $e->getMessage(), PHP_EOL;
|
||||
echo $e->getTraceAsString(), PHP_EOL;
|
||||
if ($msg != null) {
|
||||
self::send($msg,
|
||||
"sorry, an error occurred. check with <@193011352275648514>.\n```{$e->getMessage()}```"
|
||||
);
|
||||
self::ping("```{$e->getMessage()}```\nin {$msg->channel->name} in {$msg->channel->guild->name}.\ncheck the logs.");
|
||||
}
|
||||
}
|
||||
|
||||
public static function isDM($msg)
|
||||
|
|
Loading…
Reference in New Issue