Is this a good idea? https://www.npmjs.com/package/simple-mongodb-wrapper
#development
1 messages Ā· Page 1981 of 1
There's no point
The mongoDB node.js driver is simple
that package basically renames some of the methods, that's all it does
Good for learning about how mongo actually works but don't release it as a package
its not mine I just asked if I should use it
u shouldn't
let fetched = { user: "TuranGe" };
let user = fetched.user
[ERR]: Cannot read properties of undefined (reading 'user')
```š¤ š¤Ø
š
can you give more context
oh ok i solved the problem
When I send an object to the website, I can't get its content
but when I send the content of the object there is no problem
@wheat mesa
We talked about the placeholder for text input fields yesterday
There actually is a pre-filled value available
value? string a pre-filled value for this component, max 4000 characters
Which will be send with modal intertaction if the user doesn't change it
Oh nice
Does anyone know how to use Forms or file upload commands with discord.js yet?
just use detritus
just do fetch requests to discord api ez
Omg Discord... I had a user complaining they couldn't interact with a button on a command because they kept getting an "Invalid Form Body" every time they clicked it. It was working for everyone else which was weird and I wasn't getting anything in my logs. Turns out his app was out of date. Discord released slash commands how long ago now? And they're still not working for everyone. I'm glad my bot's got message intent because interactions still seem half-baked and not at all ready to be the sole point of interaction with bots from April onwards.
4head
err what
DiscordAPIError: 404: Not Found
is the modal ressource only available on v10?
Donāt think so
Afaik detritus is still on v9 and it works for me
Iād test but Iām on mobile atm
All slash commands were broken for me yesterday

Also this feature tho 
oo
I mean, I don't mind and I think it's cool they have new features, but when they introduce them and then break them for older versions in app updates, it's not cool. Now on top of debugging our code we have to debug people's @everyone perms for slash commands to show correctly in their server and make sure the user's app is up to date!
I'm all for new features, but this adds on a load more work for devs and their support teams.
why the fuck does the API returns DiscordAPIError: 404: Not Found then
Checked my code once again, I don't see any issue
i mean its not really discords fault for breaking their old client aka adding breaking changes
because they have to
But they force people to use slash commands
yea thats unfair
they didnt even finish slash commands and they are still forcing ppl to use slash commands
Yeah it's not even just slash commands. It's interaction types in general. In this case above it was a button, not even a slash command.
yea that too
My point is they're forcing everyone to switch to using interactions whilst making breaking changes to their apps.
i mean an old version of an app will break
its not like itll work forever
return to skype
They're not that old though which is why it's kinda worrying 
ah 
did you work with modals already? do they require the v10 api endpoint?
but a user should update their app though
i use discord mobile canary and i update it everytime hoping id get something pog
Not like I need forms anyways
but one time tho
it was disaster (idk if it was beta or not)
Yeah I agree, but in the real world that's not how 90% of users use their phone unfortunately for us 
dunno why semver major for just forms/non breaking changes ā ļø
theoretically, switching to v10 should just be a ver bump you can do manually and easily
And then we get people in our support servers saying "bot's broken" and we can't figure it out until we realise the only answer to give them is "it's not the bot, discord's broken" 
just make an faq and direct them to there kekw
š ±ļøot š ±ļøroke
Like anyone wants to read that
I swear I actually need to do a pinned message now in my server and they're all how to debug Discord interaction issues.
responding to interactions via rest helps you know wtf is going on
ffs I have literally no time to figure that out
im not excited to update SnowTransfer or CloudStorm to v10 or the upcoming changes I'll need to reflect
<script>
let asd = { username: response.user.username, avatar: response.user.avatar, bot: response.user.bot }
console.log(asd) // { username: response.user.username, avatar: response.user.avatar, bot: response.user.bot }
console.log(asd.username) // response.user.username
console.log(typeof asd) // object
console.log(typeof asd.username) // string
</script>
...
<div>
{ asd } <!-- { username: response.user.username, avatar: response.user.avatar, bot: response.user.bot } -->
{ asd.username } <!-- Cannot read properties of undefined (reading 'username') -->
</div>
```š¤ š¤Ø
Because thatās not how html works...?
that's vuejs or some template language
I would assume so but on the off chance it isnāt
hey waffle can you check if your interaction callback goes to the v9 api endpoint?
major respect for not using a framework for a website
I still don't get why I get a 404 API error
Iām not home atm
then go home, now!
why do you fucking play with your phone then, when being in school?
how is it possible nobody knows if the fucking modals require the v10 api endpoint
It probably doesn't
probably
Discord nor anyone else mentioned it in the announcement on GitHub
š¤¦āāļø
ok, why does the API then return 404 for the interaction callback post?
the data structure should be right, if im not wrong
I'm responding to a slash command
Assuming the dot notation follows the API url structure, wouldn't it be .api.interactions rather than .api.applications
err lemme check
"https://discord.com/api/v8/interactions/<interaction_id>/<interaction_token>/callback"
lol oops
stupid fake
Got ya
Also does discord.js really let the you specify the name of the type like that
It being a low level API I thought it would require the integers
Which is 5 if I remember correctly
Nope the API also accepts the name instead of the value
ok nvm I was wrong
djs actually accepts the names, not the API
it does convert the names to ints
DiscordAPIError: Invalid Form Body
type: Value "MODAL" is not int.

