#development

1 messages ¡ Page 2007 of 1

earnest phoenix
#

yeah

#

but the other one gives unknown app

#

maybe private deleted?

ancient nova
#

why tf does isNaN check true if the object is empty???????????????

boreal iron
sudden geyser
ancient nova
#

is that not how it behaves?

#

I want to check for the object being a number

sudden geyser
#

is NaN = adahdhaidad = false
this is true

ancient nova
#

is there not anything else I can do then?

ancient nova
sudden geyser
#

wdym by checking if it's a number

ancient nova
#

I'm getting real confused

sudden geyser
#

can you describe what you're trying to really do

ancient nova
#

if (isNaN(_amount)) {

#

}

sudden geyser
#

yes but what do you want it to do

boreal iron
#

Should work with a non empty array, too

ancient nova
#

basically checking for the _amount being a number

#

what the hell

sudden geyser
#

how about typeof

ancient nova
#

typeof is better thank you

ancient nova
sudden geyser
#

like this: typeof _amount

#

which will return a string

plucky imp
#

like

sudden geyser
#

then you can just check if it's === "number"

ancient nova
#

if (typeof _amount === "Number") {

#

}

#

like this?

sudden geyser
#

yuh

plucky imp
#
if(typeof_amount === "number") {

}
sudden geyser
#

except lowercase N

ancient nova
#

aight

plucky imp
#

beat me to it

#

lol

ancient nova
#

heh

sudden geyser
#

beat you both coolyuno

plucky imp
#

ues

ancient nova
#

I've been

#

literally

#

fucking with that

plucky imp
ancient nova
#

for

#

3 hours

#

ong

plucky imp
#

it's fine lmao

#

it took 2 people

#

5 hours

sudden geyser
#

google and stackoverflow are your best friends

plucky imp
#

to help me with args

ancient nova
#

I searched

#

I didn't find anything 😢

plucky imp
#

lolll

#

and the only thing that was wrong

ancient nova
plucky imp
#

i had

#
args.join(" ").split['||']
sudden geyser
plucky imp
#

instead of ('||')

sudden geyser
#

but google has gotten worse recently shrug

#

went searching for something last month and all I was getting were referral links to amazon

ancient nova
#

bro please what now

#

I'm having an issue with typeof

#

I'm not kidding

sudden geyser
#

show issue

ancient nova
#

THIS STOPPED WORKING

sudden geyser
#

that does not involve typeof though

ancient nova
#

yep, but the amount is the thing typeof checked for

sudden geyser
#

ah

#

so the condition reads, "(if amount is zero and error is falsely) or there is an error"

#

what exactly is wrong with the code you shared

ancient nova
#

basically

plucky imp
#

bruh

#

what do you have installed?

#

like extensions

#

if you have jslint it can make things break alot

ancient nova
#

I have a thing, it asks a question

