#this

1 messages · Page 1 of 1 (latest)

brazen warren
#

yeah thats what i needed. Lemme make a thread to help you.

#

@swift badger

swift badger
#

okay thanks

#
  for (let i = 0; i != reactions.length; ++i) {
      // we use the index to calculate the time we want to wait: 750 * 0, 750 * 1, ... for each index.
      // that way we can ensure the `message.react` calls are separated 750 ms
      setTimeout(() => message.react(reactions[i]), 750 * i);
  }
}

  module.exports = async (client, id, text, reactions = []) => {
    const channel = await client.channels.fetch(id)
  
    channel.messages.fetch().then((messages) => {
      if (messages.size === 0) {
        // Send a new message
        channel.send(text).then((message) => {
          addReactions(message, reactions)
        })

            } else {
        // Edit the existing message
        for (const message of messages) {
         message[1].edit(text)
         addReactions(message[1], reactions)
        }

}
    })
  }```
brazen warren
#

tip: add the file extension after the 3 ` to get syntax highlighting

swift badger
#

okay !

brazen warren
#
const addReactions = (message, reactions) => {
  for (let i = 0; i != reactions.length; ++i) {
      // we use the index to calculate the time we want to wait: 750 * 0, 750 * 1, ... for each index.
      // that way we can ensure the `message.react` calls are separated 750 ms
      setTimeout(() => message.react(reactions[i]), 750 * i);
  }
}

  module.exports = async (client, id, text, reactions = []) => {
    const channel = await client.channels.fetch(id)
  
    channel.messages.fetch().then((messages) => {
      if (messages.size === 0) {
        // Send a new message
        channel.send(text).then((message) => {
          addReactions(message, reactions)
        })

            } else {
        // Edit the existing message
        for (const message of messages) {
         message[1].edit(text)
         addReactions(message[1], reactions)
        }

}
    })
  }
#

what is your issue again

swift badger
brazen warren
#

ah right

#

basically you fetched the channel

#

now in that channel you got a bunch of messages

#

wait

#

i think you sent the wrong file

#

I dont see this in the file you gave

swift badger
#
  console.log("The LS-Bot is Online")

   
    //START OF THE MESSAGE SEND by ITSELF 
    //Get the channel
    const channel = await  client.channels.fetch('969790950220132462');
    const sendMessage = await channel.send({
      content: '@.everyone',
      embeds: [{
        title: 'Embed Title',
        description: 'The Description',
        color: '#000000',
        image: {url: ''}, 
        footer: { text: 'This is a footer' } ,
        author: ({ name: `${member.user.username}`, iconURL: member.user.avatarURL({ dynamic: true }) })

      }]
    }) 
    //TO EDIT BOTS OWN MESSAGE
    //.then(x => x.edit('content'));

    sendMessage.react('💞')
   //END HERE```
#

that was added by me from my old bot and it seems to not work

brazen warren
#

uhh

#

that is not your full code

#

sned the entire file

swift badger
#

wait but it is

brazen warren
#

are you sure

swift badger
brazen warren
#

what member are you truing to get

swift badger
#

the authors picture and name

#

something like this

brazen warren
#

but

#

you are running that code when the bot starts

swift badger
#

is that bad ?

brazen warren
#

uh no

#

you pasted your code in the wrong place

swift badger
#

why ?

brazen warren
#

because why would you want to run that code when the bot starts

swift badger
#

thats kinda true. the code works tho. can i makle this lets say if i write !send in a specific private channel and this thing is sent to lets say #News?

brazen warren
#

To be honest I have no idea what you want to do

swift badger
#

its ok

#

i can explain

brazen warren
#

try to explain in detail what you are trying to do

swift badger
#

this script makes the bot send the message when its turned on

here is how it looks like :

now i am asking this

  • can i make the script to be sent when i want to? and not when the bot is turned on?
    -so like this, i write !Send in a private text channel that only the admins see, then the bot will function on my !send words and send the message in a public text channel
brazen warren
#

make a send command

#

and when you run it the command should send a message in your channel

swift badger
#

can you please help with that ?

#
    if (message.content === "!send") {```
#

something like this ?

brazen warren
#

ye

#

that looks like a start

swift badger
#

and write this on the top ?

brazen warren
#

yeah

#

in it make sure that the person running the command isnt a random person

#

aka make sure that the message author is you or smth

swift badger
#

how do i do that ?

brazen warren
#

and why do you need a bot to do this?

#

whats the point

swift badger
#

so that the bot sends a message by itself

#

andnot by me yk

brazen warren
#

ah ok

brazen warren
swift badger
#

okay lets do that a little later because i have this problem

brazen warren
#

ok then

#

do you have any existing commands setup?

swift badger
#

for this script ?

brazen warren
#

I think you didnt make this yourself

#

before modifying the code

#

figure out what the current code does

#

and how everything works

#

if you dont why are you even trying to do this stuff

swift badger
#

i watched the video by wornoff keys for 2 hours, i rewrote it myself and i modified it

#

and i understand it

brazen warren
#

seems like you dont considering you are trying to make a command inside of ready

swift badger
#

what do you want me to do?

brazen warren
#

I want you to find your event where you listen for new messages

#

and then copy paste your current code for making the command there

swift badger
#

what about this ?

#

could this be the..

brazen warren
#

uhh

#

idk what it is

#

your code is organized in a strange way

swift badger
#

it is? (

brazen warren
#

yeah

#

if you want a framework that does a ton of stuff for you and makes dev life actually easy I reccomending looking at the offical docs for their template or use sapphireJS

brazen warren
#

https://www.sapphirejs.com/ (note: I have some bias as I made the HMR module for this)

swift badger
#

@brazen warren is this like a frame ? where i wuld install things in it ?

brazen warren
#

its a framework

swift badger
#

should i make a new file and start from 0? and ,aybe it will be better ?

#

@brazen warren

brazen warren
#

itll be much easier

swift badger
#

alright

brazen warren
#

if you need help ping me

swift badger
#

okay

#

@brazen warren

#

should i have both of these ?

brazen warren
#

you are using normal nodejs right

swift badger
#

how do i check that

brazen warren
#

are you using import/export or require/module.exports

swift badger
#

the second i think

brazen warren
#

ok then

#

you are doing it correctl

swift badger
brazen warren
#

looks correct tome

swift badger
#

so i shoukd not add

#

here is what its telling me

brazen warren
#

?

swift badger
#

nothing

swift badger
#

@brazen warren

brazen warren
#

currently in a sveltekit thing

#

cant talk rn