looks like they have constants for each fucking possible name
stupid fake²
the api always uses numbers
discord.js tries to abstract that away
Cuz imagine having to remember the correct numbers each time
yeah figured it out already :D
I'm using Svelte
Definitely
Itās true
Why do you play with your phone while driving then 
Because why not? I dont need to listen to a teacher smh
But you need to listen for the upcoming sirens and $10k bill
Same reason
who says it's illegal over here?
You're trying to get yourself killed run over
tf... I'm not listening to loud music, just dont watch the mirrors and ignore that road
how is it my fault if some idiot is running in front of my car?
Lol
I use my phone in class because thereās a distinct lack of content that I actually need to pay attention to
For classes like math and physics I pay attention because those have new concepts to teach all the time
Whereas all my English classes in school are all fundamentally the same thing as the previous years
Theyāre easy and imo pretty much pointless at a certain point
Somehow probably about 60% of my English class is failing
turns out djs doesn't even show the base interaction for a modal interaction
[INTERACTION] Received interaction with unknown type: 5
@boreal iron this is what detritus uses for responding with a modal
ya modal is just missing in the current djs build
not an issue for me
to use the int then
Reason #173648928273 to not use djs 
LISTEN TO YOUR FUCKING TEACHER
this guild invited my bot too it is bad or good?
damn
did i just reply to an old msg š
nvm its not old
can i add in mongodb? like if the value was 5, and i add 2 more, it'll be 7
idk they didn't seem to want to crash my bot, at least not yet
but i left it anyway

xD
Yeah thatās a discord thing
It caches the leave for up to 2 months
...what?
nice
const browser = await puppeteer.launch()
const page = await browser.newPage()
await page.setViewport({
width: 1600,
height: 1200,
deviceScaleFactor: 1,
});
await page.goto(link)
const buffer = await page.screenshot({ path: `img.jpg` })
sleep(1000)
let originalImage = 'img.jpg';
let outputImage = 'img2.jpg';
sharp(originalImage).extract({ width: 130, height: 62, left: 40, top: 210 }).toFile(outputImage)
.then(function(new_file_info) {
console.log("Immagine ritagliata");
})
.catch(function(err) {
console.log("Errore");
});
ReadText('./img2.jpg').then(text => {
const embed = new Discord.MessageEmbed()
.setTitle("Journaling")
.setDescription(`Link: ${link}\nEntry: ${entrata}\nRisk: ${risk}%\nSL: ${stop_loss}\nTP: ${take_profit}\nRR: ${rr}\nPair: ${text.split(",")[0]}`)
interaction.reply({ embeds: [embed] })
}).catch(err => {
console.log(err);
}).then(function(deletefiles){
fs.unlink('./img2.jpg', function (err) {
if (err) throw err;
});
fs.unlink('./img.jpg', function (err) {
if (err) throw err;
});
})
}
}```
it works 1 time, but at the second time it creates the file so late, so in tries to read it before creating it... can anyone help?
Please reply with MENTIONING on, so I can read the answer, thank you
You're mixing async/await and .then, just use one or the other.
You need to await the call to sharp so the code after it runs after the image has been saved to the file
Also, you should probably await sleep, too.
I can imagine how that function looks like
function sleep(b) {
const a = new Date().getTime(), c = a + b;
while (new Date().getTime() < c);
}```
big brain
wtf
saw some code in my cs class on par with that
except they used for and just looped for a very long time
Seems like something tim would do
@_@
ah yes. Pause the whole thread
Is there a way to make a GET request with a body in ReactJS/NextJS??
with axios you can make get request with body?
that would be absolutely bs but I hope it works xD
thanks man
Anyone know python that can help me
Well Ik a little bit of python and Iām trying to make a help command but when I do everything it gives a error and says discord.ext.commands.errors.CommandRegistrationError: The command help is already an existing command or alias
Even tho when I click Ctrl f and type help nothing shows up
Did you create your own help command?
If so, you probably didn't unregister the one your library has built-in
client.remove_command(ācommand-you-want-to-removeā)
Isn't there an option on the constructor for this as well
I did that and still same thing
No I didnāt itās the built in help command I think
Did you replace the ācommand-you-want-to-replaceā bit
Yh
Uh kinda canāt do that bc itās something thatās against tos for some stupid reason
What, your bots purpose?
Yes
What is itās purpose?
Even tho itās a private bot lmao
We kinda canāt help without any context
What does it do thatās against ToS..?
^
if you dont share any private infos it is not againsts tos
also i think there is a method to remove the default help cmd
I already sent
That... is not how it works
Itās a private Roblox cookie checker bc I use it a lot bc my cookie keeps going dead so I need to know when itās dead bc I flip limiteds and stuff so yk
Huh
Against roblox and discord tos but ok
And I use websites were u use ur cookie to log in
Yeah thatās sus
Oh
Itās private tho
Well then Iām afraid you wonāt get help with that here :p
The point is that it still violates ToS
And this server doesnāt help with that kind of thing
Roblox have said itās not against tos tho on Twitter to use rbxflip bc alot of ppl were asking about it
using cookie to login is against roblox tos
And that
no i thought he is talking abt sharing the code here not abt what the bot functions
And using discord to violate any other companyās ToS is against discordās ToS as well
@wheat mesa
So.. after doing some tests I ended up not to use modals.
The (bot) config command contains the choices for the features you wanna edit, like nickname, channels etc.
The next argument would need to be dynamic as the nickname is a string and the channel selection the, guess, channel type
I thought I could solve this with by displaying different modal components depending on the option choice but it only supports text input, not even a fucking channel or user selection
I mean wtf is that trash
And going to validate your text input to check if it actually matches or channel, user etc. isnāt an option
What a waste of time tho
how do I fetch last 10 messages of a channel id?
What library are you using
djs
You can use
const x = req.body?.x || req.query?.x;
Use <Channel>.messages.fetch({ limit: 10 }): https://discord.js.org/#/docs/discord.js/stable/class/MessageManager?scrollTo=fetch
You could also look in the .cache for the .first(10)
Or the .last(10)
whats the difference in cache?
Cache will look for what your bot has stored in memory
Assuming you have the message intent
When you build like a ReactJS app or a NextJS app (npm run build OR next build), are they also removing all system errors and things like Fetch finished loading: <FetchURL> etc.? Or what's really happening?
is there a limit on how much I can fetch?
Up to 100 at a time
do this normally return undefnined when there is no messages in a channel?
Yes, because a client is not associated with a channel.
Just like how you as a user aren't associated with a specific channel, like #development.
What channel do you want to get? The current channel?
e.g. message.channel
oh wait im dumb
forgot to fetch the actual channel
how can I tell if there is a specific string inside a message?
m.content.includes(userInfo.uid)
```this is what I have but TypeError: Cannot read properties of undefined (reading 'includes')
cannot read property x of undefined means you're trying to get the value of a property under undefined
In this case, m.content returns undefined, so you can't do .content.includes(...)
You'll need to fix that first
probably by figuring out what m is
for (const m of mList) {
console.log(m);
if (m.content.includes(userInfo.uid)) {
m.delete();
}
}
still don't know what m is
m is an object inside a map
does it have content?
yep
Try checking if the content also exists
if(m.content && m.content.includes(..)) {
wait, mList is actually the fetched 50 last messages.
it could be that im not iterating them properly
<Channel>.messages.fetch() returns Collection, try
for (const m of mList.values()) {}
^^
m is probably [string, Message] and not Message as you think it is
it works, but dont know why. why?
interface TestObj {
content: string;
}
const a = new Map<string, TestObj>();
a.set('message1', {content: 'test'});
a.set('message2', {content: 'test2'});
for(const m of a) {
// Not allowed: m is [string, TestObj]
console.log(m.content);
}
for(const m of a.values()) {
// Allowed: m is TestObj
console.log(m.content)
}
does .values() work in any key value object?
.values() returns an iterator of all the values in the map
does it only work in maps?
maps, things that extend maps, etc
depends on the implementation
discord's Collection class is just an extension of Maps
so it works the same
^this
you could also do something like ```ts
for(const m in a) {
console.log(a.get(m)?.content);
}
for(let [, m] in a) {
m
}
you don't need the key for that implementation so it's better to just use values
@boreal iron not sure if you ever figured out your issue but detritus is definitely still on v9
and modals work just fine
m would be [K, V] in this case
Yeah I was⦠errr⦠just stupid
How do I start when author used a command then the bot will dm the author?
I only know dm-ing the user using ?dm @user <message>
nvm
xD
That's...that's a specific bot command sir
lmao, i thought when a user used any command, the bot will dm
That's mee6
^
I used message.author.send('message') to send dm to its author
Wait you're seriously dming the user on every command?
Only for voting
Understandable, hava good day

