Untitled

 avatar
unknown
plain_text
2 years ago
1.3 kB
8
Indexable
#include <iostream>
#include <dpp/dpp.h>
#include <fstream>

int main() {
    std::string token = "TOKEN"; // Botunuzun Discord API token'ını buraya yazın
    std::string filePath = "/path/to/file.ext"; // İletmek istediğiniz dosyanın tam yolunu buraya yazın

    std::ifstream file(filePath, std::ios::binary);
    if (!file) {
        std::cerr << "Dosya açılamadı: " << filePath << std::endl;
        return 1;
    }

    std::vector<uint8_t> fileContents((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());

    dpp::cluster bot(token);

    bot.on_ready([&bot, &fileContents]() {
        std::cout << "Bot is ready!" << std::endl;

        // Hedef kanal ID'sini buraya girin
        const dpp::snowflake channelID = 1234567890;

        bot.message_create(channelID, "Dosyanızı buraya gönderiyorum!", [fileContents](const dpp::confirmation_callback_t& callback) {
            if (callback.is_error()) {
                std::cerr << "Mesaj gönderme hatası: " << callback.error.message << std::endl;
                return;
            }

            dpp::message msg = callback.reply;

            // Dosyayı ek olarak gönderme
            bot.message_create(channelID, "", dpp::message(fileContents, msg.attachments.front().filename));
        });
    });

    bot.start(false);

    return 0;
}
Editor is loading...