#development

1 messages · Page 674 of 1

peak quail
#
 message.guild.fetchMembers().then(async (col) => {
      for (item of col) {
      await sleep(1000)
      console.log(item)
      }
      })

      function sleep(ms) {
      return new Promise(resolve => setTimeout(function(){resolve()}, ms))
      }

TypeError: col is not iterable

split hazel
#

I found that that my issue above was an issue with the d.js lib

#

it's getting fixed apparently

maiden mauve
#

@peak quail did you log col to see if its what you want?

peak quail
#

i just want to log the message.guild.members

maiden mauve
#
const col = await message.guild.fetchMembers();
for(let item in col) {

}
#

try it like that

#

unless you intentionally want to use "of"

quartz kindle
#

it returns the guild, not the collection of members

maiden mauve
#

I wonder if they intentionally made it alittle obscure to obtain a list of user objects

quartz kindle
#

i dont think they do

maiden mauve
#

it's a very frequently asked question in here

quartz kindle
#

its just that d.js relies on caches, so the function serves to fill up the guild cache

#

they changed it in master though, there you can fetch members as a collection and optionally not cache them

maiden mauve
#

Was "Master" a recent release?

quartz kindle
#

no, its been in ongoing development for years

maiden mauve
#

ah just heard people talking about it lately

quartz kindle
#

its more mature for general use now, so many people are switching over

earnest phoenix
#

Umm hello?

maiden mauve
#

Umm

earnest phoenix
#

Hi?....

patent prism
#

Sup

lusty dew
mossy vine
#

if a bot cannot send a message to a user, will the response be a 403?

vestal dust
#

Hello, I want to send messages to certain channels on all servers at the same time with my bot. What is the definition of this?

quartz kindle
#

the definition is spam and api abuse

steel cloak
#

Im trying to have the bot check to see if it has the permission 'manage webhooks' from a message event. this should work right? (discord.js)
if(!message.guild.me.hasPermission(['MANAGE_WEBHOOKS'])) return message.channel.send('I need the `Manage Webhooks` permission to run this command');

mossy vine
#

i dont think you can pass an array to .hasPermission

steel cloak
#

so just send it as a string?

mossy vine
#

oh wait nevermind

#

you actually can pass an array

#

uh yeah

#

that should be right

steel cloak
#

oh okay thanks. I was just asking cause when testing it, it didn't seem to work for when i gave it permission. it just kept saying it didnt have it even though it did

lusty dew
#

Anyone know anything about lavalink?

earnest phoenix
#

What is that

#

Is there a way to remove a specific role from everyone in the guild?

#

Yep but, add a cooldown

#

You can get api banned

#

For that

#

Oh

#

@earnest phoenix look the .forEach properties in the .guild object

#

Ok thank you

#

It's in js? @earnest phoenix

#

Yes

#

Okay so, you need to forEach all member in the guild and then forEach all roles

#

I can give you a simple exemple

#

Yes please

devout flicker
#

is it just me or why is my token always invalid

earnest phoenix
#

message.guild.members.forEach(m => console.log(m.id)) display all members id

#

Ok ty

quartz kindle
#

@devout flicker are you using d.js master?

devout flicker
#

no

quartz kindle
#

then idk

#

master had a problem logging in because of a discord update

devout flicker
#

oof

earnest phoenix
#

@devout flicker contact discord

#

maybe your bot got banned

#

if the token always regen

devout flicker
#

ye was my guess but ill check my dependencies again

amber fractal
#

Update d.js anyways. The new changes to the api made tokens invalid on d.js master, which you said you werent on, but maybe you installed the wrong version.

devout flicker
#

ye already updating dependencies

earnest phoenix
#

hi so

#

i try to run my discord bot on a raspberry where i hosted my old one and get this

#

and i tried everything and nothing works

twilit rapids
#

Update node.js

#

to v10 at least

worthy adder
#

Hi

#

Someone give me rainbow 🌈 code

twilit rapids
#

Rainbow code

#

what

worthy adder
#

For make a bot in my discord

#

Server

onyx summit
#

and what is rainbow code

twilit rapids
#

What. Is. Rainbow. Code.

unique nimbus
#

Describe it

#

What does it do?

twilit rapids
onyx summit
#

if you want code that makes your role go rainbow hecc off

twilit rapids
#

They are against ToS anyway

worthy adder
#

I dont know just i always want create a new bot in my server and give it rain bow role

onyx summit
#

cool, rainbow roles are not allowed

quartz kindle
#

you can make it change color like once every 10 seconds, thats good enough

unique nimbus
#

Tim its literally against TOS

worthy adder
#

Oh thanks

#

Good answer

onyx summit
#

His problem

unique nimbus
#

none its against TOS

valid frigate
#

lmfao what the fuck

#

what happened to twitters design

onyx summit
#

sure there are ratelimits for changing a role

#

Sure

#

Go for it

worthy adder
#

I need a program for my bot

unique nimbus
#

then it wouldn't really be rainbow however I honestly dont know how far it goes

valid frigate
#

yeah

worthy adder
#

IOS

#

The app codeanywere is not working

unique nimbus
#

You need to code on PC

valid frigate
#

why codeanywhere tho

unique nimbus
#

Android/IOS isnt supported

valid frigate
#

i used to use them but they are terrible

onyx summit
#

Yes it is, but it's cancer

#

At least android

valid frigate
#

you can code anywhere but at a cost

worthy adder
#

But it is supported in my frind phone

onyx summit
#

cool

loud salmon
#

we dont spoon feed here

#

friendly reminder

#

@worthy adder this

onyx summit
#

And we don't explain how to open a text editor mmm

worthy adder
twilit rapids
#

why do you even deserve to exist

onyx summit
#

A dude on my server uses Code-Server

#

In iPad browser

#

To edit his code

worthy adder
#

Just (notes) right?

twilit rapids
#

I use Terminal to edit code dab

onyx summit
#

Use nano

loud salmon
#

@worthy adder Don't code on a phone. We won't help you if you do this

#

@twilit rapids use sublime u nerd, vim is of the past /s

worthy adder
#

There is a code in a app like node.js and so many codes

twilit rapids
#

I use VSCode don't worry

loud salmon
#

yes we know

#

all of those are bad

onyx summit
#

cool, then use it, we don't care

worthy adder
#

Ok 👍

