#development
1 messages · Page 2003 of 1
Bro when I found out react native effectively ported css to android for styling i cried
css succckkkssssss
Is it possible to generate an avatar URL that is a png or jpg? The URL always returns a webp format which the API I'm using can't utilize.
If you're referring to Discord just change the extension in the URL
Supports png and jpeg
And gif if it's one
I have a bot (waifu bot). This bot only has one of each character. I wrote another similar bot. In this bot, every character is infinite (finite in their rarity. S rarity 5 A 100 B 1000 etc. ). Now this bot is against the 7th rule(same bot rule)? Then I'll delete my first bot.
wdym, css is awsome
bros taking a piss
the default android styling way
guess I'll go back to flutter 💀
const raisonTicket = interaction.values[0];
client.db.query(`SELECT * FROM "${raisonTicket}" WHERE user = ?`, interaction.user.id, function(err, result){```
i think isn't this method to import raisonTicket into my request
but how ?please
errr wtf
When using prepared statements, then please consistently anywhere
client.db.query(`SELECT * FROM ? WHERE user = ?`, [interaction.values[0], interaction.user.id],
What is a "raisonTicket"
You cant do that
Nice try though
if that's actually your table
Can I change the username for npm?
already tested and no :/
You can only use placeholders for filter values generally
Generally to deter people from doing what you're doing
Why are your tables dynamic like that?
isn't my table
?????? What

what chilli wants to know
I only do what is asked of me
is raisonTicket your actual table name?
nop
const raisonTicket = interaction.values[0];
is a select menu
with multiples values
FROM expects your table or database.table
nop
So it is your table name... wtf
yes but i think "${raisonTicket}" is not the correct method
Ah I thought you said raisonTicket was the name of a table
Yeah it must be table name
yes
Ah ty.
but my request is not corerct but idk where
Just log interaction.values[0] to see what is shows
ok
Basically, I'm doing a ticket system and the user has to select the reason from a multi-select menu. For each reason, the value to identify it is the same as the table name in the database
@boreal iron
So on this point it works
why are you storing different ticket reasons in separate tables?
Yeah I got that but make sure raisonTicket is the right table name
Ask that to the project manager, I don't know, he asks me to develop a bot
i've check and yes
No, you have to tell him that it's wrong
It doesn't matter, I do what he asks of me :/
but I'll be sure to tell him
Did he write out the specifications for you? Did he explicitly say to have a different table for each different reason?
well tell him that it's not a good practice
What the actual error you get?
I agree with you but the problem still persists.
@earnest phoenix, تو نمیتونی ازین گها بخوری
?
english pls
english error: Syntax error near '"ticket_wipe" WHERE user='853860487665680406'' at line 1`
Remove the brackets
ok
double quotes*
here I struggled minutes for this damn problem.. thank you very much!
@boreal iron, تو نمیتونی ازین گها بخوری
@earnest phoenix, تو نمیتونی ازین گها بخوری
english broken today
English only please
@boreal iron, تو نمیتونی ازین گها بخوری
@solemn latch, تو نمیتونی ازین گها بخوری
Lmao "You cannot eat this sometimes"
o
there we go
is it a bot
strange
@earnest phoenix
think
test
🤔
not a bot
hmm weird
it acts like a bot
anyways
...
awh
i'm sry
Did you remove the quotes?
here I struggled 20 minutes for this damn problem.. thank you very much!
Those quotes aren't valid in there anyways
If you really follow the strict sytax it would be:
SELECT * FROM `table`
but SQL doesn't require that backticks
(in non strict mode)
SQL when you show it a proper error message
Stop crashing into the block points in the road when you don't know where you were driving to FakE
the `` naming changes from implementation to implementation
shut up! only happens 1-2 times a week 
ONLY

Mongoose question
I have a schema in my code
{
id: String
}
And in mongodb it saved as
id: 18392918392
I made my schema
{
id: String,
plugins: Array
}
But it still shows
id: 3829292929
How can i update my schema in mongodb
All docuemnts in mongodb gets plugin
339 votes and 116 comments so far on Reddit
dafuq?
Me when node-ipc plays russian roullete with ur disk
ft. Belarus for extra fun
just use built in libs instead of garbage
a lot of the code/apps/libs I look at might as well be NFTs since it's all just the same crap just slightly different
The amount of libs that secretly mine crypto 😩
Time to make a lib with the sole purpose of mining crypto for me, logging all of your key strokes, installing bonzi buddy, and sending you pop ups that you've won a free car or something along those lines
holy shit
i cant believe node-ipc did it
lmfao
the only reason i even made net-ipc was because node-ipc was outdated for years at that time, they just recently picked up development again
This is great since it propagates everywhere: https://github.com/vuejs/vue-cli/issues/7054#issue-1169945774
Massive fiasco
Why does this seemly happen to the JS ecosystem more than any other ecosystem
because people insist on using garbage packages instead of writing their own stuff
Because JS:
- Has no real standard library
- Has a lot more people between the spectrum of experience
Java's Maven is like half the size of npm yet you never hear of incidents like this.
Which is unfair since Java provides a lot of what an app needs built-in.
So does Python, but we don't hear about this as often.
no, but wish they did
i wonder if i should piggyback on this scandal and add something like malware free to my lib's description lmfao
LMAO
Imagine how cleaner this:
if (Number.isEven(1)) {}
Is to that:
if (1 % 2 == 0) {}
Now I need a class for that 
there is a limit between cleaniness and usefullness
1.isEven() >:()
based on what I've seen from projects that provide small functions like isEven, it does have a net positive
else you're stuck interning what something x something means
but you have to be somewhat paranoid to feel like making 1 line slightly cleaner makes a big difference
isEmpty() > array.length === 0
isEven() > num % 2 === 0
This is stuff you can implement yourself though, no need for a 3rd party library
even the smallest changes can have good effects on maintenance 
yeah, but we're talking about if java had an isEven built in
or, more simply, be declarative
bro has to write an algorithm to generate a huge array of even numbers
lets see if my lib gets more popular now that many people will likely get rid of node-ipc lmao
check this out

is there a better way to check if a number is odd or even idk maybe someone more experienced knows
const evenNumbers = [];
for (let i = 0; i < 100000000000; i++) {
evenNumbers.push(i * 2);
}
function isEven(num) {
return evenNumbers.includes(num);
}
isEven(5) // false
isEven(10) // true
lmfao
use an object or a map instead of an array, at least like that you have direct index access instead of scanning the array
it also makes it use more memory, thus makes it faster
:^)
im also considering using machine learning
is_even = ((number << 31) >> 31) == 0;```
Has Dyno ever released any developer writeups about how their distributed infrastructure works
^ only works for 32 bit numbers
use bigints
is_even = !(number & 0x01);```
The best way to check if a number is even is to use https://isevenapi.xyz/
cant beat a dedicated api..
yea, that dev deserves to make half a cent from an ad 😄
dont forget to install their python module https://pypi.org/project/PyIsEven/ 😄
jebus fokin kristus
Das a phone #. Hopefully it isn’t a random dudes
lol get bitches
im making a website where you can use the api but you get charged for it
a nice api feature to add
as a bonus i'll even let people include multiple numbers to determine if the numbers are odd or even at no extra cost
this is probably the funniest part of the site
has to be san francisco and innovation
oh ok
anyways i have a react question
so i have a main component and two components: page and auth page
if the user is not authed, i want it to show the auth page
(aka the auth component)
and so i want it so after the auth component is done, for it to update some state such as "auth=true" hence causing a rerender to page
is there a way to do that
more specifically react native but this is a plain react question
So you probably want to tell some component above you to rerender itself so it doesn't display the auth screen
something like that
Which is not that easy to do in React by just passing around values
You need some sort of environment
i was thinking i could do something like
I know Redux can do that, but that works by separating the state to my knowledge
but react doesnt like me passing functions around
I need some help with discord.js's SelectMenu. So whenever an option is selected it doesn't show in the SelectMenu box. Is there an additional function to do this or is it impossible. Examples:
guys
assume that i have an empty array
const arr = [];
then i inserted items at abitrary indexes
arr[2] = true;
arr[4] = true;
arr[10] = true;
> arr
[<2 empty items>, true, <empty item>, true, <4 empty items>, true]
is there a possible way to fill up the empty values (possibly undefined) with any values, given
function fillArray(arrayWithEmptyItems: any[], fillItem: any) {
//...
}
it'd be better to use a map in that case
i use array since i gotta map it to a 2d matrix
hmm?
and input data were
{
row: number,
col: number
}
Arrays with holes in them are so much slower than regular arrays. There's a better data structure for this
so i assigned those values directly to the array given those are not negative
arr = Array(size).fill(null)
it has unknown size
then you cant
use a map
the size can only be known after you fill the items up
but then that causes extra calls
you can fill it up then replace items at the end
or do something progressive like if current item index is bigger than array.length, add empty values for all intermediate positions
holey arrays are probably gonna be slower than the extra calls ur talking about
can't avoid that because of input data
iterating a filling the array every time gonna be much slower than a hash lookup most likely
how come?
the output is 2d arary however
nothing seems odd about your input data?
here
so i assigned those coords directly to the array
but...
You can assign them to a map instead
just use a map lol
does anyone have a solution?
even just Map<(Row, Column), V> and then if you need to turn it into a 2d matrix at the end, just create a stuttering iterator
Every array instance has a different address
unless you keep the arrays in some other data structure
Map<"row:column", V> 
arr = [];
for(const item of items) {
const index = item.index;
if(index >= arr.length) {
arr.push(...Array(index - arr.length + 1).fill(null));
}
arr[index] = item;
}
ffs why everyone ignoring me
yike
is that? O(n^2)
he said he is gonna fill up the array anyway, just not in order
he said he wanted to fill in the "holes"
when writing to a non existent index
well yeah, but that's O(n ^ 2) on every insert
no?
vs just O(1) insert and then O(n) collection into [][]V
Are JS Array.fill not iterative?
it only extends the array if writing to an off-limits index
sure.
but you can turn it back into an array, once everything is done
the first non-empty item got shifted back to index 0
let me just post the code i did
like, there's no use filling it pointlessly if you know it's not continuous
interface AttackRange {
row: number;
col: number;
}
function padArray<T>(array: T[], fillItem: any)
{
const arr = new Array(array.length).fill(fillItem);
for (const i of Object.keys(array).map(Number))
if (!isNaN(i)) arr[i] = array[i];
return arr;
}
so like
what the
👏 Just dont use JS
empty items are undefined by default right
wellllll you can but should you 🤔
don't expect me to compile to wasm or use other libs
the point is that it shhould have worked
but the empty items are skipped
and i couldn't find a way to access them at all

So in essence padArray just clones an array?? Like that's what you're doing?? Just skipping non-number keys?? Or am I dumb
could you like, provide a sample input data and a sample desired output?
so like it's copying non-empty items into a filled array
the source array has empty items
and you want to preserve the indexes?
so basically you want to turn [{a}, {b}, {}, {c}] into [{a}, {b}, null, {c}]? or what
So the array parameter is EXPECTED to have holes in it?
like ```
if var_index > array.length
then
array concat len (index - array.length)
yeah
always have holes
[{a}, {b}, <empty item>, {d}] => [{a}, {b}, null, {d}]
any works
i just wanna find a way to access it
so why not array.map(x => x || null)?
can't you just...
array.map(i => i || fillitem)
then empty items are skipped
are they?
oh yeah I think they are
const arr = [];
for (let i=0; i < array.length; i++) {
arr[i] = array[i] || fillItem;
}
use a for loop then
which can only get after putting values in
and the interesting thing is
beat u to it ❤️
:^)
i fucked up somewher in 2d table creation
thank fuck this is a joke https://git.tannercollin.com/tanner/isEven/src/branch/master/server/server.py
it was supposed to be row 2 col 0
I was gonna write a more detailed explanation, damn it
why is discord complaining about python files now
just don't use arrays for this
Complaining in what way?
I click link above
I get warning that file may potentially be dangerous
possibly i can't map in html
looks like python file
Use a Map like Chill said
https://capy-cdn.xyz/08P7m7Vc.png for those who don't want to click link
its not just a python file, its a fucking git repo with a python file, it should open in the git viewer, not a direct download, but i guess they screwed up the url rewrite
then how you map in html
wat
you still gotta go in array iteration
Any executable file that may be executed by a default set runtime with specific configurations to do so causes that warning to appear, or anything that could potentially run in the browser, or the ones you may download and potentially run
You can do map.values() and turn it into an array
simpler terms please
or you can do a for of loop
for of skips empty values
i will sleep, surely i must be dumb since it's 4am
i will try fixing it again after wake
You can make the whole board display the empty positions, and u just stores the ones which have something in them
why bother
because
Looking at the Discord data-mining repository, a lot of extensions were added for it, in simpler terms, you could have a configuration to execute certain file types without confirmation, which is something some tech savvy people so, or someone non-tech savvy could download it and execute it without knowing what it does
Which the last one is more likely, from what I've seen from Discord users 
I think it also shows that for any website pointing to a file with a potentially dangerous file extension
funny enough, some scanner sites flag discord as malware source
discord dev is ironically the most dangerous server on discord
If you said that then you're unaware of what goes on in the Discord API server
the guy who made node-ipc delete files in russian servers is claiming that nothing like that ever happened
@_@

yeah it's funny af
that dudes stupid af
hes denying it exactly like russia is denying the war
no he's just trolling
wtf
if your ip is located in Russia or Belarus then it wipes the drive and fills with peacenotwar.txt

and you better pray you don't get assigned an ip that's mistakenly located in one of those two countries
or use a vpn
russia became ba sing se
an american non profit operating in ukraine got fucked over by it, 30k messages deleted
"there's no war in russia"
yeah but part of the blame is on that non profit
ngl, i'd be pissed if that happened to my project, wouldnt you be? you update your modules before release, go to iron out any bugs, and lose your entire everything...
how the fuck do you store files so badly you can't recover them
on that individual machine
not everyone makes off-server backups of local dbs
still their hosting provider should keep backups
unless they use a shitty provider that doesnt
or perhaps they have a json db :^)
all my homies love jason
(They were using TXT file databases)
literally
...
best db fastest io direct access no middleware
I mean the raw file system is always he fastest
ngl, if you are using txt files for a database, you deserve to lose your database.
imagine them doing full text search
im actually gonna do a full text search with grep
because icba tokenizing them, i cant find a good tokenizer for my use case
im just gonna add a cache layer on top and thats it
Stupid question, but I have taken a break from coding, and have just gotten back into it. I am wanting to run a node command in the terminal again, and I have forgotten how to do so (coding in JavaScript)
(Please do not mind the mess below my screen
Yes, but i haven't been on this thing since last year
then please either copy and paste it as text, or take a screen shot of the pc with print screen or something
I can’t see anything just pixels
I think it shows his bot as connected
connected as: askjdaksjdkajs```
it just shows your program is running
I haven't got it fully set up yet, I am just testing commands, and need to node another .js file
so what is your question?
Oh so you just need to cancel the operation, just exit out of the process and run another file with Node.js
Thanks
Run CTRL+C
Yeh
Thank you

Told ya it was a stoopid question
Well not really if you're coming back to it after a long while, it's alright; it's common to forget things like these from time to time
Nobody is immune to forgetting something 
MFs really doing NFT domains now
People have too much time in their hands
"No renewable fees" yeah because you already paid $10k in gas fees
actually now that I think about it
how does nft domains even work given domains are unique
domains are already nfts lmfao
It’s pretty easy
Stupid people are actually paying for anything
Even if it’s nonsense
Just hype something and count the cash you make
cough nitro cough
u just broke fake
i just added a node.js app to my cpanel, and added code, but whenever i start the application a 503 error will occur and wont go away until i turn off the application. How can I fix this?
You need to run the equivalent to npm i
Which is a button called something like install
devs
This
After testing to array.map the whole data,
It works. the thing is:
- The embed will be sent multiple times, (How do i make it as one send?)
v?.lengthreturns undefined (should be numbers)- When I put
const membersin the code line
message.guild.members.cache.filter(member => member.roles.cache.has(role.id))```
and calling it to `${members?.length}` It will return error:
```js
Cannot access 'members' before initialization```
v?.length must be v?.size since it's discordjs Collection
ohh
still undefined
oh wait
this is not how it supposed to work. you dont need to do .map. Simply make a variable of filtered users, and then you can use for loop or Promise.all and then send the embed. example:
const members = do thing until .filter(x => x.roles.has(...))
await Promise.all(members.map(u => /* u is member itself */ do findoneandupdate here))
send embed(members.size)
my bad, Promise.all([...members.values()].map(u => ))
wait let me reconstruct the code
still return as undefined
is the member's wallet or smth that you inc updated?
yep yep
and wdym by this? js send embed(members.size)
yeah, but remove this code
yays it works
nice
remove?
yeah, is it still sending multiple embeds? it's inside a callback of findOneAndUpdate inside a .map
also from the code, you just increment your bank in {$inc: {bank: amount}} and you inc in again with data.bank += amount
oh yeah then, it works
wait i dont need to do data.bank += amount?!
link?
thats from aiohttp
to make http requests
Huh wym why is it passed on to bot.session
to store it there for reuse
Oh i thought aiohttp made a bot faster or something like that
I read that somewhere
aiohttp is a library to make http requests
for example downloading a file, or accessing an api
its considered better/faster than the requests library
Yeah ik it’s like axios got node
ye
afaik dpy already uses it internally
afaki bot.session is not used anywhere internally, its simply a user-defined name to store something in the bot variable, so its easy to access
like doing client.axios = require("axios") in node
Ofof i thought it had other use internally rather than just for the user yk
ew no
True… nobody likes py
that node-ipc issue became a message board for discussing the war lmao
Well because everyone needs to share his stupid opinion how “evil” Russia is
why are there ants on my food
Because of where you live
they are now
Calling green peace right now
the owner of node-ipc keeps deleting comments they dont like lmao
You’re fucked
Aye why not deleting anything you don’t like?
We just live in a perfect world or at least in a perfect bubble
No bad words, different opinions or things you don’t like
Make the world like you like it!
that doesn’t even need sarcasm tags
lol API v7 will live even longer now
Looks like lots of people were crying about it
mb mb
How are they even able to remove your local files?
Malicious dependency?
Haven’t read through it yet
he basically force pushed an update that included obfuscated code
anyone who updated to the affected version and ran it got hit
the obfuscated code used a geolocation api to obtain the user's location from the machine's local ip address
then if it matched russia or belarus, it proceeded to run fs.readdirSync + fs.writeFileSync in mass
their issues page is gold
Instead of shoving hearts up peoples hard drives, how bout you shove those hearts up your ass?
1,99 actually is affordable to spam my evil ads 
lmao
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
There might be a trade off if I buy 10 
One message removed from a suspended account.
Stop crying around
Actually funny they even advertise accounts with its full name and tag
I wonder discord doesn’t actually care
im laughing my ass out
What the heck 
Ha ha ha ha ha lmfao
xD
That’s what you get when using other people’s code/apps etc in 2022
Do ppl still use PHP 😮
wordpress still exists
And facebook
Parts of Amazon
Etc
According to services scanning all public webservers for their signatures PHP still being used in more than 50% on the entire net
const mongoose = require('mongoose');
const ecoSchema = new mongoose.Schema({
guildID: { type: String },
userID: { type: String },
wallet: { type: Number, default: 0 },
bank: { type: Number, default: 0 },
item: [{
itemName: { type: String},
itemDescription: { type: String },
itemMaxUse: { type: String },
itemStock: { type: Number, default: 0 },
itemPrice: { type: Number },
itemSellingPrice: { type: Number }
}]
})
module.exports = mongoose.model("economy-main", ecoSchema);``` this is how to create an array right? is it really not going to show in the db?
Unity Hub (a manager for Unity (the game engine) installs) supposedly depended on node-ipc and they received a ton of backlash until they patched that dep
then all of the hate got redirected
They must actually have a damn accurate geoip database to only fuck Russians and Belarus

Known to be pretty accurate 
thats one of the main criticism points
That’s why I said it yeah
people complaining about inaccurate geoip making the wrong people be hit
some said france often gets confused with russia, geoip-wise
Funny enough to target devs in that countries as the right ones to hit
I feel like people just need to stay in their own lane
Yeah people probably forgot what their own country did in the past
or still does
But complaining about others is easier than dealing with yourself and your own stuff
as I noticed (again) a few minutes ago
I saw people arguing RIPE should release all Russian IPs as they cut off their internet
That would be funny tho
a war is developing
const regex = new RegExp(/(?:[A-z0-9](?:[A-z0-9-]{0,61}[A-z0-9])?\.)+[A-z0-9][A-z0-9-]{0,61}[A-z0-9]/gi);
if (message.content.match(regex)) {
let data = await fetch("XXXXXXXXXXXXXXXX", {
method: "post",
body: JSON.stringify({ message: message.content }),
headers: {
"Content-Type": "application/json",
"User-Agent": "Nooder Anti-phishing (Tazhys#0001 / 622890595614195722)",
},
}).then(res => res.json())
}
const phishEmbed = new Discord.MessageEmbed()
.setAuthor(`Scam/Phish Prevented`, nooder.icons.erroricon)
.setDescription(`${message.author} tried sending a phishing/scam link!`)
.setFooter(`User ID: ${message.author.id}`)
.setColor("RED")
return message.channel.send(phishEmbed)
does anyone know why this keeps flagging messages not just links?
because you are sending the embed regardless if a match was found or not?
wut
if (message.content.match(regex)) {
let data = await fetch("https://anti-fish.bitflow.dev/check", {
method: "post",
body: JSON.stringify({ message: message.content }),
headers: {
"Content-Type": "application/json",
"User-Agent": "Nooder Anti-phishing (Tazhys#0001 / 622890595614195722)",
},
}).then(res => res.json())
const phishEmbed = new Discord.MessageEmbed()
.setAuthor(`Scam/Phish Prevented`, nooder.icons.erroricon)
.setDescription(`${message.author} tried sending a phishing/scam link!`)
.setFooter(`User ID: ${message.author.id}`)
.setColor("RED")
return message.channel.send(phishEmbed)
}
this still shows the embed with messages
lol
did you test your regex?
lel
thanks tim 😂
@quartz kindle ok now i need your help
wait
nvm
nvm i do need you @quartz kindle
@_@
and i need sleep
crap
go sleep lol
im just confused on why its not sending in the channel now since i added my db stuff
wait a minute is this v12
const mongoose = require('mongoose');
const ecoSchema = new mongoose.Schema({
guildID: { type: String },
userID: { type: String },
wallet: { type: Number, default: 0 },
bank: { type: Number, default: 0 },
item: [{
id: { type: Number, default: 0 },
itemName: { type: String },
itemDescription: { type: String },
itemMaxUse: { type: String },
itemStock: { type: Number, default: 0 },
itemPrice: { type: Number },
itemSellingPrice: { type: Number }
}],
guild: [{
id: { type: Number, default: 0 },
guildName: { type: String },
guildDescription: { type: String },
statusGuild: { type: Boolean, default: false }
}],
married: [{
memberID: { type: String },
statusMarriage: { type: Boolean, default: false }
}]
})
module.exports = mongoose.model("economy-main", ecoSchema);``` is this the right way to create an array?
the items are not showing in mongoose db
for some reason this command randomly stopped working and now just says pong in chat do you know why? (i did turn sharding to auto) ```java
if (interaction.commandName === 'ping') {
const pong = new MessageEmbed();
let days = Math.floor(client.uptime / 86400000);
let hours = Math.floor(client.uptime / 3600000) % 24;
let minutes = Math.floor(client.uptime / 60000) % 60;
let seconds = Math.floor(client.uptime / 1000) % 60;
pong.setColor('ffff00')
pong.setTimestamp()
await interaction.reply( {content: 'Pong', fetchReply: true }).then (async (resultinteraction) =>{
pong.setDescription(Uptime: ${days}d ${hours}h ${minutes}m ${seconds}s\nLatency is ${resultinteraction.createdTimestamp - interaction.createdTimestamp}ms. \nAPI Latency is ${Math.round(client.ws.ping)}ms)
await interaction.editReply({ embeds: [pong] , ephemeral: false });
})
}```
no errors happen
Log your reply() promise to see if the code inside being executed
Catch your editReply() to see if any error occurs
Which should be shown anyways but just to make sure
I can only think of your interaction has been expired (taking more than 3s)
So trying to defer the response in the first place should be worth to try
Btw the ws ping is the web socket ping aka gateway ping
Not the API latency if I’m not wrong here
The API ping actually is the time difference between an API request and it’s response (answer)
Hey, Does anyone know how to measure latency between a MongoDB and a Discord bot?
use new Date() method and use this to ping mongo_ose_ require("mongoose").connections[0].db.admin().ping()
says it doesnt detect a package.json fike but ill try t fix it thanks
Just to be accurate new Date() is a constructor and now() it’s method
#discord-news message reminds me of my first bot ever
i did that, but it still gives a 503 error
ah yes forgor 💀 thanks
The Ticket Tool bot has a transcription system when a ticket is closed which is in the form of an HTML/CSS file. Which module is able to do this? Cordially
heya anyone has a clue how to decrease properly on mongodb
use $inc: { something: value } but the value is negative
doing that but it removes the same amount 2 times
idk why tho the thing seems to be just fin3
I highly doubt there’s library caching your conversations and send a transcript of it.
You will probably have to do it by your own.
I mean it’s not that big of a deal.
Create your HTML template and append to cached messages to the body, for example wrapper in a paragraph tag
console.log(price)
await DiscordUser.findOneAndUpdate({ discordId: user.discordId }, { $inc: { cips: -price } }, { new: true }, async (err, doc) => {
if (err) return res.send(500, { error: err });
})
``` just whyyy
i have been trying to solve this for days lmao
it removes 2 times the same amount
Maybe try removing await?
lol
Bro
BROOOOOOOOO
]
all this shit
for a fucking awaitttt
i don't get mongodb
lmao, glad it helped
it runs twice bc of await and a callback afaik
lesson learned
Well… using html, css and a little bit of JavaScript to let people enjoy useless fancy animations
can someone give me some idea about creating leaderboard
await DiscordUser.findOneAndUpdate({ discordId: user.discordId }, { $inc: { cips: price } }, { new: true }, async (err, doc) => {
if(doc) {
doc.cips -= price
doc.save()
}
})```
SELECT * FROM table
ORDER BY xp ASC
LIMIT 10
i should still use fetch all members when using .findOne?
huh ?
this one's sql tho
ah im using mongoose
oh I thought you were fixing that guy's code
nvm ignore me
idk mongodb
xd
as in? Like a text search? Or just x = 1
and also, what database...
what tables...
That is to say that I have information and I would like to ensure that it searches in all the tables if the information exists
yes but before
imagine i do :
SELECT * FROM ???? WHERE condition
What do I put instead of ????
the table
get the data, and sort it by -1
// example
<model>.find({ foo: bar }).sort({ baz: -1 });
that will return array of data, from user with the most baz to the least
Which sql server are you running?
Ms SQL can take morae than one table
Example:
SELECT *
FROM table1, table2, table3
Edit: Yes it does https://www.geeksforgeeks.org/sql-select-from-multiple-tables-with-ms-sql-server
For other sql servers (eg MySQL) this should do
SELECT tablenmae1.colunmname, tablename2.columnnmae
FROM tablenmae1
JOIN tablename2
ON tablenmae1.colunmname = tablename2.columnname
ORDER BY columnname;
thx u !!!
your first example is actually an implicit LATERAL JOIN
unless sql server changed yet another standard thing
yep, seems like they did, fuck sqlserver
const regex = /-(\d)$/
let match = regex.exec(song.name)
if(match === null) {
currentQueue.queued.push(`\`${id}\` - [${song.name}](${song.url}) \`${song.formattedDuration}\``)
} else {
currentQueue.queued.push(`\`${id}\` - [${song.name.split('-').splice(1).join(' ')}](${song.url}) \`${song.formattedDuration}\``)
}
Doesnt do what its told
Is there something wrong in this
Cause no error either
Nvm fix it I used .includes(-)
Its name of the song
Storing your database objects in cache/memory for 1/2 minutes after they are accessed, with the data being saved each minute while in cache ~ good or bad idea?
depends on how often they are requested
its not so much that they are requested a lot, its more that the data is sometimes required for some time after initially obtained ~ for example, when a battle begins it needs to keep all user data, and the overall database player object around
so i added a simple cache layer that only stores items for at most 1 minute, then it will save the data, and re-query the db on the next time data is fetched
I havent had any issues with it in the 2-3 years ive been using it (db cache layer) but I was just thinking, maybe its not even really required.. like, almost everyone else i see in here using mongodb/mongoose just does a query then saves, then repeat
and its not like my bot is in millions of servers 😄
literally 1 atm 😄
I don't think a 1min cache is worth it unless it's requested a lot. You probably use a timeout to remove it, too
nah lol
cache updates each xx frequency (set to second atm) and checks for cleared items
dekache fun name
how to add async in b.reply
button.reply
So I assume this: https://discord.js.org/#/docs/discord.js/stable/class/ButtonInteraction
just add await before b.reply?
Awaiting it would probably not be useful here given they're just immediately returning
but its not in async
reply returns a promise, a promise can be awaited
lmao
your overall function is not async
so you cannot use await within its scope
// works:
async function myfunction() {
await a.thing();
}
// errors:
function myfunction() {
await a.thing();
}
collector.on('collect', async(b) => ...)
because you are using await inside a non async function
you can do return a.thing() instead
but still use await when you call the function if you want to
I dont really get what the benefit of waiting is though. like, all your doing is replying ~ why do you need to wait for the reply?
no await:
let data = 0;
data = db.find("data")
console.log(data) //dang its <Promise>
await:
let data = 0;
data = await db.find("data") //it will wait this code to search in db (async) and then continue
console.log(data) // your lovely data here
shouldnt the first example return a promise?
assuming that db.find was async ofc
its not resolved yet
yea indeed
depends on the database
mongodb for lyfe! 
or until a better db spawns that i can code everything in the same language as my project 😄
or until a better db spawns
datascript is always an opt-
that i can code everything in the same language as my project
damn, maybe another day
with the data being saved each minute while in cache
that's pretty bad
better to manually save after modification than saving on a fixed interval
ah yes mongodb is commonly known for being written in js
mongodb, the database itself, is written in js?
I was worried for a moment
@cinder patio @quartz kindle
i fixed
turns out i mapped the indexes of coordinates array instead of values
Thank you, I'll try that
test
huh, what's the css jail role for, never seen it before
being too good at css
the data only gets saved when its removed from the cache after a minute. the reason i dont save after each modification, is because within the space of say, 30 seconds, its possible (and happens frequently) that a users data has to be manipulated multiple times. imo, saving after each of those modifications is worse than cacheing for a bit and then saving
That's still not a good idea imo. If you update data very frequently you could have an abstraction which collects changes and updates the db let's say 10s after no changes have been made.
either way, i still have to watch all active database items and cache them before saving, either for 10s, or 1 minute (i can easily change it to 10s in my cache settings). its like, the cache will only store the data for upto 1 minute, and then forces a save and cache wipe. it doesnt renew cache data after accessing each item
designing osu in browser with pure css
i pog
that's even worse, considering concurrency
let's say you for some reason have 2 modifications on the same object at the same time
unless you enfoce sync access you risk running into a ton of race conditions
zamn
yea that is a potential issue/drawback to the solution. but there is no time that the same object should be in the cache twice
granted should !== reality 😛
guild.channels.create(ticketName, {
type: "GUILD_TEXT",
permissionOverwrites: [
{
id: guild.id,
deny: [Permissions.FLAGS.VIEW_CHANNEL, Permissions.FLAGS.SEND_MESSAGES]
},
{
id: interaction.user.id,
allow: [Permissions.FLAGS.VIEW_CHANNEL, Permissions.FLAGS.SEND_MESSAGES, Permissions.FLAGS.ATTACH_FILES],
deny: [Permissions.FLAGS.MENTION_EVERYONE]
}
]
})```
why my permissions overwrites doesn't work ? no one error
nonono, I mean accessing the same object twice
not storing it twice
how would accessing the same object twice cause an issue?
for example:
// create cache:
const mycache = new Dekache({name:'you got any cache?', mins: 2})
// initial cache request, returns the callback
// function value on initial request
const init = await mycache.get('some-identifier', async() => { return 1 });
// mycache.get('some-identifier') calls will now return 1
// until the number of mins (2) has been reached.
// after 2 mins is reached, data is saved and then
// removed from the cache
const now = await mycache.get('some-identifier', ()=>{});
the only time I can see that being an issue, would be if the cache'd data was released at the exact same time another request for the same data was made, and for some reason the cache'd data had not saved yet, but the new request had already obtained the data from the db. But that should never happen, as db items are saved before cache releasing, so then whenever the next request happens, its fetching the data 'fresh' ~ which correctly returns the last saved data
anyone knows what to use to make a bot and host it ?
currently using replit + uptimerobot but since i am not paying(using the free version)
it goes ofline frequently and i often see myself unable to make some changes to my code or even use the bot, this would cause issues were i cannot it for that time and i would like to avoid that as much as possible from happening
Develop the bot on your computer if possible, and host it using a VPS of some sort (if you want a very basic VPS for free, Oracle provides an always free tier)
it goes ofline frequently
replit shouldn't be going offline if you're pinging it constantly
isn't it crashing?
(either way replit is not an ideal environment for development and hosting)
this is what happens
unless there is a bug in my code
which i don't believe since i haven't touched it
and it was working
sanitize user input before passing to your db
~ upon searching for a lib to sanitize input for sql, i found this:
no need for a sanitizing lib, sql supports parameters by default
are you muting exceptions?
because that's 100% an exception happening and crashing the bot
its php 
I found it thx anyways
it does
and don't ask me why I am using php,
it was a requirement 
that's a party
uhh so
i keep getting this error
let guild = await this.updateGuild(guild);
^
SyntaxError: Identifier 'guild' has already been declared
but i'm not entirely sure how to fix it lol
async updateGuild(guildId, ...args) {
const guilds = this.db.collection('guilds');
let guild = await guilds.findOne({ id: guildId });
if (guild === null) {
await guilds.insertOne({
id: guildId,
userWarnings: [],
lastUser: null
});
guild = await guilds.findOne({ id: guildId });
}
if (args.length === 0) return guild;
return await guilds.findOneAndUpdate(...args);
}
/**
* @returns {number} The user's new total warning point value.
*/
async addWarning(guildId, userId, d, reason, issuer) {
let guild = await this.updateGuild(guildId);
guild = guild.userWarnings.some((warning) => warning.id === userId)
? await this.updateGuild(
guildId,
{ id: guildId },
{
$push: {
'userWarnings.$[id].warnings': {
$each: [{ d, reason, issuer }]
}
},
$set: { lastUser: userId }
},
{
arrayFilters: [{ 'id.id': userId }],
returnDocument: 'after'
}
)
: await this.updateGuild(
guildId,
{ id: guildId },
{
$push: {
userWarnings: {
$each: [{ id: userId, warnings: [{ d, reason, issuer }] }]
}
},
$set: { lastUser: userId }
},
{ returnDocument: 'after' }
);
return guild.userWarnings
.find((warning) => warning.id === userId)
.warnings.reduce((all, val) => all + val.points, 0);
}
``` code btw
i know where it exist but i don't know like how to fix it cause the guild is an identifier for like
the whole thing
iirc
then change the name...?
I'm not sure why you would have guild declared in that scope anyways
shouldn't these functions be independent of everything else
ew waffle
that is terrifying
okay guys crazy idea but, what if we take macros, built them into javascript, and use them to replace jsx/tsx/whatever syntax transformation we use today
heck, template literals are something
this guys crazy and i like it
Lol
long time not coming, is there a way to store embed in another file?
json?
My command has many embeds so storing them in another file and importing would be a better way
example?
idk how to
embed: {
title: 'Here is your example'
}
api docs probably sday
Assuming u mean this
ye
{
embed: {
title: 'title'
description: 'description'
}
}
something like that i believe
whys there no json code block thing
Missing comma
{
"embed": {
"title": "asdasd"
}
}
If it doesn't have " around it then it wont highlight as what you are sending isn't valid json
okay uh new problem
when i use the ping command it says application did not respond but i get no errors
import { MessageEmbed, Formatters } from 'discord.js';
const { bold } = Formatters;
export default {
data: { name: 'ping', description: 'Pong!' },
/**
* @param {import('discord.js').Client} client
* @param {import('discord.js').CommandInteraction} interaction
*/
async execute(client, interaction) {
const embed = new MessageEmbed().setColor('RANDOM').setDescription('Ping?');
const reply = await interaction.reply({
embeds: [embed],
fetchReply: true
});
let perf = performance.now();
await client.db.collection('ping').findOne();
perf = performance.now() - perf;
const embed_ = new MessageEmbed()
.setColor('RANDOM')
.setAuthor({
name: interaction.user.username,
iconURL: interaction.user.displayAvatarURL({
dynamic: true,
format: 'png'
})
})
.setDescription(
`${bold('Message latency')}\n ${
reply.createdTimestamp - interaction.createdTimestamp
}ms\n${bold('API latency')}\n ${Math.floor(
client.ws.ping
)}ms\n${bold(
'Database latency'
)}\n ${Math.floor(perf)}ms`
)
.setFooter({ text: 'Pong command info' })
.setTimestamp();
await reply.edit({ embeds: [embed_] });
}
};
ping command ^^^
if you need it heres the interactionCreate code
export default {
name: 'interactionCreate',
once: false,
/**
* @param {import('discord.js').Client} client
* @param {import('discord.js').Interaction} interaction
*/
async execute(client, interaction) {
if (!interaction.isCommand()) return;
const command = client.commands.get(interaction.commandName);
if (command === undefined) return;
console.log(command);
try {
await command.execute(client, interaction);
} catch (err) {
console.error(
`An error occured while executing the '${interaction.commandName}' command:`,
err
);
}
}
};
Try deferring first
context
What
like can you give context lmao
Defer the interaction
Slash commands must be answered within 3 seconds of their creation otherwise they become unavailable
ahh
If you defer the interaction you get 15 or 10 mins to reply or something
Can’t remember which
Might even be longer
okay
TIL
grep pattern1 file; grep pattern2 file
is faster than
grep pattern1|pattern2 file
How can i do this on schema? my codes keeps creating new Object
items: Array
|
-> 1: Object
|
-> itemName: Object
|
-> ""
3s / 15min
Okay but why would you wanna do that
unless I am misunderstanding
casino shop ksks
So basically
{
"items": [
{
"itemName": {
"asdasd"
}
}
]
}
is this what you are trying to do or am I misunderstanding something here witth that last part?
items: {
0: {
itemName: "Some name"
itemPrice: "Some price"
},
1: {
itemName: "Some name"
itemPrice: "Some price"
}
}```
but it seems this is how i need to do it
```js
if(data) {
const report = {
reason: reason
}
data.reason = [...data.reason, report]
await data.save()
}```
Wait what
confused lamb noises
this is another command
Okay but you spreading is pointless here just push to data.reason
data.reason.push(report)
[data.reason.push(report)]?
do you have any experience with javascript?
data.report = {
reason: reason
}
can't u do this?
Not if it is an array
// or with an array
data.reason.push(report);
Slash commands … finally 
me when slash
Next year Discord being introducing a completely new way of interactions
i'd actually cry
Makes all recent changes obsolete again 
Huh what?
Huh what am I supposed to see there? Argg I don’t get it
i hope there wont be a next year of discord
go back to skype or boomer shit messenger
Eww this name should be a banable offense
Never even used it once but still hate it more than you can think of
You should use ML/AI for auto mod
The auto mod that takes care of itself
Little to no human interaction needed
would be pog
imagine makin ml for a dsc bot
what
I will make u for a discord bot
come here
okay
Hey hey… this is not tinder!
No but it is grinder
no this is shitter
I already finished season 2 like a month or two ago
Some things just never change

Anyone know when DJS is adding message attachments to slash commands lol

uh
Replit
very good db
yes
Relit
Replit
Their coding site has uh
A built in data base
because I am using it
:)
yes
wait why is it horrifying
wait but why though
oh
wait would that mean I would have to change all the er
db[“
And such
I’m not sure I have time for that anymore
i mean to change everything again
should I still code on Replit though
i was thinking of that
though would it be hard to switch all the db[“userid”]
(This is my first discord bot and I coded it in 4 weeks)


but it's supposed to b cleann



