#development
1 messages · Page 2025 of 1
Azure cloud
To make a dirty deal
replit is quite possibly the worst service I have ever used for development in my entire life
unfortunately I am not the age of consent 🤨
As next you should recommend Oracle and Google and we got all shit covert
Damn
Could have opened a lot of doors for you
I'm using oracle for hosting my bot on a vps because they have a forever free plan that won't sneakily charge you $1000 without you knowing
SkySilk has stuff for 3 bucks a month
But it's VPS
Not sure if that's what you want
I mean would it be a bad idea to host it on my oracle vps
A free vps must be a very good one
there's no complex api or anything, just a portfolio with a few nextjs routes
Glitch!
Replit

Doesn’t look like an embed
it works outside of embeds
it doesn't
No
wtf
It shouldn’t
👀

that definitely should not be working
Instant report to discord, you’re abusing the system 
It only works on webhooks
And embeds
my bot deffo isn't a webhook 
slash commands route through webhooks
ofc
we can never be sure in here
lol
:C


I'll scare you away with java
You already did when telling me you use the oracle cloud
I use it for hosting my shitty bot
Because it's free and I never have to look back at it or worry about getting charged for going over my bandwidth limit or anything
Broke student life can't take any chances
lol
You got any open source and free project?
You could use my dirty services but that would bring us back to your pants and your age 
You can get free hosting for open source projects
In less than 2 months I will be the age of consent to be fair
lmao
I am still tempted to make an api where people can use some of my custom LavaLink nodes since I have a ton of headroom
Then use it for portfolio 
With what? I do plan to open source my portfolio webpage
Say its free and let them sign 5000 sites long tos charging cash from them
That looks promising
I'll look into that
But I'm not sure if my personal portfolio website would fall under their umbrella of good use cases of their service haha
it'll probably be a private api like weeb.sh is
but ofc people would be able to apply
Reason i asked if you have worked on some open source projects before
Hmm I see no real business man in here
True
I'm not about money or votes you know 
I mean I have a few projects on github that are open source but I don't actively contribute to them nor does anyone else
Pulling pants was better then filling 29 forms
The only legitimate project that I really have open sourced is probably this https://github.com/Jwaffled/MathExpressionParsing
Which I don't really plan on working on for a while anyways
That makes me sad, money is the one and only in the capitalism we’re all living in
I already have a job paying for everything
There’s never enough cash 
you think people would want to pay for an api of lavalink nodes other people use instead of just buying their own node
Like, who knows if they approve your request just apply
No I think you should offer it as free service, let them sign your contract and charge them after doing so 
You'd be better off with the callers trying to tell you about your car's extended warranty you never knew you had
lol
I don't fall under this umbrella unfortunately
I could still apply but I'll have to look at my other options first
Hmm
Thanks for the suggestion though
What do you actually need?
github pages?
netlify works
Thought they only did static sites though..?
I've been looking at netlify, I'll have to do a little more research on them
unless you're doing SSR, your portfolio should be static
Then github pages could work for you
Needless bro ✨
Just drop that and have a static website
then just npx next export and next.js will turn it into a static site UNLESS you have an API
Yeah on 3rd thought I think I'm using some sort of SSR, the site looks very wrong when it's exported as static
how does it look
rebuilding it rq
works... sorta
I think I'm going to just go with a host like netlify or something
I'm not done with the website yet anyways
The svg background isn't there and I'd have to refactor all my links and such so for now I'm not gonna worry about it
Refactor links?
They're not relative links, they point to routes in the url whereas it needs to point to files when it's static
I'll try fixing that rq
yeah I'll fix that later
I'm gonna take a break for a bit
been working on this a little bit too much and I don't wanna get burned out over config stuff
vercel is a good website host
Anyone knows how to solve driver state failure bluescreen? Can't find a recent guide on how to fix it
thats usually caused by a bad driver
yeah I found 3 drivers built for older windows versions do I just download the updated versions of them?
hey um, quick question. So i have a global var with Map() with some values. lets say this map has some 1k key -> value pairs. and this Map will keep getting more values over time. now my question is. If i remove certain keys at a certain time, will it cause memory leak. so far im suspecting this global var is the root of my memory leak issues im having which stores upto 10k+ props
i'd first uninstall them from the device manager then restart the pc
and see what windows does with them
should I make a backup first?
shouldnt be necessary
alright
depends on a few things
if you're storing objects, and those objects also exist elsewhere, if you delete them they will still exist elsewhere
other than that, Map uses a hash table behind the scenes, and hash tables grow by a specific amount every time the number of items reaches a certain limit
for example lets day your Map has 60 items, and the Map internally has a max size of 128, and a threshold of 80
once you reach 80 items, the Map will be internally resized to max 256
I can't find them in device manager?
so the memory usage of a Map does not only depend on the items it stores, but how big the table is as well
and usually these kinds of tables do not get smaller when items are deleted, idk how they do it in js
i was thinking the size could remain the same when i delete some of these itmes once their purpose is served
or when i no longer need them
keeping the size to a minimal constant
yeah that shouldnt be a problem
gotcha thanks, i'll try this out
Do I delete them from the Sys32 folder or is that the most retarded thing to do?
they usually belong to something that might be under a different name
for example badlionanticheat.sys is from an anti cheat software used in many games like minecraft hypixel
yeah but I doubt that's the one causing the blue screen as I haven't launched minecraft in like a year
It's the cdd or nwifi that's causing it I think
but I can't seem to find either one
nwifi is usually your wifi chip, under networks
cdd looks to be some kind of screen/display/monitor thing?
could I just update it directly using https://wikidll.com/microsoft/cdd-dll ?
Download the Cdd.dll file for free and fix Cdd.dll Missing or Was Not Found Error on Windows. A simple &free solution from WikiDll.com
no
drivers often have multiple dlls and sys files, you risk breaking it completely if you change one of them but not the others
you can try running a driver scanner software to scan for outdated drivers
like drivereasy or those craps
no those are gpus
i'll just install drivereasy
screen drivers, if they exist, should show here
most times they are not even needed tho
holy fuck like all of my drivers are out of date
show them
you dont necessarily need to update all of them
and its not always better to update them with the software
sometimes the software makes mistakes
is it a laptop or a desktop?
i would download most of them from your laptop's maker website
so asus
yeah, go to asus and look for your laptop's model number in their website and see what drivers they have there
after you install the drivers from there, you can try scanning again and see whats left
I just download all of them?
some of them are folders and I have no clue what to do with them
does anyone know how do i show the server count like in the example?
post your server count using the API
can you tell me how to do that exactly? or send a link from the exact page please?
what language is your bot
javascript
not all of them
there are different editions and different versions of the same laptop model, so they just put all the drivers together, but not all drivers are the correct ones for your specific device
for example they have drivers for both intel wifi and realtek wifi
you just need the one your laptop has
which is intel wireless
other than that, they also give you multiple versions of the same driver, so you can just download the latest one
Is there a possibility that discord.js-light is caching the results of this?
client.shard.fetchClientValues('guilds.cache.size')
@spark flint so if my bot console logs the posted stats i just gotta wait a bit right? i used the code below and puted my token too
const { AutoPoster } = require('topgg-autoposter')
const ap = AutoPoster('', client)
ap.on('posted', () => {
console.log('Posted stats to Top.gg!')
})
ok, thank you
shouldnt be possible no
there is no caching on those functions afaik
mmkay, i'll look see if i'm doing some weird caching.
i have this in a setInterval call and total is always logging as the same value on my server. only changes when i reset
try broadcasteval instead of fetchclientvalues
lmao
const results = await client.shard.broadcastEval(c => c.guilds.cache.reduce((acc, guild) => acc + 1, 0))```
this seems to work
also this
that's too simple
also, if you want to catch errors properly in that interval, either use .catch() or make it async () =>
lmao
ohh
i think i know what i was doing
my setinterval was async like this and it cached the result of the promise
but it still logged somehow
like thisjs const p = new Promise((resolve)=>{resolve(Math.random())}) setInterval(async () => { console.log(await p) }, 1000)
yeah like that you're creating 1 promise and then resolving the same promise over and over
it's weird that the console.log still happened even though it's cached
for this part. the loggin inside updateServerCount happened
but actually it's a function that returns a promise so it shouldn't be cached
the only way to make it cache the results of the guilds cache would be if you did this ```js
const promise = client.shard.fetchClientValues(...);
setInterval(() => {
await promise;
}, 999)
yeah that should be fine
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
idk what's wrong with it
in your messageCreate.js file, at line 17
it seems message is not a valid message
you probably want async execute(client, message, Discord)
as the normal order is client, message not message, client
depends on how his eventHandlers.js was done
Why are you guys passing client and Discord in
Quite possibly the most useless function params
Access client through message.client
idek
https://just-read.it/ moment
i changed it but its not working no err or anything

