#development

1 messages · Page 547 of 1

earnest phoenix
#

i'm pretty sure forcefully grabbing invites from a server with your bot is against the tos

topaz fjord
#

not against tos, just unwanted I believe

earnest phoenix
#

It's not cry

#

it's still being an asshole

topaz fjord
#

It's all up to the server owner if they want to do that or not

earnest phoenix
#

It will only grab me the link to a single server

#

I tried to do your method but returns the same result

#

Turtle i am alright with that, and I can handle the errors without perms.

#

I'm just not that expirienced and I would like to add that to my bot for my use only.

#

I'm not one to try and get spoonfed, but I would love to have this in a bot, and I do not know how.

amber fractal
#

.map returns an array

#

You know how to get values from arrays right?

earnest phoenix
#

No

#

I work on this with another user

#

They do not know how to make what I am asking aswell

#

and They normally are the ones to make commands while im at work

amber fractal
#

Its discord.js right

earnest phoenix
#

yes

amber fractal
#

Oh

#

Beat to it

earnest phoenix
#

great minds think alike.

#

some examples combine webdeving and js but you'll get the gist of it

#

I got the gist

amber fractal
#

Instead of just sending it, you should assign it to a variable to access it later

earnest phoenix
#

Do you think someone has made this before?

#

Cause my main dev set the whole bot up, I just edit the code

amber fractal
#

Mostlikey, but making it your own way give valuable skill and lessons

#

https://discord.js.org/#/docs/main/stable/class/TextChannel in here you can find out how to make invites aswell

earnest phoenix
amber fractal
#

That would work, or create invite which you need permissions for.

earnest phoenix
#

Create would be best

#

I did turn on the async function where i defined message

mental solstice
#

I didn't see createinvite on d.js docs.. maybe I over looked it, but swear ive seen it before

earnest phoenix
mental solstice
#

lol that website

#

where the picture is hosted

earnest phoenix
#

Custom Host

#

lol

#

so in JDA

#

wouldn't EventListener be a superclass

inner jewel
#

no

#

it's an interface you implement

wet forge
#

Quick question. Anybody know the URL format for jumping to a message in a server?
nvm im blind

earnest phoenix
#

console.log("(client.user) Ping")

#

why is not there the username

#

what

#

i like : when a user send Pong -> and that goes to the Consol with his name

#

username

coral trellis
#

@earnest phoenix

 console.log(`${client.user.username} Ping`)```
earnest phoenix
#

thx

quartz kindle
earnest phoenix
#

it dosent works

quartz kindle
#

show code

earnest phoenix
#

sendconsole: function() {
console.log(${client.user.username} Ping)
}
}

quartz kindle
#

show all code

#

and in codeblocks please

earnest phoenix
#

module.exports = {
sendconsole: function() {
console.log(${client.user.username} Ping)
}
}

#

that is the code

quartz kindle
#

like this ```code here```

earnest phoenix
#

its a require

#

German?

quartz kindle
#

there is no client in that function

#

the module cannot see client

#

you need to specifically pass something to it

slim heart
#

Eef

earnest phoenix
#

@quartz kindle and how i did that?

#

by using javascript

quartz kindle
#

for example

#

function(text) { console.log(text) }

#

then in the other file yourfunctionname(text you want to console log)

earnest phoenix
#

k

#

or put your function in the same file as your client

#

k i make it but there stand dosent his name

#

in console : LS-Gangwars Ping Ping

earnest phoenix
#

Error: Couldn't find an Opus engine.

#

client.on('', message => {
if $ip,$port
$ip=84.200.101.107
$port=22005
if (true) {
if (message.content === 'server online'){

         }
     }
};

}

#

why

bright spear
#

???

#

wut

#

you're putting... not js in js

#

why do you have ips and ports in a client on message

fierce owl
#

no one knows

bright spear
#

@earnest phoenix looks like you're putting non-js code in js

#

which obviously wont work

#

pls just learn js

#

or pick a different language but stick to it

keen drift
lusty dew
mental solstice
#

extra </a> after or before your button tags

#

why saved as xml?

lusty dew
#

it is the websites syntax detection

#

it is not acccurate ig

#

accurate

#

Also

#

Omg

#

I can't believe I didn't notice that extra </a>

#

It still isn't showing up though

mental solstice
#

line 9 of your css

#

missing ;

#

line 15 and 34.. and 60 something

#

or last lines dont require?

lusty dew
#

I pretty sure they don't but I could be wrong

mental solstice
#

I dont think they do now that I think about it

#

I dont see any issue.. idk if XML is messing with it

lusty dew
#

xml?

#

It isn't xml

mental solstice
#

its saved as xml

inner jewel
#

that's just the autodetection

#

for highlighting

lusty dew
#

Yea

mental solstice
#

type="button"

#

?

lusty dew
#

I don't see why that is needed

#

but ok

#

Yea

#

That didn't help

#

@mental solstice Do you even know Html?

mental solstice
#

I know a fair bit lol I dont see why it's not working.. so I assume try thing

#

is it because the css puts the button off the page?

lusty dew
#

It shouldn't be off page

#

I already did the measurements with the first button

#

and adjusted them accordingly

mental solstice
#

comment out the css for button tag and see if it shows up

lusty dew
#

I have already made it just a nomral button without any color or change of possiont

#

position*

#

the button still won't pop up

mental solstice
#

no idea then.. have it hosted anywhere?

lusty dew
#

Nope

#

I am doing it all from my pc

#

Unless

#

Fuck me

#

I hope my friend stopped hosting it when he looked at it

#

:/

keen drift
#

can you put this on codepen for people

earnest phoenix
#

Is something wrong with discord's emji system?

keen drift
#

looks normal

earnest phoenix
#

Look closer

#

it's showing default emojis with server titles

keen drift
#

ur scrolling 2fast

#

sl0w

earnest phoenix
#
if(command == "lb") {
    
    db.startsWith(`guildMessages_${message.guild.id}`, { sort: '.data'} ).then(resp => {
    
    resp.length = 10;
    let finalOutput = '**Leaderboard:**\n\n';
    for (var i in resp) {
      finalOutput += `${client.users.get(resp[i].ID.split('_')[2]).username} -- ${resp[i].data} messages`;
    }
      message.channel.send(finalOutput)
    });
    
  }
``` can someone help me with this code
#

I didn’t see any mistakes but it didnt give me a message leaderboard

fresh pewter
#

@earnest phoenix wat is your bot

#

just wana know

earnest phoenix
#

its not approved yet, but i have another one named @earnest phoenix

native geode
#

@earnest phoenix

pale raven
#

@spice willow

#

Jk

mental solstice
#

fiqstro does your command have your prefix added in? or does that need to be added In front of "lb"

earnest phoenix
#

My command had my prefix added in

bright spear
#

@earnest phoenix (cc @keen drift) thats a bug in channels where you dont have the use external emojis permission

