#development

1 messages · Page 79 of 1

mighty patrol
#

I picked up my experience from doing my discord bot

lyric mountain
#

you do you anyway, but you should really consider at least a couple courses

slender wagon
#

why can i not understand how to conver fucking jquery into javascript

#
$(function(){
  $("#vidLinks a").click(function(){
    $("#modal").fadeIn()
  });
  $("#modal span").click(function(){
    $("#modal").fadeOut();
    $("#mainVid").attr("src", "")
  })
})
earnest phoenix
mint bridge
#

;play 10 mg

slender wagon
# earnest phoenix https://properprogramming.com/tools/jquery-to-javascript-converter/
document.querySelector(function(){
  document.querySelector("#vidLinks a").click(function(){
    document.querySelector("#modal").fadeIn()
  });
  document.querySelector("#modal span").click(function(){
    document.querySelector("#modal").fadeOut();
    document.querySelector("#mainVid").attr("src", "")
  })
})

that's what i did earlier but it keept throwing errors about the query selectors

#
Uncaught SyntaxError: Failed to execute 'querySelector' on 'Document': 'function () {
earnest phoenix
#

I guess it's a bad converter

slender wagon
#

every converter does this

#

but .click function seems a bit sus

#

isn't it supposed an entire event on its own

earnest phoenix
#

The click() method doesn't even exist on the elements

slender wagon
#

wym

earnest phoenix
#

Unless it's an actual button*

#

Have you tried logging what the query selector returns when you pass in the actual selector string?

#

You can remove the outer one in this case, the $(function(){ ... }) because that's not needed

slender wagon
#

five of them since there are five divs connected to this

earnest phoenix
#

I'm talking about the querySelector() method, it only returns the first element that matches the query

slender wagon
#

can i use querySelectorAll()

earnest phoenix
#

Yeah

#

Since it returns a node list you can use the item() method and pass the index of the node you want

#

And then work with it

cerulean jungle
#

If I remove that part of the code, will it still work?

ap.on('posted', () => {
  console.log('Status posted!')
})```
lyric mountain
#

absolutely impossible to say without seeing...yk...the code

#

but for all effects, try it and see

cerulean jungle
#
const ap = AutoPoster(config.topgg, client)
ap.on('posted', () => {
  console.log('Status posted!')
})```I want to leave the console clean, without logs
earnest phoenix
#

You don't need to log anything

#

And if that's all you use that event listener for, you can just remove it

#

Yeah (reply to a deleted message)

cerulean jungle
#

ok

lyric mountain
#

a clean console is a bad console

#

obviously a too messy console is equally bad

quartz kindle
#

a clean console is bad, a messy console is badder

eternal osprey
#
const string = '8795485488564835575723945398498489398434434';
const bigInt = BigInt(string);
console.log(bigInt)```why is this instead of actually returning me the value
#

giving me an object

deft wolf
#

Shouldn't await be used for functions?

vivid fulcrum
sudden geyser
solemn latch
boreal iron
earnest phoenix
eternal osprey
#

hmm i see

#

i changed my database type to string

sudden geyser
#

that may just be the case of the node repl

eternal osprey
#

it's still giving me this

#

trying to save a bigint to a string using sqlite, but it still seems to round!!

#

this was something i bothered tim with yesterday but it doesn't go away

earnest phoenix
#

Some consoles might take the output value and turn it into something else for whatever reason

earnest phoenix
#

You're doing it wrong

#
const foo = 500_000_000_000_000_000n;

await saveToDatabase(foo.toString());

// ---

const bar = BigInt(await getFromDatabase());

console.log(bar);
// 5000000000000000n
eternal osprey
#

i am getting a user input from a message collector and then saving it to a string in my database

earnest phoenix
#

Show your code of saving and converting back to a big int

eternal osprey
#
 if(connected == 1){
unverified_role = m.content
connected++
let currentDate = new Date();
let cDay = currentDate.getDate();
let cMonth = currentDate.getMonth() + 1;
let cYear = currentDate.getFullYear();
// await db.query(sql`ALTER TABLE serverdatabase DROP CONSTRAINT id;`)
await db.query(sql`UPDATE serverdatabase
                  SET unverified = ${m.content}
                  WHERE id = ${interaction.guild.id};`)```This is part of a normal message collector
#

it saves the m.content as a string

#

as unverified in the table is a string type

#

only thing i am doing next is console.logging the unverified in my table and it returns me a rounded version of the original

#

might need to do m.content.toString()?

earnest phoenix
#

It's returning a number, not a string like it's supposed to from the database

#

Because it's a string type

#

I would say this is either the fault of your database or something you're doing which causes this

eternal osprey
#

strange tbh

earnest phoenix
#

You don't seem to be saving it as a string though, you're just passing a number to the right-hand side of the assignment operator in that SQL query you've got

#

Because when you're substituting a string to another, the quotes are no longer there

eternal osprey
#

no ${} already gets seen as a string

#

if i used '' it would say that i cannot use it as it's already parsed as a string by sqlitedb itself

earnest phoenix
#

Oh wait you're using tags (sql), I didn't notice that

eternal osprey
#

yeah i am using @databases/sqlite

earnest phoenix
#

Then yeah, back to my previous statement

eternal osprey
eternal osprey
#

i will try to parse it with '' first as a last resort

#

it's not treated as a fucking string tho

#

wtf

earnest phoenix
#

I would say you're better off using better-sqlite3 or PostgreSQL

eternal osprey
#

would i have to change a lot in the ways of amking a query?

#

Because a few thousand lines of code depend on this

earnest phoenix
#

I think you already know the answer

#

They don't work exactly the same

eternal osprey
#

😭

#

This might help

quartz kindle
#

youre still using sqlite3?

#

better-sqlite3 has built in support for bigint

#

but like, why dont you just use strings

#

why go through the hassle of working with bigints

#

its not worth the storage efficiency, unless youre working on a large scale project

eternal osprey
#

using*

#

i've changed it

#

but it still rounds like dafuq

eternal osprey
quartz kindle
eternal osprey
#

string

#
 await db.query(sql`CREATE TABLE IF NOT EXISTS serverdatabase (
    id INT,
    status STRING,
    admin INT,
    date STRING,
    level INT,
    unverified STRING,
    pending STRING,
    verified STRING,
    timezone STRING,
    PRIMARY KEY(id) 
    );`)
#

unverified is the thing we need

quartz kindle
#

you also need to add quotes to your queries

eternal osprey
#

nope

#

databases/sqlite already parses the ${} as a string

quartz kindle
#
"set something = '${var here}'"
#

you need to add quotes there

#

around the var

eternal osprey
#

no it's not needed in this lib

quartz kindle
#

try it

eternal osprey
#

i have

#

why can't i reply to my message lmao

#

anyways

quartz kindle
#

that makes no sens

#

because an SQL query treats numbers as numbers

eternal osprey
#

well ion know

boreal iron
#

Is this library specific?

#

Never had that before

eternal osprey
#

it's databases/sqlite

#

i really don't know

#

it's fucking my whole progress tho

boreal iron
#

Weird error tho

#

I mean you can wrap numbers in quotes too

#

But makes no sense

quartz kindle
#