this is my handler
https://pastebin.com/iJRNhBCc
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
aight but it's not even throwing an err
where is eventHandlers.js?
Does it by any chance not start with your prefix?
As you return nothing there
_case sensitive _
Don’t forget that
it starts with my prefix
you should (imo) use an async file loader, and use a custom 'require' function to reload the file each time its called, rather than use the cached version. then your exported module can be reloaded to reload commands when changed, instead of the bot having to reboot.
^ forces fresh require
What are they “relative” to?
Then remove the position class
Divs don’t stack if you don’t change their position property
still the same
my gosh 4th edit
lol
centered might also be a position change
Aye
you want to center vertically?
yeah
display: table
margin: 0 auto
have you tried using flexboxes?
well, one option is to use a negative margin-top which is exactly 50% of the height of the div, but tht requires the div to have a fixed height
or just use flexbox

flexbox is like
the magic fix for every single thing
^
that has troubled people for decades
you put them in a container
try to change the order of the flexbox iirc
<body or whatever with flex>
<div>
<p>hey there</p>
<p>i code shit</p>
</div>
</body>
the container div will be aligned by the flexbox
the text lines will be independent
remove the "shit" in the desc too
why 
epic that worked 
it is very true
no
my code is just like "it just about works"
so does every developer
just change it to "i code nice things"
btw
the word "shit" can mean good things as well
yeah
i generally mean i code shit as in like i code stuff
shit can mean stuff
https://omg-its.blahaj.wtf/EkrjrkZm.png also why no center text 
you didnt add justify center and items center
because I don't want it in the middle on this bit
then where do you want it
not bad
also, if you wanna learn more about flexboxes, check this out
Our comprehensive guide to CSS flexbox layout. This complete guide explains everything about flexbox, focusing on all the different possible properties for the parent element (the flex container) and the child elements (the flex items). It also includes history, demos, patterns, and a browser support chart.
better than http://bigbun.dev/ 
looks like a github readme
lol
in messageCreate right
Ewww, some magical css3 stuff
We build our fundaments on solid css2 and not magical aligning stuff
Grid ass looking mf
I hope that’s 100% viewport height, if not any other resolution won’t look like that but like weird space between those texts
yep
Thing don’t happen magically, unless you’re a witch
Flex it.
Shut up or I’m gonna flex you
Stop with your magical properties or I’m gonna call the catholic church and tell them about your magic tricks