Hi @remote shell
I submitted a bot on Top.gg, but I can't see the website page in my bot intro-overview
Can someone help me with this please
Tf you just pinged a random dude
that's a war crime
You probably didn't wait for approval, bots are only public after approved and indexed
@lyric mountain thank you The problem is solved
Another question I want another person to help me maintain the information in top.gg but don't know how to change the bot manager
const jokes = require("./jokes.json");
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
exclude_tags_default = ["sex"];
const getRandomJokeWithTag = async (
tag,
options = {
exclude_tags: exclude_tags_default,
}
) => {
var jokesWithTag = getAllJokesWithTag(tag);
const exclude_tags = options["exclude_tags"]; // Get a random integer between min and max
const idx = getRandomInt(min, max);
// Get a random Joke
let joke = jokes[idx];
// Declare flagged as a variable to be used in the loop
let flagged = 0;
for (let i = 0; i < exclude_tags.length; i++) {
if (joke.tags.indexOf(exclude_tags[i]) > -1) {
flagged = 1;
}
}
if (flagged === 0) {
return joke;
}
}
if (joke.tags.indexOf(exclude_tags[i]) > -1) {
^
TypeError: Cannot read property 'tags' of undefined
joke is undefined
the errors says
My whole code: https://www.toptal.com/developers/hastebin/irijosamoz.js
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
mongo db schema not delete after 10 sec
const { Schema, model } = require("mongoose");
module.exports = model(
"history",
new Schema({
userId: { type: String },
tracks: { type: Array, expireAfterSeconds: 10 }
},
)
);
can anyone help me
prob it's expires instead https://stackoverflow.com/questions/14597241/setting-expiry-time-for-a-collection-in-mongodb-using-mongoose
What is this supposed to mean
i means the file jokes.ts does not export anything named getRandomJoke
you can't store an array directly in json
lel rly
const { jokes } = require("jokes.json");
ytho
it is working for me now
all I was doing was
function({
shit1:,
shit2:
})
waste of bytes :^)
but i had to do
function(shit1,{
shit2
})
I guess nextjs was just really cringe for not letting me store an array in json
thats a lot of shit
I know
tim you won't believe how replit decided to write their css in jsx
wot
yep
huehuehue
they downgraded from actual css to this monstrosity
isnt modular css a thing tho? like react is split into modules/components, and each component has its own self contained css?
well i go sleep kthxbai
No, no you gotta wake up now and do some work!
And earn some cash, Tim
You said youāre poor, since sleeping is a waste of time and money, you not gonna sleep anymore
Why do you think Iām working around the clock? 
bitcoin mining how would you do that
just having a patreon lmao
Or you have a product u made urself with a subscription based service
Then you wake up and remember how reality actually is
yes
solana or cakeswap staking
So I plan on making something so a user can run a command in a channel and in that channel it will send an image every hour. Now I know I should use setInterval but I obv will need to save those intervals so if the bot goes down it can rerun em (which is my issue here). Also if i set an interval in the command once the command is finished executing will it still keep sending those images in that channel
SCREENSHOT NFT EVERY HOUR?????
It isn't an nft
He was joking
it is ur house's location on a map
Ik
Screenshot the precise location of you every hour 
lol people are concerned about privacy but share their whole life on social media services
True true
"I don't want to tell you in what country I am"
Also them: shares selfies from their school
Yes
Thatās how the world is
googleā¢ļø
What does android have to do with this though?
Owned by Google, Google collects data
Oh you think you can disable tracking in Android completely without routing the device?
"haha lemme disable location access
"
Isn't the OS open-source š¤
You canāt even disable simple tracking without getting spammed with errors or warning Android or installed apps wonāt work any longer
Phones using the OS could do that, but the OS in itself most likely doesn't since it's open source
Still am sure that Google's applications collect stuff that are "essential for usage"
Try to remove googles key apps or disable them
Itās an endless story of things you canāt do
At least not possible without rooting and removing them
But that will essentially make the android system unusable without sideloading stuff
Is micro-G open source?
Even if the base Android is open source is completely dislike the permissions structure
And how everyone is forced to use googles key services
Hmmm... I'm not sure if Android comes with google or if most manufacturers put google on it
Don't Huawawei phones use the Android OS? And they've banned google apps
Huawei
Ok which devices comes without the google services and apps? Except those manufacturers who are banned by the US
manufacturers prolly put google on it for the $$
Donāt need to join that sad team
I actually used Android for quite a while and got rid of it really fast
I also donāt refer to things which manufactures collect silently and hidden but Iām speaking about the stuff you as user actually can control
What phone are u using then
Well iOS of course as it allows to disable any sort of tracking without exceptions
(except the stuff which happens silently and hidden as I already mentioned)
š¤ ok then
It's ironic cause Apple is very restricting and they're more likely to track you
If you'd want more control you'd surely go with Android?
Thatās correct but the difference is the company doesnāt sell your data to third parties as they need it themselves as nr 1 global player
how do you know that. Apple is much worse than Google
such a scummy company
We talked about this yesterday
In which way apple, their ecosystem, their devices or their user data got compromised or leaked the last years?
As I said Iām not talking about the telemetry data any manufacturer collects
Also the iOS permission system allows a completely separate allow/deny permission structure for any access needed
Back when I used Android you had to allow all access when downloading the app from the App Store
Apple doesnāt allow that
When did u last use Android
Not to mention the App Store in general, the restrictions and safety
Well nowadays then
Ok and you can disable tracking on the system level, when enabling wlan, for your mobile cell etc.?
Can you do that with Apple?
Yes of course
iOS
Lemme grab an image in a readable language
I don't know but how can u be sure Apple respects that?
how do I turn fetched messages into an array?
The difference between iOS and Android is that Android is "general purpose" you could say, anyone could build it and use it, iOS is made specifically for Apple phones. Therefore Apple can put whatever spyware they could in their iOS, and the data would go tooooo... Apple.
And you can't do anything about it
console.log(typeof mList);``` returns `object`
That might be true and actually is the case as Snowden already told us but still doesnāt change the fact about the user controllable telemetry and tracking settings you canāt adjust on Android on the system level
And I can at least see and check the traffic and the tracking (location) and will see it comes to a minimum (or to null) after disabling all of them
I haven't dabbled into it, mostly because I disable location all my apps
And apps canāt overwrite the system level settings also you canāt accidentally enable it for app
Yeah and I disabled it for my entire system, thatās the difference
The system not
Any google service is tracking you by default
To āimproveā their services
Even if you donāt use the app
Like I said try disable the default google services on your android device
Itās not possible without routing the device
And yes the fact doesnāt let anybody else take a look into their ecosystem is problematic, too
No doubts on that one
how can I search for fetched messages for a string?
using .filter()?
.find()? .map()?
one message = find(), multiple = filter()
would .find() work if the message containing the string has other contents than the string?
I think it only works for exact values
That depends on your statement (expression)
find((a) => a.includes("b"))
As example
filter((a) => a.includes("b")) // returns multiple items which include b
@boreal iron then when should I use map()?
isnt it the same as filter()?
or is it completely different
filter returns a collection iirc, map of course an array
(if you refer to djs collections)
If you wanna have an array as result
m.content.match(`/(${pids.join("|")})/`)
// /(2e565cdec9dcdff44afa2b1ea71c2c2c|34482dc7c754a30aba97065d165b1b38|703aea31975f2fa45fdb3e4a8e378ad1|1789250aaf0335d750de2acf2faa707d|5737cbbf29e7e1bde4520253e920cc26|9aa92dce525591ed890cf7869cd62900)/
why when I match my string for a regex, it returns null. But when I test it in https://www.regextester.com/, it finds the string.
Why are you using regex for this?
because the message contains more content than the actual string, and I have multiple pids...
for (const pid of pids) {
if (string.contains(pid)) {
//...
}
}
I also have multiple messages to test
that's one way to do it without regex
is a loop better for this?
I'd say so
why .contains()? shouldnt it be .includes()?
oop my bad yeah it's includes
i thought i have to learn something new again...
will i be able to modify pids without breaking it?
why would you want to modify it
i want to remove the pid that is already been used
You could turn the pids array to a Set so all the pids inside of it are unique
i dont need for it to be unique
Alright explain your problem in detail
i have multiple strings in an array. i also have multiple pids in an array. if a string has pid, i want pid to be deleted, so in case if another string has the same pid, the string will get deleted. those two strings are not identical.
store the deleted pids in a Set
check if a pid is in the set, if it is then you've seen it already, delete the string or whatever
how will i know what pid it is. the strings contain more than the pid
const deleted = new Set();
for (const pid of pids) {
if (string.contains(pid)) {
// string contains deleted pid.
if (deleted.has(pid)) {
//...
} else {
//... do something
deleted.add(pid);
}
}
}
that might actually work. thanks!
string.includes()*
Can u tell me how? Cuz i tryed but it gave errore
how did ya try?
atm i am not at home, when I'll get home I'll send
Is there any way to get the announcement channel to be followed in Discord JS by the bot.
what announcement channel?
if it's discord's, you can simply monitor the message event
like this we want user can follow this channel if they want by bot command
but some bots doing this
how?
lmao contains()
Second time in a row 
Youāre officially getting old Sir
const browser = await puppeteer.launch()
const page = await browser.newPage()
await page.setViewport({
width: 1600,
height: 1200,
deviceScaleFactor: 1,
});
await page.goto(link)
const buffer = await page.screenshot({ path: `img.jpg` })
await sleep(1000)
let originalImage = 'img.jpg';
let outputImage = 'img2.jpg';
await sharp(originalImage).extract({ width: 130, height: 62, left: 40, top: 210 }).toFile(outputImage)
.then(function(new_file_info) {
console.log("Immagine ritagliata");
})
.catch(function(err) {
console.log("Errore");
});
ReadText('./img2.jpg').then(text => {
const embed = new Discord.MessageEmbed()
.setTitle("Journaling")
.setDescription(`Link: ${link}\nEntry: ${entrata}\nRisk: ${risk}%\nSL: ${stop_loss}\nTP: ${take_profit}\nRR: ${rr}\nPair: ${text.split(",")[0]}`)
interaction.reply({ embeds: [embed] })
}).catch(err => {
console.log(err);
}).then(function(deletefiles){
fs.unlink('./img2.jpg', function (err) {
if (err) throw err;
});
fs.unlink('./img.jpg', function (err) {
if (err) throw err;
});
})
}
}```
and what error did you get?
worker.send(packet);
^
TypeError: Cannot read property 'send' of null
@quartz kindle
at the 2nd time executing command
the first time it works perfectly
C:\Users\Pietro\Documents\Lavoro\TradingView\node_modules\tesseract.js\src\worker\node\send.js:9
worker.send(packet);
^
TypeError: Cannot read property 'send' of null
at module.exports (C:\Users\Pietro\Documents\Lavoro\TradingView\node_modules\tesseract.js\src\worker\node\send.js:9:10)
at C:\Users\Pietro\Documents\Lavoro\TradingView\node_modules\tesseract.js\src\createWorker.js:47:7
at new Promise (<anonymous>)
at startJob (C:\Users\Pietro\Documents\Lavoro\TradingView\node_modules\tesseract.js\src\createWorker.js:43:5)
at Object.load (C:\Users\Pietro\Documents\Lavoro\TradingView\node_modules\tesseract.js\src\createWorker.js:57:5)
at C:\Users\Pietro\Documents\Lavoro\TradingView\node_modules\text-from-image\index.js:17:20
at new Promise (<anonymous>)
at ReadText (C:\Users\Pietro\Documents\Lavoro\TradingView\node_modules\text-from-image\index.js:15:16)
at Object.run (C:\Users\Pietro\Documents\Lavoro\TradingView\commands\journaling.js:93:9)
it seems like the 2nd time it tryes to read the texzt from the photo BEFORE actually creating it
is the code you showed the file journaling.js?
yes
can you show the full file?
you pobably need to await ReadText
ok lemme try
wdym
doesn't work with readtext asynced too
awaited*
fs.unlink is an async operation, your ReadText function will not wait until the file is deleted before returning
it will return first, and then delete the file in the background at the same time other code is running
so... what should I do
is the syntaxz the same?
Ready as TradingView#6185
Immagine ritagliata
Immagine ritagliata
C:\Users\Pietro\Documents\Lavoro\TradingView\node_modules\tesseract.js\src\worker\node\send.js:9
worker.send(packet);
^
TypeError: Cannot read property 'send' of null
at module.exports (C:\Users\Pietro\Documents\Lavoro\TradingView\node_modules\tesseract.js\src\worker\node\send.js:9:10)
at C:\Users\Pietro\Documents\Lavoro\TradingView\node_modules\tesseract.js\src\createWorker.js:47:7
at new Promise (<anonymous>)
at startJob (C:\Users\Pietro\Documents\Lavoro\TradingView\node_modules\tesseract.js\src\createWorker.js:43:5)
at Object.load (C:\Users\Pietro\Documents\Lavoro\TradingView\node_modules\tesseract.js\src\createWorker.js:57:5)
at C:\Users\Pietro\Documents\Lavoro\TradingView\node_modules\text-from-image\index.js:17:20
at new Promise (<anonymous>)
worker.send(packet);
^
TypeError: Cannot read property 'send' of null
at module.exports (C:\Users\Pietro\Documents\Lavoro\TradingView\node_modules\tesseract.js\src\worker\node\send.js:9:10)
at C:\Users\Pietro\Documents\Lavoro\TradingView\node_modules\tesseract.js\src\createWorker.js:47:7
at new Promise (<anonymous>)
at startJob (C:\Users\Pietro\Documents\Lavoro\TradingView\node_modules\tesseract.js\src\createWorker.js:43:5)
at Object.load (C:\Users\Pietro\Documents\Lavoro\TradingView\node_modules\tesseract.js\src\createWorker.js:57:5)
at C:\Users\Pietro\Documents\Lavoro\TradingView\node_modules\text-from-image\index.js:17:20
at new Promise (<anonymous>)
at ReadText (C:\Users\Pietro\Documents\Lavoro\TradingView\node_modules\text-from-image\index.js:15:16)
at Object.run (C:\Users\Pietro\Documents\Lavoro\TradingView\commands\journaling.js:93:15)
PS C:\Users\Pietro\Documents\Lavoro\TradingView>
the first "immagine ritagliata" it's the time when the bot works
you are not awaiting the function
you are using the function multiple times at once without waiting for it
which function should I await? I am coinfused
the function in the file journaling.js where your code is inside
I awaited readtext and sharp
it's a package made by a friend
the handler is literally this, I need to search up in the package
give me a min
I can't find out, I think I'll use the slash commands creator from discord.js guide
are you trying to use the bot command 2 times very fast?
whay do you mean by "fast"
run the command again before the previous command finished
same error
yea
meaning you are doing 2 images at once, without waiting for one to finish
no, it sends "immagine ritagliata" as the last console log of the command
it sends it 1 time on the first time doing the command
and it works
then it sends it again right before the error
on the 2nd time doing the cmd
ah
a
well apparently its an issue with the module you are using
so I need to remove part of the package
there is a fix already but not merged
the author of the package made it in a way that it can only be used once per process lol
probably meant to be used in cli
Hey @quartz kindle can I actually check if I already registered an event listener?
I have to register one in a module (temporarily) for reasons which would of course cause another registeration if the module is loaded again
I mean I could set a simple var, but maybe there's a thing I don't think of?!
it's because they use interaction webhooks instead to receive events instead of connecting to the gateway
Is that actually listed as member in the member list or did you click on his name to popup the client info?
it listed as a online member
ahh good to know, that's already a thing
how to get all users json data on discord.js?
And with that question you provided us
- no context
- no library
- no code
- no idea what data you want
- and no specifics
what
no library 
hm

