当前位置: 首页>>代码示例>>PHP>>正文


PHP Message::reply方法代码示例

本文整理汇总了PHP中Message::reply方法的典型用法代码示例。如果您正苦于以下问题:PHP Message::reply方法的具体用法?PHP Message::reply怎么用?PHP Message::reply使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Message的用法示例。


在下文中一共展示了Message::reply方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: handleMessage

 /**
  * Handles the message.
  *
  * @param Message $message 
  * @param array $params
  * @param Discord $discord 
  * @param Config $config 
  * @param Bot $bot 
  * @return void 
  */
 public static function handleMessage($message, $params, $discord, $config, $bot)
 {
     if (!isset($params[0])) {
         $message->reply('Please pass through a guild name.');
         return;
     }
     $guild = implode(' ', $params);
     $guild = $discord->guilds->get('name', $guild);
     if (is_null($guild)) {
         $message->reply('Could not find the guild!');
         return;
     }
     foreach ($guild->channels as $channel) {
         try {
             $invite = $channel->createInvite();
         } catch (DiscordRequestFailedException $e) {
             echo "Error attempting to create invite: {$e->getMessage()}\r\n";
             continue;
         }
         $message->author->sendMessage("Invite: {$invite->invite_url}");
         $message->reply('Invite sent in PM.');
         return;
     }
     $message->reply('Was unable to create an invite for "' . $guild->name . '"');
 }
开发者ID:uniquoooo,项目名称:DiscordPHPBot,代码行数:35,代码来源:Invite.php

示例2: handleMessage

 /**
  * Handles the message.
  *
  * @param Message $message 
  * @param array $params
  * @param Discord $discord 
  * @param Config $config 
  * @param Bot $bot 
  * @return void 
  */
 public static function handleMessage($message, $params, $discord, $config, $bot)
 {
     $bot->websocket->getVoiceClient($message->full_channel->guild_id)->then(function ($vc) use($message) {
         $message->reply('Leaving voice channel...');
         $vc->close();
     }, function ($e) use($message) {
         $message->reply('Could not find a voice channel for this guild.');
     });
 }
开发者ID:uniquoooo,项目名称:DiscordPHPBot,代码行数:19,代码来源:CloseVoice.php

示例3: handleMessage

 /**
  * Handles the message.
  *
  * @param Message $message 
  * @param array $params
  * @param Discord $discord 
  * @param Config $config 
  * @return void 
  */
 public static function handleMessage($message, $params, $discord, $config)
 {
     if ($discord->bot) {
         $appId = isset($config['app_id']) ? $config['app_id'] : '157746770539970560';
         $message->reply("This bot can't accpet invites, sorry! Please use this OAuth invite link: https://discordapp.com/oauth2/authorize?client_id={$appId}&scope=bot&permissions=36703232");
         return;
     }
     if (preg_match('/https:\\/\\/discord.gg\\/(.+)/', $params[0], $matches)) {
         $invite = $discord->acceptInvite($matches[1]);
         $message->reply("Joined server {$invite->guild->name}");
     }
 }
开发者ID:uniquoooo,项目名称:DiscordPHPBot,代码行数:21,代码来源:Join.php

示例4: handleMessage

 /**
  * Handles the message.
  *
  * @param Message $message 
  * @param array $params
  * @param Discord $discord 
  * @param Config $config 
  * @return void 
  */
 public static function handleMessage($message, $params, $discord, $config)
 {
     $prefix = isset($params[0]) ? $params[0] : $config['prefix'];
     $config['prefix'] = $prefix;
     Config::saveConfig($config, $config['filename']);
     $message->reply("Set the prefix to `{$prefix}`");
 }
开发者ID:uniquoooo,项目名称:DiscordPHPBot,代码行数:16,代码来源:SetPrefix.php

示例5: handleMessage

 /**
  * Handles the message.
  *
  * @param Message $message 
  * @param array $params
  * @param Discord $discord 
  * @param Config $config 
  * @return void 
  */
 public static function handleMessage($message, $params, $discord, $config)
 {
     if (preg_match('/https:\\/\\/discord.gg\\/(.+)/', $params[1], $matches)) {
         $invite = $discord->acceptInvite($matches[1]);
         $message->reply("Joined server {$invite->guild->name}");
     }
 }
开发者ID:comentarinformal,项目名称:DiscordPHPBot,代码行数:16,代码来源:Join.php

示例6: handleMessage

 /**
  * Handles the message.
  *
  * @param Message $message 
  * @param array $params
  * @param Discord $discord 
  * @param Config $config 
  * @param Bot $bot 
  * @return void 
  */
 public static function handleMessage($message, $params, $discord, $config, $bot)
 {
     $guilds = '';
     foreach ($discord->guilds as $guild) {
         $guilds .= "{$guild->name}, ";
     }
     $message->reply(rtrim($guilds, ', '));
 }