twilit rapids
#

You're still qt though

loud salmon
#

and dont help you code

onyx summit
#

Use Google keep

worthy adder
#

So what i doing know

loud salmon
onyx summit
#

use Google calendar

loud salmon
#

learn how to code there

#

oi

#

@earnest phoenix @onyx summit both of you aren't helping

worthy adder
#

Yep

onyx summit
#

Yes, that's the point, tbh I don't want to explain someone how to edit files

worthy adder
#

Yes

#

I do

loud salmon
#

then dont shitpost here please

#

yea coding on an iphone isnt good

onyx summit
#

I wanted to have a normal conversation, but someone is discussing how to edit files on ios

#

Anyway, good luck

worthy adder
#

In my pc i have (visual stodio)

twilit rapids
worthy adder
#

Ok thanks

quartz kindle
#

i use sublime lol

twilit rapids
#

my

#

eyes

#

pls

worthy adder
#

Yes

marble juniper
#

ok

tranquil drum
#

server-side js DansGame

split hazel
#

Why does setInterval sometimes completely stop working and stops the interval on its own

#

And our bot relies 101% fully on intervals

#

And loops

quartz kindle
#

it shouldnt stop on its own unless it crashes

split hazel
#

I'll give a small overview, we have an interval that loops over around 500 elements with foreach every 5 seconds that gets data from db and does stuff only if it matches specific criteria (which only a few elements will at the time) sometimes, people say that it just stops and the bot no longer seems to fulfil the interval.

#

A restart fixes it as it restarts the interval but constant restarts aren't in my favour

abstract crow
#

What is a good issue tracker? I want one publicly for my github repo, but I want the content to be private

tidal parrot
#

@split hazel what version of node

split hazel
#

12 @tidal parrot

tidal parrot
#

show me the interval code?

abstract crow
#

Is there any way, that I can get a GUI for an Ubuntu Linux Machine I have on a VPS?

frail holly
#

Anyone have a trick to PreProcess messages before they're sent and cancel the event?

#

Example, specific spam auto deleted will make the chat flash as its visible then deleted a moment after

lofty hamlet
#

Hi

earnest phoenix
#

codyToday at 1:39 AM
Anyone have a trick to PreProcess messages before they're sent and cancel the event?
Example, specific spam auto deleted will make the chat flash as its visible then deleted a moment after
you can't intercept events

amber fractal
#

Edit the source code of the lib mmulu

#

jk dont do that, it makes literally no difference

fervent pilot
#

does anyone use heroku here

earnest phoenix
#

don't

fervent pilot
#

@earnest phoenix do you know how to create a git repository

earnest phoenix
#

use git CLI

gritty bolt
#

catch (err) { catchError(err, message) why is catch an unexpected token?

abstract crow
#

Ok well we need more information, like what you are trying to do here

#

And what language(assuming js)

gritty bolt
#

im doing a try {}

#

in javascript

#

node

abstract crow
#

So a try and catch correct?

#

If so show us the whole try and catch

valid frigate
#

you didn't close your try correctly

abstract crow
#

That is what I was thinking

gritty bolt
#

how?

abstract crow
#

Idk

earnest phoenix
#

you tell us

abstract crow
#

You need to show us more code??

#

I have no clue how you ended it

gritty bolt
#
//code here
}
catch (err) {
        catchError(err, message)
}``` 
catcherror is a function
valid frigate
#

that's correct syntax wtf? MegaThonk

abstract crow
#

Showing code here doesn't help us, because you just typed that that try and catch manually

#

COPY from your code directly

#

Because in your code you messed up

gritty bolt
#

the entire thing of code?

#

ok

abstract crow
#

And by you manually typing a correct try and catch statement doesn't help us

valid frigate
#

if you can lo

gritty bolt
#

please dont make fun of me for my error embeds im trying to reorganize them lol

earnest phoenix
#

sending it here clutters it and makes it unreadable

gritty bolt
#

trying one last thing

#

oh my goodness it worked

#

nevermind

#

the issue was something with the order of the }s

abstract crow
#

Seeeee

gritty bolt
#

i tried sooo much

#

and i didnt think of that

earnest phoenix
#

Who knows how to verify if he/she has DM's messages from a server activated?

amber fractal
#

You cant... Unless you attempt to dm them

#

Then you get an error

#

in d.js*

west spoke
#

you will get a http error if you are making raw http requests

amber fractal
#

The libs make raw http requests...

earnest phoenix
#

I cant change the color of html5 elements in my detailed description!

#

Asking for help!

opaque eagle
#

!important

earnest phoenix
#

..

opaque eagle
#
h1 {
    color: #00FF00 !important;
}```
earnest phoenix
#

thank you

tight heath
quartz kindle
#

i mean, you can simply learn about css specificity instead of abusing !important

midnight vine
cursive dagger
unique nimbus
#

I can see one problem which might ot actually be a problem

midnight vine
#

It's weird

#

@cursive dagger you see an error ?

cursive dagger
#

Yes i do, Its basic python problems. As i said, learn python before getting into discord.py

unique nimbus
#

yes

midnight vine
#

I know python

#

a few days ago everything worked fine, now no more of them works

cursive dagger
#

You have done a lot of beginner mistakes in your code

#

if you know python, fix them up

lusty dew
#

Does anyone know a good guide for better-sqlite3

quartz kindle
#

the only guide specific for better-sqlite3 is their docs lol

#

unless you need help with sqlite itself, then there are plenty of sqlite guides

#

better-sqlite3 is a wrapper for sqlite, so you should probably tackle it like this:

  1. how do i do x in sqlite? read sqlite guides.
  2. ah ok i figured it out, now how do it adapt it to use better-sqlite3? read the docs
lusty dew
#

Okay

#

Thx

split hazel
#

Would around 600 intervals running congruently impact performance?

#

I'm looking to rewrite my giveaway bot timer

#

Well not just timer

#

Because 1 interval doing everything proved to not be very helpful

pallid zinc
#

.addField("TIC_TAC_TOE", q + w + e, r + t + y)

#

cant i do this

split hazel
#

@pallid zinc I think you put an accidental comma after e which should be a +

#

Assuming all values are defined

#

And not supposed to be string

pallid zinc
#

they are defined

#

i want something like this

#

1⃣2⃣3⃣
4⃣5⃣6⃣
7⃣8⃣9⃣

