Here are two examples, which one would work?js let targetChannel = null; if (systemChannel) { targetChannel = systemChannel; } else if (tempSysCh) { targetChannel = tempSysCh; } else { const dm = await owner .send(`Please Wait... ${e.loading}`) .then((targetChannel = owner), dm.edit("")) .catch(() => null); }orjs //on this one the dm is underlined let targetChannel = null; if (systemChannel) { targetChannel = systemChannel; } else if (tempSysCh) { targetChannel = tempSysCh; } else { const dm = await owner .send(`Please Wait... ${e.loading}`) .then((dm) => { targetChannel = owner; dm.edit(""); }) .catch(() => null); }
#Question about `.then()`
9 messages · Page 1 of 1 (latest)
- 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!
Option 1:
Option 2:
Option 3:
Would Option 3 work?
Option 2 would be correct but you don’t use the const dm which you define so don’t need it. Option 3 would also be correct but you don’t edit the dm message there. So it does something else than option 2. option 1 is simply wrong syntax because then(..) expects a function as first parameter
Option 3 is the updated one, the one I actually need. If Option 3 is okay I'll go with that one, thanks for the explaining 
Also , for good practices , you don’t need to initialize targetchannel as null , doing this would be the same thing
let targetChannel;