#development
1 messages · Page 94 of 1
if it does, then thats how you do it
webhooks are the most reliable and most efficient way on doing it
using the check endpoint: will end up you getting ratelimited at some point
using the votes endpoint: up to 1000 votes
oh nvm was referring to servers only
yeah only way is webhooks
yes
Hi im getting reports that my bot is disappearing from servers where it is installed. It never shows up in the integrations list and then the slash commands stop working after a few days. These servers do not have over 50 bots installed so I dont think its because of too many bots.
Does anyone know what can cause this? i have no idea where to look
What abt ur log?
Anything there?
where can i see this log?
Where are u hosting the bot?
its stateless. its just an interactions API hook
so i have a rest API for interactions
thats it
Yes, but it still need to be hosted somewhere
Did u request the affected owners to check the audit logs?
If it got removed it has to be listed there
oh right
Else it's a discord issue
ok thankyou! i will ask for the audit logs
Yw
@dusky idol here’s your solution. Thanks Timmy
/**
* @param {string} cookie
* @returns {object} session
*/
getSessionInfo: function (cookie) {
console.log(sessions);
let filtered = sessions.filter((session) => session?.cookie === cookie);
if (filtered.length > 0) {
if (filtered[0]?.cookie) delete filtered[0]?.cookie;
return filtered[0];
} else {
return null;
}
},```
Getting something smelly
The issue is at if (filtered[0]?.cookie) delete filtered[0]?.cookie;
The issue is:
The cookie gets deleted from the sessions array as well
I make a new array that is filtered from sessions
I check if the cookie property exists, if that's the case; delete it
But it deletes it from the sessions as well
Even if I did it like this
/**
* @param {string} cookie
* @returns {object} session
*/
getSessionInfo: function (cookie) {
let session = sessions.find((session) => session?.cookie === cookie);
console.log(sessions);
if (session) {
if (session?.cookie) delete session.cookie;
return session;
} else {
return null;
}
},```
My goal:
Remove the specific property called 'cookie' before returning it
Fixed it by adding session = { ...session }; after if (session) {
Credits to ChatGPT
Hi @lyric mountain I got the audit logs. I can see that the log <user> added an integration for <my-bot> but I never see the second log <user> added <my-bot> to the server which I see on successful installations for other bots
you said ur bot works purely through interactions right?
yes
interaction-only bots are never added to servers
oh ok
there's a separation between the terms "interaction" and "bot", they aren't mutually inclusive
got it
so if this log is showing but the interaction doesnt show up in the list of integrations then its a problem on the discord side?
maybe? you mean - its installed on 50 servers?
or the server has 50 interactions installed?
im pretty sure the server has less than 50 interactions
actually my bot does have send message permission
so i think it should add the bot user
even though I dont use the permissions currently
an interaction-only application never has any permission
since there's no member to be given perms to
but yes, I mean this
there's a hard limit of 50 interactions, after that you cant add any more
i dont think its the 50 interaction limit. Even after I revoke the bot scope and leave only applications.commands the installation link still adds a the user
i have application.commands
does that mean its a bot
no, it means it uses interactions
not all bots use interactions, not all interactions are bots
the only thing they share in common is that both require some code processing events somewhere
i understand
so if my integration is interaction only then why does it still add the user when i install via the link
i had to update the default authorization link, even though i was using a link without the bot scope, it didnt stop installing a user until after i did that
sorry - i know a lot of these are dumb questions but youre really helping me
don't worry, happy to help
recently had a 9 hour downtime with no customer support from Contabo. Just switched to Galaxy Gate
reinstalling Postgres and RabbitMQ was a nightmare
us west
welcome to the club
other VMs I had in the same datacenter were still accessible, but the main VM with the database had 2 major outages since the start of 2023

👀 all of galaxygate had three incidents since late 2021, one was a part failure and another was a disk space issue so it only affected one node.
crazy their reliability.
im so hype to not have to worry about downtime and I hope the customer support is competent
I took the liberty of writing my own blog post about my contabo experience. Was just :(
their vms were so good for so cheap
always a bad idea to have one provider for everything, so called vendor lock-in
thats true 👀
always have your app, database etc for each on different providers
even though I dont because I'm crazy and dont run important apps
also, if your budget does match it
have 2 different hosts that just have mirrored databases
same lmao
$20 for an 8GB node from GG is already steep for me
redundancy gets so expensive quick 👀
I was working on making something high availability(two of everything all the way down) and it was more than double the cost 
Oracle has had 0 downtime in the last year I’ve used it 😎

I got like 4 emails about it
Only problem is they may give you permanent downtime for no reason according to some other people that have had experience with it
I was just gonna get me a pi
Might’ve just been for your data center, I haven’t gotten any emails from oracle
my wifi has unmetered data anyways
I have my own server pc, but no rack and shit sounds like airplane
2 xeons
I used to actively have 2-3 backup servers when I used to run critical, important apps
was cool stuff to setup ngl
I’ve got a server pc with 2 xeons as well, only problem is that it’s from the early 2000s and still runs windows vista
It’s not worth actually setting up
got my old laptop that is entirely airgapped through a firewall and only allows connections from my vpn or local network
pog
I’ve got no use for it and the specs are actually kinda horrendous for today’s standards
It has like 8x less ram than my rpi 3
I made my bot all microservice oriented and that shit is so easy to scale
rabbitmq is literally sv_cheats 1
You don't believe how much cool crazy microservice shit I'd do if I had the budget
like, a bunch of stuff with rpis or other microcontrollers, deploying them with ansible, rabbitmq too yes
I'm gonna be working on audio processing shit sooner rather than later
but no money to hire

managed to further improve it lmao
is that for tiny discord
yes and no, its gonna be a separate lib, but the improvements will be merged into tiny discord
thats the performance for the packer tho, which tiny discord almost doesnt use
discord needs a beefy unpacker, not a packer
Tim just make tinyjs already
im still gonna work on the unpacker later
js you could even deploy on an ESP32 if you really wanted to
lmao
i still didnt finish by serializer
i have a big issue with finishing things @_@
sort first, map later
actually, first sort, then slice, then map
Looks like you might be using sort wrong
Replace a < b with b - a
https://developer.mozilla.org/en-US/docs/web/javascript/reference/global_objects/array/sort#sorting_array_of_objects
Might be helpful
also, they are objects so looking for the property comparison
Ah yeah, access the points property and then subtract
I actually wanted to setup gh actions for fake testing gateway
cool
it will probably serve you well then
no idea
ez
just create a dockerfile, maybe docker-compose
done
you can either use the docker desktop on windows
or docker run IMAGE_NAME
Hey can anyone plz tell me how to make a schema in such a way so that I can show a user's warnings in this way-
await interaction.reply({ content: `${user.tag} has ${data.warnings}.` });```
Visual Studio code
Bruh
Visual Studio code.
Search on Google, it's very common between developers
This
You cannot use this on android
mobile code editors in general usually suck
because you haven't made a bot that is verified on top.gg
we know
you put index that you need?
Arrays are 0 based indexes so first entry in an array is 0 second is 1, third is 2 and so on
Heyya @quartz kindle I’ve been trying to implement discord ratelimits from scratch but the docs are documented in a way where I’m having trouble trying to wrap my head around it
Do you mind if I ask more questions regarding this to you? Would really appreciate it!
sure
I'm trying to cover an image with a gradient
But it isn't working quite well
I have a container div
Where in an img and a div
The div has a gradient
And then the image is common sense
I want them to stack on top of each other, which hasn't worked out yet.
hey, anyone using flask? python
hi i have a question
related to mongodb
how tf can i pull an index in an array
const result = await Account.updateOne(
{ server_id: serverid },
{ $pull: { roles: { $eq: [role_index] } } }
);
it removes some and some it doesnt any idea why?
basically i wanna remove a specific index for example index 1
well I'm pretty new to bot development and mongodb myself but I can try to assist
I don't really use $pull tho
bruh it works for index 0 but not other indexes
all good brother!
tryin to figure it out with chatgpt now
yeh that might help
so, the roles is an array & there are arrays inside an array?
yeah 2d array, not the point though i wanna remove a full index at roles
remove index 0 or index 1 or index 2 for example
i wanna remove it though, set doesnt pull out data
sometimes chatgpt is stupid lol, done it like that and it didnt work
database = await Account.find_one("server_id": serverid)
roles = database["roles"]
roles.pop(index) #put the index which you want to remove
Account.update_one({"server_id": serverid}, {"$set": {"roles": roles})```
chatgpt is wrong a lot
this could actually work, genius
1 sec
but i got a problem lol
if (acc.admins.includes(req.user.id)) {
console.log("Got Inside acc.admins.includes(req.user.id)");
const role = acc.roles[role_index];
if (role[0] == roleid) {
console.log("Got Inside role[0] == roleid");
const result = await Account.updateOne(
{ server_id: serverid },
{ $pull: { roles: role_index } }
);
console.log("Role removed successfully");
console.log(result);
res.redirect("/guilds/" + serverid);
} else {
res.redirect("/access");
}
} else {
res.redirect("/access");
}
i wanna check if its a valid id in the database first
oh
its reaching Role Removed Successfully lol
it did find a match
{
acknowledged: true,
modifiedCount: 0,
upsertedId: null,
upsertedCount: 0,
matchedCount: 1
}
but didnt modify any
well I can't really understand it 
pretty sure
{ server_id: serverid },
{ $pull: { roles: role_index } }
);```
smth is wrong in here idk what though lol
oh well what basically is the program
complicated lol, if i wanna explain we wont end
finally made it work
ay that's good
Let’s say I have 3 requests
GET /guilds/1234/channels
GET /guilds/4567/channels
GET /guilds/80882/channels
These routes all stay in the same bucket, let’s say abcd
These routes calculate ratelimits independently (when I make 2 requests to the first route, 8 remain while the other two still show that 9 requests remain)
Im really confused on whether to map every endpoint including the top level resources (guild/channel id) to its ratelimit info
OR
map the literal string /guilds/:id/channels to a single bucket like how the libs do it
I’m confused on how to go ahead from there with both approaches
honestly i havent done much regarding rate limits yet, but i would probably go for the way most others do it
however i also want to investigate how the bucket header actually works at some point and see if i can use it
instead of hardcoding all rules
anyone good in html and can help me with something really quick?
post your question and see
basically i wanna have the "Role" and "Needed Amount" names merged with the borders
but aint sure how i can do it lol
just wrap it all in a div
actually
just put the label as a child of the field, then set top to a negative value
then u can set the label background to be the same color as the parent's background color
this will create a "hole" around the label
With css, simply use flex and align-items: start can easily fix the issue
wont work
Why? It works for me
flex + flex-direction: column
margin-bottom can be a negative number
because they want it merged, not aligned
basically this
easiest way is negative top, with the label being child of the field
Yeah, why don’t use flex for the container of inputs?
cuz it'll break if u have more inputs in the same div
Oh ok
a children label will guarantee it follows the field around too
yeah exactly like that!!
i am bad in html & css could you help me?
<h3>Add a Role</h3>
<form>
<label for="role">Role:</label>
<select id="role" name="role" required>
<option value="" disabled selected>Select an option</option>
<option value="option1">Option 1</option>
<option value="option2">Option 2</option>
<option value="option3">Option 3</option>
</select><br>
<label for="amount">Needed Amount:</label>
<input type="number" id="amount" name="amount" min="1" max="100" required><br>
<input type="submit" value="Submit">
<input type="button" value="Cancel" onclick="document.getElementById('popup').style.display='none'">
</form>
</div>```
what could i do?
put the label inside the input
set negative top
set background color to match the parent
Basically using css (I use React)
can u help me lol idfk how
sorry lmao, dont know much about html i just know the basics
<...>
inside
</...>
bro i can place it inside but what then
^
if ur beginning in html, don't try to make something more complex
true but i wanna make it nice if you know what i mean
yes I know, and you shouldn't
don't put the horse in front of the wagon
go slow, improve your skills along the way
true true
Lot of people tend to start developing with a high goal by creating something over the top which is beyond their skill. Start slow, take some HTML / CSS courses which for the most part are free and start with basic projects to get an understanding of how html / css works. 🙂
yes, there are lots of html courses around the net
actually I think it's the subject with the most courses among all
do u suggest any? i already know the basics so i wanna learn more now
yeah probably
well, if it's regarding web pages w3schools/mozilla are good places to search for
don't watch videos, videos never update together with the languages
got it 🤝 thanks alot
yeah i never do
to test what u learn, simply open a new blank page and press f12
u can test html/css/js directly on the browser
yeah ik that, thanks though 🐐
for discord dashboard should i just stick with the path of using ejs or should i convert to react later on the long run?
react is pretty useful, I usually recommend using it with Next.us for the best performance
Their eco-system is the most powerful along all the alternates
honestly, as someone who used react a lot, I'm starting to ponder whether react is really that better than pure html
like, the only advantage are the libs
React helps you to maintain the project and reusing components
But you might spend some time for understanding how to improve the performance such as reducing re-render
cant u make custom html components?
you can do all of that without react
react is really about reacting to change in state
Of course, that is why it “helps”, not the only one way
hm, state, forgot abt that
though personally I don't think react handles state well since it couples it to the ui
but the idea/model is certainly good
Yeah, vue is much better at this part

delete frameworks
true but its easier to refresh data and make it "live" if you know what i mean
in ejs we can use ajax but it isnt as efficient as react
the developer experience of web dev is really incredible nowadays
really annoying too
the amount of tooling there is makes me stay away from frontend
same but u get to a point you wanna do frontend too
cant do anything these days without having a shit ton of frameworks, packers, bundlers, mappers, converters, minifiers, etc...
feels weird knowing tooo much backend and little frontend
well i've done enough frontend
i hate having to setup all those tools
so if i have to, i'll just write raw html+css+js instead
at least you take the effort to try
I dont
I hate frontend
Like I'd wanna do some extremely cool dashboard shit if I would know how to do frontend like @civic scroll does
i'd say depending on your needs
there's a difference between "i want a functional and usable ui fast" and "i want an absolute unit hand-crafted experience"
done bootstrap, am capable of like, expanding an already existing layout
but
yes lmao
Well i am building a dashboard related to nfts so having fast and reliable ui is better for me
i'd argue there are uniquely and equally hard challenges on both sides
Same lol, but come and building my own would take me ages
Well i am building a dashboard related to nfts
opinion discarded
there are premade ui component libraries out there
knowing a bit of composition does the trick
Thats my needs
https://roadmap.sh/frontend if anyone's interested in actually starting to learn frontend, just found this recently, definitely not ads
that's why we have design and planning phase
stinky ads 111!!!1@!1
ban me

🔨
bannished from susland
mods are on the way
Scary
this
this
this
this
this
...
this
reminds me of "can-i-use"
why do they still list ie
tf is kaios
apparently an android-based OS for old phones
and obviously, of course safari doesn't support it
neither does firefox
ah
sure, use the delete button on your bot page
Can't find it, only see preview and save
Ah, looks like I have to leave edit mode and go to the info panel for some reason
Hmm
Is it possible to just make it not "live" instead of completely deleting it?
Nope
hey in js, i created a set and added an element to it using set.add()
is there any way to store like an array into the set?
I ultimately want to store: user : number combo
then...not use a set
this sounds like something youd want a map for
oh wait, what u want is ```
[
[a, 123],
[a, 123],
[a, 123],
[a, 123]
]
yessirr
yes, u can, but as woo said, better to use a map
i see, maps are in java as well if i recall correctly?
java or js?
I once saw a package for it but i might be mistaken
no just out of curiosity
java
java has all collection types built-in
i kinda get why the names of java and javascript are similar, they share lots of functions
that's mostly inherited from C actually
This would be set.add([.., ..]) i suppose?
aint no way really?
js is only called "java"script because it used to be a layer between browsers and applets
yes, all languages with similar syntax inherited that from C
you can add anything to sets, so yes an array can be added to a set
while langs like rust, python, lua, pascal, etc didn't
Yeah i see. Quite strange as i thought c++ was closer to c instead of java/javascript. And c misses lots of inbuilt functions like replace, replaceall, split etc
or my teachers just fucked me really hard into not allowing to use them, also a possibility.
c++ is as close to C as is java, but c++ stood in the "minimal" side of the wagon
that's why it feels so barebones
i see, so c++ would be easier to compile and assemble right than java/js right?
As it has less 'human code' to convert
well, java doesn't compile to assembly
owh
java was made to be highly maintainable even in huge enterprise projects, while c++ kept performance as its main priority
ahh i see!
Also, just out of curiosity... c++ is usually used for security right? But why is that? I mean, c++ is the main language for buffer overflows etc
js was made to be used in browsers
which is also why it's so lenient regarding datatypes
while other languages have built in catches, c++ doesn't and yet it still is highly used in security programs
no, c++ is usually used for games and microcontrollers
ah i see, indeed! I am really looking forward to the networks lectures! Will be fun.
tho C is even more used for the latter
Owh i thought that c++ actually was used for security. I read it somewhere.
it can be, all languages can
c++ gives freedom, if u want to shoot yourself in the foot it wont prevent u
security stuff uses low level languages for performance and integration into other low level systems mostly
nobody wants an operating system calling a nodejs process to calculate some security keys lol
aha i see, this shit is quite interesting aint gonna lie
also usually such code is done with minimal processing, so it doesn't need to be very maintainable
yessir definitely
thanks for all the help tim, kuu, and woo. Can't appreciate it more for all the things yall are doing 🙂
Technically it does 🤓
JIT compilation
Most compilers use JIT nowadays
that's just JVM blackmagicfuckery
in djs v13, don't we have a property to check whether a user can get banned, muted and kicked?
it was member.kickable, member.bannable, and....? I forgot the one for timeouts/mutes.
Look at the docs perhaps
honestly i have tried to find it but couldn't
I believe there’s some sort of function that does that but I could be wrong
I know it was a thing in detritus but not 100% sure about djs
Mutability in this message is not what you think it is
mutability here refers to the data being mutable, like you being able to edit message.content and then send(message)
yes .bannable, .kickable, .moderatable
does anyone have an Idea how to design this? id like to make everything a modal
use bootstrap modals
I already have modal components, idk how to arrange the page
i cant make stuff look good
I got this concept but its horrible
Also keep in mind that you want to be looking at the properties/methods for the type that you want, not the search feature
Yeah i got it working
Owh i see
yeah i am pretty stupid with these docs
Is there any way to work around this
Why the fuck is there a max on it.. doesn't make sense??
it's a pretty big amount tho
5 isn't much right..
Depends on what your bot does
theres only 5 slash commands in total?
or whats that
application commands
I don’t think that’s what that number means
how tf is it only on 5
Cus max command amount is much higher than that
yeah doubt thats slash commands
tf is my console saying then
how many slash commands do you have
These are context menus, I believe
^
data: new ContextMenuCommandBuilder()
.setName('ban')
.setType(ApplicationCommandType.User),```this is the type
i got: 6 in total
yep, context menu
why are u even making a ban context menu command?
there's already a ban button
...
True
Also, if I'm not mistaken, it would be impossible to add any arguments to such a command without using buttons or waiting for a message from the user so slash command seems like a better choice for this kind of command
u can get the author of the message u clicked
and I think it also appears if u right click on an user
Yes, but I mean some kind of temporary bans or reasons/cases
which is already what ban button does anyway
anyone here knows erlang? how the heck do lists work lol
does the list tail count in the list length?
tim asking a question? what is this?
erlang is just way too confusing tbh
indeed
tbh im just asking for the etf encoder, i have the gist of it but some things are unclear
lists can be either proper or unproper, they can include a tail, or not include a tail, the tail is normally an empty list [] but can be any value as well
a list with a list?
so when encoding it, idk if i should add a tail at the end or not, and if the added tail should count towards the list length or not lmao
ordered myself an SBC so that I can host my own stuff. Has a pcie slot, so I might abuse my 1050ti collecting dust
when providing choices for a user
instead of getting the actual value can we also try to get the name?
There should be such an option
The Discord API doesn't provide the name of the choice the user selected, only the value
the choices api is a piece of shit
not only do they not provide it, but they type it for the user
which is misleading
when the user choses it, it autocompletes the query with the name, but what is actually sent is the value
if the user presses backspace, the name gets edited, which causes the value to be lost
if the user re-types the character they just backspaced, the value will not come back, making the query invalid
having only 25 options is also dumb
I have to make multiple commands for radio stations
Yup i got it!
Also what's the max size?
Right now i have 14 choices... and it's telling me it's exceeded it's size
The max is 25 choices
What is the length of their names or values?
14 choices won’t reach the maximum amount, Is it the problem of value length?
https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-choice-structure
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
BLÅHAJ
blåhaj
BLAHAJ





how do you make something happen after a specific amount of time happens with a bot
for example with giveawaybot someone specifies an amount of time and after that time they announce the winner
how do you do the timer thing
setTimeout and/or a database
giveaway bot would use a database.
timeouts wouldnt persist between bot restarts, which is a major issue
U definitely need a database
oof
i hope the 4 customization options + the about command meets the requirements
Requirements for what?
#mod-logs message example
I keep getting "invalid string format" here: option.setName('iconurl')
Yo
what's the best way to run something every 5th minute?
1000 * 60 * 5
what is this suppose to mean
Cron job
what module?
google cron job for whatever language you use
well
you could also use setInterval which will run every x amount of time you set
but it depends on your use case
I've tried two but
You use js right?
yes
then ye setInterval could also work
could
cron jobs are just a way of doing the scheduling on a separate process (might be other benefits but I hardly used them to know)
One other thing about cron jobs, they allow you to use the full spectrum of time, e.g hours, minutes, seconds, days, months, years
well i tried node cron and node schedule but they both break for some reason
You are likely using it wrong
how
with node cron after a day or two it starts offsetting
and with node schedule after a day or two it started running the job twice (and possibly offsetting i forget)
it works fine at first though
Interesting
I dont see why that would be happening
Maybe something around it could be affecting it
If you run the cron job more than once it will end up happening more than once as well
it's not that
it only schedules when my client is ready
will try setInterval but i'd prefer for it to happen at every 5th minute
this could lead to an issue in itself
how so
Its not guaranteed that ready will fie only once.
Unless you have code interfering with the cron job itself, I dont see how it is running twice, that or your updateTrackers() is doing it
As for the offset I am not really sure why that would happen, In my time of using cron jobs never had it happen without me specifying it to
hi
Hey could anyone tell me the benefits of using a dlatch over a sr latch? Because in my understanding they work exactly the same, just the d latch got the data inputs and enabling separated while the sr latch requires direct changes of s and r to either perform the set, reset or hold actions.
I know the d latch can set the e to false or true to either hold or perform an action and that the output is then dependent on the d input, but why is it better instead of an sr latch? Could it be because the data and enabling functions are separated? Accessibility?
Omg wait hold on i might be cookin here
Would it be correct that a d-latch cannot get into the forbidden state? So s= 1, r = 1 (race conditions occurs)
so thats why a d latch should be used over a normal sr latch??!
tbf
I'm glad I'm not going to go through the topics in my apprenticeship what you're doing right now
I'd die inside ngl
i am for sure dying ngl
but yeah, i knew computer science at the university would be rather logic than coding so gotta see it through now 
How
?
Nevermind when I booted VSCode this morning it worked for some reason
hello, does anyone know how to setup these buttons at the botton of the window view with electron?
they dont iirc
how the fuck should i calculate the delay based on a path
literally got nothing but the path (from input a to a nor gate(
resistance perhaps
nope
i just got a logical circuit and he said calculate the progpagtion time
yes, but gates still have some kind of resistance
even if negligible
that said, I still have no idea how ur even supposed to calculate propag time
a thing I remember tho, is that current has a certain speed
for example this
they told us we needed to give the propagation delay
so i thought for example the delay from a to sum is:
| A --- norgate --- norgate --sum |
would that be any correct?
Istg too brain stuff for me
Not an electrician too, didn't u learn how to calculate that in ur course?
Teachers don't usually throw questions that were never taught before
istg not
only thing we got about delays
see what the teacher wrote that |-gate-gate-gate|
that's the delay i think
what doyou think?
idk

Can someone help?
Are you using YouTube DL
yeah
well the jobs running twice only occurred with node-schedule, after switching to node-cron (with no code changes) that issue was resolved but there's still the other issue.
Drag there or click it
const Discord = require('discord.js');
const Schema = require("../../database/models/economy");
module.exports = async (client, interaction, args) => {
const type = interaction.options.getString("type");
if (type == "money") {
const rawLeaderboard = await Schema.find({ Guild: interaction.guild.id }).sort(([['Money', 'descending']]));
if (!rawLeaderboard) return client.errNormal({
error: "No data found!",
type: 'editreply'
}, interaction);
const lb = rawLeaderboard.map(e => `**${rawLeaderboard.findIndex(i => i.Guild === interaction.guild.id && i.User === e.User) + 1}** | <@!${e.User}> - ${client.emotes.economy.coins} \`$${e.Money}\``);
await client.createLeaderboard(`🪙・Money - ${interaction.guild.name}`, lb, interaction);
}
else if (type == "bank") {
const rawLeaderboard = await Schema.find({ Guild: interaction.guild.id }).sort(([['Bank', 'descending']]));
if (!rawLeaderboard) return client.errNormal({
error: "No data found!",
type: 'editreply'
}, interaction);
const lb = rawLeaderboard.map(e => `**${rawLeaderboard.findIndex(i => i.Guild === interaction.guild.id && i.User === e.User) + 1}** | <@!${e.User}> - ${client.emotes.economy.bank} \`$${e.Bank}\``);
await client.createLeaderboard(`🏦・Bank - ${interaction.guild.name}`, lb, interaction);
}
}
@lyric mountain
I don't see u replying anywhere
Up what?
const Discord = require('discord.js');
const Schema = require("../../database/models/economy");
module.exports = async (client, interaction, args) => {
const type = interaction.options.getString("type");
if (type == "money") {
const rawLeaderboard = await Schema.find({ Guild: interaction.guild.id }).sort(([['Money', 'descending']]));
if (!rawLeaderboard) return client.errNormal({
error: "No data found!",
type: 'editreply'
}, interaction);
const lb = rawLeaderboard.map(e => `**${rawLeaderboard.findIndex(i => i.Guild === interaction.guild.id && i.User === e.User) + 1}** | <@!${e.User}> - ${client.emotes.economy.coins} \`$${e.Money}\``);
await client.createLeaderboard(`🪙・Money - ${interaction.guild.name}`, lb, interaction);
}
else if (type == "bank") {
const rawLeaderboard = await Schema.find({ Guild: interaction.guild.id }).sort(([['Bank', 'descending']]));
if (!rawLeaderboard) return client.errNormal({
error: "No data found!",
type: 'editreply'
}, interaction);
const lb = rawLeaderboard.map(e => `**${rawLeaderboard.findIndex(i => i.Guild === interaction.guild.id && i.User === e.User) + 1}** | <@!${e.User}> - ${client.emotes.economy.bank} \`$${e.Bank}\``);
await client.createLeaderboard(`🏦・Bank - ${interaction.guild.name}`, lb, interaction);
}
}
here i sent again
ok
I'm referring to the code itself
oh
Were those code written by you?
yea by me and my friend
Ok, by your friend then
if you want i can re write whole
...I don't think u understand what I mean
But well, supposing those client.errNormal are your error replies, you have a lot of processing before sending something back to discord
oh
now i got it what you mean
You must defer if you're gonna be doing ANY processing at all
is it necessary to use require('dotenv').config(); in every file we use process.env
?
you only use it once and then access process.env
You only need the config when you want your env vars to be loaded
So if you load it in your e.g. index.js first, you won't need it elsewhere
totally noob on html here, how do i make images get aligned with text on a heading for the bot description? 
<h2 style="vertical-align:middle; display:inline;">
<img style="vertical-align:middle;" src="link here">
title here
<img style="vertical-align:middle;" src="link here">
</h2>
on my personal testing it works, but on top.gg the images are in a second line no matter what i try, is it something of the page or like that?
then the display used by top.gg's description doesnt support whatever vertical-align is used on
vertical align is only supported in boxed layouts or table cells anyways
also don't use the image element inside your header, as it being the child element won't do what u wanna do anyways
An example of using a table as layout to display what u wanna do:
<div style="display: table;">
<div style="display: table-cell;"><img src="..." alt="..." /></div>
<div style="display: table-cell; vertical-align: middle;"><h3>title here</h3></div>
<div style="display: table-cell;"><img src="..." alt="..." /></div>
</div>
Hey, uhm, is there anyone of you who added a bot created in Discord Bot Studio?
I'm just trying to add bot stats (I mean the code from the documentation) to bot.js but it seems I can't find a solution and I hope someone of you managed to do it so that I can ask for help in solving this situation... I installed autoposter and even sdk, then I tried to replace client (because it is not defined in DBS) with DBS.Bot but nothing has changed on the website and there is no information in the console whether the statistics were sent or not 
If there is no error in the console then most likely the code didn't even start working
oh please... im so dumb -.- uhm, so now i added the same code (which i added to bot.js) to Code Block and now it worked
I'm sorry for wasting your time reading this 
Have a nice day ❤️
I forgot what the hell prsence intent can do on bots can someone help me-
it allows you to track status changes and retrieve whether an user is online or not
update to my old issue - https://media.discordapp.net/attachments/1056972322797518848/1077230236380438578/image.png
my first time using chatgpt ever 😎
I don't know how that's supposed to help you with your problem, but if it does, that's cool
yeah it didn't really help
i just sent a suggestion/question to my router manufacturer instead 💀
i have 2 dates written like: 2/20/2023
how do i calculate the passed days/years/months between the two dates?
days: calculate the sum of days on each month, then sum together
months: divide by 30 (unless you want to be really precise, still suggest letting a library handle it)
years: divide by 365
you can always use js and run new Date('2/20/2023') if you are lazy 😎
its not the lazyness tbf
A web app that works out how many seconds ago something happened. How hard can coding that be? Tom Scott explains how time twists and turns like a twisty-turny thing. It's not to be trifled with!
A Universe of Triangles: http://www.youtube.com/watch?v=KdyvizaygyY
LZ Compression in Text: http://www.youtube.com/watch?v=goOa3DGezUA
Characters, Sym...
and I dont want to get started on different calendars
💀
where the first day of week is sunday
would this work lma
and where there's not the 28 days on february
lmao
it would
.getTime()
other way around
but essentially yes
you wanna subtract from the larger number
aka the one more into the future
Does anyone know the package that moderation bots use to change 30d to the date 30d later or 30s to 30 seconds later?
like if someone does *ban 30d <reason>
And 30d later it will unban
I am saying how do they convert 30d to a date object to find the date to unban them by
I coulda swore I saw a npm package for it so I don't have to do it manually
I'm sure something like moment could do that
But honestly it probably wouldn't be too hard to write that sort of thing yourself if you really wanted
yeah I figured but it would be easier cuz im lazy
@wheat mesa any idea the correct method for that
Haven’t used moment in a moment so can’t say
I'm sure you'll find something on the internet
its all about Date
What you know about dates bun
Immutable date wrapper
Since Moment itself is no longer maintained, that's what they recommend
when will the js gods release temporal
And we (TC39) will be moving https://github.com/tc39/proposal-temporal to stage 4 once
IETF standardizes timezone/calendar string serialization formats
Once that's done there will be no need for additional date & time libraries
dayjs is better than luxon
@earnest phoenix Can I dm you, have a super complicated project idea and what to know if you have any suggestions for the tools being used in the project...
Sure go ahead
Can someone tell me how do I get my bot verified (for discord)? It’s in 75 servers now, I’m at the developer portal & can’t really locate the verification button
I assume that it’s due to the fact that my bot isn’t in 75 servers if I exclude servers owned by me. Guess we’ve to wait for it to join 2-3 more servers.
I see, alright
your able to when its in 76 guilds
Let’s hope that I wake up into that message xD
so if its in 75 you need one more
Prepare a photo of your ID card or driving license and download some recording software
Hi
Why do discord need id card?
Will they do something if bot steals users data or what?
Am I from Discord?
so you can be held accountable if your bot does something illegal
They need it so you don't abuse data. It's accountability
And to also verify that you're not someone that has previously abused data before
They need a legible document that can truly identify you, such as an ID, driver's license, passport, etc etc so they can verify it's truly you, and that you can be held accountable if you do something bad
hell no im deleting my bot
Good luck
And besides, Discord doesn't see any of these documents, Stripe does
yeah ^
discord will likely only get access to them if your bot does something fucked up which requires legal action
I suppose that's your choice to make
like what?
Anything against their rules
hell no this is too much for me
Seriously though, I haven't heard of anyone going to jail for discord bots
Okay, I wanted to look for something on this topic, but I didn't expect it
Guess I’ll have to do it tomorrow
Good luck, I hope you pass the verification successfully 
well probably because no bot has done something fucked up enough for jail time
Damn no communist party servers 😔
☠️ this is a wild ass question
what is bro doing
What sort of ID do I need to provide though? https://prnt.sc/9UfJr5WRQTS7
ID card, driving license or passport
what's the ID card to be more specific? I certainly can't go with the other two options because of being under 18 xD
Zoey.
is it available on top.gg?
@lament rocksuggest a name for my etf lib
not so happy with tinyetf
what about wetf? can stand for "what external term format?" or "what even the fuck?"
was literally about to pull a wtf joke
hm

took me all day to figure out how UMD works today lmao
whats that
universal module definition
makes stuff compatible with other platforms, like browser
discords's erpack lib doesnt even work when decoding bigint wtf
lmao
extra terrestrial format
im testing and benchmarking like 5 different libs
and they all have weird quirks and issues
lmao
one of them encodes doubles in big endian format for some reason, while the elang docs specifically state it should use little endian
the format itself is a mess indeed
omg jesus christ
i tested encoding a uint8array using discords erlpack
and it encodes Uint8Array([1,2,3,4,5]) into an object like this { 1:1, 2:2, 3:3, 4:4, 5:5 }
instead of using the native etf binary data type
gross
also, out of them all, discord/erlpack is the second slowest one
jesus christ, talk about unoptimized
jesus
More efficient then what I write!
Oh man you should see this code I have for a single api endpoint.
Like 150 lines is just database stuff.
Prisma was a mistake
not that bad
Yeah
this guy's code is 1200 lines long
and he managed to make it almost 5 times slower than other libs
It's literally caused the project to be delayed for months.
And I'm too stubborn to just rewrite it.
And I'm too frustrated to finish kek
lmao
the reason is that he creates new buffers everywhere
he basically does stuff like this in his code ```js
const input = [1, 2, "34242", 234.2352];
// his code (sort of)
buffers = []
for(const item of input) {
const buffer = bufferAlloc(encode(item))
buffers.push(buffer)
}
buffers.unshift(bufferAlloc("header"))
return Buffer.concat(buffers)
creating tons of small buffers in js is a really bad idea
Added support for a bunch of http methods and I'm a personal fan fav of 304 :)
https://http.cat/304
ads
Using discord.jsv14 when i attempt to login using my extended client i get an error "InvalidArgumentError: invalid User-Agent header", however when i use discord.js's client constructor to login i dont. this only occurs on v14 and works perfectly on different versions, anyone know why? (The error comes from undici which is used by djsv14)
I’ve not found anything regarding this issue (e.g fixes or people who’s had it before) on either the internet or discord.js server
either you might want to see if you're overriding something of the super classes up the chain that would interfere with options or if you're setting your own User-Agent somehow since Discord expects a very specific format for the header
I’ll have a look when I’m home and get back to you
Hey there, can someone assist me a little real quick? So, there's a webhook of a website called discadia. Whenever someone votes for my server at their website, their webhook sends a message in one of my text channels which is basically an embed with a mention inside it.
Well, you can ignore the context I provided above & simply help me with getting the id of the mentioned member inside the embed.
https://prnt.sc/MY_K1_xC8O1t
In this case, I want to define an on_message function which reads the description of the embed & takes the ID of mention'd user. (Zeksy in this case) How do I achieve it
You'll need the message content intent.
But if you place it in its own channel no one else can send messages and just check if the message is in that channel. Then you can pull the user ID from the description
embed = message.embeds[0]
description = embed.description
I assume this would get the content inside the description
yeh that's what I'm doing
Do you use python?
You can also use substring
yes
I'm not so sure about extracting the member's id out of embed's description
but let me try printing the description, gimme a second
Yeah you'll need to regex the member id out, some libraries would have the luxury of providing you the mentioned users if it is just message content
nvm i found the issue
Yo
is it possible
for checking when a role got given to a user
and handle it
with node js
with discord.js?
and handle it
yeah
i have an idea
There's probably a guildMemberUpdate event or something
seems like it may return roles
lemme check
it returns old user
and new user
i mean member
thanks man
lemme test
There you can compare old and new roles, thanks to which you can check which roles have been assigned to the member
so basically what i wanna do
is mark a specific role
so administrators with this role cannot assign roles with admin to other users
lemme test
Yo
is there a way to read user bios with discord js?
no youd need to use oauth
Theres not
You can read their custom status, what game they're playing and they're online/offline status, but their bio cannot
The only profile related data is activity, status, avatar and name
o
o kok thanks
selfbot 😁
Daily tos encouraging chat
XD
i meant they're probably using a selfbot, not to use one yourself 🙏
ofc ofc
DONE
https://webhook-topgg.com/
Is it fine to use this site?
Simplifying top.gg webhooks for all users, allowing non-developers and developers to use webhooks for their bot and server without confusing configuration.
why not
const regex = new RegExp(...)
if (Boolean(data.body.match(regex) === true) {
...
}
Tf is this 😭
Yes
is it wrong
Supply the most useless thing ever
I hope so, i made it ^_^
Ideally you would use your own webhooks, but it will work
you have a question about regex so supply the regex
Oh, cool.
Just wanna say that your code snippet here tells us literally nothing
/pls|hello|example.com/i
I don't know how to make my own webhooks so.
And === true
it supplys a bool
okay
Are you using /g anywhere
How do you make your own webhook?
whats wrong with this
I assume you want to match globally
wym
Not just the beginning of the string
thats the entire thing
Well that that’s probably the problem
oh
Use /g at the end
example\.com actually
Global match
This too
. is a reserved character in regex
yes
go easy on them null
im going to change it
no
why
:)
Me when you could just use string.contains instead of jumping straight to regex
yes
Regex is slow as hell
my package got extremely fast after switching from regex to rust binary search
Caching it is a little faster (I believe v8 does that for you behind the scenes) but it’s still pretty slow
using regex for that is pretty overkill tbh
Yeah binary search is pretty crazy, O(log(n)) is really nice compared to O(infinity) for regex
no
wtf
Binary search is based
Yes
regex is O(infinity)?
Fundamental algorithm to know
no
I was joking
O(n!)



