#development
1 messages · Page 54 of 1
thus readability yes
I don't wanna experience that nightmare during debugging
c++ is a nightmare in and of itself ngl
it's better to be able to view the flow instead of suddenly having a function called and a pretty critical value changed
And I don't think neither of these improve any code performance
Was a while ago I wrote with c++ but I did write a script to read inputs from a ps4 controller a while back
glad I suffer on Java instead of c++
Ah then i will just stuck with my normal variables instead of using &
probably better if you wanna be able to understand your code later on
Using references instead of ordinary assignments can optimize the code performance if the compiler isn't able to pick them up for inlining and stuff
You should only use references if you're doing a lot of such reassignments
char a = 'a';
a = static_cast<int>(a)
cout<<a;```why would this return just plain ``a`` instead of it's int value 97?
would there be any way to convert that char a to a int, and pass it to the same a variable?
not possible
you need another var with a different type
owhh i see
#include <iostream>
#include <fstream> // for file I/O
#include <cassert>
using namespace std;
enum Action {Encrypt, Decrypt};
char rotate_char (char a, int r, Action action)
{
char b;
cout << a - 0;
if(action == Encrypt){
if(a >= 0 && a < 32){
b = a;
}else{
b = (a - 32 + (r % (128 - 32)) % (128 - 32) + 32);
}
}
return b;
}
int main()
{
cout << rotate_char('a', 32 ,Encrypt) <<endl;
return 0;
}
```i've done this, but now it returns me some strange ass shit:
I mean all characters work for really small values of r
but not for 32 etc
well you're doing something weird with your math there
that function was already given by my teacher
if a < 32, the outcome will just be a
else if a >= 32 and <128 it will perform that formula
Is there a way in a JS function to get the file where the function was called? Without an extra param?
I also found that but then I found out it's null in strict mode... NextJS is by default in strict mode so.. 😅
well u could try throwing an exception and catching it at the same time, then getting the stacktrace and finding the line before the current function
how long does a global command take to register?
Depends the bot
For me it's never more than a minute
On my testing bot it's seconds/instant
Global commands now register instantly
It used to take an hour for them to be registered and cached
But now it's instant
humm wonder why mine wont do it then
Probably something wrong, or you have done it too many times today 
No, did it once
its a new bot
const fs = require("node:fs");
const path = require("node:path");
const { Routes, REST } = require("discord.js");
const { clientId } = require("./config.json");
const dotenv = require("dotenv");
dotenv.config();
const commands = [];
const commandsPath = path.join(__dirname, "commands");
const commandFiles = fs
.readdirSync(commandsPath)
.filter((file) => file.endsWith(".js"));
for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const command = require(filePath);
commands.push(command.data.toJSON());
}
const rest = new REST({ version: "10" }).setToken(process.env.TOKEN);
rest
.put(Routes.applicationCommands(clientId), { body: commands })
.then((data) => console.log(`Successfully registered ${data.length} application commands.`))
.catch(console.error);
I get no errors, it says it was successfully registered. But when I go do my command nothing appears as it wasnt registered
Got it too work
Helps if the bot was online 😂
I want people to be able to contact me if they find any bugs or glitches on my bot, what is the best simple way to do that
modals
do note tho, only a fraction of users ever bother to report bugs
Modals? What is that
Oh is that supported in the python version?
check the docs
Yeah looks like it’s on discord.py 2.0
Yeah... at least they are available within a very short period of time, I wonder that hasn't been changed in the docs yet
Still client caching issues seem to require to reload the client quite often I noticed (before being available)
Sometimes just changing channels/servers does the trick
At leas that has always worked for me
/ Pre-condition:
assert (a >= 0 && a < 128 && r >= 0);
/* Post-condition:
Result value b > 0 or b == 0, and b < 128, and result value r > 0 or r == 0.
*/
if(action == Encrypt){
a = ((a >= 32 && a < 128) ? (a - 32 + (r % (128 - 32))) % (128 - 32) + 32 : a);
}else if(action == Decrypt){
a = ((a >= 32 && a < 128) ? (a - 32 - (r % (128 - 32)) + (128 - 32)) % (128 - 32) + 32 : a);
}```why is this returning me warnings: ``'comparison is always true due to limited range of data type'``
What are the data types of a and r?
a is a char and r is an integer
the definition of "unmaintainable"
tf is that ur doing
i am trying to encrypt chars based on the r .
can anyone help
no
Imagine i have char 'a', which has a value of 97, and chosen r = 1, the new value would be 98.
my bot is getting rate limited in every 2hours
toxic
no I'm not, you barely supplied any info
It works, i ran some google tests. However, now i am facing the issue that the encryption is slightly off due to the fact that above statements are always true
and for ratelimit, what exactly do u want help with? simply don't spam the api
like how to not get rate limited as much as i do
simply do not spam the api
how can i do that
simply do (char + r) % 0xFF
i have just written my code
and just run it
and hosted it with uptimerobot
thats it
well, I can't help if you dont give anything to work with
at least show the error
429 hit on /route
whatever
like i can fix it
i just wanna know the reason why
and why it happens so often
and how can i fix that
that's not the error
I have to do it this way, it's for school XD, like i just need to get rid of this dumb warning.
I want the full stacktrace
code?
no, the error u got in the console
i dont get error
did they explicitly ask for the spaghetti?
i just need help with how can i reduce rate limit
how do u know it's being ratelimited then?
it shows on console
429
hit on /route
and the bot is off
sigh
you don't get the point
how can i reduce how often i get rate limited
I will just wait till you are done with priyam as you otherwise get tag teamed lmao
429 hit on route /gateway/bot
that's just the message of the error, but the useful part is in the rest of the error
aka the stacktrace
it only shows that .-.
That's not a hosting provider
You are most likely using Replit which uses shared IPs for lots of projects. Since lots of people share the same IPs the rate limits come way faster.
ye
then u either muted your exceptions or is using a pretty bad logger
all loggers should include the full stacktrace
Solution? Of course: don't use Replit 
i use the standard
client.on("debug", ( e ) => console.log(e));
You cannot prevent yourself from getting rate limited.
ye that's terrible
i just wanna prevent how often i get rate limited
cuz
i used to get rate limited in like 1day or so
If you don't change 'hosting' provider, you will always get rate limited.
not this often like only 2hour
Either self host on some raspberry pi or pay for a proper VPS for as less as $2/month
console.log(e) will only print the exception message, but exclude everything else
i am poor
And that is impossible
Keeping on using replit will make you getting ratelimited, that's a fact
yeah i will try to switch
You may also eventually get rate limited by Discord - and be unable to even get your bot online
shared ip, yeah
The warning occurs because the range of the data type of char is 0-255 by default but this is compiler-dependent, you should explicitly declare if you want the char to be signed (range of -127 to 127) or unsigned (range of 0 to 255)
Since it's unsigned for you and you're checking if the char will be greater than or equal to 0, it'll always be true
that's a pointer
signed char
what is the original question asking for?
like, why can't u let the char under/overflow?
okay i see, we haven't had that so far so i don't think we would need that.. really strange!
I could give you the function one sec
char rotate_char (char a, int r, Action action)
{
// Pre-condition:
assert (a >= 0 && a < 128 && r >= 0);
/* Post-condition:
Result value b > 0 or b == 0, and b < 128, and result value r > 0 or r == 0.
*/
if(action == Encrypt){
a = ((a >= 32 && a < 128) ? (a - 32 + (r % (128 - 32))) % (128 - 32) + 32 : a);
}else if(action == Decrypt){
a = ((a >= 32 && a < 128) ? (a - 32 - (r % (128 - 32)) + (128 - 32)) % (128 - 32) + 32 : a);
}
return a;
}```
ye I saw the spaghetti
but like, simply add a + r
when it reaches 256 it'll overflow to 0
we can't ass we eventually create it based off random r's
...yes?
We eventually have a randomizer that will add values to certain characters so they get 'encrypted'.
However, i must do it like this
my teacher says so
but how is that an issue with a + r?
u could pass anything as r
it'll still work regardless
don't ask me, we just got these formulas and some background info to work with.
it must be done like this
but yeah, for some reason the output is slightly different then it should be
and i think it's due to that encoding
ok, then lemme humanize that code
if (chr >= 32 && chr < 128) {
char radix = 128 - 32;
char offset = r % radix;
if (action == Encrypt) {
chr -= 32 + offset;
} else if(action == Decrypt) {
chr -= 32 - offset + radix;
}
chr %= radix + 32;
}
considering it's checking for < 128 I imagine it's indeed a signed char
i see
the assert i made is giving issues tho
[----------] 4 tests from OTPTest
[ RUN ] OTPTest.use_OTP_1
Assertion failed!```
``main.cpp, Line 39
Expression: a >= 0 && a < 128 && r >= 0``
i will log a rq to see what's going on
but @lyric mountain isn't it strange that we are checking if a character is smaller then < 128?
I mean it's a character...
shouldn't we convert it to int first?
hmm then this issue is really strange
Which is? 
good
I meant the name

I came to the conclusion that my whole encryption is off!
However i am not sure why
i am following all steps i must
sounds overcomlpicated xD
hey, does anyone know how i can possibly make a new array in a json file without overwriting already existing data?
try {
throw new Exception()
} catch (Exception e) {
String[] theStack = e.getStackTrace();
}
then simply find which line has the same name as the current file and get the next
ah like that ye true. I'll find a way^^thanks:)
can you not just construct a new Exception and not throw it?
it won't pull the stacktrace
oh that's stupid
the stacktrace is collected at runtime, that's why you need to throw it
indeed a stupid trick, but does the work
JS is a little different and the stack is collected as the code runs and if the code reaches too large of a depth (recursive), an error saying that the max stack size has been reached. You can also configure the max stack size
it's the same concept
Well no, the thing with js is you can construct a new Error and not throw it and still get the stack
ah true
after 10 fucking hours i finally finished my assignment
The issue was so damn easy
nvm iot's still broken
where's that ? coming from?
even if it's a whitespace it should be coded normally?
while(!infile.eof()){
initialise_pseudo_random(initial_value);
initial_value = next_pseudo_random_number();
char individual = infile.get();
cout << individual <<endl;
cout << "end" <<endl;
char init = rotate_char(individual, initial_value, action);
outfile << init;
}
outfile.close ();
infile.close ();```what i am using
ok so, you can't simply open the file and expect normal characters
when u manipulate characters directly you'll eventually enter in the special characters domain
you have a normal processed space, and then you have 2 whitespaces which counts as 1 character
I have a txt template to compare mine with, they have exactly the same but don't have the strange ? symbol
this is theirs
you either opened or saved the file with a different encoding
also that last char is probably EOF char encoded with ur algo
can I somehow make these chakaraui toasts start lower? I know that containerstyle exists but I dont know if I can do that with it
yeah i thought so as well
Yeah these are the encoded chars and they are not encoded with it
how would i remove this?
simply don't save the file with it
wdym?
the 15th line was done by my teachers, on purpose i think.
then just delete that line
It should stay intact. However, if the EOF() function was the cause of this is there no other way to do this?
not function, character
and no, there's no other way
the algorithmn is doing exactly what u want, the issue is in the input text
oowhh that's an easty fix then
i could check if my current char i am looping on (called init) is equal to the EOF character?
and if it is, simply return.
kinda
I saw something once and I want to get back to it
It was a .then with an object inside the function
.then(({something}) =>
Which gets specific keys/entries from the returned object
But how.
consider you have the object
{
"name": "Abc",
"age": 21
}
doing .then(({name}) => Console.log(name)) would print the name, which is the same as doing .then(obj => Console.log(obj.name))
it's just a shortcut
it's not an object inside the function, it's the deconstructor
it's like when u do import {a, b} from "./file"
so I tried make my new bot get total server it's in with this (old code from previous bot)
client.on("ready", () => {
let total = client.guilds.cache.reduce((a, b) => a + b.memberCount, 0)
console.log(`${client.user.username} is now online!`)
let activities = [ `${client.guilds.cache.size} servers`, `${total} users!` ], i = 0;
setInterval(() => client.user.setActivity(`${config.prefix}help | ${activities[i++ % activities.length]}`, { type: "WATCHING" }),5000)
})```
but it's only shown amount of member in 1 server + watching 1 server
*first picture is the old project and the second one is the new one (the second one is in 3 server*
that's getting the total members, not servers
it get total server and total members
invited it to new server and it now shown 2 server and not 3 (for some reason) but the total members is updated
yeh it only shown the 2 server the bot in and not the original server, ig it's not a big deal
cache is never guaranteed to have the actual number of guilds
same applies to any other cache
you are defining those numbers as static values, they will never change
you have to define them inside the interval so they are recalculated
const a = client.users.cache.size; // define the value once
setInterval(() => {
console.log(a) // will always be the same value because it was defined only once
})
``` ```js
setInterval(() => {
const a = client.users.cache.size; // will get the updated value on every interval
console.log(a) // value will always be up to date because its redefined on every interval
})
PS: setInterval 

/compress Krypton
Sounds stupid I know. But if I made a bot to fight suicide would that be against discord TOS or anything?
it'd be obnoxious af
Why?
you can't fight suicide by deleting any mentions of it
if anything you'll only remember the person about bad times
Who said that's what the bot would do :/
or in the very least, make the users hate the bot
Basically in summary the bot will do that and (if I'm able to get it) will send help. It's gonna be a challenge but I'll get it.
yeah nobody will be helped by that
wasnt there a story in the usa where a person called a suicide hotline, they sent the cops, and the cops shot the person?
🗜️
I do know that having some constantly remembering you that you're depressed only makes things worse
That's something that only happens in 🦅
and how do you know? oh wait you dont.
oh boy, I do
a long time ago, about 4 years iirc I had some hard times due to parental abuse
I can say for sure, the worst thing to happen is having someone trying to "help" you by saying "no dont do that" or "your life matters"
it doesn't help, in fact, it only made me feel worse since, when you reach that point, you don't give a fuck to hypocritical words from people that never bothered to help you when you needed
you want to help? treat the root cause, not depression itself
and a bot cant do that
I agree with this sadly
I have lil problem. I tried to get user.id in discord py using discord.User but it says that user has no tuple. When i printed only user i got something like this. How to get id from this?
these are arguments you can access using their keys, such as the name by user.name or check if it is a bot by user.bot
what you're viewing is the string-based object that was converted from the user object to a readable string
mostly used for debugging, though refer to discordpy's docs on what certain objects could have for parameters
i tried using user.id but it says it has no tuple
or maybe how i could covert this somehow
it should be provided correctly, granted that you've obtained it through discordpy
post your lines causing said error
code please
The whole command?
yes
most importantly from where you're defining user to where you're going to use it
@bot.command(pass_context=True, no_pm=True)
async def closeticket(ctx, * user_author: discord.User):
channel = bot.get_channel(1026486467071057940)
author = ctx.author
db = sqlite3.connect("main.db")
cursor = db.cursor()
if not user_author:
cursor.execute(f"SELECT user_id FROM tickets WHERE user_id={author.id}")
user = cursor.fetchone()
if not user:
return await ctx.send("Nie masz żadnego otwartego zgłoszenia!")
else:
cursor.execute(f"DELETE FROM tickets WHERE user_id = {author.id}")
await author.send("Zgłoszenie zostało zamknięte, a reszta danych usunięte.")
embed = discord.Embed(description=f"ID: {author.id}")
embed.set_author(name=f"{author.name} ZAMKNĄŁ SWOJE ZGŁOSZENIE", icon_url=author.avatar_url)
await channel.send(embed=embed)
else:
print(user_author.id)
cursor.execute(f"SELECT user_id FROM tickets WHERE user_id={user_author.id}")
user = cursor.fetchone()
if not user:
return await ctx.send("Wybrany użytkownik nie ma otwartego zgłoszenia!")
else:
cursor.execute(f"DELETE FROM tickets WHERE user_id = {user_author.id}")
await user_author.send("Zgłoszenie zostało zamknięte, a reszta danych usunięte.")
embed = discord.Embed(description=f"ID: {user_author.id}")
embed.set_author(name=f"{user_author.name} ZAMKNĄŁ SWOJE ZGŁOSZENIE", icon_url=user_author.avatar_url)
await channel.send(embed=embed)
db.commit()
cursor.close()
db.close()
so as far as I'm seeing, the user provided is through the user that used the command right?
yeah
what's the difference between author and user_author btw
one if the message author, the other one the ticket or
author = User that used a command
user_author = Given id when calling a command e.g. !closeticket <id>
ohhh
so discordpy automatically converts it to a user?
yeah
wanna like, try to fetch a user yourself? would be my guess
Alright, I'll try this, thanks!
even though it should theoretically work
you could also ensure its the correct type by using type(user_author) and echoing that back
because a tuple is not the same thing as a discord.User and would explain your error
since you cant obtain values within a tuple through string based indexes/attributes, only by number indexes
@rustic nova smell
no u
Ima make you drink a Caramel Macchiato
ew
Ima turn you into a starbucks girl
@rustic nova I got a lot of books from my library
Programming ones
I got 2 on python, one for basics the other for ML in python, one C# book and one about Assembly Languages and hardware
need a python one istg
Good stick to it I will do it differently. Anyway the question I have is an important one. If I don't have Message Intents then what can't the bot do?
read message contents it was not pinged in
Get message content
thats literally all the Message Content Intent does
it just denies the ability to read the content of messages it wasnt mentioned in
just the content will be undefined
So if I'm doing technical support in private messages bot, then I would need Message Intent?
So does he need one?
If its in DMs no
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
You're free to keep it disabled
Anything in a guild though if you wanna read message content outside of messages the bot is pinged in then yes
I would love to but I don't know why without it my bot doesn't respond to any commands on the servers. Only in private message.
well as the message content intent says
You need the GUILDS intent for receiving the messageCreate event in servers
commands will not work if you're talking about - for example
unless you're doing something like @Aurel closeticket
without the GUILDS intent messageCreate wont fire in guilds
oh okay
Any fields affected by the message content intent are noted in the relevant documentation. For example, the content, embeds, attachments, and components fields in message objects all contain message content and therefore require the intent.
...
Apps without the intent will receive empty values in fields that contain user-inputted content with a few exceptions:Content in messages that an app sends Content in DMs with the app Content in which the app is mentioned
Big thanks
Actually you need GUILD_MESSAGES (too)
The intent GUILD does not include messages
That’s a intent?
Damn proves what I know
Hey Fake wanna do half of my custom Halloween bot /s
Man… pigs will learn to fly before I ever touch TS or python
Also im always busy unfortunately
Can’t even get my own shit done
lmao
Tim hey buddy
Should I even bother with caching (gotta love autocorrect) messages for a rpg bot?
All I plan on doing as of right now is just listening for messages but I don't necessarily need those messages after
If you have no use for them afterwards, no reason to cache them
Though I thoroughly believe you’ll probably need to cache them at some point for an rpg bot
Hey there, I cannot figure out how to fetch a message for the live of me on the newest discord.js
I am doing
const msg: GiveawayMsgType = await client.channels.cache.get(giveawayDetails.channel).messages.fetch(giveaway.id)
.channel is the channel id
.id is the msg ID
I am sure its a small change I am missing but I can't find it in the docs at all.
Should I just store the messages on the channel class then waffle?
No error just not actually fetching anything
I changed it to
(await client.guilds.cache
.get("889928598927073412")
?.channels.cache.get("889928599552028714")) as TextChannel
)?.messages.fetch("1027730505434681355");
but its undefined
Those channels/guilds probably aren’t cached
the message is being fetched on start up
or, it was created while the bot is running
Log the values of those guilds and channels
One of them is probably undefined and therefore ending the chain early
Yea ur right
but what is weird is that up to guild it just logs the guild id
and then obviously the channel would be undefined if its just a guild ID
All this weird chaining…
Why do you even access the guild cache then access the channel cache?
you can access the cached channels directly as property of your client
Use fetch to get the channel once it’s not cached
Relying on things being cached is a surefire way to failure
Now then time to figure out how I wanna handle event listening
I am now realizing how lazy I am and dont wanna write a caching system that will work for anything
I am fetching all channels, messages, and guilds on startup already
What in the fuck
What’s the reason of fetching the guilds for example when they already being provided with the ready event
I mean fetch will access the cache anyways before doing a request but this doesn’t make it less confusing
Not to mention that your action may result in a major rate limitation you will suffer from later on for example when trying to fetch another channel/message etc. like you did in your code example
Ok, put it simply, I just need to get a msg so i can edit it
Fetch the message via its id
but something changed from v13 to now
Tried that and it broke, maybe I'm being stupid ill try again
TypeError: Cannot read properties of undefined (reading 'fetch')
const msg: any = await client.messages.fetch(giveaway.id);
Oh yeah I forgot messages isn’t a thing on djs
You’ll need to fetch the channel and then fetch the message from there
Ask yourself why you use ts in the first place
messages arent attached to the client only channels iirc
if youre doing that right after creating the client, the channel is not gonna be cached yet
you would need to do it in the ready event
Has anybody ever found out how mobile browsers utilize the feature to switch between a desktop/mobile version of the site?
Like a m.site.com?
It does not fake it’s screen resolution
No, that has nothing to do with my question at all lol
Detecting the screen size or user agent and redirect the client has nothing to do with that
Browsers like safari or Firefox on mobile offer the functionality to show the desktop version of a site or mobile version (you can switch back and forth)
The browser doesnt control that does it?
the site does, All it(the browser) does as far as I can tell it detects the viewport scale.
There aren’t much sites supporting this functionality but I yet couldn’t figure out what exactly happens in the background
No the viewport doesn’t change as well as the screen size
Nothing is faked by the browser
To emulate a desktop client
There must be something else I don’t think of
Well, css only checks viewport size/scale right?
for media queries
Your backend wont know that though
Ie a brower will process the css as if its viewport is 1920x1080 but the viewport might only be 900x300 or something.
(which would be called viewport scaling iirc)
But I'm not a web developer and could be 1000% wrong
I’m not sure if that is handled via css
I somehow guess it’s a specific browser feature you have to build and use
My site does not account for it and it does it fine
Just using media queries for the responsive layout
Yes, me too
Which results in using that browser feature actually does nothing
But it’s sometimes a good thing or necessarily to get to view the desktop version
🤔 are you saying the desktop switch doesn't work for your site or it does?
It does not lol
The browser does not fake or emulate a different screen size and does not report a different viewport
IT DOES SOMETHING but idk what
ah, it works for me just using media queries.
Which leads back to my original question, is your mobile version using a seperate mobile site(ie, m.site.com)? or using media queries for a responsive layout between desktop and mobile.
I’m just using media queries
Anything relies on the reported screen size of the client
Is your media queries set to the standard size for between mobile and desktop?
I cant remember what that is, but there is a standard media query size
Wut
The default layout is of course the mobile view and various media queries catch screen sizes larger than XX
1280px wide is the standard resolution to start displaying a desktop version.
If the desktop flag sets the width to 1280px wide, and your media queries show the mobile version at that width it wont do anything.
It’s actually 1200 if I’m not wrong
And no the client doesn’t report a different screen size when using that switch
You can find That out yourself
Just open the site and use the switch and debug the parameters your client provides
Even if so, my media queries catching view ports larger 480px or 960px would be triggered if 1280px really would be the case instead of 1200px
But that’s also not the case
Which means the browser does not emulate a different screen size
I'm not sure what else it would be then
🤔 So, just playing around with my css files.
@media only screen and (max-width: 980px) { allowed the desktop setting to work.
@media only screen and (max-width: 979px) { did not allow it to work.
(using chrome)
Other browsers might use other levels
playing around with a max width is a horrifying solution
You should always use min widths
Scaling it towards a desktop size showing the mobile version by default

That's a discord limitation not mine
Long time top.gg user, first time joiner...
In discussion with my DAO team, we envisioned collecting the "shared servers" of Discord members to sort of 'word cloud'-esque map of server populations. I am wondering if Top.gg has anything like this already in the works, or if someone here might have a point of contact for a commission or collaboration?
For example, if you put in the uid of all members of a channel on Discord, it could create a map with all their servers (or at least all those shared by 2+ members) that shows the relative population crossover
@earnest phoenix https://www.youtube.com/watch?v=cC1CqyCN9Q0
When you are new to a group, sometimes it's hard to fit in. New-to-Linux users often find that it is hard for them to fit in with longtime Linux users. So here are some tips on how you can start acting like a longtime Linux user...so you can fit in.
MUSIC :
► Adrift by ELPHNT (from YouTube Audio Library)
IMAGES:
► https://en.wikipedia.org/wi...
Wow! Now have a look at this
https://youtu.be/Tdbr_wm6rI4
Oh well 
Will someone give an example of some command that requires Message Content Intent to work? Besides Automod
Any command that takes response back
Actually not anymore since modals exist as direct way to response
Even if they’re lacking a lot of field types
Do modals work on mobile yet
They work on mobile since they got introduced
Wait discord actually added something on launch with mobile support
no fucking way
Discord never supports the cool shit on mobile
Just android users were fucked using the old client iirc but who gives a fuck about them 
True and optionally being able to click them to open a full screen, scrollable overlay

Some are, no?
print("uwu")
console.log("uwu");
Yeah
Not all
Is mongodb a good database for bots in more than 1000 guilds
Or are there other better databases in terms of performance
MongoDB isn't really good for scalability, so you'll have a hard time with performance and similar stuff, if you want a good and scalable database then you should use PostgreSQL
Good morning,
I have 2 things to ask
-
Does anyone have a document that I can setup/host my own lavahost (music)
-
[error] Unhandled exception : 'user is not allowed to do action [find] on [test.guilds]'Does anyone know what went wrong?
Lavahost? Do you mean hosting a Lavalink server?
Im not sure. I was told to use this lavahost thingy for music for my bot
There's no such thing as Lavahost, you're looking for a Lavalink server
https://darrennathanael.com/post/how-to-lavalink/
thank you. Anyidea for my 2nd question?
What is that error thrown from?
Does anyone know how to remove the short white screen when switching pages in a react site?
.
This isn't specifically about development but just shooting my shot
My VPS' connection just fails
It doesn't shutdown
It just can't send any requests
Or receive
This happens about once a day for 5-10 mins
I saw using uptimerobot it happened twice within 30 minutes
1 minute downtime and 4 minutes
I don't use atlas but I might know the issue. I'll brb
The same issue can also occur in the MongoDB drivers, the one you're currently using right now
Is it possible to connect to the server via SSH/RDP within that period of time?
Was a datacenter issue but nah
All connections r dead
Ok… so network specific issues
Just for the statistics, what’s your provider if I’m allowed to ask?
Anyone here with a good knowledge on express js?
Just ask your question
I am typing it, 20000 character code
lol
https://pastebin.com/N0XZ1tq8
I get a ERR_EMPTY_RESPONSE
when calling /movies/xx
I dont know why
(I hope there isnt any passwords in there)
(I removed all unnecesary parts)
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.
I make a file ready with a websocket
and then I request data to /movies/xx
but then it gives me an error empty response
I see in the console that I have a request, but in the browser or with curl it doesnt send anything
can you dm me templates of multiporpse discord bots
We dont do that here
If you have passwords in there then that's an issue
you know you can just do this:
app.get('/movies/:xx', async (req, res) => {
var reqResource = req.params.xx;
Sure, but that doesnt explain the error, locally via http it does work, via https not.
local https?
Not tried, I am working on that
self signed probably
Why not use a reverse proxy like nginx?
I thought having cloudflare was enough
but it works if you bypass cloudflare?
Yes
you said it worked locally, like using localhost?
bypassing cloudflare does work over http
yes
Doesnt work either
So it just does not work over https
but why
perhaps ur ssl is configured wrongly
also, you should use cloudflare origin certificate instead
That should not be the case.
First I had that my code would read a file smaller than 2gb and it worked.
A couple of days ago I worked out how to get a buffer from a 3gb file and it is not working anymore.
That cant be a ssl issue
I couldn't find evidence that the extra 1gb is a problem.
I have a hard disk full of movie. I want to read the movies for personal use. (It is not illegal).
So my api sends out sometimes 3gb out of movie data.
are u sending it as a stream?
return res.end(moviebuffer, "binary")
I dont think so
well, that could be the issue
if ur api takes too long to return an answer, the connection may close prematurely
aka "pipe broken"
Also, cloudflare has file limitations
I know, I have my settinjgs on DNS only
fo anything bigger than 1gb you should consider using a stream instead
Ok, i can try
Still the same error
what kind of value are u returning?
https://stackoverflow.com/questions/13106096/stream-files-in-node-express-to-client this is what u should use
thats a big nono
you should never use buffers for large files
always use streams
unless the chunking code you're using only returns small buffers
I also imagine 2 simultaneous requests would crash the api due to OOM
Yeay, it is personal use with password. So nobody can use it except me 🙂
still
It worked for 1.8gb files so I didnt complain. Then when the files get larger fs.readFileSync thought it was to large. ugh
Then I could not make it work anymore
Ok, I am working on it. I come back when I cant get it to work.
const headers = {
"Content-Range": `bytes ${start}-${end}/${videoSize}`,
"Accept-Ranges": "bytes",
"Content-Length": contentLength,
"Content-Type": "video/mp4",
};
res.writeHead(206, headers);
const videoStream = fs.createReadStream(videoPath, { start, end });
videoStream.pipe(res);
this will read only the specific chunk from disk and stream it directly to the response, so it doesnt need to store anything in memory
const express = require('express')
const Topgg = require('@top-gg/sdk')
const app = express()
const webhook = new Topgg.Webhook('ok')
app.post('/vote', webhook.listener(vote => {
db.add(`votes.${vote.user}`, 1)
let value = JSON.stringify({
embeds: [
{
title: "Un nouveau vote est arrivé !",
description: `<@${vote.user}> vient de voter Synapse sur Top.gg !`,
color: "255"
}
]
})
fetch("webhook lol", {
method: 'POST',
headers: {
'Content-type': 'application/json',
},
body: value
}).catch(e => console.log('Erreur : ' + e))
}))
app.listen(3000)
``` I'm on replit but idk if works or no and idk if I use the good port :/
that 10 times better than what I have
thx
thx
use process.env.PORT instead of 3000
yes but I need to add the port no?
replit uses dynamic ports
that env var is the port replit exposes
the correct port is saved in the env variable
then I have nothing but it will be working?
yup
oh ok ok, I will test, thx
its a built in env var
Okayy
that also solves my memory issue. :))
hehe x)
I mean, 3gb in ram isnt that bad
when starting to write the code on a normal pc I had 80gb in ram
80?
i mean, why use 3gb ram when you can use 50mb instead
I had every movie on my hdd in ram
lmao wtf
not the smartest plan
...don't u mean 8gb?
how much ram do you jave?
no 80
128
80 ain't achievable no matter how I look at it
lmao
128??
i mean
Little overkill pc
thats just 4x 32gb sticks
Yes
And after I added another batch of movies, I had 330gb
that's like, not something u can call "normal pc"
Its not normal, but more and more "common"
only for first world countries ig lul
around here 32gb is already considered a lot
i have a laptop with 8gb xd
I have a "small" server with 8gb
and to think mere 20 years ago we were reaching impressive 16gb hdds
i had a quantum fireball 3.2gb
I have another small question.
I have now a video element on html and when I want to skip to a certain part it loades the whole movie.
Anyway to avoid that
(I do it on html, because with some flags enable in browser you can select your audio track and because dvd had multiple audio tracks, i wanted that to.)
the progress bar should be linked to the chunking
so when you click on it, the correct chunk should be calculated and requested
i never really did that myself so i dont know the specifics
I just skipepd from 00:00 to 1:11:43 and it wont go after getting 600mb
almost fully loaded
lmao
I hate html
are you using a player library or are you coding your own html player?
just my own html
maybe this will help
but from what om reading, you might have to use advanced stuff
the html5 player doesnt give you much control
most players use stuff like mpeg dash and hls
troll
when code is so magic that it starts emitting an aura
me when char::from exists
From<u32> is not implemented for char
the code is blazingly fast that's why 😎 💪 🚀
imagine using unsafe in rust
code as u8 as char
Chars can't be larger than a u8 anyways so you're just making it harder to read the code
Assuming Self::Character is char ofc
By votes or auctions
easy to use or not
where is api ?!!
Ok, thank u
github
u can also simply make ur own api, shouldn't be too hard
I want something ready
well, most will be paid (for obvious reasons)
Explain more
you see, apis that allow file upload inherently need high storage space, and to be able to sustain a high amount of users they either
A - have paid plans
B - have very low per-user allowed capacity
C - have very low file lifetime
else someone could just upload a ton of junk to purposely fill their storage capacity
and yes, there are people who would do that just to see the world burn
true I know that, and I assure you you're right
happened to you?
It happened in my old project
it has custom domains feature? 
probably cnaming your domain to theirs
I got a nice array here
But I want it to filter entries that are 5 minutes old or less
Using the epoch timestamp "creation"
Tell me how
.filter(f => f.created + 60 * 5 > Date.now() / 1000) is what I got now 🥶
The object key is called creation not created
At least that’s what I can see in your screenshot
filter((item) => Date.now() - item.creation * 1000 < 300000)
Same like yours but multiplying instead a division to prevent floats
@dry imp wtf is this for/else shit in python
its so useless
It’s python, that’s what’s wrong
shut up fake ur opinion dont matter 🙄
wdym its useless
Reminds me of myself
for/else and while/else has no use imo
even this guy agrees https://www.youtube.com/watch?v=6Im38sF-sjo
Guido van Rossum said that if he had to make Python again, he would have never put for/else and while/else into the language. Why would a potentially useful feature that saves extra variables be seen as such a mistake? Find out in this video, where we see how for/else while/else work, where they came from, and why you should probably avoid them ...
I just learned about it and figured out how useless it is
i thought the else was in the loop
basically the way it works is if the for loop ends naturally then the else runs
How, when, why?
so if you break it yourself it wont run
Hello I've been stuck on this error and tried a lot of methods but still dunno 
What's even the point of it then?
yea i know but its damn useless
Lmao this is more useless than do...while
it was modeled after how loops would work if you used labels and if statements instead
do...while is useful if you want to run the code at least once before checking the conditions
Well, u can always just Initialize the variable as 1 less
But it at least has a niche use
def basic_syntax_while():
x = 0
# START_LABEL
if x < 3:
# break means GOTO END_LABEL
x += 1
# GOTO START_LABEL
else:
print("DONE")
# END_LABEL
This is the example the guy used to illustrate how it was envisioned to work
misty, why did u learn this
I was bored
else in the case of for/else should be named to nobreak because it only gets run if there is no break keyword in the loop
:p
Nobreak 🔋
lol
Pretty sure some kid is being mowed down rn I hear a chainsaw and kids screaming
Halloween month is fun!
naughty boys have 0 tv/internet/phone time at the weekend
Instead they will work in my mine
sulphuric acid with your bare hands 
it will fuck up the char if code is greater than 255
chars are u32 codepoints
@rustic nova lets play roblox
ayo sure
yw
😳
btw not me being in pain rn
also 5 am much
just a part of the pain im going through
You could be doing that better im sure
idk python yet so I cant say
shameless
smelly @sharp geyser joining vc
</play input::ID>
It's not working plz help
Coz of 2 collon it's not working any other way to add collon to my input
Why do you put 2 :, just use one and place the name before and ID after that
</play input:0> - </play input:0>
use a f string
also use __slots__, it minimizes the object's size in memory

