#development
1 messages · Page 808 of 1
I'm hosting the bot on Heroku, how do I save it to the tmp folder?
Do I just save it as tmp/graph.png?
okey srry
i cant see my token in discord developer
so its discord problem ?
or just for me ?
this happens when you open the discord developers page?
which page exactly does this happen?
have you tried with a different browser?

I'm getting an error also
....
Seems to be on discord's side
so i cant sleep this night ty discord XD
their devs have -2 iq
what mention changes?
interesting
It was a bit confusing to me but I see it as a reason why bots get declined. My bot is in the approval process at the moment and I'm wondering if someone invokes an NSFW command do we return a response mentioning that it is not an NSFW channel or do we just not send anything?
Just dont allow nsfw on non-nsfw channels
@open olive sending a message would probably be best so the user knows what's happening
And take care when using apis
Alright thanks 👍
iirc, not showing an error message can also make your bot be declined
Mhmm, yeah that's how I had it originally and I read the bot decline reasons so I switched it off and then switched it back again to showing an error message. So yeah was confused lol.
Trying to get it through the approval the first try lol, but hey there could be something I'm missing.
Basic things are: have a main functionality, alert you users when error occurs and keep it mostly sfw
And don't be lazy to write your bot's description
Yeah, mine is sfw friendly, but nsfw is okay so long as it doesn't break discord TOS.
and these guys' rules as well.
@topaz fjord Thanks for your help, got it to work with the tmp folder 😄
I'm just waiting for bot approval now
finally fixed
1412955478 a good permissions number?
Previous value was 8
Isn't 8 admin?
Yea
The forbidden permission
I'm changing to 1412955478 though
That fine?
What do you mean forbidden? Discord TOS allows it
Hmm
Everyone who has used my bot so far has done so without question
Always be specific about your permissions
Yeah, but it's a lazyman's solution
Like, you don't need voice connect permission if you don't have voice commands
Nor ban permission if you don't have ban commands
Anyways though
1412955478 seem like a good number? Can't decide if I should enable everyone pings or not
Since I filter them anyways
Under a setting that can be enabled/disabled
Actually, one of the perms I ticked seems less necessary
So I'ma go 1345846614
1345842518
I just gave mine admin and put in the description it’s for future updates but you can disable everything you don’t need.
Quick question,
Would doing a for loop like this cause performance issue and/or use more resources?
const NamedCallback = function(index) {
// Do something with said index
}
for (
let index = 0,
length = 1000;
index < length;
index++
) NamedCallback(index);
Depend on what you'll run inside that for
It's not the for that's heavy, but what you run inside it
Well, then maybe
Remember that 1000 iterations are almost nothing when saying about big numbers
Yeah, The number is slighly bigger.
It's done almost instantly, Just when hiding and showing it takes a while and feels clunky.
Profile it to see exactly which method is slowing it down
Maybe it's not the loop itself, but some step inside it
Remember that js is natively mono thread
So maybe you'll have to find ways to split work
Will give it a try, Thanks for the insight.
how do you get: thispart.get_server() like what do you put before?
what?
^
linki = client.????(destination=sid, xkcd=True, max_age=mage, max_uses=mus)
what do i put here
lan?
lang*
looks like python
python
ok 1)
dont use the client architecture
oh?
cogs
basically you split it into parts
and load each part
@client.command(pass_context=True)
async def link(ctx, sid, mage, mus):
server = client.get_guild(sid)
linki = client.(destination=sid, xkcd=True, max_age=mage, max_uses=mus)
invites = []
await ctx.send(linki)
open("invites.txt", "w+").write(str(linki))
print(f"Created invites for {str(len(linki))} channels in {ctx.guild.name} and saved them @{getcwd()}/invites.txt .")
it is supposed to get an invite from a server using a server id'
i have no clue
thats an old, obselete model =/
well then what is the new model?
it lookks like you're there but not
hold on
wrong link
there
i mean the client architecture still works, its just a lil clunky
i THINK you might be looking for fetch_invites
hmm ill tryu
i honestly cant find it
found it
invites: List[discord.Invite] = await server.invites()
no so im not on the server
is the bot tho?
yes
why are you trying to generate invites for a server you arent in tho
that's a privacy breach
rly?
@coral trellis i'm right here right?
oof
but yea.
oof
look there
what if you are in the server and you bot is in the server and you go like server-info?
you're already in that server
if its for a server you aren't in, then it becomes a problem
oh
i wonder why that is tho
would you want some random bot owner getting an invite to your server
sure more people
no.
?
the answer is no.
not all servers are public
ok 😢
ansura is in a couple private servers
the tjing is tho ive no idea if it is a private server or not all i know is that my bot is in it
who cares?
me kinda
why?
you made a public bot
what do you expect
it's gonna get into servers
i wanna know what people use the bot for
so...log commands?
🙁
there are so many better ways than breaking into a server dude.
thats not ok.
better ways?
yea. like logging commands.
seeing what people are using
eh ill just make a survey
@commands.Cog.listener()
async def on_command(self, ctx: discord.ext.commands.Context):
print(str(ctx.command) + " command called with " + str(ctx.invoked_with))
print("\t>>>>> " + ctx.message.content)
thats in mine
but imma update it to not include user, cuz its not useful without guild
but all you need is something like that, showing commands
my bot wont connect to discord
error?
language?
nope no error and in discord.js
you say "doesnt connect" . so the bots not coming online?
yes
ready event is not triggered
does your ide allow you to step through code?
no im using glitch
hm
idk then
i'd say stick a bunch of print statements in
and see where it hangs
*console.log()
ye
that
(i dont use js)
429 hit on route /gateway/bot
used debug event
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
429 - too many requests
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
logs commands to console
O
wouldnt you want to just save it in a file?
eh
i redirect bot output to a file w/ bash
oh
How to get lavalink password?
it's whatever you defined it in the config
how do I list all guilds my bot is in
I did
bot.guilds() in dpy
and the only one I found returns "undefined is not a function"
@earnest phoenix I am on discordjs and bot.guilds returns [object Map]
Djs v12 or v11 @lethal stratus
well idk how maps work
JSON.stringify turns it into {} with nothing in it
What is your discordjs version
U should know
gotta fire up ssh to check
Eval Discord.version
Ok
It should be smth like this
let string = ''
bot.guilds.forEach(guild => string += guild.name+'\n')
message.author.send(string)
message.author.send is to send serverlist in ur dms instead of current channel
Security
ye
I changed it to message.channel.send and did it in my own private testing channel
@earnest phoenix if your bot isn't loading into discord make sure you have registered the login :
For example if it's Discord.js you'd do something like client#login(token)
bruh
?
i knew that
I was just covering the basic since sometimes some developers forget it.
ok
Bot Keeps On Getting Offline NOT server issue one more bot on the same server working just fine NOT code issue no error on pm2 logs
d.js
v11
need to restart to continue
can i be hitting ratelimits?
Shard issue?
Unsharded
Alright
@small prairie glitch.com is shit for uptime and keeping bot online
I dunno. Apparently one guy used debug events
maybe link the message?
Why ytpl limits playlists size to 100?
probably because you can only fetch 100 videos off of a playlist at a time
Why did my.bot get declined for being offline when there were so many times when it was online,
I applied for it ages ago and it’s been online for ages
because your bot should be online 24/7
How would i find out wether a user is connected to a channel and which channel_id that specific channel has?
eval
@finite bough your reply was to whom?
Library?
discordjs
message.channel?
@peak venture message.member.voiceChannel
what je your version of d.js? @peak venture
11.5.1 = message.member.voiceChannel
12 = message.member.voice.channel
'(node:660) DeprecationWarning: ClientUser#setGame: use ClientUser#setActivity instead'
I taking this error how can I solve that ??
use setActivity instead
ok
It even tells you to use setActivity bruh
but a bunch of useless symbols too like ( : ) : # : #
(node:803) DeprecationWarning: Collection#find: pass a function instead
I take this error now
pass a function instead to .find()
did you try to read the error messages
Btw isn't it suppose to say depreciated not deprecation 
yea but I cant understand
appreciated
depreciated
Deprecation/deprecated is correct
Never heard anyone say deprecated or seen deprecated used before so 
As a Java developer I see it a lot
I guess it is also often used in other languages
Depreciation =/= deprecation
A method being deprecated means it isn't supported anymore
I've personally have never seen depreciation over deprecation
But I guess, according to 2, it is another term for it 
depreciation is like: don't use that cuz it's shit
deprecation is like: use at your own risk, it might not be there on future releases
Yea i knew what it meant but hardly anyone used deprecation over depreciated
yep
I have never seen anyone use depreciated
Wait what
it really depends on the context it's used in but more often than not, they don't have the same meaning
in programming, the correct expression is to deprecate something
to depreciate in programming means that you're not very fond of whatever you're depriciating

