#development
1 messages · Page 1891 of 1
youtried.jpg
I guess this will do.
https://stackoverflow.com/a/61746016
-M @calm night
double muted
holy
the code i gave is only for files in the public folder, and only works with html.
is using user.discriminator instead of user.tag a good practice?
and const guild instead of const server
should index.ts be inside or outside src? 
your choice
if it's the main for an npm package put it outside
your lib's code should be in src and the index file outside src should export everything
Is there a difference? If not, it’s probably up to personal preference, though user.discriminator could probably be confusing to those who don’t know what a discriminator is
#6969
also @wheat mesa can you tell me what's the property for user about me in detritus
Not sure, I don’t think the API even has access to that does it?
yes but even people who aren't in your friend list can see it
The problem isn’t from it being public, it’s from it automatically being collected without the user’s knowledge
The user is expecting those who know them and those in servers with them to see it, not a bot that automatically collects data from their profile that they don’t anticipate
how fun would it be to log all capybara about mes 
That would be quite fun though
intense advertising
Too bad people abuse data though 
// yes i know this is djs
guild.members.cache.forEach(m => everIncreasingCollectionOfAboutMes.push(m.user.bio));
That’s cursed
Using api that doesn’t exist, using forEach, using an array to collect about me’s instead of a KV pair, and it’s djs
bruh moment
since when have i been writing normal code
when you look at the client's code to build a wrapper just to realize bots cant use the endpoint
ok how do you eval typescript
Use the typescript compiler to compile it to js, then eval the js
says the guy who recorded 190 mb ram usage from tsc
you got a point
the point is i dont like typescript
why tho
i dont like static types
umm so im using vps for first time i have everything done instead of pm2 , its like i have latest nodejs and npm ver in root or main src but its not updated pm2
anyone knows how do i upd it in pm2
lmao its 16. smthng in the main file and 5. smthng in pm2
bad then types are important,else your code will be a green banana
why my mongodb is giving an buffering error
?
i put 0.0.0.0.0/0
I always did that
who cares

and it's no longer working
there are five zeroes
in 0.0.0.0/0
you've put 6
why not ask for help with your problem in this channel
spoonfeed

