本文整理汇总了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 . '"');
}
示例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.');
});
}
示例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}");
}
}
示例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}`");
}
示例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}");
}
}
示例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, ', '));
}
示例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()}");
}
}
示例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");
}
示例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}```");
}
示例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.");
}
示例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()}");
});
}
示例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]}");
}
}
示例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();
}
示例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);
}
示例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);
}