#development

1 messages · Page 1732 of 1

eternal osprey
#

TypeError: Cannot read property 'toFixed' of undefined

sudden geyser
#

client.ping is not a thing

eternal osprey
#

prob the module that isn't installed

sudden geyser
#

No.

eternal osprey
#

owh yeah that too

sudden geyser
#

You probably meant the ping on the client.ws

#

It's not that too—that is your error.

eternal osprey
#

alright, thank you

sacred juniper
#

Which node.js should I choose in the visiual studio code?

delicate shore
#

how do I get this

#

results[0]....

sudden geyser
sacred juniper
#

I download

delicate shore
sudden geyser
sacred juniper
#

But i should select a programming lang

delicate shore
#

js

sudden geyser
#

Use bracket notation: result["First Name"]

sacred juniper
#

Which node.js should i select

sudden geyser
#

Node.js is a framework for writing JavaScript. I recommend you install the latest version.

#

So go to https://nodejs.org/en/ and select the LTS version on the front page

#

LTS stands for long-term support.

delicate shore
sudden geyser
#

Then result[0]["First Name"]

sacred juniper
#

Thx i will check it out

delicate shore
#

ohk thanks

#
et bru;
    
    for(bru=0; bru<results.length; bru++){

        var message = {
            from: 'admin@pgamerx.com',
            to: results[i].Email,
            subject: 'Random Stuff Api Update',
            text:`TEXT`,
           };

           function myFunction() {
            setTimeout(function(){
                sendEmail(message)
                .then(function(info){console.log("Sent")})   // if successful
                .catch(function(err){console.log('got error'); 
                console.log(err)
                return console.log(results[i].Email)
            }); 
            }, 5000);
          }
   

          myFunction()
    }
#

what am I doing wrong ...

#

Can anyone explain

quartz kindle
#

you are waiting 5 seconds then sending results.length emails at once

delicate shore
#

wtf

#

can you explain how to fix

eternal osprey
#

why does createOverwrite delete all channel permissions?

delicate shore
#
let bru;
              function myFunction() {
            setTimeout(function(){ 
    for(bru=0; bru<results.length; bru++){
        var message = {
            from: 'admin@pgamerx.com',
            to: results[i].Email,
            subject: 'Random Stuff Api Update',
            text:`TEXT`,
           };

                sendEmail(message)
                .then(function(info){console.log("Sent")})   // if successful
                .catch(function(err){console.log('got error'); 
                console.log(err)
                return console.log(results[i].Email)
            }); 

   

    }

            }, 5000);
          }

          myFunction()

#

like this

quartz kindle
delicate shore
#

like this

#

I found online

#

sleep

sacred juniper
#

Can ı get a tic For my bot without more than 1 shard

delicate shore
sacred juniper
#

Yea

#

Popular bots have

quartz kindle
sacred juniper
#

It is for more than 100 server

delicate shore
sudden geyser
quartz kindle
quartz kindle
#

ye you dont need sharding

sacred juniper
#

So

#

Is it mean I can get a verified icon with 1 shard?

quartz kindle
#

yes

sacred juniper
#

Thanks

#

I am really happy now

#

Thanks for answers

green kestrel
#

@quartz kindle hey there

#

triviabot is now moved over to D++

#

the speed boost is amazing

#

everyone loves it

sudden geyser
#

Comparison in performance?

green kestrel
#

noticeable

quartz kindle
#

nice

green kestrel
#

like, half the ram, a fraction of the CPU, tons less lag

#

I did combine it with some database multi threading tweaks too that also helped

quartz kindle
#

im amazed at how fast you pulled it off

green kestrel
quartz kindle
#

youre a god

green kestrel
#

you can see all the figures drop away on here

boreal iron
#

he just has too much time to spend KEKW

delicate shore
#
const sleep = (milliseconds) => {
  return new Promise(resolve => setTimeout(resolve, milliseconds))
}

const doSomething = async () => {
  for (/*for loop statements here*/) {
  //code before sleep goes here, just change the time below in milliseconds
   await sleep(1000)
  //code after sleep goes here 
    }
#

what does code after sleep mean

green kestrel
#

lol I don't have enough time

sudden geyser
green kestrel
#

I had to disappear into my coding cave for a month and the triviabot mods thought I'd left them lol

sudden knoll
#

in this case 1000 seconds

delicate shore
boreal iron
#

lmao

sudden knoll
#

oh i see now

delicate shore
sudden geyser
#

do stuff

delicate shore
#

I am confused

sudden geyser
#

When it reaches sleep() it'll wait 1 second before running code after it

boreal iron
#

1s may be the default value

delicate shore
#

I fetch email from a csv file ok
Then
I do a for each function to send emails to all emails
but I want to have an interval of 5 seconds in between all pepehmm

sudden geyser
#

If you're running down the street then take a 30-second break, you're doing the same as sleep(30000)

delicate shore
delicate shore
quartz kindle
#

earlier you were not waiting

delicate shore
#

that

boreal iron
#

Most of your emails will be marked as spam if you haven’t setup a proper mail service with SPF, DKIM and DMARC and making sure the IP isn’t blacklisted anywhere

delicate shore
#

I use Zoho

delicate shore
earnest phoenix
#

sa

#

türk varmı

sacred juniper
#

Var

#

As

earnest phoenix
sacred juniper
#

Kişiden kişiye değişiyor o

#

Eğer hiç red yemezse genelde 2 hafta veya daha fazla sürüyor bildiğim kadarıyla

earnest phoenix
#

@sacred juniper Demi?

sacred juniper
#

Hayır

#

O dediğin şey 100 sunucudan fazla sunucuda bulundugunda geliyor

earnest phoenix
sacred juniper
#

Benimki 100 sunucuda değil

#

Yok bende tik oyüzden

delicate shore
#
fs.createReadStream("./zoho.csv")
    .pipe(csv())
    .on('data', (data) => results.push(data))
    .on('end', () => {
        let bruh = null
        const doSomething = async () => {
            for (bruh = 0; bruh < results.length; bruh++) {
                let info = await transporter.sendMail({
                    from: 'admin@pgamerx.com',
                    to: results[bruh].Email,
                    subject: 'Random Stuff Api Update',
                    text: `Matter`
                })
                console.log("Message sent: %s", info.messageId);
                await sleep(3000)
            }

            doSomething()
        }
    });

This should work then?

#
const sleep = (milliseconds) => {
    return new Promise(resolve => setTimeout(resolve, milliseconds))
}

sleep function

delicate shore
sudden geyser
#

When it reaches that statement it’ll pause

#

So if you iterate 10 times with a sleep for 1 second, it’ll run 10 iterations in 10 seconds

#

If you didn’t sleep it would run a lot faster

sacred juniper
#

How can ı see my vote credit?

umbral zealot
signal estuary
#

How do I check, how much characters the message has, to avoid such errors?

crimson vapor
#

.length

feral aspen
#

I have connected my email to gmail by creating a business email and connecting my domain email, and I did that to authenticate, and that didn't work. After, I saw another tutorial on how I can connect it using an original email you have, example email@gmail.com then you add the email or import it example email@website.com

#

Now I have 2, the one that I imported and the one that I created as a business email, and somehow it works.

#

Should I delete the one that I created as a business email since I am not even able to access the email out of it?

#

👀

gusty marten
#

my bot timesout alot

#

lol

#

im updating it rn as im speaking.

blissful coral
#

Nice

small tangle
#

Extreme doing fine with that canvas stuff? aPES_Giggle

gusty marten
#

loads of people chat about certain topics i find boring so i made a bot for my server that deletes the message if it includes a certain keyword..

lucid girder
#

e

gusty marten
#

it went horably wrong cause it deleted the channel instead.

#

f

#

so i kicked it out my server

#

message.delete() deletes the message

#

message.channel.delete() deletes the channel the message was sent to.

umbral zealot
#

yes, we're aware of that

gusty marten
#

did i use 1 or 2?

#

TWO

umbral zealot
#

are you trying to write a blog post or did you have a question in there somewhere?

#

Stop trying to dotpost

gusty marten
#

ok

#

sry

#

i made a website for my bot, took a long time

#

jeezes

#

can i post it?

dusky sundial
#

Not here, no

umbral zealot
#

This isn't an advertising platform

#

this is a development channel where we usually help people with their code problems

gusty marten
#

responce: ye, if you want to get banned

#

lol

#

im joking

#

i think the real reason i write with my one finger is because its easyer for me.

#

do i lmao 😂😂

earnest phoenix
kindred patio
#

im here to find out how to get a noumeon bot

earnest phoenix
umbral zealot
#

I don't know that it's ever been

earnest phoenix
#

oh

#

idk then

cosmic forum
#

So I'm making an api, and I would like everyone to place a script tag in their site for it to work, so basically, there are options with the script, and my nodejs api will take the options for all the sites, and make an array of all the sites with their options. Anyone know how I could do this?

umbral zealot
#

wanna bet one of them has a space or something

#

or a zero width space

tired panther
#

608ff0f1c4f8d4016c4f1c69
608ff0f1c4f8d4016c4f1c69

#

I do not see any difference

umbral zealot
#

output this: ```
thatmap.keys().map(i => "${i}").join(' ');

umbral zealot
digital swan
#

could this be relevant

tired panther
gusty marten
#

one sec

tired panther
gusty marten
#

ima get luc in here

#

hes a developer like me

#

hes on a greater level than me lol

sacred juniper
#

Guys

#

So bot can be in maximum 2500 server with 1 shard right?

umbral zealot
#

yes

gusty marten
#

i was going to use bots.gg but i used top.gg instead because i knew it would be a easyer process

#

i guess its not lol

#

have to sit here for like 4 hours waiting for the bot to be approved lol

umbral zealot
#

4 hours? It's gonna take up to 2 weeks or more, dude

gusty marten
#

ok

#

lol

umbral zealot
#

I really hope you're not gonna stay here trying to stay awake for 2 weeks waiting for the approval

#

last time someone did that we did not have a great time.

sacred juniper
#

@umbral zealot thank you for answer

gusty marten
#

ok

cosmic forum
#

What would be the best image manipulation/canvas package for node js? I used to use node-canvas, but lately it's been very buggy.

quartz kindle
#

why is it buggy?

cosmic forum
quartz kindle
#

node-canvas is literally the only one. everything else is built on top of node-canvas

quartz kindle
cosmic forum
#

I wasn't using any custom fonts, just Arial which came with the package

quartz kindle
#

where are you hosting?

cosmic forum
#

replit

quartz kindle
#

no font comes with the package

cosmic forum
#

huh, well it used to work

quartz kindle
#

if there is no font files, it tries to use the system fonts

#

which depends on hosting

#

download an arial font file yourself and add it to your project

#

and use canvas.RegisterFont

cosmic forum
#

Ok

#

thanks

eternal osprey
#

hey how do i see what folders these indexes are coming from

quartz kindle
#

pm2 monit

eternal osprey
#

uhh alright

quartz kindle
#

get a better terminal lol

#

use the left right arrow keys to switch screens

#

and up and down arrow keys to scroll

eternal osprey
#

yeah i am trying to do that

quartz kindle
#

so for each index entry, switch to the lower right screen and scroll down to the file path

eternal osprey
#

but it doesn't show the folder it is in

solemn latch
#

if you get a chance name your processes eyes_shaking

gusty marten
#

watt

#

wam

#

wait a minite

lusty quest
#

index is how you main file is called, if you want to name it add the --name flag while starting the process the first time

gusty marten
#

yo se

#

oh wait

#

so

#

the www is the server

quartz kindle
#

www is a subdomain

gusty marten
#

so printer. is a server inside the site

#

..

#

?

umbral zealot
#

subdomains are a bit like "extensions" on a phone line

#

just different routing

gusty marten
#

ye

umbral zealot
#

Often enough they're all on the same server.

gusty marten
#

they go to diffrent parts

#

i wonder bif

#

no

#

how they do that then?

quartz kindle
#

a domain usually goes to a server by ip. then subdomains and pages go to different folders inside the server

gusty marten
#

umm

umbral zealot
#

yeah the web server will usually control this (though it can also be controlled at the domain DNS level)

lusty quest
#

there are also cases where sub domains point to different IPs

gusty marten
#

you make a account lets say you call it account

umbral zealot
#

depends on the setup tbh

gusty marten
#

then you make a html project called www

#

so then i make a nother project for istance project

quartz kindle
#

repl.it is not a simple website, its a system for virtual servers. so when you create a project you get a micro virtual server

gusty marten
quartz kindle
#

yes

gusty marten
#

how tho?

quartz kindle
#

domains are just paths pointing to some place

gusty marten
#

how could i do that to my own domain

#

?

quartz kindle
#

subdomains

gusty marten
#

umm

#

ok

#

i made a site

umbral zealot
#

you 'd need to have a web server like nginx or apache, which processes the incoming requests to the domain, see the subdomain, and decides what to do

gusty marten
#

its cool

quartz kindle
#

replit does not give you control over your subdomain

#

so you cannot create more subdomains inside replit

#

you would need your own server for that

gusty marten
#

ye but you can create other projects tho

lavish bramble
#

From where I can get the canvas fonts

quartz kindle
#

yes, but not subprojects

quartz kindle
lavish bramble
gusty marten
#

they you can make one like (jus.ll).account.repl.co

quartz kindle
lavish bramble
#

Any website idea

clear marlin
lavish bramble
#

😅

boreal iron
#

@quartz kindle Got a question for you.
Gonna filter guilds in the ready and guild_create events.
If a filter matches I'm gonna add a property to the guild, for example guild.filterBlocked = true;.
In the guild_delete event I am checking if the property guild.filterBlocked exists and log specific content.

At the last clean up the bot removed around 30 guilds.
I've noticed the bot left these guilds because of my filter matching but a few guilds are missing the assigned property filterBlocked.

#
// ready event filter match
guilds[i].filterBlocked = true;
guilds[i].leave();
#

Is it possible djs just removes the guild obj from the cache before the guild_delete is triggered?

quartz kindle
#

no, there is a small delay

#

the guild is only removed from the cache a bit after the event

boreal iron
#

Hmm... the property is assigned in some guilds and in some not.

#

The delay seems to be different.

#

Can't see any pattern on the timestamps

quartz kindle
#

this is what they do

boreal iron
#

hmm yeah... I assume getting rid of this issue can be solved only creating a global array instead of assigning properties to the guild obj

gusty marten
#

My bots realy laggy

#

how do i stop the lag?

umbral zealot
#

Write faster code.

#

Or get a faster host computer.

gusty marten
#

wdym

#

oh

boreal iron
#

Write a more efficient code.

umbral zealot
#

Your question is too broad and imprecise to answer.

gusty marten
#

ok i think its ok

#

its like the music keeps buffering.

#

its fine now

umbral zealot
#

oh it's a music bot. well that explains a lot

#

they're usually just crap unless you throw a lot of money at hosting

earnest phoenix
#

true

cinder patio
#
`lazy::parser::ast::model::ASTExpression` doesn't implement `std::fmt::Display`
impl std::fmt::Display for ASTExpression {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            //a ton of cases
            _ => writeln!(f, "Unknown")
        }
    }
}

But it does 😭

#

why is it saying that

cinder patio
#

yes

#

where

copper cradle
#

there

cinder patio
#

where where

earnest phoenix
#

uh wait

#

i am not the pro in rust but intermediate yes

cinder patio
#

but where tho

#

eh I'll just use a separate function

solemn jolt
#
let guild = client.guilds.cache.get("695606055064961054")
guild.channels.cache.forEach(ch=>{
  let invite = ch.createInvite({ temporary: true, reason: 'Just testing' });
  console.log(invite)
#

Why this code in console.log get me Promise { <pending> } not invite link

cinder patio
#

createInvite returns a promise

#

the action is not instant, createInvite sends an HTTP request to discord to make the invite

solemn jolt
#

How i can do it by code?

pale vessel
#

"Just testing"

#

Yeah, right

crimson vapor
#

for a bot which both as a ban command and uses the guild ban event, how would you make sure that the ban isnt logged 2 times when a user uses a command and the guild ban event is triggered?

cinder patio
#

put the banned id in a cache and ignore it if it's already in there

solemn jolt
#

I want to get a basic code of get invite server link

crimson vapor
#

aright I was thinking about doing that but didn't really know if it was a good idea

cinder patio
crimson vapor
cinder patio
#

yeah, or a set. A set is probably better because you'd want to remove the ID in the guild ban event

crimson vapor
#

ye smart

near stratus
crimson vapor
#

actually, do you think its a good idea to just do a find on the collection that is my database cache? that would expire after 15 minutes so more memory used but I wouldn't have to deal with managing another cache or anything

#

ex.js const doc = worker.db.moderationDB.cache.find(e => e.user_id === user.id && e.guild_id === guild.id && e.type === 'BAN') if (doc) return

cinder patio
#

Also... you probably don't need to store which guild the user got banned from, what are the odds a user gets banned from 2 different guilds at the same time

crimson vapor
#

unlikely but its a small check so I doubt it would matter

cinder patio
#

Yeah that also works, though you're iterating through your cache

#

and the banned user will almost always be at the bottom of the cache

#

a reverse find maybe

crimson vapor
#

oh

deep mantle
#

for discord.py, does await client.fetch_user(id) have a rate limit

crimson vapor
#

thats actually really smart

#

I doubt the cache will ever have more than 30

#

but 29 extra is kinda useless

delicate shore
cinder patio
#

yup

#

I'd go with a reverse find

crimson vapor
#

ty for your help

deep mantle
#

ok thanks

cinder patio
#

np

sudden geyser
#

But it’s a nice step

#

So you should make sure you handle the error in case it still fails

worn sonnet
#

so i switched from Flask to Quart which is async and now i'm struggling with adding await on every function i wrote

sudden geyser
#

Python will emit a warning if you forget to await an asynchronous expression

worn sonnet
#

and the real trouble is Quart doesn't give any error if there's one in Jinja templating

delicate shore
#

I got rate limited

worn sonnet
#

just shows 500 server error

delicate shore
#

for sending 55 emails in like

#

170 seconds

sudden geyser
#

I don’t work with emails.

#

I simply told you what the sleep function did

delicate shore
#

well thanks

#

it worked

#

kinda

#

I will do rest tmrw I guess..

crimson vapor
#

anyone got any clue about why sometimes requests will take ~5 seconds?

sudden geyser
#

To?

cinder patio
#

internet speed

sudden geyser
#

There could be many factors

#

Like your internet speed/connection

cosmic forum
#

Hello, anyone know how to parse a XMLHttpRequest with nodejs?

var xhr = new XMLHttpRequest();
xhr.open("POST", "https://example.com/endpoint", true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send(JSON.stringify({
  site: "example.com",
  description: "Hello description",
  checked: "Some date"
}));

I tried,

const bodyParser = require("body-parser");
let db = [];

app.use(bodyParser.urlencoded({ extended: false }));

app.post("/endpoint", cors, async (req, res) => {
  await db.push(req.body.site);
});

But when I log db it returns [null].

earnest phoenix
#

or the server on the other side,where you sent the request

cinder patio
#

Express is the exported object from "express"

crimson vapor
cosmic forum
#

ah ok

cinder patio
#

hmmm idk then

cosmic forum
cinder patio
#

Then it's express for you

cosmic forum
#

ok

crimson vapor
#

and im logging my requests so its not like im making too many requests

#

so im just confused

earnest phoenix
#

how can we setup vote webhooks in python?

umbral zealot
elfin cape
#

Anyone who using lavalink music bot?

lyric mountain
#

man there's ONE thing I hate about postgres:

MD5: md5(text/bytea) -> outputs text
SHA256: sha256(bytea) -> outputs bytea

#

generate random md5: mds(current_timestamp::text)
generate random sha256: encode(sha256(current_timestamp::bytea), 'hex')

#

why not make it have the same fckin signature and output of md5????

woeful pike
#

because sha256 outputs binary data...?

#

md5 is a plaintext hashing algorithm, sha256 produces binary output

#

this has nothing to do with postgres

lyric mountain
#

I mean, there's still no reason not to have a sha256(text) signature

#

and yeah, looks like those generators are a sql thing, not only postgres

#

so, editing, there's ONE thing I hate about sql

woeful pike
#

it's up to you to decide what binary representation you want to use for strings if that's what you want to do

#

if anything the md5 function probably shouldn't be supporting text

lyric mountain
#

why not tho?

#

either remove text signature of md5 or add it to sha hashers, just for the sake of standardization

lyric mountain
#

sketchy

jolly niche
#

hello

#

anyone can help me in heroku?

humble wraith
#

You just need to state the issue

jolly niche
#

im want to host a music bot, and i get this error

#

im added the buildpacks

lament rock
#

That's not a valid buildpack for ffmpeg. You should search npm for pre-compiled ffmpeg binaries or look for a heroku ffmpeg build pack

lyric mountain
#

yep

#

also, idk if heroku can handle music stuff tbh

modest maple
#

it really cant

lament rock
#

Also just a little words of wisdom: you aren't going to get far in terms of music with Heroku

lyric mountain
#

you aren't going far with anything other than websites or APIs with heroku

jolly niche
#

No problem.

#

Im soon host this on my vps

lament rock
jolly niche
#

ah

#

where can i find valid buildpack for ffmpeg

#

now i got this error

lament rock
#

that's not where you find build packs for heroku. You'll just have to google that yourself. NPM is for dependencies for your bot like discord.js, but it also contains modules which come with pre-compiled ffmpeg binaries which eliminates the need for a build pack

eternal osprey
#

hey guys i need some help here

#

how do i access my iphone when the screen is broken?

#

bottom half doesn't work

#

sorry i know this has nothing to do with development

#

but i have authy on my phone and my bank, paypal etc are all protected by it

queen latch
#

lol shouldn't u be asking that to a electronic device repair service

cinder patio
#

Use another phone

#

All that info should be in your SIM or SD card

lyric mountain
#

iphone: charge more for a fix than for a new phone

lament rock
#

iPhone doesn't have external storage

cinder patio
#

oh

#

well then gl

lament rock
#

You'd have to take it to get it repaired or talk to data specialists with iPhones I guess??? But the root fs of iphoneos is weird and stuff like passwords are encrypted in the keychain and by no means is it easy to access

eternal osprey
#

oh god

#

alright. Thanks guys.

lyric mountain
#

doesn't iphone have some sort of data migration tool?

lament rock
#

I don't think so. You might be thinking of android to ios

lyric mountain
#

damn, apple's pit is deeper than I thought

lament rock
#

when you get a new phone, you can have basic data like app list not including app data synced and photos and such synced

boreal iron
#

If you can still unlock the phone the Apple Configurator 2 will help you to save your stuff or move it to a different phone.

#

(MAC required)

#

Free app of course

lyric mountain
#

free? on apple?

#

that's illegal

eternal osprey
lament rock
#

Just get the screen repaired

eternal osprey
#

bottom half is dead

boreal iron
#

If you got a MAC the app I mentioned will help you

eternal osprey
lyric mountain
eternal osprey
#

I did it once and it removed all my pictures etc

lyric mountain
#

if you explicitly state that data must be kept they're legally obliged not to format it ig

#

might need some research whether there's an actual law about that

cinder patio
#

You're only getting the display repaired though

#

why would that delete all your data

lyric mountain
#

they format it

#

all technical assistance does that (at least where I live they do)

boreal iron
#

Never heard something like that

lament rock
#

That's dumb

#

why would they do that?

lyric mountain
#

idk, maybe that's a brazil thing

#

(yet another brazil thing)

lament rock
#

Come to brazil

boreal iron
#

Better not lmao

cinder patio
#

no thanks

shrewd cliff
#

hey guys

#

can i send embed in error handling message ??

queen latch
#

@rustic nova its written in the discord developer docs on how to do but i can't understand anything in that

rustic nova
#

that's why libraries are a thing

queen latch
#

but there is a way to make bot without lib

queen latch
dusky sundial
#

Why do you insist on not using a lib?

queen latch
#

I'm just trying

#

lol

knotty zodiac
#

how do i change my bot top.gg page background? i need to use css but dont know how

dusky sundial
#

Do you know any html/css?

knotty zodiac
#

not much

queen latch
#

bruh

cinder patio
queen latch
#

kkk

lyric mountain
#

¯_(ツ)_/¯

sacred juniper
#

Guys

#

Is there an age limit for bot verification?

#

For 100+ server verification

modest maple
#

the same age limit as discord in general

solemn latch
#

16 now i thought

modest maple
#

oh yeah cuz stripe update

#

gotta get yer parents

knotty zodiac
#

i still couldnt seem to figure out how to change the page theme 😢

weary socket
#

Somebody ever built a Webinterface with React and Spring as Backend?

solemn latch
#

oh like light/dark theme

knotty zodiac
solemn latch
weary socket
#

Somebody ever built a Webinterface with React and Spring as Backend?

weary socket
solemn latch
# knotty zodiac

forcing themes is restricted to those with custom css.
its only intended for those with css which is modified so much it wont work with a different theme.
if you dont have custom css, there is zero reason to turn that on.

#

sounds too specific for someone here to have done that.

knotty zodiac
weary socket
solemn latch
lyric mountain
#

well, technically, yes

weary socket
lyric mountain
#

because I don't use spring for data transaction

#

I use websockets

knotty zodiac
lyric mountain
#

but I do use react for frontend and spring for api

solemn latch
#

no need for markdown, just css.

weary socket
knotty zodiac
lyric mountain
#

java as backend

weary socket
#

Oh ok

solemn latch
lyric mountain
#

I make transactions using websockets not GET/POST requests

weary socket
#

Why using websockets and no GET or POST?

lyric mountain
#

safety, speed and simplicity

weary socket
#

So your Frontend Is communicating over websockets?

lyric mountain
#

also websockets work as a two-way phone

#

instead of GET/POST one-way direction

weary socket
#

Oh ok

#

Ah ok uhm could I ask you in dm? I have a couple of questions

lyric mountain
#

you could ask here tho

weary socket
#

Ok but these are damn long

#

so

lyric mountain
#

no prob, maybe someone with similar questions might be helped during our convo

weary socket
#

If the user gets redirected to Discord and clicks on authorize , the user is moved to my url with the parameters code and state. How do you for example get them and create a token?

lyric mountain
#

you mean with oAuth2?

vivid fulcrum
#

you need to exchange the code you get for a token

weary socket
#

I made that the user gets redicted to my rest routing in Spring and Spring is reading out the code

vivid fulcrum
#

a pseudo example of that is provided in the official docs

weary socket
vivid fulcrum
#

the code isn't in the header

knotty zodiac
#
<html><head><style>body {
   color: black;
   font-family: arial;  
}
</style></head><body><p><strong>GodBot</strong></p>
</body></html>
``` i have this and still cant force a theme?
weary socket
vivid fulcrum
#

it's in your url

#

it's a url parameter

weary socket
lyric mountain
#

like, once the user authenthicates it'll send a custom url to your destination url

weary socket
#

yes

lyric mountain
#

you gotta grab the provided param and make another request to discord

#

this time, you'll exchange that code for a token

solemn latch
weary socket
#

But what did you do to get the token? Also a RequestMapping?

lyric mountain
#

which you then use to get user info

weary socket
#

uhh code

#

sry

knotty zodiac
weary socket
#

I made this only to show me that its getting that

#

This is the Same am I right?

lyric mountain
#

you don't need to map headers

#

since it's a GET request with url params

weary socket
#

ok

#

So i`ll get this code now and exchange it with the post to a token....But thats what I am doing..The user is then stuck in a white screen because i am not redirecting him am I right?

lyric mountain
#

yep, because you're doing it wrong

#

like

#

imagine this:

weary socket
#

xD

lyric mountain
#

this is oAuth2 flow in a nutshell

weary socket
#

Yes the user is giving me over the link the code...I exchange that and get the token and then?

lyric mountain
#

user sends to your backend the custom URL, which you use the code to exchange for the token, then you return whatever page you want to the user

weary socket
lyric mountain
#

it does, I said backend

weary socket
#

yes thats why I am asking....The backend returns a html?

lyric mountain
#

no

#

it redirects the user to the page you want

#

thing is, you're stopping in half the process

weary socket
lyric mountain
#

you're getting the url code and returning it to the user

#

you need to exchange the code for the token with discord

weary socket
lyric mountain
#

oh ok

weary socket
#

Ok did you use React?

lyric mountain
#

yes

#

but it'd work for whatever you used for frontend

weary socket
#

Its getting event better for my questions xD

lyric mountain
#

this is my "simple" redirect

#

most of that is unnecessary

#

just database and flow stuff

weary socket
#

Because If I want to redirect the user then to the frontend dashboard where he can pick every Server he wants....But how can I redirect the user to the page and let it show every server?

lyric mountain
#

the important part there is http.setHeader

weary socket
#

?

lyric mountain
#

for example

weary socket
#

sry again I am new to the frontend stuff..

lyric mountain
#

there I'm setting the Location header to https://mysiteurl.com/Loading?s=whatever

#

and the status to 302 Found

#

which will make the browser redirect the user to that url

weary socket
lyric mountain
#

it's a page

#

look, I'll show a tangible example

#

brb

weary socket
weary socket
lyric mountain
#

user clicks "login"

weary socket
#

yes

lyric mountain
#

authorize

weary socket
#

yes

lyric mountain
#

loading page

#

meanwhile:

#

request is sent to big messy code

#

once authenticated, user gets redirected to dashboard

#

success

weary socket
lyric mountain
#

nvm, wrong stuff

#

that retry_after is if I'm being ratelimited

weary socket
#

oh ok

#

Ok and now to the part I have the biggest problem

#

I got the access token

#

So now my User has to be redirected to the dashboard am I right?

lyric mountain
#

yes

weary socket
#

Ok so how could I then redirect the user to a dashboard that contains the name for example?

#

or Servers?

lyric mountain
#

do you have said dashboard done?

#

like, the page

weary socket
#

what?

lyric mountain
#

did u make the page?

weary socket
#

Did you mean if i already have written the dashboard?

#

Ah

lyric mountain
#

yes

weary socket
#

no but I want to

lyric mountain
#

make it first then

weary socket
#

Thats why I am asking how I make it responsive with react

lyric mountain
#

that's a react topic then, not oAuth2

#

sadly, it falls under web designing

weary socket
#

ok and now?

lyric mountain
#

so there's little I can help you unless you have something already done

#

you need to make the page just like you'd make any other website

weary socket
#

ok

cosmic forum
#

Anyone know what tag to use to prevent html from being rendered?

lyric mountain
#

once you have the page done you can connect it to the backend

lyric mountain
boreal iron
#

you mean comments?

cosmic forum
weary socket
#

How do I connect it?

sour flame
#

...

lyric mountain
weary socket
#

oh oh

lyric mountain
#

A - pass the token via url param (DON'T)
B - connect the site to the same database your webserver use (preferrably don't)
C - make more endpoints in your webserver so you can use fetch to retrieve data from it
D - make a websocket connection

#

goes from A (easiest) to D (hardest)

weary socket
#

Which one is the savest and best?

lyric mountain
#

websocket

weary socket
#

ok...Tell me xD

modest maple
#

D is also one of the hardest to scale

lyric mountain
#

that's what I'd say

#

if you have little web/network knowledge, it'll probably be the most frustrating path

weary socket
modest maple
#

I wouldnt say websockets are the best solution for most stuff

cinder patio
#

C is the way to go imo

lyric mountain
#

in his case it is

cinder patio
#

websockets only if the data gets updated live

weary socket
weary socket
lyric mountain
#

try the fetch way

weary socket
#

I want to keep it live

cinder patio
#

Then websockets is the way to go

lyric mountain
#

then upgrade if you feel necessary

#

oh

weary socket
lyric mountain
#

only for bigger payloads

modest maple
#

polling every n is probably easier

cinder patio
#

Well, I guess if you want to update them every 5 minutes then fetch is still better

lyric mountain
#

like card collection

cinder patio
#

but if you want live updates then websockets

lyric mountain
#

which if I sent through websockets the request would scream at me

modest maple
#

even things using 1s intervals will use fetch just because load balancing

weary socket
#

So what should I use I just want to display a List fo Servers?

modest maple
#

fetch

lyric mountain
#

definitely go fetch since you'd have more work for negligible advantages with sockets

weary socket
#

ok now I need to know how a websocket works xD

lyric mountain
#

no

#

go fetch

weary socket
#

oh

lyric mountain
#

if you just want to list servers, sockets would do no good for you

weary socket
#

ok with fetch its just POSTS am I right?

lyric mountain
#

yep

weary socket
#

Ok so if I do it like that

lyric mountain
#

don't use GETs because of sensitive data

weary socket
#

How would I now build the page with that data.

cosmic forum
lyric mountain
weary socket
#

what?

lyric mountain
#

just like you did to retrieve oAuth2 code

#

create another one to retrieve user data

#

you might need some kind of token authentication system to prevent fake requests

weary socket
#

What are you using for this?

lyric mountain
#

spring

weary socket
#

I also have spring....But what do you mean with authentication system....How could I build one in Spring? Or should i first just code that fetch stuff?

lyric mountain
#

I can't really show you an example of data retrieval with POST since I've moved off fetch

#

but I have some stuff around here

#

lemme see..

lyric mountain
#

for example, my code to view shirocanvas

#

then the code to auth token

#

the former image returns the token in a base64 format, so I just parse it on whatever receives it

#

(just as a note, copying that code won't work)

weary socket
lyric mountain
#

yep, after finishing oAuth2 exchange I return a payload containing basic user authentication info, which then I use to retrieve data from my api

#

so, as long as you're logged in my website, you have the token with you

weary socket
#

What does the cookie spam on every click on that page?

lyric mountain
#

if the token for whatever reason invalidates or is missing, the site returns you to the homepage

weary socket
#

ok

lyric mountain
weary socket
#

oh

lyric mountain
#

cookies are just "variables" saved on your browser

weary socket
#

oh ok

#

So on a post you just put into it the token everytime you send one?

boreal iron
#

What he actually means are session vars

#

As long as the session is active the vars being cached in the browser for that website

weary socket
#

yes I get the session id and then can get the token from that and then see if its valid and if yes then return that shit and so on

#

How long is a cookie in that browser or session var?

lyric mountain
#

as long as you want tbh

#

or as long as the user doesn't clear cache/cookies

boreal iron
#

The sessions ends if you close your browser
A cookie can be there forever

#

(until you clean it up)

lyric mountain
#

localStorage and sessionStorage

weary socket
#

Ok so I need session vars am I right? It should not stay forever

lyric mountain
#

the latter clears once you close the page

lyric mountain
#

it's good to invalidate after some time

boreal iron
#

Sessions are no more physically written on the disk they’re usually being held in the RAM

lyric mountain
#

but requiring login eveytime user access the page is annoying af

boreal iron
#

That makes the difference to cookies

weary socket
#

@lyric mountain is your code on Github?

#

I would like to see some things so I understand that better

lyric mountain
#

the api is, the website isn't

weary socket
#

oh 😦

#

Dammit

lyric mountain
#

the endpoint stuff

weary socket
#

ok

lyric mountain
#

I advise not to copypaste my code since 99.9% the code relies on intertwined stuff

weary socket
#

no I dont want to...I just want to understand everythingf

lyric mountain
#

try to ignore database-related stuff, which composes 70% of my code

weary socket
#

Ok so like a manual for me:

  1. Discrd Redirects the user to my backend
  2. Backend is reading code and exchanging it to the token
  3. If Token success , send cookie with the token and redirect to /dashboard
  4. On acces to dashboard , react is sending a post with the cookie token to my backend and retrieves the data.
#

Everything correct?

lyric mountain
#

nonono

weary socket
#

oh whats wrong?

lyric mountain
#

the token I refer to is a custom token

#

like, I keep a table of tokens for each user that accessed the dashboard

weary socket
#

Yes like a hashmap: cookie token= 3248947 -> token "sdkfjdskfj"

lyric mountain
#

if you use the oAuth2 token you'll have a always-changing value

lyric mountain
#

not at all

weary socket
#

?

#

Can you tell me an example?

lyric mountain
#

for example, an entry of my token table

#

when the oAuth2 flow ends, I find what's the user's token

#

and add it to the payload

#

THAT token is the one that's stored on the user's side

weary socket
#

I dont understand

#

I only have at the moment the discord auth token from the user

#

and then?

lyric mountain
#

forget the auth token

#

also, technically you don't have it

weary socket
#

ok

lyric mountain
#

since you exchanged it for the user info (like the id)

weary socket
#

Wait...I can only use that token once?

lyric mountain
#

well, no, but you should

#

tokens expire very quickly

weary socket
#

168

#

In my case

lyric mountain
#

604800 millis

weary socket
#

oh there it says s

lyric mountain
#

so about 10 mins

#

what you really want is the ID not the token

#

I send that id to my backend, which gathers user info and returns a payload back to the user

weary socket
#

I dont think thats true...I just made a request one hour later and it worked

weary socket
lyric mountain
#

yes

#

the userID is the reason you use that oauth2 afterall

weary socket
#

Ah so the cookie is the userId...It sends me the User ID and I search the Token with the userID and then make a request with it if its valid

lyric mountain
#

no

#

you don't have cookies yes

#

the user id is in the backend currently

weary socket
#

yes

lyric mountain
#

you choose what to return to the user

#

if you want to return the user id or not is up to you

#

the thing is

#

you'll either be using the id or a token to make transactions with the backend

#

while userid is enough, tokens are safer since they're quite impossible to guess

weary socket
#

but I cant do much with the users ID if i want for example the guilds he is on...I need that Bearer token

#

Holds seconds...Not miliseconds

lyric mountain
#

oh, well

vivid fulcrum
#

the tokens last exactly a week

weary socket
lyric mountain
#

my bad

#

but anyway, you CAN do much thing with the userid alone

vivid fulcrum
weary socket
#

oh ok

vivid fulcrum
#

i stopped bothering with refresh tokens and just made the cookies expire after a week

lyric mountain
#

for example, use the userid to gather info by using your bot

lyric mountain
#

or use a more complete oauth2 request

weary socket
weary socket
vivid fulcrum
#

pretty much

#

but the auth token is wrapped in another level of encryption

weary socket
#

ah so you encrypt the auth token and put the crypted token as a cookie?

vivid fulcrum
#

so i can store multiple values in that encrypted token and decrypt it server-side and pull out the values

#

yup

#

it's just a good protection layer

#

you generally don't want to expose any sensitive data to the end user

vivid fulcrum
#

so when you encrypt it, to the end user the cookie is useless

weary socket
#

so for example the token weoiuzrefbbk is now encrypted to we9uierzreow and this is the cookie ?

vivid fulcrum
#

yup

weary socket
#

What are you using to encrypt it?

#

@vivid fulcrum

vivid fulcrum
#

symmetric encryption

#

just a standard aes256 method

weary socket
#

Can you show me a example?

vivid fulcrum
#

well

#

uh

#

my code is using aspnet

#

but sure

weary socket
#

JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties.

#

Would this also do that for me?

vivid fulcrum
#

that's pretty much it

weary socket
#

nice

#

What do you store in that cookie? You meant you stored more that the token

stoic haven
#

hello

#

can anyone help me ?

vivid fulcrum
#

the auth token and some more things related to my API

#

aka when the user is authenticated

#

storing their guilds, roles, whether they're an administrator for my bot etc

#

it's complicated to explain when you don't know what aspnet is

#

but basically just a bunch of Claims

weary socket
vivid fulcrum
#

um

#

oh

#

just got you

#

was about to say that you can't do that with react

#

but you meant using react as the client app

weary socket
#

So you cache all the data like guilds , the auth token and some other things in that token so you dont need to request again in the DB?

stoic haven
#

How do I sort room names in order?

vivid fulcrum
#

i barely store anything in a db

#

everything is in memory

#

but yeah

#

https://github.com/cryy/quiccban here's a repo from an old project that uses asp.net core + react + discord authentication

GitHub

Easy to use discord moderation bot with a web UI. Contribute to cryy/quiccban development by creating an account on GitHub.

weary socket
vagrant prairie
#

how can i make a string of numbers to words

#

eg

#

if ${coins} is 1,000,000 itll change to 1m

vivid fulcrum
#

there's probably a library for that

#

which language are you using

vagrant prairie
#

djs

vivid fulcrum
#

language

vagrant prairie
#

nodejs

#

js

weary socket
#

Ok so now for my manual xD:

  1. User takes code from discord auth to my callback
  2. I am exchanging token , storing it and send a cookie back (encrypted with this token) [backend]
    3.User gets redirected to for example mysite.com/dashboard where React is building the page from my data?
vivid fulcrum
vagrant prairie
#

thanks!!!

weary socket
#

nice

#

and if I have done 1 and 2 with that cookie I am going to ask you with the building page stuff if its ok

vivid fulcrum
#

sure thing

vagrant prairie
vivid fulcrum
vivid fulcrum
vagrant prairie
#

my bad sorry.

distant ledge
#

Hi so im getting this error and im confused on what i should do?
access to script at '' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, chrome-untrusted, https.

vivid fulcrum
#

what are you trying to do

distant ledge
#

im basically making a html website

#

like thats it

#

and when i try to link it with the main.js

vivid fulcrum
#

are you trying to load the file using local paths

distant ledge
#

it gives me that error and then tells me the function im trying to call doesnt exist when i click the button

vivid fulcrum
#

don't

#

read the error

distant ledge
#

but i dont have a server?

vivid fulcrum
#

doesn't matter

distant ledge
#

like idk where to host this at

vivid fulcrum
#

CORS browser policy blocks you from using local paths

distant ledge
#

ooooooo

#

i get it

vivid fulcrum
#

if you just stay with relative paths

#

i.e. ./main.js instead of file://main.js it should work fine

distant ledge
#

ohhhh

#

i get it

vivid fulcrum
#

if you're intersted as to why cors is blocking file://

#

it's so random ass html files can't access literally every file on your pc

distant ledge
#

i fixed it!

#

thank youuu

eternal osprey
#

aight thanks boys for the help here regarding my phone issue.

#

I just came to the conclusion that i am fucked big time as my icloud isn't synced, neither can i log in using my pc as it requires "allowing the login attempt" to be done.

distant ledge
#

hi guys how can i export a function and variable from the same js file?

lyric mountain
#

Just dont use export default

#

Then import {a, b, c} from "blablabla"

distant ledge
#

but i tried that and it tells me it didn't find any exported variables

lyric mountain
#

Show code

distant ledge
#

okok

#

and this is the error

#

i changed it from find to filterName and im getting the same error

#

i fixed it!

#

i just removed the whole thing and only kept the filterPokemon function

lyric mountain
#

find isn't present in data.js

#

you literally have only 1 method

distant ledge
#

but then i get another errorwaitWhat

lyric mountain
#

what error?

distant ledge
#

which is Index.html:39 Uncaught ReferenceError: findPokemon is not defined
at HTMLButtonElement.onclick (Index.html:39)

#

im using

#

OnClick on HTML

lyric mountain
#

because findPokemon isn't exported

distant ledge
#

nah but im importing main.js into html

lyric mountain
#

you can't import what's not being exported

distant ledge
#

and its just not finding the function.. should i export the function too

lyric mountain
#

obv

distant ledge
#

cause findPokemon is in main.js

lyric mountain
#

where the function is doesn't matter

distant ledge
#

ah i get it

#

my bad

mental raven
#

How can i get the client id of my bot through code in discord.py

lyric mountain
#

what matters is whether it's being exported or not

#

think of it like a door

#

you can't pass a door that's closed

lyric mountain
#

take that with a grain of salt tho

#

read the docs to be certain

mental raven
#

ok

distant ledge
#

i added export

#

but im still getting the error

lyric mountain
#

you still need to import the function

distant ledge
#

you're right

#

im a newbie im sorry

lyric mountain
#

dw

plain holly
#

how to make text look like this?

lyric mountain
#

css

#

<div class="inline-code">The text</div>

#

then```css
.inline-code {
background-color: "#333333";
font-weight: "bold";
}

#

or something like that

earnest phoenix
#

hey what is webhook_path in top.gg example for vote webhooks in python language also what will be right choice for webhook_port

lyric mountain
#

path is your endpoint path

#

port is the endpoint's port

earnest phoenix
#

Hm means?

lyric mountain
earnest phoenix
#

Hm

#

What i have to put in webhooks_path

#

i maded a Webhook for voting

lyric mountain
#

your webserver address

earnest phoenix
#

oh

earnest phoenix
lyric mountain
#

what language are you using?

earnest phoenix
#

python

lyric mountain
#

well, you do need to create a webserver first

#

look up about flask or stuff like that

earnest phoenix
#

Hm a guy told me that dbl have webserver included in their module

lyric mountain
#

that for js, idk if python has it

earnest phoenix
#

Oh

slender thistle
#

topggpy has built-in webhook

earnest phoenix
slender thistle
cosmic forum
#

Anyone know any good apis that use puppeteer to take a screenshot of a webpage? I’m using statically.io atm, but they cache the screenshots, so it doesn’t change very often.

solemn latch
cosmic forum
earnest phoenix
#
from discord.ext import commands

import dbl


class votes(commands.Cog):


    def __init__(self, bot):
        self.bot = bot
        self.token = 'top gg token'
        self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='What To Put Here?', webhook_auth='my_authorization', webhook_port=5000)

    @commands.Cog.listener()
    async def on_dbl_vote(self, data):
      print("Received an upvote:", "\n", data, sep="")

    @commands.Cog.listener()
    async def on_dbl_test(self, data):
      print("Received a test upvote:", "\n", data, sep="")

def setup(bot):
    bot.add_cog(votes(bot))
    print("Vote Webhooks is working!")```
#

so i was using this code for my vote webhooks but i confused what to put in webhook_path

sudden geyser
#

I think it's the path for the server to receive requests from.

copper cradle
dusky sundial
earnest phoenix
#

idk why

dusky sundial
#

Are you using the right url on your webhook page?

#

Is port 5000 open on your network?

earnest phoenix
dusky sundial
#

You can't use Discord webhooks, this is an actual webhook

earnest phoenix
#

Oh

#

How to create them?

dusky sundial
#

The library creates a webhook server for you, which is why you specify the path and the port