#development

1 messages · Page 1605 of 1

young flame
#

that was my question million

crimson vapor
#

you aren't using a command handler doe

#

so you don't "make" a command

mellow kelp
#

how do you want to make a command without a command handler

#

that's not how making a command works

young flame
#

fuck it then ill use a cmd handler

crimson vapor
#

obvously there is confusion

young flame
#

obviously*

icy skiff
#

Wait i think i knoa what u r talking about but the pic wont send

#

xd

crimson vapor
#

moon, normally people who don't use a command handler just use switch/case

young flame
crimson vapor
#

if statements are inefficient and how else do you plan to check the command

icy skiff
#

is this what u want

mellow kelp
#

ew

crimson vapor
#

switch/case should be used there

young flame
#

thanks

#

thats all i asked for

icy skiff
#

ye this is disgusting but i think its what he wants

young flame
#

i dont fucking need it now

mellow kelp
#

you have successfully spoonfed someone on top.gg

icy skiff
#

im not a javascript fan so my first and only attempt to make a discord js bot i did it that way

mellow kelp
#

congratulations

young flame
#

i already started coding my own cmd handler

icy skiff
#

python all the way

crimson vapor
#

its fine it just looks shit

young flame
#

so it isnt spoon feeding

#

it's pain

icy skiff
young flame
#

bruh i told you why though

#

and then you said makes since

icy skiff
#

why tho

young flame
#

cause

slender thistle
#

sense not since

young flame
#

i tried and failed and once i failed i realized that i was just to stupid to understand it

#

so i never tried again

crimson vapor
#

thats a shit reason imo but you do you

young flame
#

but i did code my own cmd handler and use that

young flame
#

thats like

crimson vapor
#

its been a while since you started

young flame
#

learning lua after using rust for 5 years

#

i lasttried 3 months ago

crimson vapor
#

you're using js, no?

young flame
#

wym been awhile

#

yeah i hadn't used js in awhile so i wanted to try again

icy skiff
#

i mean trying a lot and not managing to make it work is not a really good excuse to do it in a shitty way

young flame
#

i really only forgot cause i was coding a lib

#

well am

crimson vapor
#

yeah, command handler is basically make a map for commands then read a directory, requiring every command, then add it to the map with the corresponding name

#

then you have the function on the message event do all the shit

#

like tests

young flame
#

yes

#

i dont want to do all that shit

#

seems pointless

crimson vapor
#

alr

young flame
#

all your doing is keeping one file under 50 lines

slender thistle
#

Preferences in nutshell

crimson vapor
#

it saves me 50 lines PER command tho

young flame
#

and im not even using one file or everything

crimson vapor
#

because I do perms checks and shit

young flame
#

i code my own way so i don't like people calling my way of thinking stupid

#

i use multiple files i only wanted to know how to do it that way sine im obviously not used to coding in js

#

if i wanted to use a command handler i would have coded one myself

#

thanks anyway though.

latent heron
#

I think instead of you guys going "ew cringe" and "disgusting code you do you"

#

You should provide more constructive criticism into why it's better to program one way than to opt to insults

#

This is how you begin forming programming arrogance and it's never a good thing.

placid iron
#

but then how would i show that i hate javascript? KaguyaPensive

mellow kelp
#

lmfao

latent heron
#

Here's a secret

#

Nobody in the software industry cares what you hate and like about a language

placid iron
#

shhh dont say it, it is a secret

latent heron
#

Either you're hired or you're not.

#

@crimson vapor for example, instead of going "you should use switch/case" without reason and calling their code blasphemous, actually provide a reason why, ie. better organized structure, easier to read code, or code maintainability reasons.

placid iron
#

oh my the whole switch case thing

latent heron
#

I hate that argument

#

A lot

#

Lol

young flame
#

@latent heron thanks

#

❤️

latent heron
#

Like I've been in moonies shoes before

#

This shit super annoying

#

Lmao

placid iron
#

that one video where a dude said that yandere dev should use switch case because it is better (he even said he isnt even sure if it is) and then everyone just started splurting out that too

young flame
#

makes me want to leave ngl

solemn latch
#

Honestly I dont like switch cases

latent heron
#

I feel that

#

Because it doesn't feel like constructive criticism

#

It feels like toxicity

#

You feel like when you ask for code help

young flame
#

if you gave a valid argument i probs would have agreed and tried it

latent heron
#

People will spend more time picking away your code than actually helping solve the issue you're having

young flame
#

i've already dmed ken about it though so i don't think it matters much

latent heron
#

I think as long as you got the help you needed then that's what matters

#

But this inflation of ego I see in many programmers saying that is the right and wrong way to use code practices without explaining why irritate me

latent heron
#

Literally a +/- 2 microsecond difference if you run it in C++

#

Thats how miniscule the practice is

solemn latch
#

Yeah, to me its just switch cases are harder to read than a chain of if statements for me personally.

latent heron
#

I just want to say that I'm not calling anyone out

#

I think people just need to be on the right page on things like that

#

It's good that code is being critiqued, it's bad that you're not giving a sensible explanation of why.

earnest phoenix
#

switch case is effective at a large scale

#

where you need it to jump instead of evaluating comparisons

placid iron
#

if you dont even do ```js
switch thing:
case True:
do true things
case False:
pass

#

who are you

latent heron
#

Honestly its a choice

#

Seen codebases use else ifs so much

placid iron
#

ima be honest i dont even understand how switch cases work btu they need to do comparisons too right

#

like to check if it si the right thing to jump to

solemn latch
earnest phoenix
#

using if else for command handling is generally an antipattern because commands (usually) have arguments and should be approached atomically

tulip ledge
#
app.get("/users/:userId", async(req, res) => {
  let user = await client.db.get(`user-${req.params.userId}`)
  if (user) return res.send(user);
  else return res.send("Test")
});

Why does it not send anything when user is undefined?

latent heron
#

I'm cool with debating the practical implementations of which to use

#

I just wish people gave a valid reason instead of opting to insulting others code.

tulip ledge
#

an object

mellow kelp
#

you probably wanna use res.json(user)

placid iron
#

so like reading it

tulip ledge
#

no no

#

that works

#

but

placid iron
#

it seems like its just an if else chain but cleaner

tulip ledge
#

if user is not defined it doesn't return anything

#

I'm making an API

mellow kelp
#

o

placid iron
#

but with an optional break

tulip ledge
#

and I need to make it so when the id doesn't exist

latent heron
#

Thats the only main difference

mellow kelp
#

you could console.log the user and check what value it has

latent heron
#

And the best part is all the beginner coders or skidders on the internet think that its superior in every way to else ifs

placid iron
#

yeah

tulip ledge
#

it returns undefined

mellow kelp
#

did you console.log it?

#

that should also make sure that the request handler is actually running too

tulip ledge
#

yes

mellow kelp
#

o

#

no idea then tbh

tulip ledge
#

FetchError: invalid json response body at http://127.0.0.1:3000/users/259776081316282368 reason: Unexpected token N in JSON at position 0 I don't get what this error means tho cause if I go into the browser it shows "Test"

solemn latch
#

"Test" isn't valid json

earnest phoenix
#

you should follow RESTful design for your APIs

#

it's a standard

vale juniper
#

Hi,
I made a bot and I want to request all users with a specific role, but it doesn't show all of the users which have the role.
I looks like it only shows the users, which recently sent messages.

latent heron
#

Ah

#

Lines debate

mellow kelp
#

you need to enable the guild members intent @vale juniper

latent heron
#

My favorite

young flame
#
{
}
latent heron
#

Removing lines of code =/= memory allocation

young flame
#

thats json

latent heron
#

I think instead of saying It saves lines of code

#

Say it gives the code a more cleaner approach

cinder patio
crimson vapor
#

sorry

latent heron
#

All good

crimson vapor
#

saves duplicating code

latent heron
#

Yeah thats valid

crimson vapor
#

which is a big issue

#

one function breaks

latent heron
#

Especially when debugging

crimson vapor
#

not a big deal

young flame
#

what code gets dupliated?

#

lol

latent heron
#

Command structures

young flame
#

oh

crimson vapor
#

any permissions checks or cooldowns or shit that makes command handlers actually pog

young flame
#

aso assuming i use one file didn't help

#

assuming*

latent heron
#

Depends i think

young flame
#

i just don't use command handlers

latent heron
#

People usually do separate files to organize it

#

Command handlers are nice imo

mellow kelp
#

they are

latent heron
#

They make formatting commands really easy

young flame
#

i do separate my files

#

just

#

not with command handlers

icy skiff
#

Imagine you have ur code ready, then u find a bug after a couple of weeks without making significant changes on ur code, its really stressfull to find the issue on a messy code

young flame
#

don't they have like

icy skiff
young flame
#

issue at line

latent heron
#

Hmmm

icy skiff
#

Just do whatever u feel most comfortable with

young flame
#

this line at this part

crimson vapor
#

the main reason command handlers are used is to increase performance (maps are faster than if/elseif), stop duplicating code, making shit very scalable, ex

latent heron
#

That argument is a little varying

#

Because the error is dependent

young flame
crimson vapor
#

yea

young flame
#

that's all i wanted to hear form you tbh

#

not its fine but its still shit

icy skiff
#

If it works it works

#

xd

latent heron
#

Tbh could care less if someone is coding their stuff in an impractical way or not. That person is gonna learn how to do better ways in the future

#

Its not like we all learned somewhere and that should be respected

cinder patio
#

There's nothing wrong with pointing out what can be done better, though

icy skiff
#

Criticism is always welcome yes

latent heron
#

The mutual sentiment I've seen from many programmers is as long as you give validity and provide reasoning through critical thinking as to why, then yeah

icy skiff
#

But sometimes it honestly does not matter

latent heron
#

Despite me using classes and cogs in d.py

#

I can still write messy code

#

Using organized methods won't make you an organized programmer

icy skiff
#

"Being organized" is subjective

vale juniper
cinder patio
#

discord.js doesn't cache all members

#

You have to fetch all members in the guild in order to get all members which have a specific role afaik

#

(fetching all members is not a great idea)

old cliff
#
message.guild.members.cache.filter(m => m.roles.cache.has(roleID))```
try this
cinder patio
#

spoonfeeding much

old cliff
#

thats how people learn

#

editing complex code

#

to make it work

cinder patio
#

The code they gave already works, all they have to do is fetch all members

old cliff
#

wait... its correct ?

young flame
#

use like

#

fetch

#

get is cache only i think

old cliff
#

yes

young flame
#

@vale juniper try fetch

#

if you get a fn.bind() error tell me

old cliff
#

I forgot role#members was a thing

cinder patio
#

Their problem isn't with the role, it's with the members. Fetching the role won't do anything, although it is a good practice to fetch it

old cliff
#

instead of fetching all members just set it so they are always in cache this way =>

const client = new Discord.client({fetchAllMembers: true})
young flame
#

lol

old cliff
#

although its not recommended

vale juniper
young flame
#

thats not good tho

old cliff
#

uses a lot of ram

young flame
#

it'll eay your ram

#

eat*

#

lol

old cliff
#

yeah

#

but I do it xD

#

cause I am too lazy to fetch all members

#

everytime

mellow kelp
#

i can practically hear the jet engine sound from your cpu

old cliff
#

also I store all guild invites

#

so it needs all members cached

#

to calculate who invited whom

mellow kelp
#

dammit vscode just crashed

old cliff
#

but I do this to reduce ram usage

#

so it balances out

quartz kindle
#

fetchAllMembers will be removed in v13

#

already removed from master

cinder patio
#

nice

dire obsidian
#

so

#

i was installing quick db

#

and this shows in npm

#

npm ERR! gyp ERR! stack Error: Cannot find module 'psl'

old cliff
quartz kindle
#

fetching them yourself

old cliff
dire obsidian
#

so

#

im dumb but

old cliff
dire obsidian
#

npm i psl?

old cliff
#

psl doesn't exist

dire obsidian
#

so

old cliff
#

so do npm i psl

dire obsidian
quartz kindle
old cliff
#

nice...so that means I should just add fetch members to my loop which each 10 minutes fetches other stuff too?

quartz kindle
#

if you need to fetch all members just put it in the ready event

#

loop over guilds and fetch them for each guild

old cliff
#

yeah that is what i do

#

in ready event

#

after each 15 minutes

quartz kindle
#

you shouldnt need to fetch every 10 minutes, once for each guild should be enough

old cliff
#

what if the bot is added in another guild ?

quartz kindle
#

fetch on guildCreate

old cliff
#

that makes sense

#

time to edit code

lyric mountain
#

Yeah, like, just store member count somewhere then add or subtract it everytime someone joins or leaves

quartz kindle
#

good luck with ram usage tho :^)

old cliff
#

my bot needs that data to properly do invite tracking

lyric mountain
#

Just have a map of guild-members count

solemn latch
#

Is there actually any case which you 100% need every user cached?

lyric mountain
#

It'll be as precise as you can get

young flame
#

also hi sans

#

hi tim!

quartz kindle
icy skiff
#

Hey Tim

mellow kelp
#

hey tim

icy skiff
#

Any idea how to stablish a webhook that requires SSL?

umbral zealot
#

webhooks don't care about SSL, your web server does

earnest phoenix
#

a webhook is nothing more than just a HTTP request

#

^^

lyric mountain
#

Just check the address

#

If it's https then it's ssl mostly

quartz kindle
#

make your webserver support ssl, then change the url to https

old cliff
solemn latch
#

Track the users guilds

#

In the database itself

icy skiff
#

Im using Python's Flask trying to create a webhook with Patreon and it asks for https, ive already created a self signed SSL but Patreon says its an invalid certificate :/

lyric mountain
#

Self signed...

earnest phoenix
#

use certbot

umbral zealot
#

self-signed SSL certificates aren't valid

#

look at letsencrypt

#

free certs are easy

old cliff
#

I could implement that... nice idea

icy skiff
opal plank
#

erm, yes

young flame
latent heron
#

this is an unpopular opinion

#

but i really hate discord bots that rely on you to vote as their way to rate limit their commands

#

angryrage that really gets me

mellow kelp
#

rate limit?

latent heron
#

yeah so like

#

imagine only getting to use a command once every 2 minutes or something

mellow kelp
#

o

latent heron
#

but if you vote for my bot, you get unlimited!!

#

like

#

that's dumb

#

no

young flame
#

lol

latent heron
#

if people like your service, they'll actually vote for your bot

#

it's not the other way around

young flame
#

true

icy skiff
#

Unfortunately, most people won't vote without getting something in return, even If they like ur bot

#

"too much work" u know

latent heron
#

i thought about it for my bot

#

my bot relies on an API that costs money so i thought

#

"i can present two options: 1. those who help donate money for my API fees get more perks,

or 2. if they vote once every 24 hours they get perks for that day"

#

but it feels so cheap

mellow kelp
#

i just kinda give some bot currency to people who vote

#

simple and works

latent heron
#

that's what i was thinking

#

maybe instead of limiting the potential use of it

#

maybe actually grant them new things to use for that limited time frame

lyric mountain
#

Streak system is the secret

mellow kelp
#

i also send them a dm saying that they got money

icy skiff
#

Ye my bot has a rolling system and I just give extra rolls for those who vote

latent heron
#

that will encourage them to go "shit i should keep voting for these perks i otherwise have to pay for"

icy skiff
#

Rate-limiting is kinda wack

latent heron
#

that's my current idea

mellow kelp
latent heron
#

a streak system?

#

how would that work?

mellow kelp
#

i remember playing mobile games every day as a kid just because of the daily rewards KEKW

lyric mountain
#

Yeah, like

#

My bot is all about trading cards

icy skiff
#

Every vote in a roll gives more rewards?

lyric mountain
#

You need money to buy spawned cards

#

So the more you vote, the more you get per vote

latent heron
#

ohh so like

#

it multiplies per vote?

modest maple
#

ooh yeah

lyric mountain
#

Once you reach 7 day streak, you can redeem a gem

latent heron
#

shittt

modest maple
#

the stacking up vote stuff

latent heron
#

that's really smart

modest maple
#

is big stonks

latent heron
#

big stonk

modest maple
#

people have this anally retentive side of them that once they get a streak going they dont wanna loose it more than what the rewards are

latent heron
#

your idea is unironically good

lyric mountain
#

Which can be used to reroll your cards, make them foil, buy gif profile or buy an extra deck storage capacity

modest maple
#

its not really a new idea

latent heron
#

my thing is i need a motive to get people to vote

#

it's not about forcing at hand that i like