keen drift
#

?

earnest phoenix
#

Oh you saw that?

bright spear
earnest phoenix
#

client.on('message', message => {
if (message.content === 'how to embed') {
const embed = new RichEmbed()
.setTitle('A slick little embed')
.setColor(0xFF0000)
.setDescription('Hello, this is a slick embed!');
message.channel.send(embed);
}
});

#

it doesent works why 😦

amber fractal
#

It'd be nice if you gave us the console output or error :+1:

#

Oh

#

Wait

#

I see

#

Look at the constructor for a rich embed

earnest phoenix
#

i find my Mistake xD

#

const { Client, RichEmbed } = require('discord.js');

tender steppe
#

There is nothing wrong with that?

amber fractal
#

const embed = new RichEmbed() is wrong unless you require RichEmbed as discord.js

#

the proper constructor is new Discord.RichEmbed()

bright spear
#

no

#

if you do ```js
const { Client, RichEmbed } = require('discord.js');

then new RichEmbed is corrct
amber fractal
#

Did you read my message?

bright spear
#

theres nothing "improper" about that

amber fractal
#

unless you require RichEmbed as discord.js

bright spear
#

this is false

amber fractal
#

new Discord.RichEmbed(data); is literally what the docs say

#

Its not improper

bright spear
#

well you implied that new richembed is improper

amber fractal
#

it is, unless you for some reason require RichEmbed as discord.js

bright spear
#

"for some reason"
its cleaner

#

theres nothing wrong with it its just a different style

amber fractal
#

Normally, you just do const Discord = require("discord.js")

bright spear
#

just because someone else does something a different way than you doesnt mean their way is wrong/improper/abnormal

amber fractal
#

Never said it was?

#

Now the edit

#

makes it correct

#

I guess the word "unless" doesnt matter?

#

Either way before this escalates Im going to bed

zealous veldt
#

lmao k

earnest phoenix
#

What is wrong with this code

#
if(command == "lb") {
    
    db.startsWith(`guildMessages_${message.guild.id}`, { sort: '.data'} ).then(resp => {
    
    resp.length = 10;
    let finalOutput = '**Leaderboard:**\n\n';
    for (var i in resp) {
      finalOutput += `${client.users.get(resp[i].ID.split('_')[2]).username} -- ${resp[i].data} messages`;
    }
      message.channel.send(finalOutput)
    });
    
  }
violet dagger
#

you tell me

quartz kindle
#

which library is db coming from? is db.startsWith even a thing? also resp.length = 10 is not really doing anything, thats not how you limit the length of an array

earnest phoenix
#

@quartz kindle it’s from quick.db

quartz kindle
#

alright, so assuming the db is getting what you want correctly

#

just remove the resp.length and do js for(let i = 0; i < 10; i++) {}

#

instead of for in

earnest phoenix
#

So ill delete resp.length

keen drift
#

real question is why you modifying the length property

#

it's readonly

earnest phoenix
#

And replace (var i in resp) with
(let i = 0; i < 10; i++)

keen drift
#

or in to of

#

¯_(ツ)_/¯

quartz kindle
#

he wants to iterate over 10 items only, not all of them

keen drift
#

would be logical to filter that on the db query

inner jewel
#

for of and break

quartz kindle
#

why for of? plain for is faster

#

by like 1 nanosecond

earnest phoenix
#

It says cannot find the property of id of undefined

#

i renember i defined resp

keen drift
#

using what code

quartz kindle
#

console.log(resp)

#

it may happen that your db will return less than 10 results

#

so you will need to check for that too

earnest phoenix
#

Where do i put that

quartz kindle
#

for(let i = 0; i < (resp.length > 10 ? 10 : resp.length); i++)

keen drift
#

yikes can't imagine pulling down all the records just to iterate 10

#

good stuff

quartz kindle
#

well, according to the quick.db docs, the startswith function returns all matching entries

#

no option to limit

earnest phoenix
#

How about console.log(resp)

quartz kindle
#

console.log(resp) is just for you to see in the console the results of the db

earnest phoenix
#

Oh kk

quartz kindle
#

you can put it anywhere after resp is defined

earnest phoenix
#

It works fine but still the problem i had at start

quartz kindle
#

whats the problem?

earnest phoenix
quartz kindle
#

show the result of console.log(resp)

earnest phoenix
#

I havent put it in yet

#

Where do i put console.log(resp)

quartz kindle
#

before the for

earnest phoenix
quartz kindle
#

then your db is empty

#

either you're not inserting data in it correctly, or you're not retrieving data from it correctly

keen drift
#

oh god this is a wrapper for mysql

earnest phoenix
#

Can you check my code again see if i did simething wrong with the data

keen drift
knotty steeple
#

no its sqlie

quartz kindle
#

you can try db.all()

#

instead of db.startswith

#

to see if there is anything at all in your db

keen drift
#

hecc sql in general then

earnest phoenix
#

Ok

quartz kindle
#

just do db.all().then

#

without any options

knotty steeple
#

@keen drift atleast it isnt discord-economy

earnest phoenix
#

Its not a function

#

??

quartz kindle
#

what isnt

#

.all or .then

topaz fjord
#

What lib are you using

earnest phoenix
#

.all

#

@topaz fjord quick.db

quartz kindle
#

weird lol

topaz fjord
#

oh I see the sqlite wrapper

quartz kindle
earnest phoenix
#

Ik

topaz fjord
#

I don't see the point to quick.db but that's a talk for another time

#

@quartz kindle it doesn't return a promise I think

quartz kindle
#

i havent used quick.db either, so idk what else

#

if it doesnt return a promise, it would throw on .then() no?

#

he said its throwing on .all()

topaz fjord
#

you could try it without .then()

quartz kindle
#

try console.log(db.all())

#

lul

topaz fjord
#

bc usually it'll complain saying it's not a function if it doesn't return a promise

#

And u use .then

keen drift
#

@knotty steeple what's that

quartz kindle
#

yeah but it should say .then() is not a function not .all() is not a function

knotty steeple
#

look for it on npm

#

its supposed to be used for bot economy

keen drift
#

Kek

knotty steeple
#

and is also sqlite

quartz kindle
#

my bot still uses json lmfao

#

im gonna move to sqlite when i finish my api

earnest phoenix
#

didnt work either

keen drift
#

Npm never ceases to amaze me

earnest phoenix
#

I even followed a video tutorial online for the command (because im new at quick.db)

#

Still doesnt work

topaz fjord
#

Step 1.

knotty steeple
topaz fjord
#

Never follow videos

knotty steeple
#

they can be outdated

earnest phoenix
#

Its new

#

Well not rly..

#

5 months ago

keen drift
#

Did the video say use quick.db

quartz kindle
#

try doing condole.log(db.all()) at the beginning of your bot file, right after you define db

#

and see if it shows up in your console when your bot starts

topaz fjord
#

@keen drift I'm gonna bet it did

#

Also that community is full of people who need spoon-feed

#

I've been there before and I think I'm probably banned

#

They got made at me for telling someone to learn js

knotty steeple
#

plexi?

topaz fjord
#

yes

knotty steeple
#

been there

earnest phoenix
#

Didnt send a thing

quartz kindle
#

did it send "[]"

#

or nothing at all

#

show how you defined db

earnest phoenix
#

Right apon startup

blazing star
#

hmm, are you trying to do any guild changes?

earnest phoenix
#

@quartz kindle const db = require('quick.db')

inner jewel
#

@earnest phoenix the owner of the bot app needs to enable mfa

earnest phoenix
#

Ah

#

Alright

quartz kindle
#

@earnest phoenix so you didnt create a table?

#

if i understand the docs correctly, you're supposed to work primarily on tables: js let table = new db.table('tablename'); table.set/get/all/startswith/etc()

earnest phoenix
#

hmm ok

whole condor
#

Can I get a webhook only with his name?

topaz fjord
#

Wut

clever remnant
#

For those who have a Raspberry Pi, do you know why after a while the program stop ? (I'm using Python)

#

I mean, even changing IDE or executing the command from the terminal the program stop without marking any message.

earnest phoenix
#

Not happening for my bot

#

I'm on a pi 3

#

With thonny

#

It's had basically 24/7 uptime

clever remnant
#

I have Pi 3 too, I wondered if it was not because I was in wifi and I lost the connection. I noticed that by uninstalling teamviewer my bot stayed longer connected.
As a result, I hesitate to buy an ethernet switch to connect my raspberry pi by cable.

#

Thank you for your answer

earnest phoenix
#

Hmm

#

Probably your internet

#

Cuz my pi is on my iot network and not on Ethernet

clever remnant
#

I will first test cable to see if my bot does not stop anymore. If so, I will consider buying an ethernet switch.

earnest phoenix
#

Okay

marble elm
#

@earnest phoenix try db.fetchAll()

earnest phoenix
#

How do I find out in a on_message_delete who deleted the message?

#

can someone help me with my websites navbar

#

on the main page

#

its offset for some reason

#

but on the commands page its not

mossy vine
#

@earnest phoenix you cant

earnest phoenix
#

and font is broken too

marble elm
#

@earnest phoenix Check audit logs when the message delete event is triggered

earnest phoenix
#

Yeah I have tried figuring out how to get into audit logs, but I cant find it in the API reference

marble elm
#

What discord library are you using?

earnest phoenix
#

Python

#
        if(!message.member.hasPermission("MANAGE_GUILD")) && message.author.id !== settings.owner return message.channel.send("`You must have 'MANAGE_GUILD' permission to use this command`")
#

Alright so, that code works and denies usage to a command with someone who doesn't have permissions.

#

But how could I insert some code, that allows the Bot Owner to use the command without needing permissions.

#

So settings.owner should be the name to put in there, I'm just not as expirienced

marble elm
#

use &&

earnest phoenix
#

Where would I insert that?

#

Do you define the bot owner with a role?

#

No

marble elm
#

!message.member.hasPermission("MANAGE_GUILD") && message.author.id !== settings.owner

earnest phoenix
#

It's in the settings.json

#

So mental: ```js
if(!message.member.hasPermission("MANAGE_GUILD") && message.author.id !== settings.owner) return message.channel.send("You must have 'MANAGE_GUILD' permission to use this command")

