#development

1 messages · Page 119 of 1

lyric mountain
#

the other 2 are for beta and alpha testing

grim aspen
#

My brain is hurting

lyric mountain
#

it's like the moonknight meme "random bullshit go"

grim aspen
rustic nova
#

imagine super reacting with an invisible emoji

#

brain4

feral aspen
#

Yeah, still lost.

lyric mountain
#

like, you're loading the file, but are you actually updating the content?

grim aspen
#

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

lyric mountain
#

the worst, is that they're using heroku

feral aspen
lyric mountain
#

it's no longer free

#

so they're paying to have an underperformant bot host

feral aspen
lyric mountain
#

but apparently it's not transforming the request into html content

lyric mountain
#

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)

feral aspen
lyric mountain
#

yep, I have no idea how next.js works

#

you'll need someone else for that

feral aspen
#

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:

grim aspen
#

idk

lyric mountain
#

see your api console

lyric mountain
#

calm down satan, people here barely managed to update to v14

#

2 major updates in half a year is harsh enough lmao

boreal iron
#

there won't be any breaking changes, trust me kids

rustic nova
#

djs is tbf a good example why semantic versioning can be cringe sometimes

formal jacinth
#

how do i need to fix it?

lyric mountain
formal jacinth
#

bot is verified and live on topgg for more then a month now

lyric mountain
#

api is probably broken then

slender wagon
#

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

lyric mountain
#

popup where? in your site?

slender wagon
#

Yes

#

Like a notification sort of...

lyric mountain
#

use the chromium notification api

#

yk, the one that notifies the user in the desktop

slender wagon
#

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

lyric mountain
#

just use the classic bell button

#

like this

#

the user chooses to read it whenever they like

slender wagon
#

Hm

#

So that requires another object in the user table

lyric mountain
#

...no, make a separate table for that

#

1-N relationship exists for a reason

#

wdym "another"? what else are u hoarding inside the table?

slender wagon
#

Nothing much just normal info

#

My way of connecting words is bad

slender wagon
lyric mountain
#
SELECT *
FROM users u
INNER JOIN user_notifs un ON un.user_id = u.id
slender wagon
#

Tyvm

#

Will get back to these messages tomorrow since i need a fresh brain to rework on this

#

Moght pong u tomorrow

lyric mountain
#

sure

#

just remember, sql loves relationships, use it where it's due

slender wagon
#

Mhm

#

I am also using prisma

#

Figured out its not a bad thing

surreal sage
#

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

quartz kindle
quartz kindle
surreal sage
#

electron

quartz kindle
#

ah

surreal sage
#

might it be because theres no image?

quartz kindle
#

can you show the html structure?

surreal sage
#

Just this

#

Already checked the parents

#

the everything border: none and outline: none rules

quartz kindle
#

the background is on which element? on class or on body?

surreal sage
#

class bg div

quartz kindle
#

hmm

#

any element has box-shadow?

surreal sage
#

na

#

lovely messy css

#

as usual

#

finna be something stupid too

spark flint
#

gamers

#

i am going clnically insane

#

express.js error

#

unsure how to fix

#

issue started when i moved to a new host

slender wagon
#

Check node version?

spark flint
#

node v16.18.0

#

which is same as the other one

#

and same ubuntu version

slender wagon
#

Hmmm

surreal sage
#

You're missing a 'new ' infront of a class somewhere

quartz kindle
#

try opening dev tools and playing with stuff

surreal sage
#

hm

spark flint
surreal sage
#

same express.js ver?

spark flint
#

yeah

#

same everything

surreal sage
#

ya sure?

#

triple sure?

spark flint
#

yes

#

very

surreal sage
#

quadruple sure?

quartz kindle
#

triple caution! triple caution!

surreal sage
#

DONT CUT

#

DONT CUT

#

I SAID DONT CUT

quartz kindle
#

sammy, you have to listen to my calls sammy

slender wagon
#

