#development
1 messages Ā· Page 62 of 1
map is a function
Show the code please

so js if (member._roles.some(role => staffRoles.includes(role => role.id))) return 0; else if (member._roles.some(role => highLevels.includes(role => role.id))) return 3600000; else if (member._roles.some(role => mediumLevels.includes(role => role.id))) return 7200000; else if (member._roles.some(role => lowLevels.includes(role => role.id))) return 10800000; else return 21600000;
or am i misinterpreting this
Both are just items of your array, arenāt they?
Im stupid i cant figure out this thing...
I'm making an /emoji-search command
I cache emojis from client by a doecifig term and set it in array now how do i do it like emojis show up in button when i use command and laso when i press button it get added to server?
yeah
So array.some(role => other_array.includes(role));
Iām on mobile⦠takes me a few minutes until im back to my Pc
thats ok :)
yandev xd
???
Idk⦠did you try to hammer your head against your keyboard for st least 10 times? 
if else if (MEME)
yes
lmao
I only wrote it because of the if else, don't worry
ah
C# - didn't expect that there 
Anybody know a dependency where you can input HTML and get a .png returned?
Kinda like making a puppeteer screenshot but without puppeteer
Ping on response
you cannot "input html and get an image"
those libs use some kind of internal browser to render the webpage and THEN screenshot it
as someone who uses shard for the first time in his life, this is good
userCount: async function (client) {
var count = 0;
var shard_guilds = await client.shard.broadcastEval((c) =>
c.guilds.cache.map((guild) => guild.id)
);
shard_guilds.forEach((guilds_S) => {
guilds_S.forEach((guild) => {
count += client.guilds.cache
.get(guild)
.members.cache.filter((member) => !member.user.bot).size;
});
});
console.log(count);
},
html by itself is just code, useless without a browser to interpret it
no
No need of specifically a browser to render HTML and get a picture out of it
just the var or the whole thing?
I mean, yeah u could technically parse the html by yourself into an image
usually to be const much
either use let or const, depending if u need to change the value or not
never var, var is a curse from darker times
Java devs trying to make the world better but infecting 3 billion devices with their malware
smh
without java you'd not have credit cards
php programmer most wanted by interpol

