Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- error_reporting( error_reporting() & ~E_NOTICE );
- use Discord\Discord;
- use Discord\WebSockets\Event;
- use Discord\WebSockets\WebSocket;
- use Discord\Parts\Guild;
- use Discord\Parts\Permissions\ChannelPermission;
- use Discord\Parts\Permissions\RolePermission;
- use discord\Parts\User\Member;
- $d=0;
- $rawdata=0;
- include 'INI.class.php';
- $ini = new INI('config.ini');
- // Parse config.ini
- // **** Emoji cheat sheet: http://www.emoji-cheat-sheet.com/ ****
- // ############## Usefull Code & Commands ###############
- // Send a Invite PM
- // -------------
- // $invite = $channel->createInvite();
- // $message->author->sendMessage("Invite: {$invite->invite_url}");
- // $message->reply('Invite sent in PM.');
- // Includes the Composer autoload file
- // ----------------------
- //
- // Bot Leave voice channel
- // -------------
- // $bot->voice->leave();
- // $message->reply('Leaving voice channel...');
- //-----------------------
- //
- // Send message to channel
- // $message->channel->sendMessage("msg")
- //
- // $message->author->id;
- include 'vendor/autoload.php';
- // if ($argc < 3) {
- // echo "You must pass your Email and Password into the cmdline. Example: php basic.php <email> <password>";
- // die(1);
- // }
- $d = $ini->read('config.ini');
- if(isset($d['settings']['email']))
- {
- $_SESSION['email']=$d['settings']['email'];
- }
- if(isset($d['settings']['owner']))
- {
- $_SESSION['owner']=$d['settings']['owner'];
- }
- if(isset($d['settings']['password']))
- {
- $_SESSION['password']=$d['settings']['password'];
- }
- if(isset($d['settings']['status']))
- {
- $_SESSION['status']=$d['settings']['status'];
- }
- echo "Testing status: " . $_SESSION['status'] . PHP_EOL;
- echo "Testing email: " . $_SESSION['email'] . PHP_EOL;
- echo "Testing pass: " . $_SESSION['password'] . PHP_EOL;
- // Init the Discord instance.
- $discord = new Discord($_SESSION['email'], $_SESSION['password']);
- // $discord = new Discord($d['settings']['email'], $d['settings']['password']);
- // Init the WebSocket instance.
- $ws = new WebSocket($discord);
- // We use EventEmitters to emit events. They are pretty much
- // identical to the JavaScript/NodeJS implementation.
- //
- // Here we are waiting for the WebSocket client to parse the READY frame. Once
- // it has done that it will run the code in the closure.
- $ws->on('ready', function ($discord) use ($ws) {
- $discord->updatePresence($ws, $_SESSION['status'], false);
- // In here we can access any of the WebSocket events.
- //
- // There is a list of event constants that you can
- // find here: https://teamreflex.github.io/DiscordPHP/classes/Discord.WebSockets.Event.html
- //
- // We will echo to the console that the WebSocket is ready.
- echo "Discord WebSocket is ready!".PHP_EOL;
- // Here we will just log all messages.
- $ws->on(Event::MESSAGE_CREATE, function ($message, $discord, $newdiscord) use ($ws) {
- if(($message->full_channel->guild->name == "Paradox Lounge") || ($message->full_channel->guild->name == "Death Legion"))
- {
- // $message->reply("Your role is " . $message->author->role);
- $dat = explode("#", $message->content);
- $rawdat=$dat[1];
- if(strpos($message->content, " ") > 0)
- {
- $dat = explode(" ", $dat[1]);
- $rawdat=$dat[0];
- }
- // ################## Link protection Removal ###################
- if((strpos($message->content, ".com") > 0) || (strpos($message->content, ".org") > 0))
- {
- if($message->full_channel->guild->name == "Paradox Lounge") // ## Channel Restrictions
- {
- $den=$message->author->username;
- $rmmessages = 0;
- $channel = $message->channel;
- $num = 0;
- $channel->message_count = $rmmessages + 1;
- foreach ($channel->messages as $key => $message) {
- try {
- $message->delete();
- } catch (PartRequestFailedException $e) {
- continue;
- }
- $num++;
- }
- $message->channel->sendMessage(":no_entry_sign: " . $den . " your link was removed due to our policy.");
- } // End of channel restrictions #######
- }
- // ############### end of link protection #####################
- if(isset($dat[1]))
- {
- if(($rawdat == "restart") && ($message->author->username == "Proxy"))
- {
- // system("cmd cd C:\xampp\htdocs\bot2");
- // system("cmd php basic.php");
- // $this->websocket->on('close', function () {
- // echo "[Close] WebSocket was closed.\r\n";
- $message->channel->sendMessage(":heavy_exclamation_mark: Restarting Bot");
- exec('c:\WINDOWS\system32\cmd.exe /c START C:\xampp\htdocs\bot2\Restart.bat');
- die;
- // });
- }
- if($rawdat == "mimic")
- {
- $msg=str_replace("#mimic ", "", $message->content);
- $message->channel->sendMessage(":speaker: " . $msg);
- }
- if($rawdat == "afk")
- {
- $msg=str_replace("#afk ", "", $message->content);
- $message->author->sendMessage("AFK Set: " . $msg);
- // $ini->data['afk']['data'][] = $message->author . "€" . $msg;
- // $ini->write('config.ini');
- }
- if($rawdat == "back")
- {
- $isafk="";
- $afkmsg="";
- $_SESSION['isafk']="";
- $_SESSION['afkmsg']="";
- }
- if($rawdat == "status")
- {
- try {
- // $message->reply("Attempting status change.:: ");
- $nerd=str_replace("#status ", "", $message->content);
- $discord->updatePresence($ws, $nerd, false);
- $ini->data['settings']['status'] = $nerd;
- }
- catch(\Exception $e)
- {
- $message->reply("There was an error running the command. `{$e->getMessage()}`");
- }
- }
- if($rawdat == "purge")
- {
- $rmmessages = $dat[1];
- $channel = $message->channel;
- $num = 0;
- $channel->message_count = $rmmessages + 1;
- foreach ($channel->messages as $key => $message) {
- try {
- $message->delete();
- } catch (PartRequestFailedException $e) {
- continue;
- }
- $num++;
- }
- $message->reply("Flushed {$num} messages.");
- }
- if($rawdat == "info")
- {
- $message->channel->sendMessage(":boom: **Paradox Bot** \n ``` Created By: Proxy \n Framework: DiscordPHP \n Version 0.0.1b ``` \n https://github.com/teamreflex/DiscordPHP");
- }
- if($rawdat == "kick")
- {
- $guild = $discord->guilds->get('name', 'Paradox Lounge');
- $members = $guild->members; // Returns a collection of members
- $memberToKick = $members->get('name', 'Gravebot');
- $memberToKick->kick();
- }
- if($rawdat == "role")
- {
- $guild = $discord->guilds->first();
- $role = $guild->roles->get('name', '@everyone');
- $message->channel->sendMessage("Changing roles for {$role} ");
- }
- if($rawdat == "mkchan")
- {
- $guild = $discord->guilds->get('id', '146064483121496064');////
- $everyone_role = $guild->roles->get('name', '@everyone');
- $allow = new \Discord\Parts\Permissions\ChannelPermission;
- $allow->create_instant_invite = true;
- $deny = new \Discord\Parts\Permissions\ChannelPermission;
- $channel = new \Discord\Parts\Channel\Channel();
- $channel->name = 'Testcreate';
- $channel->type = 'text';
- $channel->guild_id = '146064483121496064';
- $channel->save();
- $channel->setPermissions($everyone_role, $allow, $deny);
- // $channel->save();
- }
- } // isset end
- $reply = $message->timestamp->format('d/m/y H:i:s') . ' - '; // Format the message timestamp.
- $reply .= $message->full_channel->guild->name . ' - ';
- $reply .= $message->author->username . ' - '; // Add the message author's username onto the string.
- $reply .= $message->content; // Add the message content.
- echo $reply . PHP_EOL; // Finally, echo the message with a PHP end of line.
- }
- // Server name = $message->full_channel->guild->name;
- });
- });
- error_log("You messed up!", 3, "errors.log");
- // Now we will run the ReactPHP Event Loop!
- $ws->run();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement