Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include __DIR__.'/vendor/autoload.php';
- //Few variables to make things easier
- $token = 'NTIwMTI4NDI3Njg1MDUyNDE2.DupY6g.4H5bha3TLeg77ixFnBoICF006VI';
- //Basic DiscordPHP stuff
- $discord = new \Discord\Discord([
- 'token' => $token,
- ]);
- $discord->on('ready', function ($discord) {
- echo "Bot is ready.", PHP_EOL;
- // Listen for events here
- $discord->on('message', function ($message) {
- echo "Recieved a message from {$message->author->username}: {$message->content}", PHP_EOL;
- });
- });
- use Discord\DiscordCommandClient;
- $discord = new DiscordCommandClient([
- 'token' => $token,
- 'prefix' => '>'
- ]);
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "bhop";
- $conn = new mysqli($servername, $username, $password, $dbname);
- if ($conn->connect_error) {
- echo "Could not connect, connection failed with reason: " . $conn->connect_error;
- }
- $sql = "SELECT * FROM times, players GROUP BY(maps) ORDER BY date desc LIMIT 10";
- $result = $conn->query($sql);
- $discord->registerCommand('wr', function ($message) {
- if($result->num_rows > 0) {
- //outputting data of each row
- echo '<table>';
- echo '<tr>';
- echo '<th>Player</th>
- <th>Map</th>
- <th>Time</th>
- <th>Style</th>';
- echo '<tr>';
- while($row = $result->fetch_assoc()) {
- echo '<tr>';
- echo ' <td>' . $row["players"] . '</td>';
- echo ' <td>' . $row["maps"] . '</td>';
- echo ' <td>' . $row["times"] . '</td>';
- echo ' <td>' . $row["style"] . '</td>';
- echo ' </tr> ';
- }
- echo '</table>';
- }
- else {
- return "No record found to display";
- }
- /*this outputs the data of each row
- while($row = $result->fetch_assoc()) {
- echo "Player: " . $row["player"]. " - Map: " . $row["maps"]. " - Time: " . $row["time"]. " - Style: " . $row["style"]. "<br>"; */
- });
- $discord->registerCommand('ping', function ($message) {
- return 'pong!';
- });
- $discord->registerCommand('shutdown', function ($discord) {
- $discord->close();
- });
- $discord->run();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement