#development

1 messages · Page 2016 of 1

sharp saddle
lyric mountain
#

put both in the same div

sharp saddle
sharp saddle
#

but...

#

another bug topggBurbur

quartz kindle
#

tcp is a streaming protocol bro

#

yep you cant, why would you want it anyway?

lyric mountain
sharp saddle
split hazel
#

honestly its just easier

#

instead i have to scan the whole string for a "end of data" character or whatever

#

because it may be clamped

lyric mountain
#

u need to define a maximum size for it

quartz kindle
sharp saddle
#

don't have it

split hazel
#

delimiters i want to avoid

#

and is the length prefix client sided or server sided

quartz kindle
#

both

quartz kindle
#

server adds a length header to the beginning of each packet, client reads the length header, then reads length data

split hazel
#

im using c++ as the server and js as the client

#

you see im making a server based database from scratch for my programming project

lyric mountain
#

im using c++
my condolences

quartz kindle
#

use a header, its probably the best way

#

thats how websockets do it as well

split hazel
#

i was gonna use c originally until i realised there are no namespaces or built in map headers

quartz kindle
#

lel

split hazel
#

to receive data on the c++ server im using recv

#

hold on

#

it takes in a buffer and the "maximum length" i presume parameters

#

then the buffer gets populated

#

i can settle for a delimiter but i want to avoid that

#

tho there comes up another issue

#

what if transmitted data accidentally contains the delimiter

quartz kindle
#

exactly

#

thats why delimiters are not good

#

headers are better

split hazel
#

dont know how i would do that

#

especially since my tcp knowledge isnt 100%

#

is there a nodejs example somewhere

#

is there really not a protocol or at least a flag which allows TCP not to be a "streaming" protocol

#

its a pretty demanded feature

quartz kindle
#

i mean

#

you literally add something to the data itself

#

for example, if you have a buffer of length 200

#

you send buffer([200]) + buffer

#

like

#

define how many bytes you want to reserve for the header

split hazel
#

do you mean prefix the data with the size

quartz kindle
#

yeah

#

lets say your header is always 4 bytes

#

so you write the data size in those 4 bytes as a unit32

#

then follow it with the actual data

#

same thing to read it, read the first 4 bytes as uint32, then read X length

split hazel
#

sounds good

#

and to add a terminator for each data (for example when printing a string) i can pretty much separate the data by 0 and add a check like if (buffer[end_of_data] == 0 && buffer[end_of_data + 1] != 0)

quartz kindle
#

you dont need a terminator

#

you have the length

split hazel
#

oh no

#

well i kind of do

#

a lot of functions dont accept the length of data

#

they rely on the terminator

#

and if you dont have one it will just keep reading

quartz kindle
#

are you using null terminated C strings?

#

then read X length and add a null terminator yourself

split hazel
#

yeah but i might overwrite a clamped packet by doing that

#

which is why its probably a good idea to end each transmission with an explicit 0 from the client

quartz kindle
#

you want to avoid buffer copies?

split hazel
#

yeah i do

#

they're slow

quartz kindle
#

then yeah i guess

split hazel
#

i can also use the length of all the data transmitted to determine if theres a clamped packet

#

so i dont have to rely on checking the buffer for additional data since it contains data from previous transmissions

#

and i also dont want to clean the buffer each time

#

yeah i can but meh

quartz kindle
#

you need to treat the incoming data as a stream

#

while data is available check if available length >=4, if yes X = read uint32, check if available length is >= 4 + X, read from offset 4, set offset to 4 + X, while data from offset 4+x is available, repeat...

#

the lengths will tell you about the sizes of the messages, there is no need to check the buffer contents

split hazel
#

yeah figured

#

worst case scenario to simplify things I'll just malloc packet sizes and use memcpy

#

with safety checks of course:)

#

don't want any buffer overflows

quartz kindle
#

use pointers

#

and move them through the stream

#

well i've never done this with c++ so idk how it works exactly

#

but i did it in js

split hazel
#

yeah no worries I have everything planned in my head

#

I've manipulated raw data many times before (dont ask how)

quartz kindle
#

xD

#

out of curiosity how does c++ give you the data?

#

does it give you pieces of malloced buffers?

#

or pointers to stack arrays?

split hazel
#

you create a buffer of your own size somewhere (I chose 1kb) - you then provide the buffer pointer and size of buffer to a function which blocks until data is available

#

not sure what happens when packets exceed that buffer size (will try tomorrow)

quartz kindle
#

ah i see

#

they should be throttled

#

if no more buffer is available, the stream will pause until space becomes available

#

ie download speed drops

#

if a single message is bigger than the entire buffer, then you probably need to copy + free until you assemble the entire thing

split hazel
#

not sure if two clamped packets will still be clamped if the buffer size is exceeded

#

if not I can just return an "exceeded size" error

#

is clamping sending side or receiving side

#

actually I'd imagine the receive function would return an error status code if that happens

quartz kindle
#

tcp has no knowledge of your packets, it only knows the tcp protocol packets, which are set by the MTU or some shit, so it can give you 1 packet, 2 packets, or 1.5 packets, or 0.5 packets at a time

split hazel
#

💀

#

do they by any chance negotiate a max size

quartz kindle
#

The absolute limitation on TCP packet size is 64K (65535 bytes), but in practicality this is far larger than the size of any packet you will see, because the lower layers (e.g. ethernet) have lower packet sizes.

The MTU (Maximum Transmission Unit) for Ethernet, for instance, is 1500 bytes. Some types of networks (like Token Ring) have larger MTUs, and some types have smaller MTUs, but the values are fixed for each physical technology.

split hazel
#

great no clear answer 💀

#

I hate the low level world

#

so I should generally set the buffer size to 64kb just to be safe?

#

well I don't know what happens yet when the function size is exceeded

quartz kindle
#

TCP deals with segments instead of packets. Each TCP segment has a sequence number which is contained inside a TCP header. The actual data sent in a TCP segment is variable.

There is a value for getsockopt that is supported on some OS that you can use called TCP_MAXSEG which retrieves the maximum TCP segment size (MSS). It is not supported on all OS though.

boreal iron
#

Tim quoting the entirety of Wikipedia again

split hazel
#

tis why I love him

split hazel
#

I can use the size from that function to malloc a nice buffer

quartz kindle
#

generally its better to have a larger buffer

#

if your buffer is too small, you will need lots of copies to rebuild the message, and the low level api needs lots of additional book keeping

