yourWaifu / sleepy-discord

C++ library for the Discord chat client. Please use Rust for new bots
https://yourWaifu.github.io/sleepy-discord/
MIT License
708 stars 93 forks source link

Set UnavailableGuild to Guild #271

Closed gncdev closed 1 year ago

gncdev commented 1 year ago

on ready, discord gateway sends UnavailableGuild and Guild merge object for guild object. So we have access to Guild properties.

yourWaifu commented 1 year ago

That doesn't change anything. It just makes things very misleading. The ready object doesn't contain Guild objects, it just contains unavailable guilds with just the id to the guild.

gncdev commented 1 year ago

That doesn't change anything

No, If you want to get all of the guilds, you need to send get request to "guilds/{guild.id}" every each of guild. But if you collect all guild in "onReady" event to map, you can easily create an access to all of the guilds.

Actually, discord.js, discord.py, discord.go always do process with readyData. They are get first all of the guilds from readyData then they are keep looking for "onGuildUpdate" event for update guild map. When come "onGuildUpdate" event, updates the map which collected the all of guild data.

gncdev commented 1 year ago

But I can't found this feature in sleepydiscord

yourWaifu commented 1 year ago

This doesn't change that, with this change, you still need to wait for guilds to be sent to the bot

gncdev commented 1 year ago

This doesn't change that, with this change, you still need to wait for guilds to be sent to the bot

it doesn't. Ready data has all guild information. Actually ready data is result of merge Unavailable Guild and Guild

yourWaifu commented 1 year ago

Look at the docs https://discord.com/developers/docs/topics/gateway-events#ready

gncdev commented 1 year ago

Look at the docs https://discord.com/developers/docs/topics/gateway-events#ready

try my code.

    void onReady(SleepyDiscord::Ready readyData) override {
        for (SleepyDiscord::Server& server : readyData.servers) {
            std::cout << server.ID.string() << "->" << server.vanityUrlCode << "\n";
        }
    }

the UnavailableGuild doesn't have "server.vanityUrlCode" but if you declare the readyData.servers to std::list\<Server> (not std::list\<UnavailableServer>), you can see working what i said.

I think they are forget to update docs :)

yourWaifu commented 1 year ago

You should make an issue about it on the Discord docs or check someone already has

gncdev commented 1 year ago

did you try?

yourWaifu commented 1 year ago

No, because if this is true and intended, it should cause a ton of problems for big bots because ready would be a huge payload.

gncdev commented 1 year ago

it is true. please try it, i beggin you :)

yourWaifu commented 1 year ago

I'm asking you to make an issue about it on the docs to be sure if it's intended. Anything not on the docs might be unintentional.

gncdev commented 1 year ago

Why do you think a huge amount of payload is coming in ready?

gncdev commented 1 year ago

Just try my code.

yourWaifu commented 1 year ago

I can't, I'm busy. Just make an issue to discord docs to check that this is intentional and will stay in the long term.

gncdev commented 1 year ago

Okey, I will. But If you don't think like what I think, I can advise to you review discord.js or discord.py documentation.