return count why Promise { <pending> }
var count = 0;
const shard_guilds = await client.shard.broadcastEval((c) =>
c.guilds.cache.map((guild) => guild.id)
);
shard_guilds.forEach((guilds_S) => {
guilds_S.forEach((guild) => {
count += client.guilds.cache
.get(guild)
.members.cache.filter((member) => !member.user.bot).size;
});
});
return count;
(for of)
var, again
and use forof for iterating, instead of forEach
forEach is pretty bad for its overhead
that's why var mer const cannot be edited
use let
let is literally the non-psycho version of var
use userCount for retrieving guild user count
or memberCount, I don't remember
instead of retrieving the member cache
yes
console.log anyway
returns the value
then the error isn't there
oo
if console.log is returning the value, that is
tools.userCount(client).then((err) => {
console.log(err);
});
return 4
why
cache usually doesn't keep everything at all times
so it'll never return the real value
How can I find out the truth?
bots filtered out
well that's an issue
pretty good
I don't have any at the moment, I just want to write the user numbers in the status, but it doesn't show the truth
do u have anything that stores users in the database?
Thatās⦠not how that works š
not yet but there will be
it'd be better if u used your database to get the user count
await aaaaaaaaa
^
Otherwise youāll be constantly spamming the API and potentially getting ratelimited
Requests it every 15 seconds
Yeah. Thatās bad
Because there is no āusercountā endpoint, it is getting the counts of each guild one by one
since KuuHaKu said db that's why I'm going to use it
well, db as in any kind of persistence you might come to use
for sql it'd be a simple SELECT COUNT(1) FROM users
"at db" ok
@lyric mountain so how is this api stuff?
Client.js (MEssage create)
if (message.author.bot) return;
if (message.channel.type === 'DM') return;
// Add a connect listenerű
let prefix = cc.prefix;
let lang = cc.lang;
socket.emit('getServerData', {
guild: message.guild,
});
socket.on('getServerData', (res) => {
prefix = res.prefix;
lang = res.lang;
if (message.content.startsWith(prefix)) {
const [cmdName, ...cmdArgs] = message.content
.slice(prefix.length)
.trim()
.split(/\s+/);
const command = client.commands.get(cmdName);
if (!command.data) {
if (command) {
command.run(client, message, cmdArgs, prefix, tools);
}
}
}
});
ws (socket.io)
let con = app.con;
socket.on('connect', (socket) => {
socket.on('getServerData', (res) => {
con.query(
`SELECT * FROM guilds WHERE id=? LIMIT 1`,
[res.guild.id],
(err, row) => {
if (row.length === 0) {
con.query(`INSERT guilds SET id=?, name=?`, [
res.guild.id,
res.guild.name,
]);
}
socket.emit('getServerData', {
prefix: row[0].prefix,
lang: row[0].lang,
});
}
);
});
});
problem š¢
for the second message, the socket returns value twice
Because u have .on inside .on
So for each connect event, u start listening to getServerData
Connect doesn't happen only once
Second line from ur second code
ok, but if there is no connect, the socket will not receive the other events
why
for the second message, message content console.log
duble send
bug fixed
what's the error again? sorry I'm a bit off
u don't need to register events inside connect
connect is an event by itself
put inside it what u need to run after estabilishing connection, ONLY
not other events
I've been using it ever since and it works perfectly, so thank you for your kindness, kisses on the cheek ā¤ļø
doesn't mean it's the proper way to do it
this is the problem
${userFtchd.username}#${userFtchd.discriminator} is the issue
a member object doesn't have that properties
an user object does
so access the user object
userFtchd.user.username
userFtchd.user.discriminator
or much more easier
replace ${userFtchd.username}#${userFtchd.discriminator} by ${userFtchd.user.tag}
The Discord "tag" (e.g. hydrabolt#0001) for this user
š
bro can someone add Rem the discord bot because im trying on fucking top.gg but it does not wanna work
Ok i don't know if this is a problem or if its a result of them not being in the same server as the bot, but rn it only displays the people from one server
pls help me i want the rem bot
dude, this isn't a support server for whatever bot
jesus christ im just saying i cant get the fucking bot i do the im not a robot type of shit because i am trying so fucking hard and i feel like ninja losing fucking fornite
This is not the channel for that, chill out
Go to their support server
We donāt know anything about specific bots
nvm
sure, what's up
i dont fucking know where the fuck is the fucking support server
ok so whenever it continues (after finding users thats no longer in the same guild as the bot), it just skips them. I want to then place #4 to #3, #9 to #4 and then keep going like that until it reaches #10
you need to do it differently entirely
push them to a new array for example
something like that
const users = UserProfiles.sort((a, b) => b.bank - a.bank);
const members = [];
for(const user of users)
{
const guild = interaction.client.guilds.cache.get(user.guildID);
if(!guild) continue;
const member = await guild.members.fetch(user.userID);
if(!member) continue;
members.push(member.user);
if(members.length === 10) break;
}
for(let i = 0; i < members.length; i++) embed.addField(`#${i + 1}`, `${members[i].tag} - \`⬠${fNum(user.bank + user.wallet)}\``);
keep in mind what I said earlier
that's an horrible solution and you will get ratelimited hard, probably
im trying somehting rn
what I wrote as example will iterate through your user list until you have 10 reachable members
or until any sorted user has been "looped throgh"
will it could happen, yes but probably not
it would make sense to store 10 user IDs in an array then request them at once but yeah...
I assume you will be fine, might take a second or two
ok so when i try to log the money thats in [i]'s bank, it somewhy logs 2 different banks
it logs [i]'s bank and someone elses
let dbUser = await UserSave.find({ userID: `${members[i].id}` }); console.log(dbUser[i].bank)
when logging
it logs [i]'s bank and one other bank
the other bank is the same bank if i log dbUser[x] (x = any number)
Whereās the code?
Inside the loop?
Also why dbUser[i]?
Is it an array as result of your database request?
I doubt
There are two for loops 
Just show me a screenshot of the code please
Ah I see what u mean
I didnāt notice the user.bank and wallet
before members.push(ā¦) just add member.user.data = user;
Then in your last line when pushing the embed field change user.bank to members[i].data.bank
Same for wallet
I didnāt notice you actually donāt need the entire user object, but just the tag
Gonna update my code real quick
const users = UserProfiles.sort((a, b) => b.bank - a.bank);
const members = [];
for(const user of users)
{
const guild = interaction.client.guilds.cache.get(user.guildID);
if(!guild) continue;
const member = await guild.members.fetch(user.userID);
if(!member) continue;
user.tag = member.tag;
members.push(user);
if(members.length === 10) break;
}
for(let i = 0; i < members.length; i++) embed.addField(`#${i + 1}`, `${members[i].tag} - \`⬠${fNum(members[i].bank + members[i].wallet)}\``);
This one will do the job
Yeah this doesnāt include a check if the member exists in multiple guilds
Log bank and wallet
would that be hard to do
same
this kinda worked but at the same time not
wdym
now the code is exactly this
console log bank and wallet inside the second loop to see why itās NaN
yep
Lemme see if the property was already used
One second
Please add console log user directly after members.push()
And show the console log output
Oh the object is probably frozen
Ok try to replace the line user.Tag = member.tag by:
let tmp = user;
tmp.tag = member.tag;
members.push(tmp);
Donāt add two times members.push() please
I assume the database result is a frozen object which means we canāt modify it like adding the tag property
We will know for sure if thatās working
Why topten.length
And Not members.length
Also remove the database query of the second loop
Entirely
Ok itās still not editable
Wtf
Ok then letās do this:
const users = UserProfiles.sort((a, b) => b.bank - a.bank);
const members = [];
for(const user of users)
{
const guild = interaction.client.guilds.cache.get(user.guildID);
if(!guild) continue;
const member = await guild.members.fetch(user.userID);
if(!member) continue;
members.push({ tag: member.user.tag, data: user });
if(members.length === 10) break;
}
for(let i = 0; i < members.length; i++) embed.addField(`#${i + 1}`, `${members[i].tag} - \`⬠${fNum(members[i].data.bank + members[i].data.wallet)}\``);
This will work
Dunno why the copied object wasnāt editable, too
Thatās beyond my JavaScript knowledge
tag is still undefined
The tag property does not exist on a guild member
You're supposed to access the user property which is the user object of the guild member, and then access the tag property
so member.user.tag?
Yes

Man i fucked up my own shit
Told him it doesnāt exist and still provided the wrong code
lmao
I updated the code above
But Iām working right now
So Iām not available unfortunately
It's alright FakE you just need some rest from all that driving 
For real
Couldnāt even remember what I was telling him 5 mins ago
Thatās the critical line
Guess Iām too old already for this shit 
those mins over?
Go ahead
Still something wrong with it?
We blame Voltrex then for it

Oh no
Heās still here
nope, just need help making the code that makes it max 1 guild per user
so like the guild they have the most money in
Uhm
Why didnāt you tell me that earlier?
You just want the highest user per guild in your leaderboard?
no
.
Ah
Quite simple
All you have to do is to search members before doing members.push() if thereās already an user object with the same ID in there
If so, you edit the wallet and Bank properties and add the current value to it
The inventory etc doesnāt seem to matter for this leaderboard, so it doesnāt need to be changed
anyone know the code to keep a bots message at the very bottom even if someone sends a message into the text channel?
Right before member.push()
I hate mobile coding
Lemme paste it together
const users = UserProfiles.sort((a, b) => b.bank - a.bank);
const members = [];
for(const user of users)
{
const guild = interaction.client.guilds.cache.get(user.guildID);
if(!guild) continue;
const member = await guild.members.fetch(user.userID);
if(!member) continue;
const findUser = members.indexOf((member) => member.data.userID === user.userID);
if(findUser)
{
members[findUser].data.wallet += user.wallet;
members[findUser].data.bank += user.bank;
}
else members.push({ tag: member.user.tag, data: user });
if(members.length === 10) break;
}
for(let i = 0; i < members.length; i++) embed.addField(`#${i + 1}`, `${members[i].tag} - \`⬠${fNum(members[i].data.bank + members[i].data.wallet)}\``);
tysm!
Err that will not work
find creates a new array
One second
Lemme edit the code once again
should be working bow
Thank you auto correct
Is it possible to simulate document.active whilst it isn't active using puppeteer
?
Window focus*
@tribal crow keep my update in mind
ive got a lil bit right here
const mentioned=roleIDs.some((roleId) => message.content.includes(roleId));
returns t/f ofc
however i need the id
any idea?
damn i talk everyone dip š
I don't understand the question
use find
or filter with includes if you want more than one id
Isnāt weirdish an official American language?

const mentioned=message.mentions.roles.find(role=>roleIDs.includes(role.id));

Country accents
hi, i need a help with C's variadic arguments
this is the main function that declares it:
size_t args_count = cprintf_count_args(start);
printf("args count: %d\n", (int)args_count);
if (args_count == 0) {
return false;
}
va_list vl;
va_start(vl, args_count);
then that function calls another function and passes the va_list to said function, it seemed to have crashed here:
const char * s = va_arg(vl, char *);
i don't see any reason to crash here, anyone have an idea?
do va_list only work if it's used in the same function that declares it?
Because of some Limitations I need to set my postgres db to C.UTF-8 instead of de_DE.UTF-8, will that break anything?
I don't think postgres uses anything other than utf8
Mysql is the weirdo that has 533 different collation for each table
Whatever ur doing is probably related to database locale, not charset
In which case, it'd only break local datetime, since the timezone offset would change
So you'd need to update your columns to reflect this change
You can C your way out of development channel

you're not helping
socket.emit no?
check the docs then
tho I'd recommend using actual websockets instead of socket.io
but it depends on what ur using it for
its for a lil proxy system im making
using a websocket is proving to be more efficient
for my bot, its making API request to a user set URL, and its making the request from a 2nd VPS with all the details being sent via websocket
you should use a websocket then
socket io has way more overhead than a normal socket
plus it's not guaranteed to use sockets 100% of the time, it'll happily switch to polling in certain situations
you are passing a size_t, which is not a char, try casting it.
Quick question, does HTML or MD work while making a Long Description for my bot?
yes both work
Ah okioki tyyy
Does it have to be char though? Documentation and examples on va_start are very ambiguous in the internet, i've seen people pass in ints
yes you can pass in ints, but you have to tell the compiler what type of argument you expect the va_arg to return, in this case you are getting a string so you have to tell it that you are getting a string (char *), now if you want to use int, you will have to tell it that you are getting an int argument with the va_arg, there are many types you can use, you need to find the one that you want and use it in the va_arg, if you want to pass a string, use char *, if you want to pass an int use int, etc...
hmmm, so basically, what does va_start even do?
what do you pass in the second argument
it confuses me

It sets up the internal variables for va_arg to work
the name of the first non-variadic argument. It doesn't do anything, it is just there so that the compiler knows the type of each variadic argument
i see

fixed it, apparently it was because of me passing a va_list by value instead of a pointer (i expected for va_list to be an alias to a pointer type... oh well)
reference stack overflow thread: https://stackoverflow.com/questions/3168056/va-arg-returning-the-wrong-argument
congrats š
how did this even segfault
i literally just called a function
main.c:
#include <cprintf.h>
int main(void) {
printf("a\n");
cprintf(NULL, "What's your favorite color? %fr\n", "red!");
// ...
}
cprintf.h:
#include <stdarg.h>
typedef struct { ... } cprintf_t;
// CPRINTF_EXPORT expands to nothing in unix
CPRINTF_EXPORT bool cprintf(const cprintf_t *in, char *fmt, ...);
cprintf.c:
#include <cprintf.h>
CPRINTF_EXPORT bool cprintf(const cprintf_t *in, char *start, ...) {
printf("CALLED\n");
// ...
}
``` `a` is printed to the console but not `CALLED` for some reason, it worked in Windows but not in unix platforms
I think the cprintf function is getting called, but you're passing a NULL pointer as the first argument (in).
what's wrong with that? the NULL pointer hasn't even been used yet
using NULL does not automatically mean immediate segmentation fault
The function dereferences it at the start, so it's probably crashing right away
And you should use const char* instead of char*, since you're not modifying the string
no, it clearly didn't, the first line is printf("CALLED\n");
Assuming that in is a pointer to a struct, it will try to dereference it to get the first member of the struct
oh wait, I think the problem is with the va_list argument in cprintf.c. It should be va_list args not char *start, ...
no? that's how va_list works
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
wait
no, it clearly didn't, as seen here
The function that cprintf() calls isn't visible outside of the current translation unit because of the CPRINTF_EXPORT macro. On Unix, this macro expands to static, resulting in the function being local to the translation unit. On Windows, this macro expands to __declspec(dllexport), which marks the function for export from the DLL
no, it doesn't, in cprintf.h it's declared as follows:```c
#ifdef CPRINTF_DLL
#ifdef CPRINTF_BUILDING
#define CPRINTF_EXPORT __declspec(dllexport)
#else
#define CPRINTF_EXPORT __declspec(dllimport)
#endif
#else
#define CPRINTF_EXPORT
#endif
You need to compile both cprintf.c and main.c with the same definition of CPRINTF_EXPORT. What you currently have is a mismatch between the definition of cprintf.c and main.c
I stand corrected. You're not building a DLL, so the CPRINTF_EXPORT macro expands to nothing.
mhm
i was just testing in WSL
i never said i was
oop looks like i fixed it on accident
it worked when i tried to compile main.c with an object file (cprintf.o) but not when i archive it to a libcprintf.a for some reason
i love C/C++ linking so much ā¤ļøš

That's because the non-DLL build is using the static library. The problem is that a linker warning has been flagged as an error, and cprintf() ends up being undefined

i understand nothing on what you said

You are using the non-dll build of the runtime and you are not linking to the static CRT library (msvcrt.lib), so cprintf() is not found
there we go
no
not at all
it working in an object file does not give any clue to what's happening
try this
main.c:
#include <cprintf.h>
int main(void) {
printf("a\n");
cprintf(NULL, "What's your favorite color? %fr\n", "red!");
// ...
}
cprintf.h:
#include <stdarg.h>
typedef struct { ... } cprintf_t;
// CPRINTF_EXPORT expands to nothing in unix
bool cprintf(const cprintf_t *in, char *fmt, ...);
cprintf.c:
#include <cprintf.h>
bool cprintf(const cprintf_t *in, char *start, ...) {
printf("CALLED\n");
// ...
}
I did a lot of stuff, but the main thing is that I removed the CPRINTF_EXPORT from cprintf.h and replaced it back in cprintf.c after the function prototype 
removing CPRINTF_EXPORT won't do anything, since it expands to nothing
I see, but it actually did something. It changed the function name to cprintf in the header. So when I built it and then did nm on the resulting object file, there was no "_cprintf" in the object file, but there was a "cprintf"
but if you want to use that too, wait
main.c
#include <cprintf.h>
int main(void) {
printf("a\n");
cprintf(NULL, "What's your favorite color? %s\n", "red!");
// ...
}
cprintf.h:
#include <stdarg.h>
typedef struct { ... } cprintf_t;
// CPRINTF_EXPORT expands to nothing in unix
CPRINTF_EXPORT bool cprintf(const cprintf_t *in, char *fmt, ...);
cprintf.c:
#include <cprintf.h>
CPRINTF_EXPORT bool cprintf(const cprintf_t *in, char *start, ...) {
printf("CALLED\n");
// ...
}
Output:
a
CALLED
What's your favorite color? red!
what did you even change
that's a part of the library
%fr is not a valid format specifier 
%fr will make it print as a red text on the screen
cprintf is a custom function from the library, which is !== to printf
If %fr is used, then the program will try to print floating point numbers as a string, and since we are not passing in any floating point numbers as an argument to cprintf(), the program will try to access null pointers and will give segmentation fault error. Thus, %fr was replaced by %s
stop talking about the %fr, it has nothing to do with the segmentation fault
the problem is that the program can't even reach the first line of the function, that is printf("CALLED\n");
the main part of the problem is probably on linking it
well removing the %fr worked, I can't help you then if that's not what u want
you were mistaking cprintf with formatted standard library functions like printf
Just wanna ask bot devs here if u have any idea: can bots start forum posts? what about webhooks?
hey guys i have a question about c++ arrays.
Imagine my max is [40][60] in a 2d array.
Why must i use <= in a for loop when writing to the array
but only < when reading?
for(int i = 0; i < NO_OF_ROWS; i++){
for(int j = 0; j < NO_OF_ROWS; j++){
(universe[i][j] == Live) ? d = LIVE : d= DEAD;
test += d;
}
test+="\n";
}
cout << test;```This is reaing
for(int i = 0; i <= NO_OF_ROWS; i++){
for(int j = 0; j <= NO_OF_COLUMNS; j++){
z = input.get();
if(z != EOF){
if(z == LIVE){
universe[i][j] = Live;
}else{
universe[i][j] = Dead;
}```writing
does it change if you switched from <= to < though
that's called undefined behavior
you were accessing/modifying the array out of bounds
<= won't work since it would access the array out of bounds in the last iteration
so strange
if i run a google test wihtout <=
it tells me that the array is not correct
i will show some more code one moment
bool read_universe_file(string filename, Cell universe[NO_OF_ROWS][NO_OF_COLUMNS])
{
ifstream input;
char z;
input.open(filename);
if(!input.fail()){
for(int i = 0; i <= NO_OF_ROWS; i++){
for(int j = 0; j <= NO_OF_COLUMNS; j++){
z = input.get();
if(z != EOF){
if(z == LIVE){
universe[i][j] = Live;
}else{
universe[i][j] = Dead;
}
}else{
input.close();
return true;
}
}
}
}else{
return false;
}
// pre-conditions, post-conditions, implementation
}```
it's not strange
consider this:```js
const array = [1, 2, 3, 4];
for (let i = 0; i <= array.length; i++)
console.log(array[i]);
``` the last output would be undefined, right?
yup because its index starts at 0
however that isn't what i find strange
it's rather that my google test is telling me that it doesn't work until i use <=
instead of <
probably because of EOF
the last item in the array is reserved for the EOF character
how can i fix this?
by not responding to the interaction before, you have done so on that one if check and done so in the end
I don't miss this chat
I miss developing discord bots but I also donāt
nub
pg.query("INSERT INTO premium(id, name, age) values(18, 'Grainger5445', 18)", (err, result) => {
if(!err) {
console.log("Here is the resul: " + result.rows);
}
console.log(err, result)
pg.end();
})
Ok so i am trying to insert data using postgres but when i open pgadmin the data doesn't show up in there
Yea no
also, make sure ur committing the transaction
it's just for testing purposes
hmm?
most pg libs work with transactions
think of it as a "bulk edit"
it doesn't confirm the changes until u commit
it makes sure there are no concurrency issues
O(365) at best case scenario lul
i am not finding the command to actually commit
using this?
https://www.npmjs.com/package/pg
yes
iirc, if you're just using queries you don't need to commit. that's only for transactions.
then why is it saying no rows found on pgadmin
what's tje result and/or error?
Result {
command: 'INSERT',
rowCount: 1,
oid: 0,
rows: [],
fields: [],
_parsers: undefined,
_types: TypeOverrides {
_types: {
getTypeParser: [Function: getTypeParser],
setTypeParser: [Function: setTypeParser],
arrayParser: [Object],
builtins: [Object]
},
text: {},
binary: {}
},
RowCtor: null,
rowAsArray: false
}
hmm, looks like 1 row count was affected
and you're sure the table doesn't hold the row?
positive
inserting multiple times without ignoring should return an error
so if that's not the case, it's indeed not inserting
is the database locked?
how do ic heck
what's the command for that
if db was locked it'd fail
both optimistic and pessimistic locks would return an exception
bruh i cannot find anything about commits

i might as well be blind
how can I make a function require json options so it shows in vscode? (nodejs)
either jsdoc comments or typesdcript declarations
how exactly would the jsdoc be for jsons?
Well they can, JSONs with comments exist but you can't declare a type definition for it in it's own JSON file
{
"comment": "This is technically not a comment"
]
I think I wrote that bad, I have a json object as an argument and want to document its possible values
that's uhhh...I don't think reverse documentation is possible
not without a model
Then you can use JSDocs, using the typedef directive allows for such declaration, for example:
/**
* @typedef {object} Bar
* @prop {string} baz
* @prop {number} [biz]
* @param {Bar} bar
*/
function foo(bar) { ... }
You can also do it this way:
/**
* @typedef {object} Bar
* @prop {string} baz
* @prop {number} [biz]
*/
/**
* @param {Bar} bar
*/
function foo(bar) { ... }
To separate the typedef declarations
thank you so much!
how can I put multiple jsdocs in one file without them overlapping each other?
Everyone stop coding, and start reviewing: https://eloncodereview.com/
Print out your last 30/60 days of code and Elon Musk will review it.
I don't think almost anybody here will want to do that, especially with spaghetti code 
ah yes have my spaghetti code be used on rockets
either submit your code or get in the bread line
I guess Tim will need quite a few more donations
To buy that
finish typing voltrex
can't wait the entire day for you

They won't overlap, as long as you're not declaring typedefs alone with conflicting names, other than that it won't ever overlap with the other type definitions
How about you stop talking in development and go back to driving, your car can't wait the entire day!
lol
shut up 
Why dd is so fucking slowly, Mr. Voltrux?
should probably use rsync instead
my fucking gosh
that will take forever
Hey
Does anyone know why a server would refuse to load my bot's Integrations.
There's a server that persistently wont show my bot on its Integrations page thus loads no slash commands. I can't recreate it on my server or a test one at all (The bot is in 4 shards total)
It works for them literal days after an update but whenever the bot is update that server has like 2-3+ days of downtime
Did they already try to kick the bot and reinvite?
Yep multiple times
probably a broken server then
saw already so much people complaining about issues with bots, permissions, guild settings not saving etc.
how many integrations are in that server?
iirc the limit is 50 integrations
Maybe 30+
Yep, I counted and they have 50 total @lyric mountain
tysm.
I notified the issue was that
lul
must be chaos
https://hastebin.com/xobeyoqeko.js
Fixed unreadable code due to indentation 
I couldn't imagine 50+ bots in one server. We have like 20 and that's more than enough to accomplish everything we need them to and even have backup automod in case one goes down for maintenance
top.gg literally had 5000+ bots in the server at some point
Dammmnnnnn
every single approved bot was added
That's a bit different though it's not a regular server
ye lul
Was like 12k+ awhile back before we purged them.
I think Xig or Marco used a bot.
ah yes, fire to kill fire
Im sure that is going to be possible in the future
It is, people use fire to deprive fire of oxygen
{ ...object[key], key: key }
This is in an object.keys for each loop,
Let's say object[key] is { "test": true }
The end result would be { "test": true, "key": key } right?
Or else how would I make that happen
(I'm converting an object to an array and I want to know each key when changing data in the original object, I'm iterating over the array to find something)
yup nvm
yes, the spread operator works in objects similarly to how it works in arrays
everything in js is objects, and as such they all have constructors
there is new Array, new Object, and lots more

in practice tho, most of these are useless, except for very specific use cases
new Array for example has one specific use case
if you need a fixed size array and you know the length, new Array will give you better performance
for example
there are no fixed size arrays in js, but its possible to initialize an array with a starting size using the Array constructor
which gives you a performance boost as long as you dont exceed it and force the array to be resized
no stinky reallocations needed
i'll reallocate you
reallocate me to a university I want to go to please
you will be reallocated to brazil
if I get to live near you and kuuhaku then I accept
Can anyone plz tell me what to write in code so that when the button is clicked, then the message gets edited
(Slash command v13)
we don't spoonfeed code here, sorry
I did not mean that, just tell me the function to use! That's it
Largatha
interaction.editReply()
or interaction.update()
dont remember which
Ok ty
lets say I do something like this
urls.add('/ok')
urls.add('/aaa')
console.log(urls)```
How can I make the result be
```{
"/ok": 'ee',
"/aaa": 'ee'
}```
? (nodejs)
Yes I need a custom function for it
list != map
and no u dont need a custom function for it
even if I want functions as content?
u didn't say u wanted functions as content
"/ok": async() {
console.log('hi')
}
}```
well I want both
a function to add functions under urls
urls['/endpoint'] = theFunc
can I do it with a custom function?
function foobar(endpoint, func) {
urls[endpoint] = func;
}
it's literally the same thing
just boilerplate
does that also work if the function is in another file? aka that the variable gets assigned correctly?
what variable?
urls
urls is supposed to be in a single, main file
not in many files
can u give me the full context?
ok, scrap that, I got it.
Why cant I assign this the urls directly though?
I think u need to declare the field beforehand
also u dont need to export it that way
u can export the class directly
this is the error when just using this
because this cannot be anything else than this
it's the same as saying "Blue is yellow" or "I am him"
I am i, this is this
how can I then make this.urls be the default thing that you get when accessing the class?
you don't
that's now how oop works
you can, however, extend map
that way URLgen will be a subclass of Map
š§
"Accessing the class"? If you want all of it's values to be reset so you can use it multiple times that's already what you're doing, it's a class and you can instantiate multiple instances of it
In which, all of the instantiated instances will have their own values, the default ones in your case if you want to call it that
Unless you mean you literally want this.urls object to be returned when you access the class, which won't work because that's not what classes are
You can just use an ordinary class, hold this.urls as a property, and access it like <ClassInstance>.urls, which would work just fine
theres nothing wrong with that code
that's the working code
ah i misread
what they tried to do is
class URLs {
constructor() {
this = {}
}
set(url, code) {
this[url] = code
}
}
...
const urls = new URLs()
urls.set("foo", "bar")
technically a class is already an object, so basically this is already an {} after you use new Thing()
it'd work, without the constructor
yeah
tbh the whole thing makes no sense, as I said before it's just boilerplate
const urls = {}
urls["foo"] = "bar"
hey guys i still can't figure out postgres
i am commiting but it doesn't seem to work
Result {
command: 'COMMIT',
rowCount: null,
oid: null,
rows: [],
fields: [],
_parsers: undefined,
_types: TypeOverrides {
_types: {
getTypeParser: [Function: getTypeParser],
setTypeParser: [Function: setTypeParser],
arrayParser: [Object],
builtins: [Object]
},
text: {},
binary: {}
},
RowCtor: null,
rowAsArray: false
}
dies
Might seem dumb, but are u connected to the right schema?
yes
is there a way i can log the branch i am at
but i am pretty sure it's the same one
since it's giving me no errors
I'm working on image processing, I have a nice large array full of rgba but each rgba values are not in invidual arrays
Aka, 0,0,0,255,0,0,0,255 (2 pixels)
What would be the best way to sort this?
Uint8Array*
Possibly .subarray() whilst iterating?
Or .slice?
convert int to individual colors
(num >> col_index * 8) && FF
RGBA = (num >> 8) && FF
šØ
RGBA = (num >> 16) && FF
i am beginner this is intermediate
this is beginner tbh
šØ
int colors are just arrays but as a number
š„¶
that ain't how it works
R,G,B,A?
no
That's how I receive it
no, u receive the number
the number is what u want
FF FF FF FF
R G B A
tho usually I see A at the 4th index
but anyway
it'd be the same as [255, 255, 255, 255]
if u convert to hex [FF, FF, FF, FF]
then if u append FFFFFFFF which is a number
all u need to do is access the index for the tone u want
(num >> 8) & FF is the same as num[1]
What does ">> 8 & FF" do?
I think you're gonna have to spoon feed me for this one
š
u kinda lost all my respect after that one
You aint here
Simply because I do not understand
just follow the damn formula (num >> index * 8) & FF
replace index with the index of the tone u want
num is the number
what are those?
What I believe I needed
I know
then use it?
About right
tho u should learn how to extract colors too, very few apis will return pixels as an array
"what could go wrong"
"If it works, it works"
where did I put that cow meme

8 bit int aka 0 - 255
How could I make this a 0 - 1 float?
you dont
well, u could, but why?
for that it's simple rule-of-three formula
value * max / total
or just divide by 255 lol
yes, I just passed the formula
Am I missing something when trying to get an iframe to appear on my bot page?
It doesn't seem to work regardless of what I do
How are u writing it?
Also, is the site https?
Yes
<iframe id="iframe-website" src="https://ticketking.xyz" />
Well self-closing is guaranteed to not work
Who's your ssl provider?
Cloudflare?
Yes
any errors in the console or network tab?
it should have an error there if the iframe refused to load or was blocked
tried force reload / disable cache?
try a different browser
I just did
Nothing
I have it live on https://top.gg/bot/710034409214181396 but it doesn't work
indeed theres nothing there
either top.gg broken or its removing the iframe, or it didnt save/update your changes
ask #support
š¤ I'm assuming you solved it, seems the iframe is working
Perhaps it's browser issue, if woo can see it
Hi. Guys I am looking for best and affordable hosting for my small bot that I am planning to expand in near future. Do you guys have any recommendation?
A help would be appreciated a lot. Btw I am looking something for bot with around 1000 servers.
Free feel to ping if you want to help me regarding this :)
Contabo
Also u don't need to worry if ur target is 1k servers
That's very little for a computer
Unless your code is terrible, that is, otherwise focus on polishing it along the way
1k could probably be hosted on free hosts like oracle tbh, unless itās a music bot
Youāre missing the permissions to create application commands in your guild
Thereās no permission to set just a scope you have to invite the bot with
Then kick the bot and reinvite it using the link including the appropriate scope
o okioki
I was searching online and found about digital ocean. What is your opinion on that?
Which one is better digital ocean or contabo?
Nope it's not a music bot but I am planning to go with basic option that usually have 1 CPU and 1 GB RAM
DO has just the largest amount of bots and compromised servers I know
Literally already blocked like half of their entire network
(probably more)
Not much better than OVH tbh
Use contabo.
use DO
can't you just use
num & 0xFF; // alpha
num & 0xFF00; // blue
num & 0xFF0000; // green
num & 0xFF000000; // red
this is basic bit manipulation
(num >> color*8) & 0xFF;
Yes, and that's how it should be done as well
bit-masking is awesome tbh
Not sure why over complicating stuff
This is my button handler. Plz tell me what to write in code so that, only the command user can use the button and if any other person use it, the bot replies- You cannot use this button!
Bc i am doing buttons for the first time
Related to discord.js
Plz help!!
I-
nope
0xFF = 255
0xFF00 = 65280
vps or just a discord bot hosting service?
you need to shift the bytes to the first 2 spots to get a 0-255 range
Just need to host my discord bot and make sure it never goes offline
the formula I passed is the shortest form already
shift index * 8 bytes to the right, mask out other bytes
Plz help!
well, plox.host has a scalable option
oh well
$4 for unmetered ram is kinda worth it tbh, plus the location is great so youll get low ping
havent tried it myself since i dont really have a bot to scale but i think you should try it
I have never heard of that hosting. Do you think it is good one?
many people recommend that to me, i personally dont have any projects that needs more than 4gb ram so i rather choose another hosting service just for 1gb of ram that costs $1, but plox.host should be better if you wanted to scale
though i hardly know a bot that uses more than 4gb of ram other than music bots, so its up to you and your bot requirements
The bot I have will only have simple fun commands like all other bots and some moderation commands and nothing special
Why music bots takes so much ram?
Old big music bots used in thousands/millions of servers take hundreds of GBs of RAM 
depends a lot on how its built, but for example if a single mp3 file has 3-5mb, put 100 of them in memory and its instantly 500mb, plus if you need to convert the stream into discords format, then its pretty much double the amount for holding the original plus the converted, then when you switch tracks you basically quadruple the amount until the old files are properly freed from memory
WOW! Still people developed them that shocking
Now everything makes sense
but the worse is not really memory, its the cpu it takes to convert the audio format live
unless all your files are already discord compatible
but stuff like youtube for example is not, it needs real time conversion
Tim what you think how much a bot like mee6 takes when it comes to ram and cpu?
Gotcha. I did not know that music bots are so much complex behind the scene.
Yeah
but they probably use distributed systems at that point, so its not a single server
I have a similar kind of bot that is very simple then mee6 and have some everyday commands
for example split the bot into 10 separate servers, each with 256gb ram and 32 cpu cores
btw can i personally contact you to fast my bot review ||jk||
or if they use stuff like kubernetes for example
tias
then its like thousands of small servers
what is kubernetes?
container orchestration system
does that means yes in some secret language? lol
there is no fast tracking for bot reviews
Mostly used for easier software deployment, scaling, and management
try it and see
it seems something cool and worthy to learn
yes i know i was just joking
kubernetes is like
you give it a piece of code
and it spawns servers for you as needed
nooooooooo never
k8s are pog
Wanna make discord bots for people and get money from it, I already made a fiverr gig but does anyone else know where I can get some work?
so as you grow, more and more servers are spawned with the same code
automatically
gotcha
that's why I dropped my music module long ago
not worth all the headache and resource drain
Sorry if this is the wrong place to ask, but my discord bot has reached 100 servers and I feel uncomfortable giving discord my ID. If anyone wants to join as a maintainer and help verify it, I would greatly appreciate it. https://top.gg/bot/835198432796737536
I abandoned it for some time because of the ID requirement, but recently started to work on it again
Links are currently dead right now, but stack is discord.js, but I've been moving it to typescript. Maintaining the bot isn't exactly a requirement, it's just the ID part that's important
I would heavily, HEAVILY recommend against doing it
don't trust anyone with your bot
for someone else to verify your bot in your place, you'd have to pass ownership to them, meaning that person could simply steal your bot out of the blue
Well my two options are either let it die or find someone I can trust with it, so don't have much choice sadly :/
I appreciate the notice though
or you trust discord with your id
it's a serious business, if anything happens they get punished anyway
it's not like ur giving ur id to some random alley goods dealer
I understand, but I feel like the ID is very unnecessary, it's just a chat app.
not really, they aren't asking your id to use the chat app
they're asking because they need to verify you are who you say you are for using sensitive data and potentially destructive endpoints
they ask for it so they can prevent you from creating alt accounts for your scams (if any)
I mean, can't they let a bot that doesn't use those endpoints or sensitive data scale without providing an ID?
they cant
Doesnāt discord use stripe for id verification?
They're trying to prevent bots that scam people after becoming slightly bigger than usual
your bot gets verified and joins in 1000 servers
discord bans u after a while
u make another account and repeat ad infinitum
now add an ID to the equation, the loop is broken
Your ID is only used to prevent abuse
IDs are something that a massive company like discord has to be very VERY careful with handling
ye, having one leaked could shutdown discord
They donāt want to steal your identity, they want to protect the users of your bot
well, stripe in this case
The important part is that Discord doesn't even get to see your ID, only Stripe does
What I mean is that some bots don't want the verified sign. I think verified is cool for people who want the sign, but I think it's a wrong choice for them to let the bots who don't want that sign not scale. People can always create alts and create new bots on those, each one holding 100 users, which makes verification pretty useless in this scenario
since discord doesn't hold any info abt ur id
they only hold if ur identity was verified or not
Why would you not want your bot to be verifiedā¦
stripe is the one to handle the id
u dont verify for the sign
Not all people are happy to give their ID
the sign is just a collateral effect
Youāre not verifying for the sign, youāre verifying so that discord can prevent abuse of user data
like, if you're verifying just for the sake of the sign then I'd laugh the hell out of you
Well, thatās your decision. But it exists for a good reason, and they do not mishandle extremely sensitive data like this
also limiting to 100 servers is to contain the possible damage, way better than having no limit
I mean here is what would be cool:
- Locked down API
- Same questions asked but without the ID
- Can join an infinite amount of servers
Yeah, no
Not how that works
An ID is a way to prevent abuse by making sure that people have accountability on the internet
Otherwise you are completely anonymous to discord and you can just keep abusing their service by creating more accounts and more bots if you get banned
They donāt want big bots mishandling large amounts of sensitive user data
ye, discord already tracks your IP, but any vpn could bypass that
an ID tho, you cannot fake that legally
- Verification isn't supposed to be the user's choice, because that's not how verification works
- This is a good way to prevent a ton of abuse
Bot gets verified after you give in your ID -> your ID is held to prevent abuse -> your bot gets detected for abuse -> gets disabled or even removed -> your make another bot and try to get it verified -> declined because you can't provide that same ID, to prevent abuse, unless you have many other IDs - Discord doesn't even see your ID, only Stripe does; which is trusted by millions of people, and many companies use it
and if u do, you have real, legal issues
You can retrieve a lot of sensitive data about users just based on their statuses
Imagine if you had a massive bot tracking everyoneās status unknowingly to the users
Then it gets banned for that
the only, ONLY thing discord holds is isUserVerified: true/false
Then you just create another bot, and another, and another
I mean if they are allowing bots to get the same data up until 100 servers, is it really sensitive? If a scam bot joins 100 servers, then the scammer can just make a new alt
100 servers is absolutely nothing in the grand scheme of things
now remove the limit
They want to prevent abuse in large numbers
Imagine if rhythm decided to nuke everyoneās servers when they got shut down
scamming 100 servers is bad, yes, but WAY better than say, 1.000.000
discord could simply say "You cannot have your bot in more than 1 server without verification", that'd kill any scam attempt
however, people would hate it
so they settled at a sane number
not too much to be a WOMD but also not too little as to make people mad
Fair point, I guess this is where the ID helps. A bot that joins a lot of servers then goes malicious. But is stopping a lot of real bots from scaling really the solution, can't they just lock down anything destructive in exchange for not providing an ID?
sending a single message is technically destructive with enough servers
almost all endpoints become destructive when u reach a certain number of servers
Also most real bots I've seen have never had an issue with this, they've just provided an ID and never looked back again
isn't stripe used by banking app btw?
It's not really an issue, except for those who don't have IDs but Discord also provides ways around that, such as providing other types of documents (driver's license, passport), or using other people's documents, such as your friends' or your parents'
Ye, stripe is a banking app I think
Stripe isn't a banking app, it's used by banks
They handle document processing and verification
or using other people's documents, such as your friends' or your parents
in this case, losing the ownership of the bot
since u need to transfer during verification
Yeah, you must transfer it to a team
Although you'll still be considered the main owner
Moderators can act fast on messages, I also think an API request limit on sending messages/anything else in a server is a pretty good idea, in case a bot starts being malicious. Most big servers have a lot of moderators that can act really fast
but how fast? and how would you know if people got dm scam before it's too late?
most dont fall for it, but some are just too dumb
multiply those "some" by 1000, 10000, 100000, whatever, even in small quantities the damage would be huge
With the API request limit idea, you can just limit the amount of DMs sent in a small period (1 or 10 minutes for example) and the damage will be kept to a minimum
that'd kill bots that use dms
Yeah, lots of unverified bots use dms a lot for valid uses.
ik a lot of bots that show their help command on dms to prevent pollution
That was why I proposed both ideas, for bots who don't need much they don't have to provide their ID, but for bots who want unlimited access they have to provide their ID
They'll still be able to DM, just not DM too much in a small period
That contradicts with the idea of preventing abuse, in an extreme level; so verification literally just gets obliterated out of the way
That won't work though.
Our bot luca sends a lot of dms, but its not verified, and it'll never be able to get verified.
Because a lot of bots don't even use privileged intents and such, which would cause a lot of abuse
I'll use my bot as an example: I rely on dms to show the player's cards
I meant keep both options, either super locked down, or unlimited with verification
if I had to be verified to be able to use dms, I'd never reach 100 servers
because my bot's sole purpose is said game, which requires dms
so I'd need to develop an entirely different bot until I reach verification threshold
So first 100 servers -> same as now, after 100 servers you have two options:
- Locked down
- Verification
HOWEVER, it'd not be the same bot after verification, thus people would either remove my bot or lose whatever they set up to it
see the problem here?
The first 100 servers have the same permissions as now, it's just after 100 servers where you can verify or choose a locked down API
that returns to my "bot would need to be drastically changed to conform to api limit changes" point
Well if you need more API requests, you have to verify, which is the same as now pretty much
if my bot could show player hands before 100 servers, but suddenly lost that ability, it'd have to become an entirely different bot after lockdown
The solution you are giving imo isn't something the vast majority of bot owners would go for.
Discord would need to do a ton of work for a very small set of bots.
It just isnt economical for them.
as much as I hate giving my info to anything, I understand their choice from a technical point
A webhook based bot it might make sense to allow that, I guess?
Ie only responding to interactions.
me?
No, I mean applications with no server cap without verification.
ah, yes, you have no limit if u only use webhooks
Technically speaking is possible now.
tho u also cant get any info abt the server at all
but yes, it works
btw, not with interactions
I mean raw webhooks
Here is an example for where the locked down API is good enough
You have a bot that just replies whenever it gets some a command (like a -weather command that is rarely used)
If the API is limited to 10 messages a minute, and that command is rarely used in an average server, then you won't have any problem at all
That would require access to a privileged intent.
So discord would never go for something like that
then you add non-documented commands, you join the server and use -nuke, the server gets deleted



