#development
1 messages ยท Page 1998 of 1
yeah I figured as much
my c/c++ installation is a bit fucked tho
I guess imma wait till I switch to linux to start doing anything
I'm wondering what kind of structure folks database' have. Like, assuming you want to allow users to have different data saved for each guild - rather than having data only be global - do you:
A: use both user and guild id's to fetch the data object to be saved. eg: ```js
const user = db.fetch({user: 'some-id', guild:'some-id'});
**B:** have some user account that stores information for each guild that user is in. eg: ```js
const account = db.fetch({user: 'some-id'});
const user = account.getUserForGuild('some-guild-id');```
**C:** something else (please share)
I'd prefer having the user settings be under the guild since it implies ownership, but if that isn't the case, then A.
By "implies ownership", I mean who really owns some dataโthe user, or the guild? If the guild is deleted, so should any data associated with it. Yet option B tries to own that data and leaks into guilds, which I don't like.
ahh yea, that is a pretty valid point
my main thinking was that, with option B, it would be much easier to manage both global and guild specific information. for example, a user might purchase credits that can then be redeemed on any guild, but they are then used
or perhaps they might set some reminder, which i would consider a user specific interaction more than a guild one
option B kind of feels more like how discord manages things internally too, with a user and member differentiations
balls out: i use option A and was thinking of switching to B ๐
How to get about me of the user?
Apparently bots arent allowed that info. idk if its now available or what
i know you can get a users banner now
It's a hard problem for me to describe as it depends on what kind of database you're using. For example, if you're using MongoDB, I highly discourage B since it encourages a coupling of those documents that can be harder to manage later (http://www.sarahmei.com/blog/2013/11/11/why-you-should-never-use-mongodb/), although it concerns documents inside documents. If you're just dealing with users that have relations to guilds, it's not much of a problem to have guilds inside the user structure, but I'd still flip it since I think guilds should bridge to users rather than the opposite.
๐ I use mongodb for everything
but yea, i do see what you mean
so then how would you manage the global datas?
Since global data is about the user, I'd just put it in the user
but if a user is specific to a guild, that cant work?
Is there an event for Username changes? Djs
like, what if that user is in many guilds, which one stores the user with the global data?
Thatโs nickname tho
idk if thats only nickname in guild or real username, but i'd imagine when real username changes so does guild nick (if unset at least)?
Iโm trying to detect when an accounts name is changed to ModMail etc as Iโm trying to stop scam accounts :)
use account id instead of name?
Account ids donโt change tho
exactly, then there is no need to even listen ๐
Iโm trying to make it auto kick them as they mass DM users, so I kind of need to check username changes tho
not sure, i'd try that event, and give yourself a nickname on some test server, change your username, and see if the event fires?
I'm thinking of this:
User:
- Settings:
-
- Favorite Color: blue
Guild:
- Settings:
-
- User: ...
-
- Favorite Color: red
Here specifically, settings is a collection, and user is a reference pointing to a user. The user document has its own settings independent of the guild, so it's easy to tell what belongs where.
ahh ok, so instead of storing the document internally, you would store the id and then get that data from another collection?
Found it!
client.on("userUpdate", function(oldUser, newUser){
console.log(user's details (e.g. username) are changed);
});
// userUpdate
/* Emitted whenever a user's details (e.g. username) are changed.
PARAMETER TYPE DESCRIPTION
oldUser User The user before the update
newUser User The user after the update */
client.on("userUpdate", function(oldUser, newUser){
Assuming you're referring to users, yeah. User is a reference here pointing to an actual user document. What's cool about this structure is the user does not concern itself with the guild, yet the guild gets to control the user however it feels.
so would this be a more accurate psuedocode for what your suggesting?: ```js
const user = db.fetch({user: 'some-id'});
const guild = db.fetch({guild: 'some-id'})
const member = guild.getDataForUser(user);
Not exactly sure, but you could probably write it that way. The guild knows its members and it knows the users it refers to (guild -> members -> nth -> user (ref)). I'm thinking more from the schema side.
can I use the js function getElementsByClassName() only onto the document, or also on an element I have in a variable?
still kind of have the whole subdocument issue though for guild's member data. ๐
Yeah, but if you went on and fully separated all the documents and only provided references, you'd end up with some pseudo-SQL that's much harder to manage since MongoDB is not optimized for it. So, for now, I think it's fine.
lol yea, I do kind of like the ease of use mongo (mongoose.js) brings ๐
weird, cause I'm getting this error from my function
function show_info(e, a) {
e.setAttribute('onclick', 'hide_info(this, ' + a + ')')
e.setAttribute('class', e.getAttribute('class') + ' pressed');
let parent_el = e.parentElement.parentElement.nextElementSibling
let data_el = parent_el.getElementByClassName(a + '-data')[0]
data_el.setAttribute('class', data_el.getAttribute('class').replace(' hidden', ''))
}```
are you sure that it is?
e.parentElement.parentElement.nextElementSibling seems... promiscuous...
not sure what you mean
My critiques on the user was just about separating two conceptually different documents. A member is bound to a guild, so it's not that bad if it's in the document for now.
But the underlying user should stay out of it
Cover in red tape
lol yea, you do make a fair argument ๐
that looks bootstrappy. i like bootstrap ๐
idk, according to the docs that function can be called on any element
almost, it's tailwind ๐
im using a discord-rpc package, i want to ask, why the buttons is not working?
ahh, i've heard of that, never tried it though ๐
discord-rpc never works for me ๐ฆ
i think its cause i have nginx server running on my machine ๐
why? Whats the error?
buttons don't work on your end
just never connects, disconnects immediately
they work for everyone else looking at your profile though
i think nginx is like, restricting the port or something
ooh I found it, I wrote getElementByClassName instead of getElementsByClassName ๐คฆ
discord-rpc can't be run remotely
RPC.login({ clientId: clientID }).catch(console.error)```
Thats how i solve my problem about disconnections
I do that crap like 5 times a day ๐
^
that's why you can't run it remotely
yea :/
ipc has to be run on the same machine that you're running discord on
yea it was
Did you tried it too? The buttons? Is it working?
were you trying to run an rpc on a bot..?
thats the error i get when trying to use some discord-rpc example project
no, its just a subfolder of my bots folder ๐
did you set the clientId thing
also you need to have an application for it in the dev portal
yea, I tried both my bot application id and my user id lol (im nub, shh) ๐
ahhh ok
you need to create a separate application for the rpc on the portal and use that application id instead
so create a specific application for just the rpc?
yes
done ๐
so i just use this application id? i dont have to set any configuration on the dev dashboard?
yup
same error still ๐
I'm not sure if you need to set this or not but I have this in mine
hmm
also can you show the code you're using?
const clientId = 'xx';
const {Client} = require('discord-rpc');
const scopes = ['rpc', 'rpc.api', 'messages.read'];
const client = new Client({transport: 'ipc'});
client.on('ready', () => {
console.log('Logged in as', client.application.name);
console.log('Authed for user', client.user.username);
});
// Log in to RPC with client id
client.login({ clientId, scopes });
still same error with the redirect too
lemme stop docker/nginx for a minute
I'm still confused, what do you need docker/nginx for
rpc connects to the discord programs internal server (iirc), nginx restricts access to routes and ports
I've never messed with rpc scopes or had the need to, so I'm not sure if those scopes are affecting it or not
don't follow those, extremely outdated
๐
relatable haha
I just do ```ts
import rpc from 'discord-rpc';
const client = new rpc.Client({ transport: 'ipc' });
// do stuff with client
await client.login({ clientId: 'client-id' }).catch(console.error);
no idea what the scopes would even do
ok i directly linked the dlls and the errors seem to have vanished, now I'm getting exit status 5 from ld
zamn
omfggg... i finally got it working (rpc) and it wasnt updating because i didnt have my status thing enabled lmao

can some teach me how to make a bot that returns gif
We cannot teach you how to clone schizo bot
I hate cpp
the include path is right and everything is there
how can there be an undefined reference to a shitload of functions
idk what I'm doing wrong
at least it's not a segfault
how do I stop a flex item, to grow, when its content changes.
I hv tried setting, flex: 0 0 100px.
Try using max-width
But Ive taught myself, to not use, width or height, but instead flex-basis
skill issue
Can u try it https://play.tailwindcss.com/LIYb2V6TUG
u can hover over, classes, to see its styles being applied
try{
const com = client.commands.get(command) || client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(command));
com.execute(message, args)
} catch(err) {
console.log(err)
}``` why aliases is not working?
can you try printing the value of cmd aliases
Or they can show the logged error
I HATE how javascript doesn't have a package private modifier OMG
Have what now
you want to refactor a thing for better organization? no problem, just expose this function to be imported GLOBALLY by EVERY possible file in your entire project
hey so, how do I get my sharded discord bot app running after i compile the ts code with tsc? the file im trying to exec after compiling just ends without any logs
execArgv: [ "-r", "ts-node/register" ],
totalShards: "auto",
token: DISCORD_TEST_BOT,
respawn: true
});```
This is my shard manager for shard.ts
package private in java lets you move files around and expose them only to other files in the same directory
after running tsc, i removed the execArgc and changed the file to client.js
didnt work
in js you HAVE to export everything globally and it destroys intellisense
not talking to you
dunno I don't make discord bots
no worries, i'll wait for someone else to reply
I really don't get what you're referring to here as "package private" in-case of JavaScript, do you mean private NPM packages or anything of that sort? Or what do you exactly mean? And you can refactor anything you want without exposing them globally
java uses the term package to refer to individual directories. In ESM's case I would expect a modifier that exposes an identifier only to the directory it's in (and above)
rust has this too
it makes organization sooooo much easier
Oh I see what you mean
with js I constantly have to think about is it worth to move this into a separate file and be forced to expose this small helper function to the ENTIRE WORLD vs just keeping it in the same file and taking the organizational L
Yeah that's not possible in JavaScript at all, although it doesn't really help organization much, but I see what you're talking about
there's absolutely 0 reason for this object to be used outside of the directory it's in, yet if I want better organization I have to litter the autocomplete of every other file with it
it absolutely helps organization
It does, I mean not too much but it helps the organization significantly if it's a large project, although I remember seeing a proposal to only export values to a certain set of directories or files, but I'm unsure what happened to it
It's like entirely gone
you can live without it but it's a net benefit with no downside
forces you to think about how you structure your folders and files which is not a downside in my book
Yeah, absolutely
Although the @ prefix was suggested to make this possible to imports that mention the package identifier, although it's still stale
https://github.com/microsoft/TypeScript/issues/41425
And was only proposed to TypeScript
But the proposal for JavaScript is just poof
ye regular js doesn't matter I only use TS anyways
this needs to be enforced at the compiler level though. If I have to write comments I don't even want it
my man google
up
A typescript transformer could be written to make that work along with a separate language service plugin but that's too much work if you ask me
not the kind of thing you should have work with a linter since the idea is to scope available identifiers and not even have them be reachable instead of filtering "the entire world" essentially, by a comment
How do you run it currently? It should be node path/to/file, like any js file
yeah i tried this but nothing shows up
i ran tsc, changed the client.ts to client.js tried running it with node
it just finishes execution
At this point it's just a good idea to propose this in a different and more verbose way to the TypeScript committee, and burn the implementation to the TypeScript compiler rather than a plugin, although I'm sure they'll probably not accept it as the previous one was stale, but yeah, a plugin would be too much work just for that
also if this helps I use ts-node -r dotenv/config path/to/tsfile
To execute the shard.ts
Why "messaggiPing": "Ei ${message.author}, per vedere la lista completa dei miei messaggi utilizza **/aiuto**."
message.author doesnt work as mention?
Because you're trying to use a template literal in a non-template string
"..." -> `...`
Ik this difference, but in config.json I can't use ...
`
or I simply dont know how
Oh you're doing that in a JSON file, then you gotta evaluate them instead using something like the global eval() function after wrapping them in strings or replacing them yourself in a way that would match them using regex if you want, I recommend the first way
I'm a coding noob, but not that noob to use "${} " instead of ` ${} , maybe 
eval() kinda run code?
If you construct an arithmetic expression as a string, you can use eval() to evaluate it at a later time.
google is my friend
For example:
const { messaggiPing } = /* JSON object here. */;
const wrappedValue = `\`${messaggiPing}\``;
// Where you have the `message` parameter/variable.
const evalutedValue = eval(wrappedValue);
And it should get replaced with the value in the current scope
Although you may need to inspect the string value with the inspect() method from the built-in util module if the strings in the JSON file are using different types of quotation marks that may interfere as you'll be evaluating it in this case
A different approach to this case is to make a helper function to replace given values in a string and return them
As this way can be better than evaluating
function replacePlaceholderString(str, ...values) {
let i = 0;
return str.replaceAll('{}', () => values[i++]);
}
// Here we have a string with placeholders.
const someStr = 'Hello there {}, {}';
const replacedString = replacePlaceholderString(
someStr,
'Alfred',
'how was your day?'
);
console.log(replacedString);
// 'Hello there Alfred, how was your day?';
@stiff lynx ^
I think I'm gonna use this for my bot, seems more clear and easy to me. I thank you a lot for your time and your explanation.
You're welcome
because you don't read errors
Itโs because I usually use root
Learn how to read errors
That is a terrible user for eval. Also, eval should almost never be used for security reasons.. A much safer approach to evaluating things is to do something like this:
The terrible user for eval
that way, you can provide access to specific variables within the 'eval scope', but it stops reference to any object you havent explicity passed
use* lol
is that actually safer nvm
Although, I suggested to use something else to use other than the global eval() function, which to use placeholder and replace them, which they went ahead and used
The eval() idea came to my mind first as if they might have something that actually needs it
^ from my game engine ๐
~shows how to define objects to be passed to the 'eval' function
eval and safe can't be used in the same sentance
:p
but yea, its not perfect. evaluating stuff on the fly just isnt.
at least my approach stops access to variables that arent defined within the function, such as process
errr you can access process after everything you're doing?
eval("a + b", null, true, {a:1, b: 2})```
how are you going to access process within that string?
The process object is global, it's accessible everywhere no matter what you do
within THAT string no but that's not the point
it is though. as that is where the user input (that could be comprimised) would occur, no?
cant u just create a new process that runs sandboxed from the rest of the bot?
you could just pass process.exit() as the string though, you aren't doing anything to stop that
I mean, that's how I do
You can filter out some globals we've defined as an operation, but not things like eternal globals such as the process object (the process will still exist, although you have to access from an internal binding) 
despite my eval being limited to me only (gotta trust noone)
You could do
const __process = process;
process = undefined;
// eval stuff
process = __process;
and you'll have to do the same for eval, require, Function
evalString.replace("process", "bingus")
and what if one of the strings inside the eval function contains "process"
Also you can access the process in other ways
globalThis.process
bad example
it'd become globalThis.bingus
globalThis["pro" + "cess"]
that's tricky ig
I believe making a sandboxed process would be the best option
no need to worry about globals, just deny any I/O perm
mhm
ok yea i did just double check and i was wrong, process is still available lol. I'm sure I tested that before and it just wasnt a thing ๐ฆ
skill issue
tbh, it does seem like just creating a vm sandbox process would be better
ye, especially since creating new js processes is easy enough
but my game engine runs in browser - so not an option there ๐
hm, that's tricky then
only thing that gets evaaluated is sprite position data though ๐
its not a major concern lol
what if u send the eval code back to the server and create a new process there
if it runs on the browser then it doesn't really matter
true, user will shoot in their feet
just remove eval, ez
Noted, removing the global eval() function from the V8 engine rn
u could use https://github.com/patriksimek/vm2 if you're ever evaling in node but it's not 100% foolproof
y'all really not trust your own eval input
experience told me not to ๐
Nowadays you can barely trust yourself
never trust an user
if you're testing the software, you're the user
never trust yourself
an user
anuser
abuser
client.on('messageCreate', message => {
console.log("hi")
});``` it doesn't print "hi" did i do the `client.on` wrong??
did u send any messages?
yeah
and are you on v13?
im not sure
Well check cause iirc v13 is what made it so message -> messageCreate
do you have message intents
you still need message intents when defining client iirc
well he need to specify it while creating the content to get the event
wait, you still get the message event without content if you dont have the intent?
i made that mistake 
Yup
Yes
do you get the user who messaged too? ๐ฎ
and the content too if the message pings the bot
You get everything on the message except the content of the message
ooohhh, snazzy! ty for the info โค๏ธ
- Ensure that you're using discord.js v13 by using
npm ls discord.js - Ensure that you have the
GUILDSintent, in which is required to receive messages - And lastly check for debug logs if the last 2 solutions does not resolve the problem by listening to the
debugevent listener
Never knew npm ls was a thing
Can you think of anything else that might be able to be abused during eval?
I removed access to those global objects during the eval process which works well enough for that use case, but im wondering how secure i can actually get it
Are you using this on a bot?
atm yes, but its a small class i pulled from my browser based game engine
^ full class
global also exists, every global constructor can get access to the Function constructor easily
ooh yea good call ๐
Array.constructor and others 
i mean, theres only so much i can restrict before there is no point in having such a thing ๐
does nodejs have native fetch package?
Not yet
sad
Are you sure you need this though
Is the input arbitrary data from the user or contained code only written by the dev
Hello. I'm trying to deploy some slash commands and I always get 'DiscordAPIError[50001]: Missing Access', even though I already put applications.commands in the URL scope. Any idea what it could be?
Did u reinvite the bot to apply the new scope?
Yes
Are u sure the source of the exceptions is the deployment of slashes and not somewhere else?
Yes, when I comment the class that is deploying the error goes away
So.. My bot got added to top.gg like 4 days ago and got 100 servers instant I asked for verification but here is the problem
I wanna stop my growth of bot untill it gets verified
This?
It will when u hit 100 servers anyways
Cuz after that nobody can invite it anymore
unless it becomes verified
Did verification increased to 250 limit
Oh wait u got suspicious growth
Yea
Its discords way of telling u "ur bot is on a botlist"
Mean?
Yes
No not fault I am telling that all growth cus of top.gg
Yes
Soo I remove it for now?
A joke is a display of humour in which words are used within a specific and well-defined narrative structure to make people laugh and is usually not meant to be taken seriously. It takes the form of a story, usually with dialogue, and ends in a punch line. It is in the punch line that the audience becomes aware that the story contains a second, ...
No no, the damage was already done
I think if it says suspicious growth u can't get verified
u need a whole new bot account and app lol
Oo lol
but I may be mistaken
Not really, u can
Discord slowly killing top.gg
Their next move will be app discovery ๐
But that means removing a lot of guilds
Yeah
K I will do it
Like how much?
Idk, many
Its current is 200 lel
you can lose at Max 250 cuz of ur suspicious growth thingy
bot.guilds.forEach(g => g.memberCount < 100 && g.leave());
Then u need to get a steady amount of invites across a long period
Like 2-3 months
Instead of 100 guilds/week
Ok what if I let it grow till 250 and it will stop automatically and wait for verification
??
I remember someone I had never met before said I will help you grow ur bot and then they proceeded to make 17 guilds and invite my not
No
It didn't reach enough guilds for verification because I deleted it
That will get your bot removed from top.gg
Well that's fine
Imagine u were trying to invite mee6 but you get dank memer instead
how stupid would that be
That's an upgrade
๐
imagine trying to invite mee6 in the first place
Oo you also verified bot developer owo
Yeee
Which bot?
and not because I specifically made a bot just to get it
Verified stinky
Anti NSFW
Filters messages and stuff
with the power of ai
Did you write the bot yourself?
Yes
Lol Lemme remove bot and come again
Fully
Your 20 stackoverflow tabs say otherwise
I also wrote the api my bot uses lol
Imagine. Cringe.
Hello cheese
Whole reason the badge got removed lol
sadge
Yeah I know 
One message removed from a suspended account.
mac gib me your account for verfied deb badge i will give you 2||.||00000 btc
2 btc? Fine
@rose warren sir ^
Feels bad when you remove bot and it gets removed from trending bot list page 
Yeah that's fine
I'll give you my account for 2 btc ๐ฅบ
my account is almost 6 years old though!
What about early supporter AND verified dev :)
everyone with these cool badges
what about a 5 year 10 month 16 day and 23 hour old account :^)
with no badges
๐
$0
slash commands become invalid in how many seconds?
3
While I'm here, what the fuck is it with websites adding tab bars
I expect that in apps, but I see it on sites like dev.to and it freaks me out
What about an even older account without without without badges?
Whereโs my without without badge badge?
My account is 4 years old am I special
yours isn't older!
mine is 6 months older than yours 
No no no must be a time zone issue
I use detritus, am I special now
Very special!!1! 
.setColor(config.colori.embed)
.setTitle(
`${config.emoji.persona} Server Totali: ${client.guilds.cache.size}`
)
.setDescription(
client.guilds.cache
.sort((a, b) => b.memberCount - a.memberCount)
.map((r) => r)
.map(
(r, i) =>
`**${i + 1}** - ${r.name} | ${r.memberCount} Membri\nID - ${r.id}`
)
.join("\n")
)
.setThumbnail(client.user.displayAvatarURL())
.setFooter({
text: `NOVABOT - Comando eseguito da ${interaction.user.tag}`,
});
interaction.followUp({ embeds: [embed] });```
No err in this code but I have a question.
For slice the list in more than one page, I have to map the servers, slice them and put them inside an embed?
I hope that aint a public command
Your server count
ok
(and shard count if there is some)
Why?
How can I block interaction for buttons and select meno for users different from who used the slashcommand
how many embeds can u send at once?
bro why
If I read that code right, ain't that a servers list?
That's privacy breach
๐
Hmm
??
Another way to clone an array 
After u get verified
Shall I dm you something?
Depends
I don't really have an ETA for how long will discord take to verify ur bot
how can i get member count across all servers
discord.js
client.users.cache.size gets cached, i need theactual total
guild.memberCount
i mean for all servers my bot is in
If you dont have the member intent, anything else wont be accurate anyways
i have member intent
than, it's up to date
ok
then use this guild property
client.guilds.cache.map((guild) => guild.memberCount);
even if FakE doesn't like map()
member count across all servers
shhhh

You didn't see anything
it reutnred 365732 but that doesn't seem right, it used to be 500k+ when i used discord.py lol
ur bot must suck :c

people are kicking it
not left any servers for like 2 weeks lol
get rekt
maybe u aren't doing something properly show cod
var total = 0
client.guilds.cache.map((guild) => {total += guild.memberCount})
total```
am evalling so
Cache
Try client.guilds.cache.reduce((acc, guild) => acc + guild.memberCount, 0) Though ur crooked code should also work
Not all guilds are cached at all times
pretty sure discord.js caches all guilds
Of course they are
client.users.cache.size gets cached, i need theactual total
Though I am not sure if it updates .memberCount on guild join / leave
are you drunk again
But if something is cached at all times, is it even a cache?
It does when the member intent is active
we had this a while ago
not having cache in there implies it's always getting fetched
@spark flint hey you got some py test environment to test something for me?
mb
nah need to get something to test from github
you're welcome brother keep the change
I mean a higher definition one and not just a screenshot of the server icon
seems bright
That's the favicon for the website
bro you dont just shit on someone giving you something for free:(
especially on a brother
that hurts
Sry
its ok
Thx
i have a fun project idea
since i used to be a mod bot reviewing is kinda lame
repetitive
i was thinking a bot that auto reviews
now most bots block other bots but
no one has to follow the rules:)
you can probably scrape the help command for commands with https://wit.ai but the hard part is probably the parameters
Like for the submission process?
I think Xetera wrote some software to automate the process.
to be fair I haven't finished this yet lol
most of the work is still manual
I had an amazing idea for this but it became completely unusable because of slash commands
kekw
how can i set thumnail to local file? vote.setThumbnail('./images/icon.jpeg')
okay so i have a index.js file running 24/7 but it seems to run into some errors often (due to some web-fetching errors) and i do have it log the error but sometimes it just crashes and i have to manually restart it. how would i make it so it ignores these errors, and if it does encounter one, to ignore it? i would use the return function but that would just stop the file from running (its on a vps)
typically you want to catch the errors and handle them, not ignore them.
ignoring errors can lead to more errors
well yes i have it catch and console.log
but then it still crashes
const logo1 = await axios.get(`https://thumbnails.roblox.com/v1/groups/icons?groupIds=${GROUP_ID}&size=150x150&format=Png&isCircular=false`).catch(async err => {
console.log(err)
})
const logo = logo1.data.data[0].imageUrl
let response = await axios.get(`https://groups.roblox.com/v1/groups/${GROUP_ID}/`).catch(async err => {
console.log(err)
})```
and whats the actual error?
status: 500,
statusText: 'Internal Server Error',```
it usually a bunch of lines with this
it restarts by itself but at some points it just crashes
this appears to be a standard http 500 response, not an error in itself.
ideally youd handle these errors by retrying, or stopping the function.
or continue if you dont need a valid response.
yeah but if i stopped the function it wouldnt run again
the function calls itself?
hmm wait do you mean stopping w like return
the function is in a setInterval thing
every 40 seconds
you can return in a function in an interval
so if there was an error, return it and then it'd run again in 30 secs right
i mean i have a return but it doesnt seem to work efficiently
ill test it out and monitor
return doesnt stop any file from running
the only way for a return to exit a process is if the return prevents a long lasting function/listener/cycle/etc from ever starting
also, this code will give you uncaught errors
when you use await together with .catch() the line will return the value that the .catch() function returns if an error happens
is it possible to do proxy rotation in one function? ๐ซ
continue = stop this iteration, go to next
break = stop this loop, go to next
return = stop this function (optionally: and return a value)
meaning if axios.get causes an error here, it will run the .catch() function, and the .catch() function doesnt return anything, which makes logo1 become undefined ```js
const logo1 = await axios.get("url").catch(async err => {
console.log(err)
})
and then this const logo = logo1.data.data[0].imageUrl will throw an error because you cant read data of undefined
o
await something.catch() means return the value of something if it succeeds, or return the value of catch if it fails
hmm so couldnt i just like return it there then
so it stops
cuz if catch doesnt give anything, it'd just return
yes, you can make it return if logo1 is undefined
alr
if(!logo1) return
idk what you mean by that
aka a guard
With axios I tend to await.then(response => {thing = response.data});
i mean, it works, but thats kinda bad design
How so 
if you ever forget await, thing will be undefined
Oh well.
I rarely forget to await my axios stuffz
await axios.get("https://prices.runescape.wiki/api/v1/osrs/latest").then(p => {
priceData = p.data
})
what you're doing is basically c/cpp style of referencing variables
Just how I learned using await and I kinda never tried anything differnet 
avoid rate limit
let priceData
await axios.get("https://prices.runescape.wiki/api/v1/osrs/latest").then(p => {
priceData = p.data
})
I've always done that not really thinking
request api rate limits you if you do it so much, proxy rotation changes IP every request so it avoids that
I NEED A SIMPLE WAY OF DOING THAT
int a;
int b;
somefunc(args, &a, &b)
function somefunc(args, &a, &b) {
a = someresult;
b = someresult;
}
``` c/cpp is weird
is that valid? like, defining an outer variable inside an async method
100% valid ๐
python weirder
weird
Well apparentily it is weird according to Tim aswell.
I'll change up my code to be a little neater knowing I can just priceData = (await axios.get(url)).data
might be weird, but it is valid lel
doesn't look weird to me

