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 toolkit10mo 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
sean10mo ago
root@vmd89202:~/mygiveaways# npm ls @discordjs/rest
mygiveaways@1.5.1 /root/mygiveaways
├── @discordjs/rest@1.7.1
└─┬ interactions.js@1.2.11
└── @discordjs/rest@1.7.1 deduped
root@vmd89202:~/mygiveaways# npm ls @discordjs/rest
mygiveaways@1.5.1 /root/mygiveaways
├── @discordjs/rest@1.7.1
└─┬ interactions.js@1.2.11
└── @discordjs/rest@1.7.1 deduped
Parogo_72
Parogo_7210mo ago
refer to #useful-servers for non djs related questions oh nvm is rest
sean
sean10mo 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
space10mo 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
sean10mo ago
That actually makes sense and will be the reason for that 👍 Thanks for your reply