Bot is stuck in request

async function editMessage(data, channelId, messageId) {
if (typeof messageId !== 'string' && typeof messageId !== 'number') throw new Error('Message ID must be a string or number! Not ' + messageId);
if (typeof channelId !== 'string' && typeof channelId !== 'number') throw new Error('Channel ID must be a string or number! Not ' + channelId);

return new Promise(async (resolve, reject) => {
console.log('Sending Request');

rest
.patch(`/channels/${channelId}/messages/${messageId}`, {
body: data,
})
.then((msg) => {
console.log('Request Done');
resolve(msg);
})
.catch(error => {
console.log('Request Errored');
reject(error);
});
});
}
async function editMessage(data, channelId, messageId) {
if (typeof messageId !== 'string' && typeof messageId !== 'number') throw new Error('Message ID must be a string or number! Not ' + messageId);
if (typeof channelId !== 'string' && typeof channelId !== 'number') throw new Error('Channel ID must be a string or number! Not ' + channelId);

return new Promise(async (resolve, reject) => {
console.log('Sending Request');

rest
.patch(`/channels/${channelId}/messages/${messageId}`, {
body: data,
})
.then((msg) => {
console.log('Request Done');
resolve(msg);
})
.catch(error => {
console.log('Request Errored');
reject(error);
});
});
}
it never logs the then() part or catch()
6 Replies
d.js toolkit
d.js toolkit15mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
sean
seanOP15mo ago
root@vmd89202:~/mygiveaways# npm ls @discordjs/rest
[email protected] /root/mygiveaways
├── @discordjs/[email protected]
└── @discordjs/[email protected] deduped
root@vmd89202:~/mygiveaways# npm ls @discordjs/rest
[email protected] /root/mygiveaways
├── @discordjs/[email protected]
└── @discordjs/[email protected] deduped
Parogo_72
Parogo_7215mo ago
refer to #useful-servers for non djs related questions oh nvm is rest
sean
seanOP15mo ago
it only stuck at the rest part? Okay something when I see it right it finished the promise after 30 seconds how is that possible ? Its only the edit request at a announcement channel message all other messages dont take so long to edit any ideas are welcome
space
space15mo ago
You might have hit a rate limit. Published messages in announcement channels do have a higher one iirc. Try listening to the rateLimited event.
sean
seanOP15mo ago
That actually makes sense and will be the reason for that 👍 Thanks for your reply
Want results from more Discord servers?
Add your server