Css3 is evil
I use HTML4 for backwards-compatibility

lol
there's a ton of stuff html5 got rid of tho so 
Is there a package similar to Puppeteer that doesn't launch Chromium? The reason for this is that I host my NodeJS projects on a VPS which only has 2GB of RAM, so even running in headless takes a good 30 seconds before Chromium is actually finished loading. This is going to send sketch but I'm asking because I'm attempting to web scrape a website that utilizes lazy-loading, so using Axios isn't enough.
did you try looking into the network tab and see if the data you want can be found on any subrequests?
Any idea on how I can make the button center?
<Container style={{minHeight: "85vh", display: "flex", margin: "auto", alignItems: "center"}}>
<Avatar className={'mr-5'} radius="lg" size="xl" src="https://imgs.search.brave.com/Q1JPL__FReDNKqetfnrYnBMKYs-uB8OwCnE6G55y7LE/rs:fit:1200:1200:1/g:ce/aHR0cDovL3dhbGxz/ZGVzay5jb20vd3At/Y29udGVudC91cGxv/YWRzLzIwMTcvMDEv/RG9nLWZ1bGwtSEQu/anBn" />
<div className={'flex-wrap'}>
<h1 className={'text-2xl'}>Hello I'm Aaron and I'm {age}</h1>
<p className={'text-lg'}>I'm a small time developer who enjoys working on random projects. I also love nature and watching MacGyver.</p>
<Button>Click Me</Button>
</div>
</Container>
use a grid and be lazy
<Grid>
<Grid.Col span={2} offset={5}>
<Button>Click Me</Button>
</Grid.Col>
</Grid>
``` something like that
cant you just 'mx-auto'?
Apparently not
.mx-auto{margin-right:auto!important;margin-left:auto!important}```
Should I use grid for the other stuff as well? At least that would make sense to me
Also wtf does span do?
how many columns the column takes up
grid component uses 12 cols by default
like bootstrap grid
depends on what you're looking for
personally I use grid for basically everything
really easy to lay out and visualize
though beware they can cause your page to overflow due to the fact that they have a -8px margin by default
I see
which I usually fix by wrapping the app
I think for this use case it is fine how it is
<Box id={"box-container"}>
<Grid m={0}>
<Grid.Col span={12}>
<Component {...pageProps} />
</Grid.Col>
</Grid>
</Box>
<Container style={{minHeight: "85vh", display: "flex", margin: "auto", alignItems: "center"}}>
<Avatar className={'mr-5'} radius="lg" size="xl" src="https://imgs.search.brave.com/Q1JPL__FReDNKqetfnrYnBMKYs-uB8OwCnE6G55y7LE/rs:fit:1200:1200:1/g:ce/aHR0cDovL3dhbGxz/ZGVzay5jb20vd3At/Y29udGVudC91cGxv/YWRzLzIwMTcvMDEv/RG9nLWZ1bGwtSEQu/anBn" />
<div className={'flex-wrap'}>
<h1 className={'text-2xl'}>Hello I'm Aaron and I'm {age}</h1>
<p className={'text-lg'}>I'm a small time developer who enjoys working on random projects. I also love nature and watching MacGyver.</p>
<Grid>
<Grid.Col span={2} offset={5}>
<Button color={'gray'} variant={'subtle'}>Click Me</Button>
</Grid.Col>
</Grid>
</div>
</Container>
this is how I have it rn
it works so
just not responsive at all but 🤷♀️
any reason why the background wont change?
hi
based on the docs ig ephemeral only works with reply
plus you can only send reply/defer for first time and then send new followup
got it
follow up should support ephemeral
It should yeah
It does, actually. A friend of mine has a bot that uses ephemeral messages on follow-ups
I checked guilds too
I think for that the main reply should also be ephemeral
https://sourceb.in/5B7LOx0Ug3, someone knows why leaderboard is not accurate?
example:
- user = 1,000,000
- user = 4,000,000
because you're looping through the results without sorting them
is at least what im seeing
you're also sorting by either the wallet or bank, then looping through the results, then summing it together when adding it
['wallet' + 'bank', 'descending'] === ['walletbank', 'descending'] ~ pretty sure thats not what you intended.
i wanted to do to join force the wallet and bank to get the leaderboard
yes. but wwhat you are actually doing is adding two strings together, then sorting your database by a 'key' that doesnt exist.
walletbankdescending is walletbankdescending yes
How am I able to check how many bytes are in a variable in Javascript?
Couldn’t find anything online.
so i should follow the code u given?
I’ll just use C nevermind.
there are literally hundreds of results to that google search 😂
idk how custom objects work with such calculations tho
how well*
Huh.
I didnt give code. i identified your issue 🙂
So everyone just counts the length by using .length and passing it as bytes?
Read one of the answers.
oh ok ok
Someone actually made C’s sizeof() available to javascript, and turned it into an NPM package. Well, maybe. They probably use the same syntax.
yes, strings length are multiplied by 2 to determine the size in bytes ~ in both the one i shared, and the npm module you mention
javascript (v8 specifically) uses dynamic containers to hold various types of data. obtaining the real memory size of a javascript value depends on many factors
for example, there are a few different container types for strings alone, depending on what characters the string has and how it was constructed
the real size of a simple string with n ASCII characters (8 bit per character) is 12 + 4 * Math.ceil(n/4)
"" takes 12 bytes
"1" through "1234" take 16 bytes
"12345" through "12345678" take 20 bytes
"123456789" takes 24 bytes, and so on.
all containers are rounded to the next multiple of size_t, so in 64 bit systems, all data sizes are rounded up to the next multiple of 8
an example of all the different string type containers in v8
the same goes for numbers, there are several different containers for them, like SMI, Double, HeapNumber
there are also 6 different types of arrays depending on its contents, etc...
but if you're using a different engine, ie firefox uses spidermonkey and not v8, then its likely gonna be completely different rules
I’m using Edge’s Chakra. So I’ll have to google all these rules online for the engine I’m using.
edge doesnt use chakra anymore
I haven’t bothered to update.
I’m using a very old version. 🥲
I always wondered why Java didn’t allow multiple inheritance, then I looked at an inheritance tree for a complex multiple inheritance program
And I realized how fucking messy it was
pls pos @sage heronty#7072
pls pos @earnest phoenix#7072
pls uptime @earnest phoenix#7072
BRUH
v8 has 6 different array types under the hood? i can legit only think of 2: regular arrays and linked list type arrays lol
wth lmao
yes
packed smi = array of small integers
packed double = array of numbers
packed elements = array of non-numbers or mixed types
holeys are non-sequencial arrays, arrays with holes
but you can have holey arrays too? is that only for strings?
ie [1,,2]
ahhh
This technical deep-dive explains how V8 optimizes operations on arrays behind the scenes, and what that means for JavaScript developers.
quite interesting tbh 😄
yeah, and these transitions can be quite costly
so for example if you keep adding and removing different data types, the array will keep transitioning
[1,2,3] = smi
.push("a") = transition to elements
.pop() = transition to smi again
so im guessing really its just about how v8 handles the memory and collection? like, a packed smi would be easier to handle than a holey array or w.e
lol yea
an smi array has a fixed size allocated for each element
if you add a double, it has to transform the entire array into double sizes
yea, where a holey could be anything or nothing
lets say [1,2,3,4] uses 4x 32 bits
if you do push(1.1)
it has to transform the array to doubles
yea
meaning the whole array now uses 5x 64 bits
so it performs that op on all elements?
and not 4x 32 + 1x 64
the entire container will use the largest item as the size for all items
yes
so for talking sake, lets say i have an array that has like [object, 1, 2, 3]
all elements would be 'holding' enough memory capacity based on the size of the object?
not exactly, because object here is a pointer/reference
so its size is always size_t
ooooohhh ok
aka 64 bit on a 64 bit cpu
but yes, all items in the array will use 64 bit because there is one 64 bit type in there
how I would handle a dynamic array is uh - store elements as a fixed size struct stating its type and size and a pointer to an entry in the heap for it
hey that's what my database is gonna do
works for memory too
how are initial sizes allocated
do they get expanded over time
👀 dang
size went from 44 bytes to 124 bytes
hmm
i removed the "a" with .pop()
and the type didnt change
nor the bytes
yup
it must not autoconvert it back
do another push with an int
what's smi
small integer
oh so under the hood it treats numbers differently
yea, has to for floats/doubles
0o
size went from 64 to 224 lol
is the array ever shrinked
so maybe the act of pushing is not optimized? 😂
there seems to be a difference between a read-only object, and a read-write object
i popped the array until it became empty
went down to 144
did push({})
a lot of interesting things happen under the hood that we dont really understand
yea im so confuzed rn wth
it must be as you say~ based on read/read-write. its likely objects that are modified are marked as 'dirty' somehow. but you would think that the 'dirt' would be auto cleaned during gc
or maybe thats it, maybe it hasnt ran gc yet
so its still holding internal reference to elements that no longer exist
totally nailed the discord gui rip-off 😂
xD
my nub app has had like 800+ downloads now 😮
and i legit only made it so i could advertize my bot, which i havent written any code for for like a month 😂
code on github is an absolute mess tho 😭
ive spent the past few weeks trying to clean it all up to be pretty, havent pushed the changes yet 😄
lmao nice
nah, it will be nice when i can finally move on to the next thing 😄
just... cant leave half chewed code on my github for a semi successful project. it deserves to be cleaned 😄
i've been thinking of trying out some kind of framework like vue or react or next.js. never tried any of them, seem like they could be helpful
You're telling me you did this without any frameworks? madman
dont need a framework to make an input element and get its value 😛
but no, ive never used any framework. kind of built my own over the years using ejs templating/rendering, but idk, seems like some frameworks could make things a fair bit faster
handling stateful input with the document API is a pain in the ass
tbf, my nub app only really has two states: running or stopped 😛
is anyone here goodwith regex
im trying to make a word filter
i made a discord serverlink filter but i cant figure out how to with just normal words
//Declare Reg using slash
let reg = /abc/
//Declare using class, useful for buil a RegExp from a variable
reg = new RegExp('abc')
//Option you must know: i -> Not case sensitive, g -> match all the string
let str = 'Abc abc abc'
str.match(/abc/) //Array(1) ["abc"] match only the first and return
str.match(/abc/g) //Array(2) ["abc","abc"] match ...
I have this function for using selenium:
async function seleniumGet(url) {
if (!driver) {
await startSelenium();
}
try {
await driver.get(url);
await driver.executeScript("window.scrollTo(0, document.body.scrollHeight)");
for (let i = 0; i < 20; i++) {
await driver.wait(until.elementLocated(By.className('lazyloaded')), 5000).catch((err) => {
console.log("Wait error");
});
}
console.log("Done waiting");
await driver.getPageSource().then(function (source) {
resolve(source);
});
}
}
However, when logging the result of the function using console.log(await seleniumGet("https://myurl.com")); returns undefined. I also tried:
let src = await driver.getPageSource();
resolve(src);
But the result is still undefined. Logging await driver.getPageSource(); works fine (the page source is logged correctly), but resolving src returns undefined.
What even is the resolve() function supposed to be?
Oh I'm stupid I forgot an entire line of code. Never mind whoooops