#

That should work?

#

Also the language is js

marble elm
#

You need a closing parenthesis

earnest phoenix
#

What about now

marble elm
#

Yeah, you need to have settings defined in that command file

earnest phoenix
#

Wouldn't I put ownerID instead of settings.owner?

#

or does it matter

marble elm
#

Doesn't matter

mental solstice
#

wouldnt u want || instead of &&

slim heart
#

Yeah you need ||

#

Which means or

mental solstice
#

if they have manage guild.. but arent owner.. it will say u need manage guild

slim heart
#

Because it’ll only invalidate if they have both of them

#

Just replace && with ||

#

When checking if something isn’t something else and you want to see if they don’t have either of them you need to use or (||) only use && if you’re doing it when you want it to work if they’re true.

knotty steeple
#

since they are using ! operators on both expressions && turns into ||

#

it gets inverted

#

so in that situation using || would mean you are actually doing &&

#

@mental solstice @slim heart

slim heart
#

That’s what I was saying above

#

That if ur saying is somethings fade use || and if ur testing if somethings true use &&

dreamy breach
#

Someone know how to get bot guilds size with jda? jda.getGuilds().size() doesn't work :c

knotty steeple
#

length?

#

idk java but if size doesnt work try length

dreamy breach
#

Length doesn't exist for an array in java :c

knotty steeple
#

oh ok

dreamy breach
#

Oh i just found, i need to wait the bot to be ready x)

inner jewel
#

length does exist for arrays

#

but getGuilds() returns a list

#

also, it's better to do getGuildCache().size() instead

#

getGuilds() creates a copy

dreamy breach
#

Okay ty 😃

#

Same for Users so? @inner jewel

inner jewel
#

in general, using getXCache() is better than getX()

#

it's either more efficient or at least as efficient as getting the list

dreamy breach
#

Okay thanks 😃

earnest phoenix
#

node canvas is driving me crazy

quartz kindle
#

whats the issue?

earnest phoenix
#

its will not install i fallowed the install guide but npm will not install it

quartz kindle
#

have you installed the dependencies?

earnest phoenix
#

yes

quartz kindle
#

are you on linux or windows?

earnest phoenix
#

windows

quartz kindle
#

did you install node-gyp, GTK2 and libjpeg-turbo?

earnest phoenix
#

How do i make a Server Check with JS

#

tes

#

yes

#

Do hava anybody a nice Embed?

#

I dosent find a cool one

quartz kindle
#

whats the errors you're getting chosenone

earnest phoenix
#

@earnest phoenix make one urself

#

can you send me an Link to learn how to

knotty steeple
#

first

#

whats ur library

earnest phoenix
#

JS

#

(node.js)

knotty steeple
#

library

late hill
#

lmao

knotty steeple
#

js isnt a library

earnest phoenix
#

What do you mean with library?

#

😦

late hill
#

discord.js most likely

earnest phoenix
#

jeah bot.js

mental solstice
#

:)

knotty steeple
late hill
#

😑

knotty steeple
#

or you can use the embed option here when sending a message https://discord.js.org/#/docs/main/stable/typedef/MessageOptions

#

i never use richembeds mmLol

earnest phoenix
#

