#development
1 messages · Page 119 of 1
My brain is hurting
it's like the moonknight meme "random bullshit go"
Yeah, still lost.
like, you're loading the file, but are you actually updating the content?
going back to this. this can result in a ban depending on how you're trying to run it. i recommend just 1 bot
however if you're going to ignore my advice, use something different than heroku
the worst, is that they're using heroku
Here's what I was able to debug so far...
{allBlogs.length > 0 ? (<p>1</p>) : null}
{search.query.length === 0 ? (<p>2</p>) : null}
The first ternary operator returns false on next start but true on next dev.
With that, it's unable to display the content of the blog (case scenario, it's within (<p>1</p>)).
idk what to say
I'd send you the sourcebin if that's gonna be any help, really.
but apparently it's not transforming the request into html content
idk next.js
btw, there's a thing
where are u making the request to get index.json?
it could be finishing before the site is loaded properly
dev environment runs considerably slower than production env (thus giving more time for the page to load)
The issue is is that I'm not sure. (https://sourceb.in/PzSA8tTkgn)
No worries. I appreciate the help, though. Unfortunately, I'm a slow learner so I'd take time to understand what I'm doing/comprehending.
For the blog page, yes. However, in a blog post, this error occurs:
idk
that's server error
see your api console
calm down satan, people here barely managed to update to v14
2 major updates in half a year is harsh enough lmao
there won't be any breaking changes, trust me kids
djs is tbf a good example why semantic versioning can be cringe sometimes
how do i need to fix it?
wait for your bot to be approved
bot is verified and live on topgg for more then a month now
What would be the best way to show users a popup of lets say something has been added to their balance but they were away
popup where? in your site?
use the chromium notification api
yk, the one that notifies the user in the desktop
Does it work on all the browsers
No not what i meant
Like lets say
You was away but i added some money to your balance
When the user comes back i want to add some sort of modal notifying them of the credits added
just use the classic bell button
like this
the user chooses to read it whenever they like
...no, make a separate table for that
1-N relationship exists for a reason
wdym "another"? what else are u hoarding inside the table?
Looking into this rn
SELECT *
FROM users u
INNER JOIN user_notifs un ON un.user_id = u.id
Tyvm
Will get back to these messages tomorrow since i need a fresh brain to rework on this
Moght pong u tomorrow
There's a white border around an image in CSS and I don't know how to remove it.
No where in the HTML, outline/border is being set to anything
fk relationships, denormalization all the way
is that live? anyway i can access it on my browser?
electron
ah
might it be because theres no image?
can you show the html structure?
Just this
Already checked the parents
the everything border: none and outline: none rules
the background is on which element? on class or on body?
class bg div
gamers
i am going clnically insane
express.js error
unsure how to fix
issue started when i moved to a new host
Check node version?
Hmmm
You're missing a 'new ' infront of a class somewhere
tried reproducing on my browser but i dont see anything
try opening dev tools and playing with stuff
hm
but the exact same code worked on the old machine, same version of everything, and the error msg does not point to my code
same express.js ver?
quadruple sure?
triple caution! triple caution!
sammy, you have to listen to my calls sammy
You are breaking the app
f1 doesnt produce good memes
rallies are a mess
f1 is also a mess
but less scary
"is there a tree in the next turn?" "I don't know"
no image = border
for some reason
1x1 placeholder time
data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
yea ic
the default "image not found" icon
i dont think there is a way to apply css to that
h
placeholder image
ye
outdated languages fr
rahhh
horizontal line
nvm
hr
Is it possible
To have a div
Scroll under a nav?
like
This is the nav's content box per say
Now that it intersects, I want it to go under the nav
(edited)
Like this
it will go under but if there is nothing to cover it, it will still be seen
so the content box needs to have its own background
if the background is a css gradient, you can merge it seamlesly
Is it possible to make the background black whenever it detects that it intersects?
possible with js yes, not with pure css
you can use the scroll event to check for the scrollY position of both elements and see if they intersect
Possible to have the pseudo element "before"'s z index under it's parent?
cuz "before" is being "after" for me rn
nvm
//Client Side
const createCourse = async (form) => {
const data = new FormData();
for (const a of form) {
if(!a.id) continue;
if (a.type === "file") {
data.set(a.id, a.files[0]);
} else data.set(a.id, a.value ||a.placeholder);
//data[a.id] = a.value || a.placeholder;
}
const res = await axios.post("/api/courses/add", data);
if (res.statusText !== "OK") return alert("Error...");
alert("Course has been created successfully!");
window.location.replace("?page=courses");
};
// Server Side
router.post("/add", isAdmin, async (req, res) => {
const data = req.body;
console.log(data);
return
data.id = uuid();
const course = await courseModel.create(data);
res.json(course);
});
// Express
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
formData is not empty on client side i can see it on network tho but whenever i try to get it on server it just shows empty object
you need the multer middleware
bodyparser is not enough for FormData
Thank you
idk what im doin but im making a bot
hey! not really discord related, but i am tryna develop graphs for my discord bot dashboard & wanna have 2 y-axis in my chart
both y-axis are at the same side, any idea why?
thats my chart script
window.onload = function () {
const timestamps = JSON.parse('<%- JSON.stringify(stats.history.timestamps) %>');
const chartData = {
labels: timestamps,
datasets: [
{
label: 'Floorprice',
yAxisID: 'left-axis',
data: <%= JSON.stringify(stats.history.floorPrices) %>,
fill: false,
borderColor: 'rgba(255, 99, 132, 1)',
borderWidth: 3,
},
{
label: 'test',
yAxisID: 'right-axis', // assign to the right y-axis
data: [50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 100, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280],
fill: false,
borderColor: 'rgba(54, 162, 235, 1)',
borderWidth: 2,
}
],
};
const chartOptions = {
responsive: true,
maintainAspectRatio: true,
scales: {
yAxes: [
{
id: 'left-axis',
position: 'left',
},
{
id: 'right-axis',
position: 'right',
},
],
},
};
const myChart = new Chart(document.getElementById('myChart'), {
type: 'line',
data: chartData,
options: chartOptions,
});
}
</script>```
👀 are you using an older version of chartjs?
This looks like the older way of setting options
Maybe its not
I cant remember off the top of my head.
No that looks right 👀
https://www.chartjs.org/docs/latest/axes/
Is it possibly because you're not setting the id
https://www.chartjs.org/docs/latest/samples/line/multi-axis.html (look in setup)
Open source HTML5 Charts for your website
Open source HTML5 Charts for your website
i did setup the id
JavaScript
[
{
type: 2,
name: "Test"
},
{
type: 2,
name: "2Test"
},
{
type: 0,
name: "3Test"
},
]
How would I sort this alphabetically and to have the largest number in 'type' first?
[
{
type: 2,
name: "2Test"
},
{
type: 2,
name: "Test"
},
{
type: 0,
name: "3Test"
}
]
Output should be ^
Gonna try something
Hold on
Ok yeah I don't know
Type: descending
Name: Alphabetically
🐐 love you
i had 1 mistake only
nvm got it
@wintry bay no ads
Im sad
Hi sad
You women
What's wrong with women? 👀
Ör man

This is not a woman nor a man, this is a weeb ^
Some Women very beatiful
Oh boy.
Coolio but that's off-topic
This is #development
@lyric mountain how do you feel about something like this for a save data manager (I need to add appending and modifying and such but still) https://pastebin.com/Wbnkr45U
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
the data that gets serialized basically looks like this, but you can implement Serializable to define your own custom object data
Tbh I should probably use a json library or something but I want to be libless
(Unless there's a one file JSON parser I can use online with the license info on it?)
yo bro! sorry for another question, tryna search how can i merge both tooltips to show data in same pop up?
sorry, I'm not that good at chartjs 😦
I only have used it a handful of times
ah damn all good, thanks for your help though ❤️
a custom format is definitely the best option, but I'd do it on a single line
if you know the possible value ranges you can simply pad each field and use substring to get the desired value
then you can simply treat each line as a separate save state
another option is to use yaml to prevent needing to unload the entire file to read a single object
you could also use xml or properties, both have wrappers by default in java
is it neccesary to use refresh tokens?
XML sounds like a decent idea if Java supports them
Especially since it’s pretty damn good at representing objects
This tutorial will show you how to use the Java built-in DOM parser to read an XML file.
tho a "bit" verbose
Don’t worry I’m used to verbosity and I don’t mind lol
Java’s strength and weakness is that it’s verbose
So I've determined that my quadtree algorithm is absolutely AWFUL
Because and only because of my remove method
Wdym?
The issue being I want each item in the quadtree to "point" to its actual data (I use a hashmap for this, where the values of the quadtree are integers), and then I need a way for the data to somehow point back to the collection that the values are being stored in
However the way I have it implemented right now is terrible. The values pointing to the actual data is just fine, but when I want to remove something I have to do a linear search through the pointers until I find the one I want to delete, which for obvious reasons is awful
Well, that doesn't entirely solve my issue. A map would be optimal, but I'd essentially have a two way pointer which is difficult to wrap my head around
A pointer from the values to the real data, and a pointer back to the pointer itself
I can try to draw it out to help explain what I need
Hm, u could use a reference holder and disallow null references in the backing map
Then instead of deleting the entry from the map, let itself delete it whenever it encounters a null reference
var ref = new AtomicReference(obj);
tree.add(ref);
map.put(key, ref);
Then simply set ref value to null, if the map ever encounters a reference holding a null value, remove the entry and return null
U can also use other types of references, but those are trickier if you don't know how to properly use them
My current code for remove, which isn't optimal because I'm doing a linear search through every single pointer is like so: ```java
public void remove(int item) {
// TODO
List<Pair<Rectangle, Integer>> list = allItems.get(item).second;
for(int i = 0; i < list.size(); i++) {
if(list.get(i).second.equals(item)) {
list.remove(i);
break;
}
}
allItems.remove(item);
free(item);
}
(Rectangle is ignored here, no need to worry about that)
Maybe I'm not explaining very well though, I can post a pastebin if you want
Mobile atm
It's only 2 classes right now outside of basic stuff like Rectangle and Vec2f
this definitely isn't the solution tho lmfao
Wait
Why don't u make a custom pair class?
With a custom hashcode impl
That way you could simply remove the entry directly, no loop involved
U can even extend pair and simply override equals and hashcode
Ik, it's that ur looping over the collection
But remove works without needing to loop
The issue is that this is fundamentally how values in a node are stored
Ideally it would be a map so that I could have O(1) access to any element
But I don't know how I could do that with keys
That might actually work I didn't think of that since I forgot all of my values are unique
Hashsets are still O(1) as they're backed by a map
Is there any way to get that set to just be Set<T> instead of Set<Pair<Rectangle, T>>
Since I need to remove based on T and nothing else
I could override the hashcode method but that is kind of suboptimal and feels wrong
specifically in this method I'd prefer to change the signature to Set<T>
<T extends Pair<Rectangle, T>
Well, not quite what I was looking for
I need to be able to call <Set>.remove(T) and not <Set>.remove(Pair<Rectangle, T>)
Uhhh
U can use as many generics u want
Need to what?
Hm, that'll be trickier as the hashcodes will differ
Even if they're the same, hashset won't like two different types
I could do something like class CustomPair<T, R> extends Pair<T, R> and just hash based on 2nd value only
kinda scuffed but might work
U can try making your hashcode impl return a hash based on the second value
Thus making both types have the same hash
But as I said, it might not work if set checks for data type
I'll try it, no harm in that I suppose
wdym
I'll try that
Gtg now, cya tomorrow
Lot of nerd speakage here
Hello
I have this really weird bug affecting only one user (who's reported it). I have a command that adds the user to a stringified array in a postgres database row when they click an interaction button. My code sends the database update query and then waits for the response rowCount to be >0 before confirming they were successfully added to the database. If rowCount is 0 it'll throw an error and tell them it failed. However, sometimes they get the confirmation message without actually being added to the database. Any ideas why this might be?
My code is basically
await query(sql, [array])
.then(res => {
rowCount > 0 ? confirm : throw new Error("Failed");
})
.catch(e => {
// reply to interaction with error
})
Why would my query return rowCount > 0 but not add him to the row?
Adding a new row or to a stringified array now?
Adding to a stringified array
Well, it may silently fail and considering the row is not 0 as it exists already, it will return it not being 0
The thing is, sometimes he gets the error message but most of the time he doesn't. And why this one specific user and not everyone else?
And most of the time it actually works for him afaik
Not sure what rowCount is in the first place as it's not defined anywhere in the given code - I assume similar to res.row.length - other than that, unsure as well why it sometimes works and sometimes not. Could log the errors returned by the DB itself
I do log the db errors but I haven't seen any about this. And rowCount is 1 on an update query in the pg npm package. It doesn't return res.rows on update.
Yeah, hence I said similar
I think it can return res.rows if you add a specific clause to your query though
Might be worth getting the query results and checking the array contents it returns to triple check it's actually there?
The thing is I suspect there wouldn't even be an error anyway if rowCount > 0 because that means the row was updated afaik
Well the weird part is that the DB returns the affected rows being >0
Could be an issue with the DB itself, have you eventually found someone with similar issues where affected row >0 but nothing got edited?
I haven't done much digging online yet. I got this error reported to me yesterday and I just updated my code to only send the confirmation if rowCount > 0 and added extra logging.
You may have some sort of race condition though, not sure how you handle the commands w/ their queries - same for the config of the database
But my db has been very performant and works for everyone else afaik. I even upgraded my VPS a couple of weeks ago. Only this user is reporting the issue.
The race condition situation is also something I thought about but I'd suspect it would affect more than one user. I'll probably try and solve for that first and see how that works out.
Yeah that's also a weird thing, that it affects one user from time to time
It is a button that gets a lot of concurrent clicks so it would make sense.
But yes, I also don't understand 
He's on an updated version of the app on a Google Pixel
Not that that really matters
But I really couldn't figure it out
The new UI might be scuffed 
I don't know
I doubt it's Discord's fault. If the member object is making it this far in the code then it's definitely there in the interaction payload and working as expected.
Yeah most likely isn't, my best guess is a race condition
I reckon it's a race condition but it is weird it's only affecting one user. It might be affecting more than one user but only this user is noticing it.
rule out if its a problem with the database or your app first
might also be some weird cache issue? don't know how you render your pages though
and rule out shit like you know maybe because they have a weird username or something
try doing the query manually
Doesn't make any sense and will probably just return the array as it is
You wanna use sort() instead
Then compare the arrays (if needed)
Also keep in mind 2 parameters require parentheses
do you happen to use transactions?
might be a commit error (succeeds at adding the row but fails at committing the transaction)
I changed it to use transactions today as a way to fix the possible race condition issue.
Ok I just got another report of it so that didn't fix it. I changed my code to this:
await interaction.client.db.query('BEGIN');
await interaction.client.db.query('SELECT * FROM table WHERE gameid = $1 FOR UPDATE', [gameId]);
await interaction.client.db.query('UPDATE table SET array = $1 WHERE gameid = $2', [array, gameId]);
await interaction.client.db.query('COMMIT');
But that's still got the same issue as a basic UPDATE query. Any ideas?
well, transactions definitelly wont fix race conditions, they're just a safe environment to ensure operations are atomic
for preventing race conditions you'd need to either
A - use database-level locking (pessimistic or optimistic)
B - make all of your database accesses synchronized (with a mutex) to prevent it from being accessed by two concurrent tasks at once
that said, UPDATE rarely does incur race condition with other rows, the only possible scenario would be if you're updating the same row at once
a thing you could do is refactor your structure to use a 1-N table instead of an array
Since it's a button users can click to be added to the row a lot of users usually click as soon as it appears
try using another table, in-column collections don't fare well with concurrent edits
can we fetch topgg total reviews count?
nope, only votes
i want to display counts on my website
👀 oh sad
this is probably to prevent review-rewarding (bribing your users to leave a good review)
it is
i want to show gg ratings and review
but there no way to need to do manually
then you don't do it because you can't 
Hey there - according to our Review Guidelines found here: https://support.top.gg/support/solutions/articles/73000502504-review-guidelines we do not allow incentivizing users to leave reviews (whether negative or positive). So this is unlikely to be added to our current API unless our stance on this changes, which is also unlikely.
what things topgg provide in api?
votes
Looks like you're providing an integer for the guild id, you need to give it a string
"1071065000350847037"
not
1071065000350847037
So I m trying to make a userinfo command
But it shows error at
MentionedUser.joinedAt.toString()
And I defined MentionedUser As - message.mentions.users.first()
what is the error?
users don't have the joinedAt field
I do it with members then it says
that should work then, did you do message.mentions.members.first()?
Well, you can also use joinedTimestamp and see if it works
we love javascript being loosely typed!
Them: 1071065000350847037
JS: Best I can do is 1071065000350847000
btw @wheat mesa, gg for managing it
80% to 2% is a huge improvement
Thank you for the help last night
Super super helpful, was going insane trying to implement this myself lol
The performance increase has been absolutely massive so far, before my beefy pc was dropping to 30 fps on 500 entities, and I haven’t tested it past this, but now my shitty laptop can handle more than 3000
You can also just use .has(a.ID) since you're just checking if it exists
That already checks the cache, but instead of retrieving a massive object it just returns a boolean
Hi
I keep having error with the embed and sending:
const fs = require('fs');
const { MessageEmbed } = require('discord.js');
const Discord = require('discord.js');
module.exports = {
name: 'help',
description: 'Displays all available commands and their descriptions.',
emoji:"📙",
run: async(message, rootPath) => {
const commandFiles = fs.readdirSync(`./Src/MessageCommands/`).filter(file => file.endsWith('.js'));
const embed = new MessageEmbed()
.setColor('#0099ff')
.setTitle('Available Commands')
.setDescription('Here is a list of all available commands and their descriptions.')
for (const file of commandFiles) {
const command = require(`../MessageCommands/${file}`)
embed.addFields({ name:`${command.name} ${command.emoji}`, value: command.description });
}
message.channel.send({ embeds: [embed] });
},
};
What's the error
Also it's a bad idea to be reading from your filesystem on each command
TypeError: Discord.MessageEmbed is not a constructor
at Object.run (/home/container/Src/MessageCommands/help.js:10:19)
at /home/container/Src/Events/MessageCreate.js:21:68
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
I would prefer doing something like for(const command : client.commands.values())
ok
new MessageEmbed() isn't a thing, it should be new Embed()
oh ok thanks for the help
oh actually
it's new EmbedBuilder() now
djs keeps changing things around
i tried that
it gave me a error
one min
TypeError: Cannot read properties of undefined (reading 'send')
at Object.run (/home/container/Src/MessageCommands/help.js:18:21)
at /home/container/Src/Events/MessageCreate.js:21:68
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
like this right:
const fs = require('fs');
const { MessageEmbed } = require('discord.js');
const Discord = require('discord.js');
module.exports = {
name: 'help',
description: 'Displays all available commands and their descriptions.',
emoji:"📙",
run: async(message, rootPath, client) => {
const commandFiles = fs.readdirSync(`./Src/MessageCommands/`).filter(file => file.endsWith('.js'));
const embed = new MessageEmbed()
.setColor('#0099ff')
.setTitle('Available Commands')
.setDescription('Here is a list of all available commands and their descriptions.');
for (const command of client.commands.values()) {
embed.addFields({ name:`${command.name} ${command.emoji}`, value: command.description });
}
message.channel.send({ embeds: [embed] });
},
};
Can you show your command handler?
yeah one min
More specifically where you call command.run()
const { statSync } = require("node:fs");
const directorySearch = require("node-recursive-directory");
module.exports = async(client, rootPath) => {
const messageCommandsFiles = await directorySearch(`${rootPath}/Src/MessageCommands`);
messageCommandsFiles.forEach(messageCommandFile => {
if (statSync(messageCommandFile).isDirectory()) return;
const messageCommand = require(messageCommandFile);
if (messageCommand.ignore || !messageCommand.name || !messageCommand.run) return;
client.messageCommands.set(messageCommand.name, messageCommand);
if (messageCommand.aliases && Array.isArray(messageCommand.aliases)) messageCommand.aliases.forEach(messageCommandAlias => {
client.messageCommandsAliases.set(messageCommandAlias, messageCommand.name);
});
});
};
discord js version?
14v
I don't see any .run() here
EmbesBuilder
Embed
That's not related to their error right now
Their error is something regarding the type of message, which is why I'm looking for where they call command.run()
where is the error?
I have that in the file
^
@wooden ocean can you show where your commands are actually run at?
yesh here:
const { prefix } = require("../Credentials/Config");
const commandOptionsProcessor = require("../Structures/CommandOptions/Processor");
module.exports = {
name: "messageCreate",
run: async(message, client) => {
if (!Array.isArray(prefix)) return;
prefix.forEach(async botPrefix => {
if (!message.content.startsWith(botPrefix)) return;
const commandName = message.content.toLowerCase().slice(botPrefix.length).trim().split(" ")[0];
const command = client.messageCommands.get(commandName) ?? client.messageCommands.get(client.messageCommandsAliases.get(commandName));
if (!command) return;
const args = message.content.slice(botPrefix.length).trim().slice(commandName.length).trim().split(" ");
const authenticatedCMDOptions = await commandOptionsProcessor(client, message, command, false, "MessageCommand");
if (command.allowInDms) {
if (authenticatedCMDOptions) return await command.run(client, message, args);
} else if (!message.guild) return;
else if (command.allowBots) {
if (authenticatedCMDOptions) return await command.run(client, message, args);
} else if (message.author.bot) return;
else if (authenticatedCMDOptions) return await command.run(client, message, args);
});
}
};
So parameters in javascript are ordered, which means they need to be passed in the same order you expect to receive them in
So in your command you have run: (message, rootPath, client) => but in your command handler you're using command.run(client, message, args)
So you have the order of your parameters switched up
oh
You're looking for run: (client, message, args) =>
oh ok thanks so much
Come back whenever you need 
ok 😄
It force casts the value to be the type of whatever it is expected to be
So for example, it solves something like this: ```ts
const token = process.env.TOKEN; // Normally, anything taken from env is of type string | undefined
login(token); // Uh oh! login expects string, but it received string | undefined
// To solve this when we KNOW it exists, you can do this:
login(token!); // Now typescript is happy
function login(token: string) {
bot.login(token);
}
my friend said
Note that this code uses MessageEmbed instead of EmbedBuilder which was used in Discord.js v12, as EmbedBuilder has been deprecated in v13 and removed in v14.
is this right?
EmbedBuilder is what's used in discord.js v14, and MessageEmbed was used in discord.js v12
Discord.js is a powerful node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.
This is the documentation for said class in v14
oh ok thanks
I made this is this a good idea:
const { Client } = require('discord.js');
const client = new Client();
const MAX_MEMORY_USAGE = 1500; // Maximum memory usage in MB
let lastMemoryUsage = process.memoryUsage().heapUsed;
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}`);
setInterval(() => {
const memoryUsage = process.memoryUsage().heapUsed;
if (memoryUsage > MAX_MEMORY_USAGE && memoryUsage > lastMemoryUsage) {
console.log(`Memory usage exceeded ${MAX_MEMORY_USAGE} MB, restarting...`);
process.exit(1);
}
lastMemoryUsage = memoryUsage;
}, 30000); // Check memory usage every 30 seconds
});
compare with rss instead
also, do you really need to set the last memory usage? can't you just call process.memoryUsage() again directly?
i could but I want to log it\
also keep in mind that headUsed returns the heap usage in bytes
which, with your current code will always restart because the heap will always have more than 1500 bytes of usage
and yeah rss is the most accurate measurement of actual RAM usage
to be fair you probably have big problems on your hands if you need to use swap space lol
well, the OS decides when to swap and if at all
I made this code and I want to know this would be ok to add to it?
const Discord = require('discord.js');
const client = new Discord.Client();
const config = {
prefix: '!',
defaultRaidersRoleID: 'INSERT_DEFAULT_RAIDERS_ROLE_ID_HERE',
defaultRaidLogChannelID: 'INSERT_DEFAULT_RAID_LOG_CHANNEL_ID_HERE'
};
let raidersRoleID = config.defaultRaidersRoleID;
let raidLogChannelID = config.defaultRaidLogChannelID;
let antiRaidSystemActive = false;
client.on('ready', () => console.log('Anti-raid system is online!'));
client.on('guildMemberAdd', async (member) => {
if (!antiRaidSystemActive) return;
const guild = member.guild;
const raidersRole = guild.roles.cache.get(raidersRoleID);
const raidLogChannel = guild.channels.cache.get(raidLogChannelID);
if (!raidersRole || !raidLogChannel) return;
const joiningMembers = await guild.fetchAuditLogs({ type: 'BOT_ADD', limit: 1 }).then(audit => audit.entries.first());
if (!joiningMembers) return;
const { executor, target } = joiningMembers;
if (target.id === member.id && executor.bot) {
await member.roles.add(raidersRole);
await member.kick('Anti-raid system: Detected bot joining the server.');
raidLogChannel.send(`${member.user.tag} has been kicked from ${guild.name} because they were a bot added by another bot.`);
}
});
client.on('message', async (message) => {
if (!message.content.startsWith(config.prefix) || message.author.bot || !message.guild) return;
const args = message.content.slice(config.prefix.length).trim().split(/ +/);
const command = args.shift().toLowerCase();
if (command === 'antiraid') {
if (!message.member.hasPermission('ADMINISTRATOR')) return message.channel.send('You do not have permission to use this command.');
if (args.length === 0) return message.channel.send(`Anti-raid system is currently ${antiRaidSystemActive ? 'active' : 'inactive'}.`);
const subCommand = args.shift().toLowerCase();
if (subCommand === 'on') {
antiRaidSystemActive = true;
raidersRoleID = args[0] || config.defaultRaidersRoleID;
raidLogChannelID = args[1] || config.defaultRaidLogChannelID;
message.channel.send(`Anti-raid system has been activated. Raiders role ID: ${raidersRoleID}, Raid log channel ID: ${raidLogChannelID}`);
} else if (subCommand === 'off') {
antiRaidSystemActive = false;
raidersRoleID = config.defaultRaidersRoleID;
raidLogChannelID = config.defaultRaidLogChannelID;
message.channel.send('Anti-raid system has been deactivated.');
} else if (subCommand === 'raidersrole') {
raidersRoleID = args[0] || config.defaultRaidersRoleID;
message.channel.send(`Raiders role ID has been set to ${raidersRoleID}.`);
} else if (subCommand === 'logchannel') {
raidLogChannelID = args[0] || config.defaultRaidLogChannelID;
message.channel.send(`Raid log channel ID has been set to ${raidLogChannelID}.`);
}
}
});
sorry but, that's horrible
the names are needlessly long and...if-else chains
what would you recommend?
sanest oracle commit message
a proper command handler
alr i will do that
ever seen discord-api-types lib?
I still think that this is the ultimate name because it's from the source code of the JVM itself
I'm having this error when trying to use asyncpg on python
No module named 'asyncpg.protocol.protocol'
I think I already installed asyncpg properly
Don't think u installed it properly
I'm getting this error intermittently. i think i'm responding to the Discord webhook too quickly sometimes and Discord isn't ready. Does that sound right? It works 99% of the time. Would it be a good idea to check for the code: 10015 error and retry the call once if it fails?
{ message: 'Unknown Webhook', code: 10015 }
👀 that doesn't sound right to me.
responding too fast to an interaction should never do that right?
how do I install it properly?
Idk, see their docs
And that explicitly means I didn't install it correctly?
Very likely
Does it really help you to argue about it instead of trying it
try what?
Takes 2 seconds to reinstall it considering python package managers are super easy to use
Perhaps even a unstable release
i have a tricky setup. i am using 2 aws lambdas. So i have an initial lambda that Discord invokes that calls another lambda in an async way that does the actual command logic, and then the initial lambda returns a response to Discord. I'm thinking that the lambda that's invoked in an async way might call the webhook before my initial lambda has responded to Discord. would i get that error if i tried to use the webhook endpoint with the token before ACKing the request from Discord?
I'm looking at their docs, I don't see anything about a module called asyncpg.protocol.protocol
All I see them using is import asyncpg
What is your pip version?
how do I check pip version lol
Ok I just did pip install --upgrade pip
And reinstalled asyncpg
but it's still showing
h ok foubd the fprovlem
fixing now thx
sure! 😊
@hasty narwhal Please no ads or self promo
https://top.gg/bot/1064145673513087018 can anyone give me an opinion about the description of my bot? I've used HTML before but it was like 3-4 years ago and I'm rusty as heck.
Should I use markdown or HTML for my description? I use both but I think HTML gives you more control over the looks of each element?
Does it have something to do with programming?
Just ask
more with the site and the voting roles
iirc those are buggy atm and there's no ETA for a fix
Roles should be assigned normally
Just take a look into #support and scroll up a bit, that has been discussed and explained a lot the last days
If it doesn't match your case you need to provide a few more details
We fixed it
:\
Queue is empty.
@earnest phoenix which linux OS would you suggest as a daily
aka working on projects
since you bullied me for using kali
(i am starting to see its issues)
no
i am tryna get rid of the pain
i have used Mint before, it seemed okay
there's always ubuntu
Isn't mint a sub of ubuntu?
maybe, I mean, it's one of the most popular distros, so the chances of not finding the answer for something is minimal
also off-topic how much are you paying for .site
plus most software that happen to support linux will almost always base their "support" on ubuntu
true
20 per year*
year, not month
oh ok lmao
automatically typed month lmao
with 20 per month you can get, hear me out, 5 days of heroku 
lmao
heroku is supposed to be used exclusively for on-demand services, like apis or whatever
use it for 24/7 and your wallet will be set on fire
they didn't see a bunch of discord devs rushing towards them when they launched it
i bet
on-demand api's are slow af tho
put a free plan on your hosting service and discord devs are like:
why starboard no worki man
so I have to make an object with alot of functions & data on every request. would a class be more efficient that creating the whole object on every request?
hello @clear plinth, i request a forced starboard
nice @eternal portal bot btw
watching the stars and on the moon
the sun is blocking its view
or perhaps it's placed in the moon
(you can't see stars when on moon)
funfact ^
wdym?
I mean, a class will be much better if it's a fixed object structure, as you can use intellisense + have class methods
but if it's a dynamic structure it wont matter much
like the general structure is always the same, the data it uses just changes and I heard generating functions every time something runs is bad practice
I mean, you can choose to either go oop or fp
I prefer oop as functions are constrained to a specific domain
@river flicker
is it necessary to insert the entire user data in the jwt
in js it doesnt really matter since classes and objects are the same thing under the hood
but if you have functions/methods attached to said object, then a class will implement the prototype for you, so all instances of the class share the same functions and not copies of them
you can do the same thing with objects, but it doesnt do it for you by default
hi i have a codding help i had changed my bot to v12 to v14 but some eror
if u know to fix pls help me
#development message @warm vine
bro i cannot do anything
because iam in a trip
and i need to edite next video for my youtube
Okay but I just gave you a link to a message that will help you move your bot from v12 to v13 and then to v14
clicked on the links NyNu mentioned
literally first thing on that page
where is it
It’s on that link
then do it when you get home
i cannot if i get home i have to go to school
that why i need a helper if u can just for a sec
No, nobody will do it for you
no
I hate quadtrees in Java without pointers
just help me
So difficult to debug
poor man still dealing with java
We helped you, you have a solution to your problem
so what i need to do
so shold i need to rewrite the command code or anyouter
Yes, most likely you will have to rewrite a lot
Of course it depends on how much code you have
use Reference subclasses
told ya that day
it's the closest you'll get to pointers
It doesn’t matter, it’s a fundamentally unsolvable issue in Java since I don’t have direct memory access
No, like, you'd use direct memory access to update a value across the whole program, right?
boldly asked question
is there no timeout_duration property somewhere?
doesnt matter what library, but does it even exist?
communication_disabled_until
nevermind, discord moment
yes, you'll need the priv intent
you'll also get a fuckton of data influx from that
no ablo ingles ¯_(ツ)_/¯
does anyone here work with pylast? (last.fm library for python)
working on something that might be useful for creating/working with session and session keys, but i need some feedback/help on what would be actually needed and be most useful
currently its a TON easier than just doing all the session work yourself
^ all the code needed to get pylast working with key based sessions, alot better than just doing it all yourself imo
vs pylast example
Hey could anyone give me some advice. I am trying to create an algorithm that takes a large batch of data to conclude what the next data point would be (basically a prediction model). Could we use any Ai or any algorithm using Java? Please let me know if anyone knows any good packages that could predict accurately and is easy to use?
Java 
First choose a machine learning library for Java and then look up how to make a prediction model
https://onix-systems.com/blog/top-10-java-machine-learning-tools-and-libraries
There aren't much AI models for Java because most people don't do AI/ML with Java
You can always write a "specific bot" yourself. That's what this channel is for
I don't know how to😭
I don't know how to make bots
I am only 13 years old too
But the bot i need is probobly already made
I am just trying to find out if anyboy know a bot
ok ty
Didn't even notice it was a link to a message. He immediately went to that channel to write the exact same message to get the same reply to which I had already sent him the link
I wanted to use weka but not sure whether it would be a good pick.
Whoever maybe h20 is actually a better pick
Because it supports large data predictions
why is cpp to fucking stupid
literally requires huge brain to set a static instance of anything
solution: dont use cpp

What? How's it confusing?
javascript fan vs typescript enjoyer
im the average typescript enjoyer
only thing I hate about typescript is the picky ass compiler settings
like just let me run my code
intervals and timeouts are based on timings
not on ticking/counting down
every event loop it checks if the current time is bigger or smaller than the expected time
You should read through https://nodejs.org/en/docs/guides/timers-in-node (@earnest phoenix)
@earnest phoenix whats the best way to make a static instance of a object in c++
I give up
the best and most understandable way
wrong
wdym by static here, a static member of a class or a global..?
bro, what are u as a lone person going to do something useful with c++
let the big corps use c++
I quite enjoy C++
no you dont
It's definitely refreshing after working with Java for so long
a class/object instance that can only exist once
context being: I am flashing code onto an esp32, that class in question is responsible for setting pin states, providing the associated pins in the constructor and it then initializing something that can only be initialized once
If you want it to be globally available you can do something like extern TypeName variableName
and instantiate it there
question being, where do I define that? in the headers file or the cpp file
header file nvm
so having defined that in the headers file, do I need to reinitialize that variable on other classes/files?
Nope, you just do extern TypeName variableName everywhere u want to use it iirc
All you need to do is declare the value as external in a header file (extern Type Identifier), and instantiate it in a source file (Type Identifier), and finally include the header anywhere you want to use the instantiated value
that being the same on classes?
Or if you don't want to do that you can use a singleton like so:
class Foo {
public:
static Foo &get_instance() {
static Foo foo;
return foo;
}
private:
// Private constructor, only the static `get_instance()` method will be able to access this, and once `get_instance()` is executed, it'll be initialized once and never again as the `foo` is marked as `static`
Foo() { ... }
};
Yes
cpp linter on vscode do be funny
You should use Clang-Tidy as the linter (totally not an ad)
man I miss C++
I've been confined to java for so long now
can't wait to be done with this project 😭
it apparently did not like it
Can you show what MotorController is?
header file and class file
yes
every 10 seconds, a timeout for 20 seconds will be created
yes
timers only "start" the timer
there is nothing about waiting anywhere
they do not interfere with each other in any way
what exactly to you want to do?
Try putting it beneath your class declaration? I remember some C++ versions/compilers don't like it when you reference something before it's defined
You're using a type before it's declaration/definition (like Waffle said, didn't see their response)
it's been too long since I've used C++
I'm going to build a proper physics engine over the summer
I'm sure you could but this is kind of the point of setInterval
oh shit yeah
it does occasionally cry on functions too
Yeah I'm not sure if that's a version thing or if that's just how it is
I seem to not have too many issues with it but I'm usually not using extern too often
this is kind of the only project I've used it in: https://github.com/Jwaffled/PhysicsSim/blob/master/Systems/PhysicsSystem.cpp
That's just how C/C++ works, it has been since the day they were made
Maybe I'm thinking of something else then
I pretty much haven't touched C++ since this physics simulation project
makes me sad but I haven't had the time
you basically want to keep multiple different intervals running with different times?
Is this Windows-only? Considering the hardcoded paths used in the CMake lists
like one every 5 seconds, another every 15 seconds, etc?
this is making my brain hurt
or am I the one having brain damage rn
its the pointers
The code itself isn’t, you could change the CMake config to work on Linux if you have SDL2
This was a while back when I was still figuring out CMake and other configuration managers
(I have a DLL path in there for SDL2_image and it’s not even used in the project)
The motor_controller_instance variable has a type of MotorController but you're assigning it to a type of MicroController *, basically to a pointer to that type which the compiler doesn't know how to handle by default
You can basically just use find_library() in CMake to make it cross-platform
Also are you constructing this object at runtime? If not, you don’t need a pointer to it
Sick, I’ll remember this when I get back on the C++ train
And the hellscape begins 😈
not even the linter is crying again
You’re defining methods more than once
It's literally showing you
MotorController::drive()
an interval cannot be waited, its not meant for that, its literally made to do something every X time no matter what
And MotorController::stop
if you want to do some repeated task while waiting a certain amount of time in between each loop, you can use an async while true
while(true) {
// do something
await something();
}
or as you did, a recursive function
both are only defined once though, MotorController for example
#include "MotorController.h"
#include <Arduino.h>
extern MotorController *motor_controller_instance;
MotorController::MotorController(int motor_pin1, int motor_pin2)
{
this->motor_pin1 = motor_pin1;
this->motor_pin2 = motor_pin2;
// set the instance to the static variable
*motor_controller_instance = *this;
}
void MotorController::setup()
{
pinMode(motor_pin1, OUTPUT);
pinMode(motor_pin2, OUTPUT);
}
void MotorController::stop()
{
digitalWrite(motor_pin1, LOW);
digitalWrite(motor_pin2, LOW);
}
void MotorController::drive(int direction)
{
switch (direction)
{
case 1:
digitalWrite(motor_pin1, HIGH);
digitalWrite(motor_pin2, LOW);
break;
case 2:
digitalWrite(motor_pin1, LOW);
digitalWrite(motor_pin2, HIGH);
break;
}
}
or are the header files considered its own definition too?
Header files should be declaration only
correct, done that
Perhaps Arduino.h has something similar?
is what I'm thinking yeah
(Unless you’re doing templates or you’re optimizing)
Header files can be included multiple times
Use header guards
Pragmas work on every major C/C++ compiler, though note that pragmas aren't standard directives, they're implementation-defined, so using header guards is better to be safer
If not, ```cpp
#IFNDEF HeaderGuardName
#DEFINE HeaderGuardName
// header code
#ENDIF
Is that right?
Been a while
I usually have my IDE do it for me
Ah damn it’s that but all lowercase
Close enough
Knew something looked off
.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\esp32dev\src\controllers\driving\MotorController.cpp.o: in function `MotorController::motor_controller_drive(int)':
src/controllers/driving/MotorController.cpp:27: multiple definition of `MotorController::motor_controller_drive(int)'; .pio\build\esp32dev\src\controllers\connection\RemoteCommunicator.cpp.o:src/controllers/driving/MotorController.cpp:27: first defined here
nah still goes for it
What's in your RemoteCommunicator.cpp file?
Oh wait that's from a library isn't it?
a fuck ton of Bluetooth Serial related parsing
void handle_serial_input(String input)
{
String CONTROLLER_LOG_PREFIX = "[CONTROLLER] ";
// create a switch case for each command
if (input == "CONTROL_LED_ON")
{
Serial.println(CONTROLLER_LOG_PREFIX + "Turning LED on");
return;
}
if (input == "CONTROL_LED_OFF")
{
Serial.println(CONTROLLER_LOG_PREFIX + "Turning LED off");
return;
}
if (input == "MOTOR1_FORWARD")
{
// get the instance from the motor controller
motor_controller_instance->motor_controller_drive(2);
Serial.println(CONTROLLER_LOG_PREFIX + "Driving forward");
return;
}
...
would be where it originates from
RemoteCommunicator *remote_communicator_instance;
being defined ontop
which should use the extern one
I think between the library and your code you both have a class called MotorController where both of them are being included and conflicting
fuck that other library
This is why you should use namespaces :^)
Show code?
.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\esp32dev\src\controllers\driving\T1MotorController.cpp.o: /src/controllers/driving/T1MotorController.cpp:4: multiple definition of `motor_controller_instance'; .pio\build\esp32dev\src\controllers\connection\T1RemoteCommunicator.cpp.o: /src/controllers/driving/T1MotorController.cpp:4: first defined here
.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\esp32dev\src\controllers\driving\T1MotorController.cpp.o: in function `T1MotorController::T1MotorController(int, int)':
/src/controllers/driving/T1MotorController.cpp:6: multiple definition of `T1MotorController::T1MotorController(int, int)'; .pio\build\esp32dev\src\controllers\connection\T1RemoteCommunicator.cpp.o: /src/controllers/driving/T1MotorController.cpp:6: first defined here
.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\esp32dev\src\controllers\driving\T1MotorController.cpp.o: in function `T1MotorController::T1MotorController(int, int)':
/src/controllers/driving/T1MotorController.cpp:6: multiple definition of `T1MotorController::T1MotorController(int, int)'; .pio\build\esp32dev\src\controllers\connection\T1RemoteCommunicator.cpp.o: /src/controllers/driving/T1MotorController.cpp:6: first defined here
.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\esp32dev\src\controllers\driving\T1MotorController.cpp.o: in function `T1MotorController::motor_controller_setup()':
/src/controllers/driving/T1MotorController.cpp:15: multiple definition of `T1MotorController::motor_controller_setup()';
.pio\build\esp32dev\src\controllers\connection\T1RemoteCommunicator.cpp.o: /src/controllers/driving/T1MotorController.cpp:15: first defined here
.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\esp32dev\src\controllers\driving\T1MotorController.cpp.o: in function `T1MotorController::motor_controller_stop()':
/src/controllers/driving/T1MotorController.cpp:21: multiple definition of `T1MotorController::motor_controller_stop()'; .pio\build\esp32dev\src\controllers\connection\T1RemoteCommunicator.cpp.o: /src/controllers/driving/T1MotorController.cpp:21: first defined here
.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\esp32dev\src\controllers\driving\T1MotorController.cpp.o: in function `T1MotorController::motor_controller_drive(int)':
/src/controllers/driving/T1MotorController.cpp:27: multiple definition of `T1MotorController::motor_controller_drive(int)'; .pio\build\esp32dev\src\controllers\connection\T1RemoteCommunicator.cpp.o: /src/controllers/driving/T1MotorController.cpp:27: first defined here
per error, relevant to:
T1MotorController
#include "T1MotorController.h"
#include <Arduino.h>
T1MotorController *motor_controller_instance;
T1MotorController::T1MotorController(int motor_pin1, int motor_pin2)
{
this->motor_pin1 = motor_pin1;
this->motor_pin2 = motor_pin2;
// set the instance to the static variable
*motor_controller_instance = *this;
}
void T1MotorController::motor_controller_setup()
{
pinMode(motor_pin1, OUTPUT);
pinMode(motor_pin2, OUTPUT);
}
void T1MotorController::motor_controller_stop()
{
digitalWrite(motor_pin1, LOW);
digitalWrite(motor_pin2, LOW);
}
void T1MotorController::motor_controller_drive(int direction)
{
switch (direction)
{
case 1:
digitalWrite(motor_pin1, HIGH);
digitalWrite(motor_pin2, LOW);
break;
case 2:
digitalWrite(motor_pin1, LOW);
digitalWrite(motor_pin2, HIGH);
break;
}
}
and the text is too large for the RemoteCommunicator
so enjoy this hastebin https://hastebin.com/share/vepigibeqa.cpp
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
And what's in your header file?
The T1MotorController
class T1MotorController
{
public:
T1MotorController(int motor_pin1, int motor_pin2);
void motor_controller_setup();
int motor_pin1;
int motor_pin2;
void motor_controller_drive(int direction);
void motor_controller_stop();
};
extern T1MotorController *motor_controller_instance;
just this
is there some way to do a follow up message to a different channel than the command was input to?
not really, except just sending a normal message into that channel
thanks
If you look at line 19, it's redefining the things you defined, I'm not sure what's going on here, this is definitely a doing of either that library or Arduino
Try using namespaces to see if it changes anything
Also you don't seem to have header guards in this header file
Unless you're intentionally not showing them
Never used header guards
Tried after literally looking up how namespaces work, everything broke, gave up for now
#ifndef SOME_UNIQUE_NAME
#define SOME_UNIQUE_NAME
// Your header code goes here
#endif
even with all the crap that cpp has, it still manages to be less confusing than java
for some reason
No
Java is more understandable for me than whatever cpp is
Could be missing experience though sk
so
i said that while having next to zero experience in both
xD
well, i have a little cpp experience, but zero java experience
so im also biased
Just wait until you see my engine
The code isn’t even complex it’s just straight up bad
I suppose it could be worse though so
||k||
add header guards if you're planning to include the same header multiple times @rustic nova
#include only pastes the contents of the header file into your source code, without consideration of it being already included in your source
That's not how Discord's gateway works, not even how JSON works either. Consider reading more about it before.
https://discord.com/developers/docs/topics/gateway#identifying-example-identify-payload

How to make vote logger bot in server discord?
Why does it write squares
font doesnt support characters you're using
Unknown character
i agree
its 2 letters
-_-
How to patch that so
(vps ubuntu)
by using a font in your browser that supports these characters
Are u writing it correctly? 2 letters becoming a single char usually means you're adding them together, instead of concatting
That is, you're summing their ascii values
Is it against tos for when a staff member of a bot joins the server to create a role called Bot name Staff but it will have no permissions
staff member of a bot joins the server
that part is, if not informed about it
create a role called Bot name Staff but it will have no permissions
might be too
Do you know what section it would be under
are you referring to our guidelines or wdym
Discord tos
that one is something for our guidelines, but should be considered a privacy breach
Do not use API Data in any way that goes against Discord users’ expectations. This includes frequently sending unsolicited direct messages, sending direct messages not directly related to maintaining or improving an Application's core functionality, or making unsolicited changes to user data or to a user’s access to Discord services.
Under discord yeah its that part.
You can, tho, make the bot say something or whatever when you join, nothing more than that
thanks
Any type of alteration on the server would be a violation
building still fucking dies with header guards
about to just rm rf this shit project ngl
it finally fucking built
jesus
Hello
yeahh just getting this now
Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x400d50d7 PS : 0x00060a30 A0 : 0x800d5130 A1 : 0x3ffc9780
A2 : 0x00000000 A3 : 0x00000011 A4 : 0x00000012 A5 : 0x3ffc3f90
A6 : 0x00000000 A7 : 0x3ffbb1e0 A8 : 0x3ffbb249 A9 : 0x3ffbb249
A10 : 0x00000000 A11 : 0x2c700c8d A12 : 0x2c700c8d A13 : 0x3ffc3f90
A14 : 0x00000000 A15 : 0x3ffbb238 SAR : 0x00000019 EXCCAUSE: 0x0000001c
EXCVADDR: 0x0000000f LBEG : 0x40090264 LEND : 0x4009026f LCOUNT : 0x00000000
Backtrace: 0x400d50d4:0x3ffc9780 0x400d512d:0x3ffc97a0 0x400d5197:0x3ffc97c0 0x400d21aa:0x3ffc97e0 0x400d294e:0x3ffc9800 0x400d60ea:0x3ffc9850
guru
This is kind of just the pipeline for embedded dev though, you should get used to obscure low level errors that have to be dug through
i can tell
taking a fair guess that approaching embedded dev stuff without a full understanding knowledge of cpp wont bring me far eh
solved it
not the best solution ngl
Btw, auto& is useful
What's auto for?
Type interpolation
Sounds like var to me
Fair enough
As long as the right side of your assignment is a known type to the compiler then you can use it pretty much anywhere in place of a normal type name
As long as it’s not in a function signature or something, it only interpolates, it won’t be a “dynamic” type

Still need to figure out how to implement that singleton-solution above to allow providing constructor arguments
Builder pattern
Since i decided to just have setters instead for now
Yeah the builder pattern is more difficult to do when the singleton of the class is that
Actually
Nvm

Make a friend builder class that has access to the private members of the thing you’re building
Then just have a .build() function
Is it worth it to do that on a class that is mainly using a singleton?
It’s just one of many options
I’m a fan of the builder pattern because it produces nice-looking code
Case and point, my engine
This just reminds me of java
I like to reduce the amount of arguments needed for my constructor, though if you require a lot of arguments that don’t have default values, you could use something like a factory pattern
Because it is Java
Lmao
The same thing applies in C++ though
Yeah i generally work with builders too when i work with multiple instances of a class
Easy usability too
You can also look at App.cpp to see the basic concept for the C++ version of a builder pattern
a major advantage of builders are that you don't necessarily need to set all params
I recently added builders to my library, it largely reduced the amount of functions signatures
Agreed
You just provide a private constructor with the appropriate parameters, and also declare the parameters you want to pass on the static method
For example:
class Foo {
public:
static Foo &get_instance(const std::string_view baz, const int qux) {
static Foo foo(baz, qux);
return foo;
}
private:
Foo(const std::string_view baz, const int qux) {
// Constructor code
}
};
const Foo &foo = Foo::get_instance(std::string_view{"quux"}, 5);
Though this has the disadvantage of having to provide those arguments every time you want to get the instance
Exactly, this
How about just another getter that returns the static object?
Or is the foo variable scoped into that one function?
A static initialized value is locked into the scope it was initialized in, nothing else can access it
How about initializing that static variable a scope up from the get_instance?
So being within the public definition
Though tbf would be better to have it on the private one
That would tell the compiler to initialize the value as soon as it encounters that class, because it's a static value
So you wouldn't get to initialize it yourself
Wdym?
like define the variable as NULL, then having the Constructor define said variable
and then have a get_instance
or nah
It doesn't work like that
Pointers c:
I'm trying to do Main to Renderer communication with Electron
And I am so stuck, ChatGPT (ik so dumb of me, lel) aint helping neither is Google
I want to send a message but no reply
preload.js
renderer.js
index.js
A
B
anyone here a pro with Google Analytics v4 event tracking? I can see the EVENT PARAMETERS in the realtime data, but when i go to the Events report i can't find the event parameter data stored anywhere. does google not save event parameter data?
builder pattern ❤️
I got it to work I’ll look for the tutorial I followed hang on. it might be out dated tho cuz t was a long time ago xD
Maybe this stackoverflow can help you https://stackoverflow.com/questions/62433323/using-the-electron-ipcrenderer-from-a-front-end-javascript-file
If I remember correctly this https://www.tutorialspoint.com/electron/electron_inter_process_communication.htm# was the tutorial I followed it might me able to help you. Best of luck!
so I have a class that takes in a generic argument of objects, it extends another class that takes in that object generic and serves it to the user at a ton of places, the problem is the type is not actually literally the objects anymore after being passed to the second class, why is that? (ts)
can you show an example?
so I have this class (https://pastes.dev/llmF37WNFj) that has a generic argument and when I pass some data and add a property with the type of the generic it works perfectly, but as you can see im passing into a class im extending (https://pastes.dev/ASPK1WAOAG) but when I add a property there with the type its just the general type, it doesnt include actual dynamic types
like its quite heard to accurately show what I have but generally I want the middlewares available throughout the code
tested it in the typescript playground and it works?
sort of
what do you mean sort of?
yeah, that will work but add multiple middlewares all containing different properties
what does your middlewareInitted type look like?
Mmm yes very informative comment :^)
/** The Middlewares */ middlewares: Middlewares = [] as any
image + https://pastes.dev/Q9lMby0lZN
:^)
sounds like typescript ovecomplication
when you overcomplicate stuff, it becomes hell to deal with
do you get an actual error?
or the type just becomes any?
nope, it is the middleware but no dynamic properties are shown
if I have a public middlewares key on the webServer it works fine
can you explain a little better what you mean with when I add a property there with the type its just the general type, it doesnt include actual dynamic types
sure, hold on
ok this is weird, it seems to be working as intended now, webServer is attached to the main class & ok to the Router. Im not quite sure if I changed something
now if I pass that through other types / classes again will it stay intact or is there like a limit?
I mean, it seems to work as intended in vscode rn after passing it like 4 times so I think it should be fine
what do you mean with that?
I'm trying to do Main to Renderer not vise versa