You are breaking the app

surreal sage
#

love how drift rally 2 is bigger than f1 22

#

my 1tb nvme is nearly full already

quartz kindle
#

f1 doesnt produce good memes

surreal sage
#

rallies are a mess

#

f1 is also a mess

#

but less scary

#

"is there a tree in the next turn?" "I don't know"

surreal sage
#

for some reason

#

1x1 placeholder time

#

data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==

spark flint
#

ok fixed issue

#

it was a module issue, even if the error did not tell me that joeverymad

surreal sage
#

What do you call a line that seperates one 'section' from another in HTML?

quartz kindle
surreal sage
#

yea ic

quartz kindle
#

the default "image not found" icon

surreal sage
#

didnt have that

#

just the border

#

might be an electron thing

quartz kindle
#

i dont think there is a way to apply css to that

quartz kindle
#

ye

surreal sage
#

outdated languages fr

surreal sage
#

horizontal line

#

nvm

#

hr

surreal sage
#

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

quartz kindle
#

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

surreal sage
#

I could duplicate the background onto there

#

but kinda tricky

quartz kindle
#

if the background is a css gradient, you can merge it seamlesly

surreal sage
#

Is it possible to make the background black whenever it detects that it intersects?

quartz kindle
#

possible with js yes, not with pure css

surreal sage
#

course

#

can you possibly link me something for that?

quartz kindle
#

you can use the scroll event to check for the scrollY position of both elements and see if they intersect

surreal sage
#

Possible to have the pseudo element "before"'s z index under it's parent?

#

cuz "before" is being "after" for me rn

#

nvm

molten halo
#
//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

quartz kindle
#

bodyparser is not enough for FormData

molten halo
lofty cave
#

idk what im doin but im making a bot

