#development
1 messages · Page 1624 of 1
Does “/n” work in a webhook message?
yes
Great
Yeah it's really not meant as an insult, Chadoxi. It's clear that you need to know some programming before making bots, because learning javascript while making a bot is like learning cooking while making beef wellington. It's not entry-level stuff.
hi guys, anyone know how long it takes until my bot is approved?
years at this rate 
1.2 millions bots enque rn
holy molly
guys what is the createEmoji's new command in discord.js?
probably guild.emojis.create ?
ill try
What are good custom variables for guildMemberAdd?
I added {user} and {user_id}, but I thought I would use that for the author instead.
ok but it still says guild.createEmoji
You're missing a whole lot of context for that question to make sense.
what should ı add?
guild.emojis.create
I was basically talking about in general hackers cyber bullies that was the topic of today how you can resolve it beside going to go do all the extra
i linked to the docs which show how to create emojis
So that wasn't a copypasta?
Ok but this is a channel for programming and development, maybe try hitting up a conversation in #general instead?
Or in an infosec related guilds if you think you want to talk about hackers, which... we can't talk about here.
Bbg boos yb
@umbral zealot thanku
It was just a general topic of cyber bullying hacking you can do hacking in a appropriate manner and there's a wrong way of doing it that's what I'm talking about
As well I was making it known that on this platform hackers don't come in very much you know what I mean and so when they're coming in constantly the way they are or they have it's a pattern it's a sign it's a person doing it specifically revealing themselves how to retaliation
guys
who have a profile code for a .json bot?
cuzmy profile code was probot 's profile
Uh okay... the thing is, the conversation wasn't about hacking or anything like that so your message felt random / weird. If you wanna continue talking about hacking please do it in #general
.json bot? Can you elaborate
No thanks
what’s the link to the api website
nope
How would I make it so it gives a user 30-80% of a user's balance
e.g: a user robs me, they get 30-80% of my balance
ik about math.random but how would i make it so it gets 30-80% of the db value
alright
Well you have to choose a random value between 30 and 80 first
Then do the math on the db
money * rngNumber / 100
That's 30-110 right now.
can someone help me make a bot like says please?
*70) + 30
We can help you with certain issues/problems to solve
Try changing 80 to 50
alr
you talking to me?
well, i am trying to make it so that people that everyone get a role taken away (role called Competitor) then then people that have the role Complete get the role added back. This is my code for the role part so far:
const compRole = message.guild.roles.cache.find(r => r.name === "Competitor");
const otherRole = message.guild.roles.cache.find(r => r.name === "OtherRole");
members.forEach(member => {
if (!member.roles.cache.has(compRole)) {
member.roles.remove(otherRole);
}
});```
if i do math.Random it generates a random decimal from 0 - 1
let chance = Math.random
if(chance >= 0.6)
// success
if(chance <= 0.6)
so does if(chance >= 0.6) a 60% chance
i want 60% chance for success 40% for failure
sounds about right
for the 40%
if(chance <=0.6)
would that work
meh i dont think that would
if chance <= 0.4
if (chance >= 0.6) {
// More than 0.6 - Which means 40% chance
} else {
// Less than 0.6 - Which means 60% chance
}
compRole is going to either be a Role or null. has expects a role ID as a string, so you should be doing compRole.id
Just by looking at your code. I'm not sure.
so, when i fetch my db value
it will print as an integer
so if i just did
userbal * random
would that work
no
^
Because it's a percentage
oh
decimal
yeah
userbal * random / 100
const user = message.mentions.users.first() ||```
i want to make it so IDs work
rn its only tags
actually i want my ID and my tag (samm#0021) to work as well
can you use `` on a array?
uhhh what do you mean "on an array"
why ı cant installing quick.db?
What do you mean exactly?
give me a sec
that always gives error
read the quick.db install troubleshooting page
oh k
const person = member.username
const message = [`yooo ${person} welcome!`, ....
like to use it this way
You could have just tried it, y'know. 😛
i did
but it gave me an error so it confused me lol
cannot send an empty message*
thats not from that line
let finalmessage = message[Math.floor(Math.random() * message.length)]
``` ik but also can i do this?
This works a bit, it takes away the role but it still does it even tho i have the role "Complete". Can anyone help?
const compRole = message.guild.roles.cache.find(r => r.name === "Competitor");
const otherRole = message.guild.roles.cache.find(r => r.name === "Complete");
members.cache.forEach(member => {
if (!member.roles.cache.has(otherRole)) {
member.roles.remove(compRole.id);
}
});```
That's because discord.js doesn't cache all members by default
It only caches online members
and only up to 200 afaik
it still didnt work with 2 people with both online
You can enable the fetchAllMembers option in the client settings, but it's not recommended
And it'll be removed
in v13
wasnt it 100? iirc
could be
bcs i know the API will only return the first 100 guilds, i guess there will be a similar limitation for members
let randomchance = Math.floor(Math.random() * 50) + 30; // 30-80
let randomamount = userbal * randomchance / 100```
why does this print a decimal
the user balance is 1321 and it prints 858.27
Round the balance
the balance is a whole number though?
There aren't "whole numbers" in js, all numbers are stored as 32-bit floating points
... just because it's a whole number doesn't mean that dividing it by another number will produce a whole number
Just Math.round the new balance
or floor, or ceil up to you
my userinfo command is selective, If the user doesnt have a custom status/ or playing a game the command fails to work, if the user is in a game/ custom status it works any-clue why its being selective
the line that causes the selective
```.addField("Playing", ${member.user.presence.activities ?
${member.user.presence.activities[0].name} : ":redtick~1: Not playing"},inline, true)
also it throws an error saying that `${member.user.presence.activities[0].name}` is invalid when theres no running game or status
activities can still be defined but empty, so they wouldn't get back the first one
install python?
how can i use .startTyping(); in a guildmemberadd
it's been more than 3 weeks since I added my bot ,, any info on how much more time?
Bot reviews are currently on hold due to the migration issues described in #site-status and #support . Please be patient.
And I'm just answering 
yo, if i have a debian VPS, is there any way to control it other than just the command line - i.e like a normal computer?
install a desktop environment on it
ok
Isn't that a drug lord
mhm
await message.guild.members.cache.some(member => member.user.tag === args[0])```
how do i get the ID from this
its defined as user1
i tried user1.id
it prints undefined
some returns a boolean value
some = only checks if the member is in the collection
find = checks if the member is in the collection and returns the member
well, i tried my own tag it works, but when i try someone else's tag it doesn't work
it says Cannot read property 'id' of undefined
aka prints undefined
The member isn't cached then
so would i be better of fetching them?
yes
good afternoon, sorry for the question, but do you have any average time for the approval of the bot?
The queue is currently on pause because the site is broken
Around 4 times a minute
would 15 seconds be fine
# get data from database
count = 0
times = []
async for x1 in self.client.totalInfections.find({}, {'time'}):
count += 1
x2 = x1['time']
times.append(x2)
# you're gonna need to make a new list for that, where the index is determined by the hour in the date
# you just always add to the last element of your new list unless the previous item in your times list had a different hour in which case append to the new list instead
newNumbers = []
previousX = None
hours = {}
if previousX is None:
previousX = times[0]
for x in times:
try:
if x.hour == previousX.hour:
hours[x.hour].append(x.hour)
else:
previousX = x
except KeyError:
hours[x.hour] = [x.hour]
print(hours)
# make up some data
x = times # time
y = hours # amount to plot
How am i supposed to link it up to the necesary time? Little confused by that. My current code results in:
hours returns a dictionary with a key inside, th ewkey represents the hour where the data should be shown, and the list inside the dictionary is the amount of data which should be logged for that hour
message.guild.members.fetch(member => member.user.tag === args[0])```
y doesnt this work
fetch doesn't accept a function
epic bruh momento
learn to read the docs
There is, kinda
.d
guild.members.fetch();```
yes
so then i can keep cache
It's not recommended though
I'm adding commands to my bot from bot desinger for discord
what's wrong with just fetching the first user with a similar username?
what?
What
hm
what are you saying? my brain is burned.
I wasn't talking to you
ah
message.channel.guild.members.fetch({cache : false}).then(members=>members.find(member=>member.user.tag === args[0]))```
Lol
this would work, right
Okay, sorry, I got it wrong.
fetch*
That's exactly why it exists
tag
if a user responds with a tag (samm#0021), i want that to be transferred to their ID
guild.members.fetch({ query: "samm" })
samm#0021 or just samm
...
tim, you're so shaped, you're burning, how handsome is that?
wat
the fuck
.d
so you're cool.
Troll in #general
lol
did he call you handsome
i guess lmao
guys I need your help. so my bot has already passed the 100 server limit for this but I can't enable those two switches??
We don't have anything to do with verification
I know
So...... More of a question in the discord developers server 

hello i want to add voting obligation to my discord bot how can i do
vote or be executed

does anyone know java and know why is this happening? so I'm using canvas to make a circle, painted it in yellow (0xFFFF00) and it is yellow, but it has green outline, why?
will i do here
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
why this dont work?
if anyone knows answer to this, ping me
if (error) {
message.channel.send(`**ERROR IN CODE ACCURED! \n ERROR: ${error}**`)
}``` with this, I catch an error?
it looks so weird, it shouldn't look like this 100% here is the code
circlePaint2.setColor(Color.YELLOW);
circlePaint2.setStrokeWidth(getDip(getApplicationContext(),2));
circlePaint2.setShadowLayer(
50.0f,
0.0f,
0.0f,
Color.parseColor("#FFFF00")
);
everything is supposed to be yellow, not red nor green
how to get dbl wephook url
perm
that seems like heavy compression to me
i just looked up the docs for setShadowLayer
why are you using that
there's literally a method for drawing a circle??
why aren't you using that??
Does anyone here use Eris
The Eris docs is giving me kind of a headache since everything is so hard to navigate unlike discord.js's
Just trying to search something up with the search function but it doesn't even seem to work 
How do I make my discord bot command voting obligation
Wdym
@vivid fulcrum is therw anything better you'd suggest?
i would highly recommend against that btw @exotic galleon ]
Someone speaks my name
I don't know any other methos to draw shadows using canvas
In call
Sorry
the literal drawCircle method
I did not understand what you said
nono, I have do use it
no english}?
I created a paint
NGL Erwin, may take some inspiration from your top.gg page once the update happens. Kinda dig the transparent anime theme. Could make it Ikaros related.
bad idea
to get a shadow
yes
then include the paint with the drawCircle
tfw JS have a drawing circle method for webGL but GIMP won't let you make it as a basic shape by default

yeah i went for the transparent route instead of solid colors, thats personal taste
I like both. But yours is pretty clean.
dont block people from using commands with votes
Can you help @opal plank
Ty ❤️
I do block people from using only our NSFW commands with voting mainly because we didn't want to make them but people requested 
I need a vote
@vivid fulcrum I managed to do it, it was heavy compression, it pasted the same circle over 15 times, it was my map generators fault
this is going to be super annoying cuz you dont know enligsh
what language you speak?
interesting, i was about to blame canvas for not blurring it correctly
nsfw hindered a lot of growth in my other bots, since then i decided to separate NSFW with SFW, like oil and water
German
Wdym? Like people seen you had em and didn't like it?
oof, i understand german but i dont speak a pint
exactly
@exotic galleon can you use google translate on my messages?
I mean, I'll send a ss what non-nsfw users would see. Sec.
i understand
aight
yes
yes
@vivid fulcrum yeah, sorry for the trouble
can we talk from private messages @opal plank
even this, people just didnt add the bto cuz it HAD it, just for that reason, i had not only nsfw check but whitelisting too, you had to add it
help only here
okey
you have webhook for vote?
no
you code in js?
Interesting. I don't think we'll really change it. We've had it for quite a while and our growth is looking good still.
glitch
what language? python? javascript?
discord.js
after it picks up its fine, but early on its a killer
look this, its very simple https://docs.top.gg/libraries/javascript/
Can we arrange together
ive had MULTIPLE people actually dm me asking if i could remove all nsfw so they could use stuff on their server, and big servers too
you need to code it
even after i explained them its nsfw only and stuff
how
Never had that complaint before. But it's like. They 100% can't use it on their server without a NSFW enabled channel + voting
partnered servers are a big nono for this sort of stuff
So they can just deal with it imo 
click link i sent
okey
it has example
I am waiting
kek, i mean thats fair, it is still a killer for bots to have nsfw from what i saw
?
sorry
no problem
@opal plank
okey
you want that ^^
yes
put that in code, change app.listen(80) to 3005
port 80 bad
then go on top.gg, on your bot, and click settings
you need to put glitch ip there
okey
I will open a new file and put the codes in the picture I throw in my bot project, otherwise I will put it anywhere.
@opal plank
index.js okey
@opal plank
what is the problem
@opal plank what should I do
yes but also no
you need to understand what this is doing
you are creating a http server and adding the /dblwebhook route to it
someone will help you eventually my guy
thnx
https://expressjs.com/ please familiarize yourself with this
I'm listening to you here
👁️👄👁️
this @exotic galleon
express is the code you are using
I dont even know how to code
😦
you should learn how do use it before you use it
from where and how
how are you creating the BufferedImage?
also, how are you converting the image to bytes?
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
why does it not respond?
guildMemberAdd only works if you have "server members" enabled in your discord developer portal
technically if you never restart the bot, isnt it possible to bypass that?
in current session
where can i enable this
still not working
oh
most likely yes
same with sharding
i mean, thats not accounting for when discord bends itself over
once a week, basically
please a lot of help i used this php discord login apit and I want to indicate if my bot is present on the server or not the agents are stored in a bot subserver SQL database
API: https://github.com/MarkisDev/discordoauth
SERVER ID CODE
<?php
for($i = 0; $i < sizeof($_SESSION['guilds']); $i++) {
echo $_SESSION['guilds'][$i]['id'];
}
>
commas, please?
i have gifs in one of my commands and it wont load||nvm got it||
hmmm quite a possibility
Whats presence intent for
status updates
correct
Thanks home dog
I was using canvas to generate map for my game that was made in java, I accidently made it repeat the paint that you added 15 times compressing the colors, but I fixed that already
First of all, don't say canvas
You were using Graphics2D right?
But yeah, repeating gradient paints do cause that when stacked
unless they are actually using javascript
No chance, that code snippet was definitely java's graphics2d
ah
You obviously cannot put "discord" in the bot's name
What's the app's name?
same thing?
Like, iirc there's both an app name and a bot name
Yeah, there's a name for the app and a name specifically for the bot
Does anyone know how to fetch the thumbnail of a SoundCloud song or any npm package that can do that? I know how to do it for YouTube ones for my music bot but I'm not sure about SoundCloud ones
Maybe scrape the html?
scraping i feel is always more work than just using the api.
or just get_tracks if you want to search by name
to query yeah, apparently it accepts id as well
Pretty sure registrations are closed
Why does it do this?
My code is this:
let giveawayE = new MessageEmbed()
.setTitle(`${prize}`)
.addField(`HOST: ${message.author}`)
.setTimestamp(Date.now() + ms(args[0]))
.setColor(`BLUE`);
let m = await channel.send(`:tada: NEW GIVEAWAY! :tada:`, giveawayE);```
You can't put mentions in field names, Discord won't format them
😐
also not filling in a field value makes it undefined
"Something", "something"
winner?
Because winner is not even a thing
winner is not a thing in a message object
Who codes in python?
A lot of people, so if you have a question, it's best to just ask
its defind somewhere on top.
Show me
...you do know how variables work right?
Maby... ?
it would be winner.send not message.winner.send >_>
anyways I have a question myself
Winner is an user as it seems
the message object doesn't have winner though
I deleted the code bc it was broken.
I was making a automod module for bot. When I made anti-swear, I had it loop through a array and check the message for any content (using .toLowerCase() for everything to make it not case sensitive) but if you say like "class" or "glass" or "glasses" it gets deleted bc it found a swear word within the message
He has a variable called winner but tried to access it with message.winner
Swearing filter is one of the hardest things to do
Why? Your name explains it
rip
4ss
How do I create an argument for a role in Python?
Like if someone has the Twitch Subscriber role, they get a certain boost in credits
if statement?
Yeah, but what do I put?
What do you want to check it with? Name or Id?
ID
try it and see
Thank you
@earnest phoenix Can I do multiple IDs with this?
you can use any or all depending on your use case, do you want the user to have at least one of the roles or all of the roles?
How Can I Connect Heroky With VS code
So that i can see logs there
It takes a lot of time and fails in the end
Gonna be giving a perk to people who boost as well. So people who are boosting and are a Twitch subscriber will get both of the perks
role_ids being both ID numbers?
A sequence of the ids yes
Kk
Could I also do an and statement?
Sure, why not
any() returns boolean, you can combine it with another condition
wait, you can't have and in the sequence, should be something like (some_id, some_other_id)
Didn’t know I needed any
that's just basically equivalent to <Member>._roles.has(some_role_id) or <Member>._roles.has(some_other_role_id)
If you use all, it'll be an and instead of or
Reeeeeee, now ya tell me
teach heroku to become sentient and gain psychic powers
if(!message.member._roles.has(ROLE_ID))
return message.channel.send("You didnt have the role")```
Correct?
wha-
That is for a command
To use the command the member need role
huh?
In what lang is this?
js
And why are you returning the message.channel.send ?
Iam actually making a command.For using the command the user need a role.If the user doent have the role then return message.channel.send
Yeah, I got that. But why are you returning the method rather than just calling it?
That code is for a private bot so
The reason he's asking you that quesiton because it's likely wrong js
What difference does that make? 
If you want the bot to send a message, just do message.channel.send. No need to put return before it
If you don't understand why, I'd recommend learning some basic js before delving into bot development
Ok
They're probably returning because they don't want to process the command. But, the thing is, if this was d.js and I wasn't misinterpreting the source code, _roles should be the raw data, which is an array ig, does an array even have has method? Shouldn't it be includes or something? Not really familiar with js nor d.js so I might be wrong.
_roles should be just roles iirc
as stated above, return is not needed in that instance
I mean, isn't it just the matter of style? Because it's either if return or if else
and why do you guys think return is not needed? He wants to stop the further execution of the command, because the user didn't have a role
Perfectly fine
right
The problem is with _roles like norizon said, it's an array of role IDs
im talking about free ones
there's no good free ones
I've heard about Heroku. But like it also says in pins, most free hosting providers won't be any good in the long run. They work fine if you're just looking for a temporary host tho
read pins on why free hosts aren't the best idea
There's a reason almost all hosts are paid
what if I dont have enough money for that and they bill me
They will probably shut your host down
how do you self host
By having your own device, like a computer or a raspberry pi that's on and running the bot 24/7
whats a rasperry pi
A popular single board computer
please show me an image
They're good for stuff like that since they are pretty cheap and consume almost no power
You can just google "Raspberry Pi" and it'll show you
how do I get it to host my bot tho
Just have it run your script
Self hosting is usually harder to set up though, and might not be as high performance as a paid host
whats the average ping for it?
Depends entirely on where you are relative to Discord's servers, as well as the actual hardware of the computer
When i self hosted from Sweden on a Raspberry Pi 3B+ i had like 100ms avg, when I swapped to a VPS in New york it went down to about 30
There are of course advantages to self hosting too, like having full control of everything that's going on. No need to rely on a hosting company
what about polarbearhosting
You can try it if you want to, but again, free hosts always have their drawbacks
It might be okay for a smaller bot, but if it grows you will have some issues
its down right now
Well, it's either going to be free or good. That's the harsh reality
its the 3 horseman
if its good, its paid
if its free, its not good
if its free and good, you're the product
pick your poison
hello i added my bot but it is waiting for a vote.
week or longer
can take longer due to issues with the site
Never really seen a hosting provider that has this though? Unless it's like Google cloud
I understand who's taking care of these
yes
every major product needs to make some profit, unlike websites, the only thing a hosting service can offer isnt ads, but anoynymous data for 3rd party advertisers
Like Hope said, you'll probably need to wait at least a week, likely longer than that
so a lot of times, i feel more comfortable knowing theres a lot of ads
Yeah, that's true. I heard a single e-mail address sells for like $90
@opal plank
how did you do your situation
my what?
status
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
why you think only a few did it?
thanks anyway
your pc is a better bet than anything free
That's only "free" if he's not the one paying the electrical bill tho ^^
hence a rpi
Use a free shitty and limited host - heroku, glitch
Use a free but credit card required - aws, f1 micro
Use a cheap friendly host - RasberryPi
Use your pc as host
Buy a small VPS - DO, galaxy, etc
Kidnap someone's kid and bargain for a VPS lifetime
Ask a friend that already has a VPS themselves and are willing to let you use it
@opal plank what about uptimerobot
on glitch? never do it
against TOS
repl it maybe
most free hosts ban uptimer bots to keep pinging your projects
Im just waiting on my approval on my bot :)
I call it: 6ball bot
took me like i think 1 hour
its just fun commands. not moderation
you made a bot in 1 hour?
i think so
what language did you use?
i loose track of time lol
JavaScript
interesting
you know javascript?
yup
javascript and typescript
im always helping here with both
thought at this point in time i moved away from discord.js, its a shit library
whats typescript
basically javascript, but better
I use discord.js
a LOT better
is it similar?
its the same basically, but with types
check this for a quick intro
Learn the basics if TypeScript in 100 Seconds! If you love TS, upgrade to Fireship PRO for 40% off using code mbus5Kcj at https://fireship.io/pro
TypeScript docs https://www.typescriptlang.org/
#typescript #js #100SecondsOfCode
Install the quiz app 🤓
iOS https://itunes.apple.com/us/app/fireship/id1462592372?mt=8
Android https://play.google.c...
https://www.youtube.com/watch?v=ahCwqrYpIuM and the first minute of this
TypeScript has forever altered the lives of JavaScript developers. Learn why TS is so awesome and the basic concepts required to be successful using it https://angularfirebase.com/typescript-the-basics/
Deep Dive https://github.com/basarat/typescript-book
TypeScript Docs https://www.typescriptlang.org/
ok ok ok. i get it
if it interests you, keep watching
hiring developers are illegal in this channel?
yea not here
not exactly illegal, but if you're searching for bot developers go to fiverr or upwork
@opal plank is it fine to abuse ! if I know that the message is from a guild
Not a fan
if you know theres guild, yes
though keep in mind, thats an easy way to create bugs
it's in a different file
Then it's fine
I see
you should also be able to cast it as GuildMessage
unless d.js is dumb enough not to have the types
detritus has it for sure
wink wink no sponsored but you should try it as a full fledged TS and GOOD library, rather than d.js's mess @pale vessel
https://discord.gg/XUvREc7W if you want to ask any questions about it
Already in it 
personal experience, a LOT better than d.js, by a mile
no you are sponsored
You really can't come in #development without telling someone to switch to a different lib, can you 
nope, i feel like its a sin not talking about such a good lib with peple trying ts
they just arent flourishing as much because nobody speaks about it
in every sense its better than d.js, and i mean it
it feels wrong to use it without giving an honest opinion about it when its this good
The only one that's holding me back is Berry
lol i use discord py?
lol i was mentioning that to flazepe?
i code in assembly like a real man
im trying to add a command that toggles the bot's responses to keywords said by users, if the admins want to disable that from happening. here's my code
if (msg.content.toLowerCase() === ",,togglekeywords") {
switch(serverToggle) {
case `${curServer}_on`:
serverToggle = `${curServer}_off`;
msg.channel.send(`keyword responses are turned off for ${msg.guild.name}`);
break;
case `${curServer}_off`:
serverToggle = `${curServer}_on`;
msg.channel.send(`keyword responses are turned on for ${msg.guild.name}`);
break;
}
}
where const curServer = msg.guild.id; and serverToggle = BT${curServer}_onBT (BT is a backtick)
everytime i use the command it keeps saying "keyword responses are turned off", and wont toggle back to on
the two variables are set right after client.on('message',async msg => {
but i don't know if that changes anything
Hey, I have a problem with my ready.js:
const Discord = require('discord.js');
const client = new Discord.Client();
const logsChannel = client.channels.cache.get('815953311614107709');
module.exports = (client) => {
console.log('Synapse en live !');
client.user.setActivity('s!help', { type: 'WATCHING' });
client.on('guildCreate', (guild) => {
console.log("Joined a new guild: " + guild.name);
const joinEmbed = new Discord.MessageEmbed()
.setTitle(`Omg, je suis arrivé sur un nouveau serveur !`)
.addField(`Serveur`, `${guild.name}`)
.addField(`Fondateur`, `${guild.owner}`)
.addField(`Nombre de membres`, `${guild.memberCount} membres`)
.setFooter(`Je suis actuellement sur ${client.guilds.cache.size} serveurs !`)
.setTimestamp()
.setColor('GREEN')
logsChannel.send(joinEmbed);
})
client.on('guildDelete', (guild) => {
console.log("Left a guild: " + guild.name);
const leaveEmbed = new Discord.MessageEmbed()
.setTitle(`Oh nan, je viens de quitter un serveur :/`)
.addField(`Serveur`, `${guild.name}`)
.addField(`Fondateur`, `${guild.owner}`)
.addField(`Nombre de membres`, `${guild.memberCount} membres`)
.setFooter(`Je suis actuellement sur ${client.guilds.cache.size} serveurs !`)
.setTimestamp()
.setColor('RED')
logsChannel.send(leaveEmbed);
})
};
Error: Cannot read property 'send'
at logsChannel.send(joinEmbed);
and logsChannel.send(leaveEmbed);
You have to wait for your client to enter the ready state before you can get items from the caches
You cannot dynamically set the timer on an interval. You'd have to clear the interval and then re-set it
how?
setinterval(() => { clearinterval();
timer = x + 10 }, timer)```
like this?
i mean yeah ik i have to assign the settimeout to a vari
to clear it
clearInterval(intervalYouAssignedToAVariable);
intervalYouAssignedToAVariable = setInterval(() => doCode(), timer);
at that point, you should be using a Timeout.
No dynamic timers for either without clearing and re-creating them
var timeout = 1000 * 2
const time = setTimeout(async () => {
console.log({ timeout })
timeout = 1000 * 5
}, timeout);
cleartimeout(time)```
function createTimeout(timeout) {
setTimeout(() => {
// Code
createTimeout(timeout + 1000);
}, timeout);
}
for example
ahh
you also want to have a condition which clears the timeout
this makes more sense
so it's not infinite
that was the missing part
clear the timeout in the timeout callback. That code will clear the timeout immediately and never trigger
i mean, i want it to trigger for 2 secs the first time and then 5 secs untill some condition and i clear the interval after that condition is met, but the issue was the timer kept exec at 2sec and never changed to 5
this probably solves that
so I just waiting and he works?
Because I made when the bot is ready I have a message to the log and works
but if I wait 5 minutes, not works 😦
Is there a performance difference between a scheduled trigger inside the mongoDB or executing a function with a timer?
That's because you access the caches before the ready event
and that code never runs again
oh
if (condition) // dont call createtimeout func and call clearTimeout()
MongoDB scheduled triggers are probably faster / use less resources
oke ill give it a try
but the console log works but not the message embed
Yes because you always have access to the console, what does that have to do with sending a message to channel?
yes
oh euhh
when my bot joins a new server
I have informations to the server in a channel
in my server
const userID = '@dusky harness';
if (message.author.id !== userID) { return message.channel.send("Bunu yapamazsın.")
client.on('message', message => {
if (!message.guild) return;
if (message.content.startsWith('!kick')) {
const user = message.mentions.users.first();
if (user) {
const member = message.guild.member(user);
if (member) {
member
.kick('Optional reason that will display in the audit logs')
.then(() => {
message.reply(Üye başarıyla atıldı ${user.tag});
})
.catch(err => {
message.reply('Üyeyi atamadım');
console.error(err);
});
} else {
message.reply("Bu kullanıcı bu sunucuda değil!");
}
} else {
message.reply("Kullanıcı bulunamadı");
}
}
}
});
what's my fault
can you help me
@coral trellis @modern sable @spare goblet
We don't provide development support, please don't ping all of us. Help in this channel is provided voluntarily by members
what are u trying to do?
Describing the error will also be helpful
oh
i find it
if (message.author.id !== userID) { return message.channel.send("Bunu yapamazsın.") //message is not defined
```
so u need to do is:
client.on('message', message => {
const userID = '698183217215176783';
if (message.author.id !== userID) { return message.channel.send("you can to that")
}
//turkish botum kod
write your code under the //
userID, you put what?
It looks like he did the <@!> thing, where it's supposed to be just the id
yes
But like Ash mentioned, the main issue is that message isn't defined in the first if-statement
Whats this in my bot's application Info?
INTERACTIONS ENDPOINT URL
You can optionally configure an interactions endpoint to receive interactions via HTTP POSTs rather than over Gateway with a bot user.
That's for slash commands
tenks
you can receive slash command events via a webhook
Ignore it if your bot doesn't use slash commands or if you listen for slash command event via the gateway
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
Yeah thank u I don't wanna integrate slash commands in my bot anyways.
message.reply(cum)
cum
😳
I have a question about the bot: reaction roles
It ask me for the message id but where can I find that
Enable Discord Dev on Discord
Ok
Do you know what are the background codes on the page of my bot on the top.gg site?
Please see <#support message>
btw.. for different environments, the results vary WILDLY.. but does anyone know which one is REALLY faster?
check it out yourself
(async()=>{
//waiter function for promises
function waiter(r,j){r(1)}
//await speed testing
var d=new Date()
for(let i=0;i<=999999;i++){await new Promise(waiter)}
let awaitSpeed=new Date()-d
console.log(`speed for await is ${awaitSpeed}ms`)
//then speed testing
let d1=new Date(); let i=0
function _then(a){
if(i==999999){
let thenSpeed=new Date()-d1
return console.log(`speed for then is ${thenSpeed}ms`)
}
new Promise(waiter).then(_then); i++
}
new Promise(waiter).then(_then)
})()
uhhh what are you testing exactly? await/async vs .then?
seems so
await seems to be way faster on chrome
also the second block of code might be not accurate in what it does (compared to the first one)
mutating variables out of the context asynchronously could cause race conditions
yeah
the code is wrong
can confirm there's a whole lot of issues here, bad practices, and code problems.
I was gonna say, the i mutation should be within the .then
thank
ikr
but the thing is it seems way slower on my version on node
L M A O
People already pointed out that the test is flawed
uhh thats the reason
why do you even care about the performance of async/await anyway
its just a wrapper over the the promise system
so it's a sin to test?
bruh it is interesting to know tho
and how would I make the then loop to make it fair?
or should I make the await a recursing function?
use the variable in the waiter
litterally why do you care
await is always going to be slower than a raw promise
but by a insignificant amount in the real world
making it a promise in the first place when the job is CPU bound is pointless anyway
so ur saying then is faster?
promised will ALWAYS be faster because async/await in JS is built ontop of them, not that it matters because the whole point of single threaded concurrency is mostly for IO where the time waiting for IO is going to be more than the cost of the promise in the first place
its actually about the same
if your promise is just returning a random thing that cant be done asynchronously e.g. heavy compute tasks then theres no point them being promises
because the overhead is tiny
no, like
using one over the other just for 'performance' is pointless 
well yes
anyone needs help from the best pron't bot programmer?
there is no way that doesn't sound arrogant so no?
what?
what I meant is that for a promise you are passing a reference for the v8 event loop to go to when the promise has completed, meanwhile async just points back to the line of code where the await call is at
oh mb
pretty much. its just a yield point for when the promise resolves
yea so its really about the same
the overhead is litterally about the same as calling an extra function
well if you're worrying about async vs promise performance you might have bigger problems
lemme restate.. im doing this for fun people
if i was asking a question id ask it straight and not beat around the bush
and i did cuz that WAS the question
im gonna try to make the things more fair and try again.. it would be really fun if one was LITERALLY faster than the other
they likely wont, unless you are doing something wrong
Hiw long does it take nowadays for discord to verify a bots intents
Used to take ages
Fr
U kidding
Months

If i were to remove intents from my bot can it be added to more guilds
ye
Might do that... this is stunting my growth aloot
no?

you still cant grown beyond the limit with or without the intents before verification
If you can work around the intents, yeah you should remove them
Most likely there's a permanent workaround too
I hate this bot verification stuff 
should have just made a bunch of bots that could be verified before they introduced it and have a store of em 
I was two weeks late to early bot badge 😦
same lol
😓
shard gives 0 error, it stays like this when 26 shard should be opened.
guilds: 26k - users: 1.5m auto works too, what can i do?
const { ShardingManager } = require('discord.js');
const settings = require('./settings.json');
const manager = new ShardingManager('./bot.js', { token: settings.token });
manager.on('launch', shard => console.log(`Launched shard ${shard.id}`));
manager.spawn();
/*
manager.on("shardDisconnect", async (eventd, id) => {
await manager.respawn(30000, 30000)
})*/``` its my shard.js
um, about the thing I was talking about a bit earlier.. that thing that you said wont happen DID. then seems WAY FASTER than await so I guess this isn't fair either.. any more pointers to a fair comparison between the 2?
(async() => {
//waiter function for promises
function waiter(r, j) {
r(1)
}
//await speed testing
var d = new Date(); let i1 = 0
async function awaiter(n){
if(n){return await new Promise(waiter)}
i1++ //because of how await works, I CANNOT put it as the last thing to do
if(i1 == 999999){
//because of that, I MUST make up for the one await outstanding
await awaiter(1)
let awaitSpeed = new Date() - d
return console.log(`speed for await is ${awaitSpeed}ms`)
}
await new Promise(waiter)
return awaiter()
}
await awaiter()
//then speed testing
let d1 = new Date()
let i = 0
function _then(a) {
if (i == 999999) {
let thenSpeed = new Date() - d1
return console.log(`speed for then is ${thenSpeed}ms`)
}
new Promise(waiter).then(_then)
i++
}
new Promise(waiter).then(_then)
})()
can you help me pls :c
click here
this?
yes
const fetchGuildData = await this.modules.guild.getValues(reaction.message.guild.id, [ "plugins.verification" ])``` how do i make this only return verification?
it says it took too long to be opened well yikes.. I found https://stackoverflow.com/questions/59119721/discord-js-unhandledpromiserejectionwarning-error-shards-client-took-too-lon but it's also inconclusive OOF
const fetchGuildData = await this.modules.guild.getValues(reaction.message.guild.id, [ "plugins.verification" ]).plugins.verification
BRUH
what?
making one edit lol
the way js works, that shouldn't work
ikik i edited it
const fetchGuildData = (await this.modules.guild.getValues(reaction.message.guild.id, [ "plugins.verification" ])).plugins.verification```
btw anyone has a solve for this one.. a quite good problem
i need some developer for an airport in roblox
This isn't the server to search for developers for personal projects
i how to fix
help pls
shard 0 took too long
yes i have this error
use client.on("debug", console.log) to see what is taking so long
thanks love you UwU
increase the spawn timeout to wait longer
i how to fix this problem
.spawn("auto", 5500, 60000)
I also want to ask something, node.js uses a lot of ram and cpu, how can I fix it?
im using discord.js v12
ues discord.js-light and properly configure it to your needs in order to reduce the memory usage
the cpu usage will be higher assuming you do all you can as thats the nature of compression
i like it discord.js-light but i how to change discord.js to discord.js-light
install it and change the base client to discord.js-light
i saw some code giving undefined error
then you havn't properly configured it
e.g: get role
yes maybe :D
cache the roles
client.on("debug", console.log) Would it be a problem if I set this as a webhook?
I want to print to a channel
it wouldn't be an issue but its not really a good idea to spam heartbeat logs to a channel
sensible +1
@crimson vapor @quartz kindle thanks so much for helping guys love you <3
echo is_numeric((bool)true) ? 1 : 0;
Output: 0
PHP - you weird!
what the fuck
I mean true isn't numeric
console.log(`Launched shard ${shard.id}`)```I have one last question, how can I write how many shards to start here?
I don't see anything wrong
generally in most languages true == 1
e.g: Launched shard 1/26
iirc guild has a shard property
idk much about djs sharding
But you're typecasting it as a bool so maybe then it doesn't coerce
oh okay thanks
@toxic jolt you need 26 shards? 😮
22k guilds
yes
oh wait, i found the error, nvm
@toxic jolt i dont know much about discord.js but i know a lot about sharding in general, what was the question again
ah i see
realistically without a guild or anything to identify, there is no way to get shard id iirc
there wont be an array of shards to count, as iirc djs sharding is one shard per process
unless they use internal sharding
shard.spawn(shard.totalShards, 3000)
cant you read shard.totalShards from within a shard, only in shard manager?
if you could, you could do:
console.log(`Launched shard ${shard.id}/${shard.totalShards}`);```
why 5 sec
discord limits you to 1 shard connection every 5 seconds
because thats the rate limit for shard identify
djs should be setting it at default 5000
when i boot all my clusters, each cluster has a 5 sec delay between shards, and each cluster has a 60 sec delay to the next cluster... i really dont want to get rate limited
so what is optimal sec
5000ms
so much 5
any less, youll get into issues, perhaps a token reset