however in real life examples, e.g "I was deprecated at that party" and "I was depreciated at that party" have the same meaning, in that context they're synonyms
so it's like
use whatever
but if you want to be understood in development use deprecated ig
That semver link is saying the same as what cry said, use deprecated
Yes, that's what I mean, if you folow semver you have to use deprecated
D.js v11
show me your message handler
Aaaaaaaa I'm on mobile >.<
ohh
well im assuming you have something like
if (message.startswith("/")) {
jaherqhe
}
?
Its somthin like js If (!message.startswith(prefix) return
message is a string right?
Its the thing from clinit.on
well if this works the way i think it does
you should be able to get the guild object somewhere in that
Like message.guild?
if the message is an object not a string then possibly
i dont do enough JS to know for sure
if (message.startswith("kt!") and /*guild*/.id == 264445053596991498)
message = "/" + message.slice(3,len(message))
if (!message.startswith(prefix)) return
something like that should work
basically, if it sees something like kt!asdf in THIS SERVER it changes it to /asdf
kinda hacky but it should workk
you're on your own, getting the message's guild tho
Mind DMing that to me?
For stability?
and wym
What's ym
jda here
gmod e2 here
Batch here
assembly
wait
you mean *bash
bash >>>>> batch
I ment batch.
learn bash ;p
WSL ftw
the funny thing is, batch cant even web request without additional libs
bruh moment
xD
i mean technically neither can bash
but just about every system has wget and/or curl
Hi, can someone help me make a prefix command
I've never dealt with databases so, i dont know where to start (eris)
Blooding my eyes.
Use mysql because it's cool
Add a guild id and respective prefix to each row of table
On message event, query table and get prefix
i have never used mysql or any database
What lingo you using?
for now i want to use quickdb
i've been told to use mongoose
well not been told, recommended by people who're really proficient in them kinda stuff
At the end of the day, a db is a db and so just read the docs of a few different ones and use the one that looks easiest
ok
is it something that i did on my part, thats why its not working?
it works..?
it logs 10 to console
which is the result of 5+5

Ohhhhh
sorry i didnt see that bit
🤦♂️
yep discords cdn page is down
Hello, how can I remove my server from website list? https://discordsl.com/server/20015/berserkov-eacute
...or you can repair my server name to Berserkove please? (berserkov-eacute)
I want vote bot
What is this page for login
Use mysql because it's cool
mysql was cool in 2009
now its all about postgres
i use SQLite
it works good
What

sqlite is fine for small scale

i used it in a lot of my projects
99% of bots are small scale
pretty much yeah

stop being annoying, yasser, thanks
@earnest phoenix no emoji spam pls thx
thank your for help me @earnest phoenix @earnest phoenix @quartz kindle
k
How much is "small scale"
< 100k guilds
lmao
you'll know it when you notice a drop in performance
ah
pretty much yh
if you use default discord.js with default caching then its already pretty large scale at 5k lol
one of the devs seems to of lowered the threshold for when the bot mentions devs if somthing is lagging like shit
rip my notifications
your bot sends you notifications when it lags?
@quartz kindle wasnt my idea
if anyone knows of course
altho does let you know if a Loop fucking axed itself
i mean, its a cool feature, but when 99% of lag problems are discord's fault, doesnt really do much lmao
i have never used a database
nah this is internal timing
k
ah cool
how long the loops are taking to complete etc..
and 0.99s is not what i call an issue xD
20 secs yes
but 0.99 nahh
what could possibly take 20s internally
lmao
theres one loop
the 4 main loops
seem to occasionally gain like a 20s time or more
i have no idea why
@digital ibex mongoose is a library that uses mongodb. you need to have mongodb installed in your system, or you need an account in some online mongodb database if you prefer an online version
not really, i've never used them
check their websites, create an account, see what the limits are
they should give you an URL that you can put in mongoose to connect
yes, as i told you, mongoose is only a library that connects to mongo, you need to have mongo somewhere
wdym mongo somewhere?
mongodb is a database software
like mysql, postgre, etc...
it offers several ways to connect to it, both offline and online
oh
mongoose is a library that uses mongodb
mongoose is not a database
it just makes the connection and does the commands for you
like discord.js does for the discord api
if you want to use mongo, you can either install it in your system and run an offline version of mongodb in your system
or create an account in some website that offers online mongodb storage
SQLite is an embedded database, which means it doesnt require to be installed in your system
it runs together with whatever program you're using it with
okay
you can install an SQLite library, and the library will install SQLite for you, you dont need to install the database separately
if you're using node.js i recommend better-sqlite3
SQLite is different from mongo, it uses the SQL language
so you need to learn how to use it
How long does the verification process take?
1-2 weeks
const channel = member.guild.channels.find(ch => ch.name === 'member-log');
if (!channel) return;
const canvas = Canvas.createCanvas(700, 250);
const ctx = canvas.getContext('2d');
const background = await Canvas.loadImage('./wallpaper.jpg');
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
ctx.strokeStyle = '#74037b';
ctx.strokeRect(0, 0, canvas.width, canvas.height);
// Slightly smaller text placed above the member's display name
ctx.font = '28px sans-serif';
ctx.fillStyle = '#ffffff';
ctx.fillText('Welcome to the server,', canvas.width / 2.5, canvas.height / 3.5);
// Add an exclamation point here and below
ctx.font = applyText(canvas, `${member.displayName}!`);
ctx.fillStyle = '#ffffff';
ctx.fillText(`${member.displayName}!`, canvas.width / 2.5, canvas.height / 1.8);
ctx.beginPath();
ctx.arc(125, 125, 100, 0, Math.PI * 2, true);
ctx.closePath();
ctx.clip();
const avatar = await Canvas.loadImage(member.user.displayAvatarURL);
ctx.drawImage(avatar, 25, 25, 200, 200);
const attachment = new Discord.Attachment(canvas.toBuffer(), 'welcome-image.png');
channel.send(`Welcome to the server, ${member}!`, attachment);
});
isnt applyText a function?
array
@finite bough the way you're using it suggests applyText is a function you made lol
I am just following the guide lmao
Math.max supports both
it converts strings to numbers before comparing
@finite bough which guide?
its a user-created function
it shows there in the guide
const applyText = (canvas, text) => {
const ctx = canvas.getContext('2d');
// Declare a base size of the font
let fontSize = 70;
do {
// Assign the font to the context and decrement it so it can be measured again
ctx.font = `${fontSize -= 10}px sans-serif`;
// Compare pixel width of the text to the canvas minus the approximate avatar size
} while (ctx.measureText(text).width > canvas.width - 300);
// Return the result to use in the actual canvas
return ctx.font;
};```
LOL
on glitch u cant rlly save images as jpg I think u have to save them as assets
either way ig it works
Or just use imgur like any sane person
nobody uses imgur
that place has been broken for years, always lags and often fails to load for me lmao
tim vs imgur
A lot of devs here have their own as well
https://nmw03.is-inside.me/6Qp4uZC4.png
this is my code
https://nmw03.is-inside.me/y5QnQ1H7.png
result
I want to get values (10, 10000)
fixed
Error: Client network socket disconnected before secure TLS connection was established```
What is this?
It's an error
how do i fix it?
in the console
breathing
what were you doing when you got that error?
@quartz kindle i was doing nothing
and when the bot was not responding i checked terminal
and what versions
I've seen that error before but not using a bot
Sounds more like an issue with the host
Ug
it's taking me so long to make my bot's rewrite
it's driving me insane
how long? my rewrite is taking over 3 months
Oh wow
I mean
I've had projects that span months (one that I've had for >year)
But a bot should not
Which bot is yours?
timbot
What are the possible options to move the "Officia incidunt" image to the right of a div?
flexbox is cute
absolute positions
absolute positions make me wanna cry
xD
html and css makes me wanna cry anyway
Oh Christ's sake... ig justify-around: space-around; does the trick 
People who have some experience with Curl
how df does one use
curl -X POST -d "grant_type=password&username=<user_name>&password=<password>" -u"<client_id>:<client_secret>" http://localhost:8000/o/token/
ignore the username and password bits
lmfao
the issue i have
oh
is dealing with the -X
apparently it no likey
which is very helpful when the docs tell you to use it