开发者ID:uniquoooo,项目名称:DiscordPHPBot,代码行数:18,代码来源:Guilds.php

示例7: handleMessage

 /**
  * Handles the message.
  *
  * @param Message $message 
  * @param array $params
  * @param Discord $discord 
  * @param Config $config 
  * @param Bot $bot 
  * @return void 
  */
 public static function handleMessage($message, $params, $discord, $config, $bot)
 {
     if (!isset($params[1])) {
         return;
     }
     try {
         eval('$response = ' . implode(' ', $params) . ';');
         if (is_string($response)) {
             $response = str_replace(DISCORD_TOKEN, 'TOKEN-HIDDEN', $response);
             $response = str_replace($config['password'], 'PASSWORD-HIDDEN', $response);
             $response = str_replace($config['sudo_pass'], 'SUDO-HIDDEN', $response);
         }
         $message->reply("`{$response}`");
     } catch (\Exception $e) {
         $message->reply("Eval failed. {$e->getMessage()}");
     }
 }
开发者ID:comentarinformal,项目名称:DiscordPHPBot,代码行数:27,代码来源:Evalu.php

示例8: actionReply

 public function actionReply()
 {
     RoutingEngine::setPage("Messages | runnDAILY", "PV__300");
     $message = new Message($_POST);
     //TODO:add in error exception in case the message cannot be created
     if ($message->reply()) {
         Message::updateCount($message->uid_to, 1);
     }
     Page::redirect("/messages");
 }
开发者ID:byronwall,项目名称:runnDAILY,代码行数:10,代码来源:messages.php

示例9: handleMessage

 /**
  * Handles the message.
  *
  * @param Message $message 
  * @param array $params
  * @param Discord $discord 
  * @param Config $config 
  * @param Bot $bot 
  * @return void 
  */
 public static function handleMessage($message, $params, $discord, $config, $bot)
 {
     if (!isset($params[0])) {
         $message->reply('Please provide a string to make fancy!');
         return;
     }
     $orig = implode(' ', $params);
     $string = str_split($orig);
     $finalString = '';
     $fancy = function () use(&$fancy, &$string, &$finalString, $orig) {
         $finalString .= implode(' ', $string) . PHP_EOL;
         $string[] = array_shift($string);
         if (implode('', $string) != $orig) {
             $fancy();
         }
     };
     $fancy();
     $message->reply("```{$finalString}```");
 }
开发者ID:uniquoooo,项目名称:DiscordPHPBot,代码行数:29,代码来源:Fancy.php

示例10: handleMessage

 /**
  * Handles the message.
  *
  * @param Message $message 
  * @param array $params
  * @param Discord $discord 
  * @param Config $config 
  * @return void 
  */
 public static function handleMessage($message, $params, $discord, $config)
 {
     $rmmessages = isset($params[0]) ? $params[0] : 15;
     $channel = $message->channel;
     $num = 0;
     $channel->message_count = $rmmessages + 1;
     foreach ($channel->messages as $key => $message) {
         if ($num >= $rmmessages) {
             $message->reply("Flushed {$num} messages.");
             return;
         }
         try {
             $message->delete();
         } catch (PartRequestFailedException $e) {
             continue;
         }
         $num++;
     }
     $message->reply("Flushed {$num} messages.");
 }
开发者ID:uniquoooo,项目名称:DiscordPHPBot,代码行数:29,代码来源:Flush.php

示例11: handleMessage

 /**
  * Handles the message.
  *
  * @param Message $message 
  * @param array $params
  * @param Discord $discord 
  * @param Config $config 
  * @param Bot $bot 
  * @return void 
  */
 public static function handleMessage($message, $params, $discord, $config, $bot)
 {
     if (!isset($params[0])) {
         $message->reply('Please enter a channel name!');
         return;
     }
     $channelName = implode(' ', $params);
     $channel = $message->full_channel->guild->channels->get('name', $channelName);
     if (is_null($channel)) {
         $message->reply('Couldn\'t find that channel!');
         return;
     }
     $bot->websocket->joinVoiceChannel($channel)->then(function (VoiceClient $vc) use($message, &$bot) {
         $message->reply("Joined voice channel.");
         $vc->on('stderr', function ($data) use($message) {
             $message->channel->sendMessage("**stderr:** {$data}");
         });
     }, function ($e) use($message) {
         $message->reply("Oops, there was an error joining the voice channel: {$e->getMessage()}");
     });
 }
开发者ID:uniquoooo,项目名称:DiscordPHPBot,代码行数:31,代码来源:JoinVoice.php