rl.question("how many times? "), async (amount) => {
if (typeof amount === "Number") return; // this just checks if amount is a number.
var Interval = setInterval(() => {
//then I use that to determine when interval stops.
amount -= 1;
console.log(amount);
if (amount === 0) return; //if it hits 0 it stops. 
}, 250);
})
```and it worked until I added the typeof check instead of isNaN
#

WHY

ancient nova
plucky imp
#

hm

earnest phoenix
plucky imp
#

sexism?

earnest phoenix
#

nah

ancient nova
ancient nova
#

it interacts with the CLI

earnest phoenix
sudden geyser
#

this looks suspect

ancient nova
#

nah that's fine

#

it's supposed to separate input into output

earnest phoenix
plucky imp
#

make the number lowercase

ancient nova
#

it's the float check that broke

#

Y doe

earnest phoenix
#

the world's flat

plucky imp
#

wait

#

why do you have

sudden geyser
#

that return in the setInterval won't work by the way

plucky imp
#
if (amount === 0) return;
}, 250);
plucky imp
sudden geyser
#

you'd need to use clearInterval(Interval)

ancient nova
#

I sent a screenshot above of what I actually do intead of return

sudden geyser
#

oh yeah

ancient nova
plucky imp
#

is Interval defined

ancient nova
#

yep

plucky imp
ancient nova
#

defo

#

otherwise my handler would gimme a error

#

I'm literally dying

plucky imp
#

to confusing for mii

ancient nova
#

braincells ded

plucky imp
#

waffle can help doe

#

waffle smort

ancient nova
#

hopefully

#

he typing sum long

earnest phoenix
#

klay moment: 🤨 ok

plucky imp
#

shush

#

your not even trying to help

wheat mesa
plucky imp
ancient nova
#

I think so

#

holy shit

#

give a sec

wheat mesa
#

Also just saying, NaN is still technically a number... ironically

ancient nova
#

const isNumeric = function (_float) {
return /^-?\d+$/.test(_float);
}
I just started getting the REGEX

sudden geyser
#

oh no

wheat mesa
#

Wtf why did you make a regex for that????

ancient nova
ancient nova
sudden geyser
#

no no no, the typeof is fine

#

please use something like typeof x === "number" && !isNaN(x)

wheat mesa
#

Would’ve taken you a quick 10 second google search or just testing typeof(10) to figure it out instead of looking for an obscure unreadable regex

earnest phoenix
#

and regex are not the fastest way

ancient nova
wheat mesa
#

Regex is very slow in comparison to a quick type check yeah

#

I avoid regex at all costs personally

ancient nova
#

holy shit it worked

wheat mesa
#

If you’re using regex a lot, the probability is that you’re likely doing something wrong

ancient nova
#

you're amazing @wheat mesa

wheat mesa
#

Regex is good in some situations but it can be avoided most of the time

ancient nova
#

my longest regex is prolly the IP check

#

/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/

wheat mesa
#

Yikes

#

Probably a cleaner way of doing that

ancient nova
#

it works so who am I to complain lol

sudden geyser
#

imb4 someone suggests you write your own ip compiler

ancient nova
#

but too lazy to make it

wheat mesa
#

I mean you could use that or you could split by dots and try to parse them as valid numbers mmulu

#

But regex is probably fine for that

sudden geyser
#

yeah now have fun figuring out what numbers make sense there

wheat mesa
#

Regex is perfectly fine for that use case

ancient nova
ancient nova
sudden geyser
#

you should see some email validators

ancient nova
#

it corrects IPs from like 1..1..1....1 to 1.1.1.1

#

but it's EXTREMELY broken

sudden geyser
#

saw one that was 170k characters long

ancient nova
#

ayooo

wheat mesa
ancient nova
#

not nice

wheat mesa
#

I have not seen a “nice looking” regex in my life

ancient nova
#

I could shoot you can example

#

if I find it

wheat mesa
#

Regex is unreadable in 99/100 cases

#

Unless you’re a wizard

ancient nova
#

I think I am

#

should I try finding it?

sudden geyser
ancient nova
#

also how would I make a range check? if value is less than 250 and larger than 5000 for example

ancient nova
wheat mesa
ancient nova
#

as a value

wheat mesa
#

Just do a simple of check

lament rock
#

in regex?

wheat mesa
#

If*

#

Also your sentence doesn’t make sense actually

#

Less than 250 AND larger than 5000 isn’t possible

dry imp
#

lmao

ancient nova
#

if value is less than 250 don't execute, and if it's larger than 5000 also don't execute

#

also found some rather nicely readable regex, it's neat if you sort it

wheat mesa
#

You said AND not OR

ancient nova
wheat mesa
#

Important distinction to make :p

#

Just do exactly as you said

#

if(value < 250 || value > 5000) return;

ancient nova
lament rock
#

this regex is to pick apart an error stack frame

#

well. A specific frame

ancient nova
lament rock
#

I bet

ancient nova
#

anyway Imma dip today

#

thanks for all da help

sudden geyser
#

github keeps recommending me node-ipc and peacenotwar in the explore tab

#

I think this is a sign

austere surge
#

what

plucky imp
#

ESLint or Jslint

sudden geyser
#

ESLint since I'm more familiar with it

#

Maybe JSHint if I learned about it

#

But ESLint has a lot more knobs and stuff so it's attractive

plucky imp
#

ty

wheat mesa
#

Should I learn electron with typescript

#

Or should I use js

sudden geyser
#

either one probably works

wheat mesa
#

I feel like those frameworks weren’t really designed with ts in mind at first so it might be finicky

#

But I’ll look into it

#

I was about to set up my pc but tornado sirens are going off so I suppose I’m gonna have to delay that mmLol

plucky imp
#

@sudden geyser any good bottums name?

sudden geyser
#

what's the bot's subject

plucky imp
#

probably gonna make it an economy one or like gacha

spark flint
plucky imp
#

¯_(ツ)_/¯

#

wait i found a unique bot pfp

#

can't share that lol

wheat mesa
sudden geyser
plucky imp
#

hMMM

sudden geyser
#

or you could just flip open the reliable greek dictionary, flip to a random page, and look up a word in there

plucky imp
#

sure

#

treasure in japanese

#

cs ima weeabo

sudden geyser
#

emeraldas

plucky imp
#

h o k u s

#

LOL

#

it's really Hoko but Hokus sounds d=funntYcdjd

sudden geyser
#

good candidate illyabaka

dry imp
#

Hakos

plucky imp
dry imp
#

why greek word sounds so cool

woeful pike
#

κυβερνήτης

sudden geyser
#

kubepvntns

#

I don't know about you, but I'd take that bot name before anyone else does

pearl trail
#

kubernetes™️

quartz kindle
#

kubepvntns best name

plucky imp
#

tbh

#

kinda bored so ima code inna bit

sudden geyser
#

Oedipus?

#

yes

maiden swan
#

anyone know why Slash commands wouldnt show up after an hour in a non guild_ids server? I invited my bot with Application Commands scope as well and it still hasnt appeared

#

alright. Just tested and im getting 0 errors when i push my code. I reinvited so now ill just wait a bit

wheat mesa
#

is there a way to make webstorm format automatically/on save or do I have to use prettier like I would normally do on vscode

boreal iron
bright hornet
#

How do i get image using axios? res.image is enough right?

plucky imp
#

abcdefghijklmopqrstuvwxyz

maiden swan
#

nvm that helped me. I figured out what i did wrong

wheat mesa
#

actually sending a curl request to that url seems to give the binary data back

boreal iron
#

That’s just up to you how you register them

bright hornet
#

curl?

quartz kindle
#

defense curl

bright hornet
#

ah using another package?

#

instead of axios, im going to use curl?

neat ingot
#

iron defence is much stronger.

quartz kindle
proven lantern
#

is there a good way to write integration tests for discord bots?

bright hornet
lyric mountain
#

Idk what for js

quartz kindle
bright hornet
#

this is how i do ```js
Axios.get('https://randomfox.ca/floof/?ref=apilist.fun')
.then((res) => {
const embed = new MessageEmbed()
.setTitle('FOXY!')
.setImage(res.image)
.setColor('RANDOM')
.setTimestamp()

                message.channel.send({embeds: [embed]})
            })```
proven lantern
quartz kindle
#

if so that should work

bright hornet
lyric mountain
#

Since it depends on user interaction not just some automated tests

quartz kindle
#

and read axios docs

bright hornet
#

okok

proven lantern
#

i was thinking i could save a request and send that to my interaction endpoint, but i dont think that works if i'm logged out

#

or the security token thing will expire

lyric mountain
#

Fill it with unit tests, they'll be pretty enough to assert it's working properly

#

Since commands are isolated by definition

proven lantern
#

then i shouldn't really have an integration environment

bright hornet
proven lantern
#

straight to prod

lyric mountain
#

Ye, integration tests feel weird for discord

bright hornet
#

wait a min

#

i think

lyric mountain
#

Just make sure all commands and modules are working (unit tests)

#

If all pass you're dog

bright hornet
#

knew it

#

lmao

#

fixed

#

it shows like res.data.image

#

thanks mates

bright hornet
#
let RN = Math.floor(Math.random() * 100) - 1
if(RN > 25) {

} else if(RN > 50) {

} else if(RN > 75) {

} else {
    
}``` is this right or na
neat ingot
#

