#development
1 messages ยท Page 1207 of 1
U wanna flex that u got ur bot to give Embed messages...
:/
a valid question
You have to do something like: *const chn = client.channel.cache.get("ChannelID")
And then chn.send(Embed)
@earnest phoenix

I'm new to creating bots, u can't doubt me :<
okay
@half elm user.avatarURL()
()?
True its a function
i see

That's why it isn't working
yes it's a method
Same thing
use displayAvatarURL() if you want to support default avatars
^
Otherwise wont show if the user has no avatar 
so i do function = async (stuff) => {}
no don't do that @half elm
async function bla(){
// code
}
so, exactly like this?
@ionic dawn
You have to do something like: *const chn = client.channel.cache.get("ChannelID")
And then chn.send(Embed)
const user = message.mentions.users.first() || message.author; const avatarEmbed = new Discord.MessageEmbed() .setColor(0x000000) .setAuthor(user.username) .setImage(user.avatarURL); message.channel.send(avatarEmbed);
@half elm make this be member instead
Like
member.username?
const user = message.mentions.members.first() || message.member
ah
It would be the samd
well
Instead of getting a user
It gets a member of the server you are currently in
Meaning you can still access their user data
But you can see displayAvatarURL iirc
this looks like it should work but it still throws the async error
oh thank you
i have seted my interval as 180000 but it sends every 1min
works, but i have an "undefined" somehow
Code again?
const user = message.mentions.users.first() || message.author;
const avatarEmbed = new Discord.MessageEmbed()
.setColor(0x000000)
.addField(`${user.username}'s Avatar`)
.setImage(user.displayAvatarURL());
message.channel.send(avatarEmbed);
do i need a title
Fields vace 2 values
Have*
lmao no
true
oh yeah
can i use that in place of title?
xD
Like val: "hey", val: "nice"
i have seted my interval as 180000 but it sends every 1min
Use title instead ye
@ionic dawn
@weak rain
?
send code pls
kk
Cant fix my own bot but can help others
๐
const channel = message.guild.channels.cache.find(channel => channel.topic === "Memes");
if(!channel) return; let data = await random.getMeme()
channel.send(data)
}, 180000) ```
Do you have multiple intervals?
no
I dont think this is the right way to set the interval tbh
its okay i guess
Actually in on phone and read that is kinda crazy
Same
var interval = setInterval (async function (guild) {
const channel = message.guild.channels.cache.find(channel => channel.topic === "Memes");
if(!channel) return;
let data = await random.getMeme()
channel.send(data)
}, 180 * 1000);
try this
i guess
Mathemagician


๐
const num = 1
const num = 1 * 1
lmao no

const user = message.mentions.users.first() || message.author;
const avatarEmbed = new Discord.MessageEmbed()
.setColor(0x000000)
.addField(`${user.username}'s Avatar`)
.setImage(user.displayAvatarURL());
message.channel.send(avatarEmbed);
i did that
YEP
so that he can multiply with min
Just with js
lmao
tf
Used more than your YouTube API limit
@no xp
You can or you could just wait
24h?
Yes
um uh
Or until the time it says
ill just change it 
ok
@sharp thicket which code
here i get this error
(node:4) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'queue' of undefined
at play (/app/commands/utility/system.js:9:23)
at Object.run (/app/commands/config/play.js:132:9)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:4) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
2020-09-01T06:52:25.278105+00:00 app[worker.1]: (node:4) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```
@pure lion wait ima get a bin real quick
this is my play.js
@pure lion u there?
ok ytping..
sry
Where is queue
also
lol i did
thats my index.js
@pure lion
also i changed my api token
@pure lion sorry for the pings im getting a new error...
(node:4) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'get' of undefined
at play (/app/commands/utility/system.js:8:29)
at Object.run (/app/commands/config/play.js:132:9)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:4) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:4) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```
anyone any help
?
:(
Hey! How could I make a custom time format. Like 1h = 60m = 3600s = 3600000ms?
@sharp thicket send your code.
oh
wait nvm
discord.js v12?
can i have the play command
that's where the issue is.
A fuckton of .replaces is an option if not through regexes
LOL
.repace
@slender thistle, how? Find filter and then get the hour in ms * the time?
.replace("h", "*60") and run the expression through a package for math expressions
ok ty
60 minutes converted to seconds being m replaced with *60 etc
how do i make a bot send messages every 10 minutes?
@earnest phoenix you need to use the setInterval.
ntf
setInterval(() => {
// code
}, time in ms);
thats it?
Yep ;p
Aight, thanks mate
๐
๐
i feel scared
Why
idk l;-;
Where do i put the time?
setInterval(() => {
// code
}, this is where i put time?);
See the time in ms part?
yes
What do you think that would be?
The first parameter (the () => stuff) is the function to run
The second parameter is... yeah, that's where you put the time (measured in milliseconds). It will be the interval between each function execution
Why not just Google 10 minutes in milliseconds
Time conversion is a helpful skill in life :p
Smart
or, hell, calculate it yourself
600,000
a minute consists of 60 seconds
a seconds of 1000 milliseconds
so, that's 10*60*1000
huh ;-;
which, when calculated, does actually give you 600 thousand milliseconds
why are u people so smart
They don't teach this shit in early grades anymore?
nope ;-;
They don't teach this shit in early grades anymore?
@slender thistle no
In my grade we're still learning 1+1
I get trigonometry and generally calculus, but
this is like the very basic thing that's quite helpful in life
I get trigonometry and generally calculus, but
@slender thistle you get what and what
anyways, how do i put a mesage into it?
you want to send a message to a certain channel, correct?
uhh, yessir
Well, get the channel (not exactly familiar with d.js nowadays, I suggest looking up the documentation) and send the message? :^)
if the channel is in the same guild as the message, you can get the channel using message#guild#channels. otherwise, get the channel from client#channels, https://discord.js.org/#/docs/main/stable/class/Client?scrollTo=channels
Where will the message param be received though?
the message event?
๐ I thought they wanted an interval?
Wdym?
i'm making something like pokemon, but the pokemon are dinosaurs
Its gonna go with the theme of my MC realm (DinoSMP)
what does an interval even do?
still learning ;-;
Do you know the definition of "interval"?
n o
Wdym?
i'm making something like pokemon, but the pokemon are dinosaurs
oh
ahh, interval means a time, or break in certain activity like a plug in a pipe making it stop from water going through?
ye
I see
what do u want the bot to do
do X, wait Y time, do X
Y being the interval
I just want to get it to send messages every 10 minute, and then i want to code leveing and stuff
oh
will u make the bot public
or only use it in ur server
It depends on if there is already a bot like that
with dinosaurs
dinos?
nice
hi can anyone help with my music command here are m main files
https://sourceb.in/6457dc6717
https://sourceb.in/73cbfb11f2
whenever i do say like a!play the box it says playing the box but doesn't join any help?
maybe u can put a loop which runs every x minutes in on_ready function
me?
oh lol
huhh
i have a big brain, but my big brain is filled with stupidity, i dont unerstand what that means ;-;
oh
its like..
u need to code a loop which executes as soon as the bot comes online
isnt there a function
throwback to the setInterval function
You'd need to use setInterval, as suggested before
where in the code?
in the ready event possibly
Oh, setInterval(() => {
// code
}, 1 billion ?);
.-.
yeah, alright, but now i just need it to send message
grab channels
and send messages
no its 1 billion
10 minutes is 600 thousand milliseconds though
So where do i put the message code? on top of setInterval, or?
10 minutes is 600 thousand milliseconds though
@slender thistle
i know
Replace the // code part with your code that will fetch a channel and send a message to it
so i replace code with channel name or ID
huh
I need help adding a role to a user so like [p]add @mossy slate [role]
discord.js?
yes
role mention or id
hey uh, is it kinda bad that im just now tryna learn jsx so i can script a bot of my own
eeh
hey uh, is it kinda bad that im just now tryna learn jsx so i can script a bot of my own
@near bone I don't think so
also, are we allowed to try and hire teams here
no
k
I need help adding a role to a user so like [p]add @mossy slate [role]
HELP ME \๐
be patient
ok sorry \๐
Replace the
// codepart with your code that will fetch a channel and send a message to it
@slender thistle
message.channel.send(' ')?
looks correct but make sure that's what you want, the bot sending in the message's channel
bulli
heh
setInterval(() => {
// your code
}, 600000);```
yup
600000 can be any time in ms
600000 is 10 mins
lazy and bot designing do not mix well
you can use an time to ms conventor
the your code is replaced with message.channel.send('test')
yes
How to host my discord bot free?
How to host my discord bot free?
@earnest phoenix top.gg
How
How to host my discord bot free?
@earnest phoenix Local Host, heroku
they said host
that's not hosting the bot
-vps @earnest phoenix
@earnest phoenix
A VPS or virtual private server is a virtualized server instance run in the cloud. It acts like a normal server, allowing you to remotely login and manage it just like a physical server or computer. If you're looking for a way to keep your bot online 24/7, a VPS is a great option.
Having trouble choosing a VPS provider or don't know where to start? Click here for a list of common and affordable VPS providers.
question
is it a good idea to go and try to use google docs as a thing to put all my code into
Does anyone have a translate Api?
Does anyone have a translate Api?
@wild current google
killua
Lol, yes
i'm new to coding overall, so i dont really know
I didn't found on google
i know, that was a joke
code:
const input = message.content.slice(prefix.length).toLowerCase().replace(/\s+/g, ` `).trim();
const [, cmd, commandArgs] = input.match(/(\w+)\s*([\s\S]*)/);```
When I type "/........."
error:
TypeError: object null is not iterable (cannot read property Symbol(Symbol.iterator))
at Client.<anonymous> (.\code.js:2:30)```
im doing a tutorial for react.js and im not sure what this even means
is there an actual way to do this
{ [key]: value }
yes, its a dynamic object key
im doing a tutorial for react.js and im not sure what this even means
@near bone this things are html
you definedp1as "poo" inside an html paragraph tag
then, a button tag with id "mybutton".
then again, you definedp2as "bar" in another html paragraph tag
so
const key = 'bob'
const value = 'fred'
that'll produce { "bob": "fred" } right
yup
can anyone help me understand the error?
code:
const input = message.content.slice(prefix.length).toLowerCase().replace(/\s+/g, ` `).trim();
const [, cmd, commandArgs] = input.match(/(\w+)\s*([\s\S]*)/);```
When I type "/........."
error:
TypeError: object null is not iterable (cannot read property Symbol(Symbol.iterator))
at Client.<anonymous> (.\code.js:2:30)```
oh hey
it's just come to my attention that there's a full reference thing in a certain thing on discord's website
under the resources tab on the developer portal
@sterile thicket that happens if input is empty
so
is it just like some sort of crossword, where i just have to match along certain keywords to make the system do something
@sterile thicket that happens if input is empty
@quartz kindle but input it "/......."
not empty
And I used if (!input.length) return; before input.match()
so, it shouldn't give me the error
match found no matches
how do I fix this?
ok, so I can do if (!input.match()) return; right?
yes
thanks
save it in a variable so you dont parse it twice
let test = input.match()
if(!test) return
const [,cmd,args] = test
nothing, just waste of cpu
ok
@quartz kindle Upgraded to v3, now my log is filled with this error:
if i console.log the message via my eval command author is properly set
weird
Your Line 2 is hardcoded
!msg.guild || msg.channel.type === "dm" :D?
Pointless to do both imo
why node.js for linux is outdated? (v10)
installed with sudo apt-get install nodejs
install using the proper method then
can't install from the website, unpacked the archive (tar.xz) to /usr/local/bin/lib/nodejs
says to install nodejs
try this https://github.com/nodesource/distributions or https://hosting.review/tutorial/how-to-update-node/
is there a node command prompt for linux?
use node version manager
i am on inux and i can't do heroku commands it needs to install a snap, but i have installed the npm package heroku in my bot folder
@tight plinth supposedly some messages have no author fields, try checking the webhook id before you check for bots
k
if you're using the message editing script, then thats especially true
since some messageUpdates only contain an ID and embed, and nothing else. so just do if(!message.author)
i am on linux and i can't do heroku commands it needs to install a snap, but i have installed the npm package heroku in my bot folder
@cinder sandal
@cinder sandal why do you need heroku commands?
why node.js for linux is outdated? (v10)
installed with sudo apt-get install nodejs
Depends on the distro. Sometimes something depends on it.
to login in the heroku cli
fast developing packages are always outdated on linux
If you're on linux why use heroku?
Unless it's not a VPS and it's their desktop OS then maybe.
it's my desktop os
You don't need to use snap.
They provide a standalone installation (on Debian systems without snap).
you probably dont need the npm package either, unless you want to control heroku from inside your bot
To push the bot from within the bot?
Well, you can install the heroku cli using npm install -g heroku
Then from there you run your needed commands.
How can i fix this? It was working before i restart the bot.
Read the docs?
anyway, will install from Discover
The CLI?
yes
Docsu okusam burada yazmazdฤฑm zaten
English.
this would work to get the content of an embeds footer, right
message.embeds[0].footer.text
pretty sure i'm right but too tired to be 100% sure
i know but you get lazy sometimes 
@quartz kindle https://canary.discordapp.com/channels/264445053596991498/272764566411149314/750289387819892800 didnt worked, still get the same error
Well, you can install the heroku cli using
npm install -g heroku
@warm marsh sry for ping, but worked
ty
@tight plinth did you do #development message
no, didnt see that you edited it
np
if I am using Bot ghost but the status is offline can the devs able to know that i am using Bot Ghost
@sage meadow maybe botghost is in maintanance, or wrong token
how could i hide a div but only show it if the user is at url#divname
if I have made the status offline, can the devs able to know that i am using Bot Ghost
dont spam the same question over and over again
That's stupid anyways, it would circumvent bot ghosts free usage policies
And won't work
ok
pokecord 2.0 using botghost
@quartz kindle yes
Can someone help me, I get this error and I'm not sure what to do, I've never used aysnc before
C:\Users\Jon\Desktop\SpiderBot Command Handler\commands\purge.js:20
await message.channel.messages.fetch({ limit: amount }).then(messages => {
^^^^^
SyntaxError: await is only valid in async function```
execute
You need to change it to async execute where you need an async
Oki, thankyou
No problem
i forgot the syntax of client.user.setPresence can someone quickly link me the docs cuz i am too lazy
You need to change it to
aync executewhere you need an async
@fringe axle spelling of async wrong
thanks
Faster :0
working on a smol repl.it template which people can use to make bots
does this mean which properties we can set to the activity object or are they parameters we can pass in client.user.setPresence???
i seriously need to learn how to read docs
activity.x - properties of the activity object parameter
activity, shardID, and status being parameters
shardID ain't a property of activity
imagine fixing someone's errors when they're the one trying to fix your errors
it's a parameter
also in node.js fs if i pass a file name in fs.readFileSync(); without any path does it default to the directory name of the current node.js process + the name of the file?
example:
const fs = require("fs");
const config = fs.readFileSync("config.json");
config = JSON.parse(config);
How can I see the users custom presence (The text or emoji what they wrote in)? discord.js v12
This
accidentally sent the message without typing the whole thign
so...
fs.readFileSync(__dirname + "/config.json");
is the same as...
fs.readFileSync("config.json");
and/or is the same as...
fs.readFileSync("./config.json");
./ is for parent folder
wait wut
ah, still fucking that up
current working directory
absolute path is usually not a good idea thouhg
specially if you eventually need to move stuff around
How can I see the users custom presence (The text or emoji what they wrote in)? discord.js v12
iterate through activities and find a status with type equal to something like custom or custom_status
Hm, okay
<User>.presence.activities``` use the `find()` method on this
Find the custom status type and get the custom emoji if available by accessing the emoji property
Okay
Hello
How can I make a code having a role heirarchy?
its like an if statement
idk
how to do it?
can someone help me,
TypeError: Cannot read property 'rowsAsArray' of undefined
this error comes from
Connection.createQuery(`SELECT * FROM money WHERE id = '${message.author.id}'`, (err, rows) => {
that statement monkaw
Flazepe
Wdym.
you can compare the role position
compare their highest role (member.roles.highest.position) with the bot's
like member.roles.highest.position > guild.me.roles.highest.position
wait
make sure it's a member
Like for example, I want to ban someone, and first, the bot will check something. It will check if I have my role above his role, if I have it below his role, it will NOT execute, it will return
i see
like if (memberHighestRolePosition >= botHighestRolePosition) return;
>= would be equal or higher than
if it is below, it won't return
you can continue your code like normal
it's just a check
I want that check
yes, you need that check
I want it to check if the author is above the target role, if not, it should return
yeah
But I cant seem to figure out the code
Take this for example.
I have the target for the ban defined as banMember, and I want to check that if my role is lower than his role, it will return
is it
you don't want to check the bot's role instead?
you should do both or the bot's only (if you use roles names)
Ill do it for both..
I know
if(banMember.roles.highest.position > guild.me.roles.highest.position || banMember.roles.highest.position > author.roles.highest.position) return;
Like that?
if(banMember.roles.highest.position >= guild.me.roles.highest.position || banMember.roles.highest.position >= author.roles.highest.position) return;
yes
if you want to have different messages, then no
Which is better, different messages?
different messages for clarity
Better..
if(banMember.roles.highest.position > guild.me.roles.highest.position) return;
if(banMember.roles.highest.position > author.roles.highest.position) return;
Like that?
Last check
well you can combine them if you're just going to return
but yes
i'm assuming you will have different text for both
Nah
oh, combine them then
Ill make it send same embed! ๐
is author.roles.highest.position a thing?
Cause at, ```if(banMember.roles.highest.position > guild.me.roles.highest.position) return;
if(banMember.roles.highest.position > author.roles.highest.position) return;``` I wrote it like that
I check this first, if(banMember.roles.highest.position >= guild.me.roles.highest.position) return;
I check this second, if(banMember.roles.highest.position >= author.roles.highest.position) return;
>= and combine them
since you're going to send the same embed
The first one is correct right?
yeah
banMember.roles.highest.position > guild.me.roles.highest.position
>= for both
yes
ok
make sure you define guild too
if(banMember.roles.highest.position >= message.member.roles.highest.position) return;
yep
make sure you define guild too
@pale vessel there is no guild on my code
nbm
nvm
woops
you mean
message.guild?
@pale vessel
not defined yet
ah i see
it is like
if(target > you/bot) return:
;
the defined target changes depending on where the code location is
whether kick or ban
My bot seems to be returning a 'channel isnt defined' error whenever I try to purge some messages with my purge command, My bot can purge them fine, But the bot only returns a channel isnt defined error, and not a success embed, https://hastebin.com/ukifihifog
Well
await message.channel.messages.fetch({ limit: amount }).then(messages => {
message.channel.bulkDelete(amount, true).message.channel.send(SuccessfullyDone);
});
const SuccessfullyDone = new Discord.MessageEmbed()
Not sure you can do this bit true).message.channel idrk tbh
Also, you're defining the success embed after you try to reference it. For some reason
You should probably put that one two new lines and not try to string them together with a .
message.channel.bulkDelete(amount, true);
message.channel.send(SuccessfullyDone);
For example
@pale vessel
It still kicked the user.
Same roile, and kicked.
*role
wait
waittt
one sec
i gotta eat lol
Now i get a 'send is undefined' trying to do this
await message.channel.messages.fetch({ limit: amount }).then(messages => {
message.channel.bulkDelete(amount, true).then(message => {
message.channel.send(SuccessfullyDone);
});
});```
oh, ty
is there a way to specify a date and do - Date.now to see how many days, months left until that date?
im trying to make a countdown command that'll count down till new year
Hmmm
new Date(date info here)
channel = bot.get_channel(72246xxxxxxxxx)
await channel.send("Hey!!")
schedule.every().day.at("18:00").do(job)
while 1:
schedule.run_pending()
time.sleep(1)```
```RuntimeWarning: coroutine 'job' was never awaited```
solution??
it supports several different ways if inputting a specific date
check it out online for some examples
check it out online for some examples
will do, thanks again
you need to type cast
fuuuuck
let channel = message.channel as Discord.TextChannel
if(!channel.nsfw)
just dont use ts :^)
Js too lax for me
or create your own context with channel, message and author etc.
more work yet more reliable
type casting should work fine
cuz i already did a check for both of the other types
yeah but you'll have to do that for each of your commands
only 3
fortunately
i dont use nsfw as often as you'd think
though there might be other cases where it might come
you can make a helper function
wdym?
async def job():
channel = bot.get_channel(72246xxxxxxxxx)
await channel.send("Hey!!")
schedule.every().day.at("18:00").do(job)
while 1:
schedule.run_pending()
time.sleep(1)```
```RuntimeWarning: coroutine 'job' was never awaited```
help??
for example
something like this lmao ```js
Discord.Structures.extend("message", M => class Message extends M {
get channel() {
switch(super.channel.type) {
case "text": return super.channel as TextChannel
case "dm": return super.channel as DMChannel
}
}
})
idk why thats even passing tbf
ACTUALLY
one second
i would assume ts would be smart about this
i can probably cast it before sending, no?
idk if it'll be smart enough to know the only type coming is TextChannel
lets try it
ยฏ_(ใ)_/ยฏ
i dont think ts will automatically cast it as TextChannel from that
you can also try (<TextChannel>message.channel).nsfw
idk if thats how it works
edited
hmmmm
it at least allows me to

lets see
those are two patches but i might still wanna dig into this to future proof it

Hello
i have a question
how do i use discordpy to send a message in a specific channel?
like if someone joins a server, how do i send them a message in the discord server
i know how to send them a private message, but not in the actual server so that everyone knows
you need to go through the list of channels the guild has and find one where your bot has permissions to send
so how would i do that?
Read the docs.
which ones?
The ones for your library.
ok
you can try checking if the guild has a system channel
which is the channel you define for default welcome messages and server boosts
but if they dont have a system channel, then you need to do what i said before
something along the lines of
if member.guild.system_channel
member.guild.system_channel.send(content="hi")
ok what are the actual benefits of ts
The main advantage is that it's a strictly typed superset of JS
ok what are the actual benefits of ts
@honest perch It's closer to OOP

that's 3 seconds
@faint prism ok but what are the benefits of it over just using js
You have to multiply by 60 as well
3 * 60 * 1000 is 3 secs
I don't use ts or js, but I've heard great things
no, that's 3 minutes
lol
3 * 1000 is 3 seconds
i meant 3 mins
yes
oh ty

3 x 1000 milliseconds = 3000 milliseconds or 3 seconds
3000 milliseconds x 60 = 180,000 milliseconds = 3 minutes
Whenever you deal with milliseconds, it might be easier to *1000 to work with seconds
is discord.js internal sharding (not the d.js sharding manager) good?
my bot sends messages after 3min after the command but when it starts sending then it sends after seconds
@cinder patio HEY
Post code
if(message.author.bot) return;
if(!message.guild) return;
let prefix = db.get(`prefix_${message.guild.id}`)
if(prefix === null) prefix = default_prefix
if (message.mentions.has(client.user.id) && !message.content.includes("@everyone") && !message.content.includes("@here")) {
let mentionEmbed = new Discord.MessageEmbed()
.setColor("RANDOM")
.setAuthor(" ")
.setDescription(`**My prefix for ${message.guild.name} is [ ${prefix} ]**
**Type ${prefix}help for commands of the bot**`);
message.channel.send(mentionEmbed)
}
var interval = setInterval (async function (guild) {
const channel = message.guild.channels.cache.find(channel => channel.topic === "Memes");
if(!channel) return;
let data = await random.getMeme()
channel.send(data)
}, 3 * 60 * 1000); ```
see interval one
var interval = setInterval (async function (guild) {
const channel = message.guild.channels.cache.find(channel => channel.topic === "Memes");
if(!channel) return;
let data = await random.getMeme()
channel.send(data)
}, 3 * 60 * 1000); ```
Which server
discord
and what about mine?
If the error is 5xx, it's the server's fault. That's all you really need to know.
@weak rain I assume it's sending multiple messages in that 3-minute timespan.
Yes
If that's the case, it's because you're creating a setInterval (do something every X milliseconds) in the message event. Where and when are you clearing the interval?
To put it simple: when the message event is emitted, you're adding another interval to run every X milliseconds.
What is the intended behavior.
Do you want it to do something after 3 minutes and only once
Yes
Consider using setTimeout
It's like setInterval but after the first run it stops so it's not repeating.
sorry but do u have any example code as i m new
rename setInterval to setTimeout
Or here is may be better
https://javascript.info/settimeout-setinterval
Don't set an interval / timeout directly inside the message event
bot is still sending multiple messages
const channel = message.guild.channels.cache.find(channel => channel.topic === "Memes");
if(!channel) return;
let data = await random.getMeme()
channel.send(data)
}, 3 * 60 * 1000); ```
@cinder patio
@sudden geyser
My visual studio code is closed
My pc too
bot is still sending multiple messages
@weak rain mine too sometimes it sends 2 or 3 times the same answer
ads be like pog
@earnest phoenix sir i want
@earnest phoenix not same
generated ones
every time new
but i only want 1 at a time
@earnest phoenix https://youtu.be/vf9EJsIgkN8
Welcome to the Blob Development, Season 2 !
Song Compilation by Chillhop
https://www.youtube.com/watch?v=s49CT4DTAkw
Source Code: https://github.com/Blob-Development/bot-tutorial-season-2
===
Chapters:
00:00 Intro
00:12 Preparing
01:49 Building a server.js
05:45 Building...
If I'm running js exec("./core.js"); how can I add my client that I've started to this child process?
ping? @earnest phoenix
How can I add to my status in how much servers and how much members the bot is in?
@gritty bolt?
What?
I was trying to start a seperate process for the key functions of my bot but I don't think thats gonna work well
So I'm gonna just turn them into functions instead
or actually that might work
pretty much what i was trying to do was spawn a child process and take my discord.Client into it with me
so if anyone could help me with that it would be great
@earnest phoenix for servers
hi all, it seems ctx.invoked_with only returns the first arg if its separated by spaces - is there a way to get the full arguments? eg command! abcd efgh i need abcd efgh but only getting abcd ?
@earnest phoenix wtf is that?
${client.guilds.cache.size}
@opal plank which?
hey erwin @opal plank

