#development

1 messages ยท Page 208 of 1

lament rock
#

I use my own libraries

sharp geyser
#

oh im 100% joking

#

if I use js im using my own library

quartz kindle
#

where did that come from?

#

never heard of it before lmao

eternal osprey
#

creating my own chatbot cuz i got nun to do

pine willow
pine willow
frosty gale
eternal osprey
#

yuh

eternal osprey
#

tim my pookie i haven't seen you in a long time

quartz kindle
#

looks pretty basic, like straight up copying most things djs/eris did

pine willow
quartz kindle
#

would be cool to see some benchmarks and memory usage statistics

pine willow
eternal osprey
#

whahahha i know

#

german looks a lot like dutch so i can also kinda speak it

pine willow
#

ayy was geht

eternal osprey
#

es geht gut

#

danke schon

#

ik habe 3 jahre deutsch gehat auf meine schule

pine willow
#

:๐Ÿ˜ฑ

pine willow
quartz kindle
#

weird that i dont speak german at all but i can understand most of it

frosty gale
pine willow
#

:)

frosty gale
#

i dont like when people just make random libraries though

#

at least set a goal to differentiate yourself

#

what do you do better than the other libraries

quartz kindle
#

well they have 200 stars on gh

#

and apparently people are migrating from eris to it

#

because eris is dead/unmaintained

frosty gale
#

thought so

#

so thats probably what it is

#

an alternative to eris

surreal sage
#

yeah so how can i the sidebar

#

wait nvm

#

just had to drag the explorer to the icon bar on the left

frosty gale
#

promising even

#

but id also like to see benchmarks

#

whats the default caching like

eternal osprey
#

like 4 years ago maybe

#

or even longr

sharp geyser
#
const client = new Client({ auth: "Bot [TOKEN]" });

wtf is the point of this

pine willow
sharp geyser
#

What other kind of tokens are you going to be using

#

unless it also has oauth2 capabilities but idk

pine willow
pearl trail
sharp geyser
#

well i dont fucking blame them

frosty gale
sharp geyser
#

the voice gateway is annoying asf

frosty gale
#

since user bots of course dont use "Bot TOKEN" for authentication

sharp geyser
#

pretty sure discord stopped allowing user tokens to be used for auth on the bot api

frosty gale
sharp geyser
#

oh?

naive fiber
#

im trying to make it customizable for multiple answers or a single answer but i think somethings wrong with the value

frosty gale
#

and the api is relatively similar with some minor differences

sharp geyser
#

I thought user's had their own gateway

frosty gale
#

ill check this

sharp geyser
#

I mean, it'd make sense if you were completely trying to get rid of self bots to have separate gateways

lyric mountain
#

at last, finished migration

#

wont be doing this again in the next decade

sharp geyser
#

It's more annoying than the normal gateway

pearl trail
#

ah i see

sharp geyser
#

the voice gateway uses the same heartbeat interval as the on you log the bot into

#

which can be confusing to people if they don't read the docs

#

as the voice gateway responds with its own interval mistakingly

#

not really what makes it annoying tho, but those who don't read the docs properly get tripped up by it and wonder why its not working ๐Ÿ’€

quartz kindle
#

how the hck are you gonna implement it if you're not reading the docs

sharp geyser
#

I said properly

quartz kindle
#

properly

sharp geyser
#

tim

lyric mountain
#

propolis

sharp geyser
#

you would be surprised at the amount of people who "read" the docs

#

vs those who skim through it

quartz kindle
#

those who skim it dont make a working lib

#

simple

sharp geyser
#

that's what I was saying

#

๐Ÿ˜ญ

quartz kindle
#

lmao

sharp geyser
#

they don't read it properly and wonder why their shits not working

quartz kindle
#

i never tried dealing with voice

sharp geyser
#

I dislike it

quartz kindle
#

the UDP part seems the most annoying at first glance, along with all the security signature and shit

sharp geyser
#

You have to do a lot of stuff before even initiating a connection with the gateway

quartz kindle
#

ye

#

its basically 3 connections

#

the main gateway for voice channel events, the voice gateway for voice events, the UDP for audio streams

sharp geyser
quartz kindle
#

most people already use a 3rd party voice system tho

frosty gale
#

by the way i accidentally went through the eris github and the code structure is identical to eris

#

it looks like they used Eris as their base and converted it to typescript

sharp geyser
#

its a fork

quartz kindle
#

so its basically an eris clone

sharp geyser
#

they literally forked eris ๐Ÿ’€

quartz kindle
#

huehuehue

frosty gale
#

so its basically as good as eris

#

good to know

quartz kindle
#

or

#

as bad as eris

frosty gale
#

theres your benchmark answer

sharp geyser
#

I mean

quartz kindle
#

:^)

sharp geyser
#

I'll give them the benefit of the doubt and say they may have made some improvements

#

but there is no benchmarks to say so

quartz kindle
#

most people dont know how to even benchmark a discord lib

sharp geyser
#

tim benchmarking is your thing

#

let us know the results

#

๐Ÿ˜

quartz kindle
#

indeed

#

lmao

#

benchmarking discord is a pain tho

sharp geyser
#

๐Ÿ˜”

#

guess we will never know

frosty gale
#

performance is going to be relatively similar across libs i reckon

#

js is js

#

and plus were dealing with api's here so youre mostly at the mercy of how good your http client is and discord latency

quartz kindle
#

the only other major aspect besides memory is the event handling

#

like how the library unpacks all the events into structures and shit

#

let me do a barebones ram test real quick

frosty gale
#

theyre all quite similar no?

#

discord event comes in

#

new Class(client, raw_discord_data) {
this.class_params = raw_discord_data.params
}

#

thats what a lot of them do anyways

quartz kindle
#

last i tested anyway

#

which was years ago

#

events processed per second per shard

sharp geyser
#

nice tiny-discord

pine willow
#

tiny discord goes hard

quartz kindle
#

yeah i made this test just to benchmark it

sharp geyser
#

whos to say its reputable

#

๐Ÿ˜

frosty gale
#

lol detritus

quartz kindle
#

test is on gh, run it yourself

