<commit_before><?php

///////////////////////////////////////////////////////////
// config
///////////////////////////////////////////////////////////

include __DIR__.'/vendor/autoload.php';
include __DIR__.'/kaomoji.php';
include __DIR__.'/definitions.php';
include __DIR__.'/util_fns.php';

$start_time = microtime(true);
$starttime = new DateTime();
$defs = new Definitions();

$discord = new \Discord\DiscordCommandClient([
    'token' => file_get_contents(__DIR__.'/token'),
    'prefix' => ';',
    'description' => "benh's bot made with DiscordPHP",
]);

// $game = $discord->factory(\Discord\Parts\User\Game::class, [
//     'name' => ';help'
// ]);
// $discord->updatePresence($game);




///////////////////////////////////////////////////////////
// commands
///////////////////////////////////////////////////////////


///////////////////////////////////////////////////////////
$discord->registerCommand('ping', function($msg) {
    send($msg, 'pong');
}, [
    'description' => 'ping pong',
    'usage' => '',
]);

///////////////////////////////////////////////////////////
$discord->registerCommand('ding', function($msg, $args) {
    send($msg, 'dong');
}, [
    'description' => 'dong',
    'usage' => '',
]);


///////////////////////////////////////////////////////////
$discord->registerCommand('hi', [
    'hey',
    'hello',
    'wussup'
], [
    'description' => 'greeting',
    'usage' => '',
]);





///////////////////////////////////////////////////////////
$discord->registerCommand('time', function($msg) {
    send($msg, "It's " . date('g:i A \o\n F j, Y'));
}, [
    'description' => 'current time'
]);


///////////////////////////////////////////////////////////
$discord->registerCommand('roll', function ($msg, $args) {
    $msg->reply('you rolled a ' . rand(1, $args[0] ?? 6));
}, [
    'description' => 'rolls an n-sided die. defaults to 6.',
    'usage' => '<number of sides>',
]);


///////////////////////////////////////////////////////////
$discord->registerCommand('text_benh', function($msg, $args) {
    if (count($args) === 0) {
        send($msg, 'missing message');
        return;
    }
    if (mail("<EMAIL>", "", implode($args, " "), "From: {$msg->author->user->username} <{<EMAIL>>")) {
        return "message sent";
    }
}, [
    'description' => 'send a message to benh off discord',
    'usage' => '<message>',
]);


///////////////////////////////////////////////////////////
$discord->registerCommand('avatar', function($msg, $args) {
    if (count($msg->mentions) === 0) {
        send($msg, $msg->author->user->avatar);
        return;
    }
    foreach ($msg->mentions as $av)
        send($msg, $av->avatar);
}, [
    'description' => 'gets the avatar for a user',
    'usage' => '<@user>',
]);


///////////////////////////////////////////////////////////
$discord->registerCommand('up', function($msg, $args) use ($starttime) {
    // $now = new DateTime();
    // $diff = $now->diff($starttime);
    $diff = $starttime->diff(new DateTime());
    print_r($diff);
    echo $diff->d;
    echo $diff->h;
    $ret = "Up for";
    $ret .= " {$diff->d} day" . $diff->d == 1 ?: "s";
    $ret .= " {$diff->h} hour" . $diff->h == 1 ?: "s";
    $ret .= " {$diff->m} minute" . $diff->m == 1 ?: "s";
    $ret .= " {$diff->s} second" . $diff->s == 1 ?: "s";
    echo $ret;
    send($msg, $ret);
}, [
    'description' => 'bot uptime',
    'usage' => '',
]);


///////////////////////////////////////////////////////////
$discord->registerCommand('say', function($msg, $args) {
    send($msg, implode($args, ' '));
}, [
    'description' => 'repeats stuff back to you',
    'usage' => '<stuff to say>',
]);



