kendim için kullanıyorum paylaşmak istedim sadece bot token ve kanal id ve şifre editleyip kullana bilirsiniz iyi kullanımlar.

bot mesaj çeker mesaj iletir


<?php
// Hataları göstermek için hata raporlamayı etkinleştir
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

// Oturum başlat
session_start();

// Şifre kontrolü
$password = "4545";// şifre değiştirin

// Giriş doğrulaması
if (!isset($_SESSION['authenticated'])) {
    if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['password'])) {
        if ($_POST['password'] === $password) {
            $_SESSION['authenticated'] = true;
        } else {
            $error = "Invalid password. Please try again.";
        }
    } else {
        // Giriş ekranı
        echo '<!DOCTYPE html>
        <html lang="en">
        <head>
            <meta charset="UTF-8">
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
            <title>Login</title>
            <style>
                body {
                    display: flex;
                    justify-content: center;
                    align-items: center;
                    height: 100vh;
                    background: #333;
                    margin: 0;
                    font-family: Arial, sans-serif;
                }
                .login-container {
                    background: #2c3e50;
                    padding: 20px;
                    border-radius: 10px;
                    box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
                    width: 350px;
                    text-align: center;
                }
                .login-container h2 {
                    color: #ecf0f1;
                    margin-bottom: 20px;
                }
                .login-container img {
                    width: 100px;
                    height: 100px;
                    margin-bottom: 20px;
                }
                .input-group {
                    margin-bottom: 15px;
                }
                .input-group input {
                    width: 100%;
                    padding: 10px;
                    border: 1px solid #34495e;
                    border-radius: 5px;
                    background: #34495e;
                    color: #ecf0f1;
                    font-size: 16px;
                    outline: none;
                }
                .input-group button {
                    width: 100%;
                    padding: 10px;
                    background: #3498db;
                    color: #ecf0f1;
                    border: none;
                    border-radius: 5px;
                    cursor: pointer;
                    font-size: 16px;
                }
                .input-group button:hover {
                    background: #2980b9;
                }
                .error {
                    color: #e74c3c;
                    margin-top: 10px;
                }
            </style>
        </head>
        <body>
            <div class="login-container">
                <img src="https://sampmobile.com/file-quoiph9bmtberqus7g6ltbrl-removebg-preview-121x121.png" alt="Logo">
                <h2>Discord Bot Login</h2>
                <form method="post">
                    <div class="input-group">
                        <input type="password" name="password" placeholder="Enter Password" required>
                    </div>
                    <button type="submit">Login</button>
                    '.(isset($error) ? '<p class="error">'.$error.'</p>' : '').'
                </form>
            </div>
        </body>
        </html>';
        exit;
    }
}

// Discord Bot Bilgileri
$discordBotToken = "bottoken"; // Discord bot token
$discordChannelId = "Kanalid"; // Discord kanal ID

// Discord mesajları gönderme ve çekme işlemleri
if (isset($_POST['send_discord'])) {
    $discordMessage = $_POST['discord_message'];
    sendDiscordMessage($discordBotToken, $discordChannelId, $discordMessage);
    // Mesaj gönderildikten sonra otomatik olarak yeni mesajları çek
    $discordMessages = getDiscordMessages($discordBotToken, $discordChannelId);
}

// Discord'dan mesajları çekme işlemi
if (!isset($discordMessages)) {
    $discordMessages = getDiscordMessages($discordBotToken, $discordChannelId);
}

// Discord'dan mesajları çekme fonksiyonu
function getDiscordMessages($botToken, $channelId) {
    $url = "https://discord.com/api/v10/channels/$channelId/messages";
    $headers = [
        "Authorization: Bot $botToken",
        "Content-Type: application/json"
    ];

    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $response = curl_exec($ch);
    curl_close($ch);

    return json_decode($response, true) ?? [];
}

// Discord'a mesaj gönderme fonksiyonu
function sendDiscordMessage($botToken, $channelId, $message) {
    $url = "https://discord.com/api/v10/channels/$channelId/messages";
    $postData = [
        "content" => $message
    ];

    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        "Authorization: Bot $botToken",
        "Content-Type: application/json"
    ]);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postData));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_exec($ch); // Yanıtı alıyoruz ama bastırmıyoruz.
    curl_close($ch);
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Discord Bot Panel</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #ecf0f1;
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
        }
        .container {
            max-width: 900px;
            width: 100%;
            background-color: #ffffff;
            border-radius: 8px;
            box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
            padding: 20px;
            text-align: center;
        }
        .container img {
            width: 80px;
            height: 80px;
            margin-bottom: 20px;
        }
        .chat-box {
            width: 100%;
            height: 400px;
            margin-bottom: 20px;
            padding: 10px;
            border: 1px solid #ccc;
            border-radius: 8px;
            background-color: #f9f9f9;
            overflow-y: auto;
            display: flex;
            flex-direction: column-reverse; /* Son mesajlar aşağıda gözüksün */
        }
        .chat-message {
            background: #007bff;
            color: #fff;
            padding: 10px;
            margin: 5px 0;
            border-radius: 10px;
            max-width: 80%;
        }
        .chat-message.bot {
            background: #95a5a6;
            align-self: flex-start;
        }
        .chat-message.user {
            align-self: flex-end;
        }
        .input-group {
            margin-bottom: 20px;
        }
        .input-group label {
            display: block;
            margin-bottom: 5px;
        }
        .input-group input, .input-group button {
            width: 100%;
            padding: 10px;
            margin-bottom: 10px;
            border: 1px solid #ccc;
            border-radius: 4px;
            font-size: 16px;
        }
        .input-group button {
            background-color: #27ae60;
            color: #fff;
            cursor: pointer;
        }
        .input-group button:hover {
            background-color: #2ecc71;
        }
    </style>
    <script>
        // Sayfa yüklendiğinde chat kutusunu aşağıya kaydır
        document.addEventListener("DOMContentLoaded", function() {
            var chatBox = document.getElementById("discord-messages");
            chatBox.scrollTop = chatBox.scrollHeight;
        });
    </script>
</head>
<body>
    <div class="container">
        <img src="https://sampmobile.com/file-quoiph9bmtberqus7g6ltbrl-removebg-preview-121x121.png" alt="Logo">
        <h2>Discord Bot Panel</h2>

        <!-- Discord Mesajları Gösterme -->
        <div class="input-group">
            <label for="discord-messages">Discord Messages:</label>
            <div class="chat-box" id="discord-messages">
                <!-- Discord Mesajları Buraya Eklenecek -->
                <?php
                if (isset($discordMessages)) {
                    foreach ($discordMessages as $message) {
                        $author = $message['author']['username'];
                        $content = $message['content'];
                        $isBot = isset($message['author']['bot']) && $message['author']['bot'];
                        $messageClass = $isBot ? "bot" : "user";
                        echo "<div class='chat-message $messageClass'><strong>$author:</strong> $content</div>";
                    }
                }
                ?>
            </div>
        </div>

        <!-- Discord Mesaj Gönderme -->
        <form action="" method="post">
            <div class="input-group">
                <label for="discord-message">Send Message to Discord:</label>
                <input type="text" id="discord-message" name="discord_message" placeholder="Type your message here..." required>
                <button type="submit" name="send_discord">Send to Discord</button>
            </div>
        </form>
    </div>
</body>
</html>

Görseller