you should work backwords

#
    if(RN > 75) {

    } else if(RN > 50) {
    
    } else if(RN > 25) {
    
    } else {
        
    }
bright hornet
#

oh

neat ingot
#

what you have would return the first check anytime over 25, even if 50 or 75

bright hornet
#

i see isee thanks

neat ingot
#

no worries 🙂

rocky hearth
#

What is this code in md files

---
lang: JavaScript
syntax: javascript
title: JavaScript is to Java what Cupboard is to Cup!
author: umng01
---

What that block is called?

wheat mesa
#

How do I get an electron app to log to the WebStorm console instead of the application's devtools console?

neat ingot
#

why webstorm?

wheat mesa
#

because that's what I'm using

#

I like the feel

neat ingot
#

fair enough. if you use most of the technologies it supports

wheat mesa
#

I usually use vscode for stuff like this, but I wanted to give webstorm another chance

neat ingot
#

yea, it doesnt look bad. i hadnt heard of it before 🙂

wheat mesa
#

the only problem being my console in devtools keeps getting overwritten which means I can't see my logs

neat ingot
#

hmm

#

so webstorm is stealing your logs to output somewhere else?

wheat mesa
#

well, the electron app is logging to its own devtools window

#

but there's a warning about a security issue (that I don't care about at the moment) that keeps overwriting whatever I log to the console

#

I can see the data pop up for a brief moment, then disappear in the console

neat ingot
#

not sure if it will help, but you could do this:

const {createWriteStream} = require('fs');
const {Console} = console;
// new FileTransport({filename, options});
class FileTransport extends Console {
    constructor(file_options) {
        const {filename="", options={}} = file_options;
        const log_stream = createWriteStream(filename, options);
        super({stdout: log_stream, stderr: log_stream});
    }
}
#

to create an instance of a custom 'console like' object, that you can do 'console.log' etc with, that will save the output to a file

wheat mesa
#

I might resort to that if I absolutely have to, but I'd prefer to use the built in console if possible

neat ingot
#

you would have to then use that logger instead of console though

#

yea i get that 🙂

wheat mesa
#

here's a gif of what it's doing

#

you can see the console get rewritten

#

it's supposed to be logging the form

neat ingot
#

hmm

#

your page is refreshing

#

when you submit the form

wheat mesa
#

which I've seen it do a few times, it just gets pretty much immediately overwritten

#

ah

neat ingot
#

your not preventing the default event

#

#beenthere

#

lol

wheat mesa
#

how would one cancel said event

#

I never really do frontend but I'm hoping electron can get me more into it

neat ingot
#
function logSubmit(event) {
  log.textContent = `Form Submitted! Time stamp: ${event.timeStamp}`;
  event.preventDefault();
}

const form = document.getElementById('form');
const log = document.getElementById('log');
form.addEventListener('submit', logSubmit);
#
<form id="form">
  <label>Test field: <input type="text"></label>
  <br><br>
  <button type="submit">Submit form</button>
</form>
<p id="log"></p>
#

^ html for that js

neat ingot
#

it basically handles the build/install/updating etc etc

wheat mesa
#

using preventDefault and now it logs, thanks!

neat ingot
#

yay! no worries 🙂

#

i added a markdown -> html converter to help make a help page quickly

#

but now i have an easy way to load child windows that show markdown ~ which is nice

cloud bough
#

For some reason, presence doesn't work on my ubuntu server?

wheat mesa
#

what type of presence

cloud bough
#

discord.js btw

#

just regular

#

like "playing: this game"

wheat mesa
#

for your account or a bot account

cloud bough
#

bot account

wheat mesa
#

can't do that

cloud bough
#

dnd works itself

wheat mesa
#

oh you mean like Playing

#

not rpc

cloud bough
#

yeah

neat ingot
#

getting someone elses info or setting your own?

wheat mesa
#

nvm then

cloud bough
#

like luca

wheat mesa
#

you get any errors?

cloud bough
#

and nope

#

just doesn't change

wheat mesa
#

and can you show your code

cloud bough
#

sure one sec

wheat mesa
#

you might be trying to set it too quickly if you're changing it a lot

#

but that would trigger a ratelimit error so you'd probably notice that