because like, ```js
const a = "876273468";
const b = set something = ${a}; // "set something = 876273468" <- SQL interprets this as a number, not as a string

eternal osprey
#

for some reason, this mother fucking library doesn't use STRING but TEXT as type???

#

wtf

quartz kindle
#

indeed it does not have STRING as a valid type

eternal osprey
#

normal sql does use string right?

quartz kindle
#

not really, it mostly uses varchar or SMALLTEXT / MEDIUMTEXT / etc

eternal osprey
#

Owh really?

#

I have my midterms coming up in a month

#

and they mainly use STRING as type

#

Together with INT and BIGINT

quartz kindle
#

this is for mysql

#

pgsql might be slightly different

eternal osprey
#

yeah ours looks a lot like postgres

boreal iron
#

Oops ping

quartz kindle
#

mariadb and mysql are 99% the same thing

boreal iron
#

Yeah ik

#

Just wanted to point it out

#

I'm actually not sure about SET tho

#

Which lib are using btw?

quartz kindle
#

hes using some weird thing called @databases/sqlite

#

which is based on sqlite3

boreal iron
#

Hmm ok

lyric mountain
#

Sqlite literally boils down all datatypes to the most generic option available

#

Also I never saw a database that uses STRING as a type

sharp geyser
#
                await conn.execute(
                    """
                    CREATE TABLE IF NOT EXISTS profile
                    (
                        id              BIGSERIAL,
                        profile_id      BIGINT NOT NULL UNIQUE,
                        balance         BIGINT DEFAULT 1000,
                        class_id        SMALLINT DEFAULT 1,
                        rank_id         SMALLINT DEFAULT 0
                    );
                    CREATE TABLE IF NOT EXISTS item
                    (
                        id              BIGSERIAL,
                        profile_id      BIGINT NOT NULL,
                        item_id         SMALLINT NOT NULL,
                        FOREIGN KEY     (profile_id) REFERENCES profile(profile_id) ON DELETE CASCADE
                    );
                    """
                )

Is this how I make a One-To-Many relation between profile and inventory? From the docs on the internet this is correct but I just want to be sure.

#

Also if it is, how would I insert an inventory item so it belongs to the correct user?

leaden hawk
#

Hey, I'm pretty sure I should know how to fix this but i dont, has stuff changed with the new version of discord.py? I stopped using discord.py when Rapptz said it was done and I have only recently discovered that theres been like 10 updates so im back at it again. Can someone explain to me why i have this error? i have never encountered "Name of a command" TypeError before

2: Extension 'cogs.config' raised an error: TypeError: Name of a command must be a string.
earnest phoenix
#

is your commands name a string

sharp geyser
dry imp
leaden hawk
sharp geyser
#

yea I don't think you can use lists anymore

leaden hawk
#

you cant??

#

🤦‍♂️ Lists are so good tho

sharp geyser
#

I might be wrong but i remember something about that being removed

leaden hawk
#

does the aliase function still work?

sharp geyser
#

there is still a prop called aliases that returns a list of str that the cmd can be called by

#

how you set them idk

#

I don't really use message cmds anymore I use slash cmds

leaden hawk
#

they back now tho, so im glad

#

you were right, i just changed it on one of my cogs

sharp geyser
#

I just looked at the docs

#

discord.gg/dpy ask here if you wanna see if you can still do listed names

leaden hawk
#

thank you

earnest phoenix
earnest phoenix
#

how to make bot send message when a user vote it on top.gg

sharp geyser
#

I swear I remember seeing it as well

earnest phoenix
#

Nope

#

Only aliases=["some", "aliases", "here"]

flat copper
#
const fs = require("fs");
const router = require("express").Router();
const MdW = require(process.cwd() + "/middlewares/middleware.js");
const mdw = new MdW();

class Router {
  constructor(app){
    this.app = app
    //app.use("/", mdw.connect)
    app.use("/", router)
   // app.use("/", mdw.error)
  }
  
  load(name, fun) {
    router.all(name, fun);
    log.log(`Loaded route ==> ${name}`)
  }
  
  async loadAll() {
    const dir = config.routerDir || "routes/route"
    let route = process.cwd() + "/" + dir
    const files = await fs.readdirSync(route)
    for(const file of files) {
      let fun = require(route + "/" + file)
      let name = file.split(".")[0]
      
      this.load(name, fun)
    }
  }
}

module.exports = Router

its saying "cannot get /main"

#

help

sterile brook
#

It could be that there is no route registered for the /main path, or there could be an issue with the route handler function that is being used to handle requests to that path.

#

Need more context btw

earnest phoenix
#

I am making a yt search command but the reply comes undefined.

Plz help!!

Code- ```js
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
const search = require('yt-search');

