#development
1 messages · Page 193 of 1
@symbol.iterator
for...of basically calls the object's hidden symbol iterator function
which executes the iterator pattern
so its basically a wrapper for a bunch of functions
surprised the engine cant optimize that out if it sees you dont use any of said iterator functions in your code other than accessing the value
here's an example of a custom iterator that i made
add those to a class, and you can do for(const a of myclass)
you can also use generator functions instead, which are even slower :^)
so there’s no way i can use this with v13?
it doesnt matter what djs you use
sqlite is a universal independent database
50% slower 💀
huehuehuehue
thats interesting never knew js supported those
i made a bunch of weird shit like that in this old lib i made
basically an array-set-like class that stores data in a single delimited string
lmao
so i implemented every single array method and some more
to make it indistinguishable from arrays
so you can do for..of myclass, as well as [...myclass]
did you actually try anything with it? like did you try coding something with it?
of course you did
about strings do you know how js compares them under the hood?
like does it keep a hash of them
it has a gazilion different structures for different types of strings lmao
no i’m scared ima fuck something up 😭😭😭
funnily enough comparing strings by hashes turns strings from one of the slowest data types to being on par with comparing numbers, i hash strings in my database and compare the query string with the strings hash in the record and if it matches it will do a 1:1 compare to make sure its actually the string and not a collision
it starts off as a single string, which can be one of like 3 types depending on which chars it holds, then once you start editing it, its pretty much broken down into linked lists and what not
tf
javascript is scary
now i need to be worried that my string is a linked list
lmao
like
when you concatenate a string
it wont actually concat it under the hood
just join the pointers or something, but its kept as two separate strings
there is nothing to fuck up if you dont have anything stored yet
this is pretty much all you need
i mean like
when i install the node module
idk i’ll just need to try it
v8 source code lmao
smart
does that string ever end up becoming a whole string instead of a linked list
yes, once you read it
what if the concats are like single character length so you append many 1-2 length strings
theres even an npm package for thsat
does it follow the same process
impl Iterator for ... {} 
lmao
mans hacking the v8 engine
yup, its that dumb
btw i tested it and it doesnt really improve performance in any of my test cases
just made it worse
reminds me of lodash functions
last commit was 5 years ago
so the method prob doesnt apply anymore
actually, the delimited string storage class i showd you before, is where i tested this
at this rate it would be easier to just not use it
pretty much
if you could insert bytes in between two memory locations computers would be OP
lmao
no need for these concat algorithms
but it causes so many problems
im surprised no one figured out a solution to this
indeed
idk maybe ram that magically shifts itself in light speed
its the whole basis of the entire memory fragmentation dilema with all those memory allocators
just reminded me my kernels memory allocator is awful
basically an entire linked list
if you need a new block of memory you append to the end of the list with the beginning being some metadata
for allocs you first iterate through all blocks to see if one with a good enough size exists
would be a good idea to split the block sizes into categories for faster allocations in the future though
you can learn a lot of checking out what big name allocators are doing
like jemalloc and mimalloc
also, array.shift and array.unshift are fucking terrible for some reason
[array] unshifted 99999 strings of 10 chars in 10326.8212ms
[ftset] unshifted 99999 strings of 10 chars in 35.20800000000054ms
[array] shifted 99999 items in 17758.464099999997ms
[ftset] shifted 99999 items in 7.6833000000005995ms
arent js arrays just linked lists?
i would imagine them to be
although what about indexes
linked lists have one weakness of being awful with index lookups
lmao
pop and push are fast
oh right
so its possible they are actually stacks
forgot about those for some reason
actually
but then that wont work for everything
if you want a fifo queue
its probably a composite structure
you need unshift eventually
make a custom array in native c++ with node-gyp
lmao
although performance penalty of calling native methods will probably outweigh gains in small queues
yup
in big queues it will probably make a big difference considering 99999 strings takes 10 fucking seconds
prob a library for that though
hold on this is a gap in the js ecosystem then
i dont really see anything with simple queues on npm
there are many data structures that js doesnt have natively but thaty you can easily do with objects lol
if only voltrex was here to chime in
explain himself as to why js arrays dont make fast queues
oh interesting
this is its implementation of a queue https://github.com/datastructures-js/queue/blob/master/src/queue.js
yeah i see what its doing
i think its using offsets to dequeue elements
so if you dequeue first element it will add offset of 1 so first entry in array will be second index
if (this._offset * 2 < this._elements.length) return first;
// only remove dequeued elements when reaching half size
// to decrease latency of shifting elements.
this._elements = this._elements.slice(this._offset);
and it removes them when reaching half size
this doesnt look like a very good implementation honestly
sounds very messy
heres a challenge then
can you do a benchmark?
for the queue problem id prob make a linked list out of it
wonder how that would differ performance wise
actually i might give it a shot
doesnt even have to be in c++ can be in js
its definitely better thats for sure
although actual gains will differ given they clear the dequeues once you reach half the array
depends on use really
what is their linked list implementation
here
not bothered to look through entire code but willing to bet its just chained objects with a last and first entry that points to each other
how i wouldve done it
wonder if doing this in native would speed things up
but then doing that you limit portability of the code
and idk how bad performance penalties are with js to native translation
pretty bad, at least in sintetic benchmarks
i reckon it could be much better if the translation of native types to js types and vice versa would be more efficient
because thats realistically the only overhead here i believe
but im not a maintainer so i dont know the challenges of it
if they can find a way to eliminate a lot of the overhead from calling native libraries javascript could easily become much faster than it already is
its been a point of conflict between a few peeps
like the maintainer of uwebsocket for instance
keeps complaining about the node perf team, about how bad it is
node had a huge performance regression since node 10
which never quite recovered
Absolutely. That's what I've been saying for years. The only limit uWS.js has is node::MakeCallback and they manage to tamper with that every release, to our disadvantage.
I wrote a benchmark that just does node::MakeCallback a million times in different Node.js versions.
Node.js 8.0.0 does it in 161ms.
Node.js 10.0.0 does it in 193ms.
Node.js 13.8.0 does it in 273ms.
Node.js 13.9.0 does it in 622ms.
Node.js 14.5.0 does it in about 600ms, but sometimes 800ms (huge variations).
?
did you try anything yet?
im waiting for you to install it and try it lol
i’m scared lmao
ok i’m about to go to my pc and try
npm install better-sqlite3 right?
yes
is there a difference between npm i and npm install ?
your computer wont blow up i promise
unless someone injected malware into better-sqlite3
which i highly doubt at the moment
thats weird
what are they doing
this is all voltrex's fault
xD
ok i’m gonna do it, only because you promised
cmon lol
i've never seen anyone scared of using npm install before
people usually install too much shit instead
bro i hate html when disabling quirks mode you literally cant make a div be 100% of the pages height without a scrollbar appearing
what is this shit
i see no one complaining about this so this just must be a skill issue somehow
remove body margins
it has like 5px default margin and padding or something
its stupid
lmao
have
ive been coding my app in quirks mode the entire time bc i literally couldnt center the page without the stupid scroll bar
now im trying to move out of it so i actually comply with modern css
you can also use a css normalizer
a lot less relevant today than it used to be, but still useful with normalizing certain behaviors between firefox and chromium
looks helpful
????
i wish my only problems were a single npm install
what is said big ass function
you already narrowed it down into a function so thats a good start
i still dont know how to split it into smaller, so i'll start with a big ass one
idk why that was so stressful to me
i need to find the dates when X planets have Y event
planets being anything from the millions of things i support
and event being stuff like "planet" reaches X position, or crosses Y difference with another planet
from a list of many possible search patterns which i still didnt finish
i’m guessing i add this to my index.js?
const Database = require('better-sqlite3');
this loads the library (which is obvious)
const db = new Database('foobar.db');
this creates a new database with the file name you specify
if the file exists, the existing database is loaded, if not a new will be created
const statement = db.prepare('SELECT name, age FROM cats');
this creates a statement, which is an SQL command, written in SQL language
then you can use one of
statement.run() // run the command
statement.get() // run the command and get the result
statement.all() // run the command and get all results
all of this goes into the index.js file?
it goes wherever you want to use it
const db = new Database('foobar.db');
this is like the discord client
you probably only want one of these
(Based better-sqlite3 user)
and then access that one from other files and places
shit im lost now lol
sorry this is new to me
it's gonna take me a min to understand this
sigh..
you know the discord client right?
the one you create with client = new Discord.Client()
right
so you know that you only have 1 client
in the entire program
no matter how many files you have
yes
its pretty much the same thing
unless you actually need multiple databases, you will likely have only 1 database in the entire program
the database is this const db = new Database('foobar.db');
so you likely wanna have that in your index
then that db variable is what you use to work with the database
ie, write and read stuff
ok so
ok here are the first 54 lines of my index
const dotenv = require('dotenv');
dotenv.config();
const fs = require('node:fs');
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
// Require the necessary discord.js classes and variables
const { Client, Intents, Collection } = require('discord.js');
const token = process.env.DISCORD_TOKEN;
const config = require('./config.json');
// Create a new client instance
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_MESSAGE_REACTIONS, Intents.FLAGS.GUILD_MEMBERS] });
// Load our commands
client.commands = new Collection();
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
const commands = [];
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
client.commands.set(command.data.name, command);
commands.push(command.data)
}
// Register slash commands
const rest = new REST({ version: '9' }).setToken(token);
console.log('Started refreshing slash commands...');
rest.put(
Routes.applicationCommands(config.clientId), { body: commands },
);
console.log(`Successfully reloaded ${commands.length} slash commands!`);
// When the client is ready, run this code (only once)
client.once('ready', () => {
console.log('Ready!');
});
// Our slash command handler
client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
const command = client.commands.get(interaction.commandName);
if (!command) return;
try {
await command.execute(interaction);
} catch (error) {
console.error(error);
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
}
});```
so I can add const Database = require('better-sqlite3'); here after the new client instance?
sure
it doesnt matter where you put it
what matters is that it has to be before const db = new Database('foobar.db');
and btw you can name them whatever you want
for example you can do this if you want to
const XD = require('better-sqlite3');
const mydb = new XD('randomfile.abc');
// This is for my database
const Database = require('better-sqlite3');
const db = new Database('foobar.db');```
how do I show the colors
sure
ok so now I create the statement
with this
now you're gonna be working with the SQL language
everything inside the prepare() function is written in SQL
not in JS
ok so I need to learn the SQL language
yes
at the beginning, your database is empty
the first thing you must do, is create a table
SQL works with tables, which is like an excel file
you have rows and columns
to create a table, the SQL command is CREATE TABLE IF NOT EXISTS table name here (columns here);
now before you create a table
you NEED TO KNOW how the table looks like
which means, what columns it will have
imagine you are creating an excel file
// This is for my database
const Database = require('better-sqlite3');
const db = new Database('foobar.db');
const statement = db.prepare('SELECT name, age FROM cats');```
do I do this in a separate program? or still within visual code studio?
to work with sql you really need to think about what you're doing, so think
all SQL commands go inside the prepare() function
for example db.prepare('CREATE TABLE IF NOT EXISTS table name here (columns here)');
um
what kind of data are you saving?
so my end goal here is to have my bot be able to save data for certain games and commands that I'm going to do. for example, like people who use /birthday with my bot to input their birthday and I'll have another command like /listbirthdays that will list all of the birthdays that were input into the /birthday command
if that makes sense
very good
now
think i got a 70 yr old in my server ion wanna out her ass like that
in discord, you probably wanna use IDs instead of usernames, because usernames can be changed, IDs cant
good point
and maybe instead of age, you wanna put birth year
but anyways
so you now know how the table needs to look like
so you need to create it
like this
so that statement line shouldn't be thereyet
const statement = db.prepare('CREATE TABLE IF NOT EXISTS birthdays (id INT PRIMARY KEY, birthday TEXT, birthyear INT)');
statement.run();
prepare = columns
// This is for my database
const Database = require('better-sqlite3');
const db = new Database('foobar.db');
const statement = db.prepare('CREATE TABLE IF NOT EXISTS birthdays (id INT PRIMARY KEY, birthday TEXT, birthyear INT)');
statement.run();```
and I'd have to create a new table for every different thing I want to have data for?
yes
if those things are very different and it makes sense to have separate tables then yes
It's been a while! I've mostly been hanging around the C# discord server
otherwise you can think if it makes sense to merge some
ok i got you
for example, you dont need to have separate users and birthdays table, if you put the birthdays in the users already
ok i see what you're saying now
now, to make it easier to use, create a new file, like database.js
and put this in it:
// This is for my database
const Database = require('better-sqlite3');
const db = new Database('foobar.db');
const statement = db.prepare('CREATE TABLE IF NOT EXISTS birthdays (id INT PRIMARY KEY, birthday TEXT, birthyear INT)');
statement.run();
module.exports = db;
and you can remove it from index
this way you can easily access the same db from any file
by doing const db = require("./database.js")
hello guys how are you? I know I shouldn't ask this but how long did it take to confirm your Masomenos bot? Does your bot have premium options?
wrong discord
this is the discord for the website top.gg, not the discord for masomenos bot
for ```js
const db = new Database('foobar.db');
will I have to create a new database for each table?
is this 1 db file that will hold all of the tables that i create in it
no, one file can have multiple tables
ok i got you
just like an excel file can have multiple pages
ok I'm going to create a new file and put it in there instead of in the index
shouldn't this be database.db ?
if i decide to call the file database
its a js file that will have this code ^
ok i got you
so take it out of my index
create database.js file
and put ```js
// This is for my database
const Database = require('better-sqlite3');
const db = new Database('foobar.db');
const statement = db.prepare('CREATE TABLE IF NOT EXISTS birthdays (id INT PRIMARY KEY, birthday TEXT, birthyear INT)');
statement.run();
module.exports = db;
in it
yes
and anytime you need new tables, add a new statement to create a new table there
you can also make it a oneliner, ie db.prepare().run()
so where do i put const db = require("./database.js")
in any of your command files that needs to access the db
ok so all i did just now i create the table
it works like this, for example:
const statement = db.prepare('INSERT INTO birthdays (id, birthday, birthyear) VALUES (?, ?, ?)');
statement.run(member.id, "MM/DD", 1995);
ahhh ok
the member id, the day and the year you should get from the discord command interaction
and this goes in the database.js file?
it goes inside the command
and then reading from the db:
const statement = db.prepare('SELECT * FROM birthdays WHERE id = ?');
const result = statement.get(member.id);
thats how to get a single entry from the db, based on the user id
or if you want to get everything in the table:
const statement = db.prepare('SELECT * FROM birthdays');
const result = statement.all();
ok so
const { SlashCommandBuilder } = require('@discordjs/builders');
module.exports = {
data: new SlashCommandBuilder()
.setName('birthdayset')
.setDescription('Set your birthday')
.addStringOption(option =>
option.setName('birthday')
.setDescription('Your birthday (MM/DD)')
.setRequired(true))
.addIntegerOption(option =>
option.setName('birthyear')
.setDescription('Your birth year')
.setRequired(true)),
async execute(interaction) {
const { member, options } = interaction;
const birthday = options.getString('birthday');
const birthyear = options.getInteger('birthyear');
const statement = db.prepare('INSERT INTO birthdays (id, birthday, birthyear) VALUES (?, ?, ?)');
statement.run(member.id, birthday, birthyear);
interaction.reply("Your birthday has been set!");
}
}
and my second command "/birthdaylist" would have this in it to retrieve the data from the table
yes
edited
also
whenever you're not sure what your database actually has inside
you can use an sqlite viewer and load the file in it
for example
open your .db file with that, and it will show you the contents like this
you can use that to confirm that your commands are working
let's say i have the data in the tables
and I have to reset my bot
as long as the bot runs (because it will establish a connection to sqlite) the data will all still be there
cause it'll pull from the tables
once saved, the data is never lost, unless you specifically run a DELETE command
after your bot restarts, the existing db with all the data will be loaded again
ok i got you
i got an error
it says db is not defined
oh is it bc I didnt put it at the top
i guess it's saying I don't have a database connection established
you guess?
well stop guessing and show the error
lol tim you are the best man
ReferenceError: db is not defined
at Object.execute (C:\Users\Maurice\Desktop\Da-High-Roller-Bot-main\commands\birthdayset.js:21:27)
at Client.<anonymous> (C:\Users\Maurice\Desktop\Da-High-Roller-Bot-main\index.js:49:23)
at Client.emit (node:events:518:28)
at InteractionCreateAction.handle (C:\Users\Maurice\Desktop\Da-High-Roller-Bot-main\node_modules\discord.js\src\client\actions\InteractionCreate.js:83:12)
at module.exports [as INTERACTION_CREATE] (C:\Users\Maurice\Desktop\Da-High-Roller-Bot-main\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (C:\Users\Maurice\Desktop\Da-High-Roller-Bot-main\node_modules\discord.js\src\client\websocket\WebSocketManager.js:346:31)
at WebSocketShard.onPacket (C:\Users\Maurice\Desktop\Da-High-Roller-Bot-main\node_modules\discord.js\src\client\websocket\WebSocketShard.js:493:22)
at WebSocketShard.onMessage (C:\Users\Maurice\Desktop\Da-High-Roller-Bot-main\node_modules\discord.js\src\client\websocket\WebSocketShard.js:327:10)
at callListener (C:\Users\Maurice\Desktop\Da-High-Roller-Bot-main\node_modules\ws\lib\event-target.js:290:14)
at WebSocket.onMessage (C:\Users\Maurice\Desktop\Da-High-Roller-Bot-main\node_modules\ws\lib\event-target.js:209:9)
^ ??
i have this
i thought the ```js
module.exports = db
was supposed to make the connection
right?
no
module.exports tells you what you're gonna get when you require() the file
if you create a file abc.js and put in it module.exports = 10, then when you do require("./abc.js") you're gonna get 10
ok i gotcha
um
so
do i add ```js
const db = require('./database.js');
at the top of the /birthdayset command file?
yes assuming database.js stores your module.exports = db
then you can use the db from the birthday set command file
const { SlashCommandBuilder } = require('@discordjs/builders');
const db = require('./database.js');
// Rest of the command login below
looks good
ok i see now
assuming the file database.js is in the same folder as the command file, that is
it's not
oh no
so i'll move it there
oh good
you dont need to move it there
what if you have more than one commands folder?
are you gonna make a copy of database.js in each folder?
also if will fuck up your command loading code
it will try to load database.js as if it were a command
right i just thought about that because it's a .js file
what you need to do is make sure the path is correct
idk what i was just thinking lmao
do you know the difference between ./ and ../ and what they mean?
yes
so there you go
yes, ./ is the current folder, ../ is the previous folder
so use that accordingly to require the file in the correct location
i mean
oops sorry
i’ve only done the paths when the files are in the same folder so idk how to format relative paths lol
./file.js = same folder
../file.js = previous folder
../../file.js = 2 folders back
../../../file.js = 3 folders back
../abc/files.js = previous folder and then inside folder abc
ohhhhhhhhh ok i got you
ok birthday command worked
now i just need to make my /birthdaylist command that will list out the data that was stored on the chart
thank you so much for your help man
turns out someone pushed a backdoor to the xz linux library which is bundled with most distros for compressing/decompressing tar files
it looks like the update was caught before most major distros added it to their repo but beware if you did any updates recently
xz version 5.6.0 and 5.6.1
I don't fully understand how it works but it appears to intercept some function call in sshd for encrypted sessions and does its own thing before resuming normal code
it was only found out because sshd logins were 2x as slow from the long work the backdoor was doing
i've been reading on it all morning
dude noticed sshd was taking a lot of cpu for apparently no reason
as well as getting valgrind errors in some db he was working on
which coincided with a system update some time earlier
now a bunch of dudes are witch-hunting a group of chinese developers who have been making PRs in a lot of places in the name of loong arch
this guy Jia Tan has apparently been secretly planning this for 2+ years
hey has anyone worked with google adsense?
my account got deactivated, and im not sure what to do to activate it again

#credits
not surprised its very sophisticated
even if you saw it in the makefile youd go "i dont know what that does i probably just dont know makefile"
but he still messed up in a lot of places
doesnt work on all systems either because of the manipulation of the symbol tables or whatever its doing
ye, waiting to see what is the actual analysis veredict
its very possible that it could be the work of some spy agency
if it turns out to be that, its funny how fast it was discovered by random open source people curiosity
lmao
since 5.4.3 interesting
his commits will probably be looked over since then too
the whole projects suspended on github, not sure what thats gonna solve actually
github just wanted to do something even if its not particularly useful
ye, everyone complaining about that lul
they even disabled the original maintainer's account
even tho he has nothing to do with it
no wonder linux still uses mail lists instead of something like github
so the project doesnt get disabled for fun
tim!!!
thank you again for yesterday man!!!
i got birthday set and birthday list working with the database!
the only question i’m having is in the event list, it’s only showing the users ID and not display name
when you use mentions, its up to discord to resolve it or not, based on the cache status in each person's device
if you want to force show their usernames, you need to fetch the user data from discord, then display it
also, the IDs are incorrect
they all end in 00s
which means they are getting rounded
😳
some further thought, thats possible because why would he go out of his way to insert malicious code in a very highly used open source library after building up so much trust to become a maintainer of xz
a single incident like this gets your reputation tarnished basically forever and you will never be trusted to work in projects of this scale again unless you of course fake your identity
discord IDs have a particular interaction with javascript because they are too big to be represented by normal numbers
so you need to do it like this
instead of db.prepare(...).run(member.id) you need to do db.prepare(...).run(BigInt(member.id))
doing BigInt(member.id) will ensure the user id is correctly stored in the database by converting it to the correct big number format
OR if you prefer, you can go back to the table settings, and change the ID field from INT PRIMARY KEY to TEXT PRIMARY KEY
and there wasnt a clear objective or motive on his part to doing it either, as if he just suddenly felt like adding a backdoor
indeed, we shall see
ok i’ll try this when i get to my pc
ok so understanding how this database works now
i have something i’ve been wanting to do and i think the way i need to do it makes so much more sense now
so i went to create a /hex command that will allow the command user to put a hex code into the parameter, which will have the bot create a color role and assign it to the user.. and they’ll be able to change it which the bot will delete the previous color role, create the new one and assign it
so i’d have to create a table with columns like (user.id, current hex code, new hex code) ? and it’ll track who has what and when it’s changing ?
I don't think you even need a database to track that
you can simply look through the users roles, remove any existing color roles they have, and add the new one
stick to simpler solutions first
that way your database won't easily go out of sync with the users actual roles and it's much more reliable
ahh ok i got you
i’m thinking to deep on it 💀
as a general idea for each user's custom role I'd make them start with something like "COLOR:"
then when removing any old color roles you can go over the users roles and delete any that start with COLOR:
but id be careful creating a custom role for every user im not sure discord likes that
that’s a good idea! well it’s only for certain users.. i have server subscribers and one of their perks is being able to change their name color to whatever hex they want
that's probably fine then, discord has a total role limit of 250 total roles in each server
i was using hexamatic for that but they’ve made their bot private
so i figured i can just code my bot to do it
is there a way to have the put position the color roles higher up on the roles list so that it can show? (it has admin permissions)
nvm
i think i got it
nvm no i didn’t
your color roles should ideally be at the bottom because roles are a hierarchy
you dont want color roles being a higher position which have higher permissions
you can disable the roles above from showing their colors on the users profile so that the color shows
i think on each role above your color roles you should set the colors to this
as an example here if a user has the dyno and booster role, the booster color will show because dyno role has no color
nvm i got it
yes that’s what i ended up doing !
well
I also had it find a specific role Id on my roles list and place all color roles under that specific role ID
What usually makes my discord bot consume ram and how can I reduce the ram consumption?
Is it linked to guild count? I haven't sharded the bot yet and it's in ~1900 servers. Well ofc I'm gonna shard it regardless sooner or later but does it have anything to do with the ram issue I'm facing or is it a complete seprate problem
how much ram are you using right now?
but yes it is linked to your guild count since the more guilds, the more channels, messages and users your bot needs to have cached
depending on the library youre using they usually have lots of settings now to reduce and fine-tune caching
i imagine the cached data with 1900 servers is the biggest factor
especially big servers
5gbs
That rings a bell now
Ah yes the on_message functions and task loops might be skyrocketing it
i literally just learned about databases last night so don’t listen to me 💀
Fair enough
Speaking of databases I too am having a database crisis atp
Hi all, just had to share that I'm super chuffed about having just played with AutoMapper for the first time this week and successfully integrated it into my bot! Gotta love learning new tools and mechanisms! 
python
I checked it's not 5 but 1.3ish right now after reboot. It scales up overtime automatically
I'm unsure why was it at that earlier thought, I rebooted like 2 hours ago. Before that the reboot was 2 days ago
and yes py
lmao
anyway, most ram usage comes from channel cache, message cache, member cache, presences
check with your library if you can customize limts for those
discord.py is very customizable in that regard i think
If I might offer a suggestion, as this is something I've looked into recently as well, consider the flags in your DiscordSocketConfig. It will be different in JS, as I'm using DNET in C#, but the concept should be identical. Consider flags like AlwaysDownloadUsers which caches users, and MessageCacheSize which caches messages, and any other cache-related flags you might have.
If your bot doesn't need to cache messages, for example, set it to 0. This is what DNet has, as an example.
Hope it helps!
Awesome, I'll see how I can get it to work for me

@harsh nova think they talking about you
lmao
@quartz kindle thats another person
if it wasnt for that its very likely it wouldnt have been caught for a while
ye thats the guy i was talking about
update: i added up and it was indeed not any fun there.
ty
is it just me or is discord's slash command option autocomplete slow? it takes like a second to update the autocomplete results
how do i get the coordinates of my png?
i used canvas’ fill text to generate numbers on this photo but idk how to get the coordinates to tell it where to put the numbers
I would just do the math, since the board seems equal sized
idk how to though, wym by do the math?
(canvas height - px of border of first square - (height of square/2))
Should be center of square
idk if that makes sense, if someone else doesn't help I can give better info when I get home
webhook interaction or ws interaction?
they were pretty alright last time, its been a while since i tested them tho
not too slow not too fast
it’ll take me a min to dissect this and get it
thanks !
ws
It takes like a second or two to load the autocomplete suggestions
I mean I get that slash commands are faster because they're cached at the client level, but i kinda expected autocomplete options to load faster than they do lol
I'm not even doing a db query or anything to load them it's just an array of objects I'm filtering
90% of the waiting time is network delays between your host and the discord servers
especially because you are receiving via ws and responding via http
so every time its creating a new http request, which does cost a bit of time, plus whatever latency there is between hosts
Yeah. It's not painfully slow or anything. I guess it's just the way slash commands load so quickly because they're cached that make the autocompletes feel really slow
yeah, unfortunately there is nothing we can do about that
its pretty much the equivalent of discord itself doing a db query on every character typed lol
Yeah
it kinda sucks that we can't post the option values to the API with the command data
what if you have millions of options :^)
Free storage 
lmao
Watch me store my entire logs table
xDDD
i need to retest my autocomplete, i did a test drive like a year ago, but never implemented it
im gonna use it for stuff like geocoding and celestial object lookup, for which the backend is now working
I just built a tag command this evening which is how i ran into this
Migrating my server's mod bot over to slash commands
It's kinda nice for tags because you don't have to remember the tag. I have verbose titles now in the option field but the old slugs work too since they're the value parameters
nvm i found a program that tells me the coordinates
What did you end up using?
pixlr
i can use the marquee tool to get the h x w of the boxes and the coordinates of where the numbers should be posted
hey guys
does anyone know a site where i can find free frontend images
been trying to find an image for a rocket but it seems fucking impossible
@queen needle
Photography or icons?
Photography: https://unsplash.com/
Icons: https://thenounproject.com/
If you're looking for rocket photography SpaceX have a bunch of photos uploaded on Unsplash
Their official photography
yeah they did that poorly
for some reason typing is also sent via http not websocket
so if a user/bot wants to indicate theyre typing thats a http request
it would make better sense to send over a low latency already established ws connection
it does take a second but doesnt look that bad tbh
nvm
so what’s the difference between i.update() and await i.reply()
I want to buy nitro like you, but I don't have it credits
use g2g
or cashapp boost
I don't know how to use it
oh wait nvm
ignore this
ok
I don't know how to use it
I am new to the server
I'm new to the server and I want to show it to my friends
Hi
Autocomplete or listed options?
Is there someone who can help me please?
What’s up?
Very bad 😭
Like what do you need help with I mean
I just want nitro in my life
Can’t help you with that one. 😂
Do not join the server just to beg for nitro espeically in the #development channel 🤦♂️
😂
ok so I’m creating a bingo game (discord.js v13) and i’m having trouble getting 2 of my buttons to respond correctly
@clear plinth ^
interaction failed to the start button and the show board button, i thought it was because there was no acknowledgment of the button interactions, so i have it send a message to the channel for start and i had it set to send the players an ephemeral of the generated bingo boards when the “show board” button is tapped but no luck
Why js 13?
Why not just use v14 where buttons are a million times easier to work with
Make a separate interaction for all buttons like using a handler
Or using component interactions for djs13
I have a very similar system but it’s automated
i think v13 was the latest js at the time i started this project and idk enough about this to go through and change the language to v14
Yeah do that
can i show you a snippet of the code?
Ummm sure 
The collector is good but the way that whole command is setup is not great
I can convert it to djs14 in the morning if you want
is v14 easier to work with? i just started learning all of this coding last month
feb 20 to be exact
I mean, when I went to v14 from v13 I just re-made my bot entirely using the new stuff. Helped me learn more if I'm being honest since I got to rethink how I made certain things.
It’s better for handling purposes I’ll say
hm
yeah i'm kinda scared
is it as simple as just doing an npm install of the latest discord.js and changing the codes to v14 language? or will this require changes within like the index.js or package.json ?
I mean it will require you to change your index.js file some but I dont by much. Its still v14 code regarless
I'm not even sure if at all actually. But I know the migration wasn't hard.
In discord.js why is my embed title coming out like this? I'd like the server's name to be a hyperlink any help would be great.
Edit: Is it because I don't have "https://" ?
exactly why.
Ah ok. I didn't realize that I didn't have it until after I sent the message. 😂
Okay, I may take a look into this tomorrow. Thanks for your help!
autocomplete
if you want to add url to the title, use setURL() for the embed
Alrighty will do.
me?
I want to have an app (executable) check the status of the user's subscription and restrict access to the app based on that
I do not know how I should handle the client-side security
Preventing reverse engineering or changing a false to true in a http request with fiddler
You can have the server provide the content to display
no
Then the client can and likely will be hacked
If the content is there then there is no stopping it, only preventing it
Even if you implemented something like state tracking where you kick the user back to a screen if they access an illegal state, they can just ignore those commands
Thought a little more and perhaps you can have the content encrypted and the server can provide you with a key you can use to decrypt the content
Though this runs into the issue that once users have the key, they can distribute it and always use the key
You can change the decryption key every update unless you somehow find a way to make it time based but I have no clue how something like that would work
Yeah mine looks exactly the same in terms of latency
Glad I didn't do anything wrong 
not exactly a db query but sort of
i have many sources for geocoding, some are remote apis, others are local text files
the one i tested with autocomplete comes from local text files, queries take about 10-20ms
does anyone know how we can change this hamburger menu frok bootstrap v5.0 to open sideways?
So in row format
hwid lock
im using tauri
Understandable
discord needs to add caching to this
so you can mark certain autocompletions as global or something
Eh wouldn’t really be effective
You are better of making the autocomplete different for each interaction user with caching the guild or user id upon using the command and using a query or local file definitions to be displayed into the autocomplete function
persistent local caching would be good, but depending on how long the cache lasts, bot updates would take a while to apply
imagine you change your autocomplete stuff but users are still loading cached autocomplete results on their end
unless discord would add a mechanism to clear cache, ie an autocomplete versioning system
too much work for a meh feature i guess
it would lighten the load on their network tho
its good only thing is that navbar
the hyperlinks either need to be spaced out more to align with the logo and hamburger menu or the logo and hamburger closer together
hmm i see
yeah i can space that part a bit more to align indeed
arigatoo
needs slightly more left and right margin for the text
the spaceship should be more in the center imo
so it doesn't look so shoved-in
definitely!
Thanks!!
margin-left: 5px; margin-right: 10px;
dont listen to me im just posting random margin offsets
does anyone want to partner with me?
on a game bot?
im struggling to like balancing the game
or if somebody wants to buy it off of me, sure im all for it too
you could just give it to me for free
just seen this in scrollback.... why is the birthday field a string with two numbers seperated by /?
makes me twitch.
keep stuff simple, can always be optimized later
(altough it did make me twitch as well)
I can give it to you for like maybe 10k
Wanna help me balance a game?
I can give you some %
sure you can give it to me for free, you can do anything you put your mind to if you believe in it
what game?
balance is hard
how?
atk buffs
I never use pixels
and try it out
dont give out so many buffs then? how are they able to buff so high
It’s like a 3v3 jrpg
it’s cause people can create their own teams
But i wanted to cap it
When I do that ppl started crying and saying I nerfed it too much and they gonna quit
in my game if i find someone with massive armour/weapon buffs, i know they found an exploit
this single player or multi
No no here sadly it’s not an exploit
It’s just how the game works
but the thing is should I cap the buff
And to how much
200%?
or increase enemy def to scale with the player
That alr is there
hmm
but that isn’t like right imo cause enemy has some stats of its own with linear scaling
Players have made teams that scale their atk exponentially
Should I just remove the exponential buffs?
People will say i nerfed it too much
Idk man it’s taking a toll on me mentally
If you can help me solve the problem that’d be great
Like maybe take a look at my bot first

