#development
1 messages · Page 1732 of 1
client.ping is not a thing
prob the module that isn't installed
No.
owh yeah that too
You probably meant the ping on the client.ws
It's not that too—that is your error.
alright, thank you
Which node.js should I choose in the visiual studio code?
I recommend you install the latest version on your system.
I download
result[0].First Name isnt possible
What language are you using?
But i should select a programming lang
js
Use bracket notation: result["First Name"]
Which node.js should i select
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.
I wanna get result[0] as well
Then result[0]["First Name"]
Thx i will check it out
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
you are waiting 5 seconds then sending results.length emails at once
why does createOverwrite delete all channel permissions?
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
you have to use async await or a recursive function. setTimeout and .then does not wait for anything
Can ı get a tic For my bot without more than 1 shard
but how can I use await in a for loop 
tic?
just like the sleep function you showed does
It is for more than 100 server
and btw my code malfunctioned and sent mail fricking 99 times to a same person
Discord doesn't care about the shard count since bots usually start sharding at 2500 guilds
you mean the verified icon next to the bots name?
Yea
ye you dont need sharding
yes
@quartz kindle hey there
triviabot is now moved over to D++
the speed boost is amazing
everyone loves it
Comparison in performance?
noticeable
nice
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
im amazed at how fast you pulled it off
Add trivia quiz games to your discord server with this free to use bot from Brainbox.cc. Featuring over 100,000 questions, nitro prizes, team play, leaderboards, quickfire rounds, community rewards, a user friendly dashboard, there is nothing quite like this bot. Invite now!
youre a god
you can see all the figures drop away on here
he just has too much time to spend 
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
lol I don't have enough time
after a second do something
I had to disappear into my coding cave for a month and the triviabot mods thought I'd left them lol
in this case 1000 seconds
millisecond*
lmao
oh i see now
no wait
so what deos code before sleep mean
do stuff
I am confused
When it reaches sleep() it'll wait 1 second before running code after it
1s may be the default value
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 
If you're running down the street then take a 30-second break, you're doing the same as sleep(30000)
then set sleep to 5000
but can it not repeat itself again and again and
this is what I was doing earlier
earlier you were not waiting
that
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
I use Zoho
that nodeJS package is promise based only 
KKK ne zman onaylanır botum =D
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
Onaylandı zaman botun yanında onay işarteimi olacak
@sacred juniper Demi?
Hayır
Top.gg ye eklenmiş olacak
O dediğin şey 100 sunucudan fazla sunucuda bulundugunda geliyor
Senin bota bakabilirmiym dm den atsana botunu
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
like if I do this in a for loop
and I don't put any code after await sleep()
will it still work because it's a foor loop and it will just do same thing (above code) over and over
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
How can ı see my vote credit?
How do I check, how much characters the message has, to avoid such errors?
.length
Use .length
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?
👀
Nice
Extreme doing fine with that canvas stuff? 
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..
e
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.
yes, we're aware of that
are you trying to write a blog post or did you have a question in there somewhere?
Stop trying to dotpost
Not here, no
This isn't an advertising platform
this is a development channel where we usually help people with their code problems
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 😂😂
im here to find out how to get a noumeon bot
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?
lemme copy them
608ff0f1c4f8d4016c4f1c69
608ff0f1c4f8d4016c4f1c69
I do not see any difference
output this: ```
thatmap.keys().map(i => "${i}").join(' ');

could this be relevant
found the solution, it was a object id which was saved, I converted to a string and it juts has one key
one sec
lol, they did the same thing
yes
i guess its not lol
have to sit here for like 4 hours waiting for the bot to be approved lol
4 months*
ftfy
4 hours? It's gonna take up to 2 weeks or more, dude
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.
@umbral zealot thank you for answer
ok
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.
why is it buggy?
Whenever I add text to the image it turns into boxes.
node-canvas is literally the only one. everything else is built on top of node-canvas
thats a problem with your fonts
I wasn't using any custom fonts, just Arial which came with the package
where are you hosting?
replit
no font comes with the package
huh, well it used to work
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
hey how do i see what folders these indexes are coming from
pm2 monit
get a better terminal lol
use the left right arrow keys to switch screens
and up and down arrow keys to scroll
yeah i am trying to do that
so for each index entry, switch to the lower right screen and scroll down to the file path
but it doesn't show the folder it is in
if you get a chance name your processes 
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
yo se
oh wait
so
thay havent buyed the www.discord.com
because discord.com is the domain
the www is the server
www is a subdomain
ye
Often enough they're all on the same server.
a domain usually goes to a server by ip. then subdomains and pages go to different folders inside the server
yeah the web server will usually control this (though it can also be controlled at the domain DNS level)
there are also cases where sub domains point to different IPs
you make a account lets say you call it account
depends on the setup tbh
then you make a html project called www
you get www.account.repl.co
so then i make a nother project for istance project
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
it would be project.account.repl.co
yes
how tho?
domains are just paths pointing to some place
subdomains
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
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
ye but you can create other projects tho
From where I can get the canvas fonts
yes, but not subprojects
any fonts website
In file.tts ?
they you can make one like (jus.ll).account.repl.co
yes canvas accepts more font formats, including ttf, woff, eof, otf, etc
Any website idea
ttf
😅
@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?
no, there is a small delay
the guild is only removed from the cache a bit after the event
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
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
Write a more efficient code.
Your question is too broad and imprecise to answer.
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
true
`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
is it rust?
use a where
there
where where
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
createInvite returns a promise
the action is not instant, createInvite sends an HTTP request to discord to make the invite
How i can do it by code?
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?
put the banned id in a cache and ignore it if it's already in there
I want to get a basic code of get invite server link
aright I was thinking about doing that but didn't really know if it was a good idea
That's a breach of privacy
how do you suggest I structure the cache? an array per each guild?
yeah, or a set. A set is probably better because you'd want to remove the ID in the guild ban event
ye smart
await
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
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
unlikely but its a small check so I doubt it would matter
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
oh
for discord.py, does await client.fetch_user(id) have a rate limit
thats actually really smart
I doubt the cache will ever have more than 30
but 29 extra is kinda useless
Thanks 😄
Yes
ty for your help
ok thanks
np
Checking the character length may not be reliable in all instances due to the size of Unicode characters
But it’s a nice step
So you should make sure you handle the error in case it still fails
so i switched from Flask to Quart which is async and now i'm struggling with adding await on every function i wrote
Python will emit a warning if you forget to await an asynchronous expression
and the real trouble is Quart doesn't give any error if there's one in Jinja templating
just shows 500 server error
anyone got any clue about why sometimes requests will take ~5 seconds?
To?
internet speed
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].
or the server on the other side,where you sent the request
app.use(Express.json());
app.use(Express.urlencoded({extended: false}));
You don't need body-parser
Express is the exported object from "express"
its funny because discord works fine for me but the bot takes 5 seconds for requests, on the same pc
ah ok
hmmm idk then
do you mean express or Express? I have called the express module like let express = require("express");.
Then it's express for you
ok
and im logging my requests so its not like im making too many requests
so im just confused
how can we setup vote webhooks in python?
https://docs.top.gg/ has the docs for the python library and everything you can do with it
Anyone who using lavalink music bot?
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????
because sha256 outputs binary data...?
md5 is a plaintext hashing algorithm, sha256 produces binary output
this has nothing to do with postgres
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
why would they add that? sha256 is not meant for strings
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
why not tho?
either remove text signature of md5 or add it to sha hashers, just for the sake of standardization
sketchy
You just need to state the issue
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
it really cant
Also just a little words of wisdom: you aren't going to get far in terms of music with Heroku
where?
you aren't going far with anything other than websites or APIs with heroku
ah
where can i find valid buildpack for ffmpeg
Only npjs.com?
now i got this error
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
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
lol shouldn't u be asking that to a electronic device repair service
iphone: charge more for a fix than for a new phone
iPhone doesn't have external storage
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
doesn't iphone have some sort of data migration tool?
I don't think so. You might be thinking of android to ios
damn, apple's pit is deeper than I thought
when you get a new phone, you can have basic data like app list not including app data synced and photos and such synced
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
i can unlock it and use it for half of the screen.
Just get the screen repaired
bottom half is dead
If you got a MAC the app I mentioned will help you
they won't save my data i guess.
cheaper to buy a new phone
I did it once and it removed all my pictures etc
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
You're only getting the display repaired though
why would that delete all your data
they format it
all technical assistance does that (at least where I live they do)
Never heard something like that
Come to brazil
Better not lmao
no thanks
@rustic nova its written in the discord developer docs on how to do but i can't understand anything in that
that's why libraries are a thing
but there is a way to make bot without lib
lol
Why do you insist on not using a lib?
Do you know any html/css?
not much
bruh
you won't get far
kkk
there is, but there's also a way to build a car without machinery
¯_(ツ)_/¯
the same age limit as discord in general
16 now i thought
i still couldnt seem to figure out how to change the page theme 😢
Somebody ever built a Webinterface with React and Spring as Backend?
is this what your looking for? https://www.w3schools.com/cssref/pr_background-image.asp
for forcing the theme on top.gg
oh like light/dark theme
yes
bot settings next to bottom setting.
https://i.woo.pics/6a0d29ff2a.webp
Somebody ever built a Webinterface with React and Spring as Backend?
Or only with Spring Boot?
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.
but im using an <iframe> that is light
And only a Backend Unding Spring?
iframe isnt css.
almost
well, technically, yes
What you mean with almost?
so if u was to use a markdown to html and use style tags, that would then work?
but I do use react for frontend and spring for api
no need for markdown, just css.
Oh so no backend for a Webinterface?
no i mean because i currently have markdown. so if i use html with style then it will let me force theme?
Oh ok
if you use css, it will let you.
if you dont, then it wont let you.
I make transactions using websockets not GET/POST requests
Why using websockets and no GET or POST?
safety, speed and simplicity
So your Frontend Is communicating over websockets?
you could ask here tho
no prob, maybe someone with similar questions might be helped during our convo
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?
you mean with oAuth2?
you need to exchange the code you get for a token
I made that the user gets redicted to my rest routing in Spring and Spring is reading out the code
a pseudo example of that is provided in the official docs
that's 50% done
yes I mean how did he get the code from the header
the code isn't in the header
<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?
What do you mean? You made it like that?
sry I meant that
like, once the user authenthicates it'll send a custom url to your destination url
yes
you gotta grab the provided param and make another request to discord
this time, you'll exchange that code for a token
html head and body are already done.
try removing all the tags which already exist in page.
But what did you do to get the token? Also a RequestMapping?
which you then use to get user info
?
uhh code
sry
i get this after, meanwhile it does let me select one this time
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?
Thank you..........Now I got someone who really had to deal with this xD...Now I know I could do that better
xD
this is oAuth2 flow in a nutshell
Yes the user is giving me over the link the code...I exchange that and get the token and then?
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
Wait I thought the frontend displays the stuff?
it does, I said backend
yes thats why I am asking....The backend returns a html?
no
it redirects the user to the page you want
thing is, you're stopping in half the process
ahhh
you're getting the url code and returning it to the user
you need to exchange the code for the token with discord
This was just for a test for me
oh ok
Ok did you use React?
Its getting event better for my questions xD
this is my "simple" redirect
most of that is unnecessary
just database and flow stuff
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?
the important part there is http.setHeader
?
for example
sry again I am new to the frontend stuff..
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
I dont understand with Loading....You are redirecting the User to https://mysiteurl.com/Loading?s=sajdhja but what does that Loading do?
Cant I redirect the user to https://mysiteurl.com/Dashboard and then just show all servers?
ok
user clicks "login"
yes
authorize
yes
loading page
meanwhile:
request is sent to big messy code
once authenticated, user gets redirected to dashboard
success
For what a while with retry_after?
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?
yes
Ok so how could I then redirect the user to a dashboard that contains the name for example?
or Servers?
what?
did u make the page?
yes
no but I want to
make it first then
Thats why I am asking how I make it responsive with react
ok and now?
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
ok
Anyone know what tag to use to prevent html from being rendered?
once you have the page done you can connect it to the backend
stop html from being rendered?
you mean comments?
yeah, I tried putting a script tag between code tags but it's still getting rendered
Ok I just took my template I coded yesterday
How do I connect it?
...
that's the thing, you have 4 options
oh oh
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)
Which one is the savest and best?
websocket
ok...Tell me xD
D is also one of the hardest to scale
that's what I'd say
if you have little web/network knowledge, it'll probably be the most frustrating path
yes....I have time and I want the best possible solution for my webinterface
I wouldnt say websockets are the best solution for most stuff
C is the way to go imo
in his case it is
websockets only if the data gets updated live
ok uhm. I got someone who has more than I...So tell me more xD
Yep it does
try the fetch way
I want to keep it live
Then websockets is the way to go
Did you used that?
only for bigger payloads
polling every n is probably easier
Well, I guess if you want to update them every 5 minutes then fetch is still better
like card collection
but if you want live updates then websockets
which if I sent through websockets the request would scream at me
even things using 1s intervals will use fetch just because load balancing
So what should I use I just want to display a List fo Servers?
fetch
definitely go fetch since you'd have more work for negligible advantages with sockets
ok now I need to know how a websocket works xD
oh
if you just want to list servers, sockets would do no good for you
ok with fetch its just POSTS am I right?
yep
Ok so if I do it like that
don't use GETs because of sensitive data
How would I now build the page with that data.
I mean the user gets redirected to https://www.mysite.com/dashboard and then? How does it send a POST and how does it display it then?
I made an "advertisement" system today and I'd like some feedback on it: https://ad.aakhilv.repl.co/
add a fetch inside componentDidMount targeting your data retrieval endpoint
what?
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
What are you using for this?
spring
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?
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..
oh what are you using now?
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)
There you get the token.....How do they send you everytime the token? cookie?
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
What does the cookie spam on every click on that page?
if the token for whatever reason invalidates or is missing, the site returns you to the homepage
ok
that's not how cookies work
oh
cookies are just "variables" saved on your browser
What he actually means are session vars
As long as the session is active the vars being cached in the browser for that website
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?
The sessions ends if you close your browser
A cookie can be there forever
(until you clean it up)
localStorage and sessionStorage
Ok so I need session vars am I right? It should not stay forever
the latter clears once you close the page
depends
it's good to invalidate after some time
Sessions are no more physically written on the disk they’re usually being held in the RAM
but requiring login eveytime user access the page is annoying af
That makes the difference to cookies
ok
@lyric mountain is your code on Github?
I would like to see some things so I understand that better
the api is, the website isn't
the endpoint stuff
ok
I advise not to copypaste my code since 99.9% the code relies on intertwined stuff
no I dont want to...I just want to understand everythingf
try to ignore database-related stuff, which composes 70% of my code
Ok so like a manual for me:
- Discrd Redirects the user to my backend
- Backend is reading code and exchanging it to the token
- If Token success , send cookie with the token and redirect to /dashboard
- On acces to dashboard , react is sending a post with the cookie token to my backend and retrieves the data.
Everything correct?
nonono
oh whats wrong?
the token I refer to is a custom token
like, I keep a table of tokens for each user that accessed the dashboard
Yes like a hashmap: cookie token= 3248947 -> token "sdkfjdskfj"
if you use the oAuth2 token you'll have a always-changing value
Like that?
not at all
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
I dont understand
I only have at the moment the discord auth token from the user
and then?
ok
since you exchanged it for the user info (like the id)
Wait...I can only use that token once?
yes 100h or smth like that
168
In my case
604800 millis
oh there it says s
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
I dont think thats true...I just made a request one hour later and it worked
UserID?
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
yes
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
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
oh, well
the tokens last exactly a week
oh the math genious xD
nah i used to create a fuckton of sites using discord oauth
oh ok
i stopped bothering with refresh tokens and just made the cookies expire after a week
for example, use the userid to gather info by using your bot
Or like that 😄
or use a more complete oauth2 request
So you are saving the auth token in a cookie which expires after a week?
I would make more oauth2 requests
ah so you encrypt the auth token and put the crypted token as a cookie?
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
yep
so when you encrypt it, to the end user the cookie is useless
so for example the token weoiuzrefbbk is now encrypted to we9uierzreow and this is the cookie ?
yup
Can you show me a example?
Would this also do that for me?
that's pretty much it
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
I know what that is...I wanna do that with react
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
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?
How do I sort room names in order?
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
I need to for my Bot....For example what yt channels and so on
how can i make a string of numbers to words
eg
if ${coins} is 1,000,000 itll change to 1m
djs
language
Ok so now for my manual xD:
- User takes code from discord auth to my callback
- 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?
thanks!!!
seems good to me
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
sure thing
wait how do i use it
are you using SSR?
the readme literally shows you how
my bad sorry.
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.
what are you trying to do
im basically making a html website
like thats it
and when i try to link it with the main.js
are you trying to load the file using local paths
it gives me that error and then tells me the function im trying to call doesnt exist when i click the button
ye
but i dont have a server?
doesn't matter
like idk where to host this at
CORS browser policy blocks you from using local paths
if you just stay with relative paths
i.e. ./main.js instead of file://main.js it should work fine
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
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.
hi guys how can i export a function and variable from the same js file?
but i tried that and it tells me it didn't find any exported variables
Show code
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
what error?
which is Index.html:39 Uncaught ReferenceError: findPokemon is not defined
at HTMLButtonElement.onclick (Index.html:39)
im using
OnClick on HTML
because findPokemon isn't exported
nah but im importing main.js into html
you can't import what's not being exported
and its just not finding the function.. should i export the function too
obv
cause findPokemon is in main.js
where the function is doesn't matter
How can i get the client id of my bot through code in discord.py
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
self.user.id iirc
take that with a grain of salt tho
read the docs to be certain
ok
you still need to import the function
dw
how to make text look like this?
css
<div class="inline-code">The text</div>
then```css
.inline-code {
background-color: "#333333";
font-weight: "bold";
}
or something like that
hey what is webhook_path in top.gg example for vote webhooks in python language also what will be right choice for webhook_port
Hm means?
for example http://example.com/topgg with port 5000
your webserver address
oh
I don't know about them much
what language are you using?
well, you do need to create a webserver first
look up about flask or stuff like that
Hm a guy told me that dbl have webserver included in their module
that for js, idk if python has it
Oh
topggpy has built-in webhook
hm?
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.
you can use puppeteer locally.
I’d like to, but repl.it (which is what I use) doesn’t support it.
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
I think it's the path for the server to receive requests from.
u also want console instead of Console
You can put whatever you want really, most people use /dblwebhook
i tried it and did a test vote but it didn't print anything in console
idk why
Are you using the right url on your webhook page?
Is port 5000 open on your network?
hm i was a webhook that i created Using integration.
You can't use Discord webhooks, this is an actual webhook
The library creates a webhook server for you, which is why you specify the path and the port
