an little help please?i really need it and i would apreciatte much if you would help me
Asked
Active
Viewed 1,048 times
1 Answers
1
First of all you need to find the channel ID. Best to go into the Discord app and right click the channel and select "Copy ID". It should look something like this: 845346073543326453
Now to send something to that specific channel you have to do this:
const channel = client.channels.cache.get(845346073543326453);
channel.send("hello!")
For the random messages you just create an array and randomly pick one:
const random = (min, max) => {
return Math.floor(Math.random() * (max - min + 1) + min);
}
let randomMsg = [`Howdy`, `Howdily doodily`, `Zoinks`]
channel.send(quotes[random(0, quotes.length - 1)])
To send it at a specific time there's many methods. I recommend using the cron
package and reference this post: How can I send a message every day at a specific hour?
But if you just want a quick and really low effort way you could just use setInterval() and set the delay to an hour. So we end up with something like this:
const channel = client.channels.cache.get(845346073543326453);
const randomMsg = [`Howdy`, `Howdily doodily`, `Zoinks`]
const random = (min, max) => {
return Math.floor(Math.random() * (max - min + 1) + min);
}
const sendRandomMsg = () => {
var d = new Date();
var n = d.getHours();
if (n === 12) {
channel.send(randomMsg[random(0, quotes.length - 1)])
}
}
setInterval(function(){ sendRandomMsg() }, 3600000);
You can add more functions into the if, in case you have more functions to run at specific times.

SINCOS
- 89
- 6
-
maybe you could help me – Vegert Jun 11 '21 at 20:57
-
Looks like I've just given the array with the random messages the wrong name by accident. I'll DM you – SINCOS Jun 12 '21 at 09:43
-
『 Tobi 『』#4269 on discord – Vegert Jun 12 '21 at 10:23
-
Unable to add you with that name – SINCOS Jun 12 '21 at 10:59
-
changed my name, add me now, TobiLOL#6969 – Vegert Jun 12 '21 at 11:18