winged linden
#

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>```
solemn latch
#

Maybe its not

#

I cant remember off the top of my head.

winged linden
#

i did setup the id

surreal sage
#

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

winged linden
#

i had 1 mistake only

surreal sage
rose warren
#

@wintry bay no ads

wintry bay
#

Why

#

Please

#

Im sad

rose warren
wintry bay
#

Im sad

earnest phoenix
#

Hi sad

wintry bay
#

You women

rose warren
#

What's wrong with women? 👀

wintry bay
#

Ör man

rustic nova
earnest phoenix
#

This is not a woman nor a man, this is a weeb ^

wintry bay
#

Some Women very beatiful

rose warren
#

Oh boy.

earnest phoenix
#

Coolio but that's off-topic

rose warren
wheat mesa
#

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?)

winged linden
solemn latch
#

sorry, I'm not that good at chartjs 😦
I only have used it a handful of times

winged linden
lyric mountain
#

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

slender wagon
#

is it neccesary to use refresh tokens?

wheat mesa
#

Especially since it’s pretty damn good at representing objects

lyric mountain
#

tho a "bit" verbose

wheat mesa
#

Don’t worry I’m used to verbosity and I don’t mind lol

#

Java’s strength and weakness is that it’s verbose

wheat mesa
#

So I've determined that my quadtree algorithm is absolutely AWFUL

#

Because and only because of my remove method

lyric mountain
#

Wdym?

wheat mesa
#

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

lyric mountain
#

U could use a tree

#

Worst case it's logn

wheat mesa
#

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

lyric mountain
#

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

wheat mesa
#

Each pointer value is a unique integer ID, that’s worth mentioning

lyric mountain
#

U can also use other types of references, but those are trickier if you don't know how to properly use them

wheat mesa
#

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

lyric mountain
#

Mobile atm

wheat mesa
#

It's only 2 classes right now outside of basic stuff like Rectangle and Vec2f

#

this definitely isn't the solution tho lmfao

lyric mountain
#

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

wheat mesa
#

I did make a custom pair class

#

The issue isn't the pair

lyric mountain
#

Ik, it's that ur looping over the collection

#

But remove works without needing to loop

wheat mesa
#

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

lyric mountain
#

Use a set instead

#

If i don't need order

wheat mesa
#

That might actually work I didn't think of that since I forgot all of my values are unique

lyric mountain
#

Hashsets are still O(1) as they're backed by a map

wheat mesa
#

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>

lyric mountain
wheat mesa
#

Well, not quite what I was looking for

lyric mountain
#

I mean, that's to declare what T is

#

Not inside set<t>

wheat mesa
#

I need to be able to call <Set>.remove(T) and not <Set>.remove(Pair<Rectangle, T>)

lyric mountain
#

Then use another letter

#

<T, R extends Pair<Rectangle, T>>

wheat mesa
#

Uhhh

lyric mountain
#

U can use as many generics u want

wheat mesa
lyric mountain
#

Need to what?

wheat mesa
#

I need to remove from the set with just an int

#

Not Pair<Rectangle, Integer>

lyric mountain
#

Hm, that'll be trickier as the hashcodes will differ

#

Even if they're the same, hashset won't like two different types

wheat mesa
#

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

lyric mountain
#

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

wheat mesa
#

I'll try it, no harm in that I suppose

lyric mountain
#

Sure

#

Btw, cant u use a map with int as the key?

#

And Rectangle as the value

wheat mesa
#

wdym

lyric mountain
#

Map<Integer, Rectangle>

#

Then just map.remove(int)

#

If it's always unique values

wheat mesa
#

I'll try that

lyric mountain
#

Gtg now, cya tomorrow

wheat mesa
#

gn, thank you for the help!

#

Holy shit, remove is now down to 2%!!!!!

#

(From 80%!)

sharp geyser
faint marlin
#

Hello

rose warren
#

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?

earnest phoenix
#

Adding a new row or to a stringified array now?

rose warren
#

Adding to a stringified array

earnest phoenix
#

Well, it may silently fail and considering the row is not 0 as it exists already, it will return it not being 0

rose warren
#

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

earnest phoenix
#

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

rose warren
#

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.

earnest phoenix
#

Yeah, hence I said similar

rose warren
#

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?

rose warren
earnest phoenix
#

Well the weird part is that the DB returns the affected rows being >0

rose warren
#

Yeah

#

That's what I can't figure out

earnest phoenix
#

Could be an issue with the DB itself, have you eventually found someone with similar issues where affected row >0 but nothing got edited?

rose warren
#

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.

earnest phoenix
#

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

rose warren
#

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.

earnest phoenix
#

Yeah that's also a weird thing, that it affects one user from time to time

rose warren
#

It is a button that gets a lot of concurrent clicks so it would make sense.

#

But yes, I also don't understand mayaLaugh

#

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

earnest phoenix
#

The new UI might be scuffed kek

rose warren
#

I don't know mayaLaugh 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.

earnest phoenix
#

Yeah most likely isn't, my best guess is a race condition

rose warren
#

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.

frosty gale
#

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

boreal iron
#

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

lyric mountain
#

might be a commit error (succeeds at adding the row but fails at committing the transaction)

rose warren
rose warren
# lyric mountain might be a commit error (succeeds at adding the row but fails at committing the ...

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?

lyric mountain
#

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

rose warren
#

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

lyric mountain
#

try using another table, in-column collections don't fare well with concurrent edits

austere mica
#

can we fetch topgg total reviews count?

lyric mountain
#

nope, only votes

austere mica
#

i want to display counts on my website

austere mica
lyric mountain
#

this is probably to prevent review-rewarding (bribing your users to leave a good review)

earnest phoenix
#

it is

austere mica
#

but there no way to need to do manually

earnest phoenix
#

then you don't do it because you can't smart

austere mica
#

what things topgg provide in api?

lyric mountain
#

votes

earnest phoenix
#

Everything listed there

solemn latch
#

Looks like you're providing an integer for the guild id, you need to give it a string

#

"1071065000350847037"
not
1071065000350847037

north cairn
#

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()

grim aspen
#

what is the error?

north cairn
#

It shows undefined

#

Or says cannot read properties of undefined toString

pale vessel
#

users don't have the joinedAt field

north cairn
pale vessel
#

that should work then, did you do message.mentions.members.first()?

north cairn
#

Ya

#

I'll look again into the matter tomorrow
Gotta sleep now

deft wolf
#

Well, you can also use joinedTimestamp and see if it works

wheat mesa
#

we love javascript being loosely typed!

lyric mountain
#

Them: 1071065000350847037
JS: Best I can do is 1071065000350847000

#

btw @wheat mesa, gg for managing it

#

80% to 2% is a huge improvement

wheat mesa
#

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

lyric mountain
#

is it cuz u used ID instead of id?

#

ah

earnest phoenix
#

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

limpid rain
#

Hi

wooden ocean
#

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] });
  },
};
wheat mesa
#

What's the error

#

Also it's a bad idea to be reading from your filesystem on each command

wooden ocean
#

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)

wheat mesa
#

I would prefer doing something like for(const command : client.commands.values())

wooden ocean
#

ok

wheat mesa
wooden ocean
#

oh ok thanks for the help

wheat mesa
#

oh actually

#

it's new EmbedBuilder() now

#

djs keeps changing things around

wooden ocean
#

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] });
  },
};
wheat mesa
#

Can you show your command handler?

wooden ocean
#

yeah one min

wheat mesa
#

More specifically where you call command.run()

wooden ocean
#
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);
        });
    });
};
wooden ocean
#

14v

deft wolf
#

I don't see any .run() here

wheat mesa
#

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()

hasty perch
#

where is the error?

wooden ocean
wheat mesa
#

@wooden ocean can you show where your commands are actually run at?

wooden ocean
#

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);
        });
    }
};
wheat mesa
#

The handler that is

#

Ah okay

deft wolf
#

Ah, yes

#

client, message

wheat mesa
#

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

wooden ocean
#

oh

wheat mesa
#

You're looking for run: (client, message, args) =>

wooden ocean
#

oh ok thanks so much

wheat mesa
#

Come back whenever you need poggythumbsup

wooden ocean
#

ok 😄

sharp saddle
#

I'm confused how value! works in Typescript

#

like

#

console.log(message.guild!)

wheat mesa
#

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);
}

sharp saddle
#

oh

#

ty

wooden ocean
#

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?

wheat mesa
#

EmbedBuilder is what's used in discord.js v14, and MessageEmbed was used in discord.js v12

#

This is the documentation for said class in v14

boreal iron
#

Soon to be changed in v15

wooden ocean
#

oh ok thanks

wooden ocean
#

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
});

pale vessel
#

compare with rss instead

#

also, do you really need to set the last memory usage? can't you just call process.memoryUsage() again directly?

wooden ocean
#

i could but I want to log it\

wheat mesa
#

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

quartz kindle
#

depends on the OS tho

#

in windows, rss will not include swapped/paged memory

wheat mesa
#

to be fair you probably have big problems on your hands if you need to use swap space lol

quartz kindle
#

well, the OS decides when to swap and if at all

boreal iron
#

cough

#

For your own sanity just ignore what Voltrex aka nerd said freerealestate

wooden ocean
#

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}.`);
        }
    }
});
lyric mountain
#

