#development
1 messages ยท Page 753 of 1
This is my first website ever so I'm not sure about what you mean by fixed or dynamic
Devices viewing the site will change so I guess height will change
i think it would be best to switch to flexbox then
vertical centering is a bit complicated with dynamic heights
but you can play around with stuff like css height: 80vh; margin 10vh auto;
another option is display:inline-block and vertical-align:center
but thats old fashioned and depends on a few other factors
The code I gave above does exactly what I want tbh
But the problem is when I zoom in to make it like mobile or view mobile site using inspect element, it is lot messy
it will be messy regardless, responsive design is not easy
most people use media queries when designing responsive
media queries let you define specific css based on screen size
other than that, try using flexbox (display:flex)
And btw, I saw a lot of websites using filenames like u3h43iu4h234njsdjanhd.js kj34hj23uih4.css why are they like that? And also, the js file is not like the js I type. All of them are hard to read
they are minified files
also obfuscated
minified files are basically just a way to save space
possibly obfuscated yes
!function(e){function t(t){for(var n,a,i=t[0],o=t[1],s=0,u=[];s<i.length;s++)a=i[s],Object.prototype.hasOwnProperty.call(r,a)&&r[a]&&u.p
most likely transpiled and minified
There are like tonnes of lines so I definitely doubt that
Idk what is transpiling but will google it
transpiled js is basically modern js converted to old js for compatibility with old browsers
if you want to you can waste a few days of your life reverse engineering and deobfuscating that code
and by the time youre done, new versions will be deployed
there are plenty of deobfuscators out there lul
sounds like a dumb way to avoid the grind ๐ช
I don't want to get that code back to js version like we use to read and copy
I want mine to go to that so it'll be hard to read
dont bother, it doesnt add any security to it
But my files are like so open
All the things I type, they can get with inspect element
all js files are open
client side code is impossible to protect, its been like this since always
the most you can do is annoy people
client side rendering 
Yea, but many won't bother to use the code if it's too messy like that
you can use an obfuscator, there are many out there
or you can convert to JSFuck
:D
what's the point in that tho
just slap a license on it and call it a day
Just some space sucking
yeah, put a license on it, and sue people who steal it
kk
thats the best protection
And I also will be making an api from my bot that should only be used by me
you wont get everything from a license but you'll get a decent portion
But you know, anyone can use it if they read the source
but if you wanna use an obfuscator, you can just google "js obfuscator" and you'll get dozes of results, like this one https://obfuscator.io/
JavaScript Obfuscator is a free online tool that obfuscates your source code, preventing it from being stolen and used without permission.
And even if I use an api key, they can still use the api key
validate the request ip
I heard ip are static
Does domain work?
nope
referers and origins can be spoofed
Wut
when you make a request from the browser, the browser sends origin and referer headers, informing the server where the request came from
those headers can be faked
So only IP works?
ip can also be faked basically
Then what am I supposed to do
but it does provide some degree of protetions
what you should do is put all your api code in the server side
and then make requests to it
Well what is the server here
for example
I thought my vps is the server
instead of
browser -> api
do
browser -> server -> api```
server is the server that is serving the webpages
so basically, you connect to another page
and this page should make the api connection
Ok, can't any user connect to the other page which then will make the requests?
Then isn't it same?
and wont see the api code
plus it is protected behind a webserver
subject to ddos protection and rate limits
I just thought to use 1 api key which gonna get data from my bot
your api is not hit directly
The api key is some random encrypted text which is decided by me
yes, but this key and the entire api logic should be in the server side, not sent to the client
What I wanted to do is not give/get data to/from users if it's not me
how about jwt
Bye "me" I mean the website
The website say example.com should only be able to give/get data
the website yes, in the server side
servers usually have a static ip, which you can use to restrict ips
while clients are mostly dynamic ips
so you can use ip restrictions from server to server
jwt is good enough
plus an api key
i used jwts to serve content from my cdn
a big plus is using an auth system though
i havent used jwt, but they still cant be used from client right?
its just server2server
jwt is sent in the headers
sometimes stored in sessions
the good thing about jwts is that you can store your password in them which becomes encrypted
yeah but if you generate jwts client side thats probably a nope
yeah
jwts are mean to be created on the server
never on the client
anything confidential shouldn't be created on the client
Well I still can't get how this client to server to api process works
if the client makes a request that it needs a to server then server will request the api to get a and return it to client
Can't another user request the same a using same code
the user won't see how the request is made and where
the whole point is hiding the api source
Yea that will be hidden but making a request to the server is still visible right
a request to your server, yeah
The server gives the data to those who requests the data
yeah, it's why all of this auth/login/jwt stuff's been mentioned
The request to server code is on client side right>
yes
client makes request to somewebsite.com/some/path, the server receives the request to /some/path and you can decide what to do there
Yea, I get that but I just can't get how I'm going to hide this auth code or whatever the client needs to send to the server to verify itself
have the client send a jwt
or simply, sessions
sessions are cookie based so they can't be faked
That jwt is random each time?
a proper jwt implementation, yes
everytime the client hits the server, the server sends the jwt to the client
and it's regenerated everytime
if the jwts don't match, throw away the request
why do u need to have this sort of api setup anyway Stickz?
jwt is encrypted data that the client needs?
the thing is, there is no way to prevent people from accessing data on a website, because websites are built to serve data. whatever you put there will be accessible one way or another. what you can do is try to prevent it from being accessed by non-browsers
which is where sessions, tokens, and jwts come into play
@modest maple I thought like no one can access if I put api key but they can still get it from client side
what do u even need todo tho?
I'm very unclear about jwt. Can anyone give me a good link about how to do that
I just need to get and post data to my bot's server
just an api key is enough for that then
you are looking into using ajax for that, correct?
god ajax is a pain
i'm confused whether this is just backend or front & back
Let me tell it very clearly wait. Like if I request for /guilds the bot will send a JSON like { "guilds": 100 } and that 100 is what I use in my webpage
im assuming its front and back, since the whole client side api key
so your page makes a request to /guilds to get the data and then display it to the user visiting?
Yea
does it request it server side or via ajax?
ajax = javascript requests without page reload
aka a massive pain in the ass to scrape
ie: click a button, display loading spinner, render the data
Yea, like that
But for some sites, it'll load along with page itself. Like in that example, it'll say Bot is in x guils when the page reloads
so your javascript code should make a request to /ajaxguilds and the /ajaxguilds should internally make a request for /guilds
this is ajax
Ok
It depends on how/where you make thr API request.
wouldn't it be simpler just to update the count every X minutes or when the bot gains a guild. rather than making a request on every page visit
i feel like the best thing here would be to do server side rendering if that's the only purpose
if your page directly makes a request to /guilds and then loads then full content, that is a server side request, and its much safer
person accesses /
the / page makes an internal request to /guilds
Ok I get it
I would HIGHLY suggest you make all requests on your server before it sends the page to the client. Why? Because in order to make requests on the client side, the client also needs to have the API credentials, which the client can then see if theyre smart enough.
then returns the content with the guild data already loaded
The server is the server which hosts the website or what?
server side requests are much safer and simple than ajax, the only reason for using ajax is if you're loading heavy/slow data, or for cool user experience
yes
@grave mist yes, as in, your website server.
That is what I'm referring to as client side so far tbh
client side is the browser the person is using
The client is the end user viewing your page
Ok where would the code for that be placed?
are you using a node server? like express?
Well, I don't have a server tbh. Since this is my first website, I'm using glitch.com
Yea, express
You have 3 parts basically.. client (the website viewer), server (web host for your site), and services (the APIs).
EVERYTHING you code in express, is server side
client side is EVERYTHING you put in res.send()
everything you send to the viewer
What you wanna do is:
Client makes request for your page -> server receives request -> server makes requests to services -> services return data to server -> server generates page with data baked into it -> server sends page to ient -> client sees page
So should I use another glitch project right here to get data from and api and send to my website project?
No, build it into the page code.
you can do it from the same project
like add a file called server.js and do things there?
I'm really confused. Sorry if the question is too dumb
...what language are you using to write the site?
you can do it however you want, as long as you dont send the js code to the viewer
having cleared the whole server/client misunderstanding, the way you were doing it since the beginning is probably the correct way
I mean personally I write all sites with PHP, including requests, and output from thay, so, the way you're doing it is like Tim ssid, probably correct (?)
I do like this mainpage.html ->
<html>
...
...
<script>request</script>
...
</html>
I know that's why I said it is so unsafe
LMFAO yeah so thats sending the request to the client
I shouldn't add the script file there right?
yeah because that way you are sending the js code to the viewer
you should process the script inside the express code
I can just do an inspect element and grab your API key with that kind of code
and only send the resulting html
That's what idk how
that way would only be secure if the backend required the user's cookie to be signed in
Make a js file -> request, send to page -> load page?
Yeah except he's using just flat HTML...
you know, html is basically a text file that the server sends to the browser right?
so you can literally code an html text in js
and use express's send functions
no need to literally send an html file
I never tried that
oh, yeah, you can't have anything secure without an actual backend server running
there is also something like EJS, which lets you weave html and js code together
I eould suggest looking into learning either PHP or JS to generate the page, then send the resulting HTML that way tbh
PHP still powers 87% of all sites
whatchu mean, php 7.3+ is quite alright
Ok so I put like
main.html
<html>
<script src.... file.js />
</html
```?
no
No
remove it completely from there
that's the same as having the code right inside of the script tag
Yea
@earnest phoenix I did mean v7+ btw lolz
Eww
python is only slow if you dont give it UNLIMITED POWER
try clojure
Can you send me a basic example of what files I need to put, what I have to insert in which file to display hi in my main page
@grave mist js app.get("/", function(req,res) { put your js code here. call your api using something like node-fetch get the result build an html text let html = `<body><div>${api result}</div></body>`; res.send(html); });
i've personally had best experience with h2o, atreugo, and asp.net core for webservers
I can give ya a simple PHP example as well later, if ya don't wanna deal with the BS that is Express
php is just a ded meme at this point
hes already running a node server, moving to php will be a pain in the arse
But what about the css and aren't those html things needed
plus does glitch even support php?
@quartz kindle true, true. Conversions are difficult for the inexperienced.
yes, you can put your links to css files in the html text
@modest maple lel not really but okay
php is widely used
it has its ups and downs
but there are much better alternatives out there
Like this?
html = `<link rel='styleshee' ....>
i use php in most of my websites
yes
basically just rebuild your entire html file as a string
I see
Thing is, basically all frameworks are either PHP or JS wrappers.
PHP is still the dominant language for web, with over 85% of sites online.
Thanks for the help
or you can look into EJS, which is a way to write html files and add server side js code to them
Which is better
its the same, just EJS lets you stay with separate files for pages instead of working on them as strings
(you could always combine all three lolz)
could always design your own framework
could always hire me to make it for you
i'll hite you
Ok now my things are safe. The last one I can't get is dynamic loading of pages. If you can waste your time to help me, then ok but if you don't want, you can just give me good link so I can learn from it
what do you mean with that
Like discord
You're just loading certain page elements dynamically, or...?
Aren't they called as dynamic webpage loading?
idk, doesnt ring a bell
Like when you click a link, instead of loading whole page, just replace the contents
yes, you can do that with ajax
you're thinking of a single page app
Like for example, this channel link is /a and you go to /b that won't reload page but just edit the part and set the contents of /b
Yeah that would be able to be done via AJAX
good luck
I guess you guys wasted 30 mins for me
It is an hour tbh
That'll be 47.50 USD plus tax for consultation services @grave mist :V
will discord even exist in 10 years?
same lul
Tbh, I saw https://mee6.xyz/ and wondered how it just have a link to only one js file and loaded the page. I guess this is how it did that. the file link is https://mee6.xyz/assets/7dfb0ad6a5015c86547c.js which is what I was saying like having random names and js is hard af to understand
eww mee6
you can't really reverse engineer something like that
half of the code is in the backend
Did they do the obfocust or whatever the process you called to make the file hard to read
What is the process they did
I also do that so no one ever can read the code
publishing which is minimization and obfuscation
isnt that basically a react app?
yeah
i also have that running on a project i'm working on
https://uwavy.com/ - i just don't really obfuscate since i don't care about people getting the front code because what's special is the backend
Ok but I like this lol
And searching up on google said that those files name are like that cuz
of stopping page loading from cache
yes, every time you update your js file, its likely that the client will not get the updated version until their local cache expires
but if you rename your files, it will bypass that
What about the cache they stored
It will go after it expires?
Or will go automatically if the page doesn't use that resource in the cache
cached files expire after their expiration timer is reached
Ok and my website embed isn't showing image. I used
<meta property="og:image" content="logo.png">
Hey Tim, what did you say the point of adding an id field to my ships table was for?
@earnest phoenix your files looks like obfuscated tbh
I canโt remember
yeah that's just the react app reference
Ok, isn't this right
<meta property="og:image" content="logo.png">
should be yeah
if you want the embed to display, discord requires opengraph data for the title and description
Yea, but I want it to display the image too at the right
Like it did for mee6
And other websites
i know
i'm just saying if you want to display the embed you need the title and the description too
@quartz kindle what did you say the Iโd field in my ships table was for again
you also might have to wait a bit for discord to scrape the website for og tags
It has them too
It displays title, description but not image
Well, it displays now
Idk how
react >>> *
I tried right after inserting that a few hours ago
but react routing is messy
and a bit slower than angular
i still have yet to try angular
i heard angular's routing is heaven
I think preact is adding vue style routing
isnt 5 sec for each status not allowed?
yes its to quick
help, every time I say the command it wont respond do any of you know why? https://prnt.sc/qefpsz https://prnt.sc/qefqoa
there are also no errors
that's not how if else works
read up your language's basics
also
instead of doing that
just make a map
wait, so should I remove the else's and then it would work
?
damn it im finna get a try_it_and_s.ee
that's not what i said
i know
ok, now it only responds once...https://prnt.sc/qefya4
and wont choose random
I am assuming to use the methods inside a class I must first make an instance of that class>
?*
can i ask a problem with quick.db here?
I don't see why not
But you might find better luck in Plexi Devs server (the people who made quick.db)
i asked there before 2 hours and no answer yet
so
any help why not setting prefix
const db = require("quick.db")
module.exports= {
config: {
name: "prefix",
description: "Change the prefix of the guild!",
usage: "<prefix>",
category: "moderation",
accessableby: "Moderators",
aliases: ["pr", "prfx"]
},
run: async (bot, message, args, prefix) => {
if(!message.member.hasPermission("ADMINISTRATOR")) return message.channel.send("You dont have permission to perform this command!")
let prfx = args.join(' ')
db.set(`guildPrefix_${message.guild.id}`, prfx)
message.channel.send(`Successfully set the prefix to **${prfx}**`);
}
}```
Sorry, im new to quick.db
do you get any errors?
no
I'm going to be straight up, quick.db is pretty bad
^
since you're using javascript I recommend mongodb https://www.mongodb.com
We're the creators of MongoDB, the most popular database for modern apps, and MongoDB Atlas, the global cloud database on AWS, Azure, and GCP. Easily organize, use, and enrich data โ in real time, anywhere.
it's a good beginner db
and has good javascript support
hmmmmmmm
I would say sqlite would be easier to start off with
then transition to mongodb
valid point
How can I save the values from a class to a database
in many cases sqlite3 is a good beginner db
or JSON if itโs a small bot like for less than 50 guilds (and if youโre afraid to begin with a DB)
sqlite is still better
please avoid file collation "databases"
Go use quickdb
He needs to save values, not really to create a database
itโs a sqlite wrapper and beginner friendly
Often devs are using it for saving something like custom prefixes per guild on small bots
And itโs nice tho
I donโt use quickdb, canโt help sorry
Hey
hi
@earnest phoenix is prfx a number
no
Well you only can store numbers
oooooo
ok
and still not response to new prefix https://infinity-coding.is-inside.me/pz4v8bri.png
do console.log(db.get(`guildPrefix_${message.guild.id}`)) right after you set it
and show the console output
also show how you check for prefixes
console output https://infinity-coding.is-inside.me/V8LuWeJE.png
https://infinity-coding.is-inside.me/fGgZpZJp.png checking for prefixes
hmm
show your full message event
and since we're already here, also console.log(await db.fetch(`guildPrefix_${message.guild.id}`))
Oh shoot
I forgot
Tim do you know how I could give myself ore?
Like through eval
so I can test some stuff out
you can do user.resources.iron = 3874508
Okay thanks
[2019-12-22 16:28:51] TypeError: User.sync is not a function
[2019-12-22 16:28:51] at StarReady.run (C:\Users\Aj\Desktop\StarGaze\events\ready.js:13:14)
[2019-12-22 16:28:51] at StarReady._run (C:\Users\Aj\Desktop\StarGaze\node_modules\klasa\src\lib\structures\Event.js:101:15)
[2019-12-22 16:28:51] at KlasaClient.emit (events.js:198:13)
[2019-12-22 16:28:51] at module.exports.run (C:\Users\Aj\Desktop\StarGaze\node_modules\klasa\src\events\onceReady.js:49:22)
I seem to be having trouble making a table
but I set User as a global variable
thats an empty collection lol
check your try/catch/.catch statements
it always happens when someone uses a commadn
so im guessing it has something to do when i grab commands
[2019-12-22 16:33:35] Uncaught Promise Error:
[2019-12-22 16:33:35] SequelizeConnectionError: SQLITE_CANTOPEN: unable to open database file
[2019-12-22 16:33:35] at Database.connections.(anonymous function).lib.Database.err (C:\Users\Aj\Desktop\StarGaze\node_modules\sequelize\lib\dialects\sqlite\connection-manager.js:61:34)
This is an odd error
I fixed the other one
would there be a way to save a collection to a database
or a class
of some sort
wot
need help on this thing
ReferenceError: help is not defined
at Client.client.on.message (C:\Users\Tails Era\Documents\GitHub\Tattles-News-Bot\Tattles-News-Bot\bot.js:30:46)
at Client.emit (events.js:198:13)
at MessageCreateHandler.handle (C:\Users\Tails Era\Documents\GitHub\Tattles-News-Bot\Tattles-News-Bot\node_modules\discord.js\src\client\websocket\packets\handlers\MessageCreate.js:9:34)
at WebSocketPacketManager.handle (C:\Users\Tails Era\Documents\GitHub\Tattles-News-Bot\Tattles-News-Bot\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:105:65)
at WebSocketConnection.onPacket (C:\Users\Tails Era\Documents\GitHub\Tattles-News-Bot\Tattles-News-Bot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:333:35)
at WebSocketConnection.onMessage (C:\Users\Tails Era\Documents\GitHub\Tattles-News-Bot\Tattles-News-Bot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:296:17)
at WebSocket.onMessage (C:\Users\Tails Era\Documents\GitHub\Tattles-News-Bot\Tattles-News-Bot\node_modules\ws\lib\event-target.js:120:16)
at WebSocket.emit (events.js:198:13)
at Receiver.receiverOnMessage (C:\Users\Tails Era\Documents\GitHub\Tattles-News-Bot\Tattles-News-Bot\node_modules\ws\lib\websocket.js:789:20)
at Receiver.emit (events.js:198:13)```
Wait updating the resources won't do anything. They don't get saved to the database do they? @quartz kindle
@sick comet read the error
I do have help defined
you don't
you do have an object that's called embed defined
which has a help property
so i do embed:help?
testing
SyntaxError: Unexpected token :
at Module._compile (internal/modules/cjs/loader.js:721:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:829:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)```
read the error

you maybe shouldn't copypaste from a tutorial and instead learn the language
That's too hard for most apparently
doubt
X
it's dot notation, not colon notation
i based my first bot off of tutorials and self learning
use a dot instead of a colon
you dont know how to get a property on an object and you have all of the more advanced stuff perfectly set up
people here have a good bullshit-o-meter ๐
hey
i made this and it works
open source to boot
(and I did give credit where it is due)
yes and
how do you know when someone has voted for your bot and use it for daily rewards
Not that I know of
In JavaScript, is there a way to add something at a certain index of a string instead of having to slice into arrays, splice, then join?
substrings?
ok
How can I save the values of a class after a new instance is made to a database
I have this class with a build method that makes a ship. And I need to save the ship to a database
I already have the table made
My bot isn't send message in this server
it show Missing Permissions error
I have tested in this server only my bot isn't working but online
anybody know?
it doesnt have permissions in the channel its trying to message
lack of message sending, image sending or embed
embed only
check the channel perms
make sure it has perms for messages and whatever else it needs
how to use get_user_vote/get_bot_upvotes for getting info about votes
I don't think I understand that question
You just call that function on an DBLClient instance
ok?
How would I update multiple things at once using sequelize
v5?
Yes
Would I just use bulkUpdate
Wait a sec
Iโm not using v5 of sequelize apparently Iโm using v4
Wait how can I check which version Iโm using, it looks like Iโm using v4 but it also looked like v5
Okay never mind
5.21.3
Okay now thatโs cleared up back to figuring out how to update multiple things at once
https://sequelize.org/v5/class/lib/query-interface.js~QueryInterface.html#instance-method-bulkUpdate
An easy-to-use multi SQL dialect ORM for Node.js
Would this work?
@west raptor
hey, does anyone know of any guides / tips on setting up a bot with k8s?
@earnest phoenix
i wasn't really able to find anything on google, apologize if i just missed it.
holup
Thanks April.
how big is your bot
o hi
hello
like 5k servers but i like overcomplicating things ok
yeah i dont have like 8 severs ๐
honestly the resources on learning how 2 k8s is really confusing but yeah
lol imagine using k8s with a 1 server bot
could be done
but realistically, would anyone with a 1 server bot know what k8s are
ravy does it
who dat
some cool dude
oh.
thanks ๐
def __init__(self, bot):
self.bot = bot
self.token = 'dbl_token' # set this to your DBL token
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True)```
How would I make this work in my main file
Save it as for example index.py.
But make sure its saved in the same folder with your main.py File.
import index
# your code here
@outer niche
So if I put it in my main file it should work
There is still some coding
What do I need to change because I cannot figure it out
import index
var = index.TopGG("BOT", "TOKEN")
index.DBLClient()
``` @outer niche
im not sure cause i dont really code or have coded in py
So instead of the class I should put that
Thats what should go in your Main File
Lol this is confusing
ikr
So instead of the stuff I put up there that is what goes in the file
Yes
Ok
Make sure you save the index and main file in the same folder @outer niche
Okay so let me see if I'm comprehending this right I put what you sent in the main file and what I sent in another file
exactly.
Okay I'm going to try
Now this isn't all in the same program will all work because I run everything off of ideal
@outer niche
import index
var = index.TopGG("BOT", "TOKEN")
index.dbl.DBLClient()```
Ok
wow i was not that much wrong
@outer niche Are you using cogs
@sick cloud yea
use Kurasuta
for discord.js
if ur getting started with clustering
i'm doing it from scratch
Anyone Use Glitch?

That is the header of the website I'm creating and see the left end and right end, the color doesn't take the full space of header. I mean it should be like a full rectangle that covers the header space instead of being like a part in the website
That color is not that different from the color below, so it would be hard to see I guess
If you still can't get what I mean, see this
The color is same for the whole header but in my site, it isn't like that so I wanna do like that
Have you tried setting width to 100% of the header
Nope
That might help
And it doesn't work
Hm
no change tbh
@grave mist just css
What do you have the width set on the body
Ok I'll just css but HOW
That could work too
Didn't set width on body
I forget absolute positioning is a thing sometimes
scss best xd
Scss is complex for a beginner
Depends really
the basics are the same
I'm not that good in positioning with absolute
you should position your header with absolute
No parent element there
use fixed or just normal
normal gives output same as the one I gave up
absolute and fixed looks same here
My code is like this
Ah margin
Learn HOW TO MAKE A WEBSITE IN HTML AND CSS STEP BY STEP FROM BEGINNING TO END. WEBSITE DEVELOPMENT TUTORIAL
Here in this tutorials you will learn how to make a website in HTML, CSS and Bootstrap, I'll show you how to create responsive modern looking website step by step wi...
K thanks
I learned css from looking at templates
From there?
And also I watched some videos
Just search "html landing page template"
It's hard for me to learn lol
Lemme watch that vid
And you can help with this header thing only? lol
This time you'll see what the real problem is
Click open original and see it
Can anyone answer this quick question? Where should I use id attribute and where to use class attribute in tags
ids are unique, classes are not
how can i check if a object in a database exists?
depends on the database, but basically just try to access it
I know that ids are unique but idk what they mean by unique. Like I can just use it once?
yes, a given id should only be used once
Ok thanks
ids are also faster than classes
Every tag can have id and class?
Usually you want to only use one of the two at least I found you do other people are different
Really depends what you are trying to do
@quartz kindle i use enmap,
let object = this.client.db.get(`object_${message.guild.id}`)
if(object === null) object = true
i tried that but wont work
As tim said ids are unique and classes aren't
@earnest phoenix if(!object) { //object doesnt exist }
oh
Also, you said that server side doings things and sending the pages from express to the client side is better for me. I should send the whole file as html for each webpage request like index, about etc. in one express file. How would I do requests from client side
Like if they click a button, I have to request to my server which then sends a request to the API and then display it?
Display what?
@silent cloud Lmao
data
Well
Like if they click a button after page loads which needs to get the data from api what should I do?
request to the api when the button is clicked then render the data recieved from the api on the page
or do whatever you wanna do with it
But I said I want to hide the api link
That's why I asked like if they click a button, the website should send a request to itself which then will send request to the api
just curious this means you dont want your api to be public
Yea obviously
i see
what endpoints are being protected, like file upload or
do you just not want people to have access to it
I will let someone else take over I have to go eat dinner
Also one thing you could do to prevent such a thing from happening
use api keys
but that is a crude way of doing things
there is better ways but that is just one of em
I do use it to make request but what I mean is my site is example.com and they click a button called a which then requests to b.com which will return b as response then the example.com should say b
ok look
if only you are going to use it, just pass something in your request headers
I want this to happen in server side that's why I asked like whether I should make my example.com request to example.com/a which will request to b.com and ....
So that I can hide that the request is being made to b.com
in example.com you click button a
button a makes an ajax request to example.com/getdata
example.com/getdata makes an internal request to api.com
api.com returns data
example.com/getdata returns data
button a receives response
tim why so many redirects
Web development with some bit of securing data is hard
Cuz I want to hide api.com here
???
its not so many requests lol, its standard procedure for ajax apis
mk
api.comshouldn't be known by users that I'm usingapi.comto get data- Even if they get they can't use cuz of api token
The above procedure does the 1st thing
But I got a small doubt like when I load a site, it'll say waiting for example.com
Will it say api.com ever?
no
Ok then there should be no way to get the link then
Wouldn't it be smart to put your api token in a .env file?
or will they not be able to see it either way
Idk how to use .env files apart from glitch.com tbh and I don't wanna use it cuz I somewhat can't trust that it is completely hidden
They aren't hard
server to server requests are invisible to the user, no matter what
????
unless they hack/break into your server
Ah okay
or if they intercept your connection and you're not using https
intercepting connection is a worry these days
like im pretty sure inspect element has a waterfall view that allows you to view requests
so just follow that to api.com
server to server requests will never be shown there
The reason I want to hide api.com is cuz I don't want users to update data. Getting data won't be of much problem but if they can change it, then that's it
is that really true
yes
mmm
thats the whole point of server2server
SERVER -> SERVER2 (API)
^
CLIENT```
client never sees server2
Well btw, if example.com/getdata sends request to the api.com when a request is sent to example.com/getdata, can't I just paste that url in my browser and then it'll send request to api.com and returns data?
yes
which is again the same conversation we had yesterday
use sessions and tokens to make sure the request came from a browser
would it not be effective to use a simple login system for this
yes
Can I do like this
request site ip === example.com/getdata
You said ip can be faked right
everything can be faked basically
I better get off from computer
lul
Hard to protect data in my side
look into how to protect ajax endpoints
there is not much you can do
but you can do stuff like CSRF tokens
which are easy to implement
Ok, you said those request from client to server to api but this still comes the same way as yesterday
That request from client to server code is in html
same as yesterday, manually build the html as a string in your express endopoint, or use EJS
I mean like I have index.js
app.get('/'....
res.send(`<body><button>a</button><script>button click event requests to example.com/getdata </body>`)
....
So that I can make it send request if a button is clicked
const { MessageEmbed } = require("discord.js");
const { get } = require("superagent");
module.exports = class extends Command {
constructor(client) {
super({
name: "trigger"
});
this.client = client;
}
async exec(message, args) {
let disabledEmbed = new MessageEmbed().setFooter(
"Sorry, the Module where the Command is in, has been disabled!"
);
let checkAvaiblity = this.client.db.get(`funModule_${message.guild.id}`);
if (!checkAvaiblity) checkAvaiblity = "true";
if (checkAvaiblity === "false") return message.channel.send(disabledEmbed);
let user = message.mentions.members.first() || message.author;
const { body } = await get("https://emilia.shrf.xyz/api/triggered")
.query({ image: user.displayAvatarURL })
.set(
"Authorization",
"Bearer Mjg1NDE4MDAwNzM0MDkzMzEy.uM7sovZdzFBtyRn9hoLv691KM5JnRAem7AUirrj8cA"
);
const embed = new MessageEmbed()
.attachFile({ attachment: body, name: "trigger.gif" })
.setImage("attachment://trigger.gif");
message.channel.send(embed);
}
};
why
FILES
somefolder
scripts.js
style.css
index.js
package.json
index.js
app.get(/, (req,res) => {
res.send(`<html>
<head>
<link rel="stylesheet" type="text/css" href="somefolder/style.css">
<script src="somefolder/scripts.js"></script>
</head>
<body>
<a href="getdata"></a>
</body>
</html>`)
})
app.get(/getdata, (req,res) => {
// make api request here
// res.send(result)
});
scripts.js (this is what the client sees)
add handler do the a, and make it an ajax request, google it```
<a href="getdata"></a> is the button right
its a link, you can make it a button with css, or you can use a button element and put the getdata part in the script file
theres a million ways to do it
couldn't you use onclick="js"?
Yea, but where would I place the onclick event
with js being the JavaScript code
Wherever I place, it is visible to client afaik
it has to be added in the script element iirc
@earnest phoenix try catching errors in the get request
And that's where the code requesting to example.com/getdata will be place right
Use this where?
in the client side js, scripts.js
I think everything is visible except index.js so the code requesting to example.com/getdata should be in there too right
yes
"in there" is index.js?
I cannot add my server in discord server list
scripts.js is visible right. So can't they see which site I'm making request to?
I'll be back in 2 mins
yes its visible, they can see you're making a request to mywebsite.com/getdata
Tim Can you check my discord channel dm me
why cant you add it?
How can they not see the website? Can you send a small example of scripts.js pls
Sorry for wasting all your time
Googling this won't be of much help than asking to a real person
you cannot hide /getdata
you can use either an xmlhttprequest or use fetch
2019-12-23T08:49:58.274776+00:00 app[worker.1]: at Client.<anonymous> (/app/xolo.js:74:11)
2019-12-23T08:49:58.274778+00:00 app[worker.1]: at Client.emit (events.js:210:5)
2019-12-23T08:49:58.274782+00:00 app[worker.1]: at GuildMemberRemoveAction.handle (/app/node_modules/discord.js/src/client/actions/GuildMemberRemove.js:20:62)
2019-12-23T08:49:58.274785+00:00 app[worker.1]: at GuildMemberRemoveHandler.handle (/app/node_modules/discord.js/src/client/websocket/packets/handlers/GuildMemberRemove.js:9:38)``` I'm having this error
Here's my code ```let t = member.guild.channels.find(c => c.name.includes("good") || c.name.includes("left") || c.name.includes("leave") || c.name.includes("bye"))
if (t){
var messages = [
***${member.user.tag}*** just left us.,
***${member.user.tag}*** left and jumped in the cliff,
***${member.user.tag}*** left the server and died,
***${member.user.tag}*** will just feed the chickens and he'll come back,
***${member.user.tag}*** went to Pluto,
***${member.user.tag}*** forgot to flush the toilet,
***${member.user.tag}*** has been eaten by a shark,
***${member.user.tag}*** went back to Pre-Cambrian Era,
Goodbye to ***${member.user.tag}***,
We hope you comeback ***${member.user.tag}***,
RIP, ***${member.user.tag}*** left the server
]
t.send({embed: {
title: `User left`,
color: 15158332,
description: messages[ Math.floor( Math.random() * 11 ) ],
timestamp: new Date(),
}
});
}
});```
Basically, you're doing member.guild.channels.find(c => true || false)
Array.includes() return either true or false
That's not the problem
guild.channels should be a Collection of GuildChannels
a GuildChannel doesn't have a send method
So that could be why
...
Your code should be aware
That not all channels that match your find
Will be TextChannels
No
member.guild.channels.find(c => {
c.name.includes("good") || c.name.includes("left") || c.name.includes("leave") || c.name.includes("bye")
})```
Can you explain me what c.name.includes("good") return?
You thinking it'll return the name?
true or false
the find method
requires a function
that returns true or false
so
like
ok chief
Ye
You confused 100% or you confused me 100%
You're confused
His function is right
It's supposed to return true or false
Which it does
- on d.js v12 collection#find ONLY accepts function
the channels collection includes all channels, text, voice, categories, etc... if a voice or category channel passes the find function, it will cause that error
ye if u want to find multiple and see if one of them exists
he can use array.some()
how to get users by their name?
Library?
What will be the full code @restive furnace
member.guild.channels.find(c => c.name.includes("good") || c.name.includes("left") || c.name.includes("leave") || c.name.includes("bye") && c.type === "text") Like this or no
You don't need the braces {}
mixing && and || is not a good idea
better to separate them like this (something || something) && somethingElse
do ur array like let urArray = ["channame1", "channame2"]
msg.guild.channels.find(c => urArray.includes(c.name) && c.type === "text) @heavy void
sry spuunfeed
is there a server boost event?
I think so
I'd expect it to be part of member update
Ohhh
you could check for when a member gets added the role nitro boosters
i make my bot wow
2 possible ways
TheNoob27
you could check for when a member gets added the role nitro boosters
i don't think that would work well, since a person can boost a server multiple times and there's no sure way to know which is the booster role (as far as i know)
the discord api docs don't say very much on boosts
but i'm sure that either the guild member update or guild update events can help
What is even going on
there's no sure way to know which is the booster role (as far as i know)
the role is managed, all you have to do is search for a manged role named server booster or whatever the role name is
i think i have an idea: listen for the boost system messages and the booster is the message author
those i mean
how to get the last user that just boosted the server?
I donโt think there currently is a method of doing so
You might have to manually track this yourself
you'd have to loop over all members and check each of their premiumSince property
with djs master
^
I was thinking of a more crude way
But that way is better
Whatโs the ratelimit on looping through all the members in a guild
yea
not all of them
most of them are cached
ye
Mmm right
Wouldnโt it be smart to loop over all the members then every few days to get the most recent
or you could check someway is the member cache, or simply add on start up fetchAllMembers
^ the 2nd choice makes ur bot ram & cpu usage bigger
^^ and ur bot slower
as moonlight said, you can listen to the boost system message
but if the server disabled em
D.py probably handles it better xd I was told never to use fetchAllMembers unless I had to as it was api spammy
you can listen to memberUpdate events
Also Super has a point
in djs master, memberUpdate should provide updated premiumSince
yeah, memberUpdate would be better
should this work, for me it doesnt js const filter = m => m.content.startsWith( "2" || "3" || "4" || "5" || "6" || "7" || "8" || "9" || "1" || "10" ); await message.channel .awaitMessages(filter, { max: 1, time: 60000, errors: ["time"] }) .then(collected => console.log(collected.message.content)) .catch(collected => console.log(`After a minute, only ${collected.size} out of 1 voted.`) );
No it shouldn't
Your code will resolve "2" || "3" || "4" || "5" || "6" || "7" || "8" || "9" || "1" || "10" and pass the result to startsWith()
Which will simply be "2"
@warm marsh if i wont use await, then my whole command screws up
๐
If you use await the .then won't be called
Use regex for it?
i use regex for links
const filter = m => /^[1-9|10]/.test(m.content);
kk
this is my output so how i access into content, cuz collected.message.content and collected.content wont work
Because it's a Collection
<Collection>#first
Could anyone help me with my website?
When I try to store json from it it stores something else
ping me pls
Show code
routes.MapMvcAttributeRoutes();
No
what's this for btw
what's the problem here
System.InvalidOperationException: 'A direct route for an action method cannot use the parameter 'action'. Specify a literal path in place of this parameter to create a route to the action.'
Got it. Apparently I can't use the word "action" in a route therefore it was causing an issue
ok quick question, whenever i try to do
message.attachments.url```
the value is null even if i attach an image to the message
attachments sounds like an array of Attachment