#

:^)

frosty gale
#

thats still in heavily active development

sharp geyser
#

nah im good

sharp geyser
#

cakedan stopped development on that lib quite a while ago

#

unless someone forked it

frosty gale
#

my heavy use of adjectives implies the use of sarcasm

sharp geyser
frosty gale
#

sorry too big of words

quartz kindle
#

last release 2021

frosty gale
#

i was joking

sharp geyser
#

Alright guys today the top.gg development channel will be make a discord lib

#

its main purpose is bitcoin mining

#

:D

#

we wont tell them that tho

quartz kindle
#

lmao

sharp geyser
#

if we get thousands of people to use our lib

#

we make bank

lyric mountain
#

needs to include cache

sharp geyser
#

buddy there will be 5 layers of cache just to make it seem like any usage is normal

#

gotta store the same thing in ram 5 times

quartz kindle
#

lmao

pine willow
#

bet

quartz kindle
#

LMFAO

#

oceanic is worse than djs

#

1gb ram usage

#

at 10k guilds

sharp geyser
#

thats normal

#

give it a second /s

quartz kindle
#

last time i tested djs i got like 800mb

pine willow
#

less guilds???

quartz kindle
#

same guilds

frosty gale
# quartz kindle same guilds

did you call the gc afterwards? it may also be a lot of leftover memory that havent been garbage collected yet

#

and do a side by side with discordjs again

#

wait like 20 seconds then --expose-gc then its gc.gc() i think then do your memory usage reading for a more accurate reading

quartz kindle
#

lmao fine

eternal osprey
#

omg i created this chatbot and it's literally so fucking cool

#

i never knew i had the capacity to do this type of shit lmao

pine willow
lyric mountain
frosty gale
#

this guy starts a new career journey every day

#

i admire it

sharp geyser
#

im sorry waht

#

he learned what now?

#

๐Ÿ’€

frosty gale
lyric mountain
sharp geyser
#

๐Ÿ’€

#

Im too scared to look back

eternal osprey
lyric mountain
#

the easier thing I helped him with was a pathfinding algorithm

eternal osprey
lyric mountain
#

like, who tf learns this outside college?

frosty gale
sharp geyser
eternal osprey
sharp geyser
#

Im curious what is your study

eternal osprey
#

CS

lyric mountain
#

see?

frosty gale
#

sounds like a graph problem

sharp geyser
#

What fucking college are you going to

#

no way its not an ivy league right?

#

I've never heard of some random college teaching that

eternal osprey
lyric mountain
#

there was also the boxing thing

eternal osprey
#

That was a bipartite graphing problem

#

pretty easy after all

#

just the runtime was shit

sharp geyser
#

oh its a dutch college

eternal osprey
#

yeah a dutch uni.

sharp geyser
#

nvm