cloud bough
#
module.exports = async (Bot) => {

    games = Bot.config.presence.games

    setInterval(function() {

    game = games[Math.floor(Math.random() * games.length)]

        presence = {

            "status":Bot.config.presence.status,
            "activity": {
                "type":game.type,
                "name":`${game.name} | ${Bot.guilds.cache.size} Servers.`
            }
        }

    Bot.user.setPresence(presence)
            
    }, 30000)

}```
wheat mesa
#

you never defined presence

#

or games

cloud bough
#

node.js still accepts them

wheat mesa
#

use a declaration like let

craggy pine
#

games = Bot.config.presence.games

cloud bough
#

and it works on windows

#

Games is an array, with objects in it

#

like this

[{"type":"WATCHING", "name":"jj2neat!"}]
neat ingot
#

isnt 'activities' an array of activity objects?

wheat mesa
#
// Set the client user's presence
client.user.setPresence({ activities: [{ name: 'with discord.js' }], status: 'idle' });
cloud bough
#

hmmm

#

must've changed in v13

wheat mesa
#

don't think so, and just because nodejs accepts it doesn't mean you should get into a habit of that btw :p

#

you should ALWAYS declare variables with one of those keywords

cloud bough
#

Yeah I know Im usually not in this part of my code

#

I use let

#

not var

#

and const

neat ingot
#

always const unless you need let ~ imo

wheat mesa
#

^

cloud bough
#

^^^

#

I got into the habit of that months ago

#

but I coded this little module about a year ago on v11

neat ingot
#

var if your a heathen who likes to live on the dark side 😄

cloud bough
#

or v12

wheat mesa
#

there are some very niche use cases for var

neat ingot
#

blasphemy!

wheat mesa
#

but generally speaking it's better to use let or const

#

var will lead to bugs

cloud bough
#

does var use more ram then let?

wheat mesa
#

no

#

ram depends on the type of the variable

cloud bough
#

and yeah I figured that out when I had multiple games running on my bot

wheat mesa
#

all numbers are 64 bit floats in js

#

strings depend on the length of the string

#

etc

cloud bough
#

what about huge database objects

neat ingot
#
function roughSizeOfObject( object ) {
    var objectList = [];
    var stack = [ object ];
    var bytes = 0;

    while ( stack.length ) {
        var value = stack.pop();

        if ( typeof value === 'boolean' ) {
            bytes += 4;
        }
        else if ( typeof value === 'string' ) {
            bytes += value.length * 2;
        }
        else if ( typeof value === 'number' ) {
            bytes += 8;
        }
        else if
        (
            typeof value === 'object'
            && objectList.indexOf( value ) === -1
        )
        {
            objectList.push( value );

            for( var i in value ) {
                stack.push( value[ i ] );
            }
        }
    }
    return bytes;
}```
cloud bough
#

or discord.js cache

#

like nesting

#

message.client; etc

neat ingot
cloud bough
#

ew var

wheat mesa
#

an example of why var is bad btw:

neat ingot
#

yup

wheat mesa
#

compared to let

cloud bough
#

honestly that doesn't look bad

#

it makes sense

#

tbf

wheat mesa
#

it's pretty bad

#

leads to unexpected and difficult to debug bugs

cloud bough
#

the bad thing is var in message listeners

wheat mesa
#

the bad thing is the hoisting

#

you can access it before it's initialized

neat ingot
#

^ this imo

wheat mesa
#

that's why that array got null in it

neat ingot
#

you should never be able to access a variable before its declared

wheat mesa
#

whereas if you used let you would find that pretty quickly, since it would error

cloud bough
#

is there a difference in speed at all?

#

just wondering

wheat mesa
#

not that I know of

#

it's still bad practice in 99/100 cases

#

it's also function scoped compared to let's block scope

cloud bough
#

yeah that makes sense

#

but the code did change in v13 for presences?

neat ingot
#
// WITH VAR
console.time("var-time")
for(var i = 0; i < 500000; i++){}
console.timeEnd("var-time")

// WITH LET
console.time("let-time")
for(let i = 0; i < 500000; i++){}
console.timeEnd("let-time")
wheat mesa
cloud bough
#

var-time: 2.521ms
let-time: 1.633ms

wheat mesa
#

thing when using let would be limited to the block scope it's in

neat ingot
wheat mesa
cloud bough
#

as its a loop

neat ingot
#

indeed, but it shows that var is indeed slower

cloud bough
#

im suprised var isn't faster

#

for loops

wheat mesa
#

although var seems to be consistently slower on my machine too

neat ingot
wheat mesa
#

not really surprised, it's older and hasn't been changed all that much

cloud bough
#

I mean it makes sense from the interpreter

wheat mesa
#

I'm not an expert on interpreters or the implementation of v8, but in theory you would think it's fundamentally the same thing

#

it's likely because it has to be allocated for longer since it's hoisted to function scope

neat ingot
#

seems like a reasonable assumption

cloud bough
#

yeah it does

#

thank you for your help guys

#

you're very nice too

neat ingot
#

there could have also been some additional performance improvements made that for some bacckwords compatibility reason var cannot have

wheat mesa
#

also an interesting difference, but small enough to be explained by differences in system processes

#

after a few tests it seems like let is very very slightly faster

#

I'd need more data to make an actual assertion though

#

and a better testing method

#

more stable environment

#

etc

neat ingot
#

i wonder if for looping down instead of up is still faster

cloud bough
#

javascript has some weird quirks when it comes to speed

neat ingot
#
    for (let index = array.length; index; index--) {
        const element = array[index];
        
    }

for example

cloud bough
#

iirc while loops are faster then for loops

#

like with the i++

wheat mesa
#

I don't think so but I could be wrong

#

from an interpreter standpoint I would think that they both use while loops internally

neat ingot
#
// WITH VAR
console.time("for-up")
for(var i = 0; i < 500000; i++){}
console.timeEnd("for-up")

// WITH LET
console.time("for-down")
for(let i = 500000; i; i--){}
console.timeEnd("for-down")```
#

oh fml, still var there

wheat mesa
#

lol

neat ingot
#

still quicker with both let

cloud bough
#

you should try for and while

neat ingot
#

neglegable when doing lots though

cloud bough
#

oh wow

#

very slow

neat ingot
#

yea lol

wheat mesa
#
const arr = Array(50000000);


console.time('up');
for (let i = 0; i < arr.length; i++) {

}
console.timeEnd('up');

console.time('down');
for (let i = arr.length; i; i--) {

}
console.timeEnd('down');

results when arr has 5000000 elements: ```
up: 4.093ms
down: 3.16ms

results when arr has 50000000 elements: ```
up: 20.957ms
down: 20.291ms
neat ingot
wheat mesa
#

seems to be more negligible with the more loops that are done

neat ingot
#

yea thats what im seeing too

wheat mesa
#

10x the elements but only took 5x the time for the up iterations

#

interesting

neat ingot
#

for down seems to be much faster for smaller loops though

#

'much faster' lol

wheat mesa
#

in reality it's not gonna affect it much

neat ingot
#

yea, considering were all using discord.js anyway CharDerp

cloud bough
#

lmao

quartz kindle
#

there should be zero difference between those

wheat mesa
#

it's probably the environment

quartz kindle
#

you're likely just seeing v8 being quirky

neat ingot
#

theres a clear difference between for/while/do-while though

wheat mesa
#

also this is probably just a fluke but prefix is consistently faster on my machine ```js
const arr = Array(500000);