#

in theory, the more memory you can reserve for it, the less work it needs to do

#

also, im pretty sure it uses circular buffers, so for example if you give it a buffer of size 500, and you receive 3 messages of size 200, on the third message it will need to clear the first 100 bytes from the buffer to continue writing

#

if you give it a buffer of 8mb, you can write a lot more before it will start overwriting the beginning

split hazel
#

we'll find out tomorrow freerealestate

#

and I don't think so in this case

#

the function is way too simple to support that

#

unless it requires you to call it multiple times

#

goodbye for now 🙏

quartz kindle
#

see ya

split hazel
#

you were very useful

#

never disappoint me 😢

earnest phoenix
#

8.5.0 Wth

sterile lantern
#

why does it check for logo if i return the function when there is no logo1

wheat mesa
#

because data[0] is undefined, not logo1

sterile lantern
#

well if there isnt logo1 to begin with, it shouldnt continue with the rest of the code

quartz kindle
#

but there is logo1

sterile lantern
#

logo1 is undefined

quartz kindle
#

and there is logo1.data

sterile lantern
#

i purposely made it undefined

#

by setting the thing to 0

quartz kindle
#

well thats not what the error says

sterile lantern
#

one sec

#

oh bruh it just returns empty data

#

k ill just make it return if there is no logo.data.data[0].imageUrl

quartz kindle
#

you can always use ?.

#

logo = logo1?.data?.data?.[0]?.imageUrl

#

if(!logo) return

sterile lantern
#

oh yeah those

#

alr

#

ty

earnest phoenix
green kestrel
#

log in?

fickle arch
lucid prawn
#

how to make your bot record when someone joins a vc? discord.js

craggy pine
#

Record?

lyric mountain
#

Tos moment

austere surge
#

privacy moment 😑

lucid prawn
#

lolllllllllllllll

#

I want it to record me and my friends vc's

austere surge
#

why dont you do that with any recording software and get arrested that way instead

lucid prawn
#

lol

#

umm

#

or I can make a record command

#

like a normal person

austere surge
#

no? what person would do that

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.

wheat mesa
#

sounds like a pain in the ass

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

lucid prawn
#

I mean I made I whole thing to stop my bot from crash and send to a channel

#

I think I can do this

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

lucid prawn
austere surge
#

what?

#

almost every npm package meant for discord is either crap or really easy to do

sage bobcat
#

One message removed from a suspended account.

lucid prawn
#

idk bored

quartz kindle
#

yeah, why not a dicksword bot

lucid prawn
#

good idea

austere surge
wheat mesa
#

but if you're up to the challenge, go for it

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.

austere surge
#

and probably nobody can help

sage bobcat
#

One message removed from a suspended account.

lucid prawn
#

Ok

#

Thxs for the support

civic scroll
#

what

#

what happened

snow vector
#

Ok so i dont know if this will make sense but on my site i changed the background, it wouldnt change so i made a new folder and it worked. Whenever i try to switch the name of the folder back to the original name it dosnt work/stays the old background even tho that link isnt in the code at all

civic scroll
#

what

snow vector
#

join vc if you can its really hard to explain

civic scroll
#

look at link tags in the website html

#

<link rel="stylesheet" href="...">

snow vector
civic scroll
#

or you can look in the background specifically and search for its selector throughout your projrct to see how it's defined

civic scroll
snow vector
#

i already did all that when i move all the files from one folder to another one it works like normal

civic scroll
#

also idk your project struct

#

wait lemme boot my pc uo

snow vector
#

ok

astral heron
#

quick question, my bot is updated to v13 with slash commands but im getting discord api error missing access when bot trys register commands and i dont know if there is any solution to fix this ?

austere surge
#

give it access

astral heron
#

bot has on every server permissions

austere surge
astral heron
#

i check it already it says that bot need to have applications.commands scope, so that means bot need to rejoin every server and there is no other solution??

snow vector
#

yes

astral heron
#

intresting

#

so how other big bots have already implemented slash commands without that scope.. like mee6 etc?

snow vector
#

unsure but i had to have my bot rejoin all the servers

austere surge
#

i think you can just redo the invite

#

unsure if you need to kcik it

astral heron
#

🤔

neat ingot
#

anyone else do crap like that? randomly name every day items to be more informative? 😄

lament rock
civic scroll
# neat ingot

EnvironmentProcessorSingleton
AbstractEngine
Visuals
Motors
Main

pearl trail
#

fr 💀

neat ingot
#

yea the stack overflow filters are not good.

dry imp
#

holyshit so ugly

atomic kindle
dry imp
#

wait if i see that with 3d glasses, will it become normal?

rustic nova
#

The pain will expand into the third dimension

rose warren
#

I've made 3D stuff like that before it's pretty simple

split hazel
#

@quartz kindle yeah it just spreads the message across multiple packets

quartz kindle
#

dont use .map

split hazel
#

@quartz kindle hlep

#

js aint low level so

#

how would i add a 16 bit number to the start

#

im using something like await client.write("test");

quartz kindle
#

client.write(Buffer.from([byte1, byte2]))

#

byte1 = number >> 8
byte2 = number & 255

#

you can do Buffer.concat(Buffer.from([byte1, byte2]), Buffer.from("test"))

split hazel
#

:o

#

thanks

split hazel
quartz kindle
#

ye

split hazel
quartz kindle
#

you're using browser js?

split hazel
#

node

quartz kindle
#

then use buffers

#

i mean, you can use uint8 as well you want to

split hazel
#

actually yeah i'll use a uint array its easier

#

i'll make a fixed size uint array

#

but how would you convert the string to that format

#

instead of iterating manually

quartz kindle
#

but Buffer.from is much faster

split hazel
#

ah right i can use that

quartz kindle
split hazel
#

thought so thank you:)

neat ingot
#

whats up gamers 😘

fickle arch
#

How do you use mongodb for economy system data saving.

neat ingot
#

give your mongodb user objects some properties like this

#

use some methods like this:

#

then save.

simple stump
#

How could I make a string of characters with the same length? Ex.

// Given the following:
let name1 = "I exist."
let name2 = "hello."
let wins1 = 2654;
let wins2 = 13;

// Format the text to be the same length:
let leaderboard = 
"1. I exist   |   2654" +
"2. hello     |     13"
;

// My goal is this:
let leaderboard2 =
`1. ${name1} | ${wins1}` +
`2. ${name2} | ${wins2}`
;
// Returns the format of leaderboard.
quartz kindle
#