exponential sounds like a disaster
i would make them linear
you cant really scale things exponentially
Mmm
So like I have 50 abilities rn that players can use
And I made it exponential buff so some of them become useful
Since most of them were useless
every bot ive ever played that has exponential things breaks
Any tips on how I can buff them to make them useful?
but what if i add cap
What if I cap the buff
i was asked to beta test one once and it was just a race to get the final unlock that was exponential scaled thing, then it all broke
To like 200%
you can scale them totally
Make your own library that does math on strings. dont need to worry about 32 or 64 bit integers
a cap sound sane
128 bit needs to get on
very
Is there any other suggestion to like balance out the abilities
So they become useable
I’d appreciate it if you can like join me and help me out tbh
make them non permanent, and with a cooldown
so people dont just stack a ton of them and keep it on
So my rpg is like turn based and the skill activates every 3rd round
this is kinda why, you plan out game logic first before you write games, a lot of game designers play out their game rules as tabletop
if you can get away with it and your players wont hate or desert you, throw it all out for a version 2
and design the version 2 on paper first
make something you can test with dice and paper
and try it, over and over looking for things that dont work right
No it’s more things do work right just need some good buffs to balance them
Hmm
also I mostly also need like game mode ideas
if it depends completely on buffs to make it work it sounds like the balance is just off
how so
a good idea is to make buffs either scale multiplicatively with themselves or make them scale additively but give them dimnishing returns
it is. It’s just that people don’t use some abilities cause it deals less damage compared to atk buff abilities. Ofc they would deal less damage but they have other perks like def buff etc
It’s hard to explain id say. You should totally checkout the bot
in my game, i have some buffs i havent ported to the bot yet, they have withdrawl! so, for example you can cast a spell to get increased sneak, it works for X amount of time but afterwards your sneak is REDUCED to half... you can keep casting, but the effects are cumulitive
Yeah mine is like idle rpg tbh you just build a team and battle it out with round based system where a skill can activate every 2 rounds or 3 rounds and these skills give an atk/def buff
There’s more than just atk and def buff tho
Like hp regain
Etc
nice
can you show an example of how the damage goes to 60 million?
I need some ideas too
like how much base damage and which buffs get you there
it’s mostly because somebody has 3 cards in their team that buff atk
Base damage is pretty balanced it’s about 1-2k
so if you have 100 base atk, upon skill activation it goes to maybe 125. The skill giving 25% buff
Now you have 3 atk buffing cards in team
Some of them give 10% some 15%
So now your atk has increased from 100 to somewhere about 175
that should be ok
But ig I just have to add a cap
should have got spiffing brit to play it 
i wouldnt add a cap
Then how would you balance it
how about instead you do 100 * (1 + 0.25 + 0.25 + 0.25)
players will always complain
it’s more they say it doesn’t buff enough or something
and now they complain it buffs too much?
then if they are not complaining why not leave it lol
yeah those are there too
and ruin the lifes of mass buff builds
make more bosses do that
make all bosses do that
game balancing is a perpetual cat and mouse chase
If I do that it won’t make the game fun cause every time you only have to build atk buff teams
Fr
if something gets too powerful and overused, either nerf it or buff something else
and then people will figure out something else to abuse
then buff/nerf again
Ngl that’s why I need a game dev help
people will always find out a new way to abuse the game
It does require one to go through the game to help me balance this out tbh
if you made 40k last year, you should be able to hire some help no?
Didn’t make any this year 
lmao how come?
players left after a game mode update I made to make many of the skills useful
I nerfed “damage” in context. When the game was broken before people always did 400k damage etc that stayed normal for a long time then i modified the game damage formulae as I learnt new things to balance it out
Things finally started balancing out but damage was only like 40k which is what was expected
So people just deserted cause they can’t do 400k damage anymore lol
it happens a lot, people get used to some op strategy then quit when it gets patched because too lazy to learn a different strat
ye but sad part is I also left a lot of bugs in the game which players thought are features
Then when I fixed those they quit
So like 80% gone
rip
does it have pvp?
thats usually where people tend to invest more, because of their competitive nature
yeah
But because of all the buffs and nerfs they’ve given up on PvP
that’s where balance comes in
pvp always requires periodic rebalancing, theres no way around it
pvp can never stay the same, there always need to be fresh things
otherwise people get bored
also, people like tournaments and stuff
any ideas for PvP mode?
competitions with prizes
Yeah
They do that on their own
do you have some sort of ladder/mmr system?
You also need significant amount of players
the points you get or lose depend on the ranks of both players
Cause if there’s only 1 guy who reached x elo. How would you match him?
that cant really happen
if the elo difference is too big, the bigger elo will earn little to no additional points
like if both players have 1000 elo
the winner can get like 25
and the loser loses like 20 idk
if one player has 2000 elo and the other 1000
then the 2000 elo player would get like 1 point if they win
and the 1000 elo player would get like 100 points if they win
i think i remember you rambling about ELO a year or 2 ago
its a pretty self balancing system
But you shouldn’t really be matching 1k elo with 2k elo right
exactly
That’s broken
but if there are no players left, thats what will happen
hmm
then its up to your settings, if you prefer to let those matches happen, or if you prefer to tell the player that no matches were found
but if that’s too frequent it won’t be much fun
Like if the same players face each other
usually the match making will spend some time looking for similar elo players
And that’s what happened too
and gradually increase the range if it starts taking too long
until a certain limit
yeah but imo you still need atleast more than 1k players
otherwise it just keeps going in circles with same 2 people being matched
i dont remember what i was rambling about
exdee
also
if the game is pretty much idle/automated
the players dont necessarily need to be both online and searching for a match, for it to happen
players could "enable" their team for matches, and they would be available for matches even if the player is offline
Yeah I just matched people based on their mmr and showed them logs if someone attacked them
well sounds like you already did a lot