its code mah dude, as long as it works
if it aint working now, fix it
ยฏ_(ใ)_/ยฏ
you asked me for help yesterday, i told you how to do it
i m trying it to do
that was of undefined and all
well @opal plank i want to go easy and simple
without using a data base
as it will be better
i think so
its the same command dude
memes and setInterval, dont needto be big brain to know this is the command you are currently mentioning lol
incorrect, you'll lose states if you disconnect your bot
but
hence why you should put it in a DB

if you dare say 'i can put it in a JSON' ill legit bonk you irl
doesnt matter
thats why i told you to set ONE setInterval() and everytime it runs, it sends messages onto the channels that are subscribed to your memes
//index
let channels = Map():
setInterval(() => {
for(let c of channels) {
client.channels_cache.get(c).send(meme);
}
})
//subscribe.js
channels.add(channel.id);
there, done
purposefully wrong so you have to work on it
but thats the framework
when someone subscribes? add the channel. Unsubscribe? remove it
see but if u set topic it will auto sub
simple as that
then loop over ALL channels and read their topics
for(let channel of client.channels.cache.values()) {
if(channel.type === "text" && channel.topic === "meme") channel.send(meme)
}
can u help me with that? @opal plank
i cant spoonfeed you dude

i can help as best as i can, but i cant spoonfeed
can someone tell me a little bit what sharding is or what itยดs use for ?
@weak rain just make a global setInterval when you bot starts up
sharding is required to log your bot in once it hits 2.5k servers @forest whale
one global setInterval on index, and then loop it as you wish thru the guilds/channels
@forest whale sharding is splitting the discord connection into multiple connections, where each connection handles an X amount of guilds
for example a bot with 3 shards and 3000 guilds will have 1000 guilds per shard/connection
@forest whale sharding is splitting the discord connection into multiple connections, where each connection handles an X amount of guilds
@quartz kindle aha okey nice isยดt hard to implement it in my code ?
depends, there are many different ways to implement sharding
the easiest way is generally known as "internal sharding", which means that all discord connections are managed by a single process
How do you bulk delete something in d.js? I tried message.channel.bulkDelete(amount, true) but i got a error-
in discord.js you can enable internal sharding using shards:"auto" in your client options
what was the error
You may want to log the value of message
its in channel no?
It's saying message.channel is returning undefined.
depends, there are many different ways to implement sharding
@quartz kindle does it make it sense to implement it early ? even if my bot is under 150 Servers ?
o, thanks
@forest whale you can experiment with it in order to future proof your bot, but its only recommended once you hit 1500 guilds, and required once you hit 2500
๐
@weak rain i literally told you what to do lol
both me and tim explained how to do it
I logged message https://hastebin.com/xofajanoro, it looks like a guild value but not
@forest whale you can experiment with it in order to future proof your bot, but its only recommended once you hit 1500 guilds, and required once you hit 2500
@quartz kindle hmm okey Iยดm just not completly shure how i do that on JDA but thank you very much for the Explanation
look into the JDA docs, there is surely something about sharding
where
this bot list
Guys
I made a bot
Uploaded files
And want to host it
So, can someone guide me up?
can
we
try
not
to
Speak
like this?
I am sorry
stop spamming


Guys please help
with?
where are you even hosting it?
Hosting
how do i set it to a global interval?
where are you even hosting it?
@opal plank Dude, I am literally dumb
what hosting
Bot hosting
wtf