console.time('suffix');
for (let i = 0; i < arr.length; i++) {

}
console.timeEnd('suffix');

console.time('prefix');
for (let i = 0; i < arr.length; ++i) {

}
console.timeEnd('prefix');

suffix: 2.433ms
prefix: 1.512ms

neat ingot
#

faster on mine too

wheat mesa
#

but again the difference fades with more loops

#

it's probably something weird with the timing tbh

neat ingot
#

its close though

#

yours seems to have a wider range

#

oh, it was slower that time! 😮

#

lol

wheat mesa
#

I think it's v8 quirks

#

because whichever loop I'm running second is always faster

neat ingot
#

lmao, well, moral of the story: do more loops?

wheat mesa
#
const arr = Array(500000);

console.time('loop-1');
for (let i = 0; i < arr.length; ++i) {

}
console.timeEnd('loop-1');

console.time('loop-2');
for (let i = 0; i < arr.length; i++) {

}
console.timeEnd('loop-2');
loop-1: 2.323ms
loop-2: 1.549ms
const arr = Array(500000);

console.time('loop-1');
for (let i = 0; i < arr.length; i++) {

}
console.timeEnd('loop-1');

console.time('loop-2');
for (let i = 0; i < arr.length; ++i) {

}
console.timeEnd('loop-2');
loop-1: 2.356ms
loop-2: 1.537ms
#

it's just the environment

craggy pine
#

what does ++i vs i++ do exactly

neat ingot
#

yea same, second loops faster here

wheat mesa
#

nothing in js

craggy pine
#

ah

neat ingot
#

++ increments. either before, or after you read the value

wheat mesa
#

iirc in c++ ++i mutates the reference to i but i++ creates a copy of i and then mutates it

neat ingot
#
let value = 1;
console.log(value++);
console.log(--value);```Both log 1

```js
let value = 1;
console.log(value++);
console.log(++value);
```First logs 1
Second logs 3
wheat mesa
#

(for c++)

#

once the code is compiled to asm there's no difference though

#

in terms of performance

#

Can’t wait to get into more complex performance stuff

cloud bough
#

what about creating a copy of an array

wheat mesa
#

I love this type of thing, just haven’t learned enough about it to be knowledgeable

cloud bough
#

like var tmp = [arr...]

#

oops var lol

neat ingot
#

you can get lost in the search for performance too easy imo, at least i can 😄

cloud bough
#

or like

let tmp = arr.map((v) => ... etc)```
#

like a deep copy

wheat mesa
#

I’m not sure if js takes arrays by reference or copies

#

I would assume it creates a copy because... it’s js

cloud bough
#

reference

wheat mesa
#

Are js references similar to Java

cloud bough
#

its very weird, tried making a connect4 ai and it was like

let arr1 = ["test1"]
for() {
  let copy = arr1
  copy.push("test2");
}
wheat mesa
#

Where everything but primitives is “pass by reference”

cloud bough
#

arr1 includes test1 and test2

wheat mesa
#

(Though technically Java is ALWAYS pass by value)

neat ingot
#

could be wrong 😛

cloud bough
#

Im not very technical in javascript, but I do know my way around a workplace, classes functions objects and more stuff like that

wheat mesa
#

All of my formal education is in Java

cloud bough
#

theres tricks that I pick up on but ive never really learned the most efficent ways of doing things

wheat mesa
#

I’ve never really looked into the way js handles references and that sort of thing

#

Ok so from what I’ve gathered on a quick search, all primitives are assign by value, and objects/arrays are assign by reference

#

So pretty similar to Java

cloud bough
#

I really wanted to learn java but it just seems complicated

#

especially because I started in javascript

#

just very.. different..?

wheat mesa
#

Java isn’t that hard tbh

cloud bough
#

I use javascript and python, did abit of ruby

neat ingot
#

omfg i love ruby

#

i miss it often

wheat mesa
#

It’s definitely gonna be different if you’re not used to OOP and statically typed languages

earnest phoenix
wheat mesa
#

But it’s an oddly satisfying structured harmony

#

I used to hate Java but I actually quite like it now