@quartz kindle Warning: Missing input files:
C:\GTK\bin\libpangoft2-1.0-0.dll
C:\GTK\bin\zlib1.dll
C:\GTK\bin\libintl-8.dll
C:\GTK\bin\libgmodule-2.0-0.dll
C:\GTK\bin\libglib-2.0-0.dll
C:\GTK\bin\libexpat-1.dll
C:\GTK\bin\libpng14-14.dll
C:\GTK\bin\libcairo-2.dll
C:\GTK\bin\libfontconfig-1.dll
C:\GTK\bin\libgobject-2.0-0.dll
C:\GTK\bin\libgthread-2.0-0.dll
C:\GTK\bin\libpangocairo-1.0-0.dll
C:\GTK\bin\libfreetype-6.dll
C:\GTK\bin\libpango-1.0-0.dll
C:\GTK\bin\libpangowin32-1.0-0.dll

knotty steeple
#

not installed properly?

earnest phoenix
#

i guse but there so many ways to install GTK on windows

quartz kindle
#

You will need the cairo library which is bundled in GTK. Download the GTK 2 bundle for Win32 or Win64. Unzip the contents in C:\GTK.

earnest phoenix
#

link

quartz kindle
#

assuming your system is x64

earnest phoenix
#

thanks

#

client.on('message', message => {
if (message.content === 'TeamCommands') {
const embed = new RichEmbed()
.setTitle('TeamCommands')
.setAuthor("New Update!", message.author.avatarURL)
.setDescription('Test')
.setFooter('Test')
.addField('Test')
.setFooter('This is work')
.setColor(0x820000)
message.channel.send(embed);
}
});

#

->

#

undefined

#

New Update!
TeamCommands
Test
Test
undefined
This is work

#

but why undefined

mossy vine
#

wat

#

send screenshot lmao

#

oh

#

because the field doesnt have a value

earnest phoenix
#

?

#

whta

#

what

#

Yundo

mossy vine
#

the .addField needs to have 2 args

earnest phoenix
#

You gotta learn the basics dude

#

Yeah i know but it doesnt works 😦

#

Yundo because it needs to have 2 args

#
  if (message.content === 'TeamCommands') {
    const embed = new RichEmbed()
      .setTitle('TeamCommands')
      .setAuthor("New Update!", message.author.avatarURL)
      .setDescription('Test')
      .setFooter('Test')
      .addField('Test')
      .setFooter('This is work')
      .setColor(0x820000)
    message.channel.send(embed);
  }
});```
#

You see that

#

Look

#

You have two set footers

#

client.on('message', message => { if (message.content === 'TeamCommands') { const embed = new RichEmbed() .setTitle('TeamCommands') .setAuthor("New Update!", message.author.avatarURL) .setDescription('Test') .addField(Test, 1, [inline=true]) .setFooter('This is work') .setColor(0x820000) message.channel.send(embed); } });

#

use this

lament meteor
#

i needs to be a string

earnest phoenix
#

This guy doesn't know anything

#

I suggest you learn a language before you decide to make something

lament meteor
#

^^

earnest phoenix
#

@quartz kindle i am getting this errror now
gyp ERR! command "C:\Program Files (x86)\nodejs\node.exe" "C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "build" "--fallback-to-build" "--module=C:\Users\TheUnChosenOne\Desktop\MogBotUpdate\node_modules\canvas\build\Release\canvas-prebuilt.node"
"--module_name=canvas-prebuilt" "--module_path=C:\Users\TheUnChosenOne\Desktop\MogBotUpdate\node_modules\canvas\build\Release" "--napi_version=3" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v67"

quartz kindle
#

why is your nodejs folder in program files x86? did you install 32bit node?

earnest phoenix
#

i did not relise i install 32bit

late hill
#

@earnest phoenix when they use [] in the docs, it means those arguments are optional 👀

#

You don't just copy that xd

sharp current
#

Hey, I am new to this whole developing thing, so I was wondering, what would I add to the kick command to have a reason? FYI, I a =m using Python

#

please help

solar mauve
#

h

sharp current
#

Can u please help

knotty steeple
#

wym have a reason

#

in the audit log?

mental solstice
#

trim the command off the kick message content and use that as your reason?

#

idk python.. I think in JS there is just a loop for each word. the sentence is split by spaces and put into an array

sharp current
#

ok

thorn nexus
#

Help please, how to protect the number of characters in the message?

inner jewel
#

what

mental solstice
#

like.. dont accept input larger than a certain amount of characters?

thorn nexus
#

you need bot to protect the number of characters in the message and if it exceeds 3, the bot ignored the message

mental solstice
#

if message.length > 3 return;

thorn nexus
#

hm

mental solstice
#

depends on the language I suppose

thorn nexus
#

d.js

#

js

mental solstice
#

are u doing this in the message recieved event?

thorn nexus
#

in command, prefix, I want to limit the number of characters

mental solstice
#

your prefix should be hard coded

#

and command names

#

err I guess unless u want server to set their prefix...

thorn nexus
#

in theory, on each server you can set your prefix, everything works fine, the problem is only in prefixes with a large number of characters

quartz kindle
#

put a limit in your prefix command

#

if someone sets prefix to something like "ubgouebgpuebgp", check for the input length, and if its bigger than like 3, reject it and return a message saying "prefix too long"

#

or something

thorn nexus
#

it is clear how it is done in js

quartz kindle
#

its very basic js

#

you can google things such as "how to get string length"

#

and "how to compare string length"

#

also google arrays and the split function, since you need to split the input

thorn nexus
#

thanks, I'll try now

earnest phoenix
#

You guys think it would be a great idea to comment on every line explaining what it does for possibly future reference when making a multi-purpose discord.js bot?

mossy vine
#

no.

earnest phoenix
#

Why?

mossy vine
#
// this line sends the pong message to the server
message.channel.send('Pong!')```
#

just please dont

earnest phoenix
#

No i mean

#

On the same line

amber fractal
#

I only do that if I'm giving code to someone on stackoverflow

earnest phoenix
#

😛

#

I am planning on hiring multiple devs to assist me with the project...

mossy vine
#

still

earnest phoenix
#

I mean something like this:

fs.readdir(config.dirs.eventsDir, (err, files) => { //Attempts to read the /Events/ Folder
if(err) return console.log(`[ERROR] ${err}`); //If there is an error doing the line above, it returns an error to the console.
files.forEach(file => { //Loops through the directory.
if(!file.endsWith(".js")) return; //If the file does not end in .js, it returns nothing.
const event = require(`${config.dirs.eventsDir}${file}`); //Requires each file so that it can load up.
if(!event) return console.log(`[ERROR] I was unable to require the event file ${file}`); //If there is a problem requiring a file, it will log it to console.
let eventName = file.split(".")[0]; //Sets eventName variable.
client.on(eventName, event.bind(null, client, config)); //Listens for new event emittions.
delete require.cache[require.resolve(`${config.dirs.eventsDir}${file}`)]; //This clears the cache on every bot restart so there is no need to use the y!reload command for events.
})});
mossy vine
#

if its literally a mulitpurpose bot i dont think the code needs to be commented

amber fractal
#

What are you making?

earnest phoenix
#

On the same line as it

