#development
1 messages · Page 77 of 1
something like this
id
constructor(id) {
this.id = id
}
log(text) {
console.log("log id ---", this.id, text)
}
}
const anotherFunc = () => {
this.logger.log("something new another")
}
const boot = async (id, time = true) => {
const logger = new Logger(id)
logger.log("before")
if (time) {
setTimeout(() => {
anotherFunc()
}, 3000);
}
}
boot(123)
setTimeout(() => {
boot(555, false)
}, 2000)```
class main {
constructor(id) {
this.id = id;
this.logger = new Logger(id);
}
boot(time = true) {
this.logger.log("before");
if(time) {
setTimeout(() => {
this.anotherFunc();
})
}
}
anotherFunc() {
this.logger.log("something new another")
}
}
const a = new main(123);
a.boot();
const b = new main(555);
b.boot(false);
what if "anotherFunc" is exported from another file?
you can do this ```js
const anotherFunc = require(...)
class main {
constructor() {
this.anotherFunc = anotherFunc.bind(this)
}
}
mmm
or this ```js
const anotherFunc = require(...)
class main {
anotherFunc() {
return anotherFunc.call(this);
}
}
so i have no choice but to pass args
to this?
i'll have to do this to every inner func inside of anotherFunc as well
which is not ideal
you have to put your args and context somewhere, with classes you can use this, with functions you have to use arguments
mm
how does google cloud run do it then? they generate a new id for each request for the logs
if the function is inside the class, or bound to it, or called from it, then the function also has access to this
if not, then it needs arguments
no idea how they do it, but most times its done by creating a new instance of a class for each request
thats what i do in my api
mmm new instance yeah trying to figure out a way to do it by not making it global object or something where it would be affected by 2nd incoming req
or by passing it to funcs
all class instances are separate from each other, they cannot be affected
given that the funcs are called from within the class
someServer.on("request", (userid) => {
const instance = new SomeClass(userid)
instance.doStuff()
})
the moment i use global instance its all gone for a toss
no other request can interfere with an existing class
each request will create its own separate instance
const instance = new SomeClass(userid)
func1()
})
func1() {
const instance = new SomeClass(userid)
instance.dostuff()
}
can i do this?
mm
ig i gotta store a global object with userid mapping
if i wanna use it that way. but i gotta pass user id everywhere
either called from within the class, or bound to the class, or called using .call(), or called by giving it the id or context as a function argument
mmm
that will create two separate classes
this is going to be a challenge
the class inside func1 will have no id
yeah mmm
its more like, i got a global logger instance
export logger = new Logger()
logger is called in multiple files and funcs
i want the logger to have same id for 1 execution
a global class is called a singleton, in that case the class cannot have a context, you need to pass the id to its methods
so you will always have to use logger.log(someid)
lets say
func1() -> inside func1 there are few more funcs() in diff files
})```
mmm
and everywhere i need to pass the id as args
into all these funcs
right?
thats mm man not ideal
depends, you can mix them up in a lot of ways
lets say i have logger.log in func3
the object oriented way would be using classes and putting all the funcs inside the classes
which is called inside func2 -> func1
yeah well cant but all funcs inside 1 class
the functional programming way would be by passing the id to all of them via arguments
okay so
you can mix it up as you prefer as well
for example having func1 inside a class, then func2 called with id as an argument
is it possible for me to access log inside func3 if its in diff file but is being called in func2 which is inside of a class?
via "this"
constructor() {
// set id
}
func1(params) {
return func2.call(params, this) // from another file
}
}
export func2({ other parameters }) {
this.log() // is this possible?
}
its possible if func1 is inside class x
params and this shold be the other way around
this first
yes
what .call() does is defining a this value for the function, and then executing it
function.call(thisVal, param1, param2, ...)
it doesnt matter, its just a design decision, how you want to design your stuff
if you have a lot of context and relationships, usually classes are nicer to use
nah
technically speaking, up until a certain number of arguments, funcions will probably be a little faster than classes
but depending on the thing you're working on, classes will be much much easier to work with
id
constructor(id) {
this.id = id
}
log(text) {
console.log("log id ---", this.id, text)
}
}
const anotherFunc = (params) => {
this.logger.log("something new another " + params)
}
class Main {
logger
constructor(id) {
this.logger = new Logger(id)
}
boot(params) {
console.log("log id: ", this.logger.id)
setTimeout(() => {
anotherFunc.call(this, params)
}, 5000);
}
}
const main = new Main(444)
main.boot("extra params")
setTimeout(() => {
const msain = new Main(555)
msain.boot("extra params")
}, 2000)```
well the only reason i need logs to have unique id is to follow the stack trace
and see the execution line
so i tried this and it says this.logger is undefined
arrow functions do not support this at all
anotherFunc needs to be a normal function
welp
figured haha
oh well
thanks
gotta find other ways cause i have arrow funcs everywhere
if id is all you need everywhere
then its not a big deal if you just give it as a parameter to all the functions
you can just do func1(id, stuff) -> anotherFunc(id, other stuff) -> func3(id, something else)
yeah well the problem is i'd have to pass this param in all funcs which are in hundreds
gotta find other ways mmm
maybe closures
?
i fr need a global object to somehow behave like a local object
thats not possible, because a global object will be modified by other functions, which you dont want
yeah, mm just tryna set a context for each new request thats all
memory leaks can happen in any kind of code, it happens if you forget to close streams or forget to clear references
hi, is there a way to call interaction.reply() multiple times without getting Interaction has already been acknowledged. error?
well it only sends it once but needs to be called twice
e.g. this gives an error but i can't figure it out:
try
{
...
} catch (err)
{
return interaction.reply("epic error message");
}
interaction.reply("ok")
discordjs latest
yes, dont reply twice
i need it to be ephemeral
show your current code

well, I cant help unless I see the code that's erroring
because the example u showed shouldn't error
Hello
it should if something goes wrong
Damn
...you're missing the point
тянуть 31 мои друзья
Is building websites with hugo a good idea? (or efficient, let's say)
Wats hugo
It is used to create static websites, and yes it's good at doing its job.
Try it and see, then if you want to keep on using it that's your choice.
I felt like it doesn't require deep learning when it comes to using it.
Drag and drop sort of?
It's a framework.
Using, no. But if you want to make your own custom pages you will need to code a lot.
Fair enough.
Up to you if you want to use it or not, simply try it out is what I'd recommend.
Eh, I've been willing to rewrite my portfolio...
However, someone told me about Hugo, but not sure if it'd be efficient to use such so.
It is, at least that's my opinion.
Do you use raw HTML & CSS for your website?
💀
???
Nope I don't
Markdown
Astro and Hugo are completely different things, Astro sucks for what Hugo does.
No need to come over and over with Astro.
Fair enough.
use mainstream ones like mine
turns out i had second bot instance already replying to interaction 
ah
hi my bit isnt working
no thanks!
whsts not working
it wint let me lig in
You need to use your login details.
whats that
Hey i want to ask something
Your details you use to login (Username and password)
oh ok
what are thjey
okay i sent you my password and email in dms
tf is happening here
hope you're joking
@green haven have you logged into it yet>?
yes omg be patient
i want my bot up
?
you ungratefuil toad
give me my password back
hahahshshshsjs lmaoooo
okay
30,000?
right? u didn't give your password did you?
excusing you
i did because she said she would help me
developing brain
its giving
you're either too innocent or dumb as a brick
can you ban her shes messaging my friends
👀 wth is going on here
what
you hacked me
@valid furnace dont give your password info out.
@green haven dont ask for user login info.
context:
but you asked for my password
i didnt do anything 😭
wtf is this drama
obviously dont give it out
but she was helping me
i thought she would help
thats not how the internet works 👀
cries
never share account info
i choose my own destiny
💀
You'll want to learn to program first.
top.ggTop voted bots on Top.gg ; ProBot ✨. 4.2. 8,000,000 · logging · +4 ; Mudae. 4.5. 3,371,839 · fun · +1 ; Karuta. 4.2. 678,782 · art · +10 ; Dank Memer. 4.8. 8,627,015.
to learn ciding
stop why are you so toxic
buddy they aren't even on the same topic
just move on
what are you even talking about
I like JavaScript because had has libraries like discordjs
can I use mongodb
with mongoose npm package

all languages have some kind of wrapper for discord
you just need to select the one that you likes the most
they're muted
discord.chef when
discord.whitespace
discord.intercal
🤢
How can i fix this?
C:\Users\diana\Documents\vscode\Hundy Bot\Hundybot\node_modules\mongodb\lib\cmap\connection.js:207
callback(new error_1.MongoServerError(document));
^
MongoServerError: BSON field 'delete.deletes.q' is the wrong type 'string', expected type 'object'
at Connection.onMessage (C:\Users\diana\Documents\vscode\Hundy Bot\Hundybot\node_modules\mongodb\lib\cmap\connection.js:207:30)
at MessageStream.<anonymous> (C:\Users\diana\Documents\vscode\Hundy Bot\Hundybot\node_modules\mongodb\lib\cmap\connection.js:60:60)
at MessageStream.emit (node:events:513:28)
at processIncomingData (C:\Users\diana\Documents\vscode\Hundy Bot\Hundybot\node_modules\mongodb\lib\cmap\message_stream.js:132:20)
at MessageStream._write (C:\Users\diana\Documents\vscode\Hundy Bot\Hundybot\node_modules\mongodb\lib\cmap\message_stream.js:33:9)
at writeOrBuffer (node:internal/streams/writable:392:12)
at _write (node:internal/streams/writable:333:10)
at Writable.write (node:internal/streams/writable:337:10)
at TLSSocket.ondata (node:internal/streams/readable:766:22)
at TLSSocket.emit (node:events:513:28) {
ok: 0,
code: 14,
codeName: 'TypeMismatch',
'$clusterTime': {
clusterTime: Timestamp { low: 1, high: 1671198912, unsigned: true },
signature: {
hash: Binary {
sub_type: 0,
buffer: Buffer(20) [Uint8Array] [
81, 46, 129, 63, 18, 156,
19, 197, 204, 12, 254, 49,
70, 149, 145, 133, 15, 184,
168, 141
],
position: 20
},
keyId: Long { low: 21, high: 1655997781, unsigned: false }
}
},
operationTime: Timestamp { low: 31, high: 1671198911, unsigned: true },
[Symbol(errorLabels)]: Set(0) {}
}
show code
try {
if (!interaction.author.bot) {
const channnel = await client.channels.fetch(db.channelId);
const message = new EmbedBuilder()
.setTitle(`Hundy Global | ${interaction.author.username}`)
.setDescription(`\n ${interaction.content}`)
.setFooter({ text: 'Von Server: ' + interaction.guild.name })
.setThumbnail(interaction.author.displayAvatarURL({ format: 'ping'}))
// .setImage(interaction.guild.displayAvatarURL({ format: 'png' }))
.setImage(interaction.guild.icon)
await channnel.send({ embeds: [message]})
}
} catch (e) {
db.collection.deleteOne(db.channelId)
}
ah, mongo
Yes
well, judging by the error, deleteOne isn't expecting a string
cant say much more than that
Okay thanks
Okay
Can anyone tell me how to delete the object that has the data to the server?
In mongodb
aka mongoose
hey @royal portal is there a way for my bot to check if a slash command is ran in a dm?
should be
client.on("message", msg => {
if(msg.guild==null &&msg.author.id!=='botDiscordId'){
msg.reply('dosomethinghere')
}
});``` ?
slashes dont have an author
Slash-commands aren't messages either
is there a way to detect it?
ok thx
what does this error even mean
it means your node is outdated
how can I make typescript use tabs instead of spaces after compilation? my files use tabs but the output isnt and its causing errors
or just make it remove tabs entirely, that would work too
configure ur editor
but anyway, HOW is it causing errors?
I mean the image u sent
I have this string:
`
Hello
How are you?
`
and it renders the spaces
and I dont want to
the first ` dictates the spot zero
u get what u get
u can also replace those spaces, but it'll cost some processing for the sake of code vanity
funny enough, in java the first word dictates spot zero, instead of the quotation mark
you have 3 options:
.setDescription(
some text here and some more
)
2. ```js
.setDescription("some text\nhere\nand\nsome more")
.setDescription([
"some text",
"here",
"and",
"some more"
].join("\n"))
all equally cursed 
3 seems the best lmao
and the only one that requires additional processing
option 4. ```js
Hello How are you?.replace(/\s+/g, " ").trim()
u can also replace those spaces, but it'll cost some processing for the sake of code vanity
wont work
it'll look like this
but without the leading spaces
a
wait
that'll result in
idk regex
lmao u just replaced everything that's an alphadecimal character
what u want is /\s+/g
but yet again, additional runtime processing for the sake of code vanity
btw, that'll result in HelloHowareyou?
there
lmao
or
`
Hello
How are you?
`.split("\n").map(x => x.trim()).join("\n")
@balmy jasperot
any clue why js client.on("ready",
isn't working
did you run that function?
yh
show more code
its something to do with the client I did debugging and I sent you all the Client bits
show where ur calling that function
show you index.js
although i kinda already figured out whats wrong tho
your problem will probably be fixed if you do async (client) => { (which btw you can remove the async here, its not needed) and remove the require("../index")
and then call the function with (client)
How do I get into the comma in node.js?
Yes 0,00000000060
Yes
"Young programmer gets into comma after learning JS"
calculate
what do you want to calculate? can you show an example?
0,00000000060 bitcoins per minute
I wouldn't get into deep decimals if I were you
Why?
js isn't precise enough to maintain a stable calculation when u use very small numbers
for such high precision calculus you'd use a scientific-capable language like c
the big question is, why do u need it?
there are some libraries that are made to handle precise numbers in js
but yeah, js itself does not have built in support for high precision decimal numbers
I will make a bitcoin system

do u REALLY need to use such ultra-small numbers?
okeh, he will develop improved blockchain
yes
is it for a bot?
yes
are u basing the values off bitcoin api or setting them manually?
for small income
just go with bigger numbers then
manually and + upgrades for more
numbers in js can go up to 2 billion, just use a higher number like 0.0006 or so
in this case, i'd use a package to ensure high precision numbers
lies, lies everywhere
its not hard to make a high precision number system in js, since it has BigInt which can be used to simulate decimal numbers, but for extra safety you probably want to use something that already exists and is trusted by other people
Is BigDecimal not a thing in js?
its not officially part of the js spec, but it exists in some js engines as a custom feature
quickjs has it, v8 doesnt
const timezone = `America/New_York`;
let options = {
timeZone: timezone,
year: 'numeric',
month: 'numeric',
day: 'numeric',
hour: 'numeric',
minute: 'numeric',
second: 'numeric',
millisecond: 'numeric',
},
formatter = new Intl.DateTimeFormat([], options);
console.log(formatter.format(new Date())); // Logs 12/16/2022, 4:37:04 PM
How to convert this date to ms?
Is that possible?
well, yes, but why do u have it to being with?
?
Because i'm using a command that works according the user timezone so the user needs to add his timezone to use the command and i want the ms to calculate the time between the timezone of the user and timings in the command.
whu not use the ms package
cant u just use js' Date?
but well, back to your question, yes you can convert that to millis
it'll be a lengthy code, but it's possible
multiply second by 1000, minute by 60000, hours by 3600000, etc
then sum all together
hey guys
i am using sqlite3 for nodejs atm as i wanted to implement a bit of testing due to my midterms next month
i have made this
let k = await db.query(sql` SELECT * FROM role;
`)```
however, is this even possible? And what does the variable look like? Is k just an array of objects?
sql` SELECT * FROM role;`
``` this is called a tagged template
no idea what the sql function does, but it should return an array of results yes
i never really implemented the things i learned in dbms in actual code, but rather tested the queries in duckdb (more like a client)
love!!
tbh i think that dbms is my favourite subject so far. I love to work with data, same went with my past semester course analysis.
What should I use for this format?
a custom format
u can format dates however u like
Nobody cares. Fuck NFTs, fuck crypto, fuck spammers
i care but u must be dumb to advertise nft in this server
Why the heck you're putting this on a development channel.
He wants to get people into investing in environment-destroying dogshit scams
That’s my take
I like artists, I like web developers, but I have absolutely no respect for people who use those things to promote “metaverse”/“web3”/crypto scams
@fluid loom please dont advertise
this channel is for development related discussions and advice, not a place to grow your own projects
timcoin is the next big thing, it will be worth more than bitcoin in 5 years, trust me bro
@wheat mesa do you prefer going safe on readability or unsafe for speed
my current code involves a lot of pointer arithmetic 

wtf are you doing that requires that much ptr arithmetic 😭
custom string ends with function 
okay maybe i should really use Iterators
i forgot that this is not C

there we go now it's more bearable
all of that for a simple endsWith function? damn
compare the length beforehand
if the desired match is longer than the test string, it's impossible for it to end with it
alrighty
i'm the type of person who use Rust just for the features, and in the end i still stick to my C's unsafe self 
Hey i need a little help.
Actually I'm creating a tag system, in which if user can set certain tags and a reply for that.
I'm using mongo db to store that. Can anyone tell me I'm which way should I store so that I can add and delete the data easily
not sure what you mean by "which way I should store"
I mean, should I store it as a direct object or an array of objects?
why would you store it as an array
you'd have to fetch the entire array and append to it and then push the entire array each time
wasted performance
Then i should directly store it as an object like
{
"tag1": "hello",
"tag2": "bye",
}```
I see nothing wrong with that
hey @quartz kindle I was able to solve my issue using cls-hooked they basically use the call stack to map the context. interesting stuff
didnt need to use class or pass any args
if (message.guild && message.guild.id === chx) {
message.channel.send("sei premium")
} else {
message.channel.send("non sei premium")
}
I don't know why but it doesn't send me mesage after else
because else won't run if the first condition evaluates to true
in fact if that and false it still doesn't send it, it doesn't send if or else
if (message.guild && message.guild.id == chx)
{
message.channel.send("sei premium")
}
else
{
message.channel.send("non sei premium")
}
i think the issue with the "===" operator ? i guess it should be "==" idk
is 'chx' a variable?
yes
const discord = require ("discord.js");
const config = require("../config/config.json")
const prefix = require('../config/config.json')
const db = require("quick.db")
module.exports.run = async(client, message, args) =>{
let chx = db.get(`premium_${message.guild.id}`);
if(chx === null) {
return;
}
if (message.guild && message.guild.id == chx) {
message.channel.send("sei premium")
} else {
message.channel.send("non sei premium")
}
await message.channel.send("non sei premium")
}```
do you know what the value of it is
const discord = require ("discord.js");
const config = require("../config/config.json")
const prefix = require('../config/config.json')
const db = require("quick.db")
module.exports.run = async(client, message, args) =>{
let chx = db.get(`premium_${message.guild.id}`);
if(chx === null) {
return;
}
await message.channel.send(chx)
if ( message.guild.id == chx) {
message.channel.send("sei premium")
} else {
message.channel.send("non sei premium")
}
}
try it like this
that'll just send "sei premium" every time
let chx = db.get(premium_${message.guild.id});
it = the id
if ( message.guild.id == chx)
i think like that will work
noone except him knows what is in the database so we dont know if chx is equal to a snowflake, number, array or what
then try to send the chx so you can see what is
const discord = require ("discord.js");
const config = require("../config/config.json")
const prefix = require('../config/config.json')
const db = require("quick.db")
module.exports.run = async(client, message, args) =>{
let chx = db.get(`premium_${message.guild.id}`);
if(chx === null)
{
return;
}
await message.channel.send(chx)
if ( message.guild.id == chx) {
message.channel.send("sei premium")
} else {
message.channel.send("non sei premium")
}
}
whats wrong with console.log
yeah also good
it should just have permissions that it needs to function
personally i wouldnt just use the admin permission, especially for a new & untrusted bot
okay my bot have permission like normal users send message
there is id of the server whose command I want the command to go
Console.log it to see if it’s actually what you expect it to be first
Hi guys,
I have a question about graphql. I use Postgresql database and redis for cache, but I got delay.
I want to make it more less. Do you advice me to use it in my project or nope.
This is simple rep
and this is only 36 row
DiscordAPIError: Missing Permissions
at RequestHandler.execute (/home/ubuntu/Ares/node_modules/discord.js/src/rest/RequestHandler.js:350:13)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (/home/ubuntu/Ares/node_modules/discord.js/src/rest/RequestHandler.js:51:14)
at async GuildBanManager.remove (/home/ubuntu/Ares/node_modules/discord.js/src/managers/GuildBanManager.js:199:5)```how to fix this error?
looks like the bot doesnt have permission to unban people
bot requires ban permissions for this right?
yeah
but i've already checked the condition if bot has or not, and if it doesn't have then it returns an error msg
well it mustnt be working properly
yeah it works, but it logs the error msg in console sometimes
well it must be coming from somewhere where you didnt check for permission
.
actually I've a command of unbanall and it unbans all the members, and in the starting of the command only, I've written that to check permissions
do you know thats where the error is coming from?
are you attempting to unban members from somewhere other than the unbanall command?
Guys any answer 🥲
then your issue is with the piece of code that you use for checking you have permission
That's because you don't await your promises and/or catch 'em
But since the error is very specific, in your case a ban/unban case it shouldn't be hard to find the related code
i do them vro, in the unbanall case also I've done that in try-catch block
message.guild.bans.fetch().then((bans) => {
if (bans.size == 0) {
return message.channel.send({ embeds: [new MessageEmbed().setColor(client.color).setDescription(`${client.emoji.cross} | There is no one banned in this server.`)] });
} else {
let i = 0;
bans.forEach((ban) => {
try {
message.guild.members.unban(ban.user.id);
} catch (err) {
console.log(null);
}
i++;
});
message.channel.send({ embeds: [new MessageEmbed().setColor(client.color).setDescription(`${client.emoji.tick} | Successfully *Unbanned* \`${i}\` users from the server.`)] })
}
}```
console.log(null); is what u catch
Also fetching the bans also returns a promise you don't catch
I added that now 😂 there's nothing which I've done in catch block
so should i do .catch(e => console.log(e)) at the end?
Not to say that this will entirely get you rate limited
;-; then what to do
Yes, you can also do catch(console.error) or catch(console.log)
Fetch returns the collection of the banned members
yes
You are looping through it or simply use filter() on it to get all user IDs
Then unban all members by providing the user IDs all at once
Should be able to pass an array of IDs to unban
can we unban all members by passing the array?
Instead of sending the request lots of times
okay I got it
using .map() will work?
Guess unbanning each one by its own is the way then
hm
Weird but ok
Adding a catch block to the fetch method
.catch() ?
Without permissions the promise will return an error
.catch() one?
Yeah
okiz
fetch(...).then(...).catch()
oki
Couldn't you also just do a quick check at the beginning of the code block to see if the permission is given to the bot in the guild and if not return an error message.
Also you aren't awaiting your confirmation message which can also fail
Imagine if 100 unbans would happen, then 100 messages would be send
Which is api spam
So send one message
it sends after everyone;s unbanned
Ah right this is a unban all command not a unban one
see this
after loop ends, it sends
Ah
Well mobile code block suck
Yeah saw it now
Still another not awaited promise
send() returns a promise
Once sending the message fails you will see an error and will never know where it comes from
Yes he also needs to do this
if (message.guild.me.hasPermission(["BAN_MEMBERS"]))
Fetch can fail regardless
I believe is the correct code.
Hate discord versions.
sigh
Well assuming it's v13
if (message.guild.me.hasPermission(["BAN_MEMBERS"])) return message.channel.send("Bot can't unban users due to missing permissions!")
//no point in running the rest if permission is not present with the bot.
message.guild.bans.fetch().then((bans) => {
if (bans.size == 0) {
return message.channel.send({ embeds: [new MessageEmbed().setColor(client.color).setDescription(`${client.emoji.cross} | There is no one banned in this server.`)] });
} else {
let i = 0;
bans.forEach((ban) => {
try {
message.guild.members.unban(ban.user.id);
} catch (err) {
console.log(null);
}
i++;
});
message.channel.send({ embeds: [new MessageEmbed().setColor(client.color).setDescription(`${client.emoji.tick} | Successfully *Unbanned* \`${i}\` users from the server.`)] })
}
}
Is what I would do. 
Console log null?
We're through that already
Does anyone know how to recover files from a corrupted Minio instance? I've located the folder of all of the files, but they are stored as directories with xl.meta in the directory.
I've tried restarting Minio from that path, but it didn't work as everything returns AccessDenied when visited in the browser.
This is my button test command and i get this error after clicking button, plz help!
Code- https://sourceb.in/msEeSXxG9L
Error-
throw new DiscordAPIError(data, "co de" in data ? data.code: data.error, statu s, method, url, requestData);
DiscordAPIError[50035]: Invalid Form Body components[0][UNION_TYPE_CHOICES]: Value of field "type" must be one of (1,). at SequentialHandler.runRequest (/home/ runner/Test-bot/node_modules/@discordjs/res t/dist/index.js:667:15)
at processTicksAndRejections (node: inte
rnal/process/task_queues:96:5) at async SequentialHandler.queueRequest (/home/runner/Test-bot/node_modules/@disco rdjs/rest/dist/index.js:464:14)
at async REST.request (/home/runner/Tes
t-bot/node_modules/@discordjs/rest/dist/ind
ex.js:910:22)
at async InteractionWebhook.editMessage (/home/runner/Test-bot/node_modules/discor d.js/src/structures/Webhook.js:338:15)
at async ButtonInteraction.editReply (/ home/runner/Test-bot/node_modules/discord.j s/src/structures/interfaces/InteractionResp onses.js:158:17) {
requestBody: {
files: [],
json: {
content: undefined, tts: false,
nonce: undefined, embeds: [t-bot/node_modules/@discordjs/rest/dist/ind
ex.js:910:22)
at async InteractionWebhook.editMessage (/home/runner/Test-bot/node_modules/discor d.js/src/structures/Webhook.js:338:15) at async ButtonInteraction.editReply (/ home/runner/Test-bot/node_modules/discord.j s/src/structures/interfaces/InteractionResp
onses.js:158:17) {
requestBody: { files: [],
json: {
content: undefined, tts: false, nonce: undefined,
embeds:
title: 'Moderation commands description: '</kick: 0>\n</ban: 0> \n</unban:0>\n</warn: 0>', color: 3771371
}
], components: [
type: 2,
emoji: undefined```
Can anyone plz tell me what am I doing wrong?
Inside your collector when building your new buttons, you forgot to put them in an action row
Buttons always need to be inside an action row
See yourself how you did it above
can someone help me
i made slash commands and it says appliacation did not respond
no erros
bot's on.
Are u listening to the accociated event?
wtf are u talking
what
You have to listen to the gateway event INTERACTION_CREATE to receive interactions events
how to do tht
djs
13.8
replit
now say which file u think the problem mayb
interactionCreate?
That's the event you need to listen to, yes
add console.log(interaction); inside your ping command file, directly after execute(...)
And see if something gets logged on the execution
where?
there is no execute
in ping
oh reply thing?
Of course there is
async execute(client, interaction) => { console.log(interaction); ...
got em
Does anyone knows why this is not working
lemme do
alr
specify "what isn't working"
nothing got logged @boreal iron
it's not coming through as a slashcommand
I waited the hour for it to sync
but still nothing
was "receiving slash command" still logged?
The command is being red
no
yes
I mean you're just adding the loaded command file to the array... but I don't see this being registered anymore
The command files haven't been loaded then
what to do now
but when i type / it shows that /ping but when i run it,says "the appilcation-"
What you do is if(!cmd) return; which is a bad behavior
Even if no command has been found you should reply accordingly
bad behav? wtf u .
trynna say
bro that dont cause the error ryt?
The error is, no loaded command file has been found
ye
client.commands.set(...) and not client.slashCommands
The property is called commands not slashCommands
so change the command to slash
inside your event listener edit client.slashCommands.get(...) to client.commands.get(...)
is slashCommands still your defined array?
on this screenshot it's different
than on this one
When reading your command files, you will have to save the commands into an array, since you wanna register 'em later on
?
the var slashCommands is only available inside your readdirsync
If you wanna make it accessible outside, define it outside
const slashCommands = [];
readdirSync...
Hi, anyone if have answer to my question, please mention me
There's no advice
It depends on your project, scale, how you implemented it and use it... etc
There's generally nothing wrong with using both
I enhanced everything in project
Not sure how GraphQL will even be able to help you for that
The problem in Response. It take maybe 800-3000ms to send responses
And that's my point
Now i have 36 row in table and with cache it take this time
Do u want to see example for one row
A common database query should only take about a few ms
This is my stack Prisma with PostgreSQL Provider Express and Typescript
Is it even necessary for you to use redis?
I use it
Do you cache database results or ...?
This benchmarks with redis
When the project will be open publish for all it will have a lot of data
Because it is SaaS App
Hmm I'm missing the experience with redis to help you with it
Might just be wrongly configured
For now I use memory Cache with redis
But i will use the redis server after finish the work on it
where is the redis server hosted? in the same vps as your app?
and your pgsql, where is it hosted?
Hi Tim, Yes in the same server
Pgsql hosted by Supabase for testing only
do some performance tests inside your code to see which parts are slow, its possible that the slowness is caused by the database being hosted far away from your server
I do it
All delay come from getting data of all orders
In database
how many db queries do you have on each request?
make a PLAN query to see where it's being slow
and make sure u have primary keys on all tables
what?
also, is 800-3000ms what you measure in your code, or is it the browser request time?
All tables have primary key
like, run a plan query, it'll output detailed data of time taken on each step
I use Postman
For api Testing
is 800-3000 what postman says?
measure the time inside your code, from request receive to response send
csv 
run a plan query, again, as I said
sql has tools for finding slow steps, no reason not to use them
Sorry but i can't understand all what are you write in every time because my lang not so cool
nobody really understands the Java dude
im convinced the problem is not the query itself
when you receive a request, do you access the db how many times?
3 times 
First and Second in Auth Middleware and Third in router
But it's not take a lot of time in other routes it take maybe 700ms in maximum
it takes a lot of time because the db is hosted in another server
so each db request is ~200ms
It can take a lot of time when resolving hostnames instead of using an IP
Which is a known issue
if the db was hosted on the same server, the requests should be like 1-10ms
I use localhost
err Wut
then the time you see in postman still has your network delay of your own internet
How can it be an external database then when using localhost?
I mean Redis
So an hostname not an IP
Yep
Yeah not much to expect then
definitely a limited bandwidth then
Idk if i will use GraphQL because after 2 or 3 months the orders will be so much
it will not make a difference
you need to reduce the distance between your app and your db
What u should do is hosting the database yourself
you could try to compress the query results as much as possible, to reduce data size
like, remove all but the essential fields
All fields are important 🥲
well, you could also use a cache layer to reduce database calls as much as possible
I want to remove a lot of things but every order have a products and more things
So i can't delete it
That won't fix the issue of the slow calls
If you wanna have a performant database you will have to pay for a server hosting it on
For example anyuser can buy a 100 different products
And that means in order query are 100 product
yes, but it'll reduce the external database calls
which will reduce overall slowness
And every product have Id, image, price and quantity*
you can use a single query to get all products
it'll ofc come at the cost of memory usage, so you'll need to balance performance x usage
Then go for your exam first
I study hard for it but I have one subject. I didn't read it. It say write 200-230 words on this topic: "Cigarettes Advertising should be illegal" 😅
aren't they?
or you could makee one query per entry 
yes, specially with a remote db and an async loop
with one query at a time
:^)
Yea
Better yet
Just do one query per column in the entry for every entry
This would make things 10x faster
Drive off a bridge

How much time do you have to wait until voting for a bot again?
12h
Wtf where
Show me
Can’t believe Pokemon ending 😭
Yooooooo
hi, not a problem but if anyone can look into my code and give any advice
it works fine just feels bad
its a command handler in js
https://hastebin.com/arosuvalos.js
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
first, never ever use var
always either let or const
whats wrong with var?
var is a relic of the past that's kept on js for the sake of backwards compatibility
that variable definition is know to cause many memory leak issues, and it's hoisted
which means sometimes it might not hold the value u expect it to
ah didnt know that, used to var from c# lol
it just feels better idk
another thing u can do is save commands[cmd] to a variable
so you don't have to access the array 3 times
the last thing would be making a proper command manager
like, without resorting to arrays/objects
also may I ask, why did u make a bot with js and not c#?
it's somewhat a downgrade
its just easier and i didnt have a vps before
thinking of converting it to c# over time
hey
i have created this sql program
await db.query(sql`ALTER TABLE serverdatabase DROP CONSTRAINT id;
UPDATE TABLE serverdatabase
SET status = 'enabled', admin = ${interaction.member.id}
, date = ${ cDay + "/" + cMonth + "/" + cYear},
level = ${level}, unverified = ${unverified_role}',
verified = ${verified_role}, pending = ${pending_role},
timezone = ${timezone};
ALTER TABLE serverdatabase ADD CONSTRAINT id;
`)``` however it returns me the error that there's a syntax error near constraint. Why?
Hey hey! I'm wanting to replace every letter of a word with _. Example: "Hello" = "_____". How would i do this?
just check the length of the message and use a for loop to create a string containing only _
execute individual queries instead
you could try regex
like
"hello".replace(/[a-zA-Z]/g, '_')
``` ?
see if the syntax is correct on the docs
yep, "normal" sql varies from database to database
the language is the same, but not all features might exist
what is that thing
u update the reply
is it interaction.update
or interaction.updateReply
or what is it
djs version?
I've not really done embed editing, you may need to set fields to an empty array?
const img = message.author.displayAvatarURL();
let level = user.level + 1;
let flitered = await model.find({}).sort({ xp: -1 }).limit(10);
let sorted = flitered.map((x) => x.xp).sort((a, b) => b - a);
let rank = sorted.splice(0, message.guild.memberCount);
let rankIndex = rank.indexOf(user.xp) + 1;
const userrank = new canvacord.Rank()
.setAvatar(img)
.setCurrentXP(user.xp)
.setRequiredXP(level * 50)
.setStatus("online")
.setLevel(user.level)
.setRank(rankIndex)
.setProgressBar("#FFFFFF", "COLOR")
.setUsername(message.author.username)
.setDiscriminator(message.author.discriminator);
userrank.build().then((data) => {
const attachment = new AttachmentBuilder(data, { name: "RankCard.png" });
message.reply({ files: [attachment] });
});
I made a simple rank command, but I'm wondering how I can make it so if I do !rank @mention it will show the mentioned users rank.
Id look at using message.mentions
https://discord.js.org/#/docs/discord.js/main/class/Message?scrollTo=mentions
and just getting the first mentioned user.
ah, thanks!
maybe ill give it a try
no work :(
Are embeds editable in the way you're trying to edit them? 🤔
as far as i know yes, it just overwrites the previous content
which is why i have to specify an empty array in the components
weirdly enough it IS editing it properly, but its erroring for whatever reason
figured it out, my messageUpdate logger was trying to fill a field with message content
👀 sus logger
its a moderation bot what do u expect
i have very low experience on writing TypeScript typings, so can anyone find an issue with this: ```ts
type DecancerFunction = (rawInput: string) => string;
export default interface Decancer extends DecancerFunction {
contains: (decancered: string, noNoWord: string) => boolean;
}
suppose the library exports:
```js
module.exports = Object.assign((rawInput) => { ... }, {
contains: (decancered, noNoWord) => { ... }
})
the error (on VSCode): ```
This expression is not callable.
Type 'typeof import("path/to/the/typings")' has no call signatures.
cc @earnest phoenix or tim
hello, so my test script (can be found here: https://github.com/User319183/Cookie-Clicker-Script/blob/main/script.js) works when pasting it into the console, but it doesn't work when pasting it into Tampermonkey. For those that don't know, tampermonkey is a browser extension where you can inject code and it auto-injects itself when your on the respected page
After doing some testing, the script and alerts load, but the functions of giving cookies and saving cookies don't load
But, the code in that link works when pasting it into the console
Lmk if anyone knows why^
Problem "outdating is this wrong command? but that update that new command. but that's not kick , etc (but removed)
how is solution?
bro what u just said
couldn't even understand
anyways can u help me out as u also wrking with slash commands
One of your commands is likely missing an execute function
only have one slash comand rn
want see it code to get the error>
?*
@wheat mesa ?
poor waffle
now a new error
Well thats not the entire error
application did not respond
Whats the full error
.
That isn't helpful
so i made slashcommands,it got registered
but when i run the only slash command i have rn
it says
appilcation did not respond
Thats not what your screenshot from a few seconds ago said
ye made some changes i thought would be helpful
Another tip: don't copy paste code that you don't understand
😔
i understand codes
try it and see
see what
but if you did you wouldn't be here :p
anything wrong in slashcommand handler or interactionCreate file?
Try it and see
bro?
What
u trynna say?
You trying to do shit yourself?
Im not going to stare at that screenshot looking for issues
const slashCommand = client.slashCommands.get(interaction.commandName);
if(!slashCommand) return;
try {
await slashCommand.execute(client, interaction)
} catch(err) {
if(err) console.log(err)
await interaction.reply({content: "A Error Occured!", ephemeral: true})
}
})```
Try it and see if it works
it dont man
in line 1,should it be commands.get or its fine now
Idk what it should be
no fkin errors rn
it just says "the appilication did not respond"
Is client.slashCommands a collection?
according to this,yes
Slow your roll bud, don't get all pissy at me cause you copied some code from the internet and now you can't get it to work
Maybe learn coding
i alr know the bsics
yea sure
I can't help you with nothing to go off of
i told u all erros
there could be a dozen things wrong and all you're giving me is it don't work
Are you sure the cmd exists in the collection?
ye
Have you actually checked?
:bruh:
Also have you checked if your command execute body even gets ran?
when i run it
it says the error
Yes but that error is literally useless here
All it means is that you didn't reply/do something to the interaction
ok here
i made this to commands.get
and now it says
slashCommand.execute is not a function
because there is no execute function attached to slashCommand variable
which means whatever .get returned has no execute func
How can i disable the buttons if no one uses it for some time.
Plz tell!
Here's my button test command code- https://sourceb.in/DfAgp2pfw1
Repeat explain: this problem did not work command bar does not appear worked 3 command.
Example add hello and then it appears "/hello" is not there, I don't see how to solve it?
make execute command 
i alr have it
well does your slash command have execute?
show your code
here

lemme see wait
k
aha
looks like your error comes from reading dir
becuase your path is /slashCommands/command.js
you read /slashCommands/${dir}/command.js
probably, dir is a file in this case
ye.