neat ingot
#
$ruby.is_a?(Object) {|oriented| language }```
^ prints true
#

best line of ruby code ever!

#

that line literally won some ruby code contest in 2013 lol

#

i've been in awe of it since 😄

cloud bough
#

Is it kinda like discord.js in a way

wheat mesa
cloud bough
#

like how the objects work?

wheat mesa
#

Yes and no

#

djs is “object oriented” but Java is very VERY object oriented

cloud bough
#

I made a very easy bukkit plugin in minecraft

#

that said something in chat lol

wheat mesa
#

Objects are everything in Java

cloud bough
#

and classes im assuming

wheat mesa
#

Yes, classes are skeletons for objects

#

Or factories of objects would be another decent comparison

#

People bag on Java a lot (cough cough fake) but it’s honestly a great language to learn

#

Extremely useful, easy to learn, and teaches a lot about programming concepts

#

Enforces organized code (most of the time at least)

cloud bough
#

and faster id assume then javascript

wheat mesa
#

Depends on what it is

cloud bough
#

and more powerful

wheat mesa
#

V8 is really fast

#

Java is mostly faster than js just because it’s (mostly) compiled

#

But I wouldn’t necessarily say it’s more powerful than js, there’s pros and cons compared to an interpreted language

#

Though Java is sort of interpreted

cloud bough
#

okay

quartz kindle
#

js is also sort of compiled

#

depending on the engine

wheat mesa
#

Nodejs uses bytecode technically right?

quartz kindle
#

nodejs uses v8, the same engine as chrome/chromium/webkit

#

v8 uses multiple different compilers depending on the situation

wheat mesa
#

Ah okay

cloud bough
#

what if you coded a discord bot in assembly

#

lmao

wheat mesa
#

It’s possible but I think you’d lose your mind before actually getting close

quartz kindle
wheat mesa
#

All ends up as bytecode either way according to that mmulu

cloud bough
#

cant something compile to assembly

#

like C

wheat mesa
#

Yes

#

C and C++ are two languages that compile directly to assembly

cloud bough
#

what if you just get the raw assembly

#

and use it on a bot

quartz kindle
#

you dont really "compile to assembly"

wheat mesa
#

Well, they generate assembly

quartz kindle
#

assembly is just a way of representing bytecode

cloud bough
#

c++ looks way more complicated then java and js

wheat mesa
#

It is

cloud bough
#

who would ever use it

#

;-;

wheat mesa
#

There’s a lot less lenience in C/C++ than there is in Java and Js

#

But once you know how to use it, it’s a pretty nice language

#

Especially considering the speed

quartz kindle
#

you use the best tool for the job

cloud bough
#

whats the use for c++

#

guessing ai's?

wheat mesa
#

C and C++ are the kings of most modern programming languages

#

They’re used basically everywhere you could think of

quartz kindle
#

c/c++ are used for a lot of things

#

like games, drivers, software

wheat mesa
#

V8 is written in C++

quartz kindle
#

yes

#

and chrome itself as well

#

afaik

#

and node.js as well

cloud bough
#

maybe windows

#

lmao

quartz kindle
#

sure

#

lots of parts of windows are written in c++

wheat mesa
#

Windows is probably a mix of asm, C, and C++

quartz kindle
#

same with lots of parts of linux and mac

cloud bough
#

wow

#

wonder how they came up with that idea

wheat mesa
#

C++ is basically the best trade off between low level code and sanity

quartz kindle
#

large software is made up of lots of smaller components

#

windows is not one big thing, its a mix of thousands of small things

#

each thing can be done by different teams and people

#

and also different languages depending on the situation

cloud bough
#

im guessing c++ is natively installed on win

wheat mesa
#

Writing a large performance critical program with a few hundred thousand lines of assembly? Nope. Use C++ and save yourself some sanity

quartz kindle
#

to compile c++ on windows you need to install a compiler like cmake or visual studio tools

wheat mesa
#

I don’t think there’s a native C++ compiler on windows yeah

#

The OS itself is already compiled and ready to go so there’s no real “need” for a compiler to be natively installed

#

Since 99% of people won’t ever use it

quartz kindle
#

yeah even on linux

#

most linuxes do include stuff like gcc, but you likely still have to install build tools to be able to compile stuff

cloud bough
#

I know someone that coded a discord bot in c#

#

very fast

wheat mesa
#

C# is a lot different than C++ and C

#

C# is like upgraded Java

quartz kindle
#

c# is pretty popular for discord bots

wheat mesa
#

It’s a very good choice for bots

quartz kindle
#

not as much as python and js tho

wheat mesa
#

It’s more in depth though

austere surge
wheat mesa
#

Since C# async/await is a bit more complex than js and py

#

I’d say it’s probably the 4th most popular choice for discord bots, behind js, py, and Java

quartz kindle
#

C# is pretty much the best choice for writing software to run on windows

#

C# + dotnet

wheat mesa
#

Made for Windows by Windows mmulu

#

It’s got all the tooling you’ll ever need for windows software

quartz kindle
#

ever wondered why 90% of games out there require you to install vcredist/dotnet/etc

wheat mesa
#

C# is also a really popular game development language

austere surge
#

unity

wheat mesa
#

Unity uses it, Monogame

#

Stuff like that

austere surge
#

what does UE use

wheat mesa
#

C++

austere surge
#

ok

wheat mesa
#

Most competitive games use mostly C++ for their games due to the performance being critical

#

But indie games in particular are largely made in C#/Unity

#

Stardew Valley was made in a mix of a custom game engine and Unity with C# by one dev

#

Really impressive

quartz kindle
#

theres this chinese indie game that looks dope af

#

also made by 1 guy

wheat mesa
#

Good games that are made singlehandedly never failed to impress me once I figured out how difficult the process was

quartz kindle
#

also, zun

wheat mesa
#

Before I started programming I would probably take a look at stardew valley and be like “That doesn’t look like it’s that hard”, but now I realize the amount of depth, complexity, and thought that was put into that game to make it a masterpiece

quartz kindle
#

all hail zun

wheat mesa
#

lol

quartz kindle
#

yeah, cant talk about this without mentioning him

#

dude made an entire game series with 10+ games by himself

austere surge
#

wow

wheat mesa
#

That’s insane

quartz kindle
#

and composed all the music by himself as well

wheat mesa
#

The amount of time that takes is crazy

#

I can barely center a div in under two hours

marble juniper
#

And what about undertale

#

lol

#

Wasn't that also made by mainly a single guy

wheat mesa
#

I think so

#

I believe all the development was done by one guy

quartz kindle
#

Since 1995,[1][2] the team's member, Jun'ya "ZUN" Ōta, has independently developed programming, graphics, writing, and music for the series, self-publishing 18 mainline games and five spin-offs as of May 2021

wheat mesa
#

I think it was 3 people, one dev, one music, one art

austere surge
#

18 wow

wheat mesa
#

But I could be wrong

quartz kindle
#

asians are something else

#

they have a ridiculous work ethic

wheat mesa
#

Oh nevermind it was just Toby Fox in the beginning of undertale

quartz kindle
#

while the west is busy partying and drinking, asians are working on their dreams and goals 24/7 for decades nonstop

wheat mesa
#

Yup

#

There’s big cultural differences between western culture and Asian culture that contribute to things like that

#

Anyways though, I’m gonna catch some sleep before I have to wake up in 5 hours. Thanks for the conversation, it was really interesting

quartz kindle
#

same

#

its 3am lel

#

kthxbye

earnest phoenix
#

if user want to execute warn command what's the permission required? MANAGE_MESSAGES or MODERATE_MEMBERS?

rocky hearth
#

I want to make some contribution for a github public repo.
I directly cloned that repo, without forking it first.
Now I had already made many changes.
But cant push it.
What do i do?

#

Is it possible to fork it now, and change the remote on my machine?

civic scroll
civic scroll
#

you can try role-based action commands

woeful pike
earnest phoenix
#

Hi guys,

I need a bot which assign automatically a role by holding specific tokens in BSC

spark flint
#

called Grape

earnest phoenix
bright hornet
#

How do i get the message.URL of the embed and post it to MessageEmbed?

.setDescription(`Your suggestion posted in **[Suggestion Channel](${msg.url})**`)``` gives me error
```js
Scheme "null" is not supported. Scheme must be one of ('http', 'https').```
spark flint
#

