Can't fetch correctly

i need to fetch a lot of times per command but it only fetchs once and stops after it
No description
9 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!
kute
kuteOP10mo ago
it used to work before adding to the bot
Unknown User
Unknown User10mo ago
Message Not Public
Sign In & Join Server To View
kute
kuteOP10mo ago
function loadCart(id, code){
var regex = /\b[A-Z0-9]{12}\b/;
try{ r = eval(code.replace(regex, id)); console.log(r) }
catch(err) { console.log(err) }
}
function loadCart(id, code){
var regex = /\b[A-Z0-9]{12}\b/;
try{ r = eval(code.replace(regex, id)); console.log(r) }
catch(err) { console.log(err) }
}
client.on('interactionCreate', async interaction => {
if(!interaction.isChatInputCommand()){ return; }
if(interaction.commandName == 'cart'){
const fetchResult = interaction.options.getString('fetch')
const amountResult = interaction.options.getString('amount')
interaction.reply('Adding to the cart... Please wait')
switch(amountResult) {
case '1.000':
loadCart('9NRFP18VHR2F', fetchResult)
sleep(5000)
loadCart('9N6LNP106BP3', fetchResult)
console.log('> works')
break;
client.on('interactionCreate', async interaction => {
if(!interaction.isChatInputCommand()){ return; }
if(interaction.commandName == 'cart'){
const fetchResult = interaction.options.getString('fetch')
const amountResult = interaction.options.getString('amount')
interaction.reply('Adding to the cart... Please wait')
switch(amountResult) {
case '1.000':
loadCart('9NRFP18VHR2F', fetchResult)
sleep(5000)
loadCart('9N6LNP106BP3', fetchResult)
console.log('> works')
break;
Unknown User
Unknown User10mo ago
Message Not Public
Sign In & Join Server To View
kute
kuteOP10mo ago
it is discord.js
Unknown User
Unknown User10mo ago
Message Not Public
Sign In & Join Server To View
kute
kuteOP10mo ago
? lol the code works when not applied to the bot ill add a check later, dw i know rn its not safe, but currently only i can use it i guess its because the response time or sum related to that
monbrey
monbrey10mo ago
I mean based solely on that 5s wait that's in there for some reason, you'll definitely need to defer
Want results from more Discord servers?
Add your server