module.exports = {
data: new SlashCommandBuilder()
.setName('yt')

.setDescription("Yt command")
.addStringOption((option) => option.setName("query").setDescription("the vid you wanna see").setRequired(true)),
async execute(interaction) {

await interaction.deferReply();

let q = interaction.options.getString('query');

const find = search(q);

if (find) {
    
   const embed = new EmbedBuilder()
  .setDescription(`${(await find).url}`);

return interaction.followUp({ embeds: [embed] });

} else {
return interaction.followUp({ content: "No results!" });
}

},

};```

#

thats not how js works

ancient wedge
#

hi, why is this happening

function getData(url) 
{
    request(url, { json: true }, (err, reason, body) =>
    {
        console.log("This will display body: " + body)
        return body;
    });
}

const data = getData("epicurl");
console.log("This will display body as undefined" + data);

First console.log waits for data to be fetched and then displays it but body is returned immediately

earnest phoenix
sterile brook
#

@earnest phoenix

const find = await search(q);
if (find.videos.length > 0) {
  const video = find.videos[0];
  const embed = new EmbedBuilder()
    .setDescription(video.url);
  return interaction.followUp({ embeds: [embed] });
} else {
  return interaction.followUp({ content: "No results!" });
}
ancient wedge
#

its very defined

#

i tried making it async but it should be async by default

sterile brook
#

Nah,

function getData(url, callback) {
  request(url, { json: true }, (err, reason, body) => {
    callback(body);
  });
}

getData("epicurl", (data) => {
  console.log("This will display body: " + data);
});

Try this

#

Or use promise

ancient wedge
sterile brook
#

I hope u understand why it didn't work

ancient wedge
#

i understand nothing about js

#

goofyahh language

sterile brook
#

Poggo

deft wolf
next storm
#

followUp and editReply both will work if the interaction is deferred

earnest phoenix
sterile brook
#

So does ur problem solved? @earnest phoenix

deft wolf
#

Ah, okay. I've never used interaction.followUp()

earnest phoenix
sterile brook
fervent moss
#

I can use documnet in node express server.
It says document is undefined. For eg I'm using : const wrapper = document.querySelector(".wrapper") what could alternative be?

carmine summit
#

How can I make a drop-down like interface on slash commands?

deft wolf
#

U mean select menu?

carmine summit
#

Maybe yes

deft wolf
carmine summit
#

In slash commands I mean...

#

Like, an argument but the values are given by the bot

#

and the user has to choose one

deft wolf
#

Aaaa

#

Choices

fervent moss
#

Also there exist autocomplete

carmine summit
#

I'm still having trouble. I'm using djs v14.7.1. I tried using .addChoices and .setChoices it gives me an error ValidationError: Expected the value to not be an array

deft wolf
earnest phoenix
#

Don't pass an array

deft wolf
#

I mean choices

carmine summit
carmine summit
earnest phoenix
#

Expected the value to not be an array

#

The error says it all

#

How it's supposed to be used, I don't know

deft wolf
#

Can you post what your command looks like?

earnest phoenix
#

Errors give you the information though

carmine summit
#

ValidationError: Expected the value to be an object, but received string instead

earnest phoenix
#

Ah yes, remove the important part of the error

sterile brook
#

Ha-ha, classic

earnest phoenix
#

Isn't it just

.addChoices({name: "blah", value: "blah"})
#

And you simply pass multiple of those objects

#

e.g

.addChoices(
  { name: "blah", value: "blah" },
  { name: "blah2", value: "blah2" },
)
boreal iron
#

The API expects an array of choices

#

Dunno how you have to pass them internally in djs

earnest phoenix
#

¯_(ツ)_/¯

boreal iron
#

The fact that you have to pass the structure the api expects as argument to the addChoices() method instead of creating the entire structure yourself is just weird

#

Idk why people use the builders

earnest phoenix
deft wolf
#

I don't know either Thonk

earnest phoenix
#

step 1 when going on the developer docs

#

Disable that garbage

sterile brook
earnest phoenix
#

Discord & consistency 101

carmine summit
earnest phoenix
#

Don't rely on AI

sterile brook
#

Ai is about generic

#

Or pretty simple cases

boreal iron
#

No time for consistency for the rest

earnest phoenix
#

I swear

sterile brook
#

Also chatgpt is bad with interactions

earnest phoenix
#

I'd be ready to be snowsgiving "gifts" are like last year

#

Emoji and sticker packs

carmine summit
#

It's pretty good and solves many cases including difficult ones, but they said that to put them in an array and pass them to addChoices

#

addChoices also confused me why they arent expecting an array

sterile brook
#

Nah, chatgpt mostly just uses freaking reactions lol

earnest phoenix
#

It's djs after all

sterile brook
#

Even if u say use buttons

#

Etc

earnest phoenix
#
public addChoices(...choices: APIApplicationCommandOptionChoice<T>[])
sterile brook
#

To be fair, that how ai worksokeh

#

Yeah, nice slash command buddy

dry imp
#

pheww... humans still have some chance

sterile brook
boreal iron
#

Actually those are called application commands

#

Not slash commands (anymore)

earnest phoenix
boreal iron
#

lol

earnest phoenix
#

Or people using #/@ as prefix, also legends

sterile brook
#

Also depr. Channel.send() method

boreal iron
#

Ye the exclusive prefixes like () or {}

sterile brook
#

From v13

#

Or v12 even

boreal iron
#

Which require to press 4 keys each command

#

(well technically 3)

carmine summit
sterile brook
#

Show how you asked smh

carmine summit
#

Partially correct

sterile brook
#

I bet u asked for slashcommandbuilder

#

Etc

carmine summit
#

Yeah I asked it to use SlashCommandBuilder

earnest phoenix
feral aspen
boreal iron
#

Host is unreachable

feral aspen
#

Oh, wat?

sterile brook
#

Exactly what fake typed

feral aspen
#

Do I just set another registry or something.

sterile brook
earnest phoenix
#

Which means network problem

#

You can search on Google for help around that

#

Searching with the error message will give you lots of results for help

feral aspen
#

Wait, wrong one.

boreal iron
#

Simply try to ping the host

earnest phoenix
#

That's what Google says, yes

boreal iron
boreal iron
#

And show me the results

earnest phoenix
#

Searched npm err! code ehostunreach on Google :)

feral aspen
#

Address unreachable?

earnest phoenix
#

If you get Destination Host Unreachable, the firewall is blocking

feral aspen
#

Nope, just a Destination unreachable: Address unreachable.

boreal iron
#

Are you blocking outgoing connections on port 443?

feral aspen
#

I've done nothing on my VPS for the past 2 months.

#

Although, I am attempting to host an express application.

earnest phoenix
#

You have the VPS somewhere

#

These people can block specific things

#

You don't own the machine

feral aspen
#

I haven't done anything really but install nginx, create a configuration file, certbot, and that's it.

boreal iron
#

There could still be a firewall of your provider active

earnest phoenix
#

As said, it's not because you did nothing regarding firewalls that it can't be done by the provider that temporarily provides you with the VPS

feral aspen
#

Oh, it could be the configuration file.

boreal iron
#

Does apt update also return an error?

feral aspen
#

Nope, returns 29 packages.

feral aspen
radiant kraken
#

@earnest phoenix does a TypeScript library require typings to be exported

earnest phoenix
#

But there's no need to export typings if the types are declared in the actual files instead of a separate typings file (such as a d.ts) file

radiant kraken
#

@earnest phoenix sobbing

#

should i remove support for linux arm x64 gnueabihf

#

i dont understand all of this

earnest phoenix
radiant kraken
#

then what should i do

#

i dont even understand what gnueabihf means

#

whats the difference

earnest phoenix
#

That's the ABI, not all machines use the same ABI, which define the system features, types, sizes, and many other stuff

radiant kraken
#

for it to work the process.arch should've yielded arm, but it yielded x64 instead

earnest phoenix
radiant kraken
#

i dont fucking get it

earnest phoenix
radiant kraken
#

@earnest phoenix can u explain what these docker flags mean

nocturne dagger
#

Hey guys

#

first time using slash commands, I got a ping command working

#

but anytime I try to add another command it just overwrites the past one

#

so if I have 2 commands in the command folder only one works

#

Nvm, fixed it stupid error

#

Had the new collection in the loop by accident

heavy island
#

Anyone know this error? discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: User.list_users() got an unexpected keyword argument 'search'

neon leaf
solemn latch
#

Id say maybe, but I have no idea what the video is.

neon leaf
#

turning
"hello im " + name + "! how are you"
into
´hello im ${name}! how are you´

earnest phoenix
neon leaf
#

oh

#

well thanks

#

can I somehow do that for the entire file at once?

earnest phoenix
#

Haven't seen that

#

Doubt there is an extension as well

#

Also haven't seen any extension about that when going through the marketplace

slender wagon
#
 <Script
        src="../scripts/modals.js"

is this how u load scripts on nextjs

#

using the next/script btw

#

i tried to log the error or onload

#

and it's logging nothing nothing

#

which is weird

lofty cipher
#

How can i make Pocket code and Social Media below Anmelden and Team?

nocturne dagger
#

Anyone know why the .addNumberOption is expecting a string?

nocturne dagger
lofty cipher
nocturne dagger
sharp geyser
#

Are you certain the error is coming from this particular part of the code?

#

That all looks correct to me

nocturne dagger
#

was here

#

need to to string it

quartz kindle
#

embed values are strings yes

wise summit
#

I don't know where to ask this but is it possible to use top.gg api to make website have a statistics part to show how many guilds and total user amount the bot is in? How hard would it be to make? Yes I know the bot needs to be approved for api token stuff.
Also dont mind my silly forming of the question

#

Just preparing in advance, incase the bot gets approved

quartz kindle
wise summit
#

I'm a rookie on this kinda stuff so didn't know

quartz kindle
#

topgg does not give you any statistics, in fact its the opposite

wise summit
#

ah

quartz kindle
#

you use the top.gg api to send your statistics to them

#

so they can display it on your bots page

wise summit
#

Ohhh! I see.

#

thanks! :)

swift lynx
#

anyone knows y im getting this?

  `  message: "Cannot read properties of undefined (reading 'add')",\n` +
  "  name: 'TypeError',\n" +
  `  stack: "TypeError: Cannot read properties of undefined (reading 'add')\\n" +\n` +
  "    '    at Shard.wsEvent (/home/container/node_modules/eris/lib/gateway/Shard.js:853:65)\\n' +\n" +
  "    '    at Shard.onPacket (/home/container/node_modules/eris/lib/gateway/Shard.js:402:26)\\n' +\n" +
  "    '    at Shard._onWSMessage (/home/container/node_modules/eris/lib/gateway/Shard.js:2444:29)\\n' +\n" +
  "    '    at WebSocket.emit (node:events:513:28)\\n' +\n" +
  "    '    at Receiver.receiverOnMessage (/home/container/node_modules/ws/lib/websocket.js:1178:20)\\n' +\n" +
  "    '    at Receiver.emit (node:events:513:28)\\n' +\n" +
  "    '    at Receiver.dataMessage (/home/container/node_modules/ws/lib/receiver.js:513:14)\\n' +\n" +
  "    '    at Receiver.getData (/home/container/node_modules/ws/lib/receiver.js:446:17)\\n' +\n" +
  "    '    at Receiver.startLoop (/home/container/node_modules/ws/lib/receiver.js:148:22)\\n' +\n" +
  "    '    at Receiver._write (/home/container/node_modules/ws/lib/receiver.js:83:10)\\n' +\n" +
  "    '    at writeOrBuffer (node:internal/streams/writable:392:12)\\n' +\n" +
  "    '    at _write (node:internal/streams/writable:333:10)\\n' +\n" +
  "    '    at Writable.write (node:internal/streams/writable:337:10)\\n' +\n" +
  "    '    at TLSSocket.socketOnData (/home/container/node_modules/ws/lib/websocket.js:1272:35)\\n' +\n" +
  "    '    at TLSSocket.emit (node:events:513:28)\\n' +\n" +
  "    '    at addChunk (node:internal/streams/readable:324:12)'\n" +
  '}'```