we use it in a server i mod

earnest phoenix
spark flint
#

its the link on the bot shrug

bright hornet
pulsar bone
boreal iron
civic scroll
#

man

atomic kindle
#

Cloudflare ban

pulsar bone
atomic kindle
#

Wait it's 429

#

Rate limited

civic scroll
dry imp
#

or u use replit

civic scroll
#

man literally copied the whole html in F12

civic scroll
dry imp
#

i mean you can always kill 1 troll

atomic kindle
#

Not Replit i guess

split hazel
atomic kindle
#

Context missing.

pulsar bone
dry imp
#

dk

civic scroll
#
assume lib "discord.js"
assume lang js

define async fn onMessage(message: DiscordJSMessage)
    get message.Mentions.Roles.First -> roleId
    await call discordFetch(guildId) -> data
    data.users filter (roles in user has roleId) foreach user:
        call sendMessage(user.name)
civic scroll
#

then skilll issue

#

actually it's pseudocode

dry imp
#

u always give pseudocode

civic scroll
#

lemme fix

split hazel
civic scroll
#

define async function onMessage(message: DiscordMessage)
    get message.Mentions.Roles.First -> roleId
    await call discordFetch(guildId) -> data
    data.users filter (roles in user has roleId) foreach user:
        call sendMessage(user.name)

when command.IsUsed -> call oneMessage(...params)
civic scroll
#

ig they gave up because my code is unintelligible

dry imp
#

the problem of being too smart

spark flint
#

i'm making a login system and I need to be able to lookup users based on their email or username

#

how can i basically combine await accounts.findOne({ email:req.body.email }) and await accounts.findOne({ username:req.body.username }) into one statement?

#

i want to check if **either **the users username or email exists in the db

pearl trail
#

afaik you can do that in one obj,
findOne({email, username})

civic scroll
#

isn't that find both?

split hazel
#

yeah both

civic scroll
#

for each condition

#

wait lemme lookup api docs

pearl trail
#

guess im wrong in understanding her question mmLol

spark flint
#

login page with allow either usernames or emails

pearl trail
#

ah

#

try find instead of findOne

civic scroll
#

yeah that

#

then you can insert both conditions

spark flint
#

alrighty

civic scroll
#

take the latest one

#

but you will have to implement in your language with whichever library you are using

wide widget
#

@everyone anyone help me

#

pls

#

any developer

spark flint
#

@oak cliff -needdev

oak cliff
#

-needdev

gilded plankBOT
#

You seem to be asking for something you don't have experience for or something that hasn't been done yet, but really need for your bot/server.
You can hire developers from Fiverr or Freelancer to code the things you need for your bot/server.

spark flint
#

@wide widget ^

wide widget
#

yess

#

can you fix my error

dry imp
cloud bough
#

Hey, I'm aware that discord is moving to slash commands in april

wide widget
#

python

cloud bough
#

How do you think that they're gonna inforce it? And not break let's say leveling bots in the process

lyric mountain
#

they aren't

#

you either move to slash or get message intent

cloud bough
#

How would you get message intent

lyric mountain
#

by applying to it

#

and btw, they'll refuse if u say it's solely for levelling

wide widget
#

pls help

cloud bough
#

🙃 discord api

lyric mountain
wide widget
#

can you fix my error in python

#

replit

spark flint
#

provide some more info

#

like the code not working

#

and the actual error

lyric mountain
#

no info = no help

wide widget
#

it is music bot like rythm

spark flint
#

ok

#

show the error

lyric mountain
wide widget
#