earnest phoenix
#

lmao

split hazel
#

You know you can put it all in one string right

pallid zinc
#

lol

#

wait

split hazel
#

And save the hassle of like 10 values

pallid zinc
#

i cant do it in pc

split hazel
#

You can do something like
let numbers = "1⃣2⃣3⃣4⃣5⃣6⃣7⃣8⃣9⃣";

pallid zinc
#

done

#

.addField("TIC_TAC_TOE", q + w + e, r + t + y)
cant i do this

split hazel
#

Yes but you're wasting time adding every number via variable when you can just add it to the code like
;one;

#

Which is 1⃣

pallid zinc
#

trying to make tic tac toe command

#

so it wound be easy to edit if i do some think like this

#

just tell the answer

#

and leave everythink on me

#

i got my ans so thanks for doing nothing

late hill
#

The only thing you were missing was "\n" ? 😂

pallid zinc
#

u are right

#

but how u know

slender thistle
#

Because it's a new line

#

And TTT has more than one line

pallid zinc
#

lol

pallid zinc
#
message.channel.send(`**TIC_TAC_TOE** \n ${q} ${w} ${e} \n ${r} ${t} ${y} \n ${u} ${i} ${o}`)```
how can i only edit ${q}
any way?
late hill
#

It only lets you edit the entire thing

#

So just do the full thing again with an updated q

pallid zinc
#

lol

#

so if i edit ${w} it will make ${q} again one

late hill
#

You're making tic tac toe

#

Which I don't think is extremely complex

#

But I'd suggest creating a class for it

#

You could nest arrays to recreate the playing field

#

Put some functions in your class that convert the playing field to a string value

#

aka a toString() method

#

It would be nice and structured to have all of that in 1 simple class that you can then reference from anywhere in your code

#

A 2D array if you've ever done that

pallid zinc
#

if(message.content === "1"){ q = e}else{q = "1⃣"}

late hill
#
let playingField = [
    ["X", "X", "X"],
    ["X", "X", "X"],
    ["X", "X", "X"]
]```
#

Like that

#

You specify a variable for each field

#

Not necessary

#

Using my playingField structure above you simply use playingFIeld[y][x]

pallid zinc
#

ok

#

let me try

#

i dont have any idea

#

of your structure

late hill
#

oof

pallid zinc
#

lol

upbeat echo
#

guys i need help i want to add bots to my server but i cant seem to get it done can anyone help me?

late hill
#

Say you have this:
0⃣1⃣2⃣three:
1⃣🇦🇨
2⃣🇩🇪🇫
3⃣🇬🇭🇮

#

oof that

#

lol

pallid zinc
#

lol

late hill
#

discord is retarded

pallid zinc
#

lol

#

1⃣ 2⃣ 3⃣
4⃣ 5⃣ 6⃣
7⃣ 8⃣ 9⃣

late hill
#

ok so

#

Say you have this:
Blank 0⃣ 1⃣ 2⃣
0⃣ 🇦 🇧 🇨
1⃣ 🇩 🇪 🇫
2⃣ 🇬 🇭 🇮

pallid zinc
#

ok

late hill
#

with the A-I being your playfield

pallid zinc
#

ok

late hill
#

If you used the 2D array as shown above

#

wait

#

ok

#

You'd access A using playingField[0][0]

#

B would be playingField[0][1]

pallid zinc
#

ok

late hill
#

F would be playingField[1][2]

#

You understand?

pallid zinc
#

yup

late hill
#

That way you don't need 9 variables

pallid zinc
#

ok

late hill
#

Or possibly even more when coding a game with more fields

pallid zinc
#

let me try

#

thanks a lot

#

it made my work easy

pallid zinc
#

but

#

string.edit() dont exists

dusky mist
#

How can i do that the bot send achievements with the say command? Without using links

#

Its possible?

earnest phoenix
#

which library

dusky mist
#

Discord.js

earnest phoenix
#

see the example for sending an attachment

#

i cant fix this thing since yesterday, i wont complicate

#

if you made .forEach loop

#

how would you stop it? (discordjs)

quartz kindle
#

you cant, not in an easy way at least

#

forEach creates a function on each iteration, so with 10 items, forEach will create 10 functions. returning will return that individual function only

earnest phoenix
#

whenever i try to stop it with return, it will just spam messages

#

i cant find anything online

quartz kindle
#

you need either an external control, or change it into a different type of iteration

earnest phoenix
#

any suggestion?

#

if i make it as another function can i just break it somehow

quartz kindle
#

you can use break/continue in a normal for loop for example

#

or you can use an external control variable, such as js let loop = true; something.forEach(t => { if(!loop) return; })

#

and then set the loop to false from inside

#

also depends on what exactly you're trying to do

earnest phoenix
#

tnx bruh, i'll try it

#

im trying to give all members a role

#

but cant stop on loop on error

quartz kindle
#

you can also use try/catch and throw an error

#
try{
    something.forEach(t => {
        throw "error"
    })
}catch(e){
}```
that should also stop the loop
earnest phoenix
#

i tried exact asme thing

#

but outside of loop damn

#

it worked lol

#

thanks

opaque eagle
#

A forEach()... I'll be damned

Better solution:js for (const t of something) { if (thing) break; // stops that iteration of the loop }
And also, depending on your circumstances, it might not be required for you to loop at all, you might be better off using smth like Array.map(), Array.filter(), Array.find(), or Array.reduce() which do it for you

quartz kindle
#

he wants to add roles using a loop, so those functions would not suit his use case

#

unless he needs to return the role objects afterwards

slender thistle
#

future reference!

opaque eagle
#
const role = "that role";
const addRole = member => member.roles.add(role);

const roleObjectsForSomeReasonEvenThoughWeAlreadyDefinedIt = await Promise.all(guild.members.map(addRole));```
abstract crow
#

So in Discord.JS I need to split the args so that anything after args[1] becomes a sentence. Because I slice args and then it goes like this
{"word1", "word2"}, but I just want it in a sentence. How can I do that?

inner jewel
#

Array#join

abstract crow
#

Gotcha. Thanks!

earnest phoenix
#

So, what do you people use with your bots?

#

I use discord.js

#

how old are you @earnest phoenix ;d

#

16? Why, uhhhmm, do you ask?

lusty dew
earnest phoenix
#