sudden geyser
#

why is that even formatted the way it is

lament rock
#

an error with eris it seems

swift lynx
#

what do you think i should do?

lyric mountain
#

I fear no man, but what the fuck is that log

swift lynx
#

lol now that error is gone

#
  '  <rejected> MongoError: E11000 duplicate key error collection: test.guilds index: _id_ dup key: { _id: "1024414204809183262" }\n' +
  '      at MongoError.create (/home/container/node_modules/mongodb/lib/core/error.js:59:12)\n' +
  '      at toError (/home/container/node_modules/mongodb/lib/utils.js:130:22)\n' +
  '      at /home/container/node_modules/mongodb/lib/operations/common_functions.js:258:39\n' +
  '      at handler (/home/container/node_modules/mongodb/lib/core/sdam/topology.js:961:24)\n' +
  '      at /home/container/node_modules/mongodb/lib/cmap/connection_pool.js:352:13\n' +
  '      at handleOperationResult (/home/container/node_modules/mongodb/lib/core/sdam/server.js:567:5)\n' +
  '      at MessageStream.messageHandler (/home/container/node_modules/mongodb/lib/cmap/connection.js:308:5)\n' +
  '      at MessageStream.emit (node:events:513:28)\n' +
  '      at processIncomingData (/home/container/node_modules/mongodb/lib/cmap/message_stream.js:144:12)\n' +
  '      at MessageStream._write (/home/container/node_modules/mongodb/lib/cmap/message_stream.js:42:5)\n' +
  '      at writeOrBuffer (node:internal/streams/writable:392:12)\n' +
  '      at _write (node:internal/streams/writable:333:10)\n' +
  '      at Writable.write (node:internal/streams/writable:337:10)\n' +
  '      at TLSSocket.ondata (node:internal/streams/readable:766:22)\n' +
  '      at TLSSocket.emit (node:events:513:28)\n' +
  '      at addChunk (node:internal/streams/readable:324:12) {\n' +
  '    driver: true,\n' +
  '    index: 0,\n' +
  '    code: 11000,\n' +
  '    keyPattern: { _id: 1 },\n' +
  "    keyValue: { _id: '1024414204809183262' }\n" +
  '  }\n' +
  '} reason: MongoError: E11000 duplicate key error collection: test.guilds index: _id_ dup key: { _id: "1024414204809183262" }'```
lyric mountain
#

Why is it formatted like a string?

#

How did u actually manage to even get it like that

swift lynx
lyric mountain
#

Yeah you're trying to insert a key twice, it's written in the first 2 lines

swift lynx
#

any solution?

lyric mountain
#

...like not inserting it twice?

#

I imagine that's happening because you're saving all the guilds to the database on startup

sharp wren
lyric mountain
#

But really, try to fix that log too

swift lynx
#

im just going to reinstall it and hope for the best

wheat mesa
swift lynx
#

ik

lyric mountain
#

Don't think we can help then

#

All in all, running random code from the internet is a serious security concern, and even if safe, it's generally impossible to maintain

#

And yes, I know you'll just roll your eyes and continue whatever you're trying to do, but at least give some thought to what I said

uneven tartan
#

running random code from the internet is the most fun thing

#

its like gambling

sudden geyser
#

onRequest((req) => eval(req.body))!!!

boreal iron
#

What can wrong

sharp geyser
sudden geyser
#

allows you to remotely shut down server

#

no more sshing at 3 am

sharp geyser
#

lmao

boreal iron
sharp geyser
#

Who doesn't run node with root privs tf

radiant kraken
#

even though i know it'll fail

boreal iron
#

Well the opposite

sterile brook
#

_id is unique, so u can't

#

Oh, sry, it was answered alr

radiant kraken
#

the docs didn't help

#

or anyone who uses docker

earnest phoenix
#

Docs are self explaining but sure

#

-v set the volumes

#

Which means that you can 'mount' a volume, folder, from your computer into the docker container so that it can edit the files and they will be edited on both your computer and in the container.
It is used like computer_path:docker_path - so the computer_path is the path on the current computer for the volume you want to share and docker_path is where it will be 'mounted' in the docker container itself.

#

-w sets the working directory in the docker container, nothing more to explain to be fair.

If you don't know what a working directory is, you can search it up and get a result like

The current working directory is the directory in which the user is currently working in. Each time you interact with your command prompt, you are working within a directory.
By default, when you log into your Linux system, your current working directory is set to your home directory. To change the working directory use the cd command.
https://linuxize.com/post/current-working-directory/#:~:text=The current working directory is,directory use the cd command.

radiant kraken
#

i already know what a working directory is thanks

earnest phoenix
#

Awesome CatJAM

vestal plover
#

Does anyone here use Repl.it to program Discord bots?

earnest phoenix
#

There are lots, just ask your question.

#

Note that Replit is not made for Discord bots at all and it is not recommended to do so.

vestal plover
earnest phoenix
#

Visual studio code is a code editor and does not host anything

earnest phoenix
#

Local files

radiant kraken
#

it's more recommended to use a VPS to host discord bots

earnest phoenix
#

You need to take care to keep backups etc. using e.g. github

vestal plover
earnest phoenix
#

The documentation of the library you're using

#

You should not use Replit to host your bot

While this may seem like a nice and free service, it has a lot more negative sides than you might think, some are the following:

• The machines are super underpowered.
• This means your bot will lag a lot as it gets bigger.

• You need to run a webserver alongside your bot to prevent it from being shut off.
• This isn't a trivial task, though eats more of the machines power that is already very low.

• Replit uses an ephemeral file system.
• This means any file you saved via your bot will be overwritten when you next launch.

• They use a shared IP for everything running on the service.
• This one is important - if someone is running a user bot on their service and gets banned, everyone on that IP will be banned. Including you.

Please make yourself a favor and avoid using Replit to host your bot. It's not worth the trouble.

vestal plover
earnest phoenix
#

You code your bot with a code editor or IDE.
You host your bot with a VPS.

earnest phoenix
deft wolf
#

Just google it

sterile brook
#

Senior Googler

boreal iron
sterile brook
#

Yep

#

In that day

#

Changed async method of buffering canvas to sync and that's it

carmine summit
#

what are the limitations for slash command names

sharp geyser
#

we cant help you

#

jk

sharp geyser
#

I don't remember if numbers are included

sharp geyser
#

I think you can't use numbers tho

lofty cipher
#

How can i use pterodactyl websocket for console in javascript

radiant kraken
#

making progress!!!!!!!

#

the green is dominating

boreal iron
#

But - and _ are allowed chars

carmine summit
#

Alright! Thanks!

boreal iron
#

Between 1-32 chars

boreal iron
#

Oh nice

#

Finally

#

Guess we now need to wait another year or two until this is implemented in the application commands UI

#

And maybe another year for modals

rose warren
boreal iron
#

Yeah it's so sad

earnest phoenix
rose warren
#

#lifegoals

radiant kraken
#

hi Mac Frost

radiant kraken
earnest phoenix
#

Heh, we don't even use GitHub Actions at all for building LLVM, we use the Harbor Master through BuildKite via our Phabricator instance

radiant kraken
#

fancy

#

anyway anybody know what docker run --rm --privileged multiarch/qemu-user-static:register --reset does?

earnest phoenix
#

The documentation explains what all the flags do, the one I linked before

radiant kraken
#

the person who made the CI template put this as the first step in several jobs

earnest phoenix
# radiant kraken just tell me what it does
  1. The --rm flag is false by default so the file system of your container stays/persists even after the container exits, which can make debugging easier but if you only need short-term foreground processes and such then those file systems and their states can pile up and use a lot of storage, using the --rm flag tells Docker to automatically clean up the container and remove it's respective file system
radiant kraken
#

ah

#

does working directory matters?

earnest phoenix
#

Everything that is contained in the container's respective file system

#
  1. The --privileged option gives the Docker container extended privileges, as by default all Docker containers are "unprivileged", which for example, they can't run a Docker daemon inside a Docker container
#

The option provides fine-grained permissions so you can be sure it runs with the exact permissions you need

#
  1. There's no flag called --reset in Docker anywhere, unless that's for a different program
feral aspen
#

Aloha, I've been going through some GitHub Repositories, and from a repository I've found, I've noticed a file called .env.example. Anyways, within such so, I've noticed the following properties requiring data, what am I required to do if I'd want to host it locally?

# exposed to client
NEXT_PUBLIC_UMAMI_USERNAME=umami username login
NEXT_PUBLIC_UMAMI_PASSWORD=umami password login
NEXT_PUBLIC_UMAMI_URL=umami self-hosted url
NEXT_PUBLIC_TWITTER_USERNAME=@twitter username
NEXT_PUBLIC_SITE_NAME=site name 
NEXT_PUBLIC_SITE_URL=site url including "https://"
NEXT_PUBLIC_SECRET=
NEXT_PUBLIC_SUPABASE_URL=
NEXT_PUBLIC_SUPABASE_ANON_KEY=
#

Now, honestly. After I've tried to run said Next.JS application (a website), it asks me that the supabaseUrl is required. If the application is hosted locally, with what am I supposed to fill it with?

earnest phoenix
#

Usually these projects have a documentation you can follow.

#

And here the variable names are self explanatory CatJAM

feral aspen
feral aspen
earnest phoenix
#

Open source firebase alternative

#

There are some examples if you search around

feral aspen
#

👍 👍

neon leaf
#

I dont know if its correct but this may be useful

#

seems to work

radiant kraken
#

@earnest phoenix i fucking hate FreeBSD

earnest phoenix
#

Lmao

ancient wedge
#

how to get reactions on an old message? i'm trying to fetch the message and create a listener but its not working

#
client.on("messageReactionAdd", (reaction, user) => {
    user.send("test")
});

Only works for new messages

minor olive
#

It's like "rawMessageReactionsAdd" or something. However, this function does not provide any message. It just provides the message ID, guildID, channelID, etc...

deft wolf
ancient wedge
#

with .fetch but its not working

#

im onto something brb

deft wolf
#

You can try this

const message = !reaction.message.author? await reaction.message.fetch(): reaction.message;
radiant kraken
ancient wedge
#

and user id

#

google isn't helping much

deft wolf
#

Then remove .cache before fetch

earnest phoenix
ancient wedge
#

can't create reaction collector

deft wolf
#

Then you need to check if this message exists, if the bot has access to it, and so on

#

As error itself says, "unknown message"

ancient wedge
#

it exists

#

its created when message is sent

#

oh wait

deft wolf
#

Can you post some more code because maybe the error lies in another part of it

ancient wedge
#
var x = client.channels.cache.get("1052712693188010116").messages.fetch("1052713687670079499").then(m => m.createReactionCollector());
#

results in m.on is not a function

#

message is fetched tho, shows everything when logged

deft wolf
#

Assign m.createReactionCollector() to another value like

const collect = m.createReactionCollector()

and then

collect.on()
ancient wedge
#

yep it worked

#

thanks man

deft wolf
#

I'm glad it works

ancient wedge
#

well turns out if you fetch it then on messageReactionAdd event will work lol

deft wolf
#

From what it seems to me, all message events work on messages that are in the bot's cache. If you fetch a message, the bot takes information straight from the discord api and puts this message in the cache

#

The cache resets every time you turn on the bot or you can set it manually to clean it from time to time

ancient wedge
#

yeah its weird but very simple

#

it doesnt seem to explain that well in the docs

#

or im just blind lol

ancient wedge
#

also, what would be c# {get; set;} js equivalent?

radiant kraken
#

@earnest phoenix linux arm mimu_thisisfine

#

do u know why

#

look there's no need to write an essay

earnest phoenix
# ancient wedge also, what would be c# {get; set;} js equivalent?

Basically getters and setters, an example:

class Foo {
  // Private property called 'bar'.
  #bar = 5;

  // Getter to get the value of the private property 'bar', but only if it's divisible by 2.
  get bar() {
    return this.#bar % 2 === 0
      ? this.#bar
      : null;
  }
  // Set the value of the private property 'bar', but only if it's a number.
  set bar(value) {
    if (typeof value === 'number' && !isNaN(value))
      this.#bar = value;
  }
}

const foo = new Foo();
// The default value of the private property 'bar' is 5 as we declared.

console.log(foo.bar); // null, because it's not divisible by 2 as we defined.
foo.bar = 4;
console.log(foo.bar); // 4

foo.bar = 'g'; // won't change as we're only setting the value if it's a number.
console.log(foo.bar); // 4
radiant kraken
#

bruh

#

i thought you were responding to mine

earnest phoenix
# radiant kraken do u know why

Exactly what it says, it requires GLIBC (GNU C Library) version 2.33 or higher, which is not on that environment you're running it on

radiant kraken
#

didnt help

earnest phoenix
#

Debian? Arch?

radiant kraken
#

it's on a ubuntu-latest so guess

earnest phoenix
# radiant kraken it's on a `ubuntu-latest` so guess

Hmm regardless, that .node add-on object file requires GLIBC 2.33 which is not present on that environment, something definitely needs to be updated there, or there's no GLIBC 2.33 for that target you've compiled against

radiant kraken
earnest phoenix
#

Nice

radiant kraken
#

@earnest phoenix is there any difference between aarch64 linux with aarch64 android?

#

like if an aarch64 linux binary works, is it a guarantee for the aarch64 android binary to work too?

earnest phoenix
radiant kraken
#

should i add another tests job for android?

earnest phoenix
#

You don't necessarily need to, but if you want everything to work exactly the way it is, just in case some things don't match then go ahead

craggy pine
#

I might be dumb but I'm converting some v13 code to v14 and I'm unsure why this is flagging as false.

console.log(needsDJ)
console.log(!interaction.member.permissions.has("Administrator"))
console.log(!role)
console.log(!interaction.user.username === player[0].queued_by) //Should flag true because MiyukaTest !== Miyuka right?
console.log(interaction.user.username)
console.log(player[0].queued_by)

Output:

true
true
true
false // here
MiyukaTest //compairing
Miyuka // compairing
wheat mesa
#

that's not how you do equality

#

use !==

craggy pine
#

Ya I was about to do that tbh

#

but I assumed it was the same thing putting the ! at the beginning

wheat mesa
#

Nope

#

that casts interaction.user.username to a boolean and then checks if that equals the other

craggy pine
#

Oh so it sets interaction.user.username to false.

#

gotcha.

wheat mesa
#

Which will always be false because you're comparing two different types with the strict equality operator

#

Yeah

craggy pine
#

Noted for future code.

#

ty

wheat mesa
#

Welcome back to another episode of "Why you should use typescript!" 😉

craggy pine
#

You know.

#

I was kinda tempted too when I stumbled apon a regex test thing with typescript and seen how useful it was. But then JS has a similar this but with an extra line of code.

#
.test
wheat mesa
#

Well, that's not the point of typescript

craggy pine
#

Idk the differences tbh between the two

#

I just know they're similar-ish

wheat mesa
#

The ts compiler would've screamed at you for this line of code: !interaction.user.username === player[0].queued_by

craggy pine
#

oh really LUL

wheat mesa
craggy pine
#

Oh I see.

wheat mesa
#

Ts is just js with strict typing

#

Though you can always work around it by using any

craggy pine
#

Isn't it complied differently. Or can you still do the whole node index.js if you wanted too.

#

Well I guess TS probably doesn't use node right

wheat mesa
#

Usually catches a lot of compile time bugs before you run it

#

TS uses node, it transpiles into javascript which is then run via node or some other js engine

craggy pine
#

oh okay.

#

I'll likely dabble with it knowing that.

#

I've heard only good things about TS > JS

wheat mesa
#

It gives a lot more compile time safety

#

And unless you're Tim you probably won't be complaining about some of the limitations

craggy pine
#

Also something that is kinda lame and unrelated.

#

Why DJSv14 have to change permission checking from ALL CAPS to A cap.

wheat mesa
#

they felt like it

craggy pine
#

making me rewrite all the shit

#

lol

wheat mesa
#

might also be something with standards, but usually with enum flags it's up to preference

#

I suppose PascalCase looks nicer

craggy pine
#
<rejected> RangeError [BitFieldInvalid]: Invalid bitfield flag or number: ADMINISTRATOR.
#

just more of this while I clean up my stuff

#

lol

wheat mesa
#

The main two are SCREAMING_SNAKE_CASE and PascalCase for enums, I don't usually see anything other than that used

craggy pine
#

inb4 camel case just to smite you

wheat mesa
#

Nah not even Java goes to that circle of hell

craggy pine
#

god I tried java

#

hated it

#

But good to learn

wheat mesa
#

java is great

craggy pine
#

Oh trust ik.

#

My original bot was java, but JS is just nicer to write

wheat mesa
#

It's the C of OOP languages

#

And in that way it's beautiful

craggy pine
#

never like the whole

#

public static void

#

stuff.

lyric mountain
#

you should try groovy then

wheat mesa
#

😔 but that's the whole point of java

craggy pine
#

Kuu ik your a java god.

#

shoo

lyric mountain
#

hi miyu

craggy pine
wheat mesa
#

encapsulation and fun

craggy pine
#

hi ❤️

lyric mountain
wheat mesa
#

though I don't necessarily agree with the "everything must be in a class" doctrine

craggy pine
#

well you saved icarus once b4 it died to getting hacked

#

so ur a god to me ❤️

wheat mesa
#

I wish I could write some static functions without needing class bodies

#

but maybe that's the rust side of me showing

lyric mountain
craggy pine
#

Hes focusing on twitch

#

while im solo now

#

do my own stuff

lyric mountain
#

ah ic

craggy pine
lyric mountain
#

but really, give groovy a try someday, it's almost as if js and java crossed paths

wheat mesa
#

noooooooooooooooooooooooooooooooooooooooooooooo but buttonnnnnnnnnnnnnnnnnnssssssssssssssssss

craggy pine
#

Listen

#

I'd use buttons if discord would let me make buttons SMOL

wheat mesa
#

think of the wasted rest requests 😔

craggy pine
#

I hate how large they are for all the buttons I need.

#

they start to stack

lyric mountain
#

like, u get all the power of java with much less verbosity, if that's the part u dont like

#

it's to java what js is to ts basically

wheat mesa
#

I've heard kotlin is nice

#

Haven't had a use case for it though

lyric mountain
#

wish I could like it, but it feels too odd for me

sterile lantern
#

If you have an already sorted array of integers, would insertion sort or selection sort take a longer time to terminate ?

lyric mountain
#

both would be O(1) no?

#

or at least, O(n) since you'll need to read all entries to see if it's sorted

wheat mesa
#

Sounds like an exam question to me

sterile lantern
#

lol yeah I got my CS final results but I think I got it wrong

#

I’m pretty sure it’s selection I put insertion

wheat mesa
#

Think about what both of the algorithms do

#

Selection sort swaps values until they’re in place

#

Insertion orders by selecting the highest/lowest value and putting it in place

lyric mountain
wheat mesa
#

Selection’s best complexity is O(n^2)

#

They’re similar but not the same

#

Selection is slower than insertion on a sorted array

sterile lantern
#

yeah I second guessed myself

#

oh well at least I passed lol

wheat mesa
#

Because best case for selection is O(n^2) and insertion’s best case is O(n)

#

I wonder what I got wrong on my CS final

#

I got 94/95

#

Very curious

sterile lantern
#

I got a 85/87

wheat mesa
#

Nice

lament rock
quaint wasp
#

hey- does anyone know react?

lament rock
#

man was using the 1TBS when that isnt the syntax

quartz kindle
#

synth axe

quaint wasp
#
import React from "react";
import ReactDOM from "react-dom/client";
import "./index.css";
import App from "./App";

const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>
);```
Someone wrote this and I haven't talked to them in quite some time and now that I really need to use the file there's a problem, with the `<` / `>` symbols.
I am unsure on what he was attempting to do, but since I do not know React I thought one of you would know and maybe help me fix it.
#