I will spoonfeed you react code if you run npm ui -g npm
nah am good, dont want react code
so rude
done
spoonfeed me daddy uwu
i-
import { useState as us, useEffect as ue } from "react";
const fn = Function;
const A = Array;
A.prototype.f = A.prototype.fill;
function Brainfuck() {
const [s, ss] = us(!0);
ue(fn("ss(!s)"), A(1).f(s));
return <a>A</a>;
}
@scarlet cliff here you go
ill let you do that
so it rerenders the component very fast and changes the effect
It's an infinite loop
yeah
Pay, I believe.
But there's no add on or something
why do you wanna upgrade ram in the first place
Because ram limit exceeded and my bot keeps restarting
then your code is bad
Reasons...
The process.memoryUsage.rss() method returns an integer representing the Resident Set Size (RSS) in bytes.
process.memoryUsage().rss/1024/1024
help
if(xp > req){ message.channel.send('Insufficient cards to upgrade')
} else if(xp < req){
doesn't work
it's the same having more than required or less
and i changed < & > too but same
when i change it it only says Insufficient cards
and now it only says the next embed
xp depends
if you want more than required or equal to the requirement do xp >= req (xp is more than or equal to req) or xp <= req (xp is less than or equal to req)
i checked it with a command
👍 i'll check
If you're dealing with a single boolean check u don't need else-if
A bot can have anything u can code
?
xp is more than 10
-bots
yeah
-bots
??
Ok
what with me?
If you're dealing with a single boolean check u don't need else-if
Then?
if (true) {
//do this
} else if (false) {
//do this
}
Makes sense?
kinda
this is cursed
oh then
if (true) {
//do this
} else {
//do this
}
k
the else would never be executed
...do you even example?
do you even grammar?
English broken
Are you trolling or being hard woooshed?
If result is false yes it will execute
but its if (true)
It's an example goddamn
You might wanna provide easier examples
if() exit;
but that'll error...
because true !== "true"
@rare mist pls view my amazing bot
Stop randomly ping the staff dude, read the guidelines and how long it takes
h4ck3r 😎
doesn't work
if(xp <= req){
message.channel.send('Insufficient cards to upgrade')
} else {
i did this too:
if(xp <= req)return message.channel.send('Insufficient cards to upgrade')
//code
doesn't work
Then your issue lies somewhere else
Log both vars and see what's the issue
And I am, in fact, trolling now
Btw, the condition u want is if (xp < req)
Bcuz if it is the same or higher than required it should pass
That's a whole statement, Sir, the condition is xp < req

How does that feel, hmm!!!11!
lmao
oh yeah
sht
Before i used args[0] so i defined it like that
and now i use args.join
i didn't change that
Did I do something wrong? roleUpdate event.
<embed>.addField("**Mentionable**", oldRole.mentionable, true);
``````js
RangeError [EMBED_FIELD_VALUE]: MessageEmbed field values must be non-empty strings.
According to the docs, I did everything correct.
oldRole.mentionable is not a string
DAMN, I have to .toString() it now?
if you want it to display "true" yes
It returned the same error. oldRole.mentionable.toString()
Oh, my bad, the entire role update embed is returning an error since most are booleans, my bad.
V13 is a pain.. 🤷♂️
Okay.. im currently lost.. but.. i need to make an axios.get request.. but the Data that i send with it must be in the body... how the f. can i do that?
The API constantly says that it gets nothing
Make sure if it’s body: { data } or like we had a few days ago data: { data }
something like that?
https://i.imgur.com/yxlvIWk.png
Dunno their requirements if the requests needs a content type, the data needs to be JSON etc.
Check the requirements for the endpoint
My Endpoint needs their request data as raw json in the body.
you are doing a .get, but it sound like you need a .post or .patch
there is no request body for get requests
ikr?
is there an api doc for the endpoint?
help
ERROR:
(node:838) UnhandledPromiseRejectionWarning: TypeError: Must specify value to add. Need Help? Check Out: discord.gg/
at Object.subtract (/home/runner/Clash-Chest/node_modules/quick.db/src/index.js:107:19)
Where is error:
db.subtract(`coin_${message.author.id}`, amount)
Amount definition:
let amount;
if(lvl === 1 && rarity === "Common")amount = 20
if(lvl === 1 && rarity === "Rare")amount = 140
if(lvl === 1 && rarity === "Epic")amount = 260
if(lvl === 1 && rarity === "Legendary")amount = 450
if(lvl === 2 && rarity === "Common")amount = 40
if(lvl === 2 && rarity === "Rare")amount = 280
if(lvl === 2 && rarity === "Epic")amount = 520
if(lvl === 2 && rarity === "Legendary")amount = 900;
if(lvl === 3 && rarity === "Common")amount = 60
if(lvl === 3 && rarity === "Rare")amount = 320
if(lvl === 3 && rarity === "Epic")amount = 780
if(lvl === 3 && rarity === "Legendary")amount = 1350
oh sorry
link
the link was in the console
Omg
I'm the author lel.. i rewrote it t... so..
Thats the Endpoint... pls. dont judge me... im still learning lol xD
router.get('/ytdb', jsonParser, (req, res) => {
var song = req.query.song;
console.log(`GET-YTDB: song - ${req.query.song}`);
if (con) {
var sql = `SELECT * FROM ytdb WHERE title LIKE '%${song}%'`;
con.query(sql, function (err, result) {
if (err) throw err;
console.log(`GET-YTDB: result - ${result}`);
if (Object.keys(result).length > 0) {
res.status(200).send(JSON.stringify(result));
} else {
console.log(`GET-YTDB: req.body - ${req.body}`);
res.status(404).send("No data found!");
}
});
}
});
help me pls
then it's not data, it's params
const x = {
"1_Common" : 20,
"2_Common" : 40,
"3_Common" : 60,
}
const amount = x[`${lvl}_${rarity}`];```
axios.get(url, { params: { song } });```
i fixed it.. main problem was that i used router.get('/ytdb', jsonParser, (req, res) => { the jsonParser
but i had to use the urlencodedParser
let embed = new MessageEmbed()
.setColor(blackColor)
.setTitle("Bot Ping")
.addField("**Message**", `${Math.floor(msg.createdAt - interaction.createdAt)}ms`, true)
.setFooter(`Responded across ${bot.guilds.cache.size} servers.`)
msg.edit({ embeds: [embed] })
return await interaction.followUp();
how can i edit and and follow up at the same time?
you were using req.query, you don't even need a parser for it
But my script says so.. idk.. it works so... i wont touch it again 😂

is this possible?
do you have the api token? if you do then you can call the api directly
What?
BTW...
Quick Question.. hehe
SQL related so..
I have a Table.. you know?
This is one of the entries
https://i.imgur.com/lzSRbAh.png
I have an SQL Query that searches for dreamcatcher whistle
If i use SELECT * FROM ytdb WHERE title LIKE '%dreamcatcher whistle&' i get no match... so.. how should i rewrite this query?
i think this makes the object into querystrings.
what does the & do in %dreamcatcher whistle&?
Woops. that was a typo from me
I was pasting the Query into DC and accidentally inserted a &
might need to convert to lowercase
WHERE LOWER(title) LIKE
Like doesn’t care about case sensitivity
i mean.. i could prob. combine both fields.. but would be extremely dirty..
oh, i see what you're doing now. that's going to be tricky
use elasticsearch
dump sql
Ngl.. im not rewriting everything again.
just add elasticsearch to the stack
search in the elasticsearch db and have that return the id for the sql db
??
oh
kk
works
yancode tf
const events = [
"messageDelete",
"messageDeleteBulk",
"messageUpdate",
];
if (!events.includes(event.toLowerCase())) {
const invalid = new MessageEmbed()
.setColor(red)
.setDescription("❌ The event ID you entered is invalid.")
return await interaction.followUp({ embeds: [invalid] });
};
I have event as the user's input, I'd like to ask how can I make it so if someone inputted messagedelete and not messageDelete?
Basically trying to lowercase all the strings in events then checking.
events.some(ev => ev.toLowerCase() === event.toLowerCase())
but also you could just
const events = [
"messagedelete",
"messagedeletebulk",
"messageupdate",
];
I can, but I will further in the code, need to capitalise them again. 🤷♂️
"messageDelete":true,
"messageDeleteBulk":true,
"messageUpdate":true,
};
if(events[event.toLowercase()]) {}
that's faster
What is :true?
And also doesn't work, lmao
let lowercased = [];
events.map((x) => lowercased.push(x.toLowerCase()));
console.log(lowercased);
if (!lowercased.includes(event.toLowerCase())) {
const invalid = new MessageEmbed()
.setColor(red)
.setDescription("❌ The event ID you entered is invalid.")
return await interaction.followUp({ embeds: [invalid] });
};
Had to do this.
works better than includes
more efficient
the code that i wrote is faster
That's just a micro-optimization which could bite you in the ass later on
if (event in events) {}
Also, why lowercase?
i was just copying the code example and improving it
I'd just use some if the events aren't 100+
i plan ahead
it's still a useful optimization. even if it's only a list of 10. that 10x optimization
O(1) vs O(n)
Yeah, 10x when 1x is literally a nanosecond, and n = 3
think about scaling
If you wanna use the keys later you'd have to use Object.keys() which kills the trade
why would you need the keys?
it's just to validate input
Because the person who asked the question said so
you shouldn't do that
the guy probably solved his issue 😂 by merging both your answers into one ig
pointless arguing is the mantra of this channel
I've made a loop by setting a new defined array into all the current array's values lowercased, then making a check. 👍
let lowercased = events.map((x) => x.toLowerCase());
console.log(lowercased);
Yup, and then setting all the values and pushing them into an array.
👍 👍 👍
actually for very small numbers of n a linear time complexity function can be much faster than a constant time one
depending on what the constant is. But at that point you're just splitting hairs
not to mention object lookups aren't technically constant time either 
oh yeah
generally you can get away with a couple hundred or even a couple thousand items in a list and do it faster in linear time than with a hash lookup
hey linear search can be constant time too if your luck stat is high enough
Luck stat 
what if my search is non linear
is that because of some overhead with creating object in js? is it that way with all languages? seems like compiled languages could fix that
Most / all languages have that behavour
Just because something is O(1) does not magically make it faster in all cases
Hashing, although it has a constant cost, is still a starting cost, you are always going to take that time to compute that hash to then do the lookup
Which often is slower than some linear lookup in a small list for example
In JS this is lesser of a thing because every is an object and although your array might be small if i remember correct node internally handles it as an object / dict anyway
You can't create all your objects at compile time and also, constant time is only considered fast because time complexity is measured in terms of growth. If we're talking about very tiny numbers that don't grow, your O(50) constant time search can end up taking more time than an O(n) search where n is a small number like 4 or 5
we say constant time is "better in all cases" because the real problems you end up solving generally involve creating an algorithm that can accommodate large inputs, not trivial numbers
I need to learn more about time complexity
learning about time complexity in CS is easy, you just need to take an algorithms and data structures class, get a university degree then unlearn all the incorrect information your prof taught you and learn it again on your own
ok you can't do benchmarks like this
you don't know what code the interpreter is actually executing
Jokes on you, I don’t have an algorithms course at my school!
and a 1.7% performance difference is well within a margin of error
js likes to give you the result of some stuff instantly as opposed to actually running it sometimes, right?
Well yes
no, it's because V8 is smarter than trivial benchmarks
I imagine the JIT has sussed out to a constant lookup
it doesn't run source code directly, there are a ton of optimizations being done
I mean
both before the code is executed and also during execution
One can argue that you should make an informed decision based on the language
also these cases are by definition trivial, you don't care whether your code takes 2 or 3 microseconds to run, you're specifically testing for a case where you have a super tiny input size
After all assuming everything will be faster O(n) for a small n in every lanuage without taking into account these optimisations are just as bad as assuming O(1) will always be faster
constant time doesn't mean 1 btw O(1000) is still constant time
O(1) is the best constant time
Well that would be simplified to O(1)
yeah cuz we don't care about how long a thing takes, we care about the growth of that time in relation to the input
so O(1) and O(1000) are the same as far as you're concerned
idk I failed calculus 3 times, probably something like that
O(0) 
Hey pal, reviews take some time as we have alot of bots to review, please wait patiently
ok bro you look smart btw
Ty
no prob
Oh thanks for the tip, I think I'll go this route
what is the best way for me to code/find a template/design a magical website
i feel like with html most templates are really OTT and more than necessary
Design it yourself ^_^
I'm struggling to lmao
if you're looking for a magical website do you not need it to be over the top lol
i mean like OTT as in TOO much detail on it
I hate sites that have way too many details on it
Xetera the sus
a lot of the computer science specifications contain bad practises and very old methods of doing things
like in A levels the cpu layout
they teach you the old cpu architecture which contains only one register called an accumulator while modern cpus have a few general purpose registers instead of 1
easy to learn but will probably fuck you over in the future
Is that what they actually teach?
yes thats part of my specification
Even Ben eater teaches more than that
i would show you the 1000 page revision book ocr but its in class
they teach you little man computing instead of actual assembly
funnily enough i find little man computing more confusing than assembly
i'm being taught Python but the exam is in OCR reference language
like bro kill me now
I have the mock mock exam on Tuesday
no
an entire language which is python, JS and Java combined
Tf
Python: len(string)
OCR reference: string.length()
its basically worse and btec version of assembly
yeh
so yeah pseudo code
its not tho sadly
pseudo code is much easier
this is actual code but like its just combined shit
they changed it in the past 3 years
i did it last year
you're doing gcses right
yes
i mean i'm fine doing it
but its the fact that lots of the stuff doesn't exist in python which most people learn for GCSE
that doesnt sound nice
nope
and there is no actual practical work for the exam
i have to prove at least 20 hours of coding though
what is this btec pseudocode
god knows
what else do you need to know
not really
:(
:)
a level computer science is pretty good so far we've been doing representation of negative numbers in binary
twos complement and sign magnitude
what
amogus
me when sus
nice nice
wait until ligma gets involved
ok
so discord.py is gone, any recommendations for alternatives/forks to use?
nextcord
or
enhanced discord.py
yea so i did some searching and it seems like there are a lot
pycord, nextcord, enhanced-dpy, hikari
which one would be the best?
is there a specific reason for nextcord over the others?
not really
well i cant really see any big differences
pycord has the most stars on github
but it doesnt have the bot ui kit
bot ui kit?
I want to make a nice looking site for my bot as a passion project, but at the same time I have a lack of time and lack of motivation to learn react
😩
I tried to make a site with raw html and css to try to get the basics down
Sucked ass
I need to learn more about html tbh
I kinda suck with div layouts
maybe react?
since it's faster to get a prototype running you might not lose motivation as fast
Yeah
anyone to help with slash cmds in cogs
why im getting this error while using pm2
^
SyntaxError: Invalid or unexpected token
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1031:15)
at Module._compile (node:internal/modules/cjs/loader:1065:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Object.<anonymous> (/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js:33:23)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
you're trying to run a file with the wrong interpreter
or trying to run the wrong file
Hikari 👀
If I import multiple weights of font from google fonts, how do I differentiate between the two in CSS?
For example, I import Poppins weight 500 and weight 200 like so: html <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@200;500&display=swap" rel="stylesheet"> but I'm not sure how to differentiate between 200 weight and 500 weight in CSS, as I use ```css
font-family: 'Poppins', sans-serif;
starting to get a hang of html and div alignment etc
actually not too bad to work with
You trying to build a static web?
yeah
Not working with react quite yet
Just trying to get a better grasp of HTML
and CSS
lol
should i deprecate aka rmv text cmds for my bot or add slash cmds and text cmds while msg intent isnt a thing yet
Its recommended
?
hi rookies
Unless your bot is not meant to be verified eg private bot
its public bot soooo
and it hasnt been verified yet still waiting for it to go in 75+ servers
Maybe give people info about removing text commands soon?
Ye its recommended
hmm when a user runs a cmd ill tell them that "this method of running a command is deprecated and will be remove soon pls use slash cmds etc. etc."
d.js v13 needs at least node v16.6
i did npm i node@latest
its using v12, weird
ur ecma version is old
this is not how you install node
Yes & once your bot is 75/76 servers (eg 61) start migrating
i know but replit
Nullish value (??) is only supported by Node v14 and higher
node is a npm package
lmao
u can update it with npm
npm is a npm package

don't worry no one will call you dumb for not knowing programming
you should (never) check my first messages in this channel
hey what's going on?TypeError: Cannot read properties of undefined (reading 'uses')
let gInvites = await member.guild.fetchInvites()
let g= [...gInvites]
console.log(g)
for (const key in g){
z1 += g[key][1].uses
}
const createdAt = new Date(member.user.createdAt).getTime()
const difference = Date.now() - createdAt
const invite = gInvites.find((inv) => invites.get(inv.code).uses < inv.uses);```
[1] is undefined
Try checking what g[key] is
-bots
Oh didnt read the bottom right one
why did the javascript undefined property error message change
it used to be Cannot read property uses of undefined
different versions of the runtime im guessing
why did they change the error message
you can't read more than one property at a time can you
@rancid kite lmao imagine ghost pinging instead of apologizing for wrong reply
I am trying something sory
ok
i guess they tried to rephrase it to be easier to understand
not that it changed much
properties
yes
like explaining
"you cant read shit from undefined"
more emphasis on the thing being undefined
than the prop youre trying to read
since most noobs didnt understand the "of undefined" part and think the prop itself is undefined
you say noobs like it's a bad thing
which it is
lmao
i didnt say it as a bad thing
just easier to type than "inexperienced/beginners"
how dare you call me inexperienced I know how to crash a bot with a help command
lmao
tim has no bot dev role anymore
lies he does
uvuvwevwevwe onyetenyevwe ugwemubwem ossas
brezil
<!DOCTYPE html>
<html>
<head>
<script href="https://cdn.socket.io/socket.io-3.0.1.min.js"></script>
</head>
<body>
<p>a</p>
<script>
const socket = io("https://joe.mama")
socket.on("connection",()=>{
console.log("hai")
})
</script>
</body>
</html>
error: io is not defined
im using socket.io
oh lol
DevTools failed to load source map: Could not load [the cdn url]: HTTP error: status 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
fixed
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.socket.io/4.2.0/socket.io.min.js"></script>
</head>
<body>
<div id="texts"></div>
<button type="button" id="btn">Click</button>
<script>
const socket = io("https://joe.mama")
socket.on("connect",()=>{
const btn = document.getElementById("btn")
btn.addE
})
</script>
</body>
</html>
i want to add a p element into the div with the id of texts how can i do that?
i mean with js

Fetching your div element by its ID and add your p element to its innerHTML
the question is how
const p=document.createElement('p')
p.innerText='asd'
document.querySelector('#id').appendChild(p)
what does appendChild do 
it appends(add)the child (which is p tag) into the div
how do i rmv an element in js?
@quartz kindle tfw my while loop was supposed to iterate over weeks in September
but instead it went as far as fucking January of 2022 because I forgot to add a check for the date's month
Bruh moment
@earnest phoenix
-b 780939405313310740
Spooky
who is hosting luca
good question
luca runs load balanced on 2 different free replit accounts
even though discord.py has been archived can i still develop with it?
lmao.
good idea
Because its trying to get a document from mongo
why req is undefined?
let req;
if(rarity === "Common"){
if(lvl === 1)req = 1
if(lvl === 2)req = 2
if(lvl === 3)req = 4
if(lvl === 4)req = 10
if(lvl === 5)req = 20
if(lvl === 6)req = 50
if(lvl === 7)req = 100
if(lvl === 8)req = 200
if(lvl === 9)req = 400
if(lvl === 10)req = 800
if(lvl === 11)req = 1000
if(lvl === 12)req = 2000
if(lvl === 13)req = "Maxed"
} else if(rarity === "Rare"){
if(lvl === 3)req = 1
if(lvl === 4)req = 2
if(lvl === 5)req = 4
if(lvl === 6)req = 10
if(lvl === 7)req = 20
if(lvl === 8)req = 50
if(lvl === 9)req = 100
if(lvl === 10)req = 200
if(lvl === 11)req = 400
if(lvl === 12)req = 800
if(lvl === 13)req = "Maxed"
} else if(rarity === "Epic"){
if(lvl === 6)req = 1
if(lvl === 7)req = 2
if(lvl === 8)req = 4
if(lvl === 9)req = 10
if(lvl === 10)req = 20
if(lvl === 11)req = 50
if(lvl === 12)req = 100
if(lvl === 13)req = "Maxed"
} else if(rarity === "Legendary"){
if(lvl === 9)req = 1
if(lvl === 10)req = 2
if(lvl === 11)req = 4
if(lvl === 12)req = 10
if(lvl === 13)req = "Maxed"
}
rarity is defined and works
req is also defined (?)
I am waiting for 10 hours but my application commands still doesnt appear
you don't put a space in between if ) and the req =
ew ugly code 
I don't think that matters, console log rarity to see what it really is, lvl too
k
yeah
1000 lines of code
every file
ew
before it was more but i made a test bot to make it less code
req is undefined
lvl = 3
rarity = Legendary
can you console log typeof lvl
ok
You should consider using math to youre req value, based on the current level.
Multipling it for example by 1,5 to add 50% of the current value to it or more complex adding a value to it based on the current value.
You may think about sharing your issue instead of screaming for help.
k
btw
Rare
number
lvl is number
idk what is the error
What's the actual error?
req is undefined
.addField('CREATE', '<t:' + member.user.createdAt + ':R>')```how can I do ?
use member.user.createdTimestamp
If req still is undefined after all your statements, rarity does not match any of your conditions
Log the var rarity and see
off
A UNIX timestamp, not a time string
Math.floor(member.user.createdTimestamp/1000)
Starting with a capital letter?
yes
2017 not 2021 
Well then your timestamp is wrong.
I know thank you it's me who am stupid
Log all the var you declare and change and send a screenshot of your console output, please
Press PRINT and you got a screenshot.
k
oh
function getJoinMember(ID, guild){
let arr = guild.members.cache.array();
arr.sort((a, b) => a.joinedAt - b.joinedAt);
for (let i = 0; i < arr.length; i++) {
if (arr[i].id == ID){
if(i == 0){
return (arr[i-2].user.tag + ", " + arr[i-1].user.tag + ",**" + arr[i].user.tag + "**")
}
}
}
}```
let arr = guild.members.cache.array();
The other categories don't contain level 1, too
works thx
Just the first one does
Hey....when I'm trying avatar command, I have set the image size to 256, and it is showing the image blur, a bit blur
While I tried same with koya bot, it was showing a clear image
Why am I getting it blur on my bot?
Show your code for it please
collection.get with number ?
collection.get( K E Y )
Wait
That's what he's doing.
is there a way to do it from a number?
example :
collection.find(3)
return
collection 3
run(message, { user }) {
const embed = new MessageEmbed()
.setTitle(user.tag)
.setImage(user.displayAvatarURL({ dynamic: true, size: 256}))
.setColor(0x00ae86);
message.embed(embed);
return;
}
nothing much a simple code
you...
Ok
Wait lemme send the entire code
I'm not having any issues with the code
But certainly with the output
It is giving blur image
Can anyone do anything of it?
Can I report it?
No
Nope
It's prob just a connection issue
Without cache u can't
Really?
Oof
yes lmao
Yeah
Its a music bot so wont get the intents
smh
Those 2 gateway intents? Dev portal?
Cache is just a way to not query the API every time you want to get a member object
Oh that intent
lul
I have no privileged intents
Is this error an issue with my code or Discord API?
You don't really need them for music bot so
You can still do it without cache, and it's probably recommended you do it without cache, since not all members get cached 100% of the time
You did a invalid request
Just wanted to see the member count of each guild for statistics
Either inputted something wrong or forgot to input something
Ah okay. Thanks
Can anyone help
Like I said
Most likely connection issue
Not really anything that can be fixed like that lul
Can I get the preexisting invite code of each guild and use the guild member count from there?
U want the member count code?
No
No
Then?
yeah smh
That's such a useless statistic
there should be something like <Guild>.memberCount if i remember correctly
You can, but it's an approximate
And will get the count
- you don't need an invite
I dont want to smh
@high crown Please stop
As u wish
Which object/endpoint?
What endpoint is that flaze?
/guilds/:id?with_counts=true
ah
caching many users isnt too good
check djs docs
Ok ill see thanks
Can't you do Guild.memberCount like reis said?
Wait... does it work without intents?
Do those even update? You only get the memberCount property on GUILD_CREATE. while you can fetch the approximate presence and member count at any time
discord.js probably increments / decrements them on a guild join / leave
though not sure
Yes they update. You will get the current amount with the ready event, too
AFAIK those dont fire without the member intent
I don't think so
They explicitly mentioned that
Your best bet is to use https://discord.js.org/#/docs/main/stable/class/Guild?scrollTo=fetch
It fetches the guild with the counts
you could increment / decrement it yourself tho
You need to fetch it since Discord doesn't provide the counts by default
I think Discord.js does that
but you just said they explicitly mentioned that they don't do that
Ok ill use the approxMemberCount
Shit, no wonder my member count never changes.
Increment the guild count provided by Discord on GUILD_CREATE
There's no way they don't provide member_count if you don't have the guild members intent
oh no I'm talking about the guild's memberCount on a GUILD_JOIN
when a member joins a guild, not your bot
That isnt available without the members intent
Yeah no I doubt Discord gives the new member count, but Discord.js can increment the initial count provided by Discord initially
I think they do that
So to conclude I should use the approximateMemberCount, right?
Why can't u use memberCount again?
No intent
How
No members intent
I thought Discord gives that regardless since it's part of GUILD_CREATE
Well in order to get approximateMemberCount you have to FETCH the guild every time you want to check
Could be trouble
Nvm... memberCount is available
Ill compare the result in a sec and see....
Ok thanks... ill use the Guild#memberCount 😛
Oof... I dont have the members intent so it never updates smh...
Because the gateway event isnt triggered without the intent
Hmmm... Anyone know how to fix this alignment issue when using a box model? The CSS and HTML are as follows: ```css
.features-container {
background-color: inherit;
width: 80%;
margin: auto;
margin-top: 10px;
border-radius: 30px;
padding: 10px;
text-align: justify;
}
.feature-item {
text-align: center;
background-color: #2f2e2e;
color: white;
padding: 15px;
border-radius: 15px;
max-width: 15%;
min-width: 140px;
display: inline-block;
margin-top: 10px;
}
html
<div class="features-container">
<div class="feature-item">
<h2>Test</h2>
<p>I wonder how I fix this stupid alignment issue when the boxes have different amounts of lines</p>
</div>
<div class="feature-item">
<h2>Test</h2>
<p>Testing of the crappy website I've made so far.</p>
</div>
</div>
Why not use flexbox?
Gonna be honest, no idea how to use flexbox
Nor do I have an idea of what it really does
.features-container {
display: flex;
justify-content: space-around
}
I have a whole channel for these things
Just put that in, works pretty well. I'll look into what flexbox actually does before moving on though
@drowsy crag
Oh damn this flexbox thing is actually a really nice thing to use
Yeah... css 3 has interesting stuff
Whenever my css works... I store the code in the channel lol
(node:562) UnhandledPromiseRejectionWarning: DiscordAPIError: 404: Not Found
at RequestHandler.execute (/home/runner/weq/node_modules/discord.js/src/rest/RequestHandler.js:154:13)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async RequestHandler.push (/home/runner/weq/node_modules/discord.js/src/rest/RequestHandler.js:39:14)
(node:562) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:562) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
``` how i can fix it?
what api endpoint are you caling?+
how do i prevent html from caching images
i have https://api.stupidapi.com/capybara sending a random image everytime
but the html site using the image tag shows the same image everytime
you can add a random query string using js
How
how i can look
<img src={`https://imagehost.com/img.jpg?${Math.random()}`}/>
not working
its going to https://www.capybara.bar/%7B%60https://api.stupidapi.com/capybara?${Math.random()}}/
instead of https://api.stupidapi.com/capybara
it should be in the code.
that's jsx javascript. you'll basically need to do the same thing with whatever js library you're using
no error line in console
its literally html
just html
do you own the server hosting the image?
put everything in a big try/catch and log the error
is there a specific way that i can put the bots pfp as the thumbnail in an embed?
it uses replit
api.stupidapi.com is my stupid api
do you control the https header that are returned with the image?
oh good point
its flask
well quart
i can add a header
@app.after_request
def add_header(r):
"""
Add headers to both force latest IE rendering engine or Chrome Frame,
and also to cache the rendered page for 10 minutes.
"""
r.headers["Cache-Control"] = "no-cache, no-store, must-revalidate"
r.headers["Pragma"] = "no-cache"
r.headers["Expires"] = "0"
r.headers['Cache-Control'] = 'public, max-age=0'
return r```
you are overwriting it
r.headers['Cache-Control'] = 'public, max-age=0'
i like the smiley faces
any good tutorial on how to read/write data to mongoDB?
preferably with djs?
is there a way to get a random image using html?
might be easier as its still not working
lol wth is this
Doesn't Discord still cache the image?
some google code
cache control tends to only work for assets
my api returns an image but my site caches it
my site relies on showing a random image from a set 5 images
are you serving different binary data from the same endpoint?
no clue what that means ngl
as in GET /image returns image/png?
https://api.stupidapi.com/capybara returns a random capybara at a bar image
yes
hmm that's not very cache friendly
you have to add cache-control headers on the server side on the response to make sure the browser doesn't store the response
thats why im thinking using html/js to return a random image url instead
the easiest way to do this would be to return a json response with the url that points to where that random image is hosted
alr i can do that
then you have no caching issues and browsers can freely optimize things for you
otherwise you always have to re-fetch every new image and that actually works against you
unless your dataset is so big that you probably won't ever have repeats
which I'm guessing isn't the case for you
yeah for sure you don't want to add a no-store header
you could generate the images like captchas do
yeah have fun generating animal images like captcha
that seems like the right direction to take this project
how do i then get that response and make it the image shown on the page
im totally useless when it comes to html and js
get the url and create an img tag
Anyone know how to fix this? I want the images to be in the same position regardless of the lines of the text. I've tried to align the img element to the bottom of the div, but I couldn't figure out how to get it to work properly
(These are just filler images for now)
use fixed-size cards
Good point
however, there's a little issue with that too
you'll be limited on how long text can be
you could like, break the card in 2 parts
one is fixed on 75% size or so
which will hold the image
the other will hold the text
something like this
the red section shouldn't be resized no matter what
I could try to vertically center the text in between the image and the h1 element
Not sure how that would look, but I'll try that rq
If that doesn't look right then I'll try your suggestion
the issue in the current design is that the text is sharing the same space as the image
so changing text also affects the image
Yeah
give the images a flex:1
are you using flexbox?
I'm using a flexbox for the cards, but the cards themselves are not a flexbox
<div class="features-container">
<div class="feature-item">
<h2>Moderation</h2>
<p>Moderate your server with ease.</p>
<img src="Resources/fillerImage.jpg">
</div>
<div class="feature-item">
<h2>Reminders</h2>
<p>Never lose track of time with WaffleBot reminders.</p>
<img src="Resources/fillerImage.jpg">
</div>
<div class="feature-item">
<h2>User Information</h2>
<p>Get information about users.</p>
<img src="Resources/fillerImage.jpg">
</div>
<div class="feature-item">
<h2>Fun</h2>
<p>Mess around with fun commands with your friends.</p>
<img src="Resources/fillerImage.jpg">
</div>
</div>
``````css
.features-container {
gap: 10px 20px;
display: flex;
flex-wrap: wrap;
background-color: inherit;
width: 50%;
margin: auto;
margin-top: 10px;
border-radius: 30px;
padding: 10px;
justify-content: center;
}
.feature-item {
text-align: center;
background-color: #2f2e2e;
color: white;
padding: 15px;
border-radius: 15px;
max-width: 25%;
min-width: 215px;
margin-top: 10px;
}
.feature-item img {
vertical-align: bottom;
width: 200px;
height: 200px;
}
.feature-item p {
font-weight: 300;
}
Sorry for the text wall
Doesn't seem to do anything, probably because .feature-item isn't a flexbox
There is not real 'best'
its all down to personal preference
Some people use VSCode
intellij IDEs are really nice
I use JB products so we roll with PyCharm, Rider and Webstorm
You can
The objective answer to that question is intellij
It's just not a good choice for developing an app with C# on
For C# I'd recommend visual studio community
For everything else I'd recommend Intellij
Rider just kinda sucks ngl
wdym?
No hot reload for xaml
You recommend Intellij for C# but say rider sucks 
🤮
^^^^^^^^^^
i recommend avoiding c#

it doesn't even have wrapper classes for primitives
i can't get the json thing to work
so far, it gets the img url from the json, but how do i then get it to show the image from the URL?
idk, jetbrains likes to take your money
Community Edition is well.. For the community so yes, free
but you can do that when you have the best IDE
Worked!
bump
its here too @drowsy crag
where is beautiful timothy when i need him
<script>
url = "https://api.stupidapi.com/capybara";
$.ajax({
method: "GET",
cache: false,
url: url,
success: function(data) {
document.getElementById('capyimg').innerHTML = data.img;
var data.img = document.getElementById("capyimg").src;
},
error: function(error) {
//What do you want to do with the error?
},
});
</script>
i did console.log(data.img) and it returned an image url
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<img id="capyimg" src="capys/pc.png">
<script>
url = "https://api.stupidapi.com/capybara";
$.ajax({
method: "GET",
cache: false,
url: url,
success: function(data) {
document.getElementById('capyimg').innerHTML = data.img;
$("capyimg").attr('src', data.img);
},
error: function(error) {
//What do you want to do with the error?
},
});
</script>
its meant to replace capys/pc.png with the capybara image
let me test something
lmao
is there a way to detect if my image wont load in html? <img src> stuff, and if not, print "this" instead of <alt>
i did $("#capyimg").prop("src", response.img);
nice
jquery docs are all over the place
thought there was something wrong with that line but wanted to test it first
Can someone tell me whats wrong with this code?
`const Discord = require('discord.js')
const client = new Discord.Client()
require('dotenv').config();
const Prefix = process.env.Prefix
client.on('ready', () => {
console.log("Logged in as the bot!")
} )
client.on('message', message =>{
if(!message.content.startsWith(Prefix)||
message.author.bot) return;
if(message.content === ${prefix}ping){
message.reply("pong!")
}
});
client.login(process.env.Token)`
Its not working
missing } line 15
missing backtick line 16
/home/runner/ORPtest/node_modules/discord.js/src/rest/RESTManager.js:32
const token = this.client.token ?? this.client.accessToken;
^
SyntaxError: Unexpected token '?'
I get this
update node
wow burbur coming in clutch
run npm install node@latest in shell
create start script in package.json with node index.js
create .replit file with run = "npm start"

but now im confused
on this part
create start script in package.json with node index.js
create .replit file with run = "npm start"
what do i do?
create a new file named .replit with run = "npm start"
Please help me
you have to create a start script in package.json
How?
"start": "node index.js"
at the top?
after the test script
{
"name": "ORPtest",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"discord.js": "^13.1.0",
"dotenv": "^10.0.0",
"fs": "^0.0.1-security",
"node": "^16.10.0"
},
"devDependencies": {},
"scripts": {
"test": "echo "Error: no test specified" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
SHow me



Banned ITZ PORRA#5979 (@maiden surge)