${name1.padEnd(10)} | ${wins1.padStart(10)}

bright thorn
#
setTimeout(() => {
  function alert(message) {
    var wrapper = document.createElement('div')
    wrapper.innerHTML = '<div class="alert alert-pink text-white' + ' alert-dismissible" role="alert">' + message + '<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button></div>'
  
    alertPlaceholder.append(wrapper)
  }
  if (alertTrigger) {
    alertTrigger.addEventListener('click', function () {
      alert('Dashboard is under construction')
    })
  }
}, 2000);
#

timeeout not working

#

🥲

#

anyone can help

cinder patio
#

How's it not working

#

what's happening?

tawny swan
#

heyhey could anýone help me with a unban command i really ran out of ideas how i could do it :')

quartz kindle
#

show code

tawny swan
#
async def unban(ctx, *, member):
    banned_users = await ctx.guild.bans()
    
    member_name, member_discriminator = member.split('#')
    for ban_entry in banned_users:
        user = ban_entry.user
        
        if (user.name, user.discriminator) == (member_name, member_discriminator):
             await ctx.guild.unban(user)
             await ctx.send(f"*Unbanned*: {member.mention}")```
I tried this code from the internet because mine was a bit yk messy
#

and it shows me an error like
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ValueError: not enough values to unpack (expected 2, got 1)

quartz kindle
#

you shouldnt be doing this with username and discriminator

#

you should be using user id

earnest phoenix
#

Why does discord.js rename something with every update?

quartz kindle
#

welcome to djs

earnest phoenix
#

I've been using discord.js since v11 and had to rewrite my bot with every new update lmao

quartz kindle
#

they wanted to separate an incoming embed object from an outgoing embed

earnest phoenix
tawny swan
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.

quartz kindle
#

lmao

sage bobcat
#

One message removed from a suspended account.

quartz kindle
#

do slash commands then

sage bobcat
#

One message removed from a suspended account.

lament rock
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.

sage bobcat
#

One message removed from a suspended account.

quartz kindle
#

:^)

quartz kindle
#

and use a raw http server

#

that way you wont ever need to update again

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

sage bobcat
#

One message removed from a suspended account.

lament rock
#

I still have a need for my websocket, so I pipe all my interactions down the socket instead of needing to scale and load balance the http server handler

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.

quartz kindle
#

penis

sage bobcat
#

One message removed from a suspended account.

neat ingot
#

your dockerfile is super out of date

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.

neat ingot
#

ahh ok lol

earnest phoenix
sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

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
sage bobcat
#

One message removed from a suspended account.

neat ingot
#

did you ever receive a message by chance? 😄

earnest phoenix
#

more more more

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

neat ingot
#

wth is this? KEKW

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

neat ingot
#

idk i think the first one you linked

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

neat ingot
#

it should remember users first random guess

#

so it will always quote that size

#

then people could use it to flex if they had a big one 😂

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

neat ingot
#

yea thats what i mean, just save which user id has which size 😄

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.

neat ingot
#

why did you rewrite things in c#?

#

i love mongodb, but ive been toying with the idea of using sqlite and sequelize for a db solution in the concept idea im building for my next app 😛

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.

neat ingot
#

fair enough. i've been learning a bit of c# in a class ive been doing, seems decent enough to write

sage bobcat
#

One message removed from a suspended account.

neat ingot
#

not terribly ugly to write with i mean 😛

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.

neat ingot
#

eww no

#

i still do same line brackets

sage bobcat
#

One message removed from a suspended account.

neat ingot
#

ew uu

#

EWW

#

😛

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

neat ingot
#

be in awe of my nub c#

#

wrote that after my first c# class, lecturer still hasnt caught up with the concepts i used there. learning is way too slow in classes lol

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

neat ingot
#

no

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

sage bobcat
#

One message removed from a suspended account.

neat ingot
#

if it was 'should' then the compiler would enforce it

#

it is an option, that is widely used, to be fair

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

neat ingot
#

i've never had any warnings for it 0o

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.

neat ingot
#

oh yea I know it says that in the conventions, but its still optional

#

its just thats what the creators/maintainers of the language would preffer

#

unless the language explicitly enforces it, its optional

#

granted, if your writing some code thats being submitted to a well used package, you should conform to that packages standards/conventions as each may be different

#

but if your writing code for your own personal projects, that may never be seen by anyone, write it the way you want. as long as the language allows for it, and its not incredibly ridiculous spaghetti

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

neat ingot
#
sage bobcat
#

One message removed from a suspended account.

neat ingot
#

i've seen very little js conforming to those standards

sage bobcat
#

One message removed from a suspended account.

neat ingot
#

2 space indentation? what? lol

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

neat ingot
#

yea fair enough, some ide/extensions will enforce standards on you

snow vector
#

html

wheat mesa
#

There is no “easiest” language

#

And html is not really a programming language :p

#

If you’re a beginner, start with javascript or python

boreal iron
#

got ya ass

wheat mesa
#

Fair

wheat mesa
# neat ingot

Also isn’t it better to check for null with the is operator?

#

Or is that just syntactic sugar

neat ingot
#

no idea on that one lol, it could very well be better

earnest phoenix
#

hey, what're your thoughts on this and how can it be improved?

sudden geyser
#

It's confusing

#

And seems to have a lot of duplication/redundancy

earnest phoenix
#

how's it confusing

sudden geyser
#

Why is the user who "joined" repeated three times and features in the title? Assuming the invite is scoped to the guild, why state the guild? Was the invite provided as an option (if so, is the link necessary)? Assuming the footer time is the time the command was run, why bother stating that when Discord implicitly tells the user?

There are other things I think are unnecessary but purely for ascetics/style so don't have much of an issue with, such as stating the bot in the footer.

earnest phoenix
#

better?

sharp saddle
#

BTS bot? 🗿

solemn latch
#

using djs? or just making a request to it?

wheat mesa
#

You can store the webhook’s id in a database so you know which webhook you want to use when you fetch the webhooks in a channel

rocky dagger
#

can i ask about mongoosedb here?

solemn latch
#

sure

rocky dagger
#

how can i do this but so i can have as many user arrays as i want and rename have user as any name i want? js const breederSchema = new mongoose.Schema({ _id: mongoose.Schema.Types.ObjectId, guildId: String, user: Array });so the object ends up looking something like this { "randomname1": [ "wyv", "giga", "pt" ], "randomname2": [ "rex", "owl" ] }

sage bobcat
#

One message removed from a suspended account.

rocky dagger
#

is that understaneble?

sage bobcat
#

One message removed from a suspended account.

rocky dagger
#

it is?

sage bobcat
#

One message removed from a suspended account.

rocky dagger
#

how

earnest phoenix
sage bobcat
#

One message removed from a suspended account.

wheat mesa
#

I don’t think storing previous names is against ToS as long as the user has a way to delete it or opt into it

rocky dagger
#

i want my database to look like the second codeblock

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

wheat mesa
#

Unfortunately I don’t believe so

rocky dagger
#

and i want to have the option to have any amount of users

wheat mesa
#

You could probably use autofill to give suggestions on IDs

#

I’ll look at the docs rq, but I don’t believe there’s an option for slash commands

rocky dagger
#

.addChannelOption(option => option.setName('channel').setDescription('Select a channel'))

#

that?

wheat mesa
#

Oh there is I just saw in the docs

#

Interesting

#

Must be relatively new, can’t remember seeing that the last time I worked on bots

rocky dagger
#

yes...

#

why?

#

is it a bad way?

wheat mesa
fluid garden
#

Need help

#
const puppeteer = require('autocode-puppeteer');
const url = context.params.event.content?.split(' ').slice(1).join(' ').trim();

if (!url)
  return lib.discord.channels['@0.2.2'].messages.create({
    content: Please provide url of the website, \.getweb <url>`,
    channel_id: context.params.event.channel_id,
  });