Right, moving to off-topic

opaque eagle
#

I use Eris on js... i've also used dgo, serenity, drb, and sword in the past

lusty dew
#

I tried using Eros

#

Eris *

#

I don’t like it that much

opaque eagle
#

It's certainly not beginner-friendly

#

You won't like it unless you're pretty good with writing code.

#

Personally, i prefer Eris over Discord.js, just because imo, Discord.js is bloated

#

D.js holds your hand through every little thing and makes everything "easier", while Eris is a lot more barebones

lusty dew
#

Yea

opaque eagle
#

That's what I hate about D.js

lusty dew
#

Took me 3days to figure out how to send messages lel

opaque eagle
#

lmao

lusty dew
#

Then I realized why not check the docs there is probably an example

topaz fjord
#

it holds your hand but the mem usage is great mmLol

#

that's a joke

#

Mem usage is shit

opaque eagle
#

^

#

client.createMessage() in Eris

lusty dew
#

I heard Eris has better mem usage

opaque eagle
#

Yes

#

Like I said it's very barebones

amber fractal
#

Get 👏 off 👏 stable 👏

opaque eagle
#

p sure d.js uses some internal caching server and all

#

very bloated

lusty dew
#

Iirc d.js caches everything

amber fractal
#

@lusty dew client options

lusty dew
#

I may try and make a bot in Eris again

amber fractal
#

You have the ability to control it

lusty dew
#

Last time didn’t go so well

#

Tried recreating one of my older bots with Eris

#

Lel

opaque eagle
#

Do you see any major bots using D.js? All of the top-tier ultra popular bots use Eris

#

That's my D.js patriot card

lusty dew
#

As far as I got was mute and ban

#

And kick

topaz fjord
#

or they use cooler libs mmLol

lusty dew
#

Python is eh C# fuck that

topaz fjord
lusty dew
#

Java was kinda easy in the beginning but then I started to get confused

#

So I just gave up on it

topaz fjord
#

lmao

lusty dew
#

Wanna try and learn Java fully though

opaque eagle
#

Dyno, Tatsumaki, Dank Memer, Pokecord, BoxBot, Pancake, Idle Miner, Zira

amber fractal
#

Java has worse cpu usage than js

opaque eagle
#

All the major bots either use Eris or anything but d,js

topaz fjord
#

it doesn't

#

my CPU usage is fine

amber fractal
#

Java eats

topaz fjord
#

and I didn't do shit to mine

opaque eagle
#

I hate Java

lusty dew
#

Well my bot is gonna stick with d.js lel

topaz fjord
#

Just wrote the code and hoped it wotked

opaque eagle
#

Writing Java code is so redundant

topaz fjord
#

I didn't optimize for mine

#

I could but I'm lazy

amber fractal
#

Typed lang bad 👎

opaque eagle
#

It's overall really terrible as far as the developer's experience and required-hassle is concerned

amber fractal
opaque eagle
#

Typed lang good

#

Java specifically bad

topaz fjord
#

I prefer typed langs

amber fractal
#

I dont like typed langs

opaque eagle
#

why

#

typed langs are godly

topaz fjord
#

I don't see how java is a hassle

opaque eagle
#

writing java code is really redundant

topaz fjord
#

but I don't use java so I wouldn't know that much

#

Kotlin gang

#

I feel like kotlin gets rid of that redundancy

amber fractal
#

Whats the point of defining a type? All the benefit I see is that it allows you to know what a variable is by glancing over code if it's not actually defined.

opaque eagle
#

kotlin is fine

lusty dew
#

Has anyone tried making a bot in scratch

#

Lmao

opaque eagle
#

what's scratch

amber fractal
#

Smh

lusty dew
#

👀

topaz fjord
#

mit programming language

amber fractal
opaque eagle
#

that looks like its for kids

topaz fjord
#

It's for the script kiddies who think they're gonna make it big

lusty dew
#

It’s a beginner coding Lang

#

Drag and drop

opaque eagle
#

lol that's not a coding lang

lusty dew
#

Iirc it’s made using js

opaque eagle
#

that's a tchotchke

amber fractal
#

@lusty dew no, they dont allow http calls

#

I actually went to their wiki

lusty dew
#

Hmph

topaz fjord
#

I don't like block coding languages

lusty dew
#

What if you optimized it to allow http calls

topaz fjord
#

they don't let you feel how actual coding is gonna be

opaque eagle
#

those aren't coding languages

lusty dew
#

IKR

#

I took a coding club

opaque eagle
#

coding club

#

sounds like the lamest thing ever

lusty dew
#

As soon as I heard we were gonna be using scratch I got up and walked out

topaz fjord
#

Watch those who use scratch thing java, js, etc. Is just drag and drop

#

I would literally just end myself

amber fractal
#

ArrayList<Integer> arr = new ArrayList<Integer>(); doesnt this seem redundant?

opaque eagle
#

it does

#

that's why java sucks

#

but other typed languages r actually good

#

like go, rust, ts

amber fractal
#

Idk I've used C# and Java didnt like either

opaque eagle
#

Strong-typing is really useful

lusty dew
#

What’s the easiest Lang to learn

mossy vine
#

probably javascript

opaque eagle
#

that depends

lusty dew
#

In your opinion

amber fractal
#

I just dont see the benefit to define a type

opaque eagle
#

on what u know already

hoary helm
#

i would say lua

mossy vine
#

syntax is simple, and as its the most popular language there are so many awesome guides out there

opaque eagle
#

defining types isn't useful for every scenario @amber fractal

lusty dew
#

Lua was so fucking gay

amber fractal
#

Lua is rarely used anymore

#

Atleast, I dont see it

hoary helm
#

cough
discordia
cough

amber fractal
#

Outside of roblox and gmod

mossy vine
#

i only see lua used for game modding

opaque eagle
#

What language(s) do u know already? That helps in defining what "easy" means to u @lusty dew

hoary helm
#

there are some lua libraries for discord bots

lusty dew
#

I know a little js but not enough to be considered an expert

#

I know some lua but it was boring so I stopped

#

Not many uses for lua

topaz fjord
#

I don't see that as redundant

opaque eagle
#

I'd consider learning more JS first @lusty dew

topaz fjord
#

it make sure you strictly follow the type you defined

opaque eagle
#

before trying to learn other langs

#

