izy521 / discord.io

A small, single-file library for creating DiscordApp clients from Node.js or the browser
https://discord.gg/0MvHMfHcTKVVmIGP
MIT License
535 stars 155 forks source link

sendMessage delivers in random order #275

Closed ClearFog closed 6 years ago

ClearFog commented 6 years ago

I'm trying to use sendMessage to send a couple of messages back to back but they go through in a random order. Is there a good way to make sure they go through serialized? I tried combining them into one longer message and that produced variable results as well.

cloudrac3r commented 6 years ago

Put the second sendMessage in the callback of the first.

bot.sendMessage({to: channelID, message: "first"}, err => {
    if (!err) bot.sendMessage({to: channelID, message: "second"});
});

You should join the discord.io server for questions like this in the future. I'm Cadence#3263, say hi!

vegeta897 commented 6 years ago

Mind posting the code you use to combine them? If it's one message, I don't see how it's possible for the order to get mixed up unless your code has bugs.

ClearFog commented 6 years ago

Well, turns out your both right. I had a bug in the combination code and the callback also worked.

Thanks for the quick response!