示例12: handleMessage

 /**
  * Handles the message.
  *
  * @param Message $message 
  * @param array $params
  * @param Discord $discord 
  * @param Config $config 
  * @return void 
  */
 public static function handleMessage($message, $params, $discord, $config)
 {
     if (isset($params[1])) {
         $user = $params[1];
         $level = isset($params[2]) ? $params[2] : 2;
         if (preg_match('/<@([0-9]+)>/', $user, $matches)) {
             $user = $matches[1];
         }
         $config['perms']['perms'][$user] = $level;
         Config::saveConfig($config);
         $message->reply("Set user <@{$user}> auth level to {$config['perms']['levels'][$level]}");
     }
 }
开发者ID:comentarinformal,项目名称:DiscordPHPBot,代码行数:22,代码来源:SetLevel.php

示例13: handleMessage

 /**
  * Handles the message.
  *
  * @param Message $message 
  * @param array $params
  * @param Discord $discord 
  * @param Config $config 
  * @param Bot $bot 
  * @return void 
  */
 public static function handleMessage($message, $params, $discord, $config, $bot)
 {
     if (!isset($params[0])) {
         return;
     }
     set_error_handler(function ($errno, $errstr) {
         if (!(error_reporting() & $errno)) {
             return;
         }
         echo "[Eval Error] {$errno} {$errstr}\r\n";
         throw new \Exception($errstr, $errno);
     }, E_ALL);
     try {
         $params = implode(' ', $params);
         $params = str_replace('```', '', $params);
         $params = "<?php\r\n" . $params;
         $fileName = BOT_DIR . '/eval/' . Str::random();
         file_put_contents($fileName, $params);
         // lint
         $lint = shell_exec('php -l ' . $fileName);
         if (strpos($lint, 'Errors parsing') !== false) {
             $message->reply("Erorrs linting the file: ```{$lint}```");
             restore_error_handler();
             return;
         }
         $response = (require_once $fileName);
         if (is_string($response)) {
             $response = str_replace(DISCORD_TOKEN, 'TOKEN-HIDDEN', $response);
             $response = str_replace($config['token'], 'TOKEN-HIDDEN', $response);
         }
         $message->reply("```\r\n{$response}\r\n```");
     } catch (\Throwable $e) {
         $message->reply("Eval failed. {$e->getMessage()}");
     }
     restore_error_handler();
 }
开发者ID:uniquoooo,项目名称:DiscordPHPBot,代码行数:46,代码来源:Evalu.php

示例14: handleMessage

 /**
  * Handles the message.
  *
  * @param Message $message 
  * @param array $params
  * @param Discord $discord 
  * @param Config $config 
  * @param Bot $bot 
  * @return void 
  */
 public static function handleMessage($message, $params, $discord, $config, $bot)
 {
     $str = "**Commands:** \r\n";
     $user_level = isset($config['perms']['perms'][$message->author->id]) ? $config['perms']['perms'][$message->author->id] : $config['perms']['default'];
     foreach ($bot->getCommands() as $command => $data) {
         if ($user_level >= $data['perms']) {
             $str .= "**_{$config['prefix']}{$command}_**";
             if (!empty($data['usage'])) {
                 $str .= " - _{$data['usage']}_";
             }
             $str .= "\r\n\t{$data['description']}\r\n";
         }
     }
     $message->reply($str);
 }
开发者ID:uniquoooo,项目名称:DiscordPHPBot,代码行数:25,代码来源:Help.php

示例15: handleMessage

 /**
  * Handles the message.
  *
  * @param Message $message 
  * @param array $params
  * @param Discord $discord 
  * @param Config $config 
  * @param Bot $bot 
  * @return void 
  */
 public static function handleMessage($message, $params, $discord, $config)
 {
     $str = "**DiscordPHP Bot**\r\n";
     $str .= "**Library:** _DiscordPHP_ " . Discord::VERSION . "\r\n";
     $sha = substr(exec('git rev-parse HEAD'), 0, 7);
     $str .= "**Current Revision:** `{$sha}`\r\n";
     $str .= "**PHP Version:** " . PHP_VERSION . "\r\n";
     $uptime = Carbon::createFromTimestamp(DISCORDPHP_STARTTIME);
     $diff = $uptime->diff(Carbon::now());
     $str .= "**Uptime:** {$diff->d} day(s), {$diff->h} hour(s), {$diff->i} minute(s), {$diff->s} second(s)\r\n";
     $ram = round(memory_get_usage(true) / 1000000, 2);
     $str .= "**Memory Usage:** {$ram}mb\r\n";
     $str .= "**OS Info:** " . php_uname() . "\r\n";
     $str .= "**Source:** <https://github.com/uniquoooo/DiscordPHPBot>\r\n";
     $str .= "\r\n**Author:** David#9512 `78703938047582208`\r\n";
     $str .= "**Server Count:** {$discord->guilds->count()}\r\n";
     $message->reply($str);
 }
开发者ID:uniquoooo,项目名称:DiscordPHPBot,代码行数:28,代码来源:Info.php


注:本文中的Message::reply方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。