///////////////////////////////////////////////////////////
$discord->registerCommand('set', function($msg, $args) use ($defs) {
    $def = array_shift($args);
    $defs->set($def, implode($args, " "));
    send($msg, $def . " set to: " . implode($args, " "));
}, [
    'description' => 'sets this to that',
    'usage' => '<this> <that>',
]);
///////////////////////////////////////////////////////////
$discord->registerCommand('get', function($msg, $args) use ($defs) {
    if (isset($args[0]))
        send($msg, $args[0] . ": " . $defs->get($args[0]));
    else
        send($msg, "can't search for nothing");
}, [
    'description' => 'gets a value from the definitions',
    'usage' => '<thing to get>',
]);
///////////////////////////////////////////////////////////
$discord->registerCommand('unset', function($msg, $args) use ($defs) {
    $defs->unset($args[0]);
    send($msg, $args[0] . " unset");
}, [
    'description' => 'removes a definition',
    'usage' => '<def to remove>',
]);
///////////////////////////////////////////////////////////
$discord->registerCommand('listdefs', function($msg, $args) use ($defs) {
    send($msg, (string)$defs);
}, [
    'description' => 'lists all definitions',
    'usage' => '',
]);


///////////////////////////////////////////////////////////
$discord->registerCommand('dank', function($msg) {
    send($msg, 'memes');
});


///////////////////////////////////////////////////////////
$discord->registerCommand('weather', [
    "sunny", "cloudy", "bad"
], [
    'description' => 'gets weather for a location',
    'usage' => '<location>',
]);

$fortunes = [
    "It is certain",
    "It is decidedly so",
    "Without a doubt",
    "Yes definitely",
    "You may rely on it",
    "As I see it, yes",
    "Most likely",
    "Outlook good",
    "Yes",
    "Signs point to yes",
    "Reply hazy try again",
    "Ask again later",
    "Better not tell you now",
    "Cannot predict now",
    "Concentrate and ask again",
    "Don't count on it",
    "My reply is no",
    "My sources say no",
    "Outlook not so good",
    "Very doubtful",
];

///////////////////////////////////////////////////////////
$discord->registerCommand('8ball', function($msg, $args) use ($fortunes) {
    $ret = "Your Question: *";
    $ret .= count($args) == 0 ? "Why didn't {$msg->author} ask a question?" : implode($args, " ");
    $ret .= "*\n\n**" . $fortunes[array_rand($fortunes)] . "**";
    send($msg, $ret);
}, [
    'description' => 'tells your fortune',
    'usage' => '<question to ask the mighty 8ball>',
]);


///////////////////////////////////////////////////////////
$discord->registerCommand('lenny', function($msg, $args) {
    send($msg, "( ͡° ͜ʖ ͡°)");
    $channel = $msg->channel;
    $channel->deleteMessages([$msg]);
}, [
    'description' => 'lenny face ( ͡° ͜ʖ ͡°)',
    'usage' => '',
]);