let browser = await puppeteer.launch();
let page = await browser.newPage();
await page.goto(url, {
  waitUntil: 'networkidle0',
});

let screenshot = await page.screenshot();
await browser.close();

return lib.discord.channels['@0.2.2'].messages.create({
  content: `,
  channel_id: context.params.event.channel_id,
  file: screenshot,
  filename: 'screenshot.png',
});```
#

Need to make this ckmmand

#

Just Fri nsfw

#

Plz hel0

#

Help

wheat mesa
#

What

rocky dagger
#

ik, it just makes it a bit more compact and im used to seeing it like that now so its fine

fluid garden
wheat mesa
#

Then check if the channel is nsfw before running your command

fluid garden
#

No can't

#

It will be globaly

wheat mesa
#

What library is that?

fluid garden
#

What library

wheat mesa
#

Oh

fluid garden
#

Ya

wheat mesa
#

That explains it

fluid garden
#

?

wheat mesa
#

Not sure how to help you then, never used auto code and I never plan to :p

fluid garden
#

Umm

#

Just try

wheat mesa
#

I’m gonna have to stay far away from sites like that

#

But yeah

#

Not to mention the top.gg scraping incident

#

Yes

#

Much easier

#

And you actually learn useful things

fluid garden
#

Iam making it myself

#

How should anyone make it to me

wheat mesa
#

Without autocode

fluid garden
#

Replit have many bug

#

That's ehy

#

I use autocodr

quartz kindle
#

wtf is autocode

split hazel
#

the future of discord bots

#

the new glitch

quartz kindle
#

the new botghost you mean

dry imp
#

yes

#

le epic scraper company

stiff dust
#

hi can someone help me in HTML / CSS code for top gg ?

dry imp
#

inspect element

stiff dust
#

i write a code and its fine in editor but when i save it, it doesnt show it and the problem is from my code so i dono

stiff dust
dry imp
stiff dust
dry imp
#

i dont know the code either

stiff dust
dry imp
#

why?

#

better to send it here, since i dont know much about hml css

hexed garnet
#

Collecting discord.py
Using cached discord.py-1.7.2-py3-none-any.whl (786 kB)
Using cached discord.py-1.7.1-py3-none-any.whl (786 kB)
Using cached discord.py-1.7.0-py3-none-any.whl (786 kB)
Using cached discord.py-1.6.0-py3-none-any.whl (779 kB)
Using cached discord.py-1.5.1-py3-none-any.whl (701 kB)
Using cached discord.py-1.5.0-py3-none-any.whl (699 kB)
Using cached discord.py-1.4.2-py3-none-any.whl (692 kB)
Using cached discord.py-1.4.1-py3-none-any.whl (692 kB)
Using cached discord.py-1.4.0-py3-none-any.whl (692 kB)
Using cached discord.py-1.3.4-py3-none-any.whl (676 kB)
Using cached discord.py-1.3.3-py3-none-any.whl (676 kB)
Using cached discord.py-1.3.2-py3-none-any.whl (676 kB)
Using cached discord.py-1.3.1-py3-none-any.whl (676 kB)
Using cached discord.py-1.3.0-py3-none-any.whl (676 kB)
Using cached discord.py-1.2.5-py3-none-any.whl (655 kB)
Using cached discord.py-1.2.4-py3-none-any.whl (655 kB)
Using cached discord.py-1.2.3-py3-none-any.whl (655 kB)
Using cached discord.py-1.2.2-py3-none-any.whl (655 kB)
Using cached discord.py-1.2.1-py3-none-any.whl (655 kB)
Using cached discord.py-1.2.0-py3-none-any.whl (654 kB)
Using cached discord.py-1.1.1-py3-none-any.whl (649 kB)
Using cached discord.py-1.1.0-py3-none-any.whl (648 kB)
Using cached discord.py-1.0.1-py3-none-any.whl (648 kB)
Using cached discord.py-1.0.0-py3-none-any.whl (648 kB)
Using cached discord.py-0.16.12.tar.gz (414 kB)
Using cached discord.py-0.16.11.tar.gz (412 kB)
Using cached discord.py-0.16.10.tar.gz (412 kB)
Using cached discord.py-0.16.9.tar.gz (412 kB)
Using cached discord.py-0.16.8.tar.gz (412 kB)
Using cached discord.py-0.16.7.tar.gz (411 kB)
Using cached discord.py-0.16.6.tar.gz (409 kB)
Using cached discord.py-0.16.5.tar.gz (408 kB)
Using cached discord.py-0.16.4.tar.gz (408 kB)

#

this happens when using topggpy==1.4.0

split hazel
#

bros spamming 💀

hexed garnet
hexed garnet
dry imp
hexed garnet
dry imp
#

whats the error?

hexed garnet
#
    bot.topggpy = topgg.DBLClient(bot, dbl_token)
TypeError: __init__() takes 2 positional arguments but 3 were given```
outer niche
#
Ignoring exception in command 'play2':
Traceback (most recent call last):
  File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\commands.py", line 457, in _invoke_with_namespace
    return await self._callback(self.binding, interaction, **values)  # type: ignore
  File "C:\Users\culan\OneDrive\Desktop\echo slash\cogs\testmusic.py", line 524, in play2
    await interaction.response.send_message(embed=[song])
  File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\interactions.py", line 595, in send_message
    params = interaction_message_response_params(
  File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\webhook\async_.py", line 485, in interaction_message_response_params
    data['embeds'] = [embed.to_dict()]
AttributeError: 'list' object has no attribute 'to_dict'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\tree.py", line 998, in call
    await command._invoke_with_namespace(interaction, namespace)
  File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\commands.py", line 476, in _invoke_with_namespace
    raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'play2' raised an exception: AttributeError: 'list' object has no attribute 'to_dict'

``` I'm struggling to figure out how to fix this I'm currently using Discord.py version 2.0a
hexed garnet
hexed garnet
outer niche
hexed garnet
#

what does [song] contain?

outer niche
#

a embed

hexed garnet
#

can you print it?

outer niche
#
 embed = (discord.Embed(
            title='Now playing',
            description=css\n{0.source.title}\n'.format(self),
            color=0x02020).add_field(
                name='Duration', value=self.source.duration)
            set_thumbnail(url=self.source.thumbnail))

        return embed```
outer niche
hexed garnet
#

so that is [song] (discord.Embed(
title='Now playing',
description=css\n{0.source.title}\n'.format(self),
color=0x02020).add_field(
name='Duration', value=self.source.duration)
set_thumbnail(url=self.source.thumbnail))

outer niche
#

Ya most of it at least

hexed garnet
#

k

#

[song] is a list

hexed garnet
outer niche
#

So what do I need to do?

hexed garnet
outer niche
#
class Song:
    __slots__ = ('source', 'requester')

    def __init__(self, source: YTDLSource):
        self.source = source
        self.requester = source.requester

    def create_embed(self):
        embed = (discord.Embed(
            title='Now playing',
            description='css\n{0.source.title}\n'.format(self),
            color=0x02020).add_field(
                name='Duration', value=self.source.duration).add_field(
                    name='Requested by',
                    value=self.requester.mention).add_field(
                        name='Music By:',
                        value='[{0.source.uploader}]({0.source.uploader_url})'.
                        format(self)).add_field(
                            name='URL',
                            value='[Click]({0.source.url})'.format(self)).
            set_thumbnail(url=self.source.thumbnail))

        return embed```
#

There you are that is the full class

outer niche
#

🤔

hexed garnet
#

like try printing [song]

outer niche
#

So add it at the end of the command?

#

Or randomly in the file?

hexed garnet
hexed garnet
outer niche
#

    def create_embed(self):
        embed = (discord.Embed(
            title='Now playing',
            description='css\n{0.source.title}\n'.format(self),
            color=0x02020).add_field(
                name='Duration', value=self.source.duration).add_field(
                    name='Requested by',
                    value=self.requester.mention).add_field(
                        name='Music By:',
                        value='[{0.source.uploader}]({0.source.uploader_url})'.
                        format(self)).add_field(
                            name='URL',
                            value='[Click]({0.source.url})'.format(self)).
            set_thumbnail(url=self.source.thumbnail))

        return embed


print(song)```
hexed garnet
#

no

#

print([song])

outer niche
#

Oop sorry

hexed garnet
#

yep

#

does it print anything?

outer niche
#

[<cogs.testmusic.Song object at 0x000001EFD57C64C0>]

hexed garnet
#

hm

#

1 sec

outer niche
#

Kk

hexed garnet
#

i got to check my code

#

well

#

uhhhhhh

#

ur [song]

#

is not an list

outer niche
#

how do i make it ome

hexed garnet
#

you dont need a list

#

what lang?

dry imp
#

js

outer niche
#

How is that going to go and get the embed from that class though

hexed garnet
hexed garnet
#

u should figure that

outer niche
#

Then this ain't going to work LOL

dry imp
#

its an object you dont need to give it a list

hexed garnet
outer niche
#

Anyone else got any ideas

dry imp
#

if you returned embed correctly there should not be any problem

outer niche
dry imp
#

also, if its only 1 embed use embed not embeds

outer niche
dry imp
#

its not a string.....

outer niche
#

Okay that's not what I meant

dry imp
#

do you print or do you send the message?

outer niche
#

Send

dry imp
#

send the send message line

outer niche
#

await interaction.response.send_message(embed=[song])

dry imp
#

can you not put a list....

outer niche
#

I understand this is the way I need to do it but I don't see how this is going to go and get the class with it embed is located await interaction.response.send_message(embed=embed)

dry imp
#

you need to fetch the embed that is returned

#

show me the function that contains the send message line

outer niche
dry imp
#

send the function

dry imp
#

here

#

......

outer niche
#

What

dry imp
#

not the embed class

outer niche
#

So do you want the command?

dry imp
#

yes the one that have send message line

#

le function

outer niche
#
    @app_commands.command(name='play2')
    async def play2(self, interaction: discord.Interaction, search: str):
        server = interaction.guild
        voice_channel = server.voice_client

        async with interaction.channel.typing():
            

            song = Song(source)
            print([song])
           await  interaction.response.send_message(embed=embed)
            await interaction.response.send_message(embed=discord.Embed(
                title="Added to queue",
                description='Enqueued {}'.format(str(source)),
                color=0x02020
            ))```
dry imp
#

does that send the embed?

outer niche
#

No

dry imp
#

also

#

what is source?

outer niche
#

Source has to do with some other stuff and nothing to do with the embed though

outer niche
thorny flume
#

I want to get the test element

'1': teste {
  ...
},
'2': teste {
  ...
}

I tried with [1] but it only gives me one but I want to get them all

quartz kindle
#

Object.values({ 1: {}, 2: {} }) = [{}, {}]

outer niche
pearl trail
#

from what i see, you send embed twice?

#

saying that it's interaction, you cant send embed twice unless you edit the first send

dry imp
dry imp
#

ig the source is a global variable?

#

just woke up, so i just answered now

granite token
#

Hi

bright hornet
austere surge
bright hornet
austere surge
#

you didnt change the value

bright hornet
#

i did

#

data.wallet * 2

near stratus
#

data.wallet = data.wallet * 2

civic scroll
#

xd

near stratus
sick agate
#

no no no no

austere surge
#

ew packages

feral aspen
#

I've been scrolling through YouTube for the best discord.js tutorial via typescript, any playlist you guys found useful?

#

I can't find the documentation for it, too.

lament rock
#

Watching videos for coding tutorials isn't very helpful if all you're doing is copying the code. Some people do explain, but they don't and can't wait for people to finish so they're paying attention to why their code is the way it is

#

people would be better off with someone who knows what beginners should know personally explaining entry level code

feral aspen
#

People have their own way of understanding something.

lament rock
#

If you're looking for more yt tutorials, then can you say you understand it?

feral aspen
#

I understand each tutorial before getting to copy it.

#

Again, people have their own way of understanding a particular subject.

lament rock
#

Do you know what types are

feral aspen
#

I'm sorry?

lament rock
#

Data types

#

why can you do x with y but not with z

feral aspen
#

Why are you testing whether I know or not?

lament rock
#

Because that's fundamental knowledge you should have

feral aspen
#

Do you know how ruby got originated?

lament rock
#

why do I care about ruby?

feral aspen
#

Why do you care if I know or not?

#

I'm LEARNING.

earnest phoenix
feral aspen
lament rock
#

Because you're not learning if you don't apply concepts

#

The core of every language is types

feral aspen
#

Understand the code ---> Know what you're doing ---> Copy paste ---> Do your end by configuring the code, etc.

lament rock
#

That's not applying concepts. how long have you been doing this?

feral aspen
#

When I want to know the basics of a language, that's what I do.

snow urchin
earnest phoenix
# feral aspen I'm not blindly copy pasting, that's what I said?

It doesn't really matter, you're still looking at other people write code with poor explanations rather than looking at guides and documentations written by people who have spent hundreds of hours doing so instead of someone trying to simplify it in a few minutes or hours, which is from what I've seen is not very helpful

lament rock
#

???

#
pearl trail
#

discord.js do have docs

feral aspen
#

Does typescript not have a seperate documentation, or is that not how it works.

lament rock
#

TypeScript is literally JavaScript with extra steps

#

but the core principle is types

feral aspen
#

Aware, and I'll take that as a no.

pearl trail
#

you dont need discord.ts to use typescript mmLol

#

and yes you can use djs with ts

earnest phoenix
#

Reminder that discord.js is not solely a TypeScript project, it's not supposed to tell you how to write it in TypeScript way, you're supposed to know how TypeScript works before jumping into the bandwagon

pearl trail
#

just with some types

#

use @ts-ignore everywhere

#

👍

lament rock
#

ts and js are supposed to go hand in hand either way

feral aspen
#

If I want to make a bot with typescript, what packages are required? ts-node, discord.js, nodemon, and what more?

lament rock
#

ts-node is not required

feral aspen
#

Why so?

lament rock
#

you compile to js first and then run the dist folder

feral aspen
#

Isn't it node for typescript.

lament rock
#

all ts-node is doing is that

#

typescript compiles down to javascript to a dist folder. You run that js

feral aspen
cinder patio
#

ts-node just keeps the transpiled javascript in-memory

#

instead of storing it in the file system

lament rock
#

I thought it wrote to temp

cinder patio
#

every time you run ts-node your code gets transpiled

#

maybe it does but still

lament rock
#

I had no clue typescript even offered an in memory solution

#

this is news to me

feral aspen
cinder patio
lament rock
tidal nymph
#

guys, what is the best way to avoid hitting 1 request / 1 second rate-limit Thonk

lament rock
tidal nymph
lament rock
# feral aspen Does it?

it uses typescript and there's only so many ways to actually use it, so idk what your question is

tidal nymph
#

I tried Promise with Settimeout but that shit was blocking my process

feral aspen
#

Am I able to use typescript on a javascript file?

pearl trail
#

no

lament rock
#

No. Typescript expressions are only valid in .ts files

pearl trail
#

but you can use js on ts

#

with some extra steps, as papi said

feral aspen
#

Oh, how was the project, I sent above, used then?

#

I don't see a dist folder.

lament rock
#

You compile it first and then its created

#

you'd usually .gitignore it

feral aspen
#

Fair enough.

cinder patio
#

Setting up ts is very simple idk what you're having issues with

feral aspen
#

I'm asking questions, that's it. (From a beginner POV).

dry imp
#

i get u pal

solemn latch
#

You cannot make more than 200 application commands in a day.

#

So wait until tomorrow

raven holly
#

Does somebody know about express and cookies?

solemn latch
#

I know about express and cookies.

raven holly
#

module.exports.updateUser = async (req, res, next) => {
  try {
    const key = res.cookies.get('key');
    if (key)
      res.locals.user = await authClient.getUser(key);
  } finally {
    next();
  }
};``` I,m getting this error   ``` const key = res.cookies.get('key');
                            ^

TypeError: Cannot read properties of undefined (reading 'get')```
civic scroll
#

man read the error

#

it tells you what's wrong most of the time

raven holly
#

yes but is defined

civic scroll
#

have you read res data struct?

civic scroll
#

in which it did

#

so res.cookies is undefined

raven holly
#

sec

civic scroll
#

check the cookie before getting

raven holly
#

But in tutorial is work

civic scroll
#

if (res.cookies && res.cookies.has(key))
assume res.cookies is of type Map

civic scroll
#

not following the tutorial

#

depends on runtime, libraries and how it got set up, things may be different

#

a request can have no cookies at all

raven holly
#

but this set cookise ```const express = require('express')
require('dotenv').config();
const authClient = require('../auth-client');

const router = express.Router();

router.get('/login', (req, res) =>
res.redirect(https://discord.com/api/oauth2/authorize?client_id=${process.env.ID}&redirect_uri=${process.env.DASHBOARD_URL}/auth&response_type=code&scope=identify guilds));

router.get('/auth', async (req, res) => {
    try {
      const code = req.query.code;
      const key = await authClient.getAccess(code);
      
      res.cookies.set('key', key)
      res.redirect('/dashboard');
    } catch {
      res.redirect('/');
    }
  });
router.get('/logout', (req, res) => {
    res.cookies.set('key', '');

    res.redirect('/');
})

module.exports = router;```

civic scroll
#

bruh

#

you clearly didn't get what i meant

raven holly
#

yep 🙂

ancient nova
raven holly
solemn latch
#

youtube tutorials are not ideal, they often contain wrong or outdated information

ancient nova
#

I want to use them to potentially create an user count

#

meaning currently online users

raven holly
#

and he use cookies

solemn latch
civic scroll
#

get the req data struct

#

pleaee for the love of god

raven holly
ancient nova
#

@civic scroll do you know anything about apis?

#

can I call an api to get cookies?

civic scroll
#

it can be something like

interface Request {
    cookies?: CookieList; // CookieList or undefined
...
}
civic scroll
ancient nova
#

const processActiveUsers = function () {
Active += 1;
}

#

I'd store them and then update active count

raven holly
ancient nova
#

actually that will not work nevermind

raven holly
#

should i use that too

civic scroll
#

THEN USE COOKIE

#

oml

#

log the req object

#

now

raven holly
#

okay

civic scroll
raven holly
civic scroll
raven holly
civic scroll
#

@raven holly check if there exists any "cookie" fields

raven holly
civic scroll
#

cookie does not exist on this object

#

in fact it's nowhere to be found

raven holly
#

but i import it ```const express = require('express')
const cookies = require('cookies')
const middleware = require('./middleware')
require('dotenv').config();

const rootRoutes = require('./routes/root-routes')
const dashboardRoutes = require('./routes/dashboard-routes')
const authRoutes = require('./routes/auth-routes')

const app = express();

app.set('views', __dirname + '/views');
app.set('view engine', 'pug')

app.use('/',
middleware.updateUser, rootRoutes,
authRoutes
);
app.use('/dashboard', dashboardRoutes)

app.use(cookies.express('a', 'b', 'c'));

app.get('*', (req, res) => res.render('errors/404.pug'));

const port = process.env.PORT;
app.listen(port, () => console.log(Server is live on ${port}))```

civic scroll
#

the request came from client

#

which doesn't have

#

which you tried to get

ancient nova
raven holly
#

this ```const express = require('express');
const router = express.Router();

router.get('/', (req, res) => res.render('index'));

module.exports = router;```

civic scroll
#

yes

raven holly
#

auth-client which?

#

xD

#
const client = require('../src');
require('dotenv').config();
const Client = new OAuthClient(process.env.ID, process.env.SECRET);
Client.setRedirect(`${process.env.DASHBOARD_URL}/auth`);
Client.setScopes('identify', 'guilds');

module.exports = Client;```
ancient nova
#

so it's not a default install for node.js

civic scroll
raven holly
civic scroll
ancient nova
civic scroll
#

if it doesn't have, set a new one and respond with it

raven holly
civic scroll
#

create one then???

#

or read cookie documentation on mdn

#

duh

raven holly
# civic scroll **create one then???**

but this should create one```const express = require('express')
require('dotenv').config();
const authClient = require('../auth-client');

const router = express.Router();

router.get('/login', (req, res) =>
res.redirect(https://discord.com/api/oauth2/authorize?client_id=${process.env.ID}&redirect_uri=${process.env.DASHBOARD_URL}/auth&response_type=code&scope=identify guilds));

router.get('/auth', async (req, res) => {
    try {
      const code = req.query.code;
      const key = await authClient.getAccess(code);
      
      res.cookies.set('key', key)
      res.redirect('/dashboard');
    } catch {
      res.redirect('/');
    }
  });
router.get('/logout', (req, res) => {
    res.cookies.set('key', '');

    res.redirect('/');
})

module.exports = router;```

civic scroll
#

how else would you write

#

if you don't know how cookies work

raven holly
#

but here is createone part

civic scroll
#

what if that part doesn't trigger in prior to the errored one

#

you didn't check the origin to verify its source

raven holly
#

because if i go /login it redirect me to /auth

civic scroll
#

you didn't submit anything

#

so

#

why

raven holly
#

what xD

civic scroll
#

run the debugger

raven holly
#

sec

civic scroll
#

and insert the breakpoint at that line

raven holly
#

which xD

#

res.cookie.set('key', key)

#

this?

civic scroll
#

yeah

#

and the one on catch block too

raven holly
#

hey @civic scroll

civic scroll
#

to see if it actually hits

raven holly
#

i just log res

#

and there are cookies

civic scroll
#

GREAT

#

LET'S GO

raven holly
#

hahaha

civic scroll
#

now

#

now

raven holly
#

but with this i got error

civic scroll
#

make sure that comes along with every request

raven holly
#

but it comes

civic scroll
#

you saved with "keys"

#

you tried getting "key"

raven holly
#

where i saved with keys

#

i can't find keys

#

ou at server.js

civic scroll
#

wait

#

you didn't use cookie plugin?

#

💀

raven holly
#

i use?

#

cookes

civic scroll
#

this is very confusing

raven holly
#

yes

#

hahah

neat ingot
#

why are all the top.gg staff and server icon etc still upside down?

#

wasnt that for april fools?

split hazel
#

they think they're funny but they're not

hollow depot
#
const options = {
  hostname: 'http://myVPSIPAddress:somePort/somePath',
  method: 'GET'
}

const req = http.request(options, res => {
  console.log(`statusCode: ${res.statusCode}`)

  res.on('data', (parsed) => {
  v = parsed.version;
  message.channel.send("Version: " + v)
  })
})

req.on('error', error => {
  console.error(error)
})

req.end()

when running this i get an ENOTFOUND error, but when i do a patch request to the same ip, same port, same path it works

and also get requests to that url work via postman, but not this

boreal iron
split hazel
boreal iron
#

still trying to move forward with my frontend, I'm working on for weeks now, so no

neat ingot
neat ingot
#

~ i only just found this out 😭

boreal iron
#

Yeah they can also have vars with a default value if the var isn't defined

#

Which isn't supported on most mobile browsers

#

Which is why I'm not using them

#

Not that I would need anyways

neat ingot
#

oh interesting, but regular css variables work on mobile browsers fine?

boreal iron
#

they're part of the first releases of css3 iirc

#

so most browsers nowadays support them, yeah

#

I'm enforcing them in my site but I don't use them

neat ingot
#

I've only been using them to define theme color type things, then when a user select their theme i just change the href of the stylesheet link element

#

works like a charm

wheat mesa
#

poor IE

neat ingot
boreal iron
#

yeah that's how I'm loading my themes in, too

neat ingot
#

lol, ie gets all the hate, but where would we be now without it?!

wheat mesa
#

still on netscape

neat ingot
#

i did notice, if the newly loaded theme.css has some @fontface type definitions and overwrites the font, the page has a slight period where the default fonts are used, which isnt an issue unless you want multi font support 😄

boreal iron
#

I wonder who will ever translate my lang files

#

Guess I need to pay somebody

neat ingot
#

how do you handle multi language support?

#

just load the 'vocabulary' from some relative json or something?

boreal iron
#

By loading the user selected language file and if it doesn't exist yet, fall back to the default one (en)

#

No ini files are way better as language files

neat ingot
#

😮 even for other os'?

#

i thought ini was a windows thing

boreal iron
#

nope

neat ingot
#

dang, this weeks full of learning 😄

boreal iron
#

it's getting parsed by PHP

#

no matter what the OS is

neat ingot
#

ahh ok so you just opted for that file type but really its irrelevant cause your parsing it using a custom parser?

boreal iron
#

aye

#

anything is already integrated in php

#

imagine it like it is the entire npmjs collection of libs, with crap but mostly useful prebuilt stuff for u

neat ingot
#

anyone know of a color pallet generator that can give me 6 colors that work well together, as well as giving shades of that color in steps going dark and also light?

#

i can either find generators that do one or the other 😭

granite token
#

Hi

boreal iron
raven holly
#

Guys do you know how to get cookise npm cookies

#

Because i know how to save cookise is just res.cookie('key')
But how to get it

neat ingot
raven holly
#

i installed it ?

#

i mean how to get cookise

#

not npm xD

neat ingot
#
var http = require('http')
var Cookies = require('cookies')
 
// Optionally define keys to sign cookie values
// to prevent client tampering
var keys = ['keyboard cat']
 
var server = http.createServer(function (req, res) {
  // Create a cookies object
  var cookies = new Cookies(req, res, { keys: keys })
 
  // Get a cookie
  var lastVisit = cookies.get('LastVisit', { signed: true })
 
  // Set the cookie to a value
  cookies.set('LastVisit', new Date().toISOString(), { signed: true })
 
  if (!lastVisit) {
    res.setHeader('Content-Type', 'text/plain')
    res.end('Welcome, first time visitor!')
  } else {
    res.setHeader('Content-Type', 'text/plain')
    res.end('Welcome back! Nothing much changed since your last visit at ' + lastVisit + '.')
  }
})
 
server.listen(3000, function () {
  console.log('Visit us at http://127.0.0.1:3000/ !')
})

^ thats their example from the npm page

raven holly
#

so i just need to change in server.js i need to add var cookise...

neat ingot
#

idk the module, but it seems easy enough. you create a new cookies object using the request and response and give it the cookies as an object

neat ingot
#

i preffer not to dm sorry

raven holly
#

ou okay 😦

#

then i send here

neat ingot
#

again, idk the module, i've always used 'cookie-parser' module

raven holly
#
const cookies = require('cookies')
const middleware = require('./middleware')
require('dotenv').config();

const rootRoutes = require('./routes/root-routes')
const dashboardRoutes = require('./routes/dashboard-routes')
const authRoutes = require('./routes/auth-routes')

const app = express();


app.set('views', __dirname + '/views');
app.set('view engine', 'pug')

app.use(express.static(`${__dirname}/assets`));
app.locals.basedir = `${__dirname}/assets`;

app.use('/', 
middleware.updateUser, rootRoutes,
authRoutes
);
app.use('/dashboard', middleware.validateUser, dashboardRoutes)

app.use(cookies.express('a', 'b', 'c'));

app.get('*', (req, res) => res.render('errors/404.pug'));

const port = process.env.PORT;
app.listen(port, () => console.log(`Server is live on ${port}`))```
raven holly
neat ingot
#

but what is it your trying to do?

raven holly
# neat ingot but what is it your trying to do?

in this ``` router.get('/auth', async (req, res) => {
try {
const code = req.query.code;
const key = await authClient.getAccess(code);

    res.cookies.set('key', key);
    res.redirect('/dashboard');
  } catch {
    res.redirect('/');
  }
});``` is gonna save cookie
#

and here module.exports.updateUser = async (req, res, next) => { try { const key = res.cookies.get('key'); if (key) res.locals.user = await authClient.getUser(key); } finally { next(); } }; get it

#

is better cookie-parser?

neat ingot
#

oh, i use passport module for handling login/auth 😄

raven holly
#

but cookie-parser can do that also yea?

neat ingot
#

if all your wanting to do is get/set cookies then yea

#

and cookies module should also be able to

raven holly
#

yes but is not work with cookies

#

i get error that 'get' is undefined

neat ingot
#

most documentations give examples with setting up using express too

raven holly
neat ingot
#

likely because res.cookies is undefined

raven holly
#

every else is with db

raven holly
neat ingot
#
const cookieParser = require('cookie-parser');
const express = require('express');
const app = express();
app.use(cookieParser());

app.get('/', function(req, res){
   res.cookie('name', 'express').send('cookie set'); //Sets name = express
   console.log('Cookies: ', req.cookies); // prints cookies
});

app.listen(3000);

^ sets/prints cookies

raven holly
#

but i want to get extacly cookie

#

req.cookies('name') ?

neat ingot
#

'name' is whatever your cookie name/id is

raven holly
#

ik that but i ask is this correct way to get it

neat ingot
simple stump
#

How do I remove global slash commands?

neat ingot
#

update your commands to discord api using an empty array

simple stump
#

ohh. tysm idk why i didnt think of that

neat ingot
raven holly
#

I get this error

neat ingot
#

res.cookie

#

not req

raven holly
#

but i want to get it

neat ingot
#

then req.cookies

raven holly
neat ingot
#

it is not a function

raven holly
#

i k that but why

neat ingot
#

because it is not a function.

#

it is a property

#

you cannot call a property

#

unless it is also a function (to be fair)

#

but this one isnt 😄

#

do console.log(req.cookies)

#

you will see, it is an object with its own properties

#

for example: req.cookies.key

raven holly
neat ingot
#

idk, there must be some flaw in the logic to load/set/get the cookies

raven holly
#

idk

#

how you do that what you said

pearl trail
#

req.signedCookies?

tacit cradle
#

Is a counting game enough of a reason to ask for the message content intent

#

Cuz according to discord it can be solved using / commands

#

And like technically they're right but it's really worsening the user experience

#

So is there any good way to go about it

sudden geyser
#

if it can be solved with slash commands you're unlikely to get the intent

#

and even if something can't (e.g. message logging) they're still aggressive on pushing people away from using it, even if it leads to less features

tacit cradle
#

Damn that sucks