dull juniper
#
const response = await axios.get(`https://top.gg/api/bots/${BOT_ID}/check?userId=${interaction.user.id}`, {
                headers: { Authorization: 'nuhuhuh' }
            });```

it's telling me that i can't check the bot even though my other code for the last 1000 votes work perfectly fine. what did i do wrong?
frosty gale
#

graph problems are fun

eternal osprey
#

i like the way how you can be creative

frosty gale
#

i had to learn some graph algorithm for determining the shortest path to a set point on a chess board using knight's movements in googles foobar challenge

#

definitely

sharp geyser
#

I just wish I knew more about my field of study

eternal osprey
#

damnnn that's actually really smart. I suppose you used dijkstra?

sharp geyser
#

but none of th CS programs around me look interesting

eternal osprey
sharp geyser
#

Computer Science

eternal osprey
eternal osprey
sharp geyser
#

Comp Sci is what I want to go on studying, but it doesn't look worth it

eternal osprey
#

i mean if you like it, fuck it just follow it.

frosty gale
sharp geyser
#

it doesnt seem worth spending thousands on a degree that probably wont teach me much of anything valuable

frosty gale
#

breadth first search i believe it was fun to learn

eternal osprey
#

I eventually had to choose an orientation as well, i chose software and data science. Was i scared for data science, yeah, did i choose it and am i enjoying it? Yuhhh.

surreal sage
#

is an inline switch possible in js

#

without an anony func

eternal osprey
surreal sage
frosty gale
#

but its obviously very memory intensive the more nodes you have

eternal osprey
#

Wouldn't the problem probably be:

  1. Defining the field
  2. Making only a set amount of tiles accessible (create a link for these nodes) from the starting node of the king.
  3. Run a dijkstra algorithm, where the amount of tiles traversed is the cost?
eternal osprey
quartz kindle
eternal osprey
#

Idk, as you have only a set amount of tiles you can traverse through, you can actually use a adjacency list instead of a matrix right?

frosty gale
#

so if your algorithm was too slow the solution wouldnt work

eternal osprey
#

that shall save you some memory

eternal osprey
frosty gale
#

so you had to use an algorithm that actually finds the shortest path first

surreal sage
#

mm algorithm hell

frosty gale
#

ill find my solution for it i ended with

eternal osprey
#

hmm i see, it sounds painful.

#

Omg hollup you know what really was painful? Creating my own btcp parser

#

I kid you not i spent 2 weeks on it

#

and it still doesn't fully work

quartz kindle
#

only 2 weeks

sharp geyser
quartz kindle
#

i spend months on things

#

because im a lazy bum

quartz kindle
eternal osprey
#

yeah but i was like actively working on it. 3-5 hours a day

quartz kindle
#

djs is right

frosty gale
#

this was the problem

sharp geyser
quartz kindle
#

i forgor some people use mobile

frosty gale
#

my solution

quartz kindle
frosty gale
#

once you know the algorithm the solution isnt too bad

quartz kindle
#

oceanic <
djs >

sharp geyser
#

so oceanic uses slightly more?

quartz kindle
#

ye

sharp geyser
#

not bad

quartz kindle
#

not bad?

#

it is very bad

#

lmao

frosty gale
sharp geyser
#

I mean in terms of both of them

#

oceanic is slightly worse than djs

#

but djs has seen an increasingly higher rise in memory usage over the years

#

at 10k guilds to be using that much is atrocious

eternal osprey
#

The solution looks pretty good tho

frosty gale
#

the first entries in the array will always be the shortest and most direct nodes to explore

#

so it all kinda falls into place

#

but i initially didnt even use deque for the problem and used the native python array and was wondering why i was failing the performance requirement

#

i thought python optimised the array shift operations internally

#

but turns out they didnt and its horribly slow

eternal osprey
#

ahhh, yeah i don't know all the details of the program, but usually for distance related stuff a prioirtyqueue is like really handy.

eternal osprey
frosty gale
#

i was really surprised it was as bad as people make it out to be

#

thats why you have all these handy libraries like numpy that do it in c

#

i dont think theres even a purely 100% python implementation of tensorflow like there is in js where you can run tensorflow without c bindings or gpu

#

because its that bad

sharp geyser
#

@warm imp you have to provide intents to the client

warm imp
#

I am trying to turn on my bot and idk how

sharp geyser
#

Show how you are creating the client

warm imp
#

Oh

sharp geyser
#

it has an intents option field

warm imp
#

Where would i put that?

sharp geyser
#

when you are creating the client

#

in its options

#

you have to set intents

eternal osprey
#

i always tend to use sklearn.

#

i love it's preprocessing methods that it comes with.

frosty gale
#

youre remining me of my machine learning era

#

i need to get back into it

#

especially in these times

eternal osprey
#

i actually wrote a research paper where i compared different classification algorithms for labeling people as high risk/low risk in insurance companies (spoiler: ockhams razor fucked my hypothesis )

eternal osprey
warm imp
sharp geyser
pine willow
frosty gale
#

from a mathematical standpoint anyways

eternal osprey
#

i swear once i graduate i am downloading all the necessary slides

#

might become useful

eternal osprey
#

especially the evaluating part and hyperparameter tuning was actually fun to do.

pine willow
surreal sage
#

ternary pyramids my beloved

sharp geyser
#

also a Cheater

eternal osprey
#

And a Demon

warm imp
#

lol

pine willow
surreal sage
#

no!!

pine willow
frosty gale
#

i remember doing the bellman equation

sharp geyser
surreal sage
sharp geyser
#

no thats intentions

frosty gale
#

thats for SARSA

surreal sage
#

same thing

eternal osprey
#

Ah damn i see. Well if you need any help whenever you're stuck or something i can explain that shit to you and send some slides on that topic.

surreal sage
#

jackbox for adults only

#

time to piss off eslint..

surreal sage
#

essay inbound

sharp geyser
#

Ask someone else here ive given you the resources I can

#

if that doesn't help then learn the programming language and read the docs of the library you are using

proven lantern
#

i am trying to hide ratings when a player hasn't played enough matches. i'm trying to use map to remove fields, but they are still showing up. any idea why combined_player distinct_player and overall_player fields aren't being removed here?

eternal osprey
#

Does anyone know how to fix a 402 Namenode error? I am running hadoop on a relatively sized cluster of 10 machines, i had gathered a few tb worth of videos and i am now trying to do some anaylsis on it. However each time my client talks with the namenode it just returns me a 402 error. The whole web doesn't even talk about it and i am pretty sure my config is correct.

eternal osprey
#

maan fuck hadoop i should have used spark from the beginning

lyric mountain
#

oh nvm, u collapsed it

surreal sage
#

i think you can do ```js
{
...(condition && {})
}

#

saw it in some source code somewhere

#

dont take my word for it though

pine willow
#

Is a 9 ms bot ping good? bloblul

eternal osprey
#

try 22

eternal osprey
#

guys recently i discovered that you can actually punch a hole in a normal host's firewall..
i read somewhere that each time you send a packet, the firewall needs to go through it's tables and apply certain filtering rules on the packets. However this takes a bit of time, so a hole occurs in the firewall. So if you spam packets you can actually go through the firewall.
Idk if it's fixed already, but it was about iptables, the firewall filtering linux used.

proven lantern
sharp geyser
#

damn

pine willow
#

Typescript on top

sharp geyser
#

Bout to say you can use Omit

#

but nvm

proven lantern
sharp geyser
#

spreading will overwrite whatever is being spread before

proven lantern
#

i'm still seeing the overall_player field when playerRating.matces < mathes_until_ranked. it should be replaced with undefined

#

i must be doing something else wrong

sharp geyser
#

that or what is before ?? is not null

proven lantern
proven lantern
#

precedence

sharp geyser
quartz kindle
#

i was confused too

#

had to test it out

proven lantern
#

thanks Tim!!

lament rock
# quartz kindle lol

?? is such a funky operator, but also I get the logic. 2 boxed to bool is true

#

Ive had weird bugs pop up because of ?? I didnt have issues when using ||

warm imp
#

I cant figure how to turn on my bot

pine willow
warm imp
#

Yeah

#

Kinda

pine willow
#

Kinda?

warm imp
#

I used a github thing then changed some of it

#

And watched youtube videos

pine willow
#

Can you send the GitHub repo?

warm imp
#

In here

pine willow
#

Ye

warm imp
#

here is it

#

this it what i got it off

pine willow
#

Mhm

#

I mean its 3 years old

warm imp
#

I found a newer one

pine willow
#

So many Things can be outdated

#

Intents too

warm imp
pine willow
#

Ohh this bot

warm imp
#

I am just trying to make a good bot lol

sharp geyser
#

well

#

you didn't make anything

#

you are just cloning a bot

#

๐Ÿ’€

pine willow
#

Or he is trying to create a "new" bot with code from many other Bots?

sharp geyser
#

still not something he made

quartz kindle
sharp geyser
#

so either way

pine willow
warm imp
sharp geyser
#

I do not help people with cloned bots

warm imp
#

I am just getting the based down

warm imp
sharp geyser
#

someone else might help you

sharp geyser
#

It sounds like you dont even have programming knowledge or knowledge of the discord.js library

#

Your time would be better spent learning js

pine willow
warm imp
#

I am just trying to get the base down to get customize it

pine willow
#

Even if you would Manage to do so you wouldn't get it on top.gg