mossy vine
#

no thats just stupid

#

almost all of it is self-explanatory

earnest phoenix
#

Still

mossy vine
#

maybe for the more complcated lines, like the delete require.cache...

blazing star
#

legit no one ik does that (comments on each line)

mossy vine
#

but for every line, fuck no

#

let eventName = file.split(".")[0]; //Sets eventName variable.

#

thats just

#

no

#

please dont

amber fractal
#

If you're hiring devs they should know what it does

earnest phoenix
#

But it would possibly help us in the future, maybe my devs wont know what a certain line does.

amber fractal
#

Should already know*

mossy vine
#

i doubt they dont know what a fucking let does

amber fractal
#

But if you're paying them money and they dont understand something...

earnest phoenix
#

I'm saying, what if they don't

amber fractal
#

If you hire someone and they cant do their own research they arent worth the money.

mossy vine
#

@amber fractal so programmers who need to use google shouldnt be hired ever?

amber fractal
#

Read my most recent message please

#

"cant do their own research"

mossy vine
#

i sent the message 0.2 seconds after you sent that ok

earnest phoenix
#

lol

amber fractal
#

I know, I'm just telling you to read it so people that come back to this later dont think you didnt

#

In short, do what you want, in other short, no.

earnest phoenix
#

lol

#

Hmm. okay

#

Thanks guys lol

knotty steeple
#

dont comment literally every line

#

like cyber said lines like let eventName = file.split(".")[0]; //Sets eventName variable. dont need to be commented