ping in replies

wheat mesa
#

Can you be more specific on what the problem actually is?

earnest phoenix
solemn latch
quaint wasp
#

Unsure though since this is my first time using react

hidden gorge
#

Im trying to put my text on the left side of the click icon but my text-align isnt working idk why

h1 {
  color: white;
  text-shadow: 1px 1px 2px black, 0 0 25px blue, 0 0 5px darkblue;
  text-align: left;
}```
earnest phoenix
#

not js but c

#

Machine code ftw

minor olive
slender wagon
#

i am working on a project where for each card i should show a quick demo with a video
how could i get through this without making the entire laggy as hell

tulip ledge
#

I'm trying to animate stuff in on scroll using react and I got this function:

  useEffect(() => {
    const observer = new IntersectionObserver((entries) => {
      entries.forEach((entry) => {
        console.log(1)
        console.log(entry)
        if (entry.isIntersecting) {
          console.log(2)
          entry.target.classList.add("show")
        } else {
          console.log(3)
          entry.target.classList.remove("show")
        }
      });
    });

    const hiddenElements = document.querySelectorAll(".toanimate")
    hiddenElements.forEach((element) => observer.observe(element));

    return () => {
      hiddenElements.forEach((element) => observer.unobserve(element));
    }
  }, []);

But this doesn't work and it probably is because the observer is being fired before my element actually exists. One way I can solve this is by using the useRef hook but then I'd have to make about 50 useRefs per page to animate everything, does anyone have a better solution?

tulip ledge
edgy lily
#

hi

#

me developer bro

radiant kraken
#

omg he is a developer guys

#

😱

next storm
#

how to get my pc's port number for topgg webhooks 😂

earnest phoenix
earnest phoenix
fervent moss
#

Well does someone know tho... I figured out how to use pug to load files with parmaeters recived from express app but the css doesn't load up. I will need lots of help in pug itself. If someone is free freerealestate

real leaf
earnest phoenix
#

holy smokes

#

Does that mean I can get a super duper insane secret badge

deft wolf
#

I want a very secret badge too pogey

earnest phoenix
#

activedevactivedev🔥

swift lynx
#

people just started to make bots just to get the badge

real leaf
#

Yes

swift lynx
#

Is there a way to change the banner colour for your bot?

#

ig not

crystal wigeon
#

Hey for app directory I emailed discord after fixing the issues they haven’t replied yet

shell echoBOT
earnest phoenix
#

Also from what I heard most of the employees are in holidays now, so it will most likely take long to get a response, up to some weeks

#

I still haven't gotten any response after 3 months for a general question, that should tell you how good their support is..

#

lol

#

2 days ago i asked about issue with my servers custom invite and they fixed it the next day, and my bot got verified after applying only 3 hours before

#

discord support fast for me

slender wagon
#

how can i use frameborder="0"
for some reason it doesn't recognize frameborder

NextJs question

slender wagon
#

that did it

#
.modal_container {
  background-color: rgba(0, 0, 0, 0.7);
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

.modal_container.show_modal {
  display: block;
}

also the script that i made adds the show_modal class name to the div but for some reason is not updating the display

#
class="Home_modal_container__CazAv show_modal"

here is the div's class after i click the show modal button

#

it adds the classname

#

but doesn't update the css

neon leaf
#

does anyone know why this in my nginx http block
error_page 404 /etc/nginx/pages/404.html;
isnt sending the custom 404 page?

carmine summit
#

how many choices can I put inside a slash command argument?

carmine summit
# deft wolf

I'm interested on this, where can I learn more about it

deft wolf
quartz kindle
#

lmao the discord docs now have snowflakes raining down? since when hahah

earnest phoenix
#

I instantly disabled that horrible thing

quartz kindle
#

hahahah

carmine summit
#

just tried autocomplete, pretty good ngl

#

tho I don't know why .respond() expects an array, but .addChoices() doesn't

still stone
#

TIM!

deft wolf
earnest phoenix
#

d.js consistency moment

radiant kraken
#

@earnest phoenix wait do they actually parse these comments

#

@earnest phoenix should i go dynamic or static lib

earnest phoenix
#

I'd go dynamic

radiant kraken
#

how do you convert a Go string to a UTF-8 []byte without copying it

earnest phoenix
#

You mean without doing

x := "Hello world"
y := []byte(x)

?

radiant kraken
#

do Go strings use UTF-8?

earnest phoenix
#

Yeah

#

At least if I remember correctly

#

Would make sense that it's the default

radiant kraken
#

then how do i convert Go strings to UTF-8 byte arrays without copying?

earnest phoenix
#

You don't?

wheat mesa
#

Yeah that doesn't make too much sense from a garbage-collected language standpoint

radiant kraken
#

oh

earnest phoenix
#

Yeah

lament rock
#

gc langs will always be damned to copy operations

radiant kraken
#

alright then

#

i forgot that go is garbage collected

earnest phoenix
#

Rust isn't right?

Rust does not use a garbage collector, but rather achieves these properties through a sophisticated, but complex, type system.
Google says that and sometimes that it is garbage collected

lament rock
#

write your own interpreter in c to allow for manual memory management

lament rock
radiant kraken
#

Rust is not garbage collected

earnest phoenix
#

okeh

lament rock
#

My mind is garbage collected tho

earnest phoenix
#

But C is /s

lament rock
#

I forgot what I ate yesterday

wheat mesa
#

Yeah rust isn't because of ownership semantics

radiant kraken
#

My mind is garbage

lament rock
#

Time to collect

earnest phoenix
#

Yeah mine as well

#

I literally made an event dispatcher library for my project

#

I end up not using it keka

lament rock
#

the pause might be a while, but you'll be back to normal assuming no leak

earnest phoenix
#

👀

#

And my first attempt was, well, golden

radiant kraken
#

hi Voltrex

radiant kraken
#

ok so i have this Rust project that can compile into native DLLs

#

how would i make a Go library around it

lament rock
#

can go even import native libs

radiant kraken
#

yes

#

not sure about third-party C libraries tho

lament rock
#

Then just do that :)

radiant kraken
#

i mean when making a C library you have to handle lots of OSes and Architectures

lament rock
#

Unless what you're doing is generic enough

radiant kraken
#

ok so how would i do this

#

do i store precompiled binaries?

#

or does go have a custom makefile system or smth so that it runs when you install it

quartz kindle
# neon leaf ?

error_page in the http block only works for absolute http urls

#

otherwise error_page's path is based on the root directive of the current server block

neon leaf
quartz kindle
#
server {
    location = /404.html {
        root /var/www/default;
    }

    error_page 404 /404.html;
}
``` something like this
neon leaf
#