sharp geyser
#

I understand that, but helping someone with no programming knowledge is like shooting yourself in the foot

#

if you dont have the basics down at least

quartz kindle
#

take it easy

sharp geyser
#

huh

pine willow
sharp geyser
#

How am I being rude?

pine willow
#

Passiv aggressive

sharp geyser
#

Its almost as if you guys havent said the same things ๐Ÿ’€

#

its not being passive aggressive its being truthful

#

Im not going to sugar coat my words to make him feel better, I'd rather get the point across

quartz kindle
warm imp
#

oh

pine willow
sharp geyser
#

Migrating from v12 -> v14 will be hard enough as is

pine willow
#

Ye

warm imp
#

Should i just delete it all

pine willow
quartz kindle
#

do you have any knowledge of programming/coding in general?
if no, are you interested in learning?

#

or are you just interested in getting a bot running with minimal effort?

warm imp
#

And become a progammer

#

But i dont really have experience or knowledge

sharp geyser
#

if you want to learn javascript

quartz kindle
#

alright, then i would recommend starting with some basic tutorials for a programming language

warm imp
sharp geyser
#

this is by far the best resource

#

javascript.info has a lot of useful chapters on the language that teaches you the ins and outs

warm imp
#

Will i learn it fast or no

pine willow
#

Ehhh

sharp geyser
#

It all depends on the effort you put in

#

if you are willing to put the time into learning it, you will achieve great things

quartz kindle
#

you can get the basics down in a couple weeks, become alright at it in a few months

sharp geyser
#

I say this with experience and from countless other testiments. Making a bot as your first project is not a good idea. It doesn't teach. you what you need to know most of the time, unless you have a clear goal and know what you need to use

#

It's better to get the basics down, then try and make a bot.

pine willow
#

Many People are seeing "Easy To Use Discord Bot" and thinking they can learn programming with that.

quartz kindle
#

funny that literally everyone who says that did it first lmao

#

making a bot as a first project xD

sharp geyser
#

We learn from our mistakes tim sadgemusic

#

not me tho

#

I said fuck it we ball

quartz kindle
#

well you can only learn from your mistakes, not from the mistakes of others

pine willow
sharp geyser
#

and wasted a lot of time

quartz kindle
#

so if they wanna make a bot as first project, let them have it

sharp geyser
#

Many people learn best when challenging themselves, I myself am like that

#

I also like the pain and suffering that comes with programming apparently

pine willow
#

I learn from seeing Things

sharp geyser
#

What can I say tim, you grow to love it KEKW

#

Its so satisfying when you finally do something and it works

#

only to later realize what you just did is useless

pine willow
quartz kindle
#

xD

sharp geyser
#

I can't tell you the amount of times i've removed/added things in my backend

#

only to realize maybe I shouldn't have done that, or maybe I actually needed that

pine willow
#

I did it so many times until i noticed i forgot ")"

warm imp
#

Why when i do npm init -y i have over 160 lines

#

Is that suppose to happen?

pine willow
#

In which file do you have 160 lines?

frosty gale
#

I probably wouldn't have gotten into programming or computer science at all if it wasn't for discord bots

pine willow
#

I mean npm init -y creates a new Project

warm imp
frosty gale
pine willow
warm imp
#

ok

quartz kindle
#

why is package.json 160 lines lol

sharp geyser
#

๐Ÿ’€

#

all those packages bro

warm imp
#

idk why i have so much

pine willow
#

I have a Project with more

#

Soo

pine willow
#

Or other Stuff

quartz kindle
#

i mean, a blank package file in a new project lel

pine willow
#

Well that shouldnt have 160 lines

warm imp
#

How do i delete packages

#

and just get the ones i need

quartz kindle
#

are you working on a blank folder?

#

or a copied folder from github?

warm imp
quartz kindle
#

then you should start with 0 packages anyway

pine willow
#

Nothing in it?

warm imp
#

Yeah except my node_modules

pine willow
#

And package.json, package-lock.json?

warm imp
#

Yeah

pine willow
#

Mhnn

#

Bruh i just noticed i'm Connected to my VPN Server

warm imp
#

I accidently did npm i

#

and some reason i got tons of packages

pine willow
#

You got all packages that are in package.json

warm imp
#

Yeah

quartz kindle
#

that will only install packages if you have a package.json with packages in it, not from an empty one lol

#

did you copy the package.json file from github?

warm imp
#

There was one in it yes

#

So yes

pine willow
#

Yea now it makes sense

warm imp
#

Should i just make a new folder

quartz kindle
#

show the contents of your package.json

warm imp
#

Its very long

quartz kindle
#

wtf

#

why do you have hundreds of packages

warm imp
#

idk

quartz kindle
#

where did you copy that package.json from

warm imp
#

It might be because that github

#

thing

quartz kindle
#

lmao

pine willow
quartz kindle
#

just delete everything

warm imp
#

The folder?

quartz kindle
#

delete everything in the folder

pine willow
#

Yes.

quartz kindle
#

then run npm init -y

warm imp
#

wow theres only like 3 things now lol

quartz kindle
#

there you go lol

pine willow
#

Fresh Project ๐Ÿ”ฅ

warm imp
#

wow

quartz kindle
#

now you only need one package to start working with discord, there are many to chose from

#

but discord.js is the most popular one

warm imp
#

Yeah i wanna use that one

quartz kindle
#

so you can try starting with that

#

you can install it by running npm i discord.js

warm imp
#

done

quartz kindle
#

now create a js file

#

for example index.js

#

or bot.js

#

whatever you prefer

pine willow
#

And start coding

quartz kindle
#

this file is where you will write the code

warm imp
#

I made it

quartz kindle
#

then go to the discord.js website and check their quick start example

pine willow
quartz kindle
#

can deal with that later

pine willow
#

Yessir

warm imp
#

{
"token": "your-token-goes-here"
}

#

Thats what i gotta put in the index.js

pine willow
quartz kindle
warm imp
#

I found guide but not example

quartz kindle
#

the guide is talking about a config.json file

#

you can do thjat if you want

pine willow
#
// Require the necessary discord.js classes
const { Client, Events, GatewayIntentBits } = require('discord.js');
const { token } = require('./config.json');

// Create a new client instance
const client = new Client({ intents: [GatewayIntentBits.Guilds] });

// When the client is ready, run this code (only once).
// The distinction between `client: Client<boolean>` and `readyClient: Client<true>` is important for TypeScript developers.
// It makes some properties non-nullable.
client.once(Events.ClientReady, readyClient => {
    console.log(`Ready! Logged in as ${readyClient.user.tag}`);
});

// Log in to Discord with your client's token
client.login(token);
#

Thats the Example code

warm imp
#

I put that in my index.js

quartz kindle
#

^ this is what goes in your main js file

#

yes

warm imp
#

okie

pine willow
#

After that the Guide Shows you how to create slash Commands

warm imp
#

Where is says client.login(token) do i put my token

pine willow
quartz kindle
#

depends, you can do it in many ways

#

if you created the config.json file or not

pine willow
#

Create a config.json file and put this in it: ```{
"token": "your-token-goes-here"
}

#

Change it with your bot token

warm imp
#

Ok did that

pine willow
#

Open a terminal in your folder with index.js

warm imp
#

k

pine willow
#

and run node index.js

#

Errors?

warm imp
#

No

#

Bot is online ๐Ÿ™‚

#

yay

quartz kindle
#

gj

warm imp
#

Ty

pine willow
#

gg

#

Now try to create your First command

warm imp
#

Should i make a folder called commands?

pine willow
#

Well if the guide said so yes

warm imp
#

So i made a sub folder and now i got to make a file. what should i call the file in the sub folder called

pine willow
#

Ping.js

warm imp
#

k

pine willow
#
const { SlashCommandBuilder } = require('discord.js');

module.exports = {
    data: new SlashCommandBuilder()
        .setName('ping')
        .setDescription('Replies with Pong!'),
    async execute(interaction) {
        await interaction.reply('Pong!');
    },
};
warm imp
#

Ok

#

I typed it in

pine willow
#

Save

warm imp
#

saved

pine willow
#

And restart your bot

warm imp
#

k so how again

pine willow
#

Ctrl+c

#

And node index.js

warm imp
#

ok

#

did it

pine willow
#

Does your bot have a /Ping command now?

warm imp
#

no

quartz kindle
#

missing the deploy step

pine willow
#

Oh

#

Yea

lament rock
#

Making a bot as my first project was a good idea

#

Unironically

warm imp
#

module.exports = {
    data: new SlashCommandBuilder()
        .setName('user')
        .setDescription('Provides information about the user.'),
    async execute(interaction) {
        // interaction.user is the object representing the User who ran the command
        // interaction.member is the GuildMember object, which represents the user in the specific guild
        await interaction.reply(`This command was run by ${interaction.user.username}, who joined on ${interaction.member.joinedAt}.`);
    },
};```
#

This it?

pine willow
warm imp
#

Oh i was on the wrong part

#

whoops

pine willow
#

Ayy my bot reached 280 Servers

#

300 in a few hours?topggFlushed

lament rock
#

dont get too ahead of yourself

lament rock
#

growth will stagnate

pine willow
lament rock
#

I was around 10,000 servers before I pulled the plug

#

Over 6 years

#

music bot too so was a popular topic

pine willow
#

Until YouTube ruined it lol

lament rock
#

My bot may or may not have the method

#

But who knows

pine willow
#

Spotify works too

#

Or other "stuff"

lament rock
#

You can only stream one track from spotify if you really wanted to be a masochist and base a player off of its api

warm imp
#

Where do i put this

#
const { clientId, guildId, token } = require('./config.json');
const fs = require('node:fs');
const path = require('node:path');

const commands = [];
// Grab all the command folders from the commands directory you created earlier
const foldersPath = path.join(__dirname, 'commands');
const commandFolders = fs.readdirSync(foldersPath);

for (const folder of commandFolders) {
    // Grab all the command files from the commands directory you created earlier
    const commandsPath = path.join(foldersPath, folder);
    const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
    // Grab the SlashCommandBuilder#toJSON() output of each command's data for deployment
    for (const file of commandFiles) {
        const filePath = path.join(commandsPath, file);
        const command = require(filePath);
        if ('data' in command && 'execute' in command) {
            commands.push(command.data.toJSON());
        } else {
            console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
        }
    }
}

// Construct and prepare an instance of the REST module
const rest = new REST().setToken(token);

// and deploy your commands!
(async () => {
    try {
        console.log(`Started refreshing ${commands.length} application (/) commands.`);

        // The put method is used to fully refresh all commands in the guild with the current set
        const data = await rest.put(
            Routes.applicationGuildCommands(clientId, guildId),
            { body: commands },
        );

        console.log(`Successfully reloaded ${data.length} application (/) commands.`);
    } catch (error) {
        // And of course, make sure you catch and log any errors!
        console.error(error);
    }
})();```
pine willow
#

deploy-commands.js

warm imp
#

didnt work

#

Is it because i never did command handling

pine willow
#

node deploy-commands.js

#

Did you set config.json?

#

{
"token": "your-token-goes-here",
"clientId": "your-application-id-goes-here",
"guildId": "your-server-id-goes-here"
}

warm imp
#

I did that

#
    "token"; "",
    "clientId"; "",
    "guildId"; ""
}
const { REST, Routes } = require('discord.js');
const { clientId, guildId, token } = require('./config.json');
const fs = require('node:fs');
const path = require('node:path');

const commands = [];
// Grab all the command folders from the commands directory you created earlier
const foldersPath = path.join(__dirname, 'commands');
const commandFolders = fs.readdirSync(foldersPath);

for (const folder of commandFolders) {
    // Grab all the command files from the commands directory you created earlier
    const commandsPath = path.join(foldersPath, folder);
    const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
    // Grab the SlashCommandBuilder#toJSON() output of each command's data for deployment
    for (const file of commandFiles) {
        const filePath = path.join(commandsPath, file);
        const command = require(filePath);
        if ('data' in command && 'execute' in command) {
            commands.push(command.data.toJSON());
        } else {
            console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
        }
    }
}

// Construct and prepare an instance of the REST module
const rest = new REST().setToken(token);

// and deploy your commands!
(async () => {
    try {
        console.log(`Started refreshing ${commands.length} application (/) commands.`);

        // The put method is used to fully refresh all commands in the guild with the current set
        const data = await rest.put(
            Routes.applicationGuildCommands(clientId, guildId),
            { body: commands },
        );

        console.log(`Successfully reloaded ${data.length} application (/) commands.`);
    } catch (error) {
        // And of course, make sure you catch and log any errors!
        console.error(error);
    }
})();```
#

The info is filled in at the top

pine willow
#

Nooo

warm imp
#

oh

pine willow
#

๐Ÿ˜ž

warm imp
#

Fixed it

#

I am learning this way btw Lawyer

sharp geyser
#

this is the part of the guide i disagree on, but if it helps to make it its own file then all the more merrier

sharp geyser
#

Whatever works for you

warm imp
#

๐Ÿ™‚

sharp geyser
#

What I said earlier was just a forewarning that it doesnt always work best for people

#

wasnt to discourage you to give it a go

quartz kindle
#

also, whenever possible try to read the code and learn what is going on

#

for example, every time you see the line require('./config.json');, that means its loading the config.json file

#

and reading its contents

warm imp
#

oh ok

quartz kindle
#

the require function is how you load files in node
you can load packages, js files and json files

pine willow
#

Anyways good Night ๐Ÿ’ค

quartz kindle
#

you should also learn how to work with variables, as they are the most fundamental concept in programming

#

the keywords var const let is how you create variables in javascript

#

a variable is a name that holds a piece of data

#

for example if you do const config = require('./config.json');
that means you are reading the config.json file and saving its contents in the variable named config

#

which then you can access its contents from it, for example config.token will access the value of the token

sharp geyser
#

Is var still frowned upon in a lot of cases due to its ability to ignore scope?

quartz kindle
#

yes

#

ability to ignore inability to respect scope

#

lmao

sharp geyser
#

right

#

Also, if you only need specific keypoints of something, you can destructure it

#

const { token } = require('./config.json')

quartz kindle
#

also learn about basic data types

#

string, number, object

sharp geyser
#

boolean, number, string, object

warm imp
#

alr

sharp geyser
#

almost pulled out i32 until I remembered this isnt rust

quartz kindle
#

xD

warm imp
#
const path = require('node:path');
const { Client, Collection, Events, GatewayIntentBits } = require('discord.js');
const { token } = require('./config.json');

const client = new Client({ intents: [GatewayIntentBits.Guilds] });

client.commands = new Collection();```

Does this go in my index.js
sharp geyser
#

I love the simplicity of js

#

how it can ignore types and yell at you at runtime

warm imp
#

So it should look like this

#
const { Client, Events, GatewayIntentBits } = require('discord.js');
const { token } = require('./config.json');

// Create a new client instance
const client = new Client({ intents: [GatewayIntentBits.Guilds] });

// When the client is ready, run this code (only once).
// The distinction between `client: Client<boolean>` and `readyClient: Client<true>` is important for TypeScript developers.
// It makes some properties non-nullable.
client.once(Events.ClientReady, readyClient => {
    console.log(`Ready! Logged in as ${readyClient.user.tag}`);
});

// Log in to Discord with your client's token
client.login(token);

const fs = require('node:fs');
const path = require('node:path');
const { Client, Collection, Events, GatewayIntentBits } = require('discord.js');
const { token } = require('./config.json');

const client = new Client({ intents: [GatewayIntentBits.Guilds] });

client.commands = new Collection();```
quartz kindle
quartz kindle
#

avoid repeating lines unnecessarily

#

whataver a line of code already did, it doesnt need to be done again

warm imp
#

Ohhh

#

so i can just put that one under it abovce

#

So like this

#
const fs = require('node:fs');
const { Client, Events, GatewayIntentBits } = require('discord.js');
const { token } = require('./config.json');

// Create a new client instance
const client = new Client({ intents: [GatewayIntentBits.Guilds] });

client.commands = new Collection();

// When the client is ready, run this code (only once).
// The distinction between `client: Client<boolean>` and `readyClient: Client<true>` is important for TypeScript developers.
// It makes some properties non-nullable.
client.once(Events.ClientReady, readyClient => {
    console.log(`Ready! Logged in as ${readyClient.user.tag}`);
});

// Log in to Discord with your client's token
client.login(token);```
sharp geyser
quartz kindle
#

missing the Collection import from discord.js

#

but yes

sharp geyser
#

Honestly why do they pass the client into the ready event

#

you typically have access to it at all times

#

Hmm ig in cases where you separate it fro mthe scope of the client

quartz kindle
#

its not the client, its the events enum

sharp geyser
#

in like a handler

sharp geyser
quartz kindle
#

ah you mean the param

sharp geyser
#

yea

quartz kindle
#

all events give you something to use in the param ye

sharp geyser
#

the only way I see that being viable is if you take the listener out of scope of the client, but even then you're using the client to listen to the event

#

:p

quartz kindle
#

you can define the handler in a separate file for example

sharp geyser
#

unless someone does function(client) {} as the listener

#

then ig so because it creates its own scope, and ignores anything outside of it (I think)

warm imp
#

Something isnt working

sharp geyser
#

What errors do you get

warm imp
#

ReferenceError: Collection is not defined

sharp geyser
#

You have to import it

sharp geyser
#

add it to your const {...} = require('discord.js')

warm imp
#

I feel like this is wrong

#
const fs = require('node:fs');
const { Client, Events, GatewayIntentBits } = require('discord.js');
const { token } = require('./config.json');

// Create a new client instance
const client = new Client({ intents: [GatewayIntentBits.Guilds] });

client.commands = new Collection();

// When the client is ready, run this code (only once).
// The distinction between `client: Client<boolean>` and `readyClient: Client<true>` is important for TypeScript developers.
// It makes some properties non-nullable.
client.once(Events.ClientReady, readyClient => {
    console.log(`Ready! Logged in as ${readyClient.user.tag}`);
});

// Log in to Discord with your client's token
client.login(token);

client.commands = new Collection();

const foldersPath = path.join(__dirname, 'commands');
const commandFolders = fs.readdirSync(foldersPath);

for (const folder of commandFolders) {
    const commandsPath = path.join(foldersPath, folder);
    const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
    for (const file of commandFiles) {
        const filePath = path.join(commandsPath, file);
        const command = require(filePath);
        // Set a new item in the Collection with the key as the command name and the value as the exported module
        if ('data' in command && 'execute' in command) {
            client.commands.set(command.data.name, command);
        } else {
            console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
        }
    }
}

client.on(Events.InteractionCreate, async interaction => {
    if (!interaction.isChatInputCommand()) return;

    const command = interaction.client.commands.get(interaction.commandName);

    if (!command) {
        console.error(`No command matching ${interaction.commandName} was found.`);
        return;
    }

    try {
        await command.execute(interaction);
    } catch (error) {
        console.error(error);
        if (interaction.replied || interaction.deferred) {
            await interaction.followUp({ content: 'There was an error while executing this command!', ephemeral: true });
        } else {
            await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
        }
    }
});```
warm imp
quartz kindle
warm imp
#

So i should delete that bottom one

quartz kindle
#

read the lines

warm imp
#

Oh wait

quartz kindle
#

and find the difference

warm imp
#

event and collection

sharp geyser
#

One has something the other should

quartz kindle
#

the words inside the {} are the components of discord.js that you are importing

sharp geyser
quartz kindle
#

your error stated that Collection was not defined, because you forgot to import it

sharp geyser
#

Its telling you x is not defined

#

you are using x somewhere but didn't import it

warm imp
#

How to import it

sharp geyser
quartz kindle
#

add it inside the brackets

#

like the other line had

sharp geyser
#

should i cave in and make tomatoe soup with water

#

I have no milk

quartz kindle
#

my late grandma used to make an amazing tomato soup

#

with just onion and tomato sauce

#

and water

sharp geyser
#

im sorry but campbells tomato soup made with water is disgusting

quartz kindle
#

f u

sharp geyser
#

I'll make normal tomato soup that way

#

but not campbells

quartz kindle
#

i dont even know what campbells are

#

lmao

sharp geyser
#

its a condensed soup

#

"Just add water"

quartz kindle
#

like instant soup?

sharp geyser
#

yea

#

but its very yucky with water because it doesn't taste like real tomato soup

quartz kindle
#

never seen instant soup that is done with milk

sharp geyser
#

it gives it a bad aftertaste

quartz kindle
#

@_@

sharp geyser
#

it makes it creamy

#

I like cream based soups if I can help it

sharp geyser
#

I haven't used js in a while

#

so I forgor a lot about it

quartz kindle
#

functions have their own scope ye

#

but they can see any outer scope

sharp geyser
#

oh?

#

I remeber it being an issue inside classes

quartz kindle
#

like anything defined outside the function can still be accessed

sharp geyser
#

oh wait

#

nvm I am thinking of something else

#

function doesn't preserve the outside scope in the sense that this is not the same as what the function is being used inside of

#

it becomes the function

#

so if I was using function anywhere inside a class method, this no longer refers to the class it refers to the function

#

arrow functions on the other hand doesn't cause such a thing

quartz kindle
#

yes

#

this inside a function is defined at function runtime

#

arrow functions on the other hand, their this is defined at define time

sharp geyser
quartz kindle
#

like if you define a function and then assign it elsewhere

#

the this inside it can change

#

based on where you assigned it

sharp geyser
#

oh?

#

I always thought it became the properties of whatever the function was used on

quartz kindle
#

thats why things like someclass.prototype.abc = function() { this } work

#

the this is defiend when the abc method is run

sharp geyser
#

so what would this contain

#

the properties of the class?

quartz kindle
#

the class instance

sharp geyser
#

See it didn't work for me like that a long time ago

quartz kindle
#

if you then do otherclass.prototype.xyz = someclass.prototype.abc

#

the this will be the otherclass this, not the someclass this

sharp geyser
#

I don't remember the exact case of what happened but roughly I was doing


someMethod(){
  SomethingFromSomePackage.on('someevent', function(someprop) => {
    // needed something from the class
    this.whatever // well this.whatever doesn't exist because its being overriden by the `function`
  })
}
quartz kindle
#

yes

#

because the function is run by the event emitter

#

at some later stage

sharp geyser
#

So it no longer belongs to the class

quartz kindle
#

ye

#

its defined when the function runs, based on what runs it

sharp geyser
#

ic

#

thats why in a lot of cases people opt to use () =>{} over function(){} ?

quartz kindle
#

if you want to keep the this unchanged yes

sharp geyser
#

is there any times where function is better to use?

quartz kindle
#

an arrow function will use whatever was the value of this when the function is declared/defined, not when its run

sharp geyser
#

quite honestly dont remember the last time i've seen someone use function over () => {}

quartz kindle
sharp geyser
#

honestly cant say i've ran into a case like that yet

quartz kindle
#

and always use () => {} whenever you want to use a this from outside, inside it

sharp geyser
#

and by context you mean how its called right?

quartz kindle
#

ye

#

99% of its use cases are prototype hacking lol

sharp geyser
quartz kindle
#

its very useful to create dynamic classes tho

sharp geyser
#

btw do you understand ts decorators?

quartz kindle
#

for example you have several versions of a method, and depending on some parameter you can hot-swap the different versions of the method

#

like if you have one method that only works on node, and another that works on browsers

#

you can detect the environment at runtime and edit the class prototype to the correct method

sharp geyser
#

icic

quartz kindle
sharp geyser
#

I don't

quartz kindle
#

dont like them thatr much

sharp geyser
#

I tried making my own and it sucks

#

I was making a class decorator that added slash command metadata to it

#

Why would i do that instead of making it part of the class? idfk I wanted to try decorators

#

I honestly don't see the appeal of them yet I see so many packages use them

quartz kindle
#

i dont quite see their usefullness either