knowing one language really well is better than knowing how to do hello world in 10

amber fractal
#

A string isnt gonna get in your array in js unless you put it in there.

opaque eagle
#

Why do u hate strong typing so much

lusty dew
#

Lol

opaque eagle
#

It's so useful

topaz fjord
#

and afaik you can leave out the <> when actually creating the array list

amber fractal
#

Thats what my problem with typing is, programatically you know what the variable is.

opaque eagle
#
/*
 * @param {number} a
 * @param {string} b
 * @returns {string}
*/
function thing(a, b) {
    return a + b;
}``````ts
function thing(a: number, b: string): string {
   return a + b;
}```
#

Which one would u rather write

amber fractal
#

const x = 5
public static final int x = 5

mossy vine
#

honestly, i would stay with the first

amber fractal
#

First

topaz fjord
#

I like the private public and protected in java

#

I would rather do the second

#

For both

mossy vine
#

in the first one you obviously know whats code and whats documentation. second one takes longer to read and can be confusing

topaz fjord
#

How is it confusing

amber fractal
#

You know what you're passing into the function anyways.

mossy vine
#

^

amber fractal
#

So why does the type matter

mossy vine
#

type checking is 1-2 lines anyways

topaz fjord
#

The second one is the easiest one to read

opaque eagle
#

Static types can ease the mental burden of writing programs, by automatically tracking information the I would otherwise have to track mentally.

topaz fjord
#

without jsdoc you can still pass in what you want if you don't do proper checks

opaque eagle
#

I don't have to remember that a function takes such and such types and returns smth, becuz the code keeps track of it for me

mossy vine
#

thats why jsdoc is a thing

opaque eagle
#

and I can infer that in any point of my code using my ide's suggestions

topaz fjord
#

but you're not gonna put jsdoc on your own bot

opaque eagle
#

^

topaz fjord
#

there's literally no point

amber fractal
#

The first function actually can do more than the second, because it doesnt have ttpes

opaque eagle
#

jsdoc is designed for documentation first

topaz fjord
#

unless your releasing the code

amber fractal
#

You can add whatever you want, not just a number and string

opaque eagle
#

but each function should have a specific purpose @amber fractal

mossy vine
#

then make it obvious from the function name?

opaque eagle
#

your code should be beautiful as well as functional

#

do exactly one thing

mossy vine
#

addNumbers(1, 2)
addStrings('a', 'b')

opaque eagle
#

@mossy vine I'm talking about when Steven said

The first function actually can do more than the second, because it doesnt have ttpes

amber fractal
#

So I should have

return a + b
}``` and
```function thing2(a, b){
return a + b
}``` ?
#

Because the top one is for numbers

#

And the bottom is for strings

topaz fjord
#

in some languages yes

opaque eagle
#

doesn't make sense in such a niche scenario

amber fractal
#

Oh wait they do the same thing

topaz fjord
#

they don't do the same thing

#

one adds numbers

opaque eagle
#

but i used adding as an example for more complex tasks that functions r used for

topaz fjord
#

One adds strings

#

those are two different things

amber fractal
#

@topaz fjord the code is literally the same

#

That was the point

#

The second function is redundant

topaz fjord
#

then there's no point in making a function for ot

#

it

#

That's just a waste of time

amber fractal
#

As you can do it with the first

#

Exactly my issue with typing

#

You need seperate functions to do the same thing

topaz fjord
#

How is making a useless function your issue with typing

amber fractal
#

With seperate types

topaz fjord
#

You don't

amber fractal
#

You literally do or it will say that you passed the wrong type

topaz fjord
#

because you can specify the type to be anything in typed languages

amber fractal
#

Not the way I was taught tho

topaz fjord
#

This scenario doesn't even make sense either way

#

no one makes a separate function to add two numbers/strings unless they're stupid

amber fractal
#

I just dont see why int x = 5 is better than let x = 5 you know what x is either way

#

It's an integer

#

The code also knows that

opaque eagle
#

code calculates that at runtime

#

in a dynamically typed language

amber fractal
#

Still would've rather learned python than java for ap cs

#

Useful language

pallid zinc
#

Why

opaque eagle
#

i would've wanted go

amber fractal
#

I'd like to create an AI

topaz fjord
#

java is useful lmao

pallid zinc
#

Python is fast

topaz fjord
#

it's not a language that no one uses

amber fractal
#

I'm aware, still dont like it

#

Learning it was hell

#

The ap test was as dumb as ap tests are

topaz fjord
#

It's used more in companies than anything else

scarlet phoenix
#

For ML applications python has the most fleshed out libs. Id stick to that for ML/AI stuff

amber fractal
#

Python is what Im learning next

scarlet phoenix
#

Well depends on what you mean by ai as thats become so convoluted over the past few years

#

If you want to do some Java stuff I would also reccomend learning some kotlin.

amber fractal
#

Lol no

topaz fjord
#

In probably just gonna learn low level languages from now on

amber fractal
#

That's the opposite of what I want

#

I hate java

topaz fjord
#

Kotlin actually solves some issues you have with java tbh

stray garnet
#
const botconfig = require("../botconfig.json");