the names are needlessly long and...if-else chains

wooden ocean
#

what would you recommend?

lyric mountain
wooden ocean
#

alr i will do that

quartz kindle
boreal iron
#

Good we don't have that issue

wheat mesa
#

I still think that this is the ultimate name because it's from the source code of the JVM itself

fluid agate
#

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

lyric mountain
#

Don't think u installed it properly

proven lantern
#

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 }

solemn latch
#

👀 that doesn't sound right to me.
responding too fast to an interaction should never do that right?

fluid agate
lyric mountain
#

Idk, see their docs

fluid agate
#

then

#

how do u know I didn't install it properly

lyric mountain
#

Because it errored

#

Things installed correctly usually don't error

fluid agate
#

And that explicitly means I didn't install it correctly?

lyric mountain
#

Very likely

wheat mesa
#

Does it really help you to argue about it instead of trying it

lyric mountain
#

Maybe a missing dependency por smth

#

Or mismatching version

wheat mesa
#

Takes 2 seconds to reinstall it considering python package managers are super easy to use

lyric mountain
#

Perhaps even a unstable release

fluid agate
#

I pip install asyncpg

#

thats it

proven lantern
# solemn latch 👀 that doesn't sound right to me. responding too fast to an interaction should ...

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?

wheat mesa
#

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