modest maple
#

its the idea behind almost every afk game

#

or every mobile game that has time limited progression

lyric mountain
#

Also, I periodically make raffles with each vote being a ticket

#

So people tend to be regulars on top.gg

latent heron
#

hmm

#

So my bot is a translation bot that uses DeepL API

lyric mountain
#

Nonetheless, ratelimiting commands with votes is dumb af

latent heron
#

By default a normal user can use 200 characters per message

#

There's no limit on a "daily character quota"

#

I intentionally did that to let users experiment with exploiting my limit on purpose

#

If you donate $1 on patreon you get 300 extra characters

#

but what if every vote I grant 50 extra characters?

lyric mountain
#

Well, first of all you must note that votes give u no money

latent heron
#

I know

icy skiff
#

Sorry to ask you that but how exactly did u do that patreon integration

lyric mountain
#

So you need a sustainable way to get income

latent heron
#

but the tradeoff is that voting gives reputability

#

which is what i need for ultimately any donations

lyric mountain
#

And apis

latent heron
#

the patreon api is so ass

icy skiff
modest maple
#

patron api sucks big time

latent heron
#

all you need to know is that it works for me 😂

icy skiff
#

That's why Ive been struggling with it

modest maple
#

thats why im writing a different system 😎

#

only issue is time 😔

latent heron
#

my bot's crux is character limits

#

because my API charges per character set

lyric mountain
mellow kelp
#

Why tho

lyric mountain
#

You REALLY need to give them a very good reason to pledge

latent heron
#

if i let people at hand translate super huge messages i can lose money quickly

#

Yeah

modest maple
#

I help for a bot with 5k servers and it makes more than @robust trellis

latent heron
#

my problem is finding a good motive for pledging as a patron

icy skiff
#

The easiest way i thought about was using the patreon bot to give roles on the support server for patrons, and then giving the rewards for those who have the role

latent heron
#

i'm still trying to find ideas on that

icy skiff
#

It works but websockets should be better

latent heron
lyric mountain
#

I never really managed to implement a patreon integration with my bot

#

Like

#

Do they REALLY need to send the whole page's info on each request?

icy skiff
latent heron
#

it's really hard

lyric mountain
#

A simple id-value-blablabla json would suffice

latent heron
#

patreon API is one of the hardest i've yet worked with

#

idk why they made it so difficult to make work

opal plank
#

did i hear shit yet complicated api?

latent heron
#

yup

#

patreon api in a nutshell

lyric mountain
opal plank
#

heheheh time to break it

#

brb

lyric mountain
#

Don't talk about twitch

latent heron
#

NO

lyric mountain
#

Nooooooo

latent heron
#

TWITCH

lyric mountain
#

Too late, he'll talk about it

opal plank
#

look, im trying to find a competitor for the spot of worst big fucking api, ever. period.

latent heron
#

you know it's really bad when YouTube's video feed API is better than Twitch's overall API

icy skiff
#

Would u mind giving me a brief help in the dms with that integration? :/ Just like, How to get started bc i dont even know where to start

latent heron
modest maple
opal plank
#

nono

#

i've worked with both

#

twitch is worse

modest maple
#

nahh

latent heron
#

twitch api gives me anxiety

lyric mountain
#

What did I say?

modest maple
#

Google shitter than twitch

opal plank
#

ive spend around 5h using gmail integrations

#

twitch was a good 2 days of constant work

lyric mountain
opal plank
#

between the shitty docs and the wrong snippets without the proper necessary means to do requests, google was a lot better

latent heron
#

The DeepL API is surprisingly nice tho ngl

#

it's majorly HTTP request based but it's intuitive

modest maple
#

its very rare that you need WS for most api's

latent heron
#

this is the one i wrote

modest maple
#

only really for receiving events

opal plank
latent heron
#

that's true

#

websocks are pretty rare in APIs now

#

it's all about async http

opal plank
#

look, websockets are nice n shit

modest maple
#

i mean they've always been pretty rare

opal plank
#

but when your docs are straight up wrong

#

you get 403's a lot

#

half of their api is dependant on the older version

modest maple
#

they're awful to scale compared to regular HTTP

opal plank
#

which is deprecated

#

they didnt port half of the shit to the new lib

#

its insanely messy

#

currently at the n 1 spot of shittiest api's ive worked with

lyric mountain
#

Is there any other option with api than patreon or donatebot?

latent heron
#

i feel bad for twitch api wrapper devs

opal plank
#

not that i know of kuuhaku

latent heron
#

who try to do that for twitch bot stuff

#

that's torture

modest maple
#

Tabaxi™️ payment paltform™️ for bot devs™️

opal plank
#

yeah i wonder who would be stupid to create twitch bots

#

👀

modest maple
#

2022™️

latent heron
#

i feel like if twitch bots used the new twitch chat reply feature

#

they'd be so much cleaner and efficient

lyric mountain
#

Plot twist: twitch supports no bots at all, it's just regular user accounts

opal plank
#

getting hot here init?

opal plank
#

idk if that was sarcastic, but in case it wasnt, thats a thing btw

#

twitch doesnt differentiate bots and user accounts

latent heron
#

also

#

synchronous requests for APIs aren't too bad

crimson vapor
#

Selfbot bro

lyric mountain
#

Ik

latent heron
#

unless you need multiple iterations being ran at the same time

#

then you fucked lmao

lyric mountain
#

Twitch is all about selfbotting

modest maple
crimson vapor
#

discord isn’t

opal plank
#

though in fairness they varified my bot for special ratelimits within 4 days

#

so, that was nice

latent heron
#

i kinda wish twitch had something similar to discord's support for bots tbh