module.exports.run = async (bot, message, args) => {
    let lel = args[0];
    if(!lel) return message.channel.send("hehe boi");
    message.mentions.users.first().send(lel)


}
module.exports.help = {
  name: "dm",
  aliases: []
}```

`k/dm @stray garnet Hello`

It sends: `Hello`
                 `@stray garnet`

how to let it only send the `Hello`?
topaz fjord
#

I wanted to learn kotlin, swift, c++ over the sunmer

#

I've only gotten to one

amber fractal
#

Cant make a dm command

#

Violates tos

scarlet phoenix
#

Of the 3, imo Kotlin > Java > Python but I do think python is great for stuff like small scripts.

#

Python just is not that good for larger projects imo

stray garnet
#

@amber fractal What? Why

scarlet phoenix
#

Strongly typed languages are a huge preference of mine

opaque eagle
#

strong-typing is neat

amber fractal
scarlet phoenix
#

At work we have a legacy python monolyth backend (~3 million lines) And it is such a waste of time trying to track down what type every function returns/brings in

amber fractal
#

Allowing users to send dms to other users from the bot would bypass blocking

stray garnet
#

@amber fractal Oh, would it ne allowed to only make it for me?

opaque eagle
#

why would u want to dm random ppl through ur bot out of the blue

topaz fjord
#

^

inner jewel
#

if you're going to complain about syntax that's been outdated for 8 years you're doing it wrong

lusty dew
#

Oof

amber fractal
#

@inner jewel not my fault the college board teaches outdated stuff tho is it?

#

I didnt choose to learn it the way I did, I was forced to.

#

I would've still preferred to not learn java at all

rustic sphinx
west spoke
#

wdym?

rustic sphinx
#

?

#

english

west spoke
#

Yes..

twilit rapids
#

@rustic sphinx give more information please

rustic sphinx
#

you know there are codes that define you to make it easier, for example: let member = message.user.tag

where can i find them i don't know ...

#

a site or github

earnest phoenix
#

they

#

write it yourself??

rustic sphinx
#

but, the discord has a slightly different code than js

earnest phoenix
#

ok

west spoke
#

@rustic sphinx if it's in js it's normal syntax

#

idfk if I spelled that right I'm tired

#

Eg
let userID =message.member.id;

upper salmon
#

someone here use ibmcloud?

tight heath
#

@rustic sphinx https://discord.js.org

#

under documentation

rustic sphinx
#

@tight heath thx

solemn helm
#

How do you make your bot stay on 24/7?

dusky mist
#

@solemn helm u can use glitch

#

Its free

vestal dust
#

ye

solemn helm
#

Really?

vestal dust
#

but 500 mb

dusky mist
#

Yep

solemn helm
#

Please can I have the link?

long blaze
#

or you could get like a cheap £5/month vps and like host the bot off that

solemn helm
#

And I’m to poor for that

long blaze
#

loool fair do's

dusky mist
solemn helm
#

Thank you

vestal dust
#

@dusky mist see dm

long blaze
#

Glitch: The friendly community where everyone builds the web (and hosts discord bots)

solemn helm
#

Tbh I’ve got the bots online and stuff it’s just they ain’t staying on when I turn off my pc

indigo geyser
#

VPS

#

not for poor people (like me)

solemn helm
#

I’m way too poor

indigo geyser
#

@dusky mist but only if you use JS

#

@solemn helm what language your bot is?

solemn helm
#

Wydm?

indigo geyser
#

?

#

The language

dusky mist
#

Js, phyton....

indigo geyser
#

Py... Js... Discordia...

#

Lel

solemn helm
#

Oh

#

Jk

indigo geyser
#

Js?

solemn helm
#

*js

indigo geyser
#

Okkk

#

So you can listen to @dusky mist and use glitch

vestal dust
#

Js my heart ❤

indigo geyser
#

Py mi heart

vestal dust
#

😁

dusky mist
#

I've never seen a py code

#

XD

#

Rlly xD

pale mango
#

Anyone have experience with express api?

quartz kindle
#

kinda

#

if you mean express.js

pale mango
#

Yeah I guess. I'm trying to make an API with express. Do you mind helping me in DM's?

quartz kindle
#

i'd rather help here if you dont mind

lusty dew
#

I have a question about better-sqlite3

#

I saw it told you to name a file in a migrations folder something specific do I have to name it that

pale mango
#

@quartz kindle i can dm you a vsc liveshare we can use.

lusty dew
amber fractal
#

He isnt gonna code it for you

lusty dew
#

Good luck with that

amber fractal
#

That's not how this works

maiden mauve
#

does nodejs keep bot online all the time anyhow?

pale mango
#

I'm not asking him to code it for me. I'm asking him for help.

maiden mauve
#

I've never had an issue with uptime

lusty dew
#

No

maiden mauve
#

and never added anything to project

lusty dew
#

If your pc or whatever shuts down or sleeps the process stops

quartz kindle
#

sorry, i dont help privately for free

pale mango
lusty dew
#

That’s what a vps is for it never goes to sleep so it keeps the command running

#

Tim

#

Question

maiden mauve
#

@pale mango you can always make an earnest attempt to code something then ask for help with syntax

#

so 1 small task at a time

#

nobody really wants to coach someone through something from 0 to 100

lusty dew
#

Tim to make an api would I have to specify the websites I want to scrap let’s say images for

#

Or is there a way to just scrape a specified topic or genre of images across the internet

quartz kindle
#

you have to either scrape or build your own database

#

and scraping requires specific rules for specific websites, so yes, you need to specify websites and rules

#

the closest thing to "scraping across the internet" would be to scrape google images lol

#

or something similar

pale mango
#

blobthinkingeyes Is there a tutorial online for oauth2 callbacks?

quartz kindle
amber fractal
#

Idk, have you used google

#

I feel most of the questions here would be answered faster if someone just put their question in google instead of here.

maiden mauve
#

or played around with a blank sheet compiler

#

that's the nature of a chat room though

#

you just want a response

#

😄

lusty dew
#

I saw it told you to name a file in a migrations folder something specific do I have to name it that

#

When looking at the better-sqlite3 npm page^^

quartz kindle
#

what are you trying to do?

#

you dont need to do anything regarding migrations unless you're specifically migrating a database to/from another db/version

lusty dew
#

Begin my adventures into sqlite3

#

This

quartz kindle
#

oh you're using better-sqlite3-helper

lusty dew
#

No

#

Wait what

#

Bruh I’m dead

#

I thought I was looking at better-sqlite3

#

So how do i create a table with better-sqlite3

#

I’m confused on how to use better-sqlite3 not very descriptive on how to use it st least not me

#

At*

quartz kindle
#
const db = new Database('foobar.db');```
lusty dew
#

Foobar.db?

quartz kindle
#

name it whatever you want

#

thats your database file

#

it will be created if it doesnt exist

lusty dew
#

Ahhh okay

#

So I can just do clap.db

#

?

quartz kindle
#

then you start executing standard sql statements like this:

db.prepare("SQL STATEMENT").run(parameters)```
#

so creating tables for example

#
db.prepare("CREATE TABLE IF NOT EXISTS guilds (id TEXT PRIMARY KEY,channel TEXT,role TEXT,message TEXT,strength INT,sensitive INT);").run();```
lusty dew
#

What does text primary key do

quartz kindle
#

when creating tables, the first value is the column name, the second is the column type

#

the third one can be a specific option, in this case, primary key means this column is the primary key

#

primary keys are unique values which are automatically indexed