would that be global?

quartz kindle
#

it will affect only the current server block

neon leaf
#

is there any way to make it global?

quartz kindle
#

you can try making a redirect

#
http {
  error_page 404 http://yourwebsite.com/error.html;

  server {
    location = /error.html {
      root /path/to/file.html
    }
  }
}
#

but you still need to change the root on the main server block for that domain

#

you can also try defining a default root, not sure if it will work but try it

http {
  root /path/to/nginx;
  error_page 404 /error.html;
}
granite trout
#

anyone know how to make this?

deft wolf
#

I'm pretty sure you need the command id

quartz kindle
granite trout
#

bot id?

quartz kindle
#

command id

granite trout
#

oh okay ty

neon leaf
#

oof, doesnt seem to work; do you know if caddy isnt so weird?

quartz kindle
#

never used caddy

tulip ledge
#

anyone got an idea why my index isn't incrementing?

  const [index, setIndex] = useState(0);

  useEffect(() => {
    const introInterval = setInterval(() => {
      setIndex(i => i + 1);
      console.log(index)
    }, 500);

    setTimeout(() => {
      setIntroFinished(true);
      clearInterval(introInterval);
    }, 4000);
  }, []);
tulip ledge
uneven tartan
#

help

#

i require multiple file paths

solemn latch
uneven tartan
#