@low wasp Oh?
-bots 180112943612952577
do i even need -X
@slender thistle use inline block on both text and image and put the image html on the other side of the text
^ or use flexboxes or grids, floats are just torture to deal with imo
i believe flexbox is the modern standard
should be used for everything
except if you want to support old browsers
like telnet
Grid is fairly new but some find it better than flexbox, but it's kind of not
idk
And for old browsers what's "better"?
"what works and looks nice"
I'll most likely be too lazy to test it all myself
Oh tables yes

tables 
all hail table layout
that's why shiro doesn't have a website
Error in data transfer
Traceback (most recent call last):
File "C:\Users\pinea\AppData\Local\Programs\Python\Python38-32\lib\site-packages\websockets\protocol.py", line 827, in transfer_data
message = await self.read_message()
File "C:\Users\pinea\AppData\Local\Programs\Python\Python38-32\lib\site-packages\websockets\protocol.py", line 895, in read_message
frame = await self.read_data_frame(max_size=self.max_size)
File "C:\Users\pinea\AppData\Local\Programs\Python\Python38-32\lib\site-packages\websockets\protocol.py", line 971, in read_data_frame
frame = await self.read_frame(max_size)
File "C:\Users\pinea\AppData\Local\Programs\Python\Python38-32\lib\site-packages\websockets\protocol.py", line 1047, in read_frame
frame = await Frame.read(
File "C:\Users\pinea\AppData\Local\Programs\Python\Python38-32\lib\site-packages\websockets\framing.py", line 105, in read
data = await reader(2)
File "C:\Users\pinea\AppData\Local\Programs\Python\Python38-32\lib\asyncio\streams.py", line 723, in readexactly
await self._wait_for_data('readexactly')
File "C:\Users\pinea\AppData\Local\Programs\Python\Python38-32\lib\asyncio\streams.py", line 517, in _wait_for_data
await self._waiter
File "C:\Users\pinea\AppData\Local\Programs\Python\Python38-32\lib\asyncio\proactor_events.py", line 280, in _loop_reading
data = fut.result()
File "C:\Users\pinea\AppData\Local\Programs\Python\Python38-32\lib\asyncio\windows_events.py", line 808, in _poll
value = callback(transferred, key, ov)
File "C:\Users\pinea\AppData\Local\Programs\Python\Python38-32\lib\asyncio\windows_events.py", line 453, in finish_recv
return ov.getresult()
OSError: [WinError 121] The semaphore timeout period has expired```
is this just a connection error or what?
Windows Error
try 64 bit python
quite why youre using 32 bit 3.8 is beyond me anyway
what if they use 32 bit windows 
then ur fucked
2020
32bit
what is this
a nightmare
Lol
windows 32 bits this is really bad..
Change this
windows 16 bits,the best edtion

8 bits
winrate
Moved Permanently
andembeds are dead
Lumap I think it wants 0.3 
lol
nice
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1088:14)
(node:28199) 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(). (rejection id: 15)```
Anyone know what this error means?
means connection refused lol
How would I go about getting it to reconnect is what I mean @quartz kindle bot was working fine yesterday then I woke up today and now this ^^
Nothing I made no changes to anything.... Yeah
what is in the part you removed?
is the ip 127.0.0.1?
Yup
are you on glitch?
tim what about dbl promotes you to web dev 😳
wut?
u help a lot
You get hoisted
You get people asking you why their bot doesn't work
saums in dms
Would doing a setInterval() function to check if a member is unbanned make my bot slower?
why do you want to use setInterval for that
I don't know how else to check if it's time to unban/unmute a member for a timed mute/ban
setTimeout()?
I'm gonna store the time for them to be unmuted/unbanned in a mysql
which lib do you use
Well no, if the bot restarts, then the setTimeout() gets ended and they don't get unbanned/unmuted
discord.js
just store the date
I see
then every hour or so check if the current date is the same as the one stored in the satabase
if so then do your thing
not the mos efficient
but it works
^
It's every 30 seconds, so people can be banned for x minutes
well
my reminder listener is 5 second
The time to be unmuted/unbanned is stored in mysql because if the bot restarts before they are unmuted/unbanned, it would end the setTimeout and they wouldn't be unbanned/unmuted
Idk how else to do timed mute/ban
save Date.now() + ms("ban/mute time") to database
for mute I did setTimeout
but you are correct, any restart would delete the timeout
Use a cron job
A what
and check with setTimeout ```js
if (Date.now() > time on database) {
Member.unban()
}
yeah i was planning on doing that
@summer torrent that's inefficient why would you do that
I just wanted to know if setInterval would make my bot slower
Waste of memory
wait
Just use a cron job
@summer torrent that's inefficient why would you do that
@slate mist Do you have a better idea
Yeah, use cron jobs
node-cron?
what about you save the time its supposed to be unbanned/muted and if it restarts, you do the settimeout again
If the bot is being used on a large scale you'll run out of memory using setTimeout for everything
cronjobs will save even if the bot restarts
as its a system process
a basic example with json for this https://github.com/VeraxonHD/shade-modbot/blob/master/commands/mute.js
how many bytes do setTimeout's use?
Its nothing with "bytes"
@cold lion your bot didn't yet approved
Bytes deal with strings lol
NMW03 Where VOTE ? :d
@cold lion your bot didn't yet approved
ok ty
Imagine this
you have 9 million users, and 500 thousand temporary mutes, each setTimeout() call creates a task to the task scheduler, which is cached. And as it waits for the task, more tasks pile up, destroying memory
I see
Its really inefficient especially if you want your bot to be available on a large scale
ty for the suggestion John, I think i'm gonna go with npm cron if it works out
Imma try to figure out how to use it rn
you can use the best of both worlds
use an interval that checks every 5 minutes or so, and then fire a timeout for everything that has less than 5 minutes left
but this kind of microoptimization is worthless to even think about. your bot will run into a billion other scaling issues before that makes any difference
Would using node-cron ( https://www.npmjs.com/package/node-cron ) help any like John. said?
well, its adding an extra dependency for something you can do yourself
other than that, you have to see their source code to see what they're doing
is there a way to do a timed function every x seconds without doing something that will take a lot of memory?
Like, would what you suggested help if/when my bot gets tons of users?
again, this kind of thing is not what you should be worried about
Is there something I should be worried about?
what library are you using?
discord.js
if you're worried about scaling, discord.js itself is your biggest worry
Is there a different lib I should be using? Or a different language?
depends on what you want to accomplish
also, discord.js can be hacked into being scalable
which is what i did
if you think about bots with millions of servers, they all most likely use a custom library they developed themselves
Yeah that makes sense
you think so?
yes
discord.js is a general purpose library, it can do everything the discord api allows you to do
but the cost of being able to do everything is that the library is quite heavy
you know that dank memer uses Eris
Its the caching thats a killer
one of the biggest bots
yes, especially the caching
is there a way to clear cache with javascript or sum so it doesn't take up memory?
yes there are many ways
lol
some more advanced than others
Run garbage collector
D.js caches though, which won't be purged by nodejs functions because it's still allocated as usable and not "dump"
d.js caches everything it can to avoid hitting the api
yes you can
The most efficient way to clear cache would to literally just delete client.messages
lol 3.3gb
is there a library that was built off of D.js and is more efficient?
there is mine lol
eris but its based on d.js v8
d.js v12 came out right?
yeah a bit ago
if you wanna give mine a try, search for discord.js-light
What version is it based off?
v12
Is it compatible with discord.js-commando?
no
oh dang
commando is a command handler
I'm using commando
oh god
it has nothing to do with the library itself
whats wrong with commando
I havnt seen commando for a while
i mean
my main bot is vanilla d.js tho
Because I'm relatively new into bot development so I don't no any better
I will be honest, commando makes it easier because you dont have to worry about command handling
and sure as hell dont do event handling
i mean
if you know what you're doing, its even easier to make your own than to use commando
I made my own lib
granted this is an old version of my own cmd handler
but the concept is relatively the same
can you explain the class and constructor, I dont use thoose
its object oriented programming
a class is kind of like a basic set of rules that describe a complex object. then you can easily create an invoke instances/copies of that object
that object includes functions called "methods", which do things to parts of itself
libraries like discord.js are entirely based on those
for example, when you do channel.send()
this seems very efficient
send is a method of a channel class
and all channels are an instance of the channel class
then there is extensions and inheritance
where you can define a base class, and then more specific classes on top of it
like textchannel and voicechannel
which is built on top of the base channel class
so for example, if you want a method that works on all channel types, you only define it in the base class, and all extended classes automatically gain access to it, no need to re-write the same function in all different types of channels
take a look at the mozilla docs and then experiment with them
ok
because right now I am doing module.exports and defining variables
probably not very efficient for the bot or me typing
well I mean for like the name and aliases and stuff, the stuff you have in classes, right?
you can use classes for many things
but classes are best suited for something that you will use multiple times
and each time it has to be a unique version of it
because mine is like this
alright thanks for taking the time to explain this
I like it when people explain rather than hand over code
its nice for learning
👍
its preferences
you can uses classes or a simple object
eitherways its up to your preference of coding
you can even use the old version of classes, before the class syntax existed, which is using objects lmao
I have a question, did you guys go to school for programing or pick it up as a hobby?
hobby
i picked it up as a byproduct of the things i wanted to do
cool
i learned a lot from discord bots, a year ago i didnt know what classes were or how to use them lol
if I were to use classes, could I do something like let pingCommand = new Command()?
in the () being options?
yes
and would that be efficient
the argument in there is what goes into your constructor
calling new is irrc slower
if you want to use classes for data that doesnt require unique copies of it every time it is used, you can use new Command() in your command loader, and then store the initialized class somewhere so you can simply access it
hmm
caching classes is pretty standard, like how discord.js caches channels and guilds
I dont see any reason to change it specially if its quite clean
I would like your opnions on the structure of my commands, can I send a screenshot?
just send it
¯\_(ツ)_/¯
classes is like that but longer
and you always call new Class() on initializing it
vs on just requiring that
do you do your commands a way similar to mine or classes?
although classes is more flexible on sticking features
I use classes because I need the flexibility on features
ok
albeit its longer, the investment returns is good for me
does longer mean more lines?
sometimes but not always like what I did here
If a role is unmentionable it doesn't show up in message.mentions??
D.js
or just different names
MessageEmbed is RichEmbed in v12
is it possible I could see an older version of a command handler that uses classes and constructors? I dont understand how it would initialize them
wdym an older version?
gotcha
I was expecting a no anyway
fuck I think I sound mean
im bad at talking to people
just as an example, i didnt know how to use module.exports, so i used eval(fs.readFileSync())
lmfao
that was 2 years ago
module.exports is used with require I think
yes
alright, back to my quest to understand this
my current command handler also doesnt use classes
so then what do you use?
so you moved away or did I mistake you for someone else?
for example, a command goes to the command file, and the command file gets a user class for the message author
and is it then run
smart
so i can access data about the user, save it to a database, etc
does that mean you just run code that runs a command with a different user?
no
hmm
lets say this
if you were just passing the user, couldn't you, or did I misunderstand
picture a channel in discord.js
it has channel.send() channel.delete() channel.update() etc
yeah
thats all created by a class
now when you get a channel id
you can do new Channel(id)
and you automatically get all those functions for that specific channel id
wait you can do new Channel(id)
figuratively speaking
yeah using classes depends on your preferences
i use classes for users, meaning when i receive a message, i can do user = new User(message.author.id) and i automatically get all functions that deal with users, for that specific user
i can do for example user.save() to save in my database
because i made my save function in the user class
¯_(ツ)_/¯
but basically its as saya says, its all user preference
the same can be done with functions, or with objects
I think using classes in many cases could increase the efficiency of the command and typing it
but may slow it down
depends again
you can cache classes
specially if it isnt something that changes all the time
ex: d.js makes a new User class, then when this user changed for example, their username, instead of making a new class again, why not just change the property on user class
since you are not calling new again, and just grabs the data on already existing class
there is no performance drawbacks in this scenario
so using new for commands probably would be okay because it would only slow the boot right
and you can change/update the user's properties while keeping all the user functions/methods still attached to it
I dont think a R2600 is potato so im good
any performance impact will be negligible
requiring a file is a gazillion times slower than creating a class instance
thats why using classes or just plain objects is more on preference
they are arguments for the class
basically calling new Class() is also calling a function tbh in some way
where in the constructor gets executed when you call that
class car {
constructor(color) {
this.color = color;
}
}
new car("blue") // creates a car with the color blue```
example, in my constructor, I can execute specific things, or just define properties of the class
why did you pass through client? for the command to use?
sorry if im asking questions that are annoying
you can attach objects and other classes to a class
the same way you can do message.client in discord.js
yes then just use this.client if I need access to client
ro msg.client but I prefer this.client 
kinda like function params
smart
what about super, if you were to get the command name how would you do that?
title*
the super keyword is for dealing with class extensions
it refers to the base class
because that class extends base command