lusty dew
#

Sql seems easy in some ways

quartz kindle
#

it is

lusty dew
#

The way it looks to me as if you are saying a sentence

quartz kindle
#

kinda yeah

#

then for example

#

adding values

lusty dew
#

You’d use insert right?

#

Or update

#

Can’t remember

quartz kindle
#
db.prepare("INSERT OR REPLACE INTO users (id) VALUES (?)").run(userid)```
#

or basically just INSERT, not need for REPLACE here

lusty dew
#

Ye

#

Do you need the ()

quartz kindle
#

selecting all users js db.prepare("SELECT * FROM users").all()

#

selecting one user js db.prepare("SELECT * FROM users WHERE id = ?").get(?)

#

the () is for inserting multiple values in multiple columns

lusty dew
#

Ah okay

quartz kindle
#

you can also use named placeholders

lusty dew
#

So basically getting info from multiple columns

quartz kindle
#
db.prepare("SELECT * FROM users WHERE id = @id").get({id:userid})
lusty dew
#

Oh shoot

#

Ima be here a lot asking questions lmao

#

I can already tell

quartz kindle
#

anyway read the api docs and read some sqlite guides

lusty dew
#

But I get it for the most part

quartz kindle
#

nearly all sqlite statements can be done simple by db.prepare().run()

lusty dew
#

I read the docs already

#

Understood some of it

quartz kindle
#

or db.prepare().all()/.get() for retrieving values

lusty dew
#

.get()?

#

Isn’t that what select is for?

#

Didn’t read about get lol

quartz kindle
#

select is the sql statement

#

.get() is the better-sqlite3 function to return the value

lusty dew
#

Ahh okay so basically if you do

#

db.prepare(Select * From users Where id=?).get(userID)

#

Would get the userID

quartz kindle
#

would get all the data from the first row that matched the user id

lusty dew
#

Ah oky

#

So without get() it’s error?

quartz kindle
#

no, without .get its a statement

#

you can store it, execute it later, use it in a transaction, etc

lusty dew
#

Ah mk

quartz kindle
#

you can do things like ```js
let s = db.prepare("INSERT INTO users (id,name,rank) VALUES (?,?,?)");
users.forEach(t => {
s.run(t.id,t.username,0)
})

lusty dew
#

Oh cool you can put placeholders in to put parameters in later?

quartz kindle
#

yes, that is the purpose of creating a prepared statement

lusty dew
#

True

#

Btw when creating a table

#

Should I do it for guilds on join?

#

Like when the bot joins the guild it instantly creates an entry for that guild

quartz kindle
#

you should create tables only once. a typical use case is to write the table creation statements that you need (and carefully plan ahead the columns you will need etc, because sql is a relational database, unlike document-oriented which lets you arbitrarily add fields/keys/columns), run you script once to create them, then remove or comment out those lines

#

then you work with rows

#

add and remove rows for guilds, users, etc

lusty dew
#

Well yea what I mean was

#

Create the table once ofc

#

But when a bot joins a guild should it create an entry to that table on join

quartz kindle
#

that is up to you

lusty dew
#

It wouldn’t cause problems?

quartz kindle
#

you can do it like that, or only do it when the guild actually uses your bot

#

it wont cause problems

lusty dew
#

Which would be the better option

quartz kindle
#

i would go for the second option because im a performance maniac

lusty dew
#

Lol

#

I was gonna do the same for users

quartz kindle
#

only run things when you actually need them

#

i would also cache your most used things

#

for example, save an entry to db and also to an object/map. then when you need it, try to get it from the object/map, if it fails, then get it from db and also add it back to the object/map

#

this is especially important for custom prefixes, so you avoid hitting your database on every single message (which can be hundreds/thousands per second)

lusty dew
#

Could I do all this in a separate file?

#

Instead of in my main file?

quartz kindle
#

yes you can

lusty dew
#

I don’t wanna cloud things

earnest phoenix
#

I just looked at that oauth2 guide, am I missing something? It doesn't run the alert

<script>
    window.onload = () => {
        const fragment = new URLSearchParams(window.location.hash.slice(1));

        if (fragment.has("access_token")) {
            const accessToken = fragment.get("access_token");
            const tokenType = fragment.get("token_type");

            fetch('https://discordapp.com/api/users/@me', {
                headers: {
                    authorization: `${tokenType} ${accessToken}`
                }
            }).then(res => res.json())
            .then(response => {
                const { username, discriminator } = response;
                alert(`Hello, ${username}#${discriminator}!`);
            }).catch(console.error);
        }
    }
</script>
lusty dew
#

I assume I’d make it functions?

quartz kindle
#

@earnest phoenix add a few console.logs along the way to see which parts of the code run successfully

#

@lusty dew thats a option yes

lusty dew
#

I forgot you don’t need to do anything in the ready event for better-sqlite3 do ya?

earnest phoenix
#

it doesnt run the javascript at all 🤔

#

only loads the HTML and CSS

lusty dew
#

@quartz kindle I don’t need to do anything in the ready event do I?

quartz kindle
#

@earnest phoenix did you try console.log(fragment) right after you define it?

#

before the if

#

@lusty dew not necessarily, up to you

earnest phoenix
#

I did a console.log just below the opening script tag and nothing happened

#

So it's not running the script at all

quartz kindle
#

how are you running the html file?

earnest phoenix
#

through an Express application

#
api.get("/dashboard", async (req, res) => {
    res.sendFile(__dirname + "/dashboard/index.html");
});
quartz kindle
#

can you do view-source in your browser?

earnest phoenix
#

you probably shouldn't do anything to do with tokens via front

quartz kindle
#

what if you put the console.log outside the window.load?

#

also what cry said

earnest phoenix
#

nothing happens still

#

Hey anyone can help me?

quartz kindle
#

well actually in this case it should be fine to use the frontend because its the user's token in question

#

not yours

earnest phoenix
#

Error: Socket Hang Up how can i fix this :/

quartz kindle
#

that usually means its a connection issue

#

@earnest phoenix try using express.static

earnest phoenix
quartz kindle
#

lol, well yeah

#

its supposed to only log there

earnest phoenix
#

i know, i meant thats the only logs it sends

#

so apparently fragment doesnt have access_token

quartz kindle
#

whats the url you used?

earnest phoenix
#

my oauth2 URL

