#development
1 messages · Page 55 of 1
lol
number of servers 8, number of users 2 ... wut :P
probably did cached users
15MB at 8 guilds is garbage >:(
could anyone help me with this issue
char arr[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ' ', '!', ',', '.', '-'};
bool matches_found = false;
bool stop_counter = false;
int counter = 0;
char individual;
while(!stop_counter){
r++;
counter = 0;
input.close();
input.open("test.txt");
if(!input.eof()){
matches_found = false;
individual = input.get();
a = ((individual >= 32 && individual < 128) ? (individual - 32 - (r % (128 - 32)) + (128 - 32)) % (128 - 32) + 32 : individual);
cout << a;
for(int i = 0; i < 56; i++){
if(a == arr[i]){
counter++;
if(counter == 30731){
cout << "done";
stop_counter = true;
}
}```I basically want tto stop my loop when ALL characters in the file are in the array. However as of now it keeps looping infinitely.
It works for 1 character indivdiually, just not for > 1 chars
but that wouldn't be a problem right?
no, but it'd be the best approach
I need to decrypt this. I already have the formula, just have one value missing which is value R. I need to calculate that
this is the formula
r is probably something appended on the secret you have there
KuuHaKu rage
too many bit flips happened to me to allow something like that to exist
the r is the value that's used to encrypt one singular character. But now i need to decrypt it, i already have that function but i don't know what r to use. That's what i need to compute
owh why?
What's a dead-end operator?
wut
>, >=, < or <=
because shit happens, and if it ever skips that number you'll have an infinite loop
boom your loop goes forever
oowh i see, thanks!
@lyric mountain can you technically define a number increment in a programming language a clock cycle?

ignoring the storing and stuff, just adding 1 to some number
well a clock tick*
no idea, especially that most compilers will bake your code into something different
wait i maybe got something really smart
so we have the first character of the encrypted text
exactly lol
a = ((individual >= 32 && individual < 128) ? (individual - 32 - (r % (128 - 32)) + (128 - 32)) % (128 - 32) + 32 : individual);can't we reverse this formula
individual will be the first character.
stop using ternaries please
though cant say I've been at such frustrating point before so
may or may not have done it
Can't we redefine this formula to get r = (formula)
honestly still think you should let another package/library handle it
people have been there
it's awful when bit flips happen because you can't debug
i am not allowed to
it simply goes haywire and u don't know why
shit thats kinda pain 
I had a formula to encrypt the text
and i can encrypt and decrypt successfully, however i now need to know fucking r lmao
make a general utilities class or file though, to avoid you doing repeated things
what encryption is that
i am in my first 5 weeks of university
so idk what that is
something like
b = decrypt(a, r)
instead of having to do that mess above every time
also tbh that stuff seems too early for 5 weeks in
i already got that
no clue about universities but
i really have no clue
it's a strange formulation tthat basically gets the character in a file, and then increemnts it's value with value r
then r should be mentioned somewhere
imagine you have 'D', which is int 68. With r 2 you would get 70, so F
nope
” that contains a text file “secret.txt” that is encrypted with OTP using a secret initializing value R. It is your task to design and implement a program that decrypts this text file and uncover what value R has been used. The name of the decrypted text file must be “source.txt”. The only information known about the source text is that it is written in English.
oh so the secret is R
likely some string
OTP = One time pad
In cryptography, the one-time pad (OTP) is an encryption technique that cannot be cracked, but requires the use of a single-use pre-shared key that is not smaller than the message being sent. In this technique, a plaintext is paired with a random secret key (also referred to as a one-time pad). Then, each bit or character of the plaintext is enc...
this can help
somewhat
so according to OTP
The key must be random (uniformly distributed in the set of all possible keys and independent of the plaintext), entirely sampled from a non-algorithmic, chaotic source such as a hardware random number generator. It is not sufficient for OTP keys to pass statistical randomness tests as such tests cannot measure entropy, and the number of bits of entropy must be at least equal to the number of bits in the plaintext. For example, using cryptographic hashes or mathematical functions (such as logarithm or square root) to generate keys from fewer bits of entropy would break the uniform distribution requirement, and therefore would not provide perfect secrecy.
The key must never be reused in whole or in part.
The key must be kept completely secret by the communicating parties.
most importantly,
The key must be at least as long as the plaintext.
so you could essentially bruteforce the key perhaps? 
yup i knew that
Idk if its the right channel for this question but is there a variable with which you can display the servers votes in a vote webhook?
since what I'm guessing your goal is is essentially a cracker
What i thought is this:
the vote webhook only tells u someone voted
webhooks aren't for getting total of anything
oh okay, thanks
we read the encrypted file, loop over each character and check if it's in the array with alphabetical !, , , ', ' ' included) characters, if all characters are true for that, it means it's encrypted with the right R.
but now i am stuck with this code. 1 character works, but if i use multiple characters it keeps infinitely looping
did u try using the debugger?
perhaps ur counter isn't incrementing properly
that said, u shouldn't use while for anything that has a boundary
aside from that, I can't really understand that code
😭
yeah it's incremeting awesome
the only thing it should do, is loop over the encrypted text and get each character. Then it will see if each character is in the array, if not it should return.
its been broken since discord changed caching like a couple years ago and i just never fixed it
indeed, though in all seriousness i installed a crappyer cpu to save power
discord doesn't cache anything
I mean, it does but not for this case
but cache is supposed to never reflect the total value anyway
used to or something there was a way of getting all users but it broke
what ever all i know is that the code used to work but now it doesnt and i never fixed it
it technically ain't broken
technically
as long as u rely on cache for total count it'll show wrong values
cache is for holding recently used values
if u want user count u need to iterate over each guild and retrieve memberCount
not worth it imo, nobody cares abt user count anyway
i forgot how to code
my code is literally there lol but it broke
one sec let me grab it
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
Page 1 is Index Page 2 is the page it’s supposed to go to
You're literally sending a GET request to the / endpoint which you've declared to read the index.js file and send it back as the response, which is why you're seeing the code there
You're only redirecting when a GET request is made to the /discord endpoint
let's also ignore the fact that you also have a handler for get / that sends hello world which is shadowed by the first get /
@ancient nova where you at homie we miss your problems in development
Yeah homie, development have been too quiet lately
This is memberAchievementData[0] how can I check how many memberAchievementData[0] is true? and how many true or false?
You wanna explain your last two questions again?
You wanna check the object properties or…?
I can make it active
Lets talk about the ENTIRE websocket protocol RFC
Hello
I want to count how many of those booleans are true?
you should reeeeally use a bitfield here
also why not store the counts themselves instead of starsN, levelN, inServerN?
Then loop through your object, create a var outside with 0 as value, and add += 1 to it, once any property has true as value
Add a strict check for the value to ignore other properties which aren’t booleans
if(<property> === true) + 1 your var
is that a non-monospace font I see there?
what is non-monospace font?
for(const property in object)
Make sure it actually is an object and not an instance of your database result
No
gud morning
well it worked but the number is wrong , it have to be 9
Could be the array which is true
Add a typeof check as condition
if(typeof archivmentData[key] === “boolean” && archivmentData[key]) ++
still its 10
Why do you nest those statements?
wdym?
Also since you did a typeof check already there’s no need to do another strict check
That’s your entire statement:
if(typeof archivmentData[key] === “boolean” && archivmentData[key]) ++
Then log the property instead to see which one is the one you don’t want to
if(typeof archivmentData[key] === “boolean” && archivmentData[key]) console.log(key);
Hmm a private property I guess idk mongoose
how can I ignore it?
memberAchivmentsData[0][key] !== $isMongooseModelPrototype
or
memberAchivmentsData[0][key] !== "$isMongooseModelPrototype"
If so the second one
nope didnt work
The key name is a string
if (typeof memberAchivmentsData[0][key] === "boolean" && memberAchivmentsData[0][key] !== "$isMongooseModelPrototype" && memberAchivmentsData[0][key]) unlocked++
key !== “ismongoose…”
BTW instead of that I can define unlocked -1 and with that isMongoose.... it will become truth number
I dunno if that private property is always there
same
yup
how do I make bot shown how many server and user that each shards have ?
hey guys i am still trying to find a way to decrypt this
the encryption process looks like this:
The function that gets called:c++ while (!infile.eof()) { initialise_pseudo_random(initial_value); initial_value = next_pseudo_random_number(); char individual = infile.get(); char encryptedchar = rotate_char(individual, initial_value, action); if (encryptedchar != EOF) { outfile << encryptedchar; } }
The encrypting function formula:```c++
if (action == Encrypt)
{
a = ((a >= 32 && a < 128) ? (a - 32 + (r % (128 - 32))) % (128 - 32) + 32 : a);
}```The next pseudo function: ```c++
const int SEED75 = seed * 75;
int next = (SEED75 & 65535) - (SEED75 >> 16);
if (next < 0)
next += 65537;
seed = next;
return next;```
So right now, the above image is encrypted with a mystery R. How would i find that r?
nope
@civic scroll your handwriting fits so well with my ide thanks
I need a email platform that I can easily make api calls to to read messages
how do i pass arguments to a node module? theres a module im using called node-microphone and idk how to set the options. up till now ive just exited the defaults in the module code
its already perfect wdym
does anyone know how i can do this please i am desparate
who may know what system should i do to get Presence Intent in verified bot?
how would i set the guild id as the name of a variable?
like this
let msg.guild.id = 'stuff'
but i know that wont work
the only other way i can think of is making an array somethging like
let stuff = {
serverID: msg.guild.id
otherinfo: 'things'
},```
but i have no idea how id get the `otherinfo` for each server without using a for each loop every time and that just doesn't seam right
you cant override it
?
aswell as it being a snowflake so you cant use an entirely different type for that
if you want to attach some info on a server, consider making a handler for that that allows you to fetch certain options for a guild
its only for a vc type thing
i gotta make a new audio stream for each thing and whildt i can create them i cant destroy them
i could do it withg the channel id
channel id would be better anyway
but i still have the same issue
you'll need to make a handler, for example having a static dictionary with the following:
- a key that is the server id
then a dictionary that has other things such as your audio instance
if you're trying to handle something on that audio instance, you can access that static list and then use the audio instance from there
if you no longer use it, you can just remove that entry from the dictionary
how on earth would i do that
the only handlers i've delt with ar command/event handlers
your general goal is trying to work with dictionary, look into how to work with dictionaries so you can store your audio instance
cool
well sounds like a project i guess will look into it later not got that sort of time at the minute but thx for the info
How do i learn C quickly
step one: don't
No i am serious
C is very simple in its essence
That's where the difficulty stems from; C is almost TOO simple sometimes
429 hit on route /channels/1024369295238635571/messages
429 hit on route /channels/1024369295238635571/typing
tldr you are ratelimited
thanks
tldr stop spamming the API
butttt wafffflleeeeeee
@rose warren is this valid
Technically yes. But I doubt it'll win if that's the only feature 
can i submit two bots
as in one will have commands that respond with the one exact sentence
and the other one will do other stuff
I guess
cant get my bot to come online how to i make it ?
English?
do you know how to code?
They asked how to make it so you tell me tim
Somewhat , not familar with discord server login thou
is there any specific progamming language youre more comfortable with?
out of those 3 i believe java would be easier
there are a lot of discord libraries out there for every programming language
so look into discord libraries for java, like jda
and learn how they work, read their documentation
and thats pretty much all you need to create a functioning bot
ight , thank you 🙂
guess would be easyr to do through git hub huh?
😛
examples on git
sure
Out of curiosity, for anyone that has a bot here and has a website for said bot, what do you use for screenshots of Discord? For example, I want to use discord screenshots on my website but using snipping tool is just giving me blurry images. Any suggestions on softwares would be much appreciated! Thanks everyone! :))
Snipping tool, if it goes blurry I use Photoshop to sharpen it
Ok I appreciate it thank you. Do you think it's worth enlarging discord via the settings to make a larger res file? That way the quality loss should be reduced no?
Of course, not too big that the image takes long to download client side.
Appreciate the input :))
np
enlarging images will always reduce resolution
as well as shrinking it
Exactly, although photoshop can be nice sometimes and not reduce the quality very much. Just so confused as to how other sites have crystal clear discord screenshots haha.
just take a higher resolution screenshot
be it photoshop, gimp, corel or whatever, manipulating image size will always degrade quality exactly the same
that's because the computer has to "guess" what would be in the missing pixels
you can, however, make the image appear sharper or blurrier by using different interpolations like linear, cubic or lohalo
nonetheless it'll not reduce the quality loss
for example, if u enlarge an image to twice of its size, the loss will always be 50%
run that bitch through waifu2x
waifu2x doesn't help with texts
not really, it'll look like texts when u try to read something inside a dream
I use w2x daily
w2x is a machine-learning upscaler, unless u build the source yourself and train it using text samples it'll do poorly for texts
it'd be better to simply write the text yourself in an image editor after upscaling it
would be hard to do on materials with fine grain color gradations
?
it's a discord print
simply upscale the image, delete the texts and write it again using whatever image editor u use
ngl when top.gg switched to chakra-ui as their ui framework, i immediately recognized it and was like "woah"
chakra-ui is mid
https://mantine.dev is better
but still it was kinda weird to see it being used in production
i havent experiemented with mantine yet but ive used chakra in the past
shameless plug of my fav react framework
framework?
I have used both and mantine was a better experience
library*
fun fact, screw framework uis that obfuscate css classes
especially if you're doing premid stuff
meh more like avoiding collisions with other classes
premid as in the discord rpc thing?
yeah
premid
why?
never heard of it
i only looked into the github repo like once to see how it worked
misty you never heard of anything lmao
not true
i've heard of ur mom
ok on a serious note
I don't really fuck with discord stuff anymore other than gateway and oauth
so
discord is kinda strange
time to read my 500 page book on python
what is your:
- preferred ui library (if any) or css preprocessor
- preferred web framework (or vanilla)
- favourite hosting platform
- favourite discord bot lib (if any)
Just cause I do smth strange for a bit of change doesn't mean anything
- Mantine if using React / Angular I write my own css
- Angular if I am not feeling lazy, if I am React
- Wtf is a hosting library
- I am libless when not lazy or I use detritus
u read books about python?
i meant hosting pltaform goddamn
wtf thats such a nerd move
daff
cmon misty python is easy u dont need books
this is why I learned something new that you didn't know despite using the language
I use contabo
never in my actual programmer life used any hosting platform
ignoring the pre-pc times
Aurel uses free hosting
these were cringe
Mod perk: get free hosting on top.gg
Wait really?
hey aurel do the -apply thing or whatever
no way
damnit
good uptime much
a computer
ofc
false
well
nvm it runs on aurel's brain
it runs on lemon juice
technically smoke signals and someone pressing buttons when sees smoke
which is why its upttime is amazing
me when elon musk's brain chip
I wanna get it
lmao i just know that you manually respond to everything and manually post everything 😂
what do you think how discord bots work
Aurel's brain connects to the satellites and downloads information
a bunch of monkeys on desks sending messages on their computer
ahhh
mhm sounds accurate enough
my command isn’t working and i made the message.js event and the code is
module.exports = (Discord, client, message) => {
const config = require("../../config.json");
const prefix = config["main_config"].prefix;
if(!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).split(/ +/);
const cmd = args.shift().toLowerCase();
const command = client.commands.get(cmd) || client.commands.find(a => a.aliases && a.aliases.includes(cmd));
if(command) command.execute(client, message, cmd, args, Discord);
})```
Should I participate in the Halloween hackathon
idk
This is helpful to us, let is just guess what exactly is going wrong as there is no error message supplied other than "this isn't working"
there’s no error printed in the console
Thank you, now the next step
What is it doing instead, is the execution of the code stopping somewhere else?
it’s just not running the command
So it doesn't reach the command.execute
yeah do you need my index?
Have you tried logging command
no
it could be null/undefined
lol
It logs nothing?
yeah nothing
try logging cmd and args see what the results of that is
It is probably not finding the command period
fixed
@wheat mesa I need help with math
Don't be stupid then
This is development related
U never said that. So yeah.
Anyway waffle math help :)
yes\
So I am trying to make a bot for the halloween hackathon but I wanna make it balanced. Essentially there will be items you can purchase that gives you a boost and obv each item will be more expensive. I am trying to figure out the best way to calculate the cost of the next item so it remains challenging but not insanely difficult
How do you determine the growth
I was also looking a an exp func but I forgot how they worked
y = a(b)^x
a is the starting amount, like 2, b is the growth rate, like 2, and x is the thing you change each level
how about quadratic
but it doesn't grow as fast
exponential implies that a variable is attached to an exponent
You can control either one, they are both exponential at its core
quadratic ≠ exponential
Quadratic is baaaasically exponential
exponential is not when line go up faster
Exponential is easier to visualize in this situation though
so am i right or?
not really, that'll change it but it's better to change b
This is Math.pow(2, 2 * x)
You can adjust things, idk what Math.exp does tbh
Looks like e^x
It is x^x
Seems like e^x to me
Oh nope, you are right
Yeah
that's literally what exponential is
He’s technically right, quadratic is diff than exponential
then what about this?
I was having a dumb moment
smh
YES FINALLY
hm?
the api works now
what api
the api for my website to show my status
ah ok
lanyard takes 5 seconds to setup, join the server and get the image...
gj ig
intents & partials?
- haha no
- still no
- my own
- d.js and xmlhttprequest 😉
please switch fonts 
no
Sayuri handwriting best font
especially for coding in a light theme IDE
🤌
Whats the discord subcommand option id for string input
because I cant find it on discord docs
they only show ROLE, CHANNEL, USER from what I can tell

danke
why i have x2?
what is this error
- Would be nice to give code so others can start to help
- Would be nice to have a better error than
[object Object]so others know the actual error to help you
xd
so xd
Yeah use a pasting service maybe? So that it doesn't flood the entire chat
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
a ok
xd
@earnest phoenix https://pastebin.com/ypMZ8veW
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
and it's fine for a react command
One message removed from a suspended account.
it doesnt show nsfw bruh
as that endpoint doesn't return nsfw
they don't use neko endpoint or whatsoever
so it's fine
const choices = ["hug", "kiss", "cuddle", "feed", "pat", "poke", "slap", "smug", "tickle", "wink"];
it doesnt show nsfw
my bot doesnt show any nsfw
as said, it's fine
and on the other side
@rose warren ping 1
also, they still have nsfw content lol
Just wondering if this exists: true ? : 1
In what language?
The way you used it in that example is invalid syntax, but the thing you’re looking for is called a ternary operator
It exists in basically every C-inspired language
Why are you pinging me?
sorry ilstop
I want to learn dc bot coding in mobile phone any tutorial?
Is anyone here?
💀
You wouldn't want to go through all the pain to do that, I've programmed on a phone for 5 years and it has been absolute hell
JavaScript and thanks
Imao i shouldn't try that
"" == null right? (js)
I should try trrmux instead
You can use terminal emulators such as Termux to write and host a Discord bot, or write it and host it on a VPS if you want to bot to stay up 24/7
"just root an android phone and put ubuntu server on it"
You don't necessarily have to write the code in Termux although, you can write it in any code editor, and move it inside Termux
Termux for another reason
You already know
I learned about hacking from you
Hmm 👀
What? Are you wondering if that's how you do comparisons in JavaScript?
Just wondering if that is true or false
It would be false, because even though they're both falsey values, their types are different
And if strict?
It would still be false if it's not true with the non-strict equality operator
hm
What do you do next
theres no UNICODE_EMOJI in that library
it works but now we get this
you cannot join a fixed string, since its already joined
so what would i do then?
same error
show your on_ready code
wdym
the code you have for the on_ready event
what is line 550?
the problem is likely that self.bot_owner_ids is not defined
"" is not a falsey value in JavaScript, no?
It is
Empty strings are falsey
Empty arrays are not though
That’s prob what you’re thinking of
Hey waffle
but people use for the .length property to check if a string is empty, not using the string itself
no matter how much I play with the exponential function it just seems like at some point it'd get way too hard to continue playing
Unless I am just calculating it wrong
both work yes
you can also use equality to empty string
!str
str === ""
!str.length
str.length === 0
the compiler will likely optimize any of the above so it doesnt really matter which one you use
if you wanna be as semantically correct as possible, id go for either str === "" or str.length === 0
!str might not be optimized the same since it would also check for null/undefined
in case of engines like v8 it doesnt really matter
i believe all containers have basic props like isFalsey or stuff, so it will just check for that, regardless of the js type
HeadersTimeoutError: Headers Timeout Error
at Timeout.onParserTimeout [as _onTimeout] (/home/container/node_modules/erela.js/node_modules/undici/lib/client.js:1005:28)
at listOnTimeout (node:internal/timers:566:11)
at process.processTimers (node:internal/timers:507:7) What is the error. Ping me to answer pls
it means your bot failed to connect to the lavalink server
ah ok xd
client.on("ready", () => {
client.users.fetch("485277325328384000").then((user) => {
//channel
//testChannel
setInterval(() => {
user.send("SOMETHINGHERE");
}, 60000);
});
});
client.on("message", (message) => {
switch (message.content.toUpperCase()) {
case "SOMETHINGHERE":
resetBot(message.user);
break;
}
});
function resetBot(user) {
user
.send("Resetting...")
.then((msg) => client.destroy())
.then(() => client.login(process.env.DISCORD_TOKEN))
.then(() => user.send("Đã reset bot thành công"));
}
why my code is not work
2022-10-11T11:15:50.912641+00:00 app[worker.1]: TypeError: Cannot read property 'send' of undefined
2022-10-11T11:15:50.912651+00:00 app[worker.1]: at resetBot (/app/index.js:155:6)
2022-10-11T11:15:50.912652+00:00 app[worker.1]: at CommandoClient.<anonymous> (/app/index.js:148:7)
It's <Message>.author not <Message>.user
Thanks bro, like this right?
There's no need to change the parameter name of the resetBot() function to author, because <Message>.author is a user
oh sorry, I'm tired today
Thanks bro, you helped me so much
wait maybe you misunderstand me
your method is sent to the bot itself (not possible)
Hmm I will make some fix :)))
Nope
Discord API error
Can't send message to this user (the bot itself)
or I wrong at somepoint?
<Message>.author is the author of the message, and not the bot; you're possibly not sending the message to the user, or their DMs are closed
Oh I make the bot to send itself
You should prevent the bot from reading bot messages, because the messageCreate event also listens to the bot's own messages
to make auto reset function
Also what discord.js version are you using?
like the bot will send the message to me then he send a signal to me that the process is happening
my idea is that
12
This is a old bot but is my first bot so I want it to live :))
Yeah my full code of this function is here
(before fixing)
You should upgrade to v14, v12 is no longer supported and will most of the time crash due to it not being able to handle newer requests
The mission of me with the bot is over
Now I just need to make the bot online 24/7 :))
I will do with my other bot
That's why I am try to make the function, all I need is the bot alive
You won't be able to make the bot run 24/7 with discord.js v12 because it'll keep crashing
that is why I make auto reset :))
some shards of the bot is die before the main reset
If you want to keep the bot alive then upgrade, it's not even hard, in your case it's a few changes
my other bot is discord.js v12 but in some magic way he is auto reset when have error
and can run 24/7 :))
only difference is that bot don't use discord.js-commando package
and this bot is not like that bot (not reset when have errors)
Auto resetting is not a solution, it can hit the 1,000 login limit and not be able to connect to the gateway again until another day
There's no reason to not update
I am doing with my main bot
changing from version 12 to version 14 make a 100% re-code and I lack of my time
You don't need to entirely rewrite, you'll only be changing a few things and that's mostly it
You can refer to the official discord.js guide on what to change
hmmm I will but not now changing few lines / file cost hours
I am not a pro, honestly
My university tests / exams is more than code lines of my bot :))
But very thank you bro
You helped me so much, I feel better now
Alright, you're welcome
oh my last question, how much time it cost to reset 1000 login limit
In 2020, I reached that a time
It takes an entire day until that ratelimit is lifted
Login count by shards / clusers spam or the bot only?
It mostly doesn't consider shards because bots could have a lot of them, so they would hit that ratelimit very quickly if it counted the shards as well
I think it's just the main instance that counts
Or it may count the shards as well, not sure
bots cant send messages to bots btw
all shards count
if you have 10 shards and a login limit of 1000, after starting your bot, your login limit is now 990
resumes dont count
@quartz kindle if a bot have more than 1000 shards like MEE6?
How can they reconnect all the bot if they want?
once you get a high amount of shards you can request a higher connection limit
when you get to 100k guilds (100 shards) or close to that, your bot becomes a "large bot"
large bots have different limits, for example the daily login limit is something like 2000 + X for every N guilds or something like that
so when you get to 1000 shards, your login limit is like 5000-10000 or even more i dont know
you also get a bigger "max_concurrency" which lets you login multiple shards at the same time, so it doesnt take too long
heres the actual numbers from tje docs
The session start limit for these bots will also be increased from 1000 to max(2000, (guild_count / 1000) * 3) per day. You also receive an increased max_concurrency, the number of shards you can concurrently start.
idk why I dont check myself but is interaction.user.id a number or a string?
in djs its always string
read all entries, for each entry write entry to new db
mysql is just too much trouble to be worth it
im on maria, I dont think postgres will benefit me at all
I mean, postgres has a much better support and scalability
but it doesnt use sql, correct? actually no, it has sql in the name, right?
postgresql
well would my code for maria straight up work with it?
90% of it probably yes
if anything it'd be just minor adjusts to fit
what wouldnt? I dont think I use anything advanced, just write and mass reads
for example, you don't declare collations on postgres
they don't even exist there
I dont even know what that is so, ... I think thats fine lol
see, you'd be in trouble with mysql already lul
lmao
really, I don't know why the hell they thought it'd be a good idea to have something like that
collate unicode mb4 ci black magic
would these still work on postgres?
exports.set = (userid, value) => new Promise(async ful => {
const data = await db.query(`select * from usermoney where userid = ?;`, [userid])
if (typeof data[0] === 'undefined') {
await db.query(`insert into usermoney value (?, ?)`, [
userid,
value
]); return ful('Y-CREATE')
} else {
await db.query(`update usermoney set money = ? where userid = ?;`, [
value,
userid
]); return ful('Y-WRITE')
}
})
// Add Function
exports.add = (userid, value) => new Promise(async ful => {
const data = await db.query(`select * from usermoney where userid = ?;`, [userid])
if (typeof data[0] === 'undefined') {
await db.query(`insert into usermoney value (?, ?)`, [
userid,
value
]); return ful('Y-CREATE')
} else {
await db.query(`update usermoney set money = money + ? where userid = ?;`, [
value,
userid
]); return ful('Y-WRITE')
}
})```
but youll need to check how your postgres library works in js
most differences are gonna be from differences between how the libraries chose to interface with the db
not the sql code itself
btw I think it might error if u try to use query for inserts/updates
I dont have any errors
btw you dont need to create a new promise there
in postgres lib I mean
ah
since they're non-returning operations
just make it an async function
whats the most similar library for postgres in js to mariadb?
usually you have something like execute or executeUpdate for insert/update/delete
pg probably
actually, it might be a literal fit for ur current code
($1::text is just CAST($1 AS TEXT) but shorthand)
this is my current:
const config = require('../../config.json')
const mariadb = require('mariadb');
const pool = mariadb.createPool({
host: config.mariadb.oxbot.host,
database: config.mariadb.oxbot.database,
user: config.mariadb.oxbot.username,
password: config.mariadb.oxbot.password,
connectionLimit: 100
}); let db
pool.getConnection()
.then(botconn => { db = botconn })```
the code u sent earlier I mean
ah
^
also apparently, it allows using query for I/U/D too
anyway, that documentation I sent explains it pretty well how to use it
is this it?
const pool = new Pool({
user: 'dbuser',
host: 'database.server.com',
database: 'mydb',
password: 'secretpassword',
port: 3211,
}); const client = new Client({
user: 'dbuser',
host: 'database.server.com',
database: 'mydb',
password: 'secretpassword',
port: 3211,
})
client.connect()```
wait
I only need client I assume?
pool is probably for creating a connection pool
which is better if u have high concurrency in ur database
otherwise client is fine
ig ill first worry about setting up the db
Connection pool is basically many connections open at once so it can balance requests
Effectively the same as djs shard manager
ok so I have this;
const { Client } = require('pg')
but I am already using the Var Client bor djs, how do I get the pg one under a different name?
that only works for actual imports
That works for import statements, however if you want to do that with require() it's basic object destructing
const { Client: Foo } = require('bar');
For example
I think I got it
You can just use the : after the destructed value to give it a different name
yeah, ill do that
so I have this sql code, and it errors in postgres. why?
code:
module.exports = {
data: {
"name": migna
},
async migrate(db) {
// Check if Migration has already occured
let status
try {
status = await db.query(`select * from migrations where id = '${migid}%';`)
} catch (e) {
await db.query(`create table migrations (id int, name text)`)
await db.query(`insert into migrations value (${migid}, ?)`, [migna])
return true
}; return false
},
};```
error:
https://paste.rjansen.de/Jlb9owVsDd
ok so it created the table but couldnt write the data
nvm, I have to use values instead of value and $1, $2, ... instead of ?
ah yes, it's usually enforced by libs to use either named or indexed parameters
Ah yes. The pg lib will compile the statement to test it :)
they support, but purposely error so u have to use the proper way
they started doing that after some incidents where param order wasn't in the expected positions
lmao
btw you don't need to add semicolons after scope curly brackets
try {
} catch(e) {
}
``` is semantically correct, and causes no confusion with the compiler
clonning a github repo but getting these errors
I think it's funny that you didn't use semicolons for the things that technically need them though lol
That's not caused by cloning the GitHub repository however, it seems like you're installing a dependency that wants a dependency missing from the registry
yeah i meant
i clonned it successfully
running it
but getting that shit error
my brain is too smooth
always stripe throwing such errors
Remove the node_modules directory and the package-lock.json file and run npm update --save, it should update the dependencies and get rid of the non-existent dependency
Then just go ahead and run the command
maybe
@stripe/react-stripe-js@1.1.2
wants another version of react
It wants a non-existent version, which causes it to not be resolved
If running npm update --save doesn't fix it, you would have to run npm outdated and update the versions from the package.json file manually
Im drawing a blank.... how do I get my bot to show how many users are using the bot? (d.js V14.6.0) Ping or dm me thx
Using the bot?
in what way?
IE used a command ever? used a command in the last minute? currently listening to music?
Using can mean many things
Love the name. But that aside I'd like it in my status. I have the server part down but the members I'm not getting atm
so you want the total count of users that your bot can see (not necessarily that use your bot)?
yes
just iterate over each server and get memberCount
I tried memberCount and it is undefined
id like it like
Watching over (users) members in (guilds) servers
`const { SlashCommandBuilder } = require('@discordjs/builders')
const Discord = require('discord.js');
const { parse } = require('path');
module.exports = {
data: new SlashCommandBuilder()
.setName('sticky')
.setDescription('Create a sticky message')
.addStringOption(option =>
option.setName('input')
.setDescription('What do you want as your sticky message?')
.setRequired(true)),
async execute(interaction, exports) {
let maxStickMessageCount = 10
let messageCount = 0
let lastStickyMessage = ""
let stickyMessageContent = "";
let stickyMessageChannel = "";
if(!contentToStick) return interaction.reply("You must provide a valid string.")
if(interaction.member.roles.cache.has('877653550027636787')) {
let getStickyMessage = interaction.options.getString('input');
let contentToStick = interaction.options.getString('input');
messageCount++
if(messageCount > 10) {
if(interaction.member.roles.cache.has('877653550027636787')) {
try {
stickyMessageChannel = interaction.channel.id;
stickyMessageContent = contentToStick.slice(0).join(" ");
lastStickyMessage = await interaction.channel.send(stickyMessageContent);
} catch (error ) {
console.error(error);
}
}
}
}
}
}`
client.user.setActivity(`over ${memberCount} members in ${client.guilds.cache.size} servers`, { type: ActivityType.Watching });
This is my code
this is a discord bot
for obvious reasons, u cant simply do memberCount
memberCount what? bananas? apples? cars?
ok, so what should i do?
would I have to define guild tho?
loop over client.guilds.cache
ok let me try that brb
u don't declare this anywhere
so either im stupid or did it wrong. its still undefined
show how u did
client.user.setActivity(`over ${client.guilds.cache.memberCount} members in ${client.guilds.cache.size} servers`, { type: ActivityType.Watching });
sigh