eww multiple loops

#

i was thinking something like this

#
const command=require(`./slashCmds/*/${ file }`); // * is different command categories, not sure if thats valid in file paths
client.SlashCommands.set(command.data.name, command)```
earnest phoenix
#

What you're looking for is recursion

uneven tartan
#

he typing a paragraph oh no

earnest phoenix
#

You can also use globs but if you can just use recursion

Function:

  • Read from directory
  • Loop over the entries of the directory
    • Join the paths, previous path + the current entry
      • If it's a directory, go to Function
      • Otherwise load the command

And pass the commands directory to the function

uneven tartan
#

i wanna try n use globals but

#
  • is not valid
earnest phoenix
#

Because that's a glob pattern

sudden geyser
#
for (const cat of require(...)) {
  for (const file of require(...)) {
    // Pow.
  }
}
#

use cat to draw path

earnest phoenix
#

@uneven tartan

import { readdirSync } from 'node:fs';
import { join } from 'node:path';
import { pathToFileURL } from 'node:url';

// Declare function for recursion.
async function loadCommands(dir) {
  // Read entries from the given directory.
  const entries = readdirSync(dir, { withFileTypes: true });

  // Iterate over the directory entries.
  for (const entry of entries) {
    // Join paths.
    const path = join(dir, entry.name);

    // If the entry is a directory, recurse.
    if (entry.isDirectory()) await loadCommands(path);
    // Otherwise, if the entry is a regular JavaScript file, load it.
    else if (
      entry.isFile() &&                                                                (entry.name.endsWith('.js') || entry.name.endsWith('.mjs'))
    ) {
      // Import command.
      const { default: command } = await import(                                         // Convert the path to a file URL, this is needed on platforms like Windows where the hard drives have drive letters like 'C://', acting as file URLs.
        pathToFileURL(path)
      );

      // Load command in whatever way you want.
    }
  }
}
#

You can of course also do this in CommonJS, just use the global require() function to import, and no need to convert the path to a file URL as it doesn't need to be a file URL with require()

uneven tartan
#

dir is

#

./

earnest phoenix
#

The thing you should pass to that function is the path to the commands directory

cursive musk
#

Stupid question. I got this npm package I'm using in my .js files:

japiRest.discord
.getApplication("1018001748020961311")
.then((user) => console.log(user.data.bot.approximate_guild_count));

Is there any way to use it in a .ejs file?

uneven tartan
#

everything is in a folder under that

#

so like

#

/commands/moderation
/commands/music

earnest phoenix
#

Yes, exactly

uneven tartan
#

and the return from that function is passed to the collection

#

or should i just do that inside the function

quartz kindle
#

not directly inside an ejs file

cursive musk
#

THAT CLEARS SO MUCH

#

THANK YOU

flat copper
#

how do i store input image in mongo without creating file in my server?

earnest phoenix
#

why

#

just make a cdn

radiant kraken
#

this looks so cursed omg

earnest phoenix
#

Is that generated?

radiant kraken
#

idk if i should return pointers or values when returning structs

earnest phoenix
#

Pointers

#

But shouldn't write it like that

#

You can just

return &person{}

with the fields in it

radiant kraken
earnest phoenix
#

You should work with pointers whenever you can

#

Also NewXXX should return a new pointer

radiant kraken
#

oh alright

earnest phoenix
#

Especially for custom structures

radiant kraken
#

have you ever worked with cgo before?

earnest phoenix
#

The good thing is that Go will auto dereference structures, so if you print the returned value you won't see the memory address. It will act just like a normal pointer, simply made better to prevent the hassle of having to use, for example, (*p).name to print the name, instead you can just use p.name which is much more convenient

earnest phoenix
sharp geyser
#

oh you guys are using go

#

fun

#

I miss using go

radiant kraken
#

last time i used go was last year

sharp geyser
#

Same here

earnest phoenix
#

Last time I used Go was yesterday evening trollStare

sharp geyser
#

why

earnest phoenix
radiant kraken
#

sob

sharp geyser
#

Whats the point of it

radiant kraken
#

how do i integrate a Rust project into a Go library

sharp geyser
#

you dont

earnest phoenix
#

Probably can't

radiant kraken
#

oh alright then

earnest phoenix
#

At least never heard of it

radiant kraken
#

ok so

#

can you include a binary file's contents in a go constant in compile-time

radiant kraken
#

you know what i'll just make a java wrapper instead, i'll do go later

earnest phoenix
#

Java pain

radiant kraken
#

im sorry, one of my friends use java and wanted to use the library

earnest phoenix
radiant kraken
#

i cant believe im installing java again

radiant kraken
earnest phoenix
#

j*va

#

yikes

#

<insert non-existent js mascot pensive>

sudden geyser
#

3 billion devices

#

or how much does it say now

earnest phoenix
#

still 3b

radiant kraken
#

imagine not having a mascot

earnest phoenix
#

cope deez nuts into your mouth

#

cring

#

I'd uninstall any language without mascot

radiant kraken
#

so true

earnest phoenix
radiant kraken
#

shrug

earnest phoenix
#

That blue line color tells me it's TS

#

Yet another language without mascot

#

Cancelled

radiant kraken
#

nah its Python

earnest phoenix
#

its so good

#

Python also has no mascot

#

Yet another one

radiant kraken
#

LMAO it really is Python

earnest phoenix
#

Cancelled

radiant kraken
#

Rust tho

earnest phoenix
radiant kraken
#

whats the name of go's mascot

#

is it just gopher

earnest phoenix
#

gonna need to ask that nerd who knows ai stuff in team

#

Yepa

#

There's also an amazing talk at a conference

#

wait

radiant kraken
#

i would use go if it can work with rust projects

earnest phoenix
#

I would use Rust it it can work with Go projects CatJAM

radiant kraken
#

it can

#

it can work with C so

earnest phoenix
#

Go can work with C as well

#

I'll see if I can make a Rust wrapper for my library CS_pepehmm

radiant kraken
#

but how do you make a Go wrapper of a C library

earnest phoenix
#

Without coding in Rust obviously

earnest phoenix
radiant kraken
#

never made a go library before

earnest phoenix
#

But you're probably not the only one trying that

#

So Google may have an answer to it

#

Anyways heading out, arriving at uni

radiant kraken
#

cya

carmine summit
#

how is interaction.deferReply() different from interaction.reply()?

radiant kraken
#

deferReply shows a <botname> is thinking... message beforehand afaik

carmine summit
#

oh you can't put message inside deferReply

sharp geyser
#

deferReply is basically telling discord you will do something at a later time keep the interaction going