lyric mountain
#

What is your pip version?

lyric mountain
fluid agate
#

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

pale vessel
#

sure! 😊

earnest phoenix
#

ah yes all permissions possible

#

cc @clear plinth

clear plinth
#

@hasty narwhal Please no ads or self promo

latent rapids
#

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?

chrome trellis
#

can I ask support question for the top.gg bot here?

deft wolf
#

Does it have something to do with programming?

boreal iron
#

Just ask

chrome trellis
boreal iron
#

iirc those are buggy atm and there's no ETA for a fix

deft wolf
#

Roles should be assigned normally

boreal iron
#

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

deft wolf
#

It's best to report such general top.gg issues on #support . I thought maybe you wanted to write a system that would assign a role after vote

#

Because that's what this channel is for

clear plinth
earnest phoenix
#

:\

pale vessel
#

error Queue is empty.

slender wagon
#

@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

lyric mountain
#

there's always ubuntu

slender wagon
#

Isn't mint a sub of ubuntu?

lyric mountain
#

yes and no

#

it has a version based on ubuntu and another based on debian

slender wagon
#

i think i used the one based on ubuntu

#

ubuntu makes life easier right?

lyric mountain
#

maybe, I mean, it's one of the most popular distros, so the chances of not finding the answer for something is minimal

slender wagon
#

also off-topic how much are you paying for .site

lyric mountain
#

plus most software that happen to support linux will almost always base their "support" on ubuntu

lyric mountain
slender wagon
#

whattt

#

per year umean

lyric mountain
#

year, not month

slender wagon
#

oh ok lmao

lyric mountain
#

automatically typed month lmao

slender wagon
#

smh

#

you could buy a nice server

lyric mountain
#

with 20 per month you can get, hear me out, 5 days of heroku KEKW

slender wagon
#

i don't get how heroku was so expensive yet so free

lyric mountain
#

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

slender wagon
#

they didn't see a bunch of discord devs rushing towards them when they launched it

#

i bet

quartz kindle
#

on-demand api's are slow af tho

lyric mountain
#

put a free plan on your hosting service and discord devs are like:

slender wagon
#

why starboard no worki man

neon leaf
#

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?

earnest phoenix
#

nice @eternal portal bot btw

#

watching the stars and on the moon

slender wagon
#

the sun is blocking its view

#

or perhaps it's placed in the moon

#