yes you can use html in your bot description
as long as you respect top.gg's existing structure and css
Note that when using javascript, it may not want to save
as script doesnt work nonetheless
let flag = 0
const timeout = 86400000
flag = await fetch(`https://top.gg/api/bots/${interaction.client.application.id}/check`, {
method: "GET",
body: JSON.stringify({
userId: interaction.user.id
})
})
if (flag = 0) ---> user dont vote
else ---> user vote```
TypeError: Request with GET/HEAD method cannot have body
insted body, what I need to write?
nowhere does it say send body
this does not explain how to fetch
it does
https://top.gg/api/bots/${interaction.client.application.id}/check?userId=${interaction.author.user.id}
nice, tnks 💙
np
you need to pass an authorization header
That moment you accidentally create an illegal directory and can’t delete it
rm -rf <directory> (add --no-preserve-root for extra adrenaline ||DON'T||)
Thanks 🙏
I think I created a directory with an array as the name
Somehow idk
But windows ain’t allowing me to delete it cause it “doesn’t exist”.
probably something that can be resolved by just restarting
or you fuck up your whole machine by doing so, cant remember
Have you tried F5 in explorer?

I have not I’ll do that in a sec
whats the problem?
emoji.name is undefined
I know but why?
Can you send us more of your code?
there isnt any more this is the whole code
message.guild.emojis.cache is the collection of server emojis so it shouldl return emojis I dono whats going on
for(const emoji of emojis.values())
^
or just replace your entire code with a single line:
v!eval [...message.guild.emojis.cache.values()]
<3
i want the names
awsome
works great
why in this case we need .values()
but this one works without it?
Collection extends Map, its default iterator works on entries, not values
but Collection has .map function built in that Map does not have, and this function iterates over values and returns an array
oh ok get it
I get an error if a bot doesn't have permission to send messages in channel and then the bot just dies
I tried doing if (!message.guild.me.permissions.has("SEND_MESSAGES")) return;
but it still shows an error DiscordAPIError: Missing Permissions
how do I fix this error. I tried try catch and it still didn't work.
discordjs
show code
client.on('messageCreate', message => {
if (!message.guild.me.permissions.has("SEND_MESSAGES")) return;
if (message.author.bot) return;
db.collection('guilds').doc(message.guild.id).get().then((q) => {
if (q.exists) {
prefix = q.data().prefix;
}
}).then(() => {
if (message.content.toLowerCase() == "@floral pumice") {
const mentionEmbed = new MessageEmbed()
.setColor("#fcc603")
.setTitle(
`Hey there, my prefix in this server is \`${prefix}\`\nTry \`${prefix}help\` to see the commands.`
)
.setFooter({
text: `${message.member.user.tag}`,
iconURL: `https://cdn.discordapp.com/avatars/${message.author.id}/${message.author.avatar}.jpeg`,
})
.setTimestamp();
return message.channel.send({ embeds: [mentionEmbed] });
}
if (message.content.toLowerCase().startsWith(prefix)) {
const args = message.content.slice(prefix.length).trim().split(/ +/g);
const commandName = args.shift();
const command = client.commands.get(commandName.toLowerCase());
if (!command) return;
// message.channel.sendTyping()
command.run(client, message, args, prefix, db)
}
})
})
long boy
TIM 👀
I have too many emojis and all of them start with 00 or maybe 01 so I want to remove the 00 or 01 from the emojis can u help with that?
some thing like this:
const emojis = message.guild.emojis.cache
for (const emoji of emojis.values()) {
if (emoji.name.startsWith('00')) { /* remove the 00 from it */ }
if (emoji.name.startsWith('01')) { /* remove the 01 from it */ }
}
well first of all why are you putting that prefix in a global variable? that will cause issues where messages will possibly get the wrong prefix because its a race condition
other than that, you can do message.channel.send().catch(console.log) or if you want to use try catch you have to use await
and if command.run is an async function, you have to catch that as well
oki doki
so i just put everything inside an aync function and then just call it whenever it detects a new message?
message.guild.emojis.cache.map(x => {
let name = x.name;
if(name.startsWith("00") || name.startsWith("01")) {
name = name.slice(2);
}
return name;
})
tnx
no
you want to use try catch?
yep
then(() => {
v
then(async () => {
ohhhhhhh
no i dont want to see it in this style i want to do it emoji.setName()
const emojis = message.guild.emojis.cache
for (const emoji of emojis.values()) {
if(emoji.name.startsWith("00") || emoji.name.startsWith("01")) {
emoji.setName(emoji.name.slice(2)
}
})
correct me if im wrong
it should look something like that?
then(async () => {
try{
//scuffed code goes here
}catch(e){
//consolelog whatever doesnt matter
}
})
await emoji.setName(emoji.name.slice(2));
yes, with await message.channel.send() or await command.run()
but i need async for await how can I use await here?
v!eval
const emojis = message.guild.emojis.cache
for (const emoji of emojis.values()) {
if (emoji.name.startsWith("00") || emoji.name.startsWith("01")) await emoji.setName(emoji.name.slice(2)
})
you need your eval command to support async
if it doesnt, then you can run a self-executing async function
eval (async () => { your code here })()
so v!eval (async () => {
const emojis = message.guild.emojis.cache
for (const emoji of emojis.values()) {
if (emoji.name.startsWith("00") || emoji.name.startsWith("01")) await emoji.setName(emoji.name.slice(2)
})
})()
should work
yes
no worky
tnx alot Tim
client.on('messageCreate', message => {
if (message.author.bot) return;
db.collection('guilds').doc(message.guild.id).get().then((q) => {
if (q.exists) {
prefix = q.data().prefix;
}
}).then(async () => {
try{
if (message.content.toLowerCase() == "@floral pumice") {
const mentionEmbed = new MessageEmbed()
.setColor("#fcc603")
.setTitle(
`Hey there, my prefix in this server is \`${prefix}\`\nTry \`${prefix}help\` to see the commands.`
)
.setFooter({
text: `${message.member.user.tag}`,
iconURL: `https://cdn.discordapp.com/avatars/${message.author.id}/${message.author.avatar}.jpeg`,
})
.setTimestamp();
return message.channel.send({ embeds: [mentionEmbed] });
}
if (message.content.toLowerCase().startsWith(prefix)) {
const args = message.content.slice(prefix.length).trim().split(/ +/g);
const commandName = args.shift();
const command = client.commands.get(commandName.toLowerCase());
if (!command) return;
// message.channel.sendTyping()
await command.run(client, message, args, prefix, db)
}}catch(e){}
})
})
what did my small brain do now
btw you still have a missing ) on setName
yeah i see
if the error is coming from message.channel.send you did not await it
i need to do in inside the command handler files too?
/home/runner/ChompBot/node_modules/discord.js/src/rest/RequestHandler.js:350
throw new DiscordAPIError(data, res.status, request);
^
DiscordAPIError: Missing Permissions
at RequestHandler.execute (/home/runner/ChompBot/node_modules/discord.js/src/rest/RequestHandler.js:350:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (/home/runner/ChompBot/node_modules/discord.js/src/rest/RequestHandler.js:51:14)
at async TextChannel.send (/home/runner/ChompBot/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:175:15) {
method: 'post',
path: '/channels/967401048597725184/messages',
code: 50013,
httpStatus: 403,
requestData: {
json: {
content: undefined,
tts: false,
nonce: undefined,
embeds: [
{
title: 'Cat',
type: 'rich',
description: null,
url: 'https://docs.thecatapi.com/',
timestamp: 0,
color: 15443968,
fields: [],
thumbnail: null,
image: {
url: 'https://cdn2.thecatapi.com/images/6xLEBwiUS.png',
proxyURL: undefined,
height: undefined,
You’re missing the permission to post a message and/or embed
At least in that channel
if you use .then() a lot
cat api 🐱
you will need to convert all of those to await
try catch only works on things that are awaited, not on things that are .then()ed
show your cat command
OMG
can i type
const fetch = require("node-fetch");
const { MessageEmbed } = require("discord.js")
module.exports.run = (client, message, args) => {
const options = {
method: 'GET',
headers: { 'x-api-key': `${process.env.CAT_API}` }
};
async function cat() {
await fetch(`https://api.thecatapi.com/v1/images/search`, options)
.then((res) => res.json())
.then((data) => {
const CatEmbed = new MessageEmbed()
.setTitle(`Cat`)
.setURL('https://docs.thecatapi.com/')
// .setDescription(`Requested by <@${message.member.id}>`)
.setColor("#eba800")
.setImage(data[0].url)
// .setTimestamp()
// .setFooter({
// text: `${message.member.user.tag}`,
// iconURL: `https://cdn.discordapp.com/avatars/${message.author.id}/${message.author.avatar}.jpeg`,
// })
return message.channel.send({ embeds: [CatEmbed] });
})
}
cat();
};
module.exports.name = "cat";
either do return cat() or await cat()
a function in this case
depending on the situation yes
in this situation cat is an async function
if its returned, then it will be awaited in await command.run()
if its not returned, you can await it, and the catch will still work
but if you dont return and dont await, then the command will exit before the cat function is finished
yes
isnt working lemmi try to return
ah yes to do await cat() you need to add async to (client, message, args) => {
but return should still work
ok so i tried return IT WORKS!
one more thing
i have the ping command
const { MessageEmbed } = require("discord.js");
module.exports.run = (client, message, args) => {
return message.channel.send(`Latency is ${Date.now() - message.createdTimestamp
}ms.\nAPI Latency is ${Math.round(client.ws.ping)}ms`)
}
module.exports.name = "ping";
what do i do in this case
can i just put it inside a function and return the function?
or because i return the message it shouldnt do an error?
since you are returning it, it will be caught by the await command.run
Your api latency technically is the gateway ping or websocket ping and the first measurement is the api response time
_just to say _
im just adding that
idk why
its more of a test command
but good to know
also Tim thank you so much!
@earnest phoenix Tried out your proxy stuff and can't quite get it to work the way I want it to. A module I made exports a boolean, but the return value when logging is the internal Object I try to proxy all stuff through.
Code:
const obj = {};
const obj[placeHolderKey] = requiredModuleReference;
return new Proxy(obj, {
apply(target, thisArg, argumentsList) {
return Reflect.apply(target[placeHolderKey], thisArg, argumentsList);
},
construct(target, argumentsList) {
return Reflect.construct(target[placeHolderKey], argumentsList);
},
defineProperty(target, property, attributes) {
return Reflect.defineProperty(target[placeHolderKey], property, attributes);
},
deleteProperty(target, property) {
return Reflect.deleteProperty(target[placeHolderKey], property);
},
get(target, property) {
return Reflect.get(target[placeHolderKey], property);
},
getOwnPropertyDescriptor(target, property) {
return Reflect.getOwnPropertyDescriptor(target[placeHolderKey], property);
},
getPrototypeOf(target) {
return Reflect.getPrototypeOf(target[placeHolderKey]);
},
has(target, property) {
return Reflect.has(target[placeHolderKey], property);
},
isExtensible(target) {
return Reflect.isExtensible(target[placeHolderKey]);
},
ownKeys(target) {
return Reflect.ownKeys(target[placeHolderKey]);
},
preventExtensions(target) {
return Reflect.preventExtensions(target[placeHolderKey]);
},
set(target, property, value) {
return Reflect.set(target[placeHolderKey], property, value);
},
setPrototypeOf(target, value) {
return Reflect.setPrototypeOf(target[placeHolderKey], value);
}
});
// somewhere else
console.log(ReturnValueWhichShouldBeAProxy) // { __heatsync_default__: false }
// what I expect
// console.log(ReturnValueWhichShouldBeAProxy) > false
Seems like the traps only work when doing thing.property
not when displaying the default thing
pretty sure what you're trying to do is not possible

you will always need an object container, you cant work on primitives
welp. I guess I can discard all of my changes
what does this mean
you've already replied to or deferred the interaction
So when I turn off my bot, there is a chance Express fails to turn off, and the only way I know to turn it off is if I shut my computer down or wait a long time. How can I shut it off if this does happen?
yes
idk, it just does not shut off sometimes
how are you turning it off?
is express inside the bot file?
it turns on when I turn the bot on, and supposed to turn off when i shut the bot off
Self hosting, beta bot where I am having the issue
Like im turning the bot on and off for beta testing
"node -v"
idk the command, I press button and bot starts
what button?
replit button probably
The run button
oh
The button that makes the bot run
Im not upload the code to a host, because im, testing the code
neither
then what run button?
The run button on my software in which im coding my bot in
what software?
VSC
vsc doesnt have an autoconfigured run command for node projects afaik
how did you configure it? show your package.json file
do you have a .vscode folder with a launch.json file?
yes or no, is it possible to turn off the express node without restarting my computer?
of course it is
then how?
literally just exit the script
thats what everybody does
but i have no idea how you are starting and stopping your script because i have no idea how your workflow looks like
so i cant help you if i know nothing about what/how you are doing
most people start stuff by running node myfile.js and then stop it by pressing ctrl+C
if you're not doing it like everyone does, then i need to know how you are doing it to be able to help
Imma get help elsewhere
good luck
using nodejs canvas
how can i place text in the center of a canvas (idk what its called)?
fillText
you can measure the height by the pixel size and the width by measureText
and use those to get the X and Y position for where to draw the text
X = canvas width / 2 - measuredText.width / 2
Y = canvas height / 2 - font size / 2
I'm still having an issue with the guild count being cached. any idea how total could be cached?
Lmao he wants u to crystal ball his problem tim
thanks typescript
I'm fucking amazed
One message removed from a suspended account.

I want to create a function called type() with several properties such as channel, message, etc. i.e, if I execute type(272764566411149314).channel, it would replace the value of, supposedly, GUILD_TEXT, to its explanation, a guild text channel.
I'm supposed to be using a class (although I want to write all of this in a seperate file as a class and then export it to use in another file), how should I be planning out the class since I'm confused how I'll do the .channel, .message, etc.
that didnt make much sense to me, can you give more examples?
My bot is constantly going offline at midnight for some reason, is there any reason why? My host is galaxygate
A generic, what you want is a generic
Basically make a class that auto-cast to the target value
For obvious reasons, you'll need to throw an exception is all cases except for the correct one
Or return null
class From {
class Type {
const id;
constructor(id) {
this.id = id;
}
function channel() {
return client.channels.cache.get(id);
}
}
function type(id) {
return new Type(id);
}
}
Something like this
Idk if js allows inner classes, or even abstract and private definitions
Ideally you'd have Type private, and From abstract so u can't instantiate it
Then just call From.type(1234567890).channel()
You can transform the last methods into properties if u load all variables during constructor
That'd fit better ur request
Is there even a keyword private? I think private vars and functions start with a #
But am on mobile, and writing code here is shit
Idk, I never really stopped to think if js has ANYTHING other than class regarding oop
Actually, I could count on hand how many reserved keywords exist
you sure about that?
Tim’s always ready to fuck somebody up
some of those have been removed since ES5
I see private but this hasn’t to do anything with classes I guess
thats one of the removed ones
It was a little confusing to come to JS without public, protected and private keywords
i didnt even know what those were until i looked beyond js
And the fact private vars and functions start with a #
yeah that decision was just stupid
Well it is how it is
ts to the rescue
no idea, never used them
Hmm
i like using _abc as the unofficial standard for private stuff
That’s why PHP has protected keyword
i dont care about making my stuff unhackable
lol
But things can get complicated when having huge extended classes and may one public var exists two times
just dont use the same name :^)
I’m also not a fan if I include an helper class for example in my database class and then call helper functions using my database class
That’s the reason private and or protected vars/functions exist
Js might not be the best oop language here
it never was and never will be
It’s feels like moving between two worlds sometimes
Can’t atm but later
i will go too
When I’m done working
kthxbye
Bye
i thought goto was going to make a comeback
https://sourceb.in/IMQ4apBY0X when im using member.id it keeps throwing error like this Cannot read properties of undefined (reading 'id') but when im pinging the member its fine.
Well, your member either isn’t cached or you’re not giving an id/mention for it to parse
i change the .cache.get to .fetch then it works fine now
i got a message with a button and when i press that button i want to get the message content of that message, how am i able to do this?
You receive the corresponding interaction event which includes the message object (and content) as property
can anyone check #topgg-api
I'm using Prisma. How can I get all records that have value bigger than x?
gt: x ??
or gte: x
yeah got it thanks^^
another question... can I somehow put variables in a query? variable as the column?
Sorry for the extremely late response, was asleep; since primitives such as booleans and numbers do not hold a reference, you can check the type of the value wanted and return a new value of the same type, which they could either use or modify, for arrays, objects, symbols or similar types of values, you gotta clone the value in a way as I'm sure I've told you how to do so before
😔
I have a function called checkName(username) which returns { scam:true, reason:"whatever" } or { scam:false }, how can I check all members from all the servers my bot is in to see if any return scam:true?
depending on what you are wanting to achieve, you may be approaching the solution backwords. If you are wanting to keep a record of all the users in each server that have been flagged as 'scam:true' then, imo, you should create a specific database table/collection for those entries and then you add to it, or check it as required. otherwise the alternative would be to iterate over every single guild you are in, then every single member, then forcing fresh data for each member, then checking the flag. which is not a good approach for a number of reasons
I already have a database for lots of them
I’m mostly checking for any users that are scam accounts that haven’t been flagged because It was from before I started checking for them
I did a check for users with the word modmail in etc and got 36 users
I just now need to get those user ids and then I’ll add to the database too
ahh, if your only planning to run the operation once, that isnt too bad. just iterate over each guild, fetch the guild data, iterate over each guilds user, fetch the user data, then check/add
Is it possible to download a file from a blob URL? I'm not sure how those work, but for some reason certain blob URL's work and some don't. For example this one results in the image:
blob:https://mangadex.org/6bb8e02d-ae5f-486b-a42d-bd655de28e39
But this one results in Firefox saying the "url doesn't look right":
blob:https://mangadex.org/6cbbfd0b-2dd0-49c0-801f-9ac8ef4fa021
(FYI Mangadex allows you to download the images directly from URL's using their API, but I'm trying a different approach since their API isn't all the greatest imo)
When I try to use this bit of code to download files from a URL, I get a timeout error.
async function downloadFile(file, path) {
const streamPipeline = util.promisify(nodeStream.pipeline);
const response = await axios.get(file, { responseType: 'stream' });
await streamPipeline(response.data, fs.createWriteStream(path));
}
how do I call a js function, using ejs?
for example, I want this p element to have as content the output of Math.floor(Math.random() * 10), how would I do that?
try {
switch (smth) {
case 'B':
result += 5;
throw new Exception();
case 'C':
result += 6;
throw new Exception();
case 'D':
result += 7;
}
} finally {
...
}
``` thank you for coming to my Ted talk on “how to avoid using `break`”
My teacher hates when I use break in loops, so I’ll just do this for loops instead of switch cases
Why does he hate using break?
Does he think it will break the loop not the switch case?
One message removed from a suspended account.
optionally, just use java 
do you want to check whether the channel is a dm channel or if it's a specific dm channel
yes
i want to reply a button which is in user dm
???????????
One message removed from a suspended account.
One message removed from a suspended account.
I’m talking about in a loop
Break is of course allowed in a switch case
That is Java!
then why not case XX -> ...?
It’s a joke
a
const perms = [
Permissions.FLAGS.VIEW_CHANNEL,
Permissions.FLAGS.SEND_MESSAGES,
Permissions.FLAGS.USE_EXTERNAL_EMOJIS,
]
channel.permissionsFor(guild.me).has(perms);
Is this the right way to check if my bot has permissions in a channel?
depends on whether has expect inputting arrays
why switch?
const mappings = {
B: 5,
C: 6
}
result += mappings[smth]
im sure it does, I tested in local, if the bot doesn't have perms it stops there. But it actually doesn't stop when its being hosted
kinda weird
are u saving the file?
1: it’s Java, 2: ITS A JOKE PEOPLE
like, pretty dumb but sometimes happen
saving what?
the file ur code is in
do you mean when its being hosted?
it rebuilds every new deploys
I dont think its related at all tbh
maybe its something about discord cache
String chars = "ABC";
int bits = 4;
bits = (bits << 6) | 5;
bits = (bits << 6) | 6;
result += (bits >> ((chars.length - 1 - chars.chartAt(smth)) * 6)) & 0xF;
ok nvm I think I found out that sending embed message with link also needs embed_links perm 🤔
does anyone have an idea why total would get cached? The value doesn't update until i restart the bot
c.guilds.cache.size maybe?
line 8 of the 3rd ss?
oh
like dont use the cache
this is the code from the library that does client.guilds._add
https://github.com/timotejroiko/discord.js-light/blob/0d8afe430a484ba8fac24fd61c33b1125b25a074/handlers.js#L114
so maybe that doesn't add it to the cache?
idk how d.js works (let alone timfork), can't help much with it
ping it once every a few minutes
What you mean?
Realy? Or u joking?
He will get alive if i pinged?
ye
repl.it is supposed to be used for sites and services
both are supposed to never be 24/7 and only start when called (aka on-demand)
so if u want to keep it 24/7 u need to trick it into thinking someone is acessing it
no
HTTP ping, not discord ping
fetch("the bot repl.it url")