///////////////////////////////////////////////////////////
$discord->registerCommand('lennyception', function($msg, $args) {
    send($msg, "( (   ͡° ͜ʖ ͡° )
 (   (   ͡° ͜ʖ ͡° )
 (   ͡° (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )(   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° ) (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )(   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )  ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )  ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )  ͡° )
 (   ͡° ͜ʖ ͡° )° )
 (   ͡° ͜ʖ ͡° )
 ( (   ͡° ͜ʖ ͡° )
 (   (   ͡° ͜ʖ ͡° )
 (   ͡° (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )(   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° ) (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )(   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )  ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )  ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )  ͡° )
 (   ͡° ͜ʖ ͡° )° )
 (   ͡° ͜ʖ ͡° ))
 (   ͡° ͜ʖ ͡° )
 ( (   ͡° ͜ʖ ͡° )
 (   (   ͡° ͜ʖ ͡° )
 (   ͡° (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )(   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° ) (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )(   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )  ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )  ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )  ͡° )
 (   ͡° ͜ʖ ͡° )° )
 (   ͡° ͜ʖ ͡° )
 ( (   ͡° ͜ʖ ͡° )
 (   (   ͡° ͜ʖ ͡° )
 (   ͡° (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )(   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° ) (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )(   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )  ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )  ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )  ͡° )
 (   ͡° ͜ʖ ͡° )° )
 (   ͡° ͜ʖ ͡° ))
 (   ͡° ͜ʖ ͡° )
 ( (   ͡° ͜ʖ ͡° )
 (   (   ͡° ͜ʖ ͡° )
 (   ͡° (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )(   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° ) (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )(   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )  ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )  ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )  ͡° )
 (   ͡° ͜ʖ ͡° )° )
 (   ͡° ͜ʖ ͡° )
 ( (   ͡° ͜ʖ ͡° )
 (   (   ͡° ͜ʖ ͡° )
 (   ͡° (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ (   ͡° ͜ʖ ͡° )
(   ͡° ͜ʖ ͡° (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )(   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° ) (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )(   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )  ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )  ͜ʖ ͡° )");
}, [
    'description' => '( ͡° ͜ʖ ͡°)',
    'usage' => '',
]);


///////////////////////////////////////////////////////////
$kaomoji = $discord->registerCommand('kaomoji', function($msg, $args) use ($kaomojis) {
    send($msg, $kaomojis[array_rand($kaomojis)]);
}, [
    'description' => 'sends random kaomoji',
    'usage' => '',
]);

    $kaomoji->registerSubCommand('sad', function($msg, $args) use($sad_kaomojis) {
        send($msg, $sad_kaomojis[array_rand($sad_kaomojis)]);
    }, [
        'description' => 'sends random sad kaomoji',
        'usage' => '',
    ]);
    $kaomoji->registerSubCommand('happy', function($msg, $args) use($happy_kaomojis) {
        send($msg, $happy_kaomojis[array_rand($happy_kaomojis)]);
    }, [
        'description' => 'sends random happy kaomoji',
        'usage' => '',
    ]);
    $kaomoji->registerSubCommand('angry', function($msg, $args) use($angry_kaomojis) {
        send($msg, $angry_kaomojis[array_rand($angry_kaomojis)]);
    }, [
        'description' => 'sends random angry kaomoji',
        'usage' => '',
    ]);
    $kaomoji->registerSubCommand('confused', function($msg, $args) use($confused_kaomojis) {
        send($msg, $confused_kaomojis[array_rand($confused_kaomojis)]);
    }, [
        'description' => 'sends random confused kaomoji',
        'usage' => '',
    ]);
    $kaomoji->registerSubCommand('surprised', function($msg, $args) use($surprised_kaomojis) {
        send($msg, $surprised_kaomojis[array_rand($surprised_kaomojis)]);
    }, [
        'description' => 'sends random surprised kaomoji',
        'usage' => '',
    ]);
    $kaomoji->registerSubCommand('embarrassed', function($msg, $args) use($embarrassed_kaomojis) {
        send($msg, $embarrassed_kaomojis[array_rand($embarrassed_kaomojis)]);
    }, [
        'description' => 'sends random embarrassed kaomoji',
        'usage' => '',
    ]);




///////////////////////////////////////////////////////////
$joke = $discord->registerCommand('joke', function($msg, $args) use ($var) {
    $json = json_decode(file_get_contents("http://tambal.azurewebsites.net/joke/random"));
    send($msg, $json->joke);
}, [
    'description' => 'tells a random joke',
    'usage' => '',
]);

    $joke->registerSubCommand('chucknorris', function($msg, $args) {
        $json = json_decode(file_get_contents("http://api.icndb.com/jokes/random1"));
        send($msg, $json->value->joke);
    }, [
        'description' => 'get a random fact about chuck norris',
        'usage' => '',
    ]);

    $joke->registerSubCommand('yomama', function($msg, $args) {
        $json = json_decode(file_get_contents("http://api.yomomma.info/"));
        send($msg, $json->joke);
    }, [
        'description' => 'yo mama jokes',
        'usage' => '',
    ]);

    $joke->registerSubCommand('dad', function($msg, $args) {
        $opts = [
            'http' => [
                'method' => 'GET',
                'header' => 'Accept: text/plain'
            ]
        ];
        $context = stream_context_create($opts);
        send($msg, file_get_contents("https://icanhazdadjoke.com/", false, $context));
    }, [
        'description' => 'tells a dad joke',
        'usage' => '',
    ]);


///////////////////////////////////////////////////////////
$discord->registerCommand('text', function($msg, $args) {
    $pain = "！゛＃＄％＆'（）＊＋、ー。／０１２３４５６７８９：；〈＝〉？＠ＡＢＣＤＥＦＧＨＩＪＫＬＭＮＯＰＱＲＳＴＵＶＷＸＹＺ［］＾＿‘ａｂｃｄｅｆｇｈｉｊｋｌｍｎｏｐｑｒｓｔｕｖｗｘｙｚ";
    $res = "";
    foreach (char_in_str(implode($args, " ")) as $char) {
        $ord = ord($char);
        if ($ord > 32 && $ord < 124) $res .= $pain[$ord - 33];
        else $res .= $char;
    }
    send($msg, "$res");
}, [
    'description' => 'convert ASCII to Unicode for font effect',
    'usage' => '<text to convert>',
]);


///////////////////////////////////////////////////////////
$discord->registerCommand('meme', function($msg, $args) use ($memes) {
    send($msg, 'dank');
}, [
    'description' => 'get a meme',
    'usage' => '',
]);



$imgs = new Definitions(__DIR__.'/img_urls.json');
///////////////////////////////////////////////////////////
$img = $discord->registerCommand('img', function($msg, $args) use ($imgs) {
    if (count($args) > 0) {
        // look for image in uploaded_images
        send($msg, $imgs->get($args[0]));
    } else {
        return;
    }
}, [
    'description' => 'image tools',
    'usage' => '<image to show>',
]);

    $img->registerSubCommand('save2', function($msg, $args) use ($imgs) {
        if (count($msg->attachments) > 0) {
            foreach ($msg->attachments as $attachment) {
                $pic = file_get_contents($attachment->url);
                $ext = pathinfo($attachment->url, PATHINFO_EXTENSION);
                $filename = __DIR__.'/uploaded_images/';
                $filename .= isset($args[0]) ? $args[0].".$ext" : $attachment->filename;
                file_put_contents($filename, $pic);
            }
        } else send($msg, "no image to save");
    }, [
        'description' => 'image tools',
        'usage' => '<save as>',
    ]);

    $img->registerSubCommand('save', function($msg, $args) use ($imgs) {
        if (count($msg->attachments) > 0) {
            $i = 0;
            foreach ($msg->attachments as $attachment)
                $imgs->set($args[$i++], $attachment->url);
        } else send($msg, "no image to save");
    }, [
        'description' => 'saves attached image as name',
        'usage' => '<name>',
    ]);

    $img->registerSubCommand('list2', function($msg, $args) use ($imgs) {
        $dir = new DirectoryIterator(__DIR__.'/uploaded_images/');
        foreach ($dir as $fileinfo) {
            if (!$fileinfo->isDot()) {
                $ret[] = $fileinfo->getBasename(".".$dir->getExtension());
            }
        }
        send($msg, "list of uploaded images:\n\n" . implode($ret, ", "));
    }, [
        'description' => 'saved image list',
        'usage' => '',
    ]);

    $img->registerSubCommand('list', function($msg, $args) use ($imgs) {
        send($msg, "list of uploaded images:\n\n" . implode($imgs->list_keys(), ", "));
    }, [
        'description' => 'saved image list',
        'usage' => '',
    ]);

    $img->registerSubCommand('asciiart', function($msg, $args) {
        if (count($msg->attachments) > 0) {
            $imgpath = $msg->attachments[0]->url;
        } else {
            $imgpath = $msg->author->user->avatar;
        }
        send($msg, ascii_from_img($imgpath));
    }, [
        'description' => 'converts image to ascii art',
        'usage' => '<image>',
    ]);



$discord->run();

<commit_msg>diff->format<commit_after><?php

///////////////////////////////////////////////////////////
// config
///////////////////////////////////////////////////////////

include __DIR__.'/vendor/autoload.php';
include __DIR__.'/kaomoji.php';
include __DIR__.'/definitions.php';
include __DIR__.'/util_fns.php';

$start_time = microtime(true);
$starttime = new DateTime();
$defs = new Definitions();

$discord = new \Discord\DiscordCommandClient([
    'token' => file_get_contents(__DIR__.'/token'),
    'prefix' => ';',
    'description' => "benh's bot made with DiscordPHP",
]);

// $game = $discord->factory(\Discord\Parts\User\Game::class, [
//     'name' => ';help'
// ]);
// $discord->updatePresence($game);




///////////////////////////////////////////////////////////
// commands
///////////////////////////////////////////////////////////


///////////////////////////////////////////////////////////
$discord->registerCommand('ping', function($msg) {
    send($msg, 'pong');
}, [
    'description' => 'ping pong',
    'usage' => '',
]);

///////////////////////////////////////////////////////////
$discord->registerCommand('ding', function($msg, $args) {
    send($msg, 'dong');
}, [
    'description' => 'dong',
    'usage' => '',
]);


///////////////////////////////////////////////////////////
$discord->registerCommand('hi', [
    'hey',
    'hello',
    'wussup'
], [
    'description' => 'greeting',
    'usage' => '',
]);





///////////////////////////////////////////////////////////
$discord->registerCommand('time', function($msg) {
    send($msg, "It's " . date('g:i A \o\n F j, Y'));
}, [
    'description' => 'current time'
]);


///////////////////////////////////////////////////////////
$discord->registerCommand('roll', function ($msg, $args) {
    $msg->reply('you rolled a ' . rand(1, $args[0] ?? 6));
}, [
    'description' => 'rolls an n-sided die. defaults to 6.',
    'usage' => '<number of sides>',
]);


///////////////////////////////////////////////////////////
$discord->registerCommand('text_benh', function($msg, $args) {
    if (count($args) === 0) {
        send($msg, 'missing message');
        return;
    }
    if (mail("<EMAIL>", "", implode($args, " "), "From: {$msg->author->user->username} <{$msg-><EMAIL>>")) {
        return "message sent";
    }
}, [
    'description' => 'send a message to benh off discord',
    'usage' => '<message>',
]);


///////////////////////////////////////////////////////////
$discord->registerCommand('avatar', function($msg, $args) {
    if (count($msg->mentions) === 0) {
        send($msg, $msg->author->user->avatar);
        return;
    }
    foreach ($msg->mentions as $av)
        send($msg, $av->avatar);
}, [
    'description' => 'gets the avatar for a user',
    'usage' => '<@user>',
]);


///////////////////////////////////////////////////////////
$discord->registerCommand('up', function($msg, $args) use ($starttime) {
    // $now = new DateTime();
    // $diff = $now->diff($starttime);
    $diff = $starttime->diff(new DateTime());
    print_r($diff);
    $ret = "Up for ";
    $ret .= $diff->format("%a") . " day" . $diff->d == 1 ? ", " : "s, ";
    $ret .= $diff->format("%h") . " hour" . $diff->h == 1 ? ", " : "s, ";
    $ret .= $diff->format("%i") . " minute" . $diff->m == 1 ? ", and " : "s, and ";
    $ret .= $diff->format("%s") . " second" . $diff->s == 1 ? "" : "s";
    echo $ret;
    send($msg, $ret);
}, [
    'description' => 'bot uptime',
    'usage' => '',
]);


///////////////////////////////////////////////////////////
$discord->registerCommand('say', function($msg, $args) {
    send($msg, implode($args, ' '));
}, [
    'description' => 'repeats stuff back to you',
    'usage' => '<stuff to say>',
]);



///////////////////////////////////////////////////////////
$discord->registerCommand('set', function($msg, $args) use ($defs) {
    $def = array_shift($args);
    $defs->set($def, implode($args, " "));
    send($msg, $def . " set to: " . implode($args, " "));
}, [
    'description' => 'sets this to that',
    'usage' => '<this> <that>',
]);
///////////////////////////////////////////////////////////
$discord->registerCommand('get', function($msg, $args) use ($defs) {
    if (isset($args[0]))
        send($msg, $args[0] . ": " . $defs->get($args[0]));
    else
        send($msg, "can't search for nothing");
}, [
    'description' => 'gets a value from the definitions',
    'usage' => '<thing to get>',
]);
///////////////////////////////////////////////////////////
$discord->registerCommand('unset', function($msg, $args) use ($defs) {
    $defs->unset($args[0]);
    send($msg, $args[0] . " unset");
}, [
    'description' => 'removes a definition',
    'usage' => '<def to remove>',
]);
///////////////////////////////////////////////////////////
$discord->registerCommand('listdefs', function($msg, $args) use ($defs) {
    send($msg, (string)$defs);
}, [
    'description' => 'lists all definitions',
    'usage' => '',
]);


///////////////////////////////////////////////////////////
$discord->registerCommand('dank', function($msg) {
    send($msg, 'memes');
});


///////////////////////////////////////////////////////////
$discord->registerCommand('weather', [
    "sunny", "cloudy", "bad"
], [
    'description' => 'gets weather for a location',
    'usage' => '<location>',
]);

$fortunes = [
    "It is certain",
    "It is decidedly so",
    "Without a doubt",
    "Yes definitely",
    "You may rely on it",
    "As I see it, yes",
    "Most likely",
    "Outlook good",
    "Yes",
    "Signs point to yes",
    "Reply hazy try again",
    "Ask again later",
    "Better not tell you now",
    "Cannot predict now",
    "Concentrate and ask again",
    "Don't count on it",
    "My reply is no",
    "My sources say no",
    "Outlook not so good",
    "Very doubtful",
];

///////////////////////////////////////////////////////////
$discord->registerCommand('8ball', function($msg, $args) use ($fortunes) {
    $ret = "Your Question: *";
    $ret .= count($args) == 0 ? "Why didn't {$msg->author} ask a question?" : implode($args, " ");
    $ret .= "*\n\n**" . $fortunes[array_rand($fortunes)] . "**";
    send($msg, $ret);
}, [
    'description' => 'tells your fortune',
    'usage' => '<question to ask the mighty 8ball>',
]);


///////////////////////////////////////////////////////////
$discord->registerCommand('lenny', function($msg, $args) {
    send($msg, "( ͡° ͜ʖ ͡°)");
    $channel = $msg->channel;
    $channel->deleteMessages([$msg]);
}, [
    'description' => 'lenny face ( ͡° ͜ʖ ͡°)',
    'usage' => '',
]);

///////////////////////////////////////////////////////////
$discord->registerCommand('lennyception', function($msg, $args) {
    send($msg, "( (   ͡° ͜ʖ ͡° )
 (   (   ͡° ͜ʖ ͡° )
 (   ͡° (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )(   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° ) (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )(   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )  ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )  ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )  ͡° )
 (   ͡° ͜ʖ ͡° )° )
 (   ͡° ͜ʖ ͡° )
 ( (   ͡° ͜ʖ ͡° )
 (   (   ͡° ͜ʖ ͡° )
 (   ͡° (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )(   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° ) (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )(   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )  ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )  ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )  ͡° )
 (   ͡° ͜ʖ ͡° )° )
 (   ͡° ͜ʖ ͡° ))
 (   ͡° ͜ʖ ͡° )
 ( (   ͡° ͜ʖ ͡° )
 (   (   ͡° ͜ʖ ͡° )
 (   ͡° (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )(   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° ) (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )(   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )  ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )  ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )  ͡° )
 (   ͡° ͜ʖ ͡° )° )
 (   ͡° ͜ʖ ͡° )
 ( (   ͡° ͜ʖ ͡° )
 (   (   ͡° ͜ʖ ͡° )
 (   ͡° (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )(   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° ) (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )(   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )  ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )  ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )  ͡° )
 (   ͡° ͜ʖ ͡° )° )
 (   ͡° ͜ʖ ͡° ))
 (   ͡° ͜ʖ ͡° )
 ( (   ͡° ͜ʖ ͡° )
 (   (   ͡° ͜ʖ ͡° )
 (   ͡° (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )(   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° ) (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )(   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )  ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )  ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )  ͡° )
 (   ͡° ͜ʖ ͡° )° )
 (   ͡° ͜ʖ ͡° )
 ( (   ͡° ͜ʖ ͡° )
 (   (   ͡° ͜ʖ ͡° )
 (   ͡° (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ (   ͡° ͜ʖ ͡° )
(   ͡° ͜ʖ ͡° (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )(   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° ) (   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )(   ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )  ͡° ͜ʖ ͡° )
 (   ͡° ͜ʖ ͡° )  ͜ʖ ͡° )");
}, [
    'description' => '( ͡° ͜ʖ ͡°)',
    'usage' => '',
]);


///////////////////////////////////////////////////////////
$kaomoji = $discord->registerCommand('kaomoji', function($msg, $args) use ($kaomojis) {
    send($msg, $kaomojis[array_rand($kaomojis)]);
}, [
    'description' => 'sends random kaomoji',
    'usage' => '',
]);

    $kaomoji->registerSubCommand('sad', function($msg, $args) use($sad_kaomojis) {
        send($msg, $sad_kaomojis[array_rand($sad_kaomojis)]);
    }, [
        'description' => 'sends random sad kaomoji',
        'usage' => '',
    ]);
    $kaomoji->registerSubCommand('happy', function($msg, $args) use($happy_kaomojis) {
        send($msg, $happy_kaomojis[array_rand($happy_kaomojis)]);
    }, [
        'description' => 'sends random happy kaomoji',
        'usage' => '',
    ]);
    $kaomoji->registerSubCommand('angry', function($msg, $args) use($angry_kaomojis) {
        send($msg, $angry_kaomojis[array_rand($angry_kaomojis)]);
    }, [
        'description' => 'sends random angry kaomoji',
        'usage' => '',
    ]);
    $kaomoji->registerSubCommand('confused', function($msg, $args) use($confused_kaomojis) {
        send($msg, $confused_kaomojis[array_rand($confused_kaomojis)]);
    }, [
        'description' => 'sends random confused kaomoji',
        'usage' => '',
    ]);
    $kaomoji->registerSubCommand('surprised', function($msg, $args) use($surprised_kaomojis) {
        send($msg, $surprised_kaomojis[array_rand($surprised_kaomojis)]);
    }, [
        'description' => 'sends random surprised kaomoji',
        'usage' => '',
    ]);
    $kaomoji->registerSubCommand('embarrassed', function($msg, $args) use($embarrassed_kaomojis) {
        send($msg, $embarrassed_kaomojis[array_rand($embarrassed_kaomojis)]);
    }, [
        'description' => 'sends random embarrassed kaomoji',
        'usage' => '',
    ]);




///////////////////////////////////////////////////////////
$joke = $discord->registerCommand('joke', function($msg, $args) use ($var) {
    $json = json_decode(file_get_contents("http://tambal.azurewebsites.net/joke/random"));
    send($msg, $json->joke);
}, [
    'description' => 'tells a random joke',
    'usage' => '',
]);

    $joke->registerSubCommand('chucknorris', function($msg, $args) {
        $json = json_decode(file_get_contents("http://api.icndb.com/jokes/random1"));
        send($msg, $json->value->joke);
    }, [
        'description' => 'get a random fact about chuck norris',
        'usage' => '',
    ]);

    $joke->registerSubCommand('yomama', function($msg, $args) {
        $json = json_decode(file_get_contents("http://api.yomomma.info/"));
        send($msg, $json->joke);
    }, [
        'description' => 'yo mama jokes',
        'usage' => '',
    ]);

    $joke->registerSubCommand('dad', function($msg, $args) {
        $opts = [
            'http' => [
                'method' => 'GET',
                'header' => 'Accept: text/plain'
            ]
        ];
        $context = stream_context_create($opts);
        send($msg, file_get_contents("https://icanhazdadjoke.com/", false, $context));
    }, [
        'description' => 'tells a dad joke',
        'usage' => '',
    ]);


///////////////////////////////////////////////////////////
$discord->registerCommand('text', function($msg, $args) {
    $pain = "！゛＃＄％＆'（）＊＋、ー。／０１２３４５６７８９：；〈＝〉？＠ＡＢＣＤＥＦＧＨＩＪＫＬＭＮＯＰＱＲＳＴＵＶＷＸＹＺ［］＾＿‘ａｂｃｄｅｆｇｈｉｊｋｌｍｎｏｐｑｒｓｔｕｖｗｘｙｚ";
    $res = "";
    foreach (char_in_str(implode($args, " ")) as $char) {
        $ord = ord($char);
        if ($ord > 32 && $ord < 124) $res .= $pain[$ord - 33];
        else $res .= $char;
    }
    send($msg, "$res");
}, [
    'description' => 'convert ASCII to Unicode for font effect',
    'usage' => '<text to convert>',
]);


///////////////////////////////////////////////////////////
$discord->registerCommand('meme', function($msg, $args) use ($memes) {
    send($msg, 'dank');
}, [
    'description' => 'get a meme',
    'usage' => '',
]);



$imgs = new Definitions(__DIR__.'/img_urls.json');
///////////////////////////////////////////////////////////
$img = $discord->registerCommand('img', function($msg, $args) use ($imgs) {
    if (count($args) > 0) {
        // look for image in uploaded_images
        send($msg, $imgs->get($args[0]));
    } else {
        return;
    }
}, [
    'description' => 'image tools',
    'usage' => '<image to show>',
]);

    $img->registerSubCommand('save2', function($msg, $args) use ($imgs) {
        if (count($msg->attachments) > 0) {
            foreach ($msg->attachments as $attachment) {
                $pic = file_get_contents($attachment->url);
                $ext = pathinfo($attachment->url, PATHINFO_EXTENSION);
                $filename = __DIR__.'/uploaded_images/';
                $filename .= isset($args[0]) ? $args[0].".$ext" : $attachment->filename;
                file_put_contents($filename, $pic);
            }
        } else send($msg, "no image to save");
    }, [
        'description' => 'image tools',
        'usage' => '<save as>',
    ]);

    $img->registerSubCommand('save', function($msg, $args) use ($imgs) {
        if (count($msg->attachments) > 0) {
            $i = 0;
            foreach ($msg->attachments as $attachment)
                $imgs->set($args[$i++], $attachment->url);
        } else send($msg, "no image to save");
    }, [
        'description' => 'saves attached image as name',
        'usage' => '<name>',
    ]);

    $img->registerSubCommand('list2', function($msg, $args) use ($imgs) {
        $dir = new DirectoryIterator(__DIR__.'/uploaded_images/');
        foreach ($dir as $fileinfo) {
            if (!$fileinfo->isDot()) {
                $ret[] = $fileinfo->getBasename(".".$dir->getExtension());
            }
        }
        send($msg, "list of uploaded images:\n\n" . implode($ret, ", "));
    }, [
        'description' => 'saved image list',
        'usage' => '',
    ]);

    $img->registerSubCommand('list', function($msg, $args) use ($imgs) {
        send($msg, "list of uploaded images:\n\n" . implode($imgs->list_keys(), ", "));
    }, [
        'description' => 'saved image list',
        'usage' => '',
    ]);

    $img->registerSubCommand('asciiart', function($msg, $args) {
        if (count($msg->attachments) > 0) {
            $imgpath = $msg->attachments[0]->url;
        } else {
            $imgpath = $msg->author->user->avatar;
        }
        send($msg, ascii_from_img($imgpath));
    }, [
        'description' => 'converts image to ascii art',
        'usage' => '<image>',
    ]);



$discord->run();


{'fraction_non_alphanumeric': 0.3315418095489317, 'fraction_numerical': 0.0030994460564494858, 'mean_word_length': 1.7576832151300237, 'pattern_counts': {'":': 2, '<': 43, '<?xml version=': 0, '>': 389, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1293896', 'n_tokens_mistral': 11727, 'n_tokens_neox': 12207, 'n_words': 2318}