(you can't see stars when on moon)

#

funfact ^

lyric mountain
#

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

neon leaf
#

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

lyric mountain
#

I mean, you can choose to either go oop or fp

#

I prefer oop as functions are constrained to a specific domain

wind sundial
#

@river flicker

slender wagon
#

is it necessary to insert the entire user data in the jwt

quartz kindle
#

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

warm vine
#

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

deft wolf
warm vine
#

bro i cannot do anything

#

because iam in a trip

#

and i need to edite next video for my youtube

deft wolf
#

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

quartz kindle
#

literally first thing on that page

warm vine
#

where is it

grim aspen
#

It’s on that link

warm vine
#

i cannot do it

#

because iam in bus

quartz kindle
#

then do it when you get home

warm vine
#

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

deft wolf
#

No, nobody will do it for you

warm vine
#

no

wheat mesa
#

I hate quadtrees in Java without pointers

warm vine
#

just help me

wheat mesa
#

So difficult to debug

boreal iron
#

poor man still dealing with java

deft wolf
warm vine
#

so what i need to do

deft wolf
#

Edit your code

#

So that it matches with the changes made to the discord api

warm vine
#

so shold i need to rewrite the command code or anyouter

deft wolf
#

Yes, most likely you will have to rewrite a lot

#

Of course it depends on how much code you have

wintry bay
lyric mountain
#

told ya that day

#

it's the closest you'll get to pointers

rustic nova
#

@wintry bay keep it sfw please

#

thanks

wheat mesa
lyric mountain
rustic nova
#

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

lyric mountain
#

yes, you'll need the priv intent

#

you'll also get a fuckton of data influx from that

grim aspen
#

Yeah it’s a backslash then emoji

#

Oops

hazy raptor
#

Hi all

#

hello everyone

pale vessel
#

hello 107

#

that's a nice number for a username

hazy raptor
#

no ablo ingles ¯_(ツ)_/¯

cloud agate
#

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

eternal osprey
#

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?

earnest phoenix
#

Java bravemmlol

earnest phoenix
#

There aren't much AI models for Java because most people don't do AI/ML with Java

weary kettle
#

helloooo

#

can somebody pls help me find a specific bot?

deft wolf
#

You can always write a "specific bot" yourself. That's what this channel is for

weary kettle
#

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

weary kettle
deft wolf
deft wolf
#

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

eternal osprey
#

Whoever maybe h20 is actually a better pick

#

Because it supports large data predictions

rustic nova
#

why is cpp to fucking stupid

#

literally requires huge brain to set a static instance of anything

spark flint
#

solution: dont use cpp

rustic nova
#

yeah thanks for that info

#

issue being

#

esp32 is built on cpp

#

fucking shit

spark flint
rustic nova
#

i would even prefer java to run that shit

#

so stupid

#

even haskell or brainfuck

earnest phoenix
rustic nova
#

nah gave up already

#

fuck that

wheat mesa
#

javascript fan vs typescript enjoyer

onyx urchin
#

im the average typescript enjoyer

#

only thing I hate about typescript is the picky ass compiler settings

#

like just let me run my code

wheat mesa
#

Me too

#

That’s the point of typescript

quartz kindle
#

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

earnest phoenix
rustic nova
#

@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

strange mirage
#

c++ is a useless language

#

give up

rustic nova
#

thanks for agreeing

wheat mesa
#

wrong

wheat mesa
strange mirage
wheat mesa
#

Have you ever written C++?

#

There's a reason it's used everywhere 🙂

strange mirage
wheat mesa
#

I quite enjoy C++

strange mirage
#

no you dont

wheat mesa
#

It's definitely refreshing after working with Java for so long

rustic nova
wheat mesa
#

If you want it to be globally available you can do something like extern TypeName variableName

#

and instantiate it there

rustic nova
#

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?

wheat mesa
#

Nope, you just do extern TypeName variableName everywhere u want to use it iirc

rustic nova
#

coolio giving it a try

#

also pointers confuse me too tbf

earnest phoenix
#

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

rustic nova
#

that being the same on classes?

earnest phoenix
#

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() { ... }
};
earnest phoenix
rustic nova
#

cpp linter on vscode do be funny

earnest phoenix
#

You should use Clang-Tidy as the linter (totally not an ad)

wheat mesa
#

man I miss C++

#

I've been confined to java for so long now

#

can't wait to be done with this project 😭

rustic nova
#

it apparently did not like it

quartz kindle
#

wdym?

#

timers are set when the function is called

earnest phoenix
rustic nova
#

header file and class file

quartz kindle
#

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?

wheat mesa
earnest phoenix
wheat mesa
#

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

rustic nova
#

it does occasionally cry on functions too

