#development
1 messages ยท Page 1037 of 1
You should know the basics of JS before starting out with a library as complex as discord.js
I get it
Inside the guildMemberAdd..
You should know the basics of JS before starting out with a library as complex as discord.js
@steep cedar
const PREFIX = "!";```
or whatever the event's name is
Prefixes can be your cache, you can make it anyway you want.
For example
.get can get what you want, if it doesn't exist returns the default.
.set can set your cache and update it in the db.
Or it can be your db directly and you can cache another way.
@steep cedar
const PREFIX = "!";```
@autumn aspen Write variables either in camelCase or snake_case. That is just ugly. And yes, I know that. I want to allow every server to store their own prefix in a database so one server can have prefix "!" while another uses the prefix "?"
The structure can be what you want
so will bot.user.setPresence({activity:{name:"yeet"},status:"dnd"}) work?
Prefixes can be your cache, you can make it anyway you want.
For example
.get can get what you want, if it doesn't exist returns the default..set can set your cache and update it in the db.
Or it can be your db directly and you can cache another way.
@solemn latch What kind of DB is that for?
yes
I get it
Yet you still ignore any advices to learn JS itself
Yet you still ignore any advices to learn JS itself
@slender thistle That's what I'm talking about.
@solemn latch What kind of DB is that for?
@steep cedar quick.db
that's what i use
for my bot's terrible economy system
I've been reading this channel for the past few days and I'm not taking that opinion out of the blue
Take a look at the docs and understand basic JS syntax and how stuff works. Then you can go on. https://developer.mozilla.org/en-US/docs/Web/JavaScript MDN is a reliable source for all things JS.
that's what i use
@earnest phoenix Okay thank you.
You could store prefixes in a collection or map
client.prefixes = new Collection
client.on('message' () => {
const prefix = client.prefixes.get(message.guild.id);
// rest of logic here
});
small
You could store prefixes in a collection or map
client.prefixes = new Collection client.on('message' () => { const prefix = client.prefixes.get(message.guild.id); // rest of logic here });
@strange trout That I then need to store and fetch once the bot restarts
I've never used quick.db
I use mysql and a few tsdb's
When a guild changes the prefix simply update it in the collection as well
Yes, I can do that with Maps thats no problem. I just need it to stay available after restarting the bot.
i use uncomplicatedenoughtobeunderstandablebya1yearold solutions
That's is possible but maybe not the best way to approach a scenario.
The cache resetting after a restart shouldn't be a problem
That's the point of a cache
imma go run EVERYSINGLECOMMAND my bot has in order to check if i broke smth
To store things in memory so you get them faster
why do all tutorials on yt show discord.js v11
Welp why error?
In my case, get gets from the cache, if its not in the cache check the db.
If the db doesn't have that row, get the default one and add the default to the cache for that guild
KOMMUNIST
Welp why error?
@autumn aspen it is literally defined as an event
do you want that or smth else
and you sure the role works?
1) Fetch Collection from DB server
2) Check if message from specific guild starts with set prefix in Collection
3) If, run command
4) After somebody changes command, change the Collection and update the db with the updated Collection
Correct?
bot.on is a callback function
and can you show your errors
imma go run EVERYSINGLECOMMAND my bot has in order to check if i broke smth
@earnest phoenix If you knew what exactly you were doing there wouldn't be a need for that.
Learn JavaScript like you've been told. You don't have any idea what you're doing even after getting help from multiple people@autumn aspen
I think it would be faster to cache prefixes as they come and not cache all of them at the start
^
i use v11 for months and i updated 5 minutes ago @steep cedar
Welp why error?
@autumn aspen what the fuck is this
i use v11 for months and i updated 5 minutes ago @steep cedar
@earnest phoenix Oh okay, sorry then
That's actually valid syntax, but the usage is not correct lol
???
@autumn aspen what the fuck is this
@steep cedar LMAFO
what are you trying to say lmao
I should cache my prefix
@autumn aspen client.on() is a method only used for events. What you set as an event above is a statement, so something that is "executable".
holddizzt, you've literally been here for days after like 5 different people have told u to learn js 
That doesn't belong there where you put it.
Yikes hes having that issue again?
It took 5 of us to get him to put an if statement in an event
We need an army
Look, it is a lot more fun to write proper JS and know why stuff works. Read normal JS docs, then you will have way way less problems with discordjs but 99% of problems you have here are because of incorrect use of JavaScript, not the library discordjs.org
how to create channels with specific perms for @.everyone and save the ID?
(no begging for spoonfeed but please don't take me to the docs i don't get anything)
I'm joining the army
@pure lion Your username is epic and I feel it
lol
@earnest phoenix check out the docs
join da army
I don't like the docs either i must admit
@autumn aspen
client.on()is a method only used for events. What you set as an event above is a statement, so something that is "executable".
@steep cedar w8 pls
some people should have a "no development" role so they can't talk here
- this is what i was trying to do *
some people should have a "no development" role
@digital ibex or a goldfish brain role for peeeps like meeeeeeeeee
meee6 suxxxx
@steep cedar need help I dont know about this command, all I know is I need to have this bc I ned my bot to give a role when someone join.
someone help me
We can't help you because you are refusing to listen
IT LITERALLY GIVES A ROLE WHEN SOMEONE GIVES A ROLE ๐คฃ
idk anymore
LOl
not when someone joins
I'm wondering how much ram a bot will use when it has like 1000 guilds
depends
Mine is in 130 and it already used 77 MB on avarage
my bot will use zero ram it's supposed to be my brain
It depends on what the bot does, which library it uses, what gets cached and what not
@earnest phoenix https://discord.js.org/#/docs/main/stable/class/GuildChannelManager?scrollTo=create
It returns a promise so you can await it then save the ID
And the one I'm working on rn is only in 4 and it used 64 MB average
@earnest phoenix https://discord.js.org/#/docs/main/stable/class/GuildChannelManager?scrollTo=create
It returns a promise so you can await it then save the ID
@strange trout ??? what's await
Bruh lemme see the docs but witch category should I be on if I wanna perms and give a role when someone joins?
64mb??
witch
what are you doing with it?
wdym witch
Alot of calculations
wich
u shouldn't be dong that with nodejs then
Hold up your bot has 64MB?!
(i use glitch for mining bitcoin HEHHE but my projects got deleted ๐ญ)
Or what has 64MB
Hold up your bot has 64MB?!
@steep cedar Kill me
his bot uses on average
My bot uses 64MB ram
(i use glitch for mining bitcoin HEHHE but my projects got deleted ๐ญ)
@earnest phoenix Its probably against Tos
64mg is fine
When its being used
mb
On idle it's like 20 MB
Sound okay
for 4 servers tho?
should i put the code of a random game here?
react with ๐ atleast 5 reacts
Didn't look on mine though
no
im pretty sure thats kinda a bit more than it should be
I hope you do realize that this is a development channel and there's a fuckton of selfbots for 100k members
yes
sooo
Sorry I missed anything, but what are selfbots?
bruh
userbots, actually
user account bots
Automated user accounts
Oh okay, then I thought correctly.
in this case they claim gifts instantly
wait what people don't want me to put the code of a game here
Yeah
bruh
@autumn aspen You my buddy cant say bruh in this channel
Yes because it'll be gone anyway
by code i mean gift code
@earnest phoenix Steam or what?
Also, keep this channel on topic
@autumn aspen You my buddy cant say bruh in this channel
@steep cedar yup
Completely ignored my words
YEAH!!!
also
Also, keep this channel on topic
Bots use it
rip this channel
wait what its claimed
OK
thank you
welcome
Wait what gift was it?
what does bot.on("guildCreate") do
WHat gift was it?
When the bot joins a guild that gets fired
Exactly
WHat gift was it?
@autumn aspen did you not read my messages
shivaco warn him
Oh yeah
Should be called guildOnJoin much rather, create is a bit misleading
(why telling a mod to do stuff)
CHill I just wondered
If i wanna host my JDA music bot on heroku, what should be the content of the Procfile
Well no a new guild object is created
The event guildCreate is fired whenever your bot joins a guild or a guild becomes available
Well no a new guild object is created
@tulip ledge oh yeah
So it's not middleading
Should be called guildOnJoin much rather, create is a bit misleading
@steep cedar by should you mean it is an alternative?
@slender thistle why can I ping all moderators and admins?
So it's not middleading
@tulip ledge ur right
Will you please
does it give you the new guild as argument?
keep this channel on topic
???
Ok
Wut
not you
oh ok
- I just said guilds are objects
- It returns the object when called
Arguments are things you pass
So code can never give you arguments
guilds are objects where we peeps try to fit inside
upto 200k in a normal server and 450k for verified servers
the name of the variable depends on you
the object is saved in a variable
@slender thistle That's what I mean
can someone link me the text channel create discordjs link again?
So could the guildCreate event be used to send a message when the bot joins a server?
Yes
Ok nice
So could the guildCreate event be used to send a message when the bot joins a server?
@earnest phoenix Yes but you would have to guess where to send the message
client.on('guildCreate', createdGuild => {...})
What is createdGuild called here? I'm mixing up syntax right now. I thought it would be an argument. Or is that a property?
Confused
createdGuild is an argument passed to the "arrow function"
When it fires you can loop through the channels and check if you have perms to send messages then send a message in there
imagine it like this
Can someone send me the docs of where u do so ur bot gives a role when someone joins?
Can someone send me the docs of where u do so ur bot gives a role when someone joins?
@autumn aspen
goto discordjs.org and search and STAHP BEGGING HERE
Can someone send me the docs of where u do so ur bot gives a role when someone joins?
@autumn aspen You need a event that fires when somebody joins and then use the argument this event will most probably give you and add a role. That's two different actions.
please learn proper js first
code chill dude
and why is @pliant gorge in 100+ servers and isn't verified but still works fine
?
i have certificates on there
@earnest phoenix You get certs? Epic
Since it only applies after the 7th of october
yeah
and why is @pliant gorge in 100+ servers and isn't verified but still works fine
@earnest phoenix You tagging a bot and talking about the server.
@slender thistle i still cant get it working :/
and why is @pliant gorge in 100+ servers and isn't verified but still works fine
@earnest phoenix Because restrictions don't take place just yet
@distant jewel Code in DMs please
What are u talking about @steep cedar
alright
bot.on("someEvent", eventName => {});
//is this the correct syntax for events?
Should be
well not really
w8 what
as a template for events it's fine
???
bot.on("someEvent", eventName => {});
//is this the correct syntax for events?
@earnest phoenix Not quite
It's correct, but also, you could have multiple parameters passed by the event
.then(console.log)
.catch(console.error);```
Guys is this the command u type when someones join?
eventName should rather be the object you are passed with the event. That is different from event to event.
bot.on("someEvent", (eventName, otherParameter) => {});
what is the best way to have your bot DM you, when you dont specifically summon it, IE on it joining a server or something
.then(console.log) .catch(console.error);``` Guys is this the command u type when someones join?
@autumn aspen No, thats how you set a role to a guildMember object. READ
bot.on("someEvent", (eventName, otherParameter) => {});
@tulip ledge You don't get the eventName as parameter
oh ok
@steep cedar what are utalking about?
bot.on("someEvent", (eventName, otherParameter) => {});
@tulip ledge so stuff like message and guildCreate work normally without the extra params?
Yes
But I cant find where i setup command so when someones joins it gives a role
eventName should rather be the object you are passed with the event. That is different from event to event.
@steep cedar The name can be flexible like in functions they don't have to be a specific name
ChickenDev i love chickens expecially those who can use computers
@tulip ledge so stuff like message and guildCreate work normally without the extra params?
@earnest phoenix Depends what you want to do. WHen you want to use the content from a message for example you use the first argument.
client.on('message', message => {
client.log(message);
}
This will give you all information that you have about the message that triggered the function
number of passed arguments depends on the event itself but how to name them is up to you entirely
console.log you mean, not client.log
ok so off to docs
client.log
@steep cedar The name can be flexible like in functions they don't have to be a specific name
@tulip ledge I know, but calling it "eventName" isn't semantic at all
Yeah you can call it whatever you want sure
I know that
But in this case I thought it was a bit misleading
client.log
@tulip ledge ?
so does guildCreate work without extra stuff?
And you saying it's not a parameter. If you look in the source of discordjs the eventNames are used as parameters and then returned therefor they are parameters
Yes
Depends on what you want to do
Everything works without extra stuff
It depends what your google is. If you want to work with the object that fired the function, youll need an argument. For example, when you want to greet the owner of the server that fired guildCreate you will need the first argument (what is the server that fired the event, justa reminder) to find out more about who has the highest perms or has the owner property, for example.
THis is a bit complicated for the beginning but once you get it it makes sense
Just experiment
why ping me and run away. Yes I have 41 screenshots all dumped on my desktop
What is that dude
MEESUCKS is a great name btw
but please move the discussion to #general
If you want to work with the object that fired the function, youll need an argument. For example, when you want to greet the owner of the server that fired guildCreate you will need the first argument (what is the server that fired the event, justa reminder) to find out more about who has the highest perms or has the owner property, for example.
You're just talking nonsense at this point literally 80% of what you said here is wrong
The second argument of the on function is a function, and functions can have an unlimited amount of parameters, you can do:
SomeEventEmitter.on("someEvent", (a, b, c, d, e, f, g) => {
console.log(a, b, c, d, e, f, g);
});
And only the ones provided by the thing that emits the event matter:
SomeEventEmitter.emit("someEvent", 1, 2, 3, 4);
The event gets called, and 1, 2, 3, 4, undefined, undefined, undefined gets console logged.
First of all objects don't fire functions
events !== functions
arguments aren't given by the event as arguments are things you pass to a function
to find the owner you don't have to look at the highest perm
does this work:
bot.on("guildCreate", guild => {
guild.channels.create(/*/somestuff/*/);
});
Events are exactly that, functions, which get executed at a given point in time.
slpit
Let doesnt work
-> split
lowercase l
It's case sensitive
Can someone help me on smth?
Won't send the eembed or the xembed to the message.author when they dm the bot https://sourceb.in/c72fe99047
the man is back again
lmao
const main = guild.channels.cache.find((x) => x.name === message.author.id)
this looks like a problem
Growing tired of this shit already
@slender thistle where can split?
const main = guild.channels.cache.find((x) => x.name === message.author.id)
You're finding a channel not a user
You typed slpit instead of split
slpit
You typed Let instead of let
oh
As a DM channel doesn't have a guild object
Won't send the eembed or the xembed to the message.author when they dm the bot
That's because yourifcondition covers the entire code you do (if(message.guild){).
@compact echo
oh
honestly don't add up to it please
That's because your first
ifcondition covers the entire code you do.
@sudden geyser wdym? Just a noob at coding discord.js sry
It's not Discord.js; it's just condition checking. You expect the bot to respond to the user in DMs if they sent the bot a DM in the first place, correct?
Yes
honestly don't add up to it please
@slender thistle Thx it works
Alright, and in your source code, you do your condition check of if (message.guild) {...}
Yes
However, that check has the rest of your source code in it. So, if the author sent something, that code inside that if statement would not run, and there's nothing below it.
To put it in an image
did you forgot to check if the message starated with the prefix
are you actually doing anything when you use a command kick
the prefix is !
lmao
@compact echo bruh stop
@autumn aspen
did you forgot to check if the message starated with the prefix
@sudden geyser wdym?
come up with your own conclusion
thx!
huh?
@autumn aspen you need to check that the command starts with the prefix you put
oki
ย ย ย ย if (!message.content.startsWith(prefix) || message.author.bot) return;```
Like this
No spoonfeed ๐ญ
that still won't fix his error
really the issue is the splitting and not debugging the code
yea
The second element of args is the command name, not the first
jeez
the first is an empty string
No, it should be the command name
They removed the prefix from the start with substring
What's PREFIX tho, maybe it's not "!"?
Well they say it is, but it doesn't hurt to ask.
How did you set up the prefix @autumn aspen
Ok
Im confused so I did like this, @earnest phoenix
Nope
oh my god
Bro I little hand could be useful
bruh
Hold do you have a good understanding of JavaScript
To set a prefix you need to do const prefix = 'insert here'
switch
@autumn aspen
Thats how
js
switch as command handler = ultra massive stonks
@earnest phoenix
.split(" ") should do the job, but now you are making it so the only command that can be used is !kick
Bro no break
use
Don't do ;
ok
the semicolon is fine
lowercase letters would be best as well
I'm used to not adding a break their so idk if it will work the same
Adding ; is a good practice
Ok
especially for inline codes
if (err) throw err;
^Error: Cannot enqueue Handshake after already enqueuing a Handshake.
anyone know why this error exists
You only have 2 hands
Lol
Im 100x confused
you already have thrown an error
@autumn aspen =
@autumn aspen don't use a switch
@autumn aspen do ' for prefix
one at a time please
this is such a shitshow
@autumn aspen search "js tutorial"
5 pings
Lmao
Chill out lmao
With multiple people "trying to" help, this shit will go on forever
Quoted from the discord.js server
I got 5 coins
ย ย ย ย if (!message.content.startsWith(prefix) || message.author.bot) return;```
[Javascript] If I use Sets to save data momentarily, the data will follow this format { id: message.author.id, date: message.createdAt }. If I want to use the .has method of sets, how do I check if that set contains data that has the message.author.id as id?
Please learn Javascript
Do that dude
^
Please learn how to use javascript and discord.js before asking ANY question here
Are you using Eris or djs or djs light
node.js is runtime environment
discord.js is a library
(if youre using js ofc)
y'all need to give up telling them to learn JS
To do what I'm asking not server know the library that is discord.js, but the language
djs
why star
if (err) throw err;
^Error: Cannot enqueue Handshake after already enqueuing a Handshake.
anyone know why this error exists
Simo a set is like an array but with no duplicates and different methods. If you wanted to work like that, you'd need to check the object (which are all unique so you'd need to get the reference to it)
tbh, there should be a role which doesn't allow people accessing this channel if they're just being retarded and stubborn to learn
good idea
Aka mute
yea just moot dumb ppl
Do that dude
@earnest phoenix can I change here: *
client.on('message', message => {
if (!message.content.startsWith(prefix) || message.author.bot) return;
^^^^
Honestly. Your not helping the guy giving so much help.
He will come to expect people to help if this keeps up.
@autumn aspen you've been here for hours, take a break
@autumn aspen that should work i do believe
Bro I guess then Im gonna take a break ๐
If not you should take a break and learn some js
@sudden geyser Ok thanks, the only thing is that when I go to use the set.has method I don't know the value of dates, just the id, so I don't know how to do it. Any ideas?
This channel is for bot chat, we make this stackoverflow
yall should put a system that only allows people who already know JS (or the language they made their bot in) to talk here
i just was on stackoverflow @earnest phoenix lmfao
If not you should take a break and learn some js
@earnest phoenix Can we just restart look wait
Take a break
yall should put a system that only allows people who already know JS (or the language they made their bot in) to talk here
@tight plinth agreed
why star
bruh
Idk they put it
@balmy knoll you'd need to iterate over it to find it.
Oooh ooh star this too :D
And with the way sets work, it may be easier to use an array or key/value object
erm

lol
Oooh ooh star this too :D
@pure lion as you may know this type of message is not allowed in starboard
and dont try to self star
hmmm
hahahha

real star is here
@pure lion please don't ask people to star your messages
@sudden geyser I tried with a forEach, but I had to remove it, since when I find the author's id inside the set, I have to use a return, a forEach ignores returns and breaks.
Sorry
OH
good job
Well shit
You could use .values() and use the spread operator to create an array then find it, or you could take the shorter approach and use a for (const x of y) {...} instead (I think).
star this tkk
tf is that url
it isn't wrong
@digital ibex a good url
says who 
Says me
how to use emojis in messages. It shows up as plain text for every emoji not just custom emojis
for animated custom emojis that you can't \
i think you need to be a mod for sending someone on the starboard
Is there a way to put the thumbnail of an embed above the fields?
no
Rip
It think it always goes to the side
the thumbnail?
The top right corner
No
yes, you just define the thumbnail
setImage I mean
Oh
Sad
Lmao guys quick question, can u do a command so ur bot reacts and responds when a person server boosts?
@autumn aspen yes
hi chicken
Hi
You are asking to be spoonfed which we don't allow
rule kek
You are asking to be spoonfed which we don't allow
@slender thistle It was a joke
epic

Very funny
@autumn aspen Listen to the guildMemberUpdate event
Jokes -> #memes-and-media
hmmm
ok srry
oh ofc
u can get that premiumSince thing
I still dont get what the point of boosting is
i mean use
cool stuff
oop one sec
the owners of the discord dont get anything
ok
this is the amount of sent bytes per second my bot has. for some reason, it randomly spikes by like 10x and then my bot gets rate limited and temp banned for an hour. does anyone know why this happens?
Are you able to trace what's happening in order for the spike to occur (aka what code is running)
bad code
an example would be an infinite loop
i dont think there are any
ive tested my bot extensively and its been running for like 7+ months now
its possible that you access an API?
(outside of the Discord API)
i had the issue that i dont filter out some stuff from the API request. this resulted that the API returned pretty large datapacks (about 2 million entries) this got pm2 to panic and lagged the entire server
or did you have a disconnect reovery? if yes limit in pm2 how often the bot gets restarted after a crash
my shards dont crash so i dont have to deal with restarts
also i dont use any apis except discords
i used to, but i got rid of them
well besides top.gg
whamed = message.guild.members.find(m => (message.content.includes(m.nickname) || message.content.includes(m.user.username)));
whamed.addRole("bunch of numbers");
any reason why this might not be adding the role to the whamed GuildMember?
the idea is to find the member that was included in the message, and add the role to them
i know the ID isn't the issue, I think whamed might be the wrong type but I don't know why that's happening
@near ether maybe a loop that has no defined end?
maybe a timer?
Guuuuys how do I make an xp bar in canvas
I know there's something to do with % fills but uh
No idea how to translate the xp value to a percentage
Oh-
Sicccc
Can someone link a thing
The thing has to be how to add levels to my xp system
{ name: 'Servers', value: `client.server.cache.size` },```
Why output is not good
ยฏ_(ใ)_/ยฏ
because you set that as the string
you didn't use ${} or just not use the backticks.
ok
lol
.
Help? Won't send them the dm and won't create the channel https://srcb.in/ba1616e854
Ping me if you have an answer
dot copy paste code โข๏ธ
don't worry about it he was confused
@pure lion you love changing ur name dont u?
does anyone know if there is any way to have an event listen to boosts in djs v12
or, does it fire a role event when they earn the role from boosting
Well you could listen for new messages then check message.type
Which would need to equal USER_PREMIUM_GUILD_SUBSCRIPTION to my knowledge.
maybe guildMemberUpdate
@spare goblet
@spare mirage .-.
*hits roof of car* this xp system is so shit please help me
function xpRand(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min)) + min;
}
var guildXPmax;
var guildXPmin;
if (guildXPmin == null) {
experience.set(`xpVal.${msg.guild.id}.min`, 50)
guildXPmin = experience.get(`xpVal.${msg.guild.id}.min`)
} else {
guildXPmin = experience.get(`xpVal.${msg.guild.id}.min`)
}
if (guildXPmax == null) {
experience.set(`xpVal.${msg.guild.id}.max`, 150)
guildXPmax = experience.get(`xpVal.${msg.guild.id}.max`)
} else {
guildXPmax = experience.get(`xpVal.${msg.guild.id}.max`)
}
const xpShit = await experience.get(`xp.${msg.author.id}.${msg.guild.id}`)
if (xpShit == null) {
experience.set(`xp.${msg.author.id}.${msg.guild.id}`, {
xp: 0,
rank: msg.guild.memberCount,
level: 1
})
} else {
experience.add(`xp.${msg.author.id}.${msg.guild.id}.xp`, xpRand(guildXPmin, guildXPmax))
}
if (xpShit.xp > xpShit.level * 500) {
++xpShit.level
}
WOA
(node:16628) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'xp' of undefined
at Client.<anonymous> (C:\Users\james\Desktop\qBot\index.js:274:14)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:16628) 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: 2)
if (xpShit.xp > xpShit.level * 500) {
the offending line
@tight plinth time to delete computer and start over?
yes ofc
what's up
this totally took me more than five minutes
it cant read the property xp of xpShit even though it can read it at my xp command
@pure lion where did u define xp?
its a property
if (xpShit == null) {
experience.set(xp.${msg.author.id}.${msg.guild.id}, {
xp: 0,
rank: msg.guild.memberCount,
level: 1
})
i wanna make level up but it no work
and it doesnt even add to the xp count lOl
what database did you use?
quickdb
idk then
i never used quickdb so i dont have a idea about the syntax
but i look into the code maybe i see something
dankyou
im not sure but its possible that you need to run the Database querys Asnyc
with Mysql and mongodb you need to do it
any time anyone has an issue, its quickdb
can i use enmap for xp?
can i store the guild id, the author id, the level, the xp amount, the ceiling and floor andom values and other shit?
await songEmbed.react('1๏ธโฃ').catch(err => { if (songEmbed) songEmbed.delete(); return message.react(stop) })
await songEmbed.react('2๏ธโฃ').catch(err => { if (songEmbed) songEmbed.delete(); return message.react(stop) })
await songEmbed.react('3๏ธโฃ').catch(err => { if (songEmbed) songEmbed.delete(); return message.react(stop) })
await songEmbed.react('4๏ธโฃ').catch(err => { if (songEmbed) songEmbed.delete(); return message.react(stop) })
await songEmbed.react('5๏ธโฃ').catch(err => { if (songEmbed) songEmbed.delete(); return message.react(stop) })
await songEmbed.react('๐').catch(err => { if (songEmbed) songEmbed.delete(); return message.react(stop) })
[discord.js] I use this method to react in a specific order to the same message. I only have one problem, the reaction time between them is very long. I've seen bots that do it much faster, you know how I can solve it?
he got a decent documentation and some good explanations
@balmy knoll make the first reaction then chain .then()
also you cant get it faster, the API limits how fast you can react
the same thing we had a few days ago and its API limited
*cryig*
enmap is pretty easy to use @pure lion
but needs a lot of ram if you store much data
The speed that there are between the reactions of my bot and those of other bots that I personally use are really very different
yk what fuck it im moving to sql
its possible that other languages dont have the limit from D.js
im assuming its persistent?
I've seen people show very slow reaction times(much slower than the 1/s of djs).
I've never seen anyone figure out why
yes its sqlite
no, big boy sql
yes its persistent
you will cry
so nothing changes, great
I love raw sql tbh
:D
Not for everything
if you get the hang of it its easy but getting into it can be annoying
what do i need to install and shit
i used the npm mysql lib
Guys lmao u can use js of single commands why u dont told me it'
bruuuuuuuuuuuuuuuuuuuuh
?

i think we told you about command handler
okay because i am a lazy i will use quick.db for my previous shit but also use sql because fuck
hhhhhhhhhhh
not for me
pogey
time to make a new bot
time to make a new bot
@pure lion Lmafo
thats normal
i recoded my bot like 7 times until he got verified
eyyy
but this is how you learn stuff
you try stuff until it gets buggy AF, then start new and avoid the mistakes you made last time
this is how i learned stuff too, tryed stuff and then wanted to optimize it
wrong chat
like i had a command that retrived 25 Items from a API. i made 25 Embed Fields for it, later i made a command that retrived a undefined amount of data from a API so i learned how to Chunk it and made the Embed dynamic. With this knowledge i rewrote the command with the 25 Embed fields, was a good thing
wait how can you make dynamic embeds?
paginated?
is there a way to forEach addfields?
i use a for loop for the addField stuff
Just push the items to fields array
i have a array that contains the data i want to display in the embed. with array.length i can define where the loop ends
Just do it with a foreach
oki doki
I just chuck it and then generate the page based off the chuck for said page
chunk(array, size) {
return Array.from({ length: Math.ceil(array.length / size) }, (_, i) => array.slice(i * size, i * size + size));
}
for (var i=0; i<chunked[n].length; i++) {
embed.addField(chunked[n][i].item, `Place: ${chunked[n][i].place}\n Rarity: ${chunked[n][i].rarity}\n Dropchance: ${chunked[n][i].chance}%`);
}
``` i have a part of the above this that chunks down a array with a undefined amount of keys (easy 2k keys) down to 10 keys per sub array
async function chunk(arr, len) {
let chunks = [],
i = 0,
x = arr.length;
while (i < x) {
chunks.push(arr.slice(i, i += len));
}
return chunks;
}
```this is how i chunk it down
How do you get Bot developer role?
i feel like a proper developer, just for starting over uhmmmmmmmmm
Oh
automatically
I've been Waiting like a day now I think
the wait is kllike 2-3 weeks
i think its already at 4 weeks
a day funny
But for leaderboard command I just use:
await Members.findAll({
where: {
guild: this.guild.id,
level: {
[Op.gte]: 0,
},
xp: {
[Op.gt]: 0,
},
},
attributes: ['member', 'xp', 'level'],
order: [['xp', 'DESC']],
...Util.paginate({ page, pageSize }),
});
static paginate({ page, pageSize }) {
const offset = page * pageSize;
const limit = pageSize;
return {
offset,
limit,
};
}
it has been done @lusty quest
?
How come?
rip
Nice
i would have made a backup of it
Oh okay
Do you not version control?
now i just gotta think of a name
Maybe SyntaxError? xD just kidding
ive made a auction bot and named him Stonks
corona!help
thats perfect
why my bot got deleted?
idk
he is probably muted here
no
what did you want to do with your bot?
WELL THATS COMPLICATED
if you have a Idea you can make a name out of it
My bots name is Rice Ball
my bot that got me Verified got a name themed after the game i designed it for
Has nothing to do with rice balls lol
hey, i've made an interface where you can login and see the servers you can manage online, to after make a web dashboard for my bot, but when i try to display only the servers that the user can manage it returns me this error (in ejs) :
2| <h1 class="display-3">Dashboard</h1>
3| <ul class="list-unstyled">
>> 4| <% user.guilds.forEach(guild => {
5| var usr = guild.member(user)
6|
7| if(!usr.hasPermission("MANAGE_GUILD")) return;
guild.member is not a function```
would anyone know how i can fix it ?
Have you looked at the docs
yes i do
exactly what i've done
but it's not js
so idk
and it's not a guild of a bot
it's a guild of a user
so it might be different
but idk
that's why i'm asking
๐
Guys why does it dont work no errors?
is user UserResolvable
?
@solemn latch well i guess, bcs it's the guild of the user :/
limit for deleting messages is 100
Yes and I did 99?
Why don't you do that when you handle the route
@solemn latch why is it wrong?
which suggests this is custom built
does it say you dont have permissions @autumn aspen
but it displays all the guilds
express server
@autumn aspen why MessageFlags?
the users logs in with passport
is it possible to see the create date of a bot you dont own?
https://discord.js.org/#/docs/main/stable/class/ClientApplication?scrollTo=createdTimestamp
so you cant do user.guild(user)
because (user) needs to be UserResolvable
this is wrong use message.channel
router.get('/servers', require('path to your middle ware'), (req, res) => {
// Sort out that logic here
const guilds = req.user.guilds;
res.render('thing', {
user,
guilds,
});
});
You should do it there
is it possible to see the create date of a bot you dont own?
https://discord.js.org/#/docs/main/stable/class/ClientApplication?scrollTo=createdTimestamp
@proven lantern yes, createdAt is a property of user
And then just pass the filtered guilds
Then you can iterate over them and make it pretty on the front end
@hasty lotus thanks, i'll try that out
so i filter the guilds before sending the page ?
Is it supposed to be a MessageFlag above all???
@autumn aspen replace MessageFlag with channel
@autumn aspen you dont need return on every statement btw
if you don't want to use if else then you do
Make one
bruh
we don't spoonfeed.
yesterday i sent you 4 links
do you know how to use the fs module
but
i don't understand
in the app.get("/dashboard')
i've got this :
const baseData = {
bot: client,
path: req.path,
user: req.session.user
};
res.render(path.resolve(`${templateDir}${path.sep}dashboard.ejs`), Object.assign(baseData));```
what do i need to add ?
yeah sry
first fetch the user guilds because discord oath doesn't give you the entire guild object. Then just filter out the guilds that the bot isn't in and finally filter the guilds that the user doesn't have perms for
its usually better if you are checking permissions to use final
not guild permissions
because channel overwrites
Well you could listen for new messages then check
message.type
@sudden geyser you mean that system message thing? soz for ping
o yeah it seems to be system message type
ah okei thanks for your help 
So i got a play command here i made, the message collector in the middle of the code works fine if you try to queue a song but don't answer in 15 seconds, it will stop the collector and emit the end event, causing it to check if the collected message size is 0 then say you didn't respond in 15 seconds, but... If you queue a song and after this song try to queue a song and not respond, it won't check if it responded or not in 15 seconds, it just continues the session and causes an error ofc
https://pastebin.com/k3UQ82zV
I'd do guild perms
Wouldn't want a member who has perms over one channel to be able to login into dashboard and change settings that affect the entire server
Depends though
There is a lot of JS here. What about some python? I have question about if anybody know how could I make bot leave after being some time inactive?
leave voice channel
well there's asyncio.sleep and... hold on let me open the docs...
Ok so I have the following, simple lines of code, why~ when the user aint a verified dev, does it say they are?
const user = message.mentions.users.first() || client.getUser(args[0] || message.author.id),
guildMember = client.getMember(user.id, message),
userFlags = user.flags.toArray(),
bot = user.bot;
const verifiedDev = !bot ? userFlags.filter(x => x.includes("VERIFIED_DEVELOPER")) ? client.Constants.Emojis.Badges.Verified.Developer : "" : "";
@snow urchin why filter?
Yeah thats good. I have idea how could I do it. But it would be somehow bad
Just do
userFlags.includes() @snow urchin
with some asyncio.sleep
@strange trout look at @snow urchin code, that is not an object... Only object has , after every line or whatever that even is
Yeah thats good. I have idea how could I do it. But it would be somehow bad
@fast glen Which part are you confused on?
const x = 1,
y = 2,
z = 3
Volt the commas are just separators
How do you create a levelling up system?
interesting
It's short for (based on Alexis example) js const x = 1 const y = 2 const z = 3
Oo
I was thinking on something like this:
when bot stops playing the function will start. If the bot would still not be playing after some time he will leave.
I have problem with that it will spot some time when the song just ended and person wants to start another song
But I have idea how I could fix this problem
How do you create a levelling up system?
Does anyone have ideas?
The formatting makes it look confusing
@marble scaffold There's lots to a leveling system
Does your bot have a database?
Yes
when bot stops playing the function will start
A custom event, possibly?
Interesting
yeah thats what I was thinking about
in that event you assign the vc ID to a global dictionary (attached to the client object), sleep for a while, and see if ID is still there
Do you know about making xp formulas? What type of growth do you want: linear, exponential, logarithmic etc.
on play command, you remove the ID from the dictionary
Yes that could do. I first thought on something like reseting the function but then I found that nothing like this exists in python
So i got a play command here i made, the message collector in the middle of the code works fine if you try to queue a song but don't answer in 15 seconds, it will stop the collector and emit the end event, causing it to check if the collected message size is 0 then say you didn't respond in 15 seconds, but... If you queue a song and after this song try to queue a song and not respond, it won't check if it responded or not in 15 seconds, it just continues the session and causes an error ofc
https://pastebin.com/k3UQ82zV
Ideas?
It's cool math stuff. Look it up to get a good idea of how they work
I've previously written about stats in RPGs but I avoided talking about one of the most important RPG stats; the level! Levels are such a unique stat they need examining all on their own. We'll cover using them to increase stats and how to implement them in a ...
This has a few good examples
How do I get a token env from a file named config.env? I've tried process.env.token (defined as token in the .env) but it returns undefined
Ahh thank you
It's lua but the math is there lol
Yeah lol ๐
Hello
Hi
need help?
h
let permissions = channel.permissionOverwrites.get(guild.id);
Why this is always undefined?
my bot say I'm ready, but i do z!ping and dont work :c
the console don't say errors
idk why is buged
thats not enough info to help
@solemn latch guild.id === everyoneRole.id
https://discordapp.com/channels/264445053596991498/272764566411149314/730490034997952523
Just to come back to my question, i searched for some open source web bot dashboard, and i foud the dashboard of the "guidebot" by an idiot's guide (on github), which uses Discord.EvaluatedPermissions like this :
const renderTemplate = (res, req, template, data = {}) => {
const baseData = {
bot: client,
path: req.path,
user: req.session.user
};
res.render(path.resolve(`${templateDir}${path.sep}${template}`), Object.assign(baseData, data));
};
//other things
const perms = Discord.EvaluatedPermissions;
renderTemplate(res, req, "dashboard.ejs", {perms});```And then this in the ejs file :
```js
<% user.guilds.cache.forEach(guild => {
const permsOnGuild = new perms(guild.permissions);
if(!permsOnGuild.has("MANAGE_GUILD")) return;
%>```How does this work exactly ? I tried to run the dashboard but it looks deprecated, because of newer djs versions, so i don't know if this is still functionning ^^
and please ping me
@hasty lotus if you need help with anidiotsguide you should ask in their community.
the invite is listed on the website, and probably the github
TypeError: vCommands.map is not a function - I can't workout what it is 
whats vCommands
@autumn aspen talk hehe
nah not really
just need to learn some laravel