#

like the UI badge and shit

opal plank
#

already tried sirius

latent heron
#

it kind of does

opal plank
#

not happening

latent heron
#

yeah

opal plank
#

its been on hold for over a year

latent heron
#

twitch's method sucks ass

opal plank
#

i spoke to some twitch devs

#

like, internal staff

lyric mountain
#

Do you know what I wanted? Proper message control

latent heron
#

i mean what should we expect

opal plank
#

its not coming

lyric mountain
#

Like, delete 'n edit stuff

latent heron
#

we're dealing with people from a company that banned the word simp

opal plank
#

there is delete n stuff kuuhaku

#

its IRC based

crimson vapor
#

They banned simp?

#

why

opal plank
#

indeed

latent heron
#

simp, incel and virgin

#

all got banned

crimson vapor
#

that’s stupid

latent heron
#

if a big-time streamer says it then uhh

modest maple
#

cuz those 8 year olds dont want a toxic chat mmLol

latent heron
#

"toxicity of feminine streamers"

opal plank
#

not like we know the demographics is 99% horny teens, and not kids

latent heron
#

i made

#

good for female streamers that simps exist

crimson vapor
#

Yeah have you seen just chatting kekw

latent heron
#

but own up to it at least?

#

like anime weebs being called degenerates

#

just accept it lmao

opal plank
#

funny how simp is banned but calling someone a retard isnt

lyric mountain
#

Imagine streaming a gameplay of simpsons

#

****sons

modest maple
#

banned for nsfw name

opal plank
#

simpons? imagine south park gameplay

crimson vapor
latent heron
#

Discord bans the word retard for partnered and higher servers.

#

but Twitch can't

earnest phoenix
#

whole lotta dev chat going on here

crimson vapor
#

yes

opal plank
#

indeed

modest maple
crimson vapor
#

Want to join?

opal plank
#

we talking about twitch bots

latent heron
#

how can we develop a strap-on

modest maple
#

well

latent heron
#

so i can fuck twitch's ass sideways over?

crimson vapor
#

LOL

modest maple
#

stap-on wise

#

they differ so much

#

also there is so much engineering going into them

latent heron
#

are you owning up to pegging someone/being pegged CF?

modest maple
#

i did some work experience with a manufacture of them bloblul

latent heron
#

which one

#

was it the domination or being dominated

modest maple
#

Neither

latent heron
#

fuck

#

lucky

placid iron
modest maple
#

i was in design not testing

#

though the place i went didnt test them there

latent heron
#

being pegged is a confusing and rather painful experience

modest maple
#

😅 luckily for me

latent heron
#

anyhow

#

i hate twitch api a lot

lyric mountain
#

fuck is just luck but with arms and looking down

latent heron
#

thanks i hate it

#

now i cant unsee the imagination of the letter f fucking uck

lyric mountain
#

Wait until you discover resident evil 6

latent heron
#

I also am looking for code jockeys voluntary programmers who can help me with my project

#

but that won't ever happen blobpain

old cliff
#

if your code is not a mess.... its not code

crimson vapor
#

Nah

west pine
#

Plz help me making a ping command

#

@old cliff u asked me to come here plz help

crimson vapor
#

Long

west pine
#

I am very new

crimson vapor
#

Ling

west pine
#

I just started today

misty sigil
#

dont make a bot as a first porject

odd stratus
#

Did you learn the basics of that programming language before diving into a Discord library to make a bot

west pine
#

No I made a python programmer and a fractal code

#

This is a bot,so I am pretty new

west pine
#

This is the bot

odd stratus
#

I think so 🤔

west pine
#

Help me plz

misty sigil
#

with what bro

west pine
#

How to make ping command

#

In py

crimson vapor
odd stratus
#

Read the documentation on how to get the bots latency?

odd stratus
west pine
#

Do u mind sending the links

odd stratus
west pine
#

Ok

icy skiff
#

But ye read the docs

west pine
#

@icy skiff ok,can u say if my code is good or not?

icy skiff
#

I mean i guess

west pine
icy skiff
#

Oh lord

#

Ok

#

Dont check for commands with the on_message

west pine
#

Then

icy skiff
#

Python makes command handling really easy

west pine
#

I followed a tut and now I am experimenting what I lesrnt

thorny flume
#

help

#

Shard 0's process exited before its Client became ready.

icy skiff
#

Just do
@commands.command()
async def(ctx):
// Ur command goes here

west pine
#

I did

#

I got an error

icy skiff
west pine
#

Yea

#

But there not that many

#

I found 1 series

icy skiff
#

Ill dm u them

west pine
#

Ok

#

Thnx

earnest phoenix
#

agree to dissagree

spare portal
#

when my bot joins a server it sends a welcome message like its supposed to, but if i kick it and add it back it doesnt say the message

#

is that supposed to happen?

crimson vapor
opal plank
crimson vapor
#

@opal plank please inform them of the issue ty

#

All of them

opal plank
#

already did tell them the issue

#

its nothing related to development tho

crimson vapor
#

then they are lost

odd stratus
opal plank
#

being stubborn is the issue, not the code

earnest phoenix
crimson vapor
#

Just use mongoose it’s the exact same as json but safe and non-blocking

opal plank
#

shouldnt be asking for help if you arent willing to listen then

#

¯_(ツ)_/¯

crimson vapor
#

yo Erwin, you up for supplying me with some constructive criticism

opal plank
#

not rn, i gotta ditch in just a couple seconds

quartz kindle
#

yes erwin, criticize the shit out of him

#

:^)

crimson vapor
#

Alr

opal plank
#