disgusting
unless you're making it backwards-compatible to Python < 3.6, there is no reason not to use f-strings
Hey is there a way i can set a custom property on "MessageButton"?
i added the types but when i click on a button i dont see my custom properties
As long as your structure is cached/in memory you can attach/add whatever you like to it
As well as overwriting/deleting properties etc
What actually is a “message button” for you?
You’re speaking about message components -> buttons?
hello

93.158.92.13 - - [08/Oct/2022:08:23:16] "GET /humans.txt HTTP/1.1" 302 219 "-" GET /humans.txt
lmao
that's how I search the web for humans, too - never found one yet
guys does anyone knows any good discord bot hosting which is free or very cheap(under 5$) with which i caqn deploy code from github
what specs
i am not allowed to use any libs
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;
char individual;
while(!stop_counter){
r++;
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);
for(int i = 0; i < 56; i++){
cout <<a;
if(a == arr[i]){
//code
}else{
//code
}
}
}```I need to implement a code that would basically check if each character in the file that gets decrypted to variable a, is in the array. If that's the case, it will stop. Else it will keep on moving on and incrementing the r. However right now it doesn't work as i don't know what code to add to the last if statements.
any specs over 1gb ram and a good cpu ( my bot has 100 commands and is in 170 servers)
Something.host
i heard good things about that advin thing
yea no under 5 tho
but id still recommend hetzner even though its more expensive
doesnt advin have like 2gb for 2 bucks?
nah
apart from their invoices
the plans dissapear on my end
o
hmm
i bought it before i know there is that plan on the amsterdam kvm standart vps group
not there anymore tho
would anyone know what do tho? Because i am like totally stuck
youre right, its not there
you can write a function yourself
i have done this. But i don't know how to proceed
i am mainly trying to read a file and get all the characters. Then i want to check if each one of those characters is in the array.
because imagine i do: c++ if(a == arr[i]){ bool_var = true; }else{ bool_var = false } it might work for 1 character, but the file contains like 20 characters or so
You could simply use std::find() for arrays, for example:
Foo foo[10];
Foo *bar = std::find(
std::begin(foo),
std::end(foo),
baz // Element you're looking for.
);
bool found = bar != std::end(foo);
Why are you using a variable? if it's equal then stop, otherwise continue the loop
those are your conditions right
yeah
those are my conditions indeed
the only problem atm, is that if the first is equal it will stop the whole loop, However there are lots of other characters in the file that didn't loop yet.
should i give you some background info?
Tell me what do you want to stop
{}:}|"}|463262"}```imagine i have this file. I will need to create a function that will find the number r where all these characters are normal characters (that are in the array). This is an assignment about encrypting/decrypting using OTP and i already got the function to calculate the decrypted character.
i only want to stop the loop if ALL characters are in the array
else i want to increment the r
not sure if you get me
please ping me if anyone knows the answer.
i've literally just sent him that
Ah I didn't look at your linked SO thread, didn't know it included that
then you can use a simple for-loop
is he searching through an array for an element?
Just do a linear search, or binary if you know the array is sorted
yeah i have done this but the issue is that I only want to stop the loop if all the characters are in the array
Then count the amount of characters that have been found in the array, and stop when it's the expected amount of characters
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;
char individual;
while(!stop_counter){
r++;
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);
for(int i = 0; i < 56; i++){
cout <<a;
if(a == arr[i]){
//code
}else{
//code
}
}
}```so what this code does is that it decrypts a file. The file with the chars are already given, but i now need to find the r of the above formula that they used for encrypting
okay i will retry it rn
Also you may want to use a formatter like clang-format, it might also be supported by the editor you use already
//above the code when it reloops as not all characters are equal it will set the counter to 0.
if(a == arr[i]){
counter++;
if(counter == 30731){
cout << "done";
stop_counter = true;
}```Only issue with this is that it keeps on looping. Even with only 2 characters it keeps loopin forever. Even if the 30731 is set to 2 in this case
voltrex, stop promoting llvm programs
Yeah i will. I already have one but usually only format at the end.
Hehehe, never! 
it's like "Oh you're trying to learn JavaScript? then you should use our popular Node.js runtime, where you don't have to use a browser to use JavaScript"
Oh just because I mention a popular project/program that they could use I'm somehow trying to self-promote or something? I'm just helping
💀
I know that I'm a member of the LLVM Developer Group but that doesn't mean I can't mention it's projects/libraries when applicable
helping what
Their formatting is off-putting, so it's harder to read to help out
it's normal since they are quite new to c++
In this case I'm sure it's not because of Discord
.setDescription(
`__**Top.gg**__\n${
checkDBLVote
? `\`In ${ms(user.lastVoted - Date.now() + DBL_INTERVAL, {
long: true,
})}\``
: "[`Available Now!`](https://top.gg/bot/1000496153462329496/vote)"
}\n\n__**Rewards:**__\n`
)
Not sure why it isn't updating with the time after I vote.
this is barely readable, could you format it correctly so it is more understandable
Sure! Sorry
await message.channel.sendCustom({
embeds: [
new MessageEmbed()
.setDescription(
`__**Top.gg**__\n${
checkDBLVote
? `\`In ${ms(user.lastVoted - Date.now() + DBL_INTERVAL, {
long: true,
})}\``
: "[`Available Now!`](https://top.gg/bot/1000496153462329496/vote)"
}\n\n__**Rewards:**__\n`
)
.setAuthor(
message.author.tag,
message.author.displayAvatarURL({ dynamic: true })
)
.setColor(message.guild.me.displayHexColor)
.setFooter({ text: "https://universebot.xyz" })
.setTimestamp(),
],
});
lol
still can't really tell what it is supposed to do, sorry
it sends an embed
...
what do you want 
Have you tried logging user.lastVoted and see it actually updates when you vote?
And assuming user.lastVoted is a timestamp, it'll always be lower than Date.now() and since you're subtracting them, you're working with negative numbers here or if that's what you intended on doing
man I wanna rewrite some of the components in my ECS to not be as messy
perhaps I should have a lot of systems that do specific tasks instead of one big system that does a lot of tasks
im trying to refresh a discord oauth token, but this is returning unknown grant type for me. anything wrong?
let DBL_INTERVAL = 43200000;
let lastVoted = user && user.lastVoted ? user.lastVoted : 0;
let checkDBLVote = Date.now() - lastVoted < DBL_INTERVAL;
how can i set middleware on a single path like:
like it calls it whenever /api is called
/api/1
/api/2
/api/3
in express
That looks correct to me, are you sure you're making the POST request to the correct endpoint?
if im posting to incorrect url the response should be different
Actually the incorrect oauth2 endpoints would give kinda the same response because of the grant type, are you making the POST request to /oauth2/token?
using @discordjs/rest and discord-api-types
Weird, then I don't see why that error would be given as the response, it feels like it's an issue from @discordjs/rest
well, it is fine when im requesting first token
just no for refreshing it
i dont see it a package problem
Ya my formatting is just fucked indeed.
Maybe try asking in https://discord.gg/discord-developers , the documentation might be outdated or something
they ignored me, asked like 3 times no response
Did anyone find the answer on this btw
@earnest phoenix this should be correct right?
Those are correct yes, but unrelated to what I just said; check if the lastVoted value actually updates when you vote, and swap the subtraction positions, user.lastVoted - Date.now() -> Date.now() - user.lastVoted in the initial code you showed
Can this random() method be put on a seperate class and be called from there?
https://cdn.hamoodihajjiri.com/U5UVRG2jTP
Learning more about Java. :)
Can't think of a better way than this: https://cdn.hamoodihajjiri.com/jxvf4kjkki .
huh?
Why not just do RandomPassword.random(10)
No need for a constructor for a class that only contains static methods
Yeah isnt really necessary to initialize a new object for that
Hm.. really?
better to just make it a static method
It's shorter though?
It's worse for performance
Or it's not best practice?
And it's a bad practice
You should only ever use new for objects that need to be instantiated because they keep track of some sort of data
This method doesn't need any object specific data
Sweet.
Lastly, when should I be using static and when should I instantiate a new object? 
All I know for now is that static just makes my life easier, but I haven't understood the correct difference.
You should declare them as static if you want to use them without instantiating a new instance of the class
Otherwise don't mark them as static, as it'll then become a prototype property/method
Other than that it doesn't really matter, because the performance difference is basically almost the same, just the semantic usage is different
You've got an array with strings, see the strings as an authentication or proxy list
I want to iterate over that array, each time it should run a function (promise) and wait for it to resolve or reject before continuing with the next item
I know the javascript is full of crap
And isn't async
So how would I?
For that you need to be inside an async function, because that's how asynchronous operations work, not just limited to JavaScript
So if I would for loop the array, it would indeed wait til it has been completed correct?
await func(item)
Yes it would wait until the promise of the called function is resolved before going to the next iteration
Performance difference is not the same. One instantiates an object that the gc has to clean up, whereas the other just creates a call to a method afaik
In small scenarios like that yeah it's fine, but definitely not good practice
The process wouldn't be kept alive for a long time
That's not what I meant in that case, I meant like the performance of static and non-static functions are the same (not talking about class instantiation)
Not a production thing
It's just: Complete those tasks and kill your self (process.exit 😅)
It'll resolve all the returned promises, and return the resolved value
It'll just keep resolving the promises until there is no promise to resolve?
Yes
Pretty much what I want 😄
The history of JavaScript over the last 25 years. How did a simple scripting language for Netscape evolve into the world's most widely used programming language? https://dev.to/codediodeio/the-weird-history-of-javascript-2bnb
Full Course: https://fireship.io/courses/javascript/
#javascript #history
Sources:
ECMA https://www.ecma-internationa...
Every language has it's own weird history in some ways
Is this the same with .forEach?
The forEach() method does not wait until the promises are resolved, it keeps going to the next iterations regardless
No
That's pretty !awesome
like personal homepage