you're weird
tim 
idk which api you're using, but the way to change ips is by using the host parameter in your requests to one of your ip addresses
the way to do it depends on what http lib you use
request
I know it's old but good
yep, so what's a good way of doing so
The best discussions are these ones
I may be new to JS and shit, but atleast I'm not asking "why not work!?!??!?!?!?!!?" 
do you have a list/array of ip's? or do you have a reserved ip block?
let item = (await axios.get("https://prices.runescape.wiki/api/v1/osrs/latest?id=" + itemIDFromIndex[0] + "/5m")).data
let sellPrice = item.data[itemIDFromIndex].high
let buyPrice = item.data[itemIDFromIndex].low;
let potentialProfit = sellPrice - buyPrice;
Much better looking than wrapping everything in it's own {} appreciate the tip ๐
xD
also ```js
https://prices.runescape.wiki/api/v1/osrs/latest?id=${itemIDFromIndex[0]}/5m
xD
b4 I knew about that
I literally only use ` now for all my strings / urls, just at the time I made this command which was over a year ago, I didn't even know I could do that 
Even some apis still recommend using the "" + "" stuff like this is just copy pasta code
async function getCards() {
const cards = await axios({
"method": "GET",
"url": "https://api.tcgplayer.com/catalog/products/" + response.data.results + "?getExtendedFields=true",
"headers": {
"Authorization": "bearer " + token,
"User-Agent": agent,
"Accept": "application/json"
},
"data": "grant_type=" + "client_credentials&client_id=" + publicKey + "&client_secret=" + privateKey
});
return cards.data.results
}
tho either or work
""+"" is better to show beginners how basic merging of variables works
ya I can agree with that for beginners
which btw, fuck html header stuff
learning that for my first time, aids.
"method": "GET",
"url": "https://api.tcgplayer.com/catalog/products/" + response.data.results + "?getExtendedFields=true",
"headers": {
"Authorization": "bearer " + token,
"User-Agent": agent,
"Accept": "application/json"
},
"data": "grant_type=" + "client_credentials&client_id=" + publicKey + "&client_secret=" + privateKey
});
xD
yep, I'll prolly either store them in a txt file or call from API
format will be IP:PORT
unless you need something different
I need it bad so what should I use?
idk if it's related, but a library I use that allows my to rotate ipv6's uses a thing like this
if (options.IPv6Block) {
options.requestOptions = Object.assign({}, options.requestOptions, {
family: 6,
localAddress: utils.getRandomIPv6(options.IPv6Block),
});
}
Obviously it's all coded for the library itself, but it does indeed rotate my ip however it works
you can look at the source code https://github.com/fent/node-ytdl-core/blob/master/lib/index.js
is random a good way of rotating? ๐
i mean with a ipv6 block with a billion ips, it does the job well
exports.getRandomIPv6 = ip => {
// Start with a fast Regex-Check
if (!isIPv6(ip)) throw Error('Invalid IPv6 format');
// Start by splitting and normalizing addr and mask
const [rawAddr, rawMask] = ip.split('/');
let base10Mask = parseInt(rawMask);
if (!base10Mask || base10Mask > 128 || base10Mask < 24) throw Error('Invalid IPv6 subnet');
const base10addr = normalizeIP(rawAddr);
// Get random addr to pad with
// using Math.random since we're not requiring high level of randomness
const randomAddr = new Array(8).fill(1).map(() => Math.floor(Math.random() * 0xffff));
// Merge base10addr with randomAddr
const mergedAddr = randomAddr.map((randomItem, idx) => {
// Calculate the amount of static bits
const staticBits = Math.min(base10Mask, 16);
// Adjust the bitmask with the staticBits
base10Mask -= staticBits;
// Calculate the bitmask
// lsb makes the calculation way more complicated
const mask = 0xffff - ((2 ** (16 - staticBits)) - 1);
// Combine base10addr and random
return (base10addr[idx] & mask) + (randomItem & (mask ^ 0xffff));
});
// Return new addr
return mergedAddr.map(x => x.toString('16')).join(':');
};
// eslint-disable-next-line max-len
const IPV6_REGEX = /^(([0-9a-f]{1,4}:)(:[0-9a-f]{1,4}){1,6}|([0-9a-f]{1,4}:){1,2}(:[0-9a-f]{1,4}){1,5}|([0-9a-f]{1,4}:){1,3}(:[0-9a-f]{1,4}){1,4}|([0-9a-f]{1,4}:){1,4}(:[0-9a-f]{1,4}){1,3}|([0-9a-f]{1,4}:){1,5}(:[0-9a-f]{1,4}){1,2}|([0-9a-f]{1,4}:){1,6}(:[0-9a-f]{1,4})|([0-9a-f]{1,4}:){1,7}(([0-9a-f]{1,4})|:))\/(1[0-1]\d|12[0-8]|\d{1,2})$/;
/**
* Quick check for a valid IPv6
* The Regex only accepts a subset of all IPv6 Addresses
*
* @param {string} ip the IPv6 block in CIDR-Notation to test
* @returns {boolean} true if valid
*/
const isIPv6 = exports.isIPv6 = ip => IPV6_REGEX.test(ip);
how it works I guess
I'm afraid of ipv6 if a regex to validate it is like that
same
Whatโs the benefit of that?
I only use it specifically for ratelimiting
I'm mostly just trying to figure out how much 1 billion ipv6 ip's costs
Your public IPv6 has a prefix
That can be banned anyways
No matter what your devices IPv6 is
The base is always the same
Which your ISP does assign to you
That is also true. Tho atleast for now it works 
const IPV6_REGEX = /^...$/ 
not my code 
I feel there has to be a smaller regex for ipv6
a libs
Changing the IP is not the issue
i put the github above
I have your IP 