be more than happy to trash all over your code later

#

prob ask @quartz kindle meanwhile

crimson vapor
#

Tim doesn’t know ts too well

#

Well not do I

opal plank
#

@quartz kindle learn ts and teach em'

#

all that while im gone

crimson vapor
#

Yes that would be pog

mellow kelp
#

tim the ts teacher

#

tttt

quartz kindle
#

i mean

#

i've never used ts, but i've learned a ton of it just from doing typings and watching people talk about it

crimson vapor
#

You up for reading my code?

quartz kindle
#

if you're up for some bashing, sure

#

:^)

crimson vapor
#

Always bro

#

The big thing is the structure cuz idk how to structure code well ngl

cinder patio
#

No Readme notlikenoot

latent heron
#

readme is overrated

#

mine just points you to a website

quartz kindle
latent heron
#

oh shit

quartz kindle
#

lots of files in there

latent heron
#

@cinder patio you made a programming lang?

quartz kindle
#

google made google

#

:^)

latent heron
#

well no

#

because

cinder patio
latent heron
#

i've done the same thing too

crimson vapor
latent heron
#

i made my own lang to see how it would work out

quartz kindle
cinder patio
#

nice

crimson vapor
#

Shit yes

#

xD

latent heron
#

my code is worse lmao

cinder patio
#

Mine's not statically-typed

crimson vapor
#

saw nothing ok?

latent heron
#

but it had a working lexer, feeder, and error

#

ahh i see

cinder patio
#

and it's also written in c++

earnest phoenix
#

Using slappey where do I edit code in the files to add commands?

latent heron
#

i have more works but they're mainly gists

cinder patio
#

the first time I really used c++ for a serious project

thorny flume
#

@odd stratus I don't know what's wrong with the code

earnest phoenix
#

Is it under commands ;-;

cinder patio
#

I also got lazy with the parser so I just used bison and yacc

latent heron
#

I found my PHP database script you were talking about

quartz kindle
#

@crimson vapor this could make use of fs.promises and also withFileTypes is your friend

thorny flume
#
const { ShardingManager } = require('discord.js');

const manager = new ShardingManager('./index.js', {

  totalShards: 'auto', 

  token: process.env.TOKEN
});

manager.spawn({ time: 180000 });

manager.on('shardCreate', (shard) => console.log(`Shard ${shard.id} launched`));
earnest phoenix
quartz kindle
#

xD

odd stratus
latent heron
#

: )

#

pls dont block me nik

thorny flume
#

@odd stratus

const { ShardingManager } = require('discord.js');

const manager = new ShardingManager('./index.js', {

  totalShards: 'auto', 

  token: process.env.TOKEN
});

manager.spawn({ time: 180000 });

manager.on('shardCreate', (shard) => console.log(`Shard ${shard.id} launched`));
crimson vapor
quartz kindle
#

require("fs/promises") or require("fs").promises

#

then await readdir(folder, { withFileTypes: true })

#

withFileTypes gives you DirEnt objects instead of file names

#

Dirent contains a method isFolder()

#

so no need to use stats to see if they are folders or not

crimson vapor
#

Ah

odd stratus
crimson vapor
#

Tim if you say anything else link the message in dms cuz my phone is almost dead

earnest phoenix
#

that moment when you know nothing about JS but know java so you just go in guessing. I mean just looking at the code it seems easy to read so, easy language???

thorny flume
#

ok @odd stratus

odd stratus
#

Hmm I should try making a bot in TypeScript Think

modest maple
#

Knowing one language well makes learning every language after that alot easier

earnest phoenix
earnest phoenix
#

js seems like a breath of fresh air

crimson vapor
#

Are you ok?

#

THATS FUKCING SYNC

#

not a callback

earnest phoenix
#

no errors hollering at me every time i space something wierd

modest maple
earnest phoenix
#

I know the basics

latent heron
#

if it makes you guys feel better

#

i spent a majority of my programming career knowing only PHP

earnest phoenix
#

I just wrote a new command to speak. Is using Slappey a good idea?

latent heron
#

and learned every other lang off of my PHP knowledge

earnest phoenix
modest maple
#

I generally would pick rust over c#, c# over java and java over js

latent heron
#

i've been in hell's programming language

#

to know the pain of it 😂

earnest phoenix
#

g-code is something i never want to see in my life again

crimson vapor
earnest phoenix
#

geometric code

#

widely used for operating cnc machines

spare portal
#

how do you get the thumbnail to appear in an embed? im using a direct imgur link

earnest phoenix
#

discord or imgur have been having issues so the images don't show for whatever reason

crimson vapor
#

Ah

spare portal
#

oh okay

earnest phoenix
#

try using another image hoster

earnest phoenix
spare portal
earnest phoenix
#

don't know

#

So me being a idiot and doesnt know what hes doing wrote this.....and it doesnt work🤣

#

Im a certified idiot

#

cause what do I do 😦

#

lmao i have no idea

#

im a certified idiot too

thorny flume
#

@odd stratus I use repl.it and this host has the index.js folder already generated and cannot be deleted or renamed. I put the fragment code in the index.js file to be started first and then I extracted the code that runs my bot, it didn't give an error, but it only gave the console (fragment 0 released)

earnest phoenix
#

but i do diffrently

#

Yeah im using slappey lol

#

And the test command works so I copied it 2 times, first by typing, then by ctrl C and V

#

and it doesnt work

#

See certified idiot

#

nvm

#

i am a real idiot

#

XD

#

You know how you trn your computer on and off again, i forgot to save! Sorry for wasting time

#