😅
He said iterate though it
when I say "loop over it" I literally mean it
Where’s your loop
im new to this activity stuff so idk how to loop it
that's not an activity stuff
that's basic js
actually
that's basic programming
I dont think ive looped before
for(const [id, guild] of client.guilds.cache) …
that or ive used a different word than loop
Access memberCount inside on guild
ah ok so yeah i just used different wording then loop
Add it to a var you created outside the loop
total_count = 0
loop->total count += guild member count
activity->show total count
That’s the order
ok ill try that
funny enough, that'd be valid in groovy (client.guilds.cache.memberCount.sum())
I love how many shortcuts are in groovy
groooooooooveh
You’re goofy
how can I check if a user still exists in djs v14? aka if he deleted his account or not
actually, how do I just check if a user is in guild X
the second one is a little more difficult depending on if the user is cached or not
the first one is a little easier, deleted accounts often have same features: "deleted user", default avatar
they're never actually deleted
what about the second one though? I dont need the results to be 100% accurate
@neon leaf
- You can fetch the user using the
<Client>.users.fetch()method to see if they exist, the method is likely to throw an error if the user no longer exists as the API will returnUnknown User - You can also fetch the user from the aforementioned guild using the
<Guild>.members.fetch()method, if it doesn't exist an error will be thrown, otherwise the guild member will be returned
You don't have to worry much when fetching users/members (ratelimit reasons) because the cache is checked first before fetching, so if they already exist a new request won't be made
Isn’t .map more effective
It absolutely is inefficient
- Just use a traditional
forloop (for-i) and iterate through the next 10 elements as that's what you're looking for - You should handle errors that can be thrown from the
<Client>.users.fetch()method - For string concatenation you can just use
+= - ${'`'} -> \`
Yes, because you are awaiting an async call in every loop iteration.
You should look at ways of doing that in parallel.
They're fetching a user inside each iteration, and since <Array>.map() doesn't wait for promises to be resolved, it'll return unresolved promises unless you use something like Promise.all()
Ah ok
I only want to loop 10 times if 10 results match, so If the user selected local baltop it checks if the user in baltop is on the same server first
You should probably add a limit to your query as well.
If you had 1000 users, it would get every single one. When you only want 10
I need all users though, else I cant be sure im getting all for a local server
man I cant think of anything to not need to fetch every user to check if they are still in the guild. Ig starting again may help, whats the best way to make a local baltop command?
how do i make the timer thingy on discord with unix time
it is already one
as the other tim said, the single best optimization you can do is add a LIMIT 10 to the query. its already ordered by money, so you dont need more than the top 10.
if you want users in guild only, add their guild id to you database and use a WHERE query.
as for making sure the user is still in the guild, the only way is to use the member events, but for that you need the members intent
so on memberDelete you remove it from your database
if you dont have the members intent, then the only way is to fetch the member every time
oh my, how havent I thought about it that way, but how do I store all guilds a user is in?
you can store it in an array
most databases do not support array columns directly tho
does postgres have array- ah
ye
whats the best way to assign all currently existing user their guilds?
I mean theres nothing stopping you from using one that doesnt, but placing the json data into a string based field

dont think theres actually a way to do that is there? unless theres fields within the user field that have guilds
aswell as there being a possibility of users being in multiple guilds of your bot
theres no real way to do that other than trying to fetch the same user id from every guild and ignore the ones that failed lol
unless you have the members intent
I think I have the members intent, im currently fetching and it works
then:
Loop through guilds, fetch members, add to array
but can you fetch all members from a guild?
like guild.members.fetch() without any id
to cache everything
what is guild? interaction.guild?
for example yes
is it supposed to take like 1 minute? its not finished yet
but it didnt error either
depends on guild count and member count
like 40 members in the guild I executed the cmd in
if its 0 or something below 40, you might not have the intent
is the Members intent on your code enabled too?
yeah missing an extra intent
GuildMembers?
yup, works
what do I do with that?
and would this be correct for the sql syntax?
select * from usermoney where $1 = ANY(guilds) order by money DESC
$1 is the interaction.guild.id
would fetch everything where guild id is any of your guilds, then order it by the money field descending
is guilds a list of ids?
aka the field with the ids?
Does anyone know how to disable temp time limit?
yes
then should work, otherwise test-execute it
taking a fair guess here, perhaps setting it to 0
also @neon leaf even if it doesnt make much of a difference, consider defining the fields you'd want instead of *
could make your queries a tiny bit faster
unless literally all of it is what you need
I need every one though so ig not
lmao alright
there are only userid, guilds and money
fair fair
would this work?
```const rawvalues = await db.query(select * from usermoney where $1 = any(guilds) order by money DESC, [interaction.guild.id])
for (const element of rawvalues.rows) {
if (count >= 10) break
let skip = false
await interaction.guild.members.get(element.userid).catch((e) => skip = true)
if (!skip) {
count++
let formattedcount = count
if (count < 10) { formattedcount = '0' + count }
embedDesc = embedDesc + `\`${formattedcount}.\` » <@${element.userid}> (**${element.money}€**)\n`
}
}```
thats something you gotta ask someone with js knowledge, @quartz kindle come back here
add LIMIT 10 to the query
order by money DESC LIMIT 10
.catch doesnt exist on .get()
do you know how to remove something from a psql array by content?
I currently got this far
once you have all members cached, after you used guild.members.fetch(), you can loop over all members and add their guilds to your database
from there on, you can use the memberAdd and memberDelete events to manage them in your database
no need to always fetch them
yeah, but how exactly do I edit the array?
oh shit yeah, that would make it easier so you wont need to count until 10 within your code
i believe update usermoney set guilds = array_remove(guilds, 'id')
you dont need two queries for that:
update usermoney set guilds = array_remove(guilds, $1) WHERE userid = $2
couldnt I just use $1 for both?
$1 is guid id, $2 is user id
do you plan to keep the members in your database even after they leave everywhere?
like if you have a user with 0 guilds remaining
alright
so on the guildMemberAdd you need an upsert
add if it doesnt exists, update if it does
im currently confused by myself, so I have a file with money functions so I only have to edit them once, couldnt I just do the entire adding part in there if the guild isnt in the array when the bot wants to add / set money?
something like this
INSERT INTO usermoney (userid, money, guilds[]) VALUES($1,0,{$2}) ON CONFLICT (userid) DO UPDATE SET guilds = array_append(guilds, $2)
where $1 is the userid and $2 the guild id
and you also need to prevent duplicates
although it should never happen, its possible you receive a guildMemberAdd for a user that is already in the guild in your db
Owo vote
either due to discord bugs, or they joined/left when your bot was offline
we do not have owo here
Wvote
Owo vote
was able to migrate everything with this terrible code
console.log(Guilds); for (const element of Guilds) {
const guild = await client.guilds.fetch(element)
const members = await guild.members.fetch()
for (const element of members) {
console.log(element)
const data = await db.query(`select * from usermoney where userid = $1`, [element[0]])
if (data.rowCount === 1) {
await db.query(`update usermoney set guilds = array_append(guilds, $1) where userid = $2`, [guild.id, element[0]])
}
}
}```
hey has anyone used "google-spreadsheet" npm package?
how do i update a row with some condition
var utterance = new window.SpeechSynthesisUtterance('Hello Treehouse');
utterance.onstart = function(event) {
alert('The utterance started to be spoken.')
};
window.speechSynthesis.speak(utterance);
utterance.onerror = function(e) {
alert(e)
}
its is not working , in express js
@solemn latch hi woo
@earnest phoenix no ads/self promotion please
is there any website that makes it easy to make a base with canvas?
because I want to make a level card
A base? as in the base layers?
You could make one in MS paint if you really wanted to.
so you can import images into canvas?
Its called a spread operator.
https://www.geeksforgeeks.org/javascript-spread-operator/
[...x]
``` is pretty much the same as doing ```js
n = [];
for(const item of x) {
n.push(item)
}
but there is also this ```js
function(...x) {}
its the same as ```js
function(a,b,c,d) {
const x = [a,b,c,d]
}
RangeError: Invalid count value
at String.repeat (<anonymous>)
at /home/container/src/commands/information/help.js:209:37
at /home/container/node_modules/discord.js/node_modules/@discordjs/collection/dist/index.js:1:3113
at Function.from (<anonymous>)
at Map.map (/home/container/node_modules/discord.js/node_modules/@discordjs/collection/dist/index.js:1:3053)
at module.exports.run (/home/container/src/commands/information/help.js:203:12)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async module.exports.runCommand (/home/container/src/events/message/messageCreate.js:302:5)
at async module.exports.run (/home/container/src/events/message/messageCreate.js:276:9)
I am so confused as to why this is happening because of my help command.
Yeah, idk what is wrong with it
return message.channel.sendCustom({ embeds: [embed] });
} else if (
(args && args[0].toLowerCase() == "config") ||
(args && args[0].toLowerCase() == "configuration")
) {
embed.setTitle(` ${emojis.config} - Config`);
embed.setDescription(
this.client.botCommands
.filter((cmd) => cmd.category.toLowerCase() === "config")
.map(
(cmd) =>
`${
cmd.disabled || disabledCommands.includes(cmd.name || cmd)
? red
: green
} \`${cmd.name} ${" ".repeat(14 - Number(cmd.name.length))}:\` ${
cmd.description
}`
)
.join("\n")
);
embed.setFooter({
text: `Requested by ${message.author.username}`,
iconURL: message.author.displayAvatarURL({ dynamic: true }),
});
embed.setTimestamp();
embed.addField(
"\u200b",
"**[Invite](https://universebot.xyz/invite) | " +
"[Support Server](https://universebot.xyz/support) | " +
"[Dashboard](https://universebot.xyz/dashboard)**"
);
repeat count must be non negative
14 - length is likely negative
Well cmd.name.length is greater than 14
¯_(ツ)_/¯
I just know what’s wrong with the code you posted, that’s all I can speak for
console.log(cmd.name.length)
also, you can just use padding
you dont need to use repeat
cmd.name.padEnd(14, " ")
how was it to make the bot recognise caps and no caps? a regex? like I send !e and !E, bot will reply with same message
.toLowerCase()
alternatively, use slash commands
what
TypeError: AttachmentBuilder is not a constructor




