#development
1 messages · Page 1997 of 1
my personal laptop is mid range
but my production servers and shit are all low end
I'm assuming they get by with quite the headroom?
from?
1gb 1core
legendary
well my stuff isnt that big either
ever since top.gg got rid of certified section my bot has been permastuck at 9.5k guilds
lmao
rip
It do be like that 
lmao

Cert front page definitely was nice.
3k in a year 
View the historical performance of up to 32676 bots listed on Discord Bot List (top.gg). Updates hourly.
did a few ads the last week, bumped my count about ~110%
all thanks to certified section, i would often gain 100+ in a day just from showing up there
that is insane
which basically means
steady
dafuq
one minute breakup
rip shard 0
contained in 150mb mostly
cacheless 👀

too bad that'll be dead soon
AmandaDiscord/ThunderStorm

tiny-discord :^)
fair
still don't trust Tims software
bro his gateway code is 🪄
i guess its good enough for people to rip it off :^)
I asked for consent D:
xD
You wouldn’t happen to have experience in rotating ipv6 blocks would ya? Using a package which idk if I can talk about since technically again tos but ig its to prevent ratelimiting. It works, tho it just errors on binding. #development message
thats useless for discord ratelimits, or are you talking about another service?
Another.
star the message right below that link
Dmd incase a moddum doesn’t want me talking about a again tos lib
does that happen randomly or on all addresses?
All
Atleast i have not successfully had an ip bind yet after 20ish attempts
Its a /48 block btw
well i have no idea, but it sounds like a linux / ipv6 configuration issue
does it work if you try to run some random server on one of the ips?
I wouldn’t know that one tbh since im running it off of a friends server and he says it should be configured correctly he thinks. He uses he-ipv6
try binding a server to one of the ips
Ill let him know.
for example http.createServer().listen(port, one_of_the_ips_here)
If you have a ipv6 tunnel and ever wana give it a try for testing sake lemmy know as i hope its just an issue with their lib since that code was implemented just 3 days ago lol
But well mess around with it some more and try your suggestions
im using node-fetch, and i want to catch an error when it occurs, so it doesnt crash my bot, but whatever i try, catch(), try {} catch {}, it crashes my bot and exits the process when the page isnt json. How can i prevent that, and instead catch the error and preventing my bot from crashing and exiting the process?
code ```js
try {
response = await fetch(https://www.mentalfloss.com/api/facts)
} catch (e) {
functions.err(An error occured while trying to fetch a fact from the API., e);
return client.user.setActivity(`The facts API doesn't work :sob:`, {
type: type
});
}```
error node_modules\node-fetch\lib\index.js:273 return Body.Promise.reject(new FetchError(`invalid json response body at ${_this2.url} reason: ${err.message}`, 'invalid-json')); ^ FetchError: invalid json response body at https://www.mentalfloss.com/api/facts reason: Unexpected token < in JSON at position 5 at C:\Users\Luckie\Desktop\discordbots\crazyclown\node_modules\node-fetch\lib\index.js:273:32 at processTicksAndRejections (node:internal/process/task_queues:96:5) at async status (C:\Users\Luckie\Desktop\discordbots\crazyclown\index.js:78:22) { type: 'invalid-json' }
try-catch wont work for async functions
how could i make a working version?
.catch(...) after fetch
also since the error says "unexpected <" youre very likely fetching from the wrong url
show the error
the url returns a 404 that happens when the api goes down sometimes, so i dont want my bot to crash when that happens
return Body.Promise.reject(new FetchError(`invalid json response body at ${_this2.url} reason: ${err.message}`, 'invalid-json'));
^
FetchError: invalid json response body at https://www.mentalfloss.com/api/facts reason: Unexpected token < in JSON at position 5
at C:\Users\Luckie\Desktop\discordbots\crazyclown\node_modules\node-fetch\lib\index.js:273:32
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async status (C:\Users\Luckie\Desktop\discordbots\crazyclown\index.js:78:22) {
type: 'invalid-json'
}``` the same error
show how u did
similair to this one ```js
const data = await fetch(https://api.popcat.xyz/chatbot?msg=${encodeURIComponent(message.content)}&owner=Crab+Developments&botname=Crazy+Clown).catch((e) => {
message.reply({
content: :ccCross: An unexpected error occured while trying to fetch a chatbot response. The developers have been notified.
});
return functions.err('An unexpected error occured while trying to fetch a chatbot response.', e);
});```
if it throws an exception, it can
actually maybe it can
let me test it without that thing
nope does the same
response = await fetch(`https://www.mentalfloss.com/api/facts`).catch((e) => {console.log(e)})```
what is index.js line 78?
inside node-fetch
oh nvm
https://cdn.luckiecrab.nl/i/Code_iE4omOewqS.png i didnt see it 💀 does that cause it?
const activities = [
`LISTENING:`,
`PLAYING:`,
`WATCHING:`
];
let type = activities[Math.floor(Math.random() * activities.length)];
const response = await fetch(`https://www.mentalfloss.com/api/facts`).catch((e) => {console.log(e)})
const data = await response.json();
const index = type + data[0].headline || data[0].shortHeadline || data[1].headline || data[1].shortHeadline;
const regEx = /(<([^>]+)>)/ig;
if(index.match(regEx)) {
await index.replace(regEx, "");
}
console.log(index); //Remove after test.```
i think you changed something, so the error is no longer on line 78
yeah i removed that try-catch
anyway the proper way to do what you want is like this:
oh waiit ofc it was this line ```js
const data = await response.json();```
now that explains everything
cause i looked in the node-fetch/index.js where the error occured and it was in the .json() function
:))))
let data;
try {
const response = await fetch(`https://www.mentalfloss.com/api/facts`);
data = await response.json();
} catch(e) {
console.log(e)
// do something
return;
}
thank you
or you can do ```js
let data;
try {
data = await fetch(https://www.mentalfloss.com/api/facts).then(x => x.json());
} catch(e) {
console.log(e)
// do something
return;
}
in this case, putting .catch() would reduce it to a one-liner no?
or you can do ```js
const data = await fetch(https://www.mentalfloss.com/api/facts).then(x => x.json()).catch(console.log);
if(!data) {
// do something
return;
}
xD
anyone has a nice facts api?
i saw that but the rate limits are-
It's also paid nvm 
thanks that looks nice
why did they even change that anyways
oh right probably because they're moving away from discord
why to daos and nfts 
mfs predicting discord will fuck them over one day
like they haven't already
why tf is my user ID on the page my discord ID then?!
basing your business on another business is really risky i noticed
sure you get people immediately but at a massive risk
well everyone who does that knows that
e.g. any mobile app
it is snowing here as well
Lmao I totally pocket sent a picture
bro whenever i go into the djs server to get help i immediately feel a negative atmosphere 💀
That feeling doesnt go away
that's the majority of bot communities
because realistically most people around them don't know anything, and have just been brought up with the whole negative atmosphere so it's just a cycle of people shitting on each other while equally knowing just as little
Anybody here being familiar with Twitter API? Limits etc.?
I would need to get ~85k posts of a Twitter account in a reasonable time.
tf
idk what's worse, that someone did post 85k posts or that you need to fetch em
yeah it's a more or less offical source of game bans, I need to add them to my database and fetch the account every few mins
it's an automated system posting game bans, not users posting shit
understandable
87k is fairly moderate for twitter
so somebody here already having API access and wanna catch the posts for me? I'm ok with a simple txt file containing the message content
(which is just an URL)
@quartz kindle You wanna earn a few bucks doing something for me?
wut
I would need to get ~85k posts of a Twitter account in a reasonable time.
excuse me tf?
just fetching them for, providing the tweet content for me in a txt file, or CSV or whatever
I mean, I'm seeing people with 20k, 40k, 57k, etc. on the platform
how many posts per day does that translate to for that individual
FakE's gonna pay money as I have no time to do that shit myself or any intentation to register on twitter
anyone see any downside/flaw to this?
yes now let's say 12 instead
12 years?
ye
That's more accurate
13 per day
yikes
since may 2015
that's a tweet every 2 hours
looks more plausible, but tf 13 per day
every few mins
800k
yeah I was missing a 0
i dont have a twitter account either
SOOoooo... you're motivated to earn some cash?
shouldn't be a big deal to fetch all user tweets and throw the content into a file
a big file
yeah no motivation for it?
nah, I'll pass
...too lazy to earn money, my gosh
bruh i dont even have twitter
me either
im a 9gagger
fuckers making me use puppeteer
you probably mean 9*chan
btw i take back what i said about my fts solution
sqlite fts5 is a billion times better
im just gonna compile all my data into an sqlite db file
the only drawback is that the file size is 5x bigger
but i'll taake 0.2ms queries over 10ms queries anyday
@boreal iron why not just apply to the research program and say it's for some science project
...
im guessing they actually have proper checks in place because they wouldnt just make an application for fuckers to lie and get access
like university ID verification and proof etc
i'll have a look
yeah
yeah that's getting a little bit tricky to fake
i guess that depends on your budget 😄
guess I will have to take some student as hostage
thats the spirit!
anyone with docker experience know the minimum amount of RAM you can get away with running a linux container?
or even easier the amount of ram a barebone linux container uses
not alot
average node js container uses about that
uses more for discord bot obviously
node js uses some basic linux stuff, so a barebones linux should be even smaller
debian stuff it uses
the kind of figure i was looking for (ram doesnt grow on trees 😢)
I thought it did
I'm sure you can get some when paying for emojis
wait until they manage to replace silicon with wood
omg imagine all the greenpeace retards crying about the wood
I think you've been proven wrong
turns out its just a tutorial showing you how to configure swap
nope it's downloading more ram
fuck
sqlite's fts5 only has a trigram tokenizer
i need an ngram tokenizer with minimum 2 chars
For what purpose?
2 char ngram is gonna produce a metric fuck ton of terms
And also probably gonna hurt perf quite a bit because of that
its a list of 500k asteroids, some of them have 2 char names, like Io
? You mean like alias names or what?
i want full text search
with partial matching
for example if the person searches for eri it will return Eris and Amneris and eveyrthing that contains that term
trigram is perfect for my needs, but then searching for Io returns nothing
elasticsearch has a configurable ngram tokenizer where you can configure minimum and maximum chars
Setup a damn database
sqlite doesnt
I mean yeah
You could use tantivy if you're willing to use rust and want something embedded
It'll also give you much better performance over ES and Sqlite
There's also Pisa but that's intermittently maintained and cpp
Do you care much about the order of results i.e do you care much about the relevancy?
i can order the resulting subset myself with levenshtein
That'd be pretty expensive to do
still better than nothing
Amneris would have an edit distance of 4+ which is insane distance levels
but the subset is much smaller
Sure
searching for eris in 500k asteroids returns 6 results
Either way https://github.com/quickwit-oss/tantivy is probably your friend here for what you wany
Or you could do semantic search perhaps with a BERT model of some sort
That might produce more relevant results
how can i solve this error?
idk, i'd need something that also works with js xd
sqlite is good because i can offload most of it to disk
and as long as it gives me sub-millisecond performance its fine
XD
I mean tantivy will do that for you
But the JS bindings aren't maintained anymore iirc
can it build a database on disk tho? or does it need to rebuild the index on every runtime?
Tantivy use a segmented index like lucene
So everything can run on disk
It's quite happy to use < 5MB ram if needed
But generally you just use the MMap backend and let the OS decide what to do about caching
But it will store everything on disk
and persist for next run?
Yes
It's what powers the backbone of my lnx search project
Yeah that'd work
Although not sure if sqlite would give sub ms perf on 2 char ngrams
trigram gives me 0.2ms
Yeah but trigrams are very diffrent to ngrams
if only there was some sort of fallback with regular indexing
i could try making a separate table for all 2char entries and use a normal index lmao
actually i might just do that xD
In sqlites case a trigram tokenizer will split into 3 word tokens generally where n tokens = len_text / 3, with ngrams you produce every possible combination between the character length ranges
So the amount of tokens you produces tends to be exponential and/or quadratic
i guess id need to make a custom tokenizer that only does 1-2 char grams for the first 1-2 chars of each word
and trigram for the rest of the word
Do you only care about the prefix matching in that case?
I.e if i out Io would i expect to see ioo and not oio
yeah not sure, but right now not finding Io at all is a bigger issue
with 3 chars people can just specify further if it doesnt show up
Mmm
In that case
Maybe consider maintaining a seperate tri structure for doing prefix lookups? And then just add them onto your query so they match and/or just append them to the results?
And then when you start the system up just rebuild based off of the data in the db
its a possibility
Would recommend maybe looking at this https://github.com/wolfgarbe/PruningRadixTrie
PruningRadixTrie - 1000x faster Radix trie for prefix search & auto-complete - GitHub - wolfgarbe/PruningRadixTrie: PruningRadixTrie - 1000x faster Radix trie for prefix search & auto-complete
In terms of the structure you'd use
It'd also be alot more efficient search wise
interesting
Me when
Today we’re excited to announce our support and collaboration on a new Stage 0 proposal to bring optional and erasable type syntax to JavaScript. Because this new syntax wouldn’t change how surrounding code runs, it would effectively act as comments. We think this has the potential to make TypeScript easier and faster to use for development at e...
like python's typing API but without the runtime inspection
i tested a tokenizer function on the 500k datatset, trigrams got 4 million words, bigrams got 9 million, 2+ ngram got 19 million
now lets see if using these indexes directly with joins will be as fast as the fts5 plugin
If I have an integer like this:
172800
How would I convert this to 2 days?
Ex.
x = 2 * 60 * 60 * 24
You would divide it...?
172800 / (2 * 60 * 60 * 24)
Unless that’s not what you’re asking, in which case I don’t understand what you’re asking for
got a nice basic ban appeal system working
-1000000 social credits
your execution date is tomorrow
ching cheng hanji moment
Lowkey wanna steal the design
@fiery stream it'a only functional and buggy atm but definitely gonna improve it a lot 
I plan to add different types of bans too not just servers
Whats dluxe
A user
Lemme show
The user can submit an appeal with discord oauth with optional email notifications and will access that chat with other staff to discuss or appeal/deny with realtime messages
How does email notifications works you pay for the domain or like how
I remember this module it did for free or was api ion remember
I actually have it integrated with gmail using custom domain and no gsuite
looks cool what it for?
Does anyone have any experience with virtual host in apache?
so i have a folder for each user user1-user100
And i want to access it from a subdomain like www1-www100
How can do that
@earnest phoenix hint
I assume a discord bot then
Dash looks cool
Thx been working on it a lot
Some very useful features too like server suggestions, tags with its own prefix, message filters with rules for blocking ip grabbers, bitly links, ect
Can anyone here guide me through slash commands?
Py?
Idk then
aw
I've been trying everything I can find from the internet but nothing is working
I'm going to stop for today cause my back hurts sitting here.
hi
how do I give different roundness to an element at top and bottom?
Which api should i use then?
Oooooo nicee
Border-radius: 10px 10px 5px 5px iirc
does it go top left bottom right or top right bottom left
Top left right bottom right left iirc


Cool
I have button paginator, but how can I make it disable after the setinterval?
col.on('collect', async (button) => {
await button.deferUpdate()
if(button.user.id !== message.author.id) return;
if(button.customId == '00001') {
page = page > 0 ? --page : pages.length - 1
} else if(button.customId == '00002') {
page = page + 1 < pages.length ? ++page : 0;
}
curPage.edit({ embeds: [pages[page]], components: [row]})
setInterval(() => {
curPage.edit({embeds: [page[page]], components: [deadRow.setDisabled(true)]})
}, 5000)
})``` not working
What exactly is database indexing, and an example in discord.js, I suppose?
sure
database indexing is like a book index, you can tell the database to index a specific column (for example the ID field) it tells the database that that column will likely receive a lot of lookups and so it should pay extra attention when caching it
An example would be a modlog, you lookup users by their ID but if you had a lot of modlogs, that lookup would start to get slow since the database has to manually find the records
With indexing it can quickly locate those records and return them to you (usually in sub millisecond times) at the cost of some extra memory usage
you have to be wise and to index fields you only need to index otherwise this can result in a lot of memory usage and potentially worse performance
I appreciate it a lot!!
I need to learn how to apply that with MongoDB, or is that not possible, supposedly?
mongo does have indexing i think
what driver are you using?
Driver?
setTimeout(function() {
row.components[0].setDisabled(true);
row.components[1].setDisabled(true);
curPage.edit({ embeds: [pages[page]], components: [row]})
}, 15000)``` I've made a command that using a paginator, I wanted to activate the `setTimeout` only when the command is inactive, how do i do it?
Are you using the mongodb package or mongoose or smth else?
mongoose package.
@split hazel does mongoose have indexing
it does just need to pull up an example in a sec unless anyone beats me to it
how do u open the devtools in discord mac app?
There are different types of indexes but one for a unique column (which is probably the only one you'll really use) is
const User = new Schema({ user_id: { type: String, index: { unique: true } } })
something like that @feral aspen
You can also just use the _id field so mongo uses the user id as the pk field
setTimeout(function() {
row.components[0].setDisabled(true);
row.components[1].setDisabled(true);
curPage.edit({ embeds: [pages[page]], components: [row]})
}, 15000)``` so i used timeout but how can i set it when the button is inactive?
Hi
Listen to the interactions made by the buttons and set a timeout, and store it somewhere, once a new interaction is made by the same button clear the old timeout using the global clearTimeout() function by passing the timeout you stored, and setting a new timeout, and repeating the same process
ah thanks thanks
after trying to put clearTimeout() it seem its not working, ```js
var timeouts = setTimeout(function() {
row.components[0].setDisabled(true);
row.components[1].setDisabled(true);
curPage.edit({ embeds: [pages[page]], components: [row]})
}, 5000)
clearTimeout(timeouts)``` did i do it wrong?
I read the docs about two functions
oh wait
i just stopped the settimeout
That clears the timeout instantly, you must do a few checks before clearing it, for example:
// Set a map of timeouts to get and track them easily.
const timeouts = new Map();
client.on('interactionCreate', async (interaction) => {
// In your case, check if it's a button interaction.
if (interaction.isButton()) {
// Check if the button details match the one you want.
if (interaction.customId === 'something') {
// Construct a unique ID.
const id = `${interaction.guild.id}_${interaction.channel.id}_${interaction.message.id}`;
// check if the timeout already exists.
const timeout = timeouts.get(id);
if (timeout !== undefined) {
// If the timeout already exists, clear it and set a new one later.
clearTimeout(timeout);
// Reset timeout.
timeouts.delete(id);
timeouts.set(id, setTimeout(...));
} else
// If the timeout doesn't exist, then set it.
timeouts.set(id, setTimeout(...));
}
}
});
That's basically it
You can also choose to only store the IDs of the timeouts instead of the whole timeout instance for resource efficiency
AKA setTimeout(...)[Symbol.toPrimitive]()
How can I create a channel in a input category in discord.js?
Ctrl shift I?
that is not doing anything
does that work for u? on windows?
Help me! I have disabled this tip in VS Code and don't know how to enable it again.
who actually uses it tho
I do
may i ask why
it use it when using the untitled file to write example / psuedo code
interesting use case
Tysm😄
np
helpful as fuck
BUN CHAN FTW
how can i add a button to a div if the user's id = to owner id
ik how to see if user's id = to owner
but how to add button
ejs
is ejs one of them?
hmmm
not too hard
<% if (<object>.id == "ownerid") { %>
// button stuff goes here
<% }) %>```
lets see indeed
happy birthday @quartz kindle
How can I create a channel in a specified category?
Language?
js
ty same
Use <Guild>.channels.create(..., { parent: ... })
The first ... is the name of the channel, and the second ... is the category you want to create the channel in, which has to either be a CategoryChannel instance in Discord.js or its ID as a string.
For example, guild.channels.create("party", { parent: "1234567890123456789" });
ty Klay
Np, for other settings see https://discord.js.org/#/docs/discord.js/stable/class/GuildChannelManager?scrollTo=create
I would like to send a message to the channel right after I create it, should I await the create(), then send to it?
Yes, then call .send on it.
Though make sure you have a resolved instance, rather than a promised instance.
let newChannel = await partnerServer.channels.create(`${nomeCanale}`, {
parent: idCategoria,
});
newChannel.send({ content: `${messaggioPartner}` });```
something like this?
yup, worked, ty again
Yes
Does the one pixel in a <canvas> represent one pixel of the screen or does it scale like svg does?
yes, once pixel is one pixel
of the screen?
Tim 
of the image, not the screen
how the screen shows one pixel depends on screen size, resolution, zoom, etc
in svg the viewbox defines how many pixels are in the original image then css defines the rendered size of the element
is there a way to do something similar with canvas?
canvas is raster graphics, there are only pixels, nothing else
you can either zoom the canvas element or increase the resolution of the canvas
svg is vector graphics, not pixels
so i have to animate an svg now to get responsiveness 😔
it defines shapes and paths
shapes and paths and be scaled infinitely because they are just instructions for what/how to draw
but i wanna add the button to a div
well i am making a pong game which is just two rectangles and a circle
then put in div
that can be done in svg right
you put html inside that
yes
svg scales very well with size, canvas doesnt
canvas scales well with graphic complexity, but not with size
i want like if js <% if (id === 'ownerId') { %> //add a button to a div but how? <% } %>
but i already have the div i wanna add a button to it not create a new div
that is making a new div right?
please learn html and yes
<div>
<% if (id === 'ownerId') { %>
//add a button to a div but how?
<% } %>
</div>
ok ty
step 1: uninstall ejs

god I love me some <% } %>
React > ejs
@quartz kindle happy birthday
ty
react is so much more than ejs
Try learning svelte instead
just use template literals like a pro
export default {
"name": "ping",
"test": this.name
}
Cannot read properties of undefined (reading "name")
How can I solve this problem?
this refers to the global this in this case
you can't
It has to be a way of doing this
separate it
well, you could do this instead, which is pretty much the same:
export const name = "ping";
export const test = name;
not exactly the same as there's still no default export but still
export default { name, test }
or
const name = "ping";
const test = name;
export default { name, test }
Thank you
well that was a disaster, i gave up once the table grew past 10x the size of the fts5 table and still didnt finish generating
i might just go with 2 tables then, one using prefix and the other using trigram
doing a UNION query on these two tables still gives me sub-millisecond performance for most queries
I need small help with css
Please tell me how can i align this image exactly in the middle?
It's supposed to be responsive depending on the screen size
align-items: center
also, ur text aint in the middle too
its still in the left side
bro tip: use F12 -> Elements and change css there
you'll see it being applied in realtime
how do you know they are using a flexbox
align-items aint flexbox
It is
is it really? a bunch of times I just used it in raw html with no flex mention whatsoever and it worked
yes im using
display: flex;
align-items: center;
for the parent div
Is it only the image that needs to be centered or do you want the text too?
flex-direction: column;
align-items centers it vertically unless you change the flex direction to column
That also didn't work 😥
Im supposed to put that in the @media screen rule right?
lmao no
NVM I figured it out
I screwed up with the max width and width parameters of the img container, ffs
@prime mist just wondering, but what editor do you use
help , this code works only if the first statement is true and gives error in second statement although the code is the same only the parameters are diff and error make no sence
who is @prime mist
don't send again if someone doesn't answer straight away
someone will help when they can
mistake in code -_- in file , can't edit,
i think you pinged wrong tim
oh no that guy again
@pulsar bone
can you like put a normal username
@rustic nova change their nick to ultra stinky
They get z
You're pea now
?
-meow
purr
I’m trying to block moderator Academy scam etc, is it worth blocking the phrase “moderator” from usernames?
It would be easier than manually doing each name
Same with Hype squad
i was recommended regex
function useRegex(input) {
let regex = /moderator [a-zA-Z]+/i;
return regex.test(input);
}```
that would work?
yes but u could also use just /^moderator/i
heh, easy enough to bypass that regex
function useRegex(input) {
let regex = /^mod(erator)?.+/i;
return regex.test(input);
}
but then people with mod in their name
Why tf would you need global as flag? It’s enough if the regex has one match
i flag
what is i btw
case insensitive
Case insensitive
Most important for this case
I usually just lowercase the entire test string
actually, there are still cases of [MOD], xX MOD and stuff like that
so matching inside the string would be better
hi i want to create language setup for my bot (just 2 language) what is the best way to do it ?
big i18n files
can u explain more ?
name_of_property=Hi my bot works in english
name_of_property_2=Cool ain't it?
name_of_property=Meu bot funciona em português
name_of_property_2=Legal não?
Nope
name one file locale_en-US.properties and the other locale_pt-BR.properties
then grab by locale_${localeTag}.properties
so i need a really big json file
that's usually the proper way to i18n a project, since u can have N locales and allows external help without disclosing the database
can someone help me with something basic
just ask
this
you need to import Discord
Easiest thing to do is to create language files for your supported languages
Any var that outputs a string which would be replaced is available in your language file
Load all of them at the start of your bot into the cache, save the selection a guild does (choosed an available language) and return your cached vars for this language
how
that's...exactly what I said (except for the cache part)
im noob in this sorry
did you copy your bot's code from somewhere?
nope
object languages { "en" => { var1: … }, "es" => { var1: … } }
Ooh => lmao
PHP flash back
In this case a language map containing the vars with your translation under the language key
so yes, do this^ but cache the values after reading
you use different files for different langs
that's why I separated the codeblocks
note both have the same property name
You always be consistent to use the same in a map for example by choosing the right key for your language
How can i fix this?
Horrible
regarding the file ^
learn js before attempting a bot
how does that differ from your example?
define Discord
so im confused now
how 🥲
sorry
learn js and dont copy codes from github or random youtube videos even if i told you how to do it you will stuck in next parts
(unless you plan to hardcode all the values inside an in-memory map, which would be beyond bad)
i dont copy codes 🥲
const something = require("somewhere")
so how you dont know how to define something but you know how to code ?
You load your languages only once into the map, then based of the guilds selection you define a var
language = available_langs.map.get("en");
The use your consistent var names which are all the same for any language
You don’t fucking use your language selection on any var
What an horrible desaster to look at
i think big json is easier way am i wrong ?
For JS JSON probably is the best choice, yeah
While I’m using to parse INI files but not for JS
so what is the i18n ?
_internationalization _
Anyways… you load the languages once only
Then let the guild select its choice, then get the vars of your loaded language file(s)
And they have to be same on any file
ok
just a question
is there any different in one big json for each language or multi json file for one language i mean like 1 json file with 100 line or 10 json with 10 line is this have any effect in speed ?
At the place your return your strings, you for example use then:
embed.title = translation.embed_title_welcome_msg;
Or more useful saved as object:
embed.title = translation.embeds.titles.welcome_msg;
Well I prefer different language files
To not entirely loose the overview when having 10000 lines
It also makes sense as I use the language file names as keys for my language map
that's what I said aaaaaa
that's what I DIDN'T say
In my case for example en.ini, es.ini, fr.ini, de.ini etc
Which is what the user could select at the end
Not hard coded another time in my code
if you pay close attention, I wrote locale_en-US.properties <<<< see the file extension
bruh
You load anything once only and keep it in the cache
No 

both texts are indexed by the same property name
they're each in their own locale files
they aren't indexed by language code, the file name is
bruh
me?
@boreal iron well why do i need to use i18n? i cant understand
i read few docs but why?
i can just use
let language;
if (lang === 'en') {
language = require(english file location);
else if (lang === 'fr') {
language = require(france file location);
}
and save lang in data base
i18n is short for internationalization
for obvious reasons, we don't read it fully
Just because you’re lazy 
me and the entire programmer community

🥔
speak for urself sir
well i figure out why do i need to use i18n this way i dont need to check language each time!
Well where you save it and load it from is up to you
oh wrong reply
i18n is the concept of internationalizing something, not something you "use" physically
basically, by supporting multiple langs ur already i18n'ing
But hard coding the language selection in is weird,
When creating a dynamic system you want it to be dynamic lol
ok tnx
also don't forget to cache
Again this weird Brazilian language

sorry I don't speak car driver
lmao

he’s driving right now don’t distract him
He isn’t
richie
any recommended randomized meme api that supports searching?
With a grain of salt, yk, cuz reddit
There's a mod here that has an anti-nsfw filter
Don't remember who
Oof, It turned in to topgg search
Damn I was right
How do i update the username/avatar for my bot?
You can no longer do this from the developer portal directly for now due to a bug. It will be fixed soon. [...]
I mean you can’t for verified bots anyways, at least the name
Regarding the average development speed of discord this might take a while also in fact I guess it hasn’t much a priority at all
I mean April it’s what… just one and a half month until the message intent comes
There would be so much to do to improve interactions
hi i want to use i18n but i have a little problem
how can i find the data base for message.guild.id or interaction.guild.id in i18n to to set the language??
My gosh with a library you seem to make your life harder than needed
It’s actually really easy to do yourself and less confusing
Once your guild has selected a language you gotta save it and attach it to the guild object (which is the easiest way)
guild.selectedLangProperty = some language;
It available anywhere you have your guild object available
I don't think the library is relevant here
Like, Discord does tell you the user's and guild's locale
So you can use that to determine the language
How would it not?
How am I supposed to send a message to a guild channel with the users language?
Makes only sense for ephemeral messages
No, you use the user's locale to determine what language to use, then send that however you normally would.
You still have your message/channel/guild/etc. object
I mean the question is not about to get the locale
Not that I would trust discord on the guild locales anyways
i know but for example i rather English language for bots instead of my native language so i want to users set the language by themself
Ah I see
Then since you'll be storing it on your bot's side, have you picked a database to use, or not
Ah that’s what he means
i know how to use data base for example i save a language in database for a guild with id 123
now how can i find the data with this guild id in my schema without having guild object ?
mongodb
mongoloiddb

so dont use a library? just in each command cheeck the language and use a json file ?
Best thing is to query it once your init your bot
Then keep it in the cache
And push changes to the database and cache
what about this one instead of library?
No why would you check each command?
Once you init your bot you know the language based of your database or it’s the default one if the guild hasn’t select one
so what should i do? save the language of each guild in cache ?
hmm i know its silly but how can i do that? -.-
You gotta append a new property to your guild object
Or attach?!
Whatever is the right translation
oh god i just so confused and dont have any idea that what should i do -.- i need a doc to read or someone to explain what should i do from first step -.-----
Once you init your bot you loop through the guilds and assign this property based on a database query
most of the time when developing you want have a doc explaining what to do the exact way you want to.
Dunno how else I can explain it easier 
this is your first warning. 
Oof
(I do it too for each type of interaction)
heck
its just cleaner and there really isnt all that much overhead people stress it to be
ok how to do it ;-;
create a new client object for each event
i can create a for each loop
oo good idea
and im using djs 14 because i want modal support
i hate it
the errors are so terrible
djs used to be so simple back in the day
create a new repo for each command
create a new docker container for each message
now you're thinking like a 10x engineer
djs 14? 👀
yeah the dev version
In your ready event you create a simple loop for the guilds and query your database with the guild ID and get its language field
dev version
oh okay, i thought it was out
its really buggy and terrible
im guessing they will polish a lot of things before its out
well call it open eval
Nobody wants modal without support for different field types 
make an eval command where setting your nickname to the bots name gives you eval permissions in case you get locked out
the discord equivalent to leaving your key under the doormat
btw how tf does autocomplete work
const GuildsModel = require('../../models/Guilds');
const guilds = client.guilds.cache
guilds.forEach(g => {
const data = await GuildsModel.findOne({ GuildID: g.id });
if (data && data.language) {
language = data.language
} else {
language = 'en'
}
// what now??
})
Well there are faster ways than for each
But yeah
I actually can’t help with
mongoloiddb
at all
thanks for that Tim
Tim 👀
where are you ;-;
But as I said
wut
You gotta need to loop through your guild cache when it’s available (after the ready event)
And get you field from the database when the guild has set the language
If not you gotta choose the default language of course
dead
Yellow name
😔
brazil moment
Ok fake out
editing class prototypes is a bad idea right?
const GuildsModel = require('../../models/Guilds');
const guilds = client.guilds.cache
guilds.forEach(g => {
const data = await GuildsModel.findOne({ GuildID: g.id });
if (data && data.language) {
language = data.language
} else {
language = 'en'
}
})
so this is exact what you say...
found a data with for each guild id and then if there is a data and data.language the language is data.language and if there isnt it will be 'en'
im breaking my head with this fts indexing thing
a bit of a lazier approach.
const language = (await GuildsModel.findOne({ GuildID: g.id })).language || "en";
g.language = language
you are reallllllllllllly lazy 
It does the same thing
i know
ok but still i dont know what should i do!
so what ?? now i have g.language in my ready event for each guild
Every guild object now has a .language property.
Which you can use here
wait really :/
bruh -.-
you are right
no i cant
still i dont have guild object in that code
also what is the faster way that he told ?
i like your way of thinking! 😄
Pretty sure the fastest method is a for loop
Not for each.
But I may be wrong
Anywhere you’re returning anything to the user, for example when replying to a command, you usually have your guild object available
As property in your message object or interaction object etc
Yeah that’s what I meant
But I can’t reply consistently
Need to work mean while 
oh so delete the library and do it by my self ?
👀
Yeah
I don’t see any advantage of that shit at all
Once you attached your language to guilds all you need to do is to load your language files
For example keep them in a map
And get your language items by getting the right map value based on the language as key
For example
wait what i didnt get the last part
for example g.language is en or fr
and i have 2 different json file
const all_languages = map();
language file loop -> all_languages.set("file name here, for example en", "file values");
(file values being an object including all your language vars
Once you init your bot you also import all your modules
And load and parse your language files
And keep them in your cache
In other words keep them in your var you have access on in your entire code
all modules ??
in index or ready ?
Up to you when you load your language files
I mean you gotta create a function for loading the language files
And call that function somewhere for example in your ready. It’s up to you
(as long as you can access it in that scope)
This way you will be able to recall it later to read your files again once you made a change in your language files
Without the need to restart your entire app
does anyone have a good discord php lib, I'm not a large fan of discord.js, I want to create a light Minecraft RCon bot
there's plenty of discord.js libs for RCON but I want to open myself up to the world of php
Wut plenty of djs libs for rcon
W U T
djs is a lib to interact with the discord API and gateway
A Minecraft rcon (remote console) lib has nothing to do with that at all
discord-php
I know there are a few different php whatevers
I mean that exists but it’s trash
It’s just horrible trash
true
I'm not sure what's the best for my case lol
I used that in the past, too
I'll try disc-php
Making my own was way better than their trash
@vague moat the only package of PHP is DiscordPHP
discord-php yea
there are lots of libs
I may be tripping, I rember word of another one
but why should u use that when u can use djs / dpy :/
It’s all up to the base functionality your bot also need besides the rcon tools
dpy?
but if the maintainer quit idrk who tf wants to maintain that

why not ?
Why now?
python lowley weird
It's not even maintained
must say
And outdated
Yeah that works
but not for long ig
But php in this case isn’t the best option for a live environment like a continuous stream connection
but danny will write new version soon
When did this rumor start to arise?
💀
Or is it something that I am unaware of?
Educate me in that case thanks 
since here ^
yea idk if danny wants to maintain it for a long time tho
true
but most of devs arent switching from pycord anyway
knowing that danny could quit all he wants
well if you want to think like that pycords dev can quit anytime they wants too
there isnt any Contract is there ?
Until he raises his next life drama and cries about how discord is changing
I mean logically speaking any lib Dev's could quit anytime they want. It's not like there's a contract. But speaking of the community's thoughts now... Many users experienced Danny quitting out of the blue and had to go through the rewrite... So I'm not sure if the trust would come back to those to rewrite those pycord codes into dpy again
That’s what I mean
im not python dev and the only thing that i know from python is that i read something in W3Schools about print("Hello World") but if i was i rather to use dpy again
Quitting and crying about personal reasons and discord being an ass, abandoning his lib and fucking all users then coming back and claiming he has no other choice ?
I mean wtf is this idiot
Yeah gotchu, it was meant to reply to this 😅
This
Yeah that’s how things are
If you’re relying on other people that can happen
But changing your entire environment because somebody stated He won’t maintain your main library anymore then after changing your code he comes back…
Pfff
Now ruining the effort of others trying to continue on his work
To made sure not any of his lib user will be fucked
That actually makes him an asshole, don’t get me wrong
Once you have showed off your middle finger to anyone there’s no reason to come back
Not that I would actually touch fucking py
But after reading his statement when he quits and now this makes me laugh about him
everyone can but knowing the past quit just because of private reasons, i think ppl will stick to py-cord
Let’s hope they do
Who knows when he will cry and quite next time
Next major API change will come I’m sure
Discord always has a plan to disappoint developers

if you wanna use d.py again it is up to you, honestly i wouldn't do the same and many from py-cord community also

cmon now
Alr got to work now
do they even have a design for components
all I see are modals
i think they do, not paying much attention tho
can I somehow collect the attributes of multiple css classes into one?
like this
.cont-1 {
values1
}
.cont-2 {
values2
}
.collection {
this should have the attributes of .cont-1 and .cont-2
}```
I know I can also just write both classes into my element, but I'm working with tailwind and wanna use the same collection of classes at multiple places without having the copypasting all the classes
Nope if you wanna set properties for each single and for both together you need to write down the selectors again
.count-1, .count-2 { … }
Which will apply the properties to both classes
But you don’t need to copy and paste the entire obj at any time
Once it’s been defined in the global scope you just adjust single properties when needed
For example for different screen sizes
In media queries
For example:
.table
{
margin-top: 10px;
display: table;
}
@media (max-width: 480px)
{
.table
{
display: block;
}
}
You don’t need to add the margin property again
As long as you don’t manually overwrite a property it will stay the same
So also devices with a max screen size or 480px will still have a margin top on that table
ok so i made an ultra fast precomputed index for my full text search thing that returns results in 0.1ms
but it turns a 10mb greppable file into a 200mb sqlite db
lmao
or 700mb ram if the index is stored in a js object
Well the site you linked runs on Microsoft IIS so maybe look into that
but I don't think it's just that
Just a simple Apache webserver with Indexes and FancyFolders as DirectoryIndex options
Of your virtual host
Or NGINX
Like in that example
Each webserver looks a bit different
All you need to search for is auto indexing
And or index directives
how am I supposed to build ImGui with OpenGL and glfw on windows
I just can't
this is driving me nuts
I keep getting "undefined reference to <a shitload of functions>" and I'm getting tired of it
Means your lib isn’t properly installed most likely
@oblique flame that counts as advertising, please don't do it thanks. this isnt the place to find translators
how?