=[

odd stratus
earnest phoenix
#

i put my bot on a new server and it takes like 3-5 seconds for it to send a message back

thorny flume
#

yes @odd stratus

#

@odd stratus I think the error was not in the code, but in the way I put in the files the shards have to start first that the client

earnest phoenix
#

i put my bot on a new server and it takes like 3-5 seconds for it to send a message back

thorny flume
#

thank you so much for your help helped me a lot

quartz kindle
#

writeFileSync does not have callbacks, its a synchronous function

#

it either returns, or it throws an error

restive furnace
#

corrupted heap errors be my bae

sand salmon
#

how i do to get user by id, but user is not on a guild
discord.js

stark abyss
#
setTimeout(reset, midnightTime())
 function reset(){
    setInterval(function(){ 
      var d = new Date();
      var today = d.getDay();
      if(today == 6){
        //weekly reset here
      }
      //daily reset here
    }, 86400000);
}
function midnightTime() {
  var midnight = new Date();
  midnight.setHours( 24 );
  midnight.setMinutes( 0 );
  midnight.setSeconds( 0);
  midnight.setMilliseconds( 0 );
  return (midnight.getTime() - new Date().getTime());
}

This is what I have right now, but the problem is that setInterval function runs after that milliseconds so it will skip the first time the function is called I don't know how to fix this

stark abyss
restive furnace
#

put that reset function inside setTimeout

sand salmon
stark abyss
#

probably wanna await it

stark abyss
earnest phoenix
#

it's still going to run after the interval hits that amount of ms

#

make the callback of setTimeout its own function

#

call the function outside of the setTimeout

#

then pass the function to setTimeout

stark abyss
#

if I call the function outside of the timeout it won't be consistently at midnight no?

earnest phoenix
#

i'm confused as to what your goal is

#

execute it at exactly midnight?

stark abyss
#

I am trying to have it do something once every day at midnight, and once a week at midnight as well

#

yeah

earnest phoenix
#

you need to calculate the time until midnight, put that in a setTimeout

stark abyss
#

yeah that's what the midnightTime() is

stark abyss
#

the reset function gets executed midnight, but because of setInterval the code inside waits 24 hours more to be executed

#

I don't want that, I want it to be executed immediately when the reset function is called but I also want it to repeat everyday

earnest phoenix
#
//pseudo
//copypasting this won't work

function intervalfunc() {
  return "pp";
}

function reset() {
  setTimeout(() => {
    intervalFunc();
    setInterval(intervalFunc, that big ass number);
  }, midnightTime());
}
#

in this context, reset should only be called once

stark abyss
#

oh

#

that's what you meant

#

okay that looks good thank you

young scroll
#

helo how could i do one !givemoney bot?

earnest phoenix
#

pray to discord gods

pale vessel
#

pp

earnest phoenix
#

whelp thanks for pointing out my stupid

quaint wasp
#

guys

#

And yall kept telling me dont do sharding till I get like 1k servers or so

#

And I only had 11

#

welp..

#

look at this:

restive furnace
#

async != callback != sync

#

if you'd want the async version: js const fs = require("fs/promises"); //... use fs like here normally except await it, but why though if you're not processing files in P A R A R E L L

cinder patio
# quaint wasp

You can shard anytime, but you get no benefit from it, even worse - you have multiple websocket clients, which use way more resources

quartz kindle
#

technically the callback version is async

#

everything that is not sync is async

#

promises are just a form of async

quaint wasp
#

oh

restive furnace
#

but if you use lots of callbacks, it's c a l l b a c k h e l l then

earnest phoenix
solemn latch
earnest phoenix
#

what is it even saying is wrong

#

too high a vocab

earnest phoenix
#

hence why im rewriting

cinder patio
#

for example:

#
if (expression) let a = 50;

Is wrong, because a will never be accessible

earnest phoenix
#

hmmm ok ty

sudden geyser
#

An example would be using a let statement after an if block without the braces. Without the braces, a block like that will only accept 1 statement.

earnest phoenix
# cinder patio You cannot use let/const in a let statement without a code block
if(!fs.readdirSync(this.dir).some(d => d == "data.json")){
            let  data = {
                "joinMessage": "[user.ping] has joined, using invite [invite], created by [inviter.ping] who has [inviter.total] invites.",
                "leaveMessage": "`[user.tag]` has left, [inviter.ping] now has [inviter.total] invites.",
                "banMessage": "[user.name] was dumb and got themselves the big ban hammer. [inviter.ping] now has [inviter.invites] invites.",
                "embed": false,
                "joinchannel": null,
                "leavechannel": null
            }
            fs.writeFile(this.dataDir, JSON.stringify(data, null, 2), (err) => { 
                if (err) throw err;
                console.log('Saved file to' + this.dataDir);
            })
        }```
#

so i have code

cinder patio
#

aaaand?

earnest phoenix
cinder patio
#

try it, looks good to me

earnest phoenix
#

thats the code thats erroring tho

cinder patio
#

that code looks correct, are you sure it's coming from there?

earnest phoenix
#

positive

#

it says line 28 in that file

#

that is line 28

cinder patio
#

That's really odd

earnest phoenix
#

thats me

#

i get the wierdest errors

#

my discord bot is delayed by atleast 5 seconds

#

any recommendations

#

i have a good enough server\

#

it could be the code

#

or something

#

idk

#

@earnest phoenix if you have a lot of startup items it will take a moment

#

mine almost takes a minute and its running on a 9700k

solemn latch
#

sounds like its commands taking 5 seconds

earnest phoenix
#

^^

#

@cinder patio figured it out. i had a double space between let and data

solemn latch
#

ratelimited?

earnest phoenix
#

bot is delayed a bit

#

could be

#

i have no idea why

cinder patio
#

you probably forgot to save or something, because there's no way the error is coming from there. The error only occurs if you have the following:

if (...) let ...
for (...) let ...
#

And I highly doubt an empty space would cause such an error

earnest phoenix
#

and yes it was saved

#

hmmm yes exe not sus at all

#

huh

earnest phoenix
#

why you keep del.eting

#

i gotrchu

#

in a rar

#

this isnt that exe

#

@earnest phoenix send the executable file

#

tha you uploaded in my dms

#

there dm it to me

earnest phoenix
rustic nova
#

@earnest phoenix Don't share things here that could potentially be malicious. This is your only warning.

#

Even if it wasn't malicious, just don't do it niko_happy

earnest phoenix
#

(node:3304) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open './db/data/guilds/731342408293285928/members/627660958499864586.json'

#

i dont understand my life

cinder patio
#

json database moment

earnest phoenix
#

i'm interested in what it is lol

earnest phoenix
#

damn

#

i got hxd and IDA ready lmfao

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

earnest phoenix
#

shoot it

modest maple
sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

earnest phoenix
#

hi guys

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

1.a - well this is kind of invalid because you cannot assign a static class to a variable
1.b - no, you should avoid the static pattern in the first place, it defeats the point of OOP and creates god classes. you should have something like ```cs
public class Facts
{

private YourDeserializer _deserializer;

public Facts()
{
//fill the data here
//i.e
_deserializer = new Deserializer();
}
}

//in another file
internal class Deserializer
{
//you get the point
}

//in end user's code
var facts = new Facts();
facts.GetRandomFact();

1.c - use json if you're having dynamic content, otherwise just fill the array manually
2 - yes, the less dependencies the better, the only excuse is that the system.text.json is garbage in some cases so you could use newtonsoft's json package
#
Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
#

why i get this error?

#

did you read it

#

yea?

#

so, what do you not understand about it

#

how could i fix it?

#

🤷‍♂️

#

that error is worth dogshit when you don't provide your code

sage bobcat
mellow kelp
sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

earnest phoenix
#

do public class, not static

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

this also allows super easy integration with DI

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

yes

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

slender wagon
#
 for (const warning of results.warnings) {
          const { author, timestamp, reason } = warning
          reply += `By ${author} for "${reason}". ${timestamp}\n\n` 
        }


        message.reply(reply)
        const embed = new MessageEmbed()
        .setAuthor(`Warnings for ${target.username}#${target.discriminator}`)
        .setThumbnail(message.guild.iconURL())
        .setTitle(`Warnings`)
        .setColor(`YELLOW`)
        .addField(`${reply}`, 'hi')
        .setFooter(`Boop!`)
    
         message.channel.send(embed);

This is a command that lists the warnings for a certain user. But embed field seems to be limited at 256 chars, is there a way i could get through this?

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

slender wagon
#

yeah i see but like what could i do to send the warning lists

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

slender wagon
#

to list it on descritpion?

sage bobcat
#

One message removed from a suspended account.

slender wagon
sage bobcat
#

One message removed from a suspended account.

slender wagon
#

alright i'll try that real quick ty

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

slender wagon
#

yeah i can set a limit on the warnings displayed or something

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

slender wagon
#

aightys ty

earnest phoenix
sage bobcat
#

One message removed from a suspended account.

lyric mountain
slender wagon
sage bobcat
lyric mountain
#

embed body can go up to 2048 chars, fields up to 1024

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

lyric mountain
#

hard limit is somewhere near 4k iirc

earnest phoenix
#

6k

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

you then don't need it

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

it was just an example of how you should structure your class fields

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

i checked the code

#

and i had

if(test1){
  res.render('tst')
}
if(test2){
  res.render('tst')
}
#

or something like that

#

and both relations was true so yea

#

thank you for idea

#

:}