wheat mesa
#

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

earnest phoenix
#

That's just how C/C++ works, it has been since the day they were made

wheat mesa
#

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

quartz kindle
#

you basically want to keep multiple different intervals running with different times?

earnest phoenix
quartz kindle
#

like one every 5 seconds, another every 15 seconds, etc?

rustic nova
#

this is making my brain hurt

#

or am I the one having brain damage rn

#

its the pointers

wheat mesa
#

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)

earnest phoenix
# rustic nova or am I the one having brain damage rn

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

earnest phoenix
wheat mesa
#

Also are you constructing this object at runtime? If not, you don’t need a pointer to it

wheat mesa
rustic nova
#

tbf am feeling like its trying to refer to another library thats default

wheat mesa
#

And the hellscape begins 😈

rustic nova
#

not even the linter is crying again

wheat mesa
#

You’re defining methods more than once

rustic nova
#

where doe

earnest phoenix
#

It's literally showing you

wheat mesa
#

MotorController::drive()

quartz kindle
#

an interval cannot be waited, its not meant for that, its literally made to do something every X time no matter what

wheat mesa
#

And MotorController::stop

quartz kindle
#

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

rustic nova
#

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?

wheat mesa
#

Header files should be declaration only

rustic nova
#

correct, done that

wheat mesa
#

Perhaps Arduino.h has something similar?

rustic nova
#

is what I'm thinking yeah

wheat mesa
earnest phoenix
wheat mesa
#

Try using a namespace to see

#

That might be it too

earnest phoenix
#

Use header guards

wheat mesa
#

#pragma once for MSVC iirc

#

Does that work on other compilers too?

earnest phoenix
#

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

wheat mesa
#

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

rustic nova
#
.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

earnest phoenix
#

What's in your RemoteCommunicator.cpp file?

#

Oh wait that's from a library isn't it?

rustic nova
#

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

earnest phoenix
#

I think between the library and your code you both have a class called MotorController where both of them are being included and conflicting

rustic nova
#

fuck that other library

earnest phoenix
#

This is why you should use namespaces :^)

rustic nova
#

I'll look into namespaces in a bit

#

nope still cries about it

#

giving up

earnest phoenix
#

Show code?

rustic nova
#
 .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

earnest phoenix
#

And what's in your header file?

rustic nova
#

of what?

#

the T1MotorController or the RemoteCommunicator

earnest phoenix
#

The T1MotorController

rustic nova
#

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

proven lantern
#

is there some way to do a follow up message to a different channel than the command was input to?

rustic nova
#

not really, except just sending a normal message into that channel

proven lantern
#

thanks

earnest phoenix
#

Try using namespaces to see if it changes anything

earnest phoenix
#

Unless you're intentionally not showing them

rustic nova
#

Never used header guards

rustic nova
earnest phoenix
quartz kindle
#

even with all the crap that cpp has, it still manages to be less confusing than java

#

for some reason

rustic nova
#

No

#

Java is more understandable for me than whatever cpp is

#

Could be missing experience though sk

#

so

quartz kindle
#

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

wheat mesa
#

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

hazy raptor
#

||k||

hushed robin
#

hi development

#

been awhile

radiant kraken
#

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

lean bobcat
#
ws.send(json.dumps(f'''42{"token":"{token}"}'''))
#

i am getting error in this

earnest phoenix
earnest phoenix
umbral flicker
#

How to make vote logger bot in server discord?

spark flint
earnest phoenix
#

Why does it write squares

rustic nova
earnest phoenix
#

Unknown character

rustic nova
#

fuck wrong reply

#

sorry null

radiant kraken
earnest phoenix
#

-_-

#

How to patch that so

#

(vps ubuntu)

rustic nova
#

by using a font in your browser that supports these characters

earnest phoenix
#

it was working this morning , why not now

#

How to find the supported fonts?

rustic nova
#

i dont even know what context that is

#

is that a website or what