so ipv6 includes a device prefix? ๐
The issue is your public prefix, still and will ever be
๐ no ideas then?
You usually get a block assigned by your ISP
The size differes from ISP to ISP
As the ipv6 block I'm using it from a proper server, so how many is the question. Regardless, Ill use it until it gets yeeted I suppose
For example I got a /56 block
The entire block will be banned not the single IP when exceeding rate limits
Your block is public when fetching your IP
You know the base then and can ban the entire block
Thereโs no way around that other than using different public IPs (better around the globe)
IPv6 is no solution for anything just a nightmare especially regarding tracking
I fear a future, where nobody memorizes localhost's IP
I fear the future where any fucking device has an unique IPv6 and can be tracked down to hell
imagine not being able to simply write 127.0.0.1
Thanks to any asshole out there thinking IoT is something useful
::1
You gotta be more specific or nobody can help
what kind?
You fetch a member if your library doesnโt have him cached
Well and we canโt help you without more details
If you got an error with your code just post it
If you have questions about what and how to do something then ask them as detailed as possible
after testing a bunch of ways to grep files, including rigrep and ugrep
the normal grep is still the fastest
lmao
nope

Regarding your birthday thatโs just another reason to drink
if i make all my files lowercase, i can grep them all recursively in 5ms
so now the question is
grep ~15mb worth of files in 5ms, or turn them into a 200mb sqlite db to get 0.1ms response times
i dont drink
i spent my bday coding mostly, and running these stupid benches
the only issue is that the index takes a long time to generate
well i didnt optimize it yet
also, i will make a cache for common queries
so in most cases neither grep nor the db will be hit
eh fuck it, i'll stick with grep for now
Yeah I have that issue too
The 466GB index took around 13d
~19 when it wasnโt optimized
You might remember my rsync screenshot
When transferring the database files was faster then regenerating it
um my node modules keep doing this idk how to fix it
const timeout = this.client.setTimeout(() => {
this.client.removeListener(Events.GUILD_MEMBERS_CHUNK, handler);
this.client.decrementMaxListeners();
reject(new Error('GUILD_MEMBERS_TIMEOUT'));
}, time);
this.client.incrementMaxListeners();
this.client.on(Events.GUILD_MEMBERS_CHUNK, handler);
});
}
i was told to comment it out but when i do it crashes
is this on startup?
How can I make a div fit the page height wise
I'm making it start like half way through the page, and h-full makes it extend the page length
100vh?
yep that worked
now new issue
on mobile view the right margin doesn't work
<div class="article w-full rounded p-4 mb-4 text-white items-center justify-center w-1/2 md:w-3/6 m-auto ml-3 mr-3">
<div class="flex my-auto items-center">
<img src="img url" class="w-12" />
<span class="ml-3">How to setup ShareX</span>
</div>
</div>```
that error happens if you try to use guild.members.fetch() without having the GUILD_MEMBERS intent
so i was trying to register aliases in my command handler but I keep getting error like this ```js
command.aliases.forEach(alias => {
^
TypeError: Cannot read properties of undefined (reading 'forEach')```
my code ```js
const fs = require('fs');
client.commands = new Collection();
client.aliases = new Collection();
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
for(const file of commandFiles) {
const command = require(./commands/${file});
client.commands.set(command.name, command);
command.aliases.forEach(alias => {
client.aliases.set(alias, command.name);
});
}```
one of your commands does not have aliases
oh i should put aliases in all commands?
the code you showed expects all commands to have them
ohhhh
otherwise you need to add a check to see if the current command has aliases or not
thanks thanks, this is my first time using normal handler, im done with slappey xd
its okay to leave empty aliases right
yes
๐
bump because i need sleep
guys I need help/ a question
show how you put them in your commands
??
module.exports = {
name: "testing",
aliases: "test",
description: "Testing Area",
execute(message, args) {
message.channel.send("Testing Success")
}
}```
Can you check my question there, please
What do you mean by making the ID public?
your code has command.aliases.forEach(alias => {
.forEach() does not work on text
"test".forEach() is not a thing
aliases has to be an array or a collection
Open your browser inspect tool, scale to a mobile screen size and check if the margin might be overwritten
for example aliases: ["test"]
ok
how would I tell?
module.exports = {
name: "testing",
aliases: ["test"],
description: "Testing Area",
execute(message, args) {
message.channel.send("Testing Success")
}
}``` :/
client.on('messageCreate', message => {
if(!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).trim().split(/ +/);
const command = args.shift().toLowerCase();
if(!client.commands.has(command)) return;
try{
client.commands.get(command).execute(message, args)
} catch(err) {
console.log(err)
}
});``` or i need to call it here too?
you put all aliases in client.aliases
so you need to check if the command exists there as well
should i do console.log?
hmm?
no, you need to do the exact same thing you're doing with client.commands but with client.aliases
or change your file loader to put the aliases in client.commands as well, and get rid of client.aliases
i have client.aliases
Yeah but you dont check if your entered command may is an alias
if(!client.commands.has(โฆ)) return
Doesnโt check your client.aliases
client.on('messageCreate', message => {
if(!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).trim().split(/ +/);
const command = args.shift().toLowerCase();
if(!client.commands.has(command)) return;
try{
const cmd = client.commands.get(command) || client.commands.find(a => a.aliases && a.aliases.include(cmd))
if(cmd) cmd.execute(message, args)
} catch(err) {
console.log(err)
}
});``` changed code to this, still aliases cant be used
I don't see a point in doing a.aliases tbh
Ok so I suck at math so I want to see another opinion:
Lets say I have 10 pages and an array that displays 5 results per page.
If I were to select lets say, page 5, result 2, how would I math the index that result it on.
I've tried a few things like let input = page === 0 ? 0 : page + 6 but that's wrong and also let input = page === 0 ? 0 : page * 5 same for that one.
Page starts at 0 since array index 0 = 1
https://scs.twilightgamez.net/pFz1Y.png
Because you still donโt check if client aliases contains your entered command
if(!client.commands.has(โฆ)) return
If the command wasnโt found you return the event listener
if(!client.commands.has(aliases)) return;```?
Now this would only check the alias and not the command anymore
you need to check for both
If your entered command is not part your client command and not part of client aliases
Is what you need to check for
You just have to slice your array (the one which includes all results) and keep remember itโs index - your offset
First slice would be 0, 5
2nd 5, 5
3rd 10, 5
and so on
The sliced array with 5 results is the one you display
The index aka. offset is your current page number * number of results
Example:
hm
if i do this js if(!client.aliases.has(command)) return; both commands and aliases not working
if(!client.commands.has(command) && !client.commands.has(aliases))
is what he's getting at.
Or how ever you'd have to write it for your code
OHHHH
page 1: slice(0, 5)
page 2: slice(5, 5)
page 3: slice(10, 5)
The first argument of slice is your offset -> page * 5 = offset
The second argument stays 5 as you wanna display 5 results only
let limit = 5;
let offset = current_page * limit;
Only for page 1 you need to check manually as 0 * 5 would be 0
why I had the === 0 ? 0, 1, 2, 3, 4 : stuff
Thatโs static not dynamic
if the page # === 0 then any * 0 === 0 so manually set the index as index 0 - 4
I may be miss understanding, but I get atleast what you're saying with slice
let limit = 5;
let offset = current_page * limit;
if current page == 1 then offset = 0
all_results.slice(offset, limit)
i got new error ```js
client.on('messageCreate', message => {
if(!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).trim().split(/ +/);
const command = args.shift().toLowerCase();
if(!client.commands.has(command) && !client.aliases.has(command)) return;
try{
const cmd = client.commands.get(command) || client.commands.find(a => a.aliases && a.aliases.include(command))
if(cmd) cmd.execute(message, args)
} catch(err) {
console.log(err)
}
});```
a.aliases.include is not a function```
;-;
its working now
thanks @quartz kindle @boreal iron @craggy pine ^^
sorry for the ping, just wanted to thanks
XD
๐
Just one note to that
The second parameter for JS slice() is the index of last item end
Not the count based on the start index
I realised quickly that it was backwards in ur thing ๐
thoughts on how best to handle 'reminders'? I am planning to save them in their own data collection, but would you periodically check that and then send out reminders, or would you set a timeout when registered (also after reboot if needed) and try to trigger at the exact time? (which is the route im considering)
To correct myself it would be:
let limit = 5;
let offset = current_page * limit;
if current page == 1 then offset = 0
result_array = all_results.slice(offset, (offset + limit))

if(message.member.roles.highest.comparePositionTo(target.roles.highest) > 1 ) return message.reply("I can't mute this person!")``` how can i use this properly? myself getting muted instead of the given person, then if i pinged the person its returning the command,
```js
if(target.roles.highest.comparePositionTo(message.member.roles.highest) > 1 ) return message.reply("I can't mute this person!")``` if i do this, even me and the bot has the same role, the bot still cant mute me
and if I'm only trying to get the 1 result from the # they select it would just be result_array[0 - 4] since only 5 results display, the array I'm grabbing has more data than what the embed shows
If you wanna display 1 result per page only then the var limit would need to be 1
Hii
got sorted out in dms
Is it possible to fetch votes from server listings using webhook?? cause its not working
PrefixSchema.findOne({
guildID: message.guild.id,
}, async (err, data) => {
if(data) {
data.newprefix
data.save()
} else {
new PrefixSchema({
guildID: message.guild.id,
Prefix: newprefix
}).save()
}
})``` guildID and prefix is not saving :/ and this is the first time data not saving
use findOneAndUpdate 
thats for another command
im showing the pic cause when im saving new data, guildID and prefix are not saving
i dont think that function is supposed to be in the findOne function
you could probably do it outside some other way
I don't get why you are doing it this way ngl
why-
i dont know if this is even possible, it looks very weird
I don't think you can do it that way
I haven't used mongodb in ages so don't quote me on it
my configurations looks like that, works perfectly fine
i'd do it something like
const data = await PrefixSchema.findOne({
guildID: message.guild.id,
});
if(data) {
data.newprefix;
data.save();
} else {
new PrefixSchema({
guildID: message.guild.id,
Prefix: newprefix
}).save();
}
this didnt work also
ok
whatre you trying to do
per guild set-prefix
saving data
that couldve been one message but ok
schema.findOneAndUpdate({ guildID: message.guild.id }, { Prefix: prefix });
might do something
lmao
is it really required to use console.log everytime deleting data in mongoose discordjs
what
not really
Of course not, logging does not interfere whatsoever with the functionality of the database, itโs just useful for debugging
cause if i dont use console.log the data not deleting
Property 'get' in type 'ApexApplication' is not assignable to the same property in base type 'BaseApplication'.
Type '(data: ApexData) => Promise<void>' is not assignable to type '(data: FortniteData) => Promise<FortniteResult | null>'.
Type 'Promise<void>' is not assignable to type 'Promise<FortniteResult | null>'.
Type 'void' is not assignable to type 'FortniteResult | null'.
9 async get(data: ApexData){
So I haven't used classes in a while so I am unsure of how I can make BaseApplication being able to have its own methods and be usable as well as having the ability to extend it and overwrite methods
overwrite modifier
Wait could I just give ApexApplication get method its own return type and it'd work ๐ค
override*
I didn't know ts had that
TS2416: Property 'get' in type 'ApexApplication' is not assignable to the same property in base type 'BaseApplication'. ย ย Type '(data: ApexData) => Promise<ApexData>' is not assignable to type '(data: FortniteData) => Promise<void>'. ย ย ย ย Type 'Promise<ApexData>' is not assignable to type 'Promise<void>'. ย ย ย ย ย ย Type 'ApexData' is not assignable to type 'void'
Even when using override it still won't let me overwrite the return type and such of the methods
imagine using ts
let test = "hello"
event.test(/*code*/)```What did I need to do that I can use event.hello and not event.test?
what
what what
I did not understand your question
Only thing that comes to mind is that it would be an object
well no, that wouldn't make sense either.
^ pretty much same. I don't think thats really possible
event[test](...);
thanks
is rust the future of low level programming
imo no because the syntax is like struct<'b> { name: &*:/'ted}
println!!!/??!! ((-/:' '("' hrllo world")
At this point use Malbolge
bruh
awesome language: exists
some random weeb: EWWW CRINGE SYNTAX
easy to use syntax language: exists
some random weeb: EWWW NOT COOL ENOUGH
Discord user code913 with a Minecraft golden apple avatar: exists
Some random weeb: EWWW NOT ENCHANTED

this is a no irony conversation
I don't think the syntax is cringe i just want it to be readable ๐
So is C readable?
I find c very readable
what's your definition of readable anyway
is it "can I understand the general constructs applied" or "can I understand what the program is really trying to do"
how many braids do you have to twind before you can clearly see it
Ewwww
My eyes
white-space: nowrap; try with this
Alrighty
That doesnโt allow the text to wrap in a new line at all 
overflow-wrap: break-word
(parent container)max-width: has to be set
You could use an announcement channel in your support server.
Which would practically have the same effect.
Thatโs simply not true. console.log() is completely separate from the functions youโre using. It does not have any effect on what happens to the data
I'm using SQLite3, but for some reason this method returns id and characters correctly:
async function info(id) {
return new Promise(function (resolve, reject) {
db.serialize(async function () {
await db.get('SELECT * FROM daily WHERE id = ?', [id], function (err, rows, fields) {
if (err) reject(err);
if (!rows) {
reject(null);
} else {
resolve({ "id": rows.id, "characters": rows.characters });
}
});
});
});
}
But this doesn't:
async function updateCharacters(id, character) {
return new Promise(function (resolve, reject) {
db.serialize(async function () {
await db.get('SELECT * FROM daily WHERE id = ?', [id], function (err, rows, fields) {
if (err) reject(err);
if (!rows) {
reject(null);
} else {
console.log("id: " + rows.id);
console.log(rows.characters);
resolve({ "id": rows.id, "characters": rows.characters });
}
});
});
});
}
ID is logged correctly, but rows returns undefined.
why are there two functions with the exact same body?
Yea
don't do that
But some peeps are not in the sup server
Just for me !
still
Then have them join and set up the announcement channel
Imagine having 2000+ servers, and sending a message to each one of them without their permission
Much more natural than going through your idiosyncratic process
lol anyway can anyone help me to setup reply and typing thingy for my chatbot?
For testing purposes. I keep trying different methods and changing the code, but updateCharacters always returns null.
The main purpose is to use update to update the user's characters column, but whenever I try to get data from the database rows is always undefined.
Which is strange since the info function works fine. I don't understand what the difference is.
didn;t work
Have a command where they can define a channel to receive notifications, with default being none (no channel = no notifications)
Then use webhooks instead of normal messages, they're made for that
show css pls
Or do smth like dank memer: an alert command that displays recent updates when you specifically ask for it
Or have both
.article {
background: #2b2a2a;
white-space: initial;
overflow: hidden;
text-overflow: ellipsis;
overflow-wrap: break-word;
max-width:75vh;
transition:0.3s;
}```
i was told to try initial liek 2 mins ago
that made it use a new line
why do you have white-space inthe first place
idk
when removed: https://capy-cdn.xyz/dJvKRNGc.png when there: https://capy-cdn.xyz/0Gz8AlX2.png
try overflow-wrap: anywhere;
I can't keep count of how many times people got lost af after I added new updates to my tcg, only to find out they didn't check the updates channel
@spark flint hi
thanks 
Hah
its the worlds simpelist thing
Nice to meet you
nice to meet you too
Ahem.....i am not web dev so idk
;-;
I love hidemymail's ui
@gilded plank
tyty
It all has to do with your pfp

i simp u

How do you use SQLite's Blob data type? I want to store an array in the database and figured using Blob is the best option, but I'm not sure how it works.
litterally just give it some bytes
can i iframe a website in overview ?
not in the short desc but yes in the long desc
that would be an iframe yes
failed
does breaking down long jsx react code into components, improves performance?
not really, but that doesn't really matter, readability comes first in react
just ask