quartz kindle
#

with a fragment?

earnest phoenix
quartz kindle
#

it works here

earnest phoenix
#

it shows your tag?

quartz kindle
#

shows an empty dashboard

earnest phoenix
#

thats what i get too, but it should be showing a popup with your tag

quartz kindle
#

hmm let me check

lusty dew
#

Also ur inv to the support server is expired

#

Lol

earnest phoenix
#

mine? works for me

lusty dew
#

Not me smh

earnest phoenix
#

wait you're right, tf

lusty dew
#

Told ya

#

Lel

earnest phoenix
#

oh its cause i deleted the channel L

lusty dew
#

Lmaooo

earnest phoenix
#

thanks for letting me know lol, fixed

lusty dew
#

I think inv should still work though

#

Doesn’t it

#

Haven’t payed much attention to discord invites and how they work lel

earnest phoenix
#

no wonder i havent had new members join smh

lusty dew
#

Lel

quartz kindle
#

there is something wrong with your oauth2 url

earnest phoenix
lusty dew
#

That looks correct to me though

#

Probably the way he is using it?

quartz kindle
#

@earnest phoenix change response_type from code to token

#

then it works

earnest phoenix
#

implicit grant type is not suggested, it's very unsafe

#

ah yeah that worked, thank you :)

#

is there a more reliable guide for this? cause the one im reading has gave 2 faults so far from whats been said here xd

quartz kindle
#

i mean, the problem is that you didnt read it completely

#

it says in there to change your response_type to token

#

After you change the response type, you can test the url right away. Try visiting it in your browser and you will be directed to a page that looks like this.```
earnest phoenix
#

you should still avoid storing the token on the front, phishers can grab the token

quartz kindle
#

thats why the token expires

lusty dew
#

Mmm I love light theme on discord

earnest phoenix
#

expires after a week

#

which is enough time for someone to steal the token

#

especially with CSRF attacks

quartz kindle
#

a week? i thought this was like a 6 hour token or something

earnest phoenix
#

it's a week, that's why some people who do sessions server side make sessions expire after a week

quartz kindle
#

well, if he scrolls down, there is a guide for the code grant method as well

earnest phoenix
#

^ I'll continue with the guide, I was just testing what I had so far, thank you again guys

lusty dew
#

How do you link the website to your domain?

earnest phoenix
#

through DNS, change the DNS to your IP

#

server IP*

#

if you want to go more in depth and more secure, you should also reverse proxy

#

oh i tried using CloudFlare but it was really difficult with Express for some reason

#

so I reverted and my friend has gave me some iptables rules to set

quartz kindle
#

cloudflare has a guide on how to use it with apis

#

which includes a set of things you need to disable

#

another thing you can also do is use nginx as a reverse proxy, which is what i do

lusty dew
#

Nginx?

earnest phoenix
#

same

lusty dew
#

My friend uses it don’t know what it does though

earnest phoenix
#

web server

quartz kindle
#

nginx is a webserver

earnest phoenix
#

its just a web server

#

like apache

#

so Tim, are you using Express too? with nginx

quartz kindle
#

im using restana instead of express

lusty dew
#

Doesn’t a lot of people use express?

#

Oh?

quartz kindle
#

which is basically the same thing, but faster

earnest phoenix
#

im kinda new to express, it was the other PiBot Developer who shown me it

quartz kindle
#

which doesnt really matter tho

#

express is the most popular node server

#

also has the most features, and biggest community

#

but depending on your usage needs, it can be quite bloated and slow

#

there are dozens of alternatives out there which are smaller/faster than express

#

they just have less features, and might be harder to use

#

in any case, most times it wont make a difference

#

express can handle 10-15k requests per second

earnest phoenix
#

so one more thing, once the token has authorised or whatever, is there a way to pass my client to the website? so i can use client.guilds.get etc on the webpage

quartz kindle
#

if you're not hitting that much volume, you can stay with express

#

for comparison, restana can hit 45k reqs/s

#

the developer of restana is going even further, he also made 0http, which claims to reach 70k+ requests/second

lusty dew
#

What website would ever get that high of requests?

quartz kindle
#

usually social networks and such

lusty dew
#

YouTube maybe

#

Actually YouTube definitely

quartz kindle
#

youtube has other problems

lusty dew
#

Lol

#

Oof what’s that?

quartz kindle
#

youtube's problem is storage and bandwidth lmao

lusty dew
#

Ah true

amber fractal
#

And garbage compression mmulu

earnest phoenix
#

youtube's problem is youtube

quartz kindle
#

i fucking hate windows atm

#

i've been trying to build this fucking module for hours

#

on linux it works in 5 seconds

mossy vine
#

do you have proper build tools installed?

#

right version and stuff

quartz kindle
#

yeah i got everything, now the final boss is python is installed in program files

#

and i get cant find command files/python in c:/program

#

lmfao

#

fucking spaces in directory names

#

but i dont feel like moving python only for this

#

seriously, i even went through shit like npm deleting itself

#

or npm not updating because npm is open and cant be deleted

topaz fjord
#

i prefer koa

#

escape the spaces mmLol

quartz kindle
#

now it refuses to install gyp because an unrelated npm module gives resource busy or locked

topaz fjord
#

lmao

#

what are you moving for

quartz kindle
#

im not moving, i need to setup a local test environment to work on a rather complex function

topaz fjord
#

oh

quartz kindle
#

also im dumb

#

i was running the install gyp inside the module folder

#

lmao

topaz fjord
#

yes tim. its a fact

quartz kindle
#

dude wtf is this shit, i dont get it

#

i completely uninstalled the module, deleted the folder from packaje.json and node_modules, but when i install gyp its still trying to build the module

#

during installation?

#

well apparently it didnt get removed from package.json, even though i did uninstall -s

earnest phoenix
#

@quartz kindle how do you get the Discord.Client() on the HTML javascript?

upper salmon
#

someone know any free host for bot w db?

sick cloud
#

there's no such thing

#

go buy a vps

maiden mauve
#

Heroku is free

earnest blade
grim aspen
#

well

#

because both versions of message don't work together

earnest blade
#

i am confusion

grim aspen
#

it has to be one message functionn

earnest blade
#

you want all the code?

#

im just trying to make a command that makes the bot resend a certain custom emoji

grim aspen
#

no just the code for that code you have for the command