lyric mountain
#

That is, you're summing their ascii values

dry delta
#

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

rustic nova
#

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

dry delta
#

Do you know what section it would be under

rustic nova
#

are you referring to our guidelines or wdym

dry delta
#

Discord tos

rustic nova
#

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.

solemn latch
#

Under discord yeah its that part.

lyric mountain
#

You can, tho, make the bot say something or whatever when you join, nothing more than that

dry delta
#

thanks

lyric mountain
#

Any type of alteration on the server would be a violation

rustic nova
#

building still fucking dies with header guards

#

about to just rm rf this shit project ngl

#

it finally fucking built

#

jesus

earnest phoenix
#

Hello

rustic nova
#

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
earnest phoenix
#

guru

rustic nova
#

about to just flash micropython onto this shit

#

starting to hate cpp more and more

wheat mesa
#

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

rustic nova
#

i can tell

#

taking a fair guess that approaching embedded dev stuff without a full understanding knowledge of cpp wont bring me far eh

rustic nova
#

solved it

not the best solution ngl

wheat mesa
rustic nova
wheat mesa
#

Type interpolation

rustic nova
#

Sounds like var to me

wheat mesa
#

Yes

#

It is

rustic nova
#

Fair enough

wheat mesa
#

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

rustic nova
#

Still need to figure out how to implement that singleton-solution above to allow providing constructor arguments

wheat mesa
#

Builder pattern

rustic nova
#

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

wheat mesa
#

Make a friend builder class that has access to the private members of the thing you’re building

#

Then just have a .build() function

rustic nova
#

Is it worth it to do that on a class that is mainly using a singleton?

wheat mesa
#

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

rustic nova
#

This just reminds me of java

wheat mesa
#

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

rustic nova
#

Lmao

wheat mesa
#

The same thing applies in C++ though

rustic nova
#

Yeah i generally work with builders too when i work with multiple instances of a class

#

Easy usability too

wheat mesa
#

You can also look at App.cpp to see the basic concept for the C++ version of a builder pattern

lyric mountain
#

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

rustic nova
#

Agreed

earnest phoenix
#

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

rustic nova
#

How about just another getter that returns the static object?

#

Or is the foo variable scoped into that one function?

earnest phoenix
#

A static initialized value is locked into the scope it was initialized in, nothing else can access it

rustic nova
#

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

earnest phoenix
#

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

rustic nova
#

paein

#

cant NULL define it either?

earnest phoenix
#

Wdym?

rustic nova
#

like define the variable as NULL, then having the Constructor define said variable

#

and then have a get_instance

#

or nah

earnest phoenix
#

It doesn't work like that

wheat mesa
#

Pointers c:

surreal sage
#

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

void drum
#

A

quartz kindle
#

B

proven lantern
#

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?

cold hearth
peak drum
neon leaf
#

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)

neon leaf
neon leaf
#

like its quite heard to accurately show what I have but generally I want the middlewares available throughout the code

quartz kindle
#

sort of

neon leaf
#

what do you mean sort of?

quartz kindle
#

i removed most things and tried to make it as barebones as possible

neon leaf
#

yeah, that will work but add multiple middlewares all containing different properties

quartz kindle
#

what does your middlewareInitted type look like?

earnest phoenix
# quartz kindle

Mmm yes very informative comment :^)

/** The Middlewares */ middlewares: Middlewares = [] as any
neon leaf
quartz kindle
#

when you overcomplicate stuff, it becomes hell to deal with

#

do you get an actual error?

#

or the type just becomes any?

neon leaf
#

nope, it is the middleware but no dynamic properties are shown

#

if I have a public middlewares key on the webServer it works fine

quartz kindle
#

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

neon leaf
#

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?

quartz kindle
#

welp

#

¯_(ツ)_/¯

neon leaf
#

I mean, it seems to work as intended in vscode rn after passing it like 4 times so I think it should be fine

neon leaf
surreal sage