File "main.py", line 7
for i in range{len{cogs{)]
^
SyntaxError: invalid syntax
îş§

lyric mountain
#

oh god

simple stump
lyric mountain
#

in what kind of mind state did you think { and ( are the same thing?

simple stump
#

Python moment

#

Any lang > Python

lyric mountain
#

range{len{cogs{)]

wide widget
#

can you fix

lyric mountain
#

idk what to say, how did you reach such point?

#

I mean, it wasn't by copying probably

#

your issue is that you mixed ( and {

#

do you know how programming works or is this your first time?

#

@wide widget I won't go and fix it for you, you'll be doing that yourself

marble juniper
#

What is yall favorite programming language

spark flint
#

topggDotRed No language / library wars - anyone involved will be muted.

#

careful

#

we will get topgged

radiant kraken
lyric mountain
spark flint
#

i'll answer anyways

#

i think brainfuck

radiant kraken
spark flint
#

lol

marble juniper
#

Mine is lolcode

#

lol

radiant kraken
#

code

wheat mesa
earnest phoenix
#

Hi, i am looking for a bot verifying NFT holders of BEP 1155 on Binance smart chain (similar to collab.land). Is there an existing solution?

boreal iron
lyric mountain
#

don't think there's a bot for that

#

but you could try using the search bar on top.gg

cloud bough
#

is it possible to transfer an advanced command handler with cooldowns, and all sorts of permission checks like botInVC and isEnabled

#

to slash commands

#

and is there any reasonable resources where I can learn more on implementing them, because it seems very very different

#

needing to build a slash command like an embed

boreal iron
#

Well the handling of slash command responses isn't different, at least code wise
You just need to use the proper methods and need to add slash command registration/removal to your handler

cloud bough
#

if your bots offline does it still show the commands in chat

#

when you type /

boreal iron
#

Of course, that's why you register them

cloud bough
#

oh god

#

so before it shuts down I should remove them

boreal iron
#

They will fail if you don't respond properly

boreal iron
#

Deploying global slash commands can take up to an hour or more to be pushed to all guilds

cloud bough
#

oh god

boreal iron
#

There's no need to remove them

cloud bough
#

what if you remove the command all together

#

should I make a command like /remove global command "play"

#

or something

boreal iron
#

If you have the bot scope (an active gateway connection) your app will be shown as offline and users will receive a "interaction failed, didn't respond" eroor

cloud bough
#

discord just had to make this change

#

this gonna make lots of ppl stop coding bots lmao

boreal iron
#

Nope, this is actually way better than a gateway connection

cloud bough
#

Yeah im not really sure about the backend of d.js

#

but I'd assume the gateway connection is where the heartbeat is

boreal iron
#

It's a websocket connection to Discords gateway

#

permanently

cloud bough
#

so they're completely shutting down the gateway

#

actually nvm they're using intents

boreal iron
#

Interaction (like slash commands) will actually send a request to your endpoint, don't require a gateway connection, either you answer to the request or not (interaction failed)

cloud bough
#

okay

boreal iron
#

You can still use the scope bot

#

and/or application-commands

cloud bough
#

so a command like /add global command "name" and /rem global command "name"

#

is a must

#

for stuff like that

boreal iron
#

I don't see any sense

cloud bough
#

what if you add more guilds

boreal iron
#

You register the commands in your code once

#

They are deployed after anywhere

#

At any time

cloud bough
#

yes, but if your in the middle of coding something

boreal iron
#

Until you remove them again

cloud bough
#

and you decided to delete lets say an 8ball command from your code

#

Im sorry im trying to wrap my head around these new methods

boreal iron
#

You can deploy guild commands (only available in a guild of your choice) to develop and test commands, then deploy them globally

cloud bough
#

okay

#

and if you end up not needing them I guess eval to remove it globally

boreal iron
#

When using common commands in modules you can also add properties let's say to deploy a command in one guild

#

If you don't need a command anymore you delete it, yes

cloud bough
#

okay

boreal iron
#

That's instant

#

On any guild

cloud bough
#

so basically just like a regular command handler, but you also want to load the commands one time

like:

cmds.map((cmd) => {
  build slash command here
});```
boreal iron
#

An example:

#

This would only be deployed to guild X

#

Requiring permissions Y

#

My command handler will register them once the bots start OR update (if needed) if they are already registered

cloud bough
#

so like in the ready event

boreal iron
#

Once guilds are null in my case, the command will be deployed globally

cloud bough
#

okay thats cool

boreal iron
#

Only after that you have access to all guild objects

#

Also to guild commands etc.

cloud bough
#

okay im starting to understand abit more now

boreal iron
#

But as I said you don't necessary need a gateway connection

#

You could also register them once

#

manually

cloud bough
#

oooof

boreal iron
#

No gateway connection, no ready event, nothing

cloud bough
#

nop

#

too different

#

ima stick with the gateway

waxen cloak
#

my bot invite links are showing "Invalid Permission(s) provided" but I have not changed anything can someone please help

boreal iron
#

Yeah that's no must

#

You can still use the normal gateway connection and application.command scope

cloud bough
#

okay

#

do you know the new event for slash commands?

#

isn't it interactionCreate or something

boreal iron
#

interactionCreate

#

Yeah

cloud bough
#

okay cool

#

and im guessing arguments and stuff work the same

cloud bough
#

like interaction.author, interaction.content

#

okay

boreal iron
#

Yeah lots of properties messages come with are also available for interactions

#

author actually isn't one

cloud bough
#

its interaction.user

boreal iron
#

Aye

cloud bough
#

okay thank you for the help

boreal iron
#

np

cloud bough
#

ima make a small bot with a test command handler

boreal iron
#

wait until it comes to how to reply interactions and/or defer responses

cloud bough
#

😂 ik

boreal iron
#

You will need to watch a few examples here and read the docs to get into them accurate

cloud bough
#

I read some and

#

it looks bad

boreal iron
#

And play around a little bit with guild slash commands

#

you register on your test guild

#

btw. registering guild commands are instant available

cloud bough
#

oooh cool

#

so my bots official server can have beta commands early

boreal iron
#

As that's mostly a testing purpose use case

#

Yeah

cloud bough
#

okay thank you

boreal iron
#

np have fun lmao

#

Once you got into them you wont go back

cloud bough
boreal iron
#

also true, yeah

neat ingot
#

any yall do freelance work on any site like fiverr/upwork/flexiple ? Wondering what like the experience is for the developer 🙂

lyric mountain
#

from what I heard, terrible

neat ingot
#

yea, but bad news travels quicker than good, so folks always hear about the bad stuff first 😛

#

i too find lots of negative reviews on such services

lyric mountain
#

I believe the issue comes not from the platform, but from having to interact with customers

earnest phoenix
spark flint
#

@oak cliff -needdev pls

#

:))

neat ingot
#

~ is currently seeing freelance work ~ if your paying feel free to dm me details on your request lol

oak cliff
#

this isn't a place to find developers or advertise yourself as a developer

#

please refrain from doing so

neat ingot
#

lol sorries, wasnt purposely trying to advertise 🙂

quartz kindle
#

never got a single job from there

cinder patio
#

Market is oversaturated for bots at least

woeful pike
#

every job I've ever had came from connections. I recommend just reaching out on discord in servers that allow it

neat ingot
#

yea, thats fair. most of the jobs i've got has been through word of mouth etc

neat ingot