Help

Aalexfa12/1/2022
hey, just need help with something. When I invoke the command, it reacts on the embed. (I forgot the code to do that feature lol)
ImageImage
Aalexfa12/1/2022
my verision is this.
Image
LLioness10012/1/2022
Please elaborate on what "it reacts on the embed" means
Aalexfa12/1/2022
As soon as I invoke the command, it shows this, then i want the bot to react on the invoked embed.
Image
LLioness10012/1/2022
Oh
Aalexfa12/1/2022
Example:
Aalexfa12/1/2022
Image
LLioness10012/1/2022
basically, where you write, message.channel.send(...), change that to const sentMessage = await message.channel.send(...) (make sure the function is async). Then, on the next line, you can use await sentMessage.react(...) (using the guide page to see what you pass to that function)
Aalexfa12/1/2022
This is my updated one.
Image
BBen85512/1/2022
Your reacting to whatever message the message variable represents, not the one sent on line 97. Store the response from 97 in a new variable or const and react to that like Lioness recommended
LLioness10012/1/2022
Also it would be helpful if you could send your code in text instead of screenshotting it
Aalexfa12/1/2022
okay 1 sec
Aalexfa12/1/2022
  if(message.content === prefix + "activitycheck") {
    channel1 = message.guild.channels.cache.find(r => r.name === "activity_checks")
    if (channel1) {
      if (!message.member.roles.cache.some(role => role.name === 'Management')) return message.author.send("
You Do Not Have The Correct Permissions To Run This Command
"), message.react("❌")
      let embed = new EmbedBuilder()
      .setColor(0x0099FF)
      .setTitle("**Activity Check**")
      .setDescription("> **Please React Below Proving That You Are Active (:below:)**")
      .setThumbnail("https://media.discordapp.net/attachments/1038860507467227176/1047544499812974612/standard.gif?width=205&height=205")
      .setTimestamp()
      .setFooter({ text: `Invoked By ${message.author.username} • ${message.guild.name}`});
      (async() => {
        let m = await channel1.send("@everyone")
        await m.delete();
        })();

      await channel1.send({embeds: [embed]})
      await message.react("✅")
      await message.delete()
    }
}
Aalexfa12/1/2022
So what would I do exactly?
BBen85512/1/2022
You do what is described here
LLioness10012/1/2022
Change
      await channel1.send({embeds: [embed]})
      await message.react("✅")

To
      const sentMessage = await channel1.send({embeds: [embed]})
      await sentMessage.react("✅")
LLioness10012/1/2022
I'd also recommend learning some more js basics
SSpinel12/1/2022
Before you make a Discord Bot, you should have a good understanding of JavaScript. This means you should have a basic understanding of the following topics:

- Read and understand docs
- Debug code
- Syntax
- NodeJS module system

If you aren't sure that your understanding of JavaScript is truly good enough to make a bot, you should really try to continue learning first. Here are good resources to learn both Javascript and NodeJS:

Codecademy: https://www.codecademy.com/learn/javascript
Udemy: https://www.udemy.com/javascript-essentials/
Eloquent JavaScript, free book: http://eloquentjavascript.net/
You-Dont-Know-JS: https://github.com/getify/You-Dont-Know-JS
JavaScript Garden: https://bonsaiden.github.io/JavaScript-Garden/
JavaScript reference/docs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference
Nodeschool: https://nodeschool.io/
Pluralsight: https://www.codeschool.com/courses/real-time-web-with-node-js

Before you ask a question, you should ask these yourself:
1) Is this question related to JavaScript, or the library I am using? - If it is the library you are using, go to the proper server. You would get better answers there.
2) Have I tried to google and / or check StackOverflow? - Double check that you can't find anywhere that can lead you to a solution online.
3) Have I tried to look on MDN or the library documentation? - You should always check documentations to make sure you aren't missing how any details.
4) Does my question make enough sense so that people can understand it, and do they understand what I am trying to accomplish? - If no, revise your question. Give as much detail as possible. Include any error or code output that can help us help you.
5) Am I aware of what I am doing, and not just mindlessly copy and pasting? - If you are just copy and pasting code from a guide, you are not going to be able to solve anything. Make sure you understand the code you are writing.
Aalexfa12/1/2022
Okay. Thank you so much!!
<E<3 execrate12/11/2022
You can also use "Then" and "Catch". "Then" so you don't have to pause the code to wait for the message to be sent and for the reaction to be use only if it's good. "Catch" to be sure that the asynchronous function (detached from the process) will not make an error that could crash your bot.
<E<3 execrate12/11/2022
When you use await in the main process the bot is in pause. In thread and process, all error not catch will be display and the program will close
LLioness10012/11/2022
That's not true
<E<3 execrate12/11/2022
Explain
LLioness10012/11/2022
await only blocks the scope it's called in and everything after it (in that block)
LLioness10012/11/2022
Since there's nothing else in the function, the await isn't blocking anything
LLioness10012/11/2022
Synchronous functions are what block the main thread
LLioness10012/11/2022
That's the whole point of async
<E<3 execrate12/11/2022
That's what I said
LLioness10012/11/2022
No, you said it blocks the main thread
LLioness10012/11/2022
Those are very different haha
LLioness10012/11/2022
Image
LLioness10012/11/2022
I think you just mixed the terms up, because synchronous methods are what block the main thread
LLioness10012/11/2022
For example, all of the fs sync methods
LLioness10012/11/2022
However, fs/promises methods do not
<E<3 execrate12/11/2022
Okkk, the first call come from an async?
<E<3 execrate12/11/2022
But you are right
LLioness10012/11/2022
?
<E<3 execrate12/11/2022
If you make an async call from the top, or the call come from an async event emitter (I think that it could be the same) and everything is await, the bot will be in pause
<E<3 execrate12/11/2022
If you use discordjs you always have this issues
<E<3 execrate12/11/2022
If you use sapphire I think that it have things to break that
LLioness10012/11/2022
Again, I'm pretty sure that's not true
LLioness10012/11/2022
Could you send a short code example so I can visualize what you're saying?
<E<3 execrate12/11/2022
I will try
<E<3 execrate12/11/2022
Maybe you're right
LLioness10012/11/2022
From the top (global scope), then I agree, but not from an async event emitter
<E<3 execrate12/11/2022
If you are right, I don't know why my bot was in pause when I was using command 😅
LLioness10012/11/2022
Mostly because I don't think async event emitter exists :KEKW:
LLioness10012/11/2022
Do you mean a client.on function that passes an async callback?
<E<3 execrate12/11/2022
Yes
LLioness10012/11/2022
👍
<E<3 execrate12/11/2022
Global scope I'm also sure
LLioness10012/11/2022
But also, if you didn't want to block the top scope with an async function, just put it at the bottom of the entry file
LLioness10012/11/2022
And if you can't, because something else depends on it being done, then it blocked the top scope for a reason haha
<E<3 execrate12/11/2022
@Lioness100 you are right
<E<3 execrate12/11/2022
sorry
<E<3 execrate12/11/2022
my test was
const EventEmitter = require("events");
const emitter = new EventEmitter();

let amount = 0;

emitter.on(
  "test",
  () =>
    new Promise((resolve, reject) => {
      const number = ++amount;
      console.log(`Called number ${number}`);
      setTimeout(() => {
        console.log(`Resolved after one second number ${number}`);
        resolve();
      }, 1000);
    })
);

emitter.emit("test");
emitter.emit("test");

console.log("I'm not waiting for the promises to resolve");