#
delete require.cache[require.resolve(`${config.dirs.eventsDir}${file}`)]``` this is reasonable, not all people know what it would do
quartz kindle
#

guys, remember that most people dont even comment their code, like, at all

knotty steeple
#

i dont

quartz kindle
#

commenting is always good

#

regardless if it looks bad or is done in a weird way

#

its still better than uncommented code

knotty steeple
#

but no need to like fill ur entire script with comments

quartz kindle
#

if he is a beginner it can be very good for him

#

writing down what you're doing does wonders in helping you remember

earnest phoenix
#

knotty steeple
#

i wouldnt pay a beginner to help me code

earnest phoenix
#

Atleast I have 1 person on my side 😂

#

always commenting is not a good idea

#

specially not something you would want to teach to a beginning

#

over commenting is purely unnecessary and cumbersome

amber fractal
#

My coding class said to comment what function do, not on every line tho

knotty steeple
#

you meant beginner right

earnest phoenix
#

yes

#

For the record. I ain't really a beginner 😂

#

you should only comment your code when you believe it is necessary for a future reader to understand

#

Just wanna point it out there lmao

#

that's a good rule of thumb

#

Yeah like my devs?

#

only lines which you belive that would be hard to understand

#

or that are not self-documenting enough

#

They know similar stuff to me, i'm just worried that they will messa bout with the code they don't understand

#

yea

#

just no need to make a 1 hour tutorial through comments

knotty steeple
#

if they dont know what a line does most of the time you can explain it to them

earnest phoenix
#

in fact, many comments may lead to more confusion

#

than actual help

#

It's not that simple samurai

#

it would be correct to comment in such case

#

uh i'd say it's viceversa

#

basics of programming

#

and logic

#

that's what comments are for

#

explaining things and making notes

#

Not even just a quick desc of what each line does. Maybe 3-7 Words or something?

#

Not detailing your entire code-base

#

to a point of writing more comment than actual code

#

I wouldn't recommend commenting each line

#

that's just exaggerating

#

if a developer couldn't understand at least a single line

#

experienced coders use advanced terms in their comments, then you have newbies pretending they're your most elite russian hackers when they dive facefirst into any language instead of reading docs and making beginner projects to practice first

#

than he/she shouldn't call himself/herself a developer at all

#

and that's where confusion originates from

#

Yes but my point is, I'm hoping that it will actually become a good bot... Like really good and that members will add it more. More guilds = more work to the bot. More comments = Better understanding of what things to change etc.

#

are you EA lol

#

?

knotty steeple
#

nah they are worse

earnest phoenix
#

It's not really "advanced terms" just precise wording is what really matters, and sometimes words that precisely detail a situation may seem complex

#

☝ Was this english? 😂

knotty steeple
#

your hoping it will become a good bot because all of your lines are commented?

earnest phoenix
#

No

#

^

#

then why are you forcing the comments

#

Just the bot itself will hopefully be a good bot

#

on every line

#

For future referance

knotty steeple
#

so why are you making that point

earnest phoenix
#

let me tell you something

#

there is a concept called self-documenting code

#

For my devs. So i know what to change later on if it becomes popular

#

if you comeback 6 months and you understand nothing of your code

#

you won't get any guilds if your bot is coded in a shitty way without any knowledge of the language, and shitty projects originate from shitty knowledge

#

then you'll really want to work on your coding structure and naming practices

#

Can we keep this chill? I just asked a simple question. No need to go all parliament on me lmao

#

No one is judging you

#

Ik but I feel a bit of heat in this convo

#

from some people

#

well it does sound that some people don't use proper wording

#

and it does sound somewhat offensive

#

so I understand what you're saying

#

you don't need to subtalk about it, you can just refer to the person itself, which is more than likely me

#

It's fine lol. Okay, so a few lines that are probably hard to figure out are worth commenting? Just not the whole code?

topaz fjord
#

No commenting = skill smh

knotty steeple
#

yes

earnest phoenix
#

you just need to comment the lines that need commenting

#

that's all

knotty steeple
#

i barely comment my code

earnest phoenix
#

no need to overdo it

amber fractal
#

Getting heated over commenting Thonk

earnest phoenix
#

you don't need to comment if you write readable code

topaz fjord
#

Like you don't need to comment 1 + 1

earnest phoenix
#

Alright, thank you lol. I never used to comment my code. I was a little curious if other large bot devs comment like that... Seems as if they do not lol

#

good programmers wouldn't even need comments (in most situations) as their code would be self-documenting

topaz fjord
#

Well

earnest phoenix
#

I have a 15k project and barely have around 50 comments

quartz kindle
#

most devs comment their functions

amber fractal
#

Cry, what you said is just false ;-;

inner jewel
#

i comment every single thing that other people might use

#

well, document

quartz kindle
#

they comment it using jsdoc

earnest phoenix
#

well that's just

#

stupid

topaz fjord
#

Comments are good if you intend on letting others see source

inner jewel
#

but docs are comments so :^)

earnest phoenix
#

ah I see document

#

that's a better word

#

I personally document every function

inner jewel
#

it's still a comment

#

just a special format of comment

#

¯_(ツ)_/¯

earnest phoenix
#

I understand

#
Cry, what you said is just false ;-;```
![thonkang](https://cdn.discordapp.com/emojis/282745590985523200.webp?size=128 "thonkang")
#

they have different intentions however

#

My is a project that I work on with other people? What would you recommend?

#

it is very different to comment every line of your code

inner jewel
#

also

earnest phoenix
#

than to document your functionality

inner jewel
#

even very good code can be hard to read

amber fractal
#

"you don't need to comment if you write readable code" is just wrong

inner jewel
#

eg fields added to pad for memory alignment

earnest phoenix
#

wow... Did I start this?
Slowly backs away hoping nobody see's him...

quartz kindle
#

whats popular these days is to split your code into functions and use jsdoc, like this ```js
/**

  • Download data from the specified URL.
  • @async
  • @function downloadData
  • @param {string} url - The URL to download from.
  • @return {Promise<string>} The data from the URL.
    */```
earnest phoenix
#

it doesn't have to be hard t oread if it is properly organized and documented

#

if you're a js dev your opinion doesn't count /s

inner jewel
#

try reading a lock free data structure source code

earnest phoenix
#

it may be, however, to those who have not mastered/completely understand what the code does

amber fractal
#

His bot is in js Thonk

earnest phoenix
#

yagamiTick

#

of course it is

#

JS is best imo

inner jewel
#

or crypto stuff

amber fractal
#

Commenting the use of a function can be good to know its use for later if you bring in other developers in the future, so they know what it a certain function does, bot not every line, thats a bit excessive.

earnest phoenix
#

the hardest thing to understand that I've seen is C/C++ code specially in os development, mostly because C/C++ naming conventions are somewhat vague and short

#
JS is best imo

because you more than likely can't understand any more complex language

#

bruh

#

Can you like not 😂

#

sheesh

amber fractal
#

No my lang > your lang

#

;-;

earnest phoenix
#

i'm saying that as if isn't complex with inconsistencies

knotty steeple
#

i mean

earnest phoenix
#

js implements a large amount of advanced programming concepts

knotty steeple
#

i find java the best

inner jewel
quartz kindle
#

best language is html

knotty steeple
#

but i cant code it

#

so

earnest phoenix
#

it may seem like a simple language however it is not

zealous veldt
#

jsdoc stuff great

#

woah lmao

earnest phoenix
#

my bot is written in css

inner jewel
#

without comments maintaining that kind of thing is practically impossible

earnest phoenix
#

Yes

knotty steeple
#

html is a programming language

earnest phoenix
#

'm guessing you're implementing a data structure in the code above

#

hypertext mprogramming language

#

I got another question now 😂

inner jewel
#

yes

#

that's a thread safe, lock free hashtable

earnest phoenix
#

I see

#

did you make the hashing functions

#

or are you using a helper library

#

speaking of thread safety, dbl's official .net wrapper is full of deadlocks

inner jewel
#

that's java's ConcurrentHashMap

earnest phoenix
#

I see

#

so it's based upon it

#

I am going to be adding members to a database, without using async, what would be the best way to do it? I was thinking of like do it in the 'guildMemberAdd' event. I don't really want to do it in the 'message' event... Any idea's plox?

quartz kindle
#

i have a bunch of weird old uncommented code that i hardly remember how it works

earnest phoenix
#

without using async? hm

#

what database are you using

quartz kindle
#

like this js for(i=0; i< 10; i++) { var arccos1 = Math.sin(h2) * Math.tan(e*Math.PI/180) * Math.tan(result.observer.latitudeGeodetic*Math.PI/180); if(arccos1 > 1) {arccos1 = 1} else if(arccos1 < -1) {arccos1 = -1}; var arccos2 = Math.sin(h3) * Math.tan(e*Math.PI/180) * Math.tan(result.observer.latitudeGeodetic*Math.PI/180); if(arccos2 > 1) {arccos2 = 1} else if(arccos2 < -1) {arccos2 = -1}; var arccos3 = -Math.sin(h11) * Math.tan(e*Math.PI/180) * Math.tan(result.observer.latitudeGeodetic*Math.PI/180); if(arccos3 > 1) {arccos3 = 1} else if(arccos3 < -1) {arccos3 = -1}; var arccos4 = -Math.sin(h12) * Math.tan(e*Math.PI/180) * Math.tan(result.observer.latitudeGeodetic*Math.PI/180); if(arccos4 > 1) {arccos4 = 1} else if(arccos4 < -1) {arccos4 = -1}; h2 = (ramc+180)*Math.PI/180 - Math.acos(arccos1) / 1.5; h3 = (ramc+180)*Math.PI/180 - Math.acos(arccos2) / 3; h11 = ramc*Math.PI/180 + Math.acos(arccos3) / 3 ; h12 = ramc*Math.PI/180 + Math.acos(arccos4) / 1.5; }

#

lmao

earnest phoenix
#

well that is clearly a mess

#

Desgustand SQLITE Fam

knotty steeple
#

whats the reason for doing that thonkeyebrows

earnest phoenix
#

add members to your database only when they execute database interactive commands

#

😂

inner jewel
knotty steeple
#

@earnest phoenix yes

quartz kindle
#

lmao

knotty steeple
#

wtf

earnest phoenix
#

bitwise operators may seem confusing

#

but after mastering them it is not the case

inner jewel
#

i know bitwise ops

earnest phoenix
#

they are used a lot in cryptography

#

then why wouldn't you be able to understand the snippet

inner jewel
#

but a 150 line method that consists of nothing but bitwise ops on loops isn't the easiest thing to read

earnest phoenix
#

I see

#

@earnest phoenix However, it would mean that they would need to enter the command twice... Once to actually add the to the database otherwise it would give errors, and the second time to make it work.

#

I thought it was just a block

#

I only want to make them do it once

#

you can just add the user to the database before the command's actual code? ...

#

^

#

that would mean that you would have to await the database query to apply

#

I don't know if that would be possible or not... Using cmd handler also.

#

depends on the database and the helper library

#

Thing is, I don't use async

amber fractal
#

He said he isnt using async didnt he?

#

Ye

earnest phoenix
#

😦

#

yep

#

#

It's just plain inefficient to query a database in a blocking way

#

tbh

amber fractal
#

Why not just add async tho Thonk is there something bad with it?

earnest phoenix
#

so you might want to reconsider using async programming for that

quartz kindle
#

if you must use sync, your best option is to use eventual consistency

earnest phoenix
#

I've literally never used it before

quartz kindle
#

work on an in-memory copy of the database, and only push it to the db every once in a while

inner jewel
#

if you must use sync in js, you're screwed

zealous veldt
#

Why don't you use async?

#

async cool

quartz kindle
#

^

earnest phoenix
#

Idk

#

I'm just not used to working with it

quartz kindle
#

i struggled a bit to learn how to use it properly, but after i got it down, i cant do without it anymore

amber fractal
#

Only thing I even use it for is await mmLol

earnest phoenix
#

so you're not familiar with async programming

#

then that should be your next topic to learn

#

very important

zealous veldt
#

so learn

earnest phoenix
#

Any links for it?

#

Plox

quartz kindle
#

await new Promise()

zealous veldt
#

It's really not that hard

quartz kindle
#

xD

zealous veldt
#

I learned how to use async stuff from stack overflow alone

inner jewel
#

await is just syntatic sugar for .then()/.catch()

zealous veldt
#

lmao

earnest phoenix
#

for js that is

#

one of my hardest concepts to grasp was that of async programming

#

but mostly because I never found a good guide

zealous veldt
#

yeah

#

but its cleaner

earnest phoenix
#

I like to understand things from their core, deep down, how they work internally

amber fractal
#

Wait I couldve been using await instead of setTimeout Thonk lmao

earnest phoenix
#

lmao

#

I thought it was as simple as adding await to the beginning of a line 😂

#

Clearly not 😮

#

Actually, I could still use a .then for this? ☝

#

yea you can use a callback

#

wow

quartz kindle
#

you have to learn about promises first

#

let me try to explain

earnest phoenix
#

Bloody hell

#

Huh?

amber fractal
#

.then returns a promise thats why you need to learn about it

earnest phoenix
#

Oh, it's fine. I used it already before lmao

#

in case you don't know, a promise is an object used to represent a pending action

#

Just never thought about using that

quartz kindle
#

when you execute js, your code will always execute immediately, it cannot wait, there is no such thing as waiting. what an async code does, is that it immediately returns a "promise" instead of a value, meaning it will eventually give you something, but not yet, so your code continues. when your code finishes, it goes back and looks for anything that is left over, and finds there is a promise waiting, so it goes back there again until the promise finishes, then you can receive the result from the promise, and continue the code that was waiting

zealous veldt
#

yeah

inner jewel
#

a promise is a value that will eventually™ be available, or will be an error

earnest phoenix
#

I'm not entirely sure about js, but the event loop designates execution time from action to action, it is not processed in a sequential order, that would take away the entire reason for async

amber fractal
quartz kindle
#

all types of async code, async/await, promises, .then(), they all rely on the "promise" value

earnest phoenix
#
when your code finishes, it goes back and looks for anything that is left over

that would make async programming essentially useless

quartz kindle
#

let me rephrase

earnest phoenix
#

I understand what you meant, you just didn't phrase it properly

quartz kindle
#

it finishes the code, then moves on to the next loop, and repeats any leftover/waiting code

earnest phoenix
#

what code?

quartz kindle
#

the promises

earnest phoenix
#

you're still mentioning that it is done in a sequential order

#

So .then requires the new Promise thingy ma bob?

#

What about if I was to just use .catch?

quartz kindle
#

js is sequential, its single thread

earnest phoenix
#

.then is a property of the Promise object

quartz kindle
#

what node does is put everything into a neverending loop

earnest phoenix
#

which can be used to specify the callback of the promise once it is completed

#

I am aware

quartz kindle
#

and executes code sequentially on each loop

earnest phoenix
#

it is called the event loop

#

But couldn't I just do this?

addtodatabasethingy.then(() => {
//add whole code in here
}).catch(console.error);
quartz kindle
#

if addtodatabasethingy is a promise, yes

earnest phoenix
#

It would be the adding to the database part

#

addtodatabasethingy

zealous veldt
#

does that return a promise?

earnest phoenix
#

should normally be a function call

#

addtodatabasethingy()

zealous veldt
#

yeah

earnest phoenix
#

async functions return a Promise object in javascript

#
sql.run("CREATE TABLE IF NOT EXISTS userConfig (userID INTEGER, prefix TEXT, embedColour TEXT, banner TEXT, balance INTEGER)").then(() => {
  sql.run("INSERT INTO userConfig (userID, prefix, embedColour, banner, balance) VALUES (?, ?, ?, ?, ?)", [user.id, "y!", "ffffff", "default", 500]);
  }).then(() => {
//Do the rest here
}).catch(console.error);
```?
zealous veldt
#

oof sql

earnest phoenix
#

ikr kill me

#

depends on if sql.run returns a promise

#

I would recommend using something like Knex.js

#

that's just plain painful

#

once your application grows, it'll become 70% sql queries 30% code

#

(exaggeration)

#

if you have hard-coded queries everywhere

#

Could I do this?

function userDB(client, config, userDB, user) {
//Things in database get completed.
}

//======================
userDB(client, config, userDB, user).then(() => { console.log("Finished") }).catch(console.error);
inner jewel
#

yes

earnest phoenix
#

you must return a promise in the userDB method however

#
function userDB(client, config, userDB, user) {
//Things in database get completed.
return new Promise((resolve) => {
// call resolve when you're done
resolve();
});
}
zealous veldt
#

in the code should be js return new Promise((resolve, reject)=>{ blah blah blah resolve() })

earnest phoenix
#

if you're not going to use the reject callback there's no need to include it in the parameter list

#

So:

function userDB(client, config, userDB, user) {
//Things in database get completed.
return new Promise((resolve) => {
// call resolve when you're done
resolve();
}).then(() => { console.log("Finished") })
}

So something like that?

#

yes

#

Ah okay, thank you very much 😃

#

() => { console.log("Finished") } no need for the { }

#

Yeah, I would do the rest of my code in there...

#

yep

#

you can do that but

#

hence the {}

#

I see

#

uh

#

you're doing it a bit weird

#

if you were to do it like that that would remove the purpose of the function

#

or at least the result of it (Promise)

#

what you would want to do is userDB(..).then(() => { console.log("Finished") })

#

not inside it

#

just move that piece of code

#

Yeah, I specified that earlier but you guys suggested I added the Promise stuff in there lmao

#

yes the promise should be inside the function

#

ah

#

but the .then callback not

#

Would it be good to add the .catch also?

#

Or would promise do that? Idk xD

#

you're not rejecting the promise anywhere so it would be useless

#

rejecting is basically throwing an error inside a promise

#

What if there was an error, I would want the user using the command to know that there is an error

#

where would the error originate from tho

#

Nvm lmao

inner jewel
#

.then(result => {it worked}, error => {🔥})

earnest phoenix
#

Maybe they was not able to be added to the db?

inner jewel
#

or .then(result => {it worked}).catch(error => {🔥})

earnest phoenix
#

That would trigger an error in the func, kherrect?

#

but what is the method call

#

that triggers the error

#

or that could possibly trigger such error

amber fractal
#

what if the db is down?

earnest phoenix
#

I need to know which method you're concerned that might throw an error

#

so I can help you

#

if you meant sql.run, that it would depend on what sql.run returns

#

if it's a promise than you would have to "pipe" or so to say the error using .catch into YOUR promise

#
function userDB(client, config, userDB, user) {
  sql.run("CREATE TABLE IF NOT EXISTS userConfig (userID INTEGER, prefix TEXT, embedColour TEXT, banner TEXT, balance INTEGER)").then(() => {
  sql.run("INSERT INTO userConfig (userID, prefix, embedColour, banner, balance) VALUES (?, ?, ?, ?, ?)", [user.id, "y!", "ffffff", "default", 500]);
  }).catch(console.error);
}

Further below.. (Technically in a different file cuz I use cmd handler cuz I kewl af 🔥 )

userDB(...).then(() => { 
//Rest of code here 
}).catch(err => return message.reply("There was an error adding you to the database???"))
#

OOF

#

otherwise you'll want to try catch the error and reject your promise

#

o wait

#

I can see that you attached a callback to your sql.run method so I'm guessing they return a promise

#

in such case follow my first instructions

#

if it's a promise than you would have to "pipe" or so to say the error using .catch into YOUR promise

#

Add the promise code to the func?

#
return new Promise((resolve, reject) => {
    sql.run(...).catch(reject);
});
#

then you can do

userDB(...).then(() => { 
//Rest of code here 
}).catch(err => return message.reply("There was an error adding you to the database???"))
#

aaaah

#

there is also no need for the return keyword nor the err parameter since they're not being used at all

#

Okaaaaay

#

return and err are redundant

#

So complicated at this point haha

#

probs best using async tbf but whatever

#

😂

#

it may seem complicated at first but I highly recommend you learn async programming in your spare time

#

it is certainly an efficient approach to interfacing with databases and will make your life easier in the long run

#

Do you know of any good guides at all for me to check over please??

#

not really

#

Then thats a lil problem haha

#

a simple search of async node.js programming will do

#

So would this be it? :P

function userDB(client, config, userDB, user) {
  return new Promise((resolve, reject) => {
  sql.run("CREATE TABLE IF NOT EXISTS userConfig (userID INTEGER, prefix TEXT, embedColour TEXT, banner TEXT, balance INTEGER)").then(() => {
  sql.run("INSERT INTO userConfig (userID, prefix, embedColour, banner, balance) VALUES (?, ?, ?, ?, ?)", [user.id, "y!", "ffffff", "default", 500]);
  }).catch(reject);
  })
}

Below this:

userDB(..).then(etc)
#

looks like that would do it

#

Alright, will give it a go soon 😛

#

also you're not resolveing your promise

#

or at least I can't see the call

#

ow?

#
function userDB(client, config, userDB, user) {
  return new Promise((resolve, reject) => {
  sql.run("CREATE TABLE IF NOT EXISTS userConfig (userID INTEGER, prefix TEXT, embedColour TEXT, banner TEXT, balance INTEGER)").then(() => {
  sql.run("INSERT INTO userConfig (userID, prefix, embedColour, banner, balance) VALUES (?, ?, ?, ?, ?)", [user.id, "y!", "ffffff", "default", 500]);
  }).resolve(resolve).catch(reject); // look here
  })
}
#

oof aight 😂

#

Thank you

quartz kindle
#

resolve(resolve) ?

earnest phoenix
#

LUL

#

yea

#

resolve(resolve)

quartz kindle
#

why?

earnest phoenix
#

I mean .then(resolve)

#

my bad

quartz kindle
#

lul

earnest phoenix
#

lol

#

Did you know, lul in Dutch, means Cock smart

#

good observation

quartz kindle
#

yeah something similar in slovenian

earnest phoenix
#

lol anyway.

#

Lets try this 😛

#

Would it be good to add them to the database on the message event or the command file that requires the db?

#

well

#

the message event might just spam tf out of it

#

Yeah

#

lol

quartz kindle
#

a command that requires a db, else you'll be querying the db on every single message

earnest phoenix
#

I was thinking it would probably use up more memory also, kherrect?

#

I generally add a "rate-limiting" mechanism for commands that perform database queries which increase in strictness depending on the bot's load

#

Is it good to indent code?

#

😂

quartz kindle
#

you can make a caching system

#

yeah its good, makes it easier to understand

earnest phoenix
#

Okay

#

yep

#

same goes for spaces

#

they can make a big difference in readability

#

I like to keep most code on one line so it looks cleaner

#

that's not a good idea, specially if is very long

#

you can break the line on each .

#

that's what I do

quartz kindle
#

yeah but when you use promistes and callbacks, you will have code that runs inside another code. you will want to indent that

earnest phoenix
#

I see

#

Okay 😂

#

Thank you vm guys ❤

#
something.something()
    .something()
    .something()
    .something();
#

that's what I like to do

neat falcon
#

needs a bit more async tbh

earnest phoenix
#

And I'm probably correct when saying that it is not really a good idea to stack brackets either?

#

provide an example

#

hmm one sec

#

you mean parentheses?

#

( )

#

Uhhh

#

Dunno 😂

#

I generally do use them for better readability

#

.then((result) => { ... }); // I prefer

#
jsfiles.forEach(f => {
    let props = require(`${config.dirs.commandsDir}${f}`);
    props.fileName = f;
    if(!props.help) return;
    client.commands.set(props.help.name, props);
    props.conf.aliases.forEach(alias => {
      client.aliases.set(alias, props.help.name);
    })})
#

Bottom line

quartz kindle
#

you mean something like this? function(){ function(){ }}

earnest phoenix
#

Not good?

#

Ye

#

Looks cleaner imo but may not be good

#

I personally don't see anything wrong with it

#

I would recommend you add { } whenever possible

#

specially in the if statements

#

there are several reasons why this is good practice but I'll save you the research

#

yee

quartz kindle
#

i would rather group them together just like html, into parents and children

#

i like the concept of "boxes" with a clear visual definition on where it starts and where it ends

earnest phoenix
#

So this:

jsfiles.forEach(f => {
    props.conf.aliases.forEach(alias => {
    })
  })

I'd be better doing this is what I think your saying Tim?

jsfiles.forEach(f => {
    props.conf.aliases.forEach(alias => {
})})
#

oh

#

You mean the top one?

quartz kindle
#

i would do like this js jsfiles.forEach(f => { props.conf.aliases.forEach(alias => { //code }) })

earnest phoenix
#

Ah aight

#

I'm with ya xD

#

Okie sir

quartz kindle
#

with a few exceptions

earnest phoenix
#

yea same

quartz kindle
#

if the code is a one liner

#

id rather do like this

earnest phoenix
#

I just think that it would be nicer and cleaner to stack them lol

quartz kindle
#
jsfiles.forEach(f => {
    props.conf.aliases.forEach(alias => { code })
})```
earnest phoenix
#

Yeah, i'd do that also

quartz kindle
#

if its more than 1 line, then the previous one

earnest phoenix
#
jsfiles.forEach(f => 
    props.conf.aliases.forEach(alias => code)
);

#

even simpler

#

lol

quartz kindle
#

yeah, but i dont like that style, because it hides the "ending" from the visual field

earnest phoenix
#

But then that would make room for mistakes

#

There ya go xD

quartz kindle
#

xD

earnest phoenix
#

I don't personally recommend that style, just adding to your options

#

Yer

#

lol