aaaaaaaaaa.....just need ansš
explain your question better
i just need to store all of my guild members data (my bot is only in one server)...but i cant find a way to get all the users data
I feel like discord wouldn't want you to store everyone's data.
He edited it
i agree
im getting only bot data from client.users.cache
yea my bad
i last used d.js on v12 so idk
that's technically "all the data"
store the id, any other data just fetch from the api
im getting only the bot data
or better yet, don't store anything since it'd be pointless
GUILD_MEMBERS intent enabled?
with client.users.cache
this one?
yes, and is it also enabled during client initialization?
is it ok or have to add something?
idk about this intents stuffs.. everything looks new to me now
the one you want to enable is Intents.FLAGS.GUILD_MEMBERS
also it's quite clear you just copypasted from the docs
don't do that, take some time to understand what you're doing
else you'll become dependant of this channel
yeah.. bcs i just back to discord.js after year
ok
const guild = client.guilds.cache.get("822979643589787688");
guild.channels.cache.first()
.createInvite()
.then(invite => message.channel.send(invite.url))```
why does that not work
or am i being stupid
maybe no permission to create an invite in that channel?
TypeError: guild.channels.cache.first(...).createInvite is not a function
Channels are not just text channels iirc
ah
does someone know if there is a way to make that every new week and every new month the bot does something?
what do you mean
like
on every monday it sends a message
on every month it sends another message
@spark flint
Cron scheduler ig
why do they always ping after answering the question
Because they want a response in 2 seconds 
yes, that's definitely a task for cron
lmao
const channels = message.guild.channels.fetch().array()```
Iterate through the channels until you find the first one thatās a TextChannel
...channels.fetch().array().filter(c => c instanceof TextChannel)
or something like that
this means that
chron.schedule("1 * * * * * *", () => {}```
executes every monday?
TypeError: message.guild.channels.fetch(...).array is not a function
(await ...channels.fetch()).array().filter(...)
^ that
let channels = [];
message.guild.channels.cache.forEach(chn => {if (chn.type == "GUILD_TEXT") { channels.push(chn) }})
channels;```
that worked
?
Channels arenāt guaranteed to be cached I donāt think but yeah if it works it works
they are if youre using regular djs, since they dont support disabling channel cache
that's every 1st second each minute
Ah
God imagine fetching every single channel and caching it on startup with a massive bot
That sounds like hell
good thing nobody does that
4 hours later
the more you know the better
Give me the number of your teacher... I will call him and tell him you're a bad boy
Now!
Pffft she doesnāt care
pretty good teacher
me when the word wrap
Thereās a certain point where teachers stop caring about what you do in their class because youāre old enough to know that itās your education not theirs
when you enforce items per row instead of letting flexbox do its job
not when I was young
don't form elements automatically wrap tho
Thereās a few of my teachers that care
not if u enforce item count
Most donāt though
I'm actually so done with modals as they don't support anything other than text input, right before the feature really makes it way into discord
I can see it being way more useful in the future
only if it will support other fields
Maybe once they support dropdowns, numbers, etc
once
2030
I mean why can't they publish something after thinking of it a little bit more
is there a way to tell intellij where the source code is? /opt/ is a special directory for aws lambda layers.
also how can i tell my unit tests where the source code is. i tried this for jest
{
"jest": {
"moduleNameMapper": {
"^/opt/nodejs/(.*)$": "<rootDir>/layer/nodejs/$1"
}
}
}
right click -> copy path/reference
as for unit tests, you probably shouldn't include layer/nodejs/
like this?
now choose the proper path
i have to use /opt/ as the path. that tells aws lambda to load from the lambda layers
intellij doesn't know that, so it yellows the path as invalid
i want to tell it
alt + enter -> inspections -> suppress for statement
i'm trying to get all the refactoring tools enabled
idk if that's possible at all
it might not be
unless you connect intellij to aws
which I also don't know if it's possible
Describes how to use the AWS Toolkit for JetBrains to create an AWS Lambda function in an AWS account.
i have the plugins all setup, and i opened a ticket to see if they can add the feature
it is
https://sourceb.in/rVNHCWVv0p it logs 'test' but doesn't send the message, anyone know why?
try js const channel = await client.channels.cache.get("941750305022947331") await channel.send({ content: 'test', components: [row] })
idk
Because it doesnāt know what msg is and you never defined client
Assuming thatās your whole file
without components it works
I need to define msg cuz I need to edit the msg later
Is that snippet the only thing in your file?
I would assume not since it works without components
Do you get an error?
Because if Iām looking at these docs right it seems like addComponents() takes an array
it does not require an array
In that case Iām going to assume that guild isnāt cached, I donāt know
it's the only guild the bot is in
Do you get an error?
no
Random but
how do I restart the containers in a docker compose only if the images for them have been changed
so like I got container 1 and 2 but only the image for 2 changed
so only container 2 gets restarted
if(!category2){
po2 = await message.guild.channels.create(`COMMUNITY-MONDAY`, {
type: 'category',
permissionOverwrites: [
{id: message.guild.id, allow: ['SEND_MESSAGES']},
{id: message.guild.id, allow: ['VIEW_CHANNEL']},
{id: client.user.id, allow: ['VIEW_CHANNEL']},
{id: client.user.id, allow: ['SEND_MESSAGES']},
]
})
}``` and ```js
channel2 = await message.guild.channels.create("community-nominates", {
type: "text",
parent: po2.id,``` why is this returning me the id undefined error?
where though
the error means you're trying to do something.x when something is undefined
so where it's occurring is helpful
Help pls
oh god i've seen the same code before and don't create an invite link to the guilds your bot joins
Oh boi
sorry that was my arch nemesis
guessing sibling
Editing a non-ephemeral deferred response with an ephemeral one and vise versa still doesnāt work
Is that considered to be a bug or intentionally?
Has anyone ever said something officially about that one?
@pale vessel usually knows such weird things

i don't do weird things unlike a certain person in this channel
Idk, but itās quite annoying imo
I've already asked about this in the Discord Developers server, it doesn't work because when you defer the response to the interaction, the "thinking" state becomes the initial response to the interaction, and when you edit it, it doesn't change the response's ephemeral optionality, because you're editing a response, not creating a new one
what is this error
Invalid form Body
method: 'get',
path: '/channels/931996787953270843/messages?limit=',
code: 50035,
httpStatus: 400,
requestData: { json: undefined, files: [] }
}
?limit= is suspicious
there's supposed to be a number after the =
or there could be no reason to include the ?limit= since it'll default to 50
Yeah unfortunately I already expected that answer
But as thinking as response isnāt ephemeral, too it should be in theory to adjust it for the first response (after deferring)
Yeah, I suggested that the "thinking" state should at least be a separate placeholder instead an initial response placeholder to prevent the upstream response from taking the options the "thinking" state has, but I don't think they'll ever change that
Hmm probably not
I usually like to display the response non-ephemeral and errors as ephemeral messages
But yeah this doesnāt work
Guess I gotta do the validation first, then deferring
Or set a timeout for error messages being removed after some time
What im confused
Show the associated code to the error
you need to parse amount into a number
what u mean by that i don't get it
right now your amount variable is a string
"50" is not the same as 50
former is a string, latter is a number
ok
why does this not start š„²
because you have a dream pfp
not sure maybe you havent saved or the bot.run is blocking?
everything is saved lemme try running it before the bot or just commenting out the bot.run
lowkey worked not really
two very conflicting statements did it or did it not
Mostly yes but no i have to have a run def in class so it actually runs š
is there a method called run_async or something
i dont exactly know how python handles this stuff
there's a package called asyncio but im not really good with concurrency
yeah its a blocking call
i think you need to do something like asyncio.run(bot.run)
then it wont block
oh
dont use run
@fiery stream replace bot.run with bot.start
that way it shouldnt block
ahhh what if i user asyncio on both of the things web n bot itself
i dont know but you should use start
hmm that solved the issue
i think
maybe
no its not gonna work lel
cuz bot.run() is this def
ayyy i fixed everything š
ohh you mean change super().run to start?
yeah
lol i failed it didnt work
only one works at a time
once i control + C the other starts working
H!ping
Coding is for the weaks, I use Bot Ghost š š š
imagine not using assembly to write a discord bot

With that knowledge, soon the google ai will develope own discord bots
if (message.member.id === member.id) return message.reply("You can't put your self in timeout");
^
TypeError: Cannot read properties of undefined (reading 'id')
at Object.execute (/Users/dhruvshah/Documents/GitHub/Archer-Bot/Bot/commands/moderation/timeout.js:29:40)
at Object.execute (/Users/dhruvshah/Documents/GitHub/Archer-Bot/Bot/events/Message/messageCreate.js:45:17)
at Client.<anonymous> (/Users/dhruvshah/Documents/GitHub/Archer-Bot/Bot/Handlers/eventsHandlers.js:13:58)
at Client.emit (node:events:402:35)
at MessageCreateAction.handle (/Users/dhruvshah/Documents/GitHub/Archer-Bot/Bot/node_modules/discord.js/src/client/actions/MessageCreate.js:26:14)
at Object.module.exports [as MESSAGE_CREATE] (/Users/dhruvshah/Documents/GitHub/Archer-Bot/Bot/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/Users/dhruvshah/Documents/GitHub/Archer-Bot/Bot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:351:31)
at WebSocketShard.onPacket (/Users/dhruvshah/Documents/GitHub/Archer-Bot/Bot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
at WebSocketShard.onMessage (/Users/dhruvshah/Documents/GitHub/Archer-Bot/Bot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
at WebSocket.onMessage (/Users/dhruvshah/Documents/GitHub/Archer-Bot/Bot/node_modules/ws/lib/event-target.js:199:18
i'm so confused this is my code
https://sourceb.in/wy0VzkW0Fl
member is undefined
it is
const member =
message.mentions.members.first() ||
message.guild.members.cache.get(args[0]) ||
message.guild.members.cache.find(
(x) =>
x.user.username.toLowerCase() === args.slice(0).join(" ") ||
x.user.username === args[0]
);
It wasn't able to get a member mention from the message, get a member from the cache by user ID and get a member by their username
all of those values returned a falsy value
Not all members are cached, so be sure to check for that as well, as you might be trying to get an uncached member
I'm trying to make a suggestion bot by fetching the message ID via a button. However, I get the error that this.options.embeds?.map isn't a function. Can I not fetch the message ID of a message sent?
const suggestEmbed = new Discord.MessageEmbed()
.setColor("#99ffb3")
.setTitle("Suggestion by " + interaction.member.user.username)
.setDescription(firstResponse)
.setTimestamp();
interaction.guild.channels.cache.get("918613584672591912").send({ embeds: makeSuggest }).then((msg) => {
let msgId = msg.id;
const row = new MessageActionRow().addComponents(
new MessageButton()
.setCustomId("suggest-" + id)
.setLabel("Make a Suggestion")
.setStyle("SUCCESS")
);
msg.edit({ components: [row] });
});
What's the value of the makeSuggest variable?
Oops wrong embed
const makeSuggest = new Discord.MessageEmbed()
.setColor("#99ffb3")
.setTitle("Make a Suggestion")
.setDescription("If you wish to make a suggestion, click the button below! **Joke suggestions will get removed.**")
.setTimestamp();
OOPS
can i put this into a embed
aliases: ["avatar"],
descriptions: "Shows users profile picture",
cooldown: 5,
yes if you try hard enough
just get that object and treat it like an object
e.g. ```js
let command = ...; // figure out how to get it
send({ embeds: [{ title: ${command.name} (${command.aliases.join(", ")}) }] });
yo
how do you usually fix this?
https://cdn.discordapp.com/attachments/838416295144980550/944415701794435172/2022-02-18_21-09-51.mp4
ping in replies
how do i add text next to each other in embed
That's just plain old Markdown
You'd use ** for bold and a line break to separate the two.
how i have it
Not exactly.
The difference is you're using fields while the first image is using a single field/description with line breaks.
You could use .setDescription instead
is it possible to create a symbolic link in windows that would point to a unix type directory like /opt/nodejs/
i mean /opt/nodejs/ would point to c:\something
maybe if i run from cygwin
just play around with mklink in the command prompt
mklink /D ../.. ../..
if Iām not wrong
Aren't windows shortcuts (.lnk) essentially the same as symlinks?
i think so, but they probably require the windows style paths
It wouldn't be an issue in code since most libs parse the path to the proper format
i need to make a symlink at a system level to trick intellij, but i cant make unix links
at least i dont think so
but i should at least be able to run unit tests
Doesn't intellij understand both forms of path tho?
it understands the relative paths using ../, but not absolute paths from the root
No plugins for that?
How do I insert multiple buttons in an action row using discord.js
let row = new MessageActionRow().addComponents(new MessageButton().setCustomId(`${act.pid}_getLink`).setLabel("GET LINK").setStyle("PRIMARY"));
maybe i should just test the small functions and ignore all the integration level functions
let row = new MessageActionRow()
.addComponents(new MessageButton().setCustomId(`${act.pid}_getLink1`).setLabel("GET LINK").setStyle("PRIMARY"))
.addComponents(new MessageButton().setCustomId(`${act.pid}_getLink2`).setLabel("GET LINK").setStyle("PRIMARY"));```
custom id cannot be the same or else it will give a 4xx error
np
btw the limit for components per action row is 5
yep, ive read
but dont understand why they have to have a limit for those
wait, why didnt the setCustomId show up when I logged the button?
wait, it does show up. its just not in console when I logged it.
How should I handle sending something every x amount of time to a channel a person used a command in.
Should I use a interval?
setInterval depending on how long you want it to go on
If you want something sent every few days or something though then thereās probably a lib out there for that (not sure if cron is a good choice or not for your situation)
I was just planning on sending something every hour. Though I also want to plan for scaling so is setInterval good to be used when multiple guilds/channels will be having an interval being ran for them
Probably best to use cron
Im having a problem with my set-prefix command which is the bot not sending back the command,
I'm using slappey package to create my command, here's the code:
in my MessageEvent.js
async run(client, message, prefix) {
if (message.author.bot) return;
if (message.content.startsWith(prefix)) {
const [cmdName, ...cmdArgs] = message.content
.slice(prefix.length)
.trim()
.split(/\s+/);
const command = client.commands.get(cmdName);
if (command) {
command.run(client, message, cmdArgs);
}
}```
in my `index.js`:
```js
(async () => {
client.commands = new Map();
client.events = new Map();
let prefix;
await registerCommands(client, '../commands');
await registerEvents(client, '../events');
await client.login(process.env.DISCORD_BOT_TOKEN);
client.on('messageCreate', async message => {
const PrefixSchema = require("./prefixSchema");
let data = await PrefixSchema.findOneAndDelete({
guildID: message.guild.id
})
if(data === null) {
prefix = "?"
} else {
prefix = data.newPrefix
console.log(data.newPrefix)
}
})
})();```
Is it necessary to require the schema every single time a message is created..?
If i called the prefix outside of (async) im receiving an error such as prefix is not defined
nope lmao
Because you defined prefix in a different scope
Yea that's the point :/
wait is that 2 message events
From what it looks like your logic here is backwards
Nope
You need to check the prefix in messageCreate, and if it passes the check in messageCreate, then run the command
You donāt need to pass it to the command every single time
Thatās a waste
Also I just have a lot of questions about this
Then I should remove the event in index.js?
I think you should rethink most of your design here
Because it doesnāt really make sense... at all
^
It's in slappey package
I donāt know what that is but it still doesnāt make sense regardless
crappy bot template
None of this design makes sense
Iām not trying to shit on it but Iām just saying that I think it needs to be recreated with more planning
its supposed to be a really nice easy bot template but tbh its just horribly confusing
^
github.com/stuyy/slappey if you wanna look at it lmao
Seems like itās overcomplicating everything
yes
I only got problem with this set-prefix
but overall
i used slappey for a very short bit and hated it
its nice
I would have to disagree from looking at it
Wdym
Hm yea you're probably right
Iām saying that the design looks flawed and overcomplicated for no reason when you could just use normal djs
a bot in a single file is better
better than slappey* ||imo||
A bot in a single file is like asking to be pushed off a cliff
yes
The worst part of it is that itās easy to get lost in
Gets worse if your bot's starting to get big
yes
how long does ephemeral interactions last?
until you dismiss the message or close the app?
but the message isnt dismissable
do I have to add the ephemeral tag into the reply or to the buttons?
seems like I need to add it to the reply...
what does ephemeral do to the buttons?
wdym
wait nvm im so dumb, you cant put ephemeral in buttons
why would <Interaction>.channel_id could be undefined? coz a interaction should definitely come from a channel
you need to learn basis of English
who?
besides if you really think this is a basis thing why don't you just tell me instead of being a helpless person
bookmark to reply
im not obligated to help you, i ask you to learn the basics because it is all in the basics of python, if you know the basics then you should have your answer. I just dont want to spoonfeed small things because it tends to make people lazy and ask another simple question instead of learning abt them or searching them online.
hope you understand
firstly I know how "in" works but if you use in like
if "text" in msg.content
it will only get the msg which is sent after the bot is online
but "in" alone can't fetch old msg you stupid
and fetch is a part of discord.py which not the basic of python
laziness = not doing anything
not just asking simple question