sharp geyser
#

So many packages use em tho

#

so maybe its just something im not seeing

quartz kindle
#

i had to learn about them when i had to learn about angular to teach a class abot it lol

sharp geyser
#

I mean ig its useful if you don't necessarily need all those properties on the class

#

you dynamically add them with decorators

quartz kindle
#

or, you can... idk... use constructor options?

#

xD

sharp geyser
#

yea thats my point

#

I can see why but there is other options

#

it just doesn't make sense for a language like ts

quartz kindle
#

ยฏ_(ใƒ„)_/ยฏ

#

igoslepnao

sharp geyser
#

gn tim

wheat mesa
sharp geyser
#

wtf is a colored function

#

but i've never in my life heard of this terminology

#

From what I can tell is that a colored function is something that must be run in something that also takes on a similar signature

#

like rust async functions must be called using await but you can't use await outside of an async function, so therefor the function making that call must also be async

#

whereas go has async functions but are called similarly to sync functions. Meaning whatever is calling that function doesn't HAVE to have the same signature as the function being called

#

Please someone let me know if I am wrong :p

frosty gale
#

nobody calls them colored or uncolored

#

not sure where they got that from

#

oh this is langdev section

#

they might have their own terminology

sharp geyser
#

I assume they do

#

It's my first time hearing about it, which came from a youtube video on a new programming language and I decided to google it

#

that was the first page I saw talking about it

quartz kindle
#

colored functions are more diverse and come from multicultural backgrounds

sharp geyser
#

wym

frosty gale
quartz kindle
spark flint
#

does anyone have experience with Twilio SMS verify API

#

you can't pass a custom code without having a paid plan

#

so im trying to get the SMS code it sends

#

but its not working

eternal osprey
#

i spent like 4hours today to generate a mandelbrot set on a pixel sheet using c.
It's actually really cool, it has a strong link to the chaos theory.

#

where one pixel 'activates' another pixel. It produces pretty sick images as well

#

it reminds me of synapses for some reason

neon leaf
#

is there any nodejs package for ssh2 that handles all sftp events for me? I dont want to reinvent the wheel for that

radiant kraken
eternal osprey
eternal osprey
surreal sage
eternal osprey
surreal sage
covert gale
#

how would i get the total ram a system has through java?

covert gale
#

thats for the vm

#

i need the actual ram like the whole system has

surreal sage
covert gale
surreal sage
#

(i dont know java at all)

covert gale
#

oshi is a PITA and will probably break once i update it but yeah that works

surreal sage
#

look at the source!

eternal osprey
surreal sage
#

it builds on my machine

#

ah yes

#

i redeploy

#

and it builds

#

how interesting

#

(same code)

eternal osprey
#

Process flops 1.322960
Process flops 1.323176
Process flops 1.054708
Process flops 1.053313
Total flops 2.667088

could someone enlighten me

#

i am using openMPI to calculate the amount of gflops my parallel program makes.

#

i used 4 threads, the imbalance is like 1.3. Is this considered high? Second of all, how the fuck do these numbers add up to the total gflops count?

civic scroll
#

@radiant kraken gaming

solemn latch
#

So each thread on its own can get 1-1.3 but you lose some when doing them all at once.

#

Unless your threads don't depend on each other entirely you're going to lose some 'gain' with each thread

sharp geyser
eternal osprey
pseudo grotto
#

hey im using native discord.js sharding on auto, my bot is in 513 servers and its hitting rate limits for some odd reason. i dont know why. auto sharding is just 1 shard, should i raise it to 2 shards manually or more? or should i switch to discord-hybrid-sharding with clusters and idk if that will work better

quartz kindle
pseudo grotto
#

429

#

gateway

quartz kindle
#

on what routes

#

ah gateway

pseudo grotto
#

let me check

#

yeah gateway

quartz kindle
#

thats related to excesive login attempts

#

ie bot constantly crashing and restarting

pseudo grotto
#

its prob crashed like once an hour? i fixed the error just now i was sleeping

#

i changed the port but i guess discord goes by IP

quartz kindle
#

maybe the bot was on a crash loop while you were sleeping

#

if you check the headers from gwateway 429 it will tell you how long you have to wait to login again

#

you can also try logging in from a different machine

pseudo grotto
pseudo grotto
#

Welp I've moved it to Germany vps for now

pine willow
pseudo grotto
#

I wonder how long it'll take for the rate limit to clear

#

Because I can't see the headers

quartz kindle
pine willow
#

whut

quartz kindle
#

most gateway 429 are caused by a cloudflare ip ban

pseudo grotto
#

Alright I'll move it back tmrw I guess

quartz kindle
#

its unclear what triggers it exactly, but its usually too fast repeated login attempts

pine willow
#

hmm

quartz kindle
pseudo grotto
#

A post request? Or just a get or idk maybe a patch or put

#

I don't need to send any headers or body right?

quartz kindle
#

you need to send the bot token in the headers

pseudo grotto
#

Ah no body needed either?

quartz kindle
#

nop

#

just get /gateway/bot

#

with auth token

pseudo grotto
#

Alright so I just needa do console log the headers from the response?

quartz kindle
#

ye

pseudo grotto
#

Alright

#

Also sometimes my shard takes forever to be ready it's finished all of its tasks for the client and it should be ready so it just dies for taking too long I have auto respawn on and usually it takes 10 mins to go online. Is there a reason for this? Saw some people had the same issue on GitHub they made a issue but no updates from discord.js or anything. Changing the IP doesn't help.

#

Even if I dont shard if I just straight up run my client it doesn't want to go ready then.

quartz kindle
#

that can happen if your internet sux

#

or your host's internet sux

pseudo grotto
#

Hmm I should do a speed test on my vps then

quartz kindle
#

it can also happen when there are bugged guilds

#

you can check whats going on by listening to the raw event

pseudo grotto
#

Hmmm I'll look into that

pseudo grotto
quartz kindle
#

shard events are emitted through the client

pseudo grotto
#

Ah ok

sharp geyser
quartz kindle
#

h

pseudo grotto
pine willow
#

Dubai? Eyes

pseudo grotto