slender wagon
earnest phoenix
#

How to I setup the bank part of a bot?

summer torrent
#

bank part?

earnest phoenix
#

Like how ZeroTwo tracks your coins and gives them to you for doing ZT! Work?

lime current
#

node:internal/modules/cjs/loader:926
throw err;
^

Error: Cannot find module 'discord.js'
Require stack:

  • C:\Users\Admin\bot\index.js
    ←[90m at Function.Module._resolveFilename (node:internal/modules/cjs/loader:923:15)←[39m
    ←[90m at Function.Module._load (node:internal/modules/cjs/loader:768:27)←[39m
    ←[90m at Module.require (node:internal/modules/cjs/loader:995:19)←[39m
    ←[90m at require (node:internal/modules/cjs/helpers:92:18)←[39m
    at Object.<anonymous> (C:\Users\Admin\bot\index.js:1:17)
    ←[90m at Module._compile (node:internal/modules/cjs/loader:1091:14)←[39m
    ←[90m at Object.Module._extensions..js (node:internal/modules/cjs/loader:1120:10)←[39m
    ←[90m at Module.load (node:internal/modules/cjs/loader:971:32)←[39m
    ←[90m at Function.Module._load (node:internal/modules/cjs/loader:812:14)←[39m
    ←[90m at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)←[39m {
    code: ←[32m'MODULE_NOT_FOUND'←[39m,
    requireStack: [ ←[32m'C:\Users\Admin\bot\index.js'←[39m ]
    }
#

help

earnest phoenix
lime current
#

yes

#

I added new options and then went back and the bot broke

earnest phoenix
#

I think you might have messed up something in the slappey files but idk

lime current
#

ok

earnest phoenix
#

I got the same problem with loader.js. Still didn't fix it.

#

Super annoying

lime current