#development

1 messages · Page 1990 of 1

earnest phoenix
#

yea I fixed that but now its bugging out cause there is no extension on file names when importing a file

#

when it compiles down it compiles down to the same import statement but js wants there to be a .js at the end

cobalt junco
earnest phoenix
#

yea

#

but typescript compiles it down without a file extension

#

so it fucks imports up

cobalt junco
#

Use --experimental-specifier-resolution=node flag

earnest phoenix
#

unknown compiler option

cobalt junco
earnest phoenix
#

"start": "tsc --experimental-specifier-resolution=node && node ." assuming you mean this by start script

cobalt junco
earnest phoenix
#

Oh I see

#

Thanks

#

Kinda dumb that you need to do that

#

😔

cobalt junco
cobalt junco
daring cedar
#

Guys what permission is required by the bot to change channel perms ?

austere surge
#

probably MANAGE_CHANNELS

daring cedar
#

I gave that but it is still not changing the perms :/

austere surge
#

does it have it for the specific channel

daring cedar
#

Yes

#

So like it is supposed to disable sending messges for everyone in the channel the command is used

#

But it does not change it

#

(it did work when I was lazy and gave it admin)

austere surge
#

odd

daring cedar
#

Yeah....

#

I think it needs manage server :/

#

Idk

#

Still does not work oof

sacred aurora
#

does anyone know how to write optional chaining with array?
something like this

someArray[0]?.something
#

or is it impossible to do that

old cliff
#

It should work

sacred aurora
#

nope it didn't work

old cliff
#

Js version?

sacred aurora
#

how do i check

old cliff
#

node -v

sacred aurora
#

v16.10.0

old cliff
#

Do you mean to do js someArr?.[0]?.someValue?

sacred aurora
#

the array is always exist

#

but the element inside of it

sacred aurora
#

oh wait a sec

#

its because of prettier that it didn't work

#

bruh

old cliff
#

Which ide?

sacred aurora
#

it format like

array[0]?
  .something
#

vs code

old cliff
#

Uninstall js formatters and use the default code formatter

sacred aurora
#

maybe because of long key

#

mhmm

fiery stream
#

is it a good idea to make bot as a module ??

earnest phoenix
#

I dont see why not then again I am dumb

#

:^)

green pebble
#

sounds cool tho

fiery stream
#

how you extend class in js n so on

#

in other langs

earnest phoenix
#

ofc you can use classes to make a bot

green pebble
fiery stream
earnest phoenix
#

It is what I do all the time

green pebble
#

i thought both discord.py and js actualy used classes for stuff like commands?

fiery stream
#

do you use class to make the bot or like class to make submodules for it?

earnest phoenix
#

if you are using discord.js you can extend the Client class and add your ow nstuff to it and just make a new instance of that class and still login

#

so yes

#

you can

fiery stream
#

nope ik what you talking about but im using py

green pebble
earnest phoenix
#

Oh as for py then idk

bright thorn
#

how to count all guilds from all shard

earnest phoenix
#

you never specified what language you're using

fiery stream
#

yuh its py lol forget about that can anyone help me run webserver along side the bot in py

bright thorn
green pebble
bright thorn
#

in js

green pebble
#

oh idk

bright thorn
#

from alll shards?

fiery stream
green pebble
green pebble
fiery stream
green pebble
#

like the standard thing you do with replit keep alive lmao

lament rock
#

a bot's code base shouldn't be a node_module

#

They're not really extensible like a library is

green pebble
fiery stream
# green pebble uh..... 🤔 elaborate pls
                ):
                    raise

    loop = asyncio.get_event_loop()
    loop.run_until_complete(bot.run())
    asyncio.create_task(webserver.run(bot))
    #bot.run()

if __name__ == '__main__':
    main()``` this is what i basically got n yuhh it doesnt work lol
#

thats all i know if the bot is above the webserver then the bot works n if the webserver code is above thebot then the bot doesnt work

green pebble
#

jus a min

fiery stream
#

alrighh

green pebble
lament rock
#

Pretty sure trying to loop your run method will get your token reset if it tries to login a bunch of times

green pebble
fiery stream
#

intresting

#

n does it like idk how ot word it

#

like if the bot is sharded multiple times does it conflict with the port

lament rock
#

a web server should be running on a thread independent of forking. Bots don't claim ports like a webserver would

dry imp
#

is that replit?

green pebble
dry imp
#

noone wants to attack you

green pebble
#

Oh.. I jus had some flashbacks lmao... They would hate this method... In a server of my friend

#

😅

dry imp
#

i thought replit doesnt have a dark mode

lament rock
#

Your example seems pretty clean imo

green pebble
dry imp
#

topggSunglasses i dont code in replit

green pebble
fiery stream
earnest phoenix
#

The website you are using to write the code

fiery stream
#

no wait its Quart

green pebble
fiery stream
#

ohh vscode lol

#

n use glitch to host 😎

dry imp
#

nice host

green pebble
#

wait what

#

glitch? damn

fiery stream
#

yep lol

dry imp
#

best host

slender thistle
green pebble
#

bestest host

green pebble
fiery stream
slender thistle
#

Yeah nah chief if you run Flask and Discord.py on the same thread you're gonna have issues

green pebble
fiery stream
#

just make a .sh file n type

#

n it downloads pip reqs using pip2 so you have to install pip3 reqs using terminal

green pebble
#

oh.. didnt know these when i had tried glitch

#

uh

fiery stream
bright hornet
#

is there any module that the vote can track from top.gg or any other vote sites?

green pebble
fiery stream
#

does replit support custom domains ?

green pebble
fiery stream
#

its way better than glitch...

fleet cargo
#

@modern sable DM's

green pebble
fiery stream
#

having a problem using env varibles on it tho lul

green pebble
fiery stream
#

yeahh ik i added the token there but still doesnt work

green pebble
green pebble
fiery stream
#

i had it like that

#

either way imma rewrite my whole bot on this

#

i didnt like the way it was written

lucid prawn
#

channel.guild.fetchOwner(user.tag) or channel.guild.fetchOwner.user.tag

earnest phoenix
#
CREATE TABLE IF NOT EXISTS Users (
  id text NOT NULL PRIMARY KEY,
  balance bigint DEFAULT 0,
  itemsId INT FOREIGN KEY REFERENCES Items(itemId)
)
        
CREATE TABLE IF NOT EXISTS Items (
  itemId SERIAL PRIMARY KEY,
  name varchar(21) NOT NULL,
  description varchar(150),
  value bigint DEFAULT 10,
  rarity text NOT NULL
)

I can't remember if this is correct or not, but is this is how you make a one to many relation where a user can have multiple items but an item can only belong to one user?

#

well I am obv doing smth wrong

#

error: syntax error at or near "FOREIGN"

#

@quartz kindle @cinder patio React performance skill issue: The setState function in hooks changes on every rerender so if a child depends on it the child would rerender on every state change
https://paste.gg/p/anonymous/fb351970794f48a69667e84b04d8b54e
Press the button and it will always log Child updated

cinder patio
#

instead of passing the function directly

earnest phoenix
#

column "itemid" referenced in foreign key constraint does not exist I get this error for some reason even though I am creating the table before trying to make a reference to it

#
        CREATE TABLE IF NOT EXISTS Items (
            itemId SERIAL PRIMARY KEY,
            name varchar(21) NOT NULL,
            description varchar(150),
            value bigint DEFAULT 10,
            rarity text NOT NULL
        );
        
        CREATE TABLE IF NOT EXISTS Users (
            id text NOT NULL PRIMARY KEY,
            balance bigint DEFAULT 0,
            CONSTRAINT fk_item
            FOREIGN KEY(itemId)
            REFERENCES Items(itemId)
        );
marble juniper
#

never worked with foreign keys so idk

#

can't help you

earnest phoenix
#

FUCK

#

😔

earnest phoenix
#

what if we memoize the function?

fiery stream
#

help pls

green pebble
fiery stream
#

just discordpy

#

thats the code...

eternal osprey
#

hey how do i write this json file: {"q4Bav":{"question":"test","type":[3],"good":"test2","wrong1":"test4","wrong2":"test4","emoji1":"🟢","emoji2":"🔴","emoji3":"🗑️","answer1":[],"answer2":[],"answer3":["345138133429649408"],"time1":[],"time2":[],"time3":[1646044962001],"postid":"947805981310595112"}}to an excel file using js?

split hazel
#

you need some excel library

earnest phoenix
pearl trail
#

excel.db

onyx socket
#

Can one bot read other bots' messages if it doesn't have message content intent..

earnest phoenix
onyx socket
#

Sigh

#

Thanks for the info

lyric mountain
lyric mountain
#

just transform keys into columns

woeful pike
#

I made this repo 5 mins ago

earnest phoenix
#

the weebs are stalking you

woeful pike
#

there are so many bots out there doing this??

earnest phoenix
#

kpop

woeful pike
#

this is chinese

boreal iron
#

@woeful pike you got an idea for this?

woeful pike
#

idk

boreal iron
earnest phoenix
sudden geyser
neat ingot
woeful pike
#

it's a vulnerability report for some dependency

neat ingot
#

although the two pages do seem to have a LOT of identical content

woeful pike
#

those are the bots that do it

#

except you can't really do this because most vulnerability reports are not meant to be disclosed publicly like this

#

it's a cool idea but can be harmful

daring cedar
#

Hey guys I have given manage channels perms to the bot but it still can't change the channel's perms.

#

What should I try now ?

neat ingot
#

i honestly dont get what that is supposed to do. like, i translated the description and such, but yea, totally went over my ehad lol

boreal iron
lyric mountain
#

so giving manage channels perm doesn't mean you can give any permission

daring cedar
#

I meant in the discord dev portal

lyric mountain
#

...I keep my statement

#

the permissions at dev portal are only to build an invite

#

they don't give them to your bot everywhere

#

and even then, the bot can only give permissions it has

daring cedar
#

Um you did not understand what I was asking, nvm I got the right one 😓

desert roost
quartz kindle
#

wat

#

there is no such thing

lyric mountain
#

tts is client-side, you have no control over it

quartz kindle
#

tts voice is defined by your pc's language

desert roost
#

oh okay

whole glen
#

when i try using let membercountss = member.guild.memberCount console.log(membercountss) member.guild.channels.cache.get('856652240550625290').setName('Members:' + membercountss) nothing happens to the name of channel but the name changes if i take away the memercountss and i get the member count in the console

#

discord.js

#

nvm this fixed it `Members: ${membercountss}`

wooden ember
#

and today on "random things i found on github" we have:

#

can i just get confermation on the fact that none of that even does anything?

atomic kindle
#

This one does.

wooden ember
#

like the ones that just go => { } dont do anything

atomic kindle
#

These too. joystroke

wooden ember
#

oh bruh i wrote none

#

i meant most of them dont do anything

#

brain moment

earnest phoenix
wooden ember
#

hahaha

#

you know whats worce? thats only half of it

#

theres pretty much one for every event

fiery stream
#

Hey im writing this bot https://github.com/oxy/Nest/blob/master/nest/client.py n orginally in this bot the function was in a class and im not using class to make this bot can anybody help me fix it 🙂

wooden ember
#

bruh

fiery stream
fiery stream
wooden ember
#

i dont know much about python sadly

fiery stream
#

thats alright

fiery stream
sick agate
#

idk?

#

probably not

#

for bot cogs

surreal sage
#

This is a hard one but alright.
Language is JavaScript

I have a forEach
Each forEach needs to send a get request, but that would rateLimit it and break it.
So I want a interval between each get request and the response would be sent back
Kinda like this: (Green is 5 seconds after Red)

earnest phoenix
#

Use a recursive function instead of a for loop

surreal sage
#

Ah thanks

earnest phoenix
#
async function loop(index) {
     await array[index].doSomething();
     if (array.length === index + 1) return;
     loop(index + 1);
}
await loop(0);
surreal sage
#

Had a bit different in my head but this is better yeah

earnest phoenix
#

@oak cliff is this considered spoonfeeding?

#

because if it is i don't care

oak cliff
#

eh

surreal sage
#

And google xD

cinder patio
#

or even better, you could use a single set interval

#
let ind = 0;
const interval = setInterval(async () => {
    // Check if ind == array.length, if so use clearInterval
    // Do ur work
    ind++
}, 5000);
woeful pike
#

recursion good

boreal iron
quartz kindle
#

recursion is good when you dont know the exact number of loops you're gonna need

sudden geyser
#

Or just a while

#

But recursion is hotter

quartz kindle
#

there are cases where a while doesnt cut it

#

for example recursion inside recursion

#

like for transversing objects with unknown depth

sudden geyser
#

No, a while should be able to do it

#

Can't see how it couldn't

quartz kindle
#

try making an object cloner with a while loop

#

its not impossible, but you will need some form of code reusability

sudden geyser
#

I think where while is harder to use is when you need to maintain some state of what's happened

#

That's where recursion has a leg up since it feels a lot more natural and simpler than a while

#

Which is where code reuse comes in

quartz kindle
#

yeah

#

like transversing objects

#

you need some sort of state to know which depth you are at or something

#

and if you're checking value types for properties, you wanna be able to reuse the type checking code

cinder patio
#

Recursion can always be done imperatively, not saying it's always better tho yeah

quartz kindle
#

if your lang supports goto

#

xD

#

i mean

#

fn1 calling fn2 which calls fn1 is pretty much the same as recursion

cinder patio
#

I mean with just loops

#

for and while

quartz kindle
#

how are you gonna reuse code without a function somewhere?

sudden geyser
#

Call them procedures coolyuno

quartz kindle
#

but like

#

with an object of unknown depth

#

how are you going to make just enough loops to the right depth

cinder patio
#
let child = obj;
while (child) {
  child = child.something;
  // do something
}
quartz kindle
#

make 100 loops and break once it runs out of depth?

quartz kindle
#

one slight issue tho

#

you're basically keeping a single level of state, which makes it difficult to go back to

sudden geyser
#

Yes but now you can only walk top down into the thing

cinder patio
#

you could always store all parents in an array

sudden geyser
#

Can't walk back down top like you can with recursion

quartz kindle
#

for example an object like this {a:10, b: {c:20}, d:10}, once you set the child to object c, how will you do back to the main object to parse prop d

sudden geyser
#

It probably relies on mutation so it doesn't need to get the parent

lament rock
#

There's Array.flat. But what about Object.flat

woeful pike
#

oh you mean without recursion?

cinder patio
#
const properties = []; // A list of all properties inside an object (and nested objects)
const parents = [obj];
while (parents.length) {
    for (const prop in parents[parents.length - 1]) {
        const parent = parents[parents.length - 1][prop];
        // Doesn't account for arrays
       if (typeof parent === "object") parents.push(parent);
       properties.push(prop);
    }
  parents.shift();
}

Would work, I think. Obviously in this case recursion is better, but still, possible with imperative.

sudden geyser
#

Looks painful

woeful pike
#

typical recursion hater

cinder patio
#

I love recursion

#

I swear

quartz kindle
#

yeah that would probably work

#

if you want pure performance though, 100 loops inside each other would probably beat everything else

#

provided the object will never have a depth of over 100 lmao

wheat mesa
#

I’ve never used all that much recursion until diving into parsers and interpreters, now it’s an essential piece of life for those things

sudden geyser
#

Or any sort of list processor

#

The sum of a set of numbers?

#

Would prefer recursion over for/while any day of the year

wheat mesa
#

I would say the same except for when it’s poorly defined recursion. Recursion that’s poorly written makes it really difficult to follow along with what the program is actually doing

#

Recursion is overcomplicating it for simple loops as well

earnest phoenix
#

@quartz kindle does Object.is return true if you compare functions that are completely same but totally different references

#

because maybe that's maybe what causing unnecessary rerenders in my react component

split hazel
#

whats the point of that function

earnest phoenix
split hazel
#

i dont know too much about react i only sometimes do things in it

woeful pike
#

iirc Object.is behaves differently with -0 but that's about it

novel jetty
woeful pike
#

if options.getSubCommand isn't a function then options isn't what you think it is. Go find out by logging it

wheat mesa
#

js is case sensitive, make sure to read the docs on the function names

simple stump
#

What's the function for autocomplete: true?

new SlashCommandBuilder().setName('info').setDescription('Gets the info of an user.').setDefaultPermission(false).addSubcommand(subcommand => subcommand.setName("user").setDescription("The user to get info on.").addUserOption(option => option.setName('target').setDescription('Select an user').setRequired(true))),

I've tried:

new SlashCommandBuilder().setName('info').setDescription('...').addSubcommand(subcommand => subcommand.setName("...").setDescription("...").addUserOption(option => option ... .setAutocomplete("true"));

But that throws an error saying it isn't a function.

#

Attempting to implement autocomplete for slash commands.

ancient nova
#

can anyone help me with something that is completely not related to discord bots, but it's using node.js or is that not allowed?

lament rock
#

Any dev talk is allowed

#

just ask

ancient nova
#

great

#
        if (commandArray.indexOf(answer) > -1 && customCommandArray.indexOf(answer.replace('-','')) > -1) { 
            require(`./customcommands/${answer.replace('-','')}.js`);
            return recursiveAsyncReadLine();
        }

I'm making a custom script execution for my program
and I'm trying to execute the command using the require() function
but the problem is it only executes once
https://media.discordapp.net/attachments/288498150145261568/947939448438554654/unknown.png
if it helps I search for files using

var availableCommandsArray = require('fs').readdirSync('./customcommands/');
``` then iterate though it and list everything
#

it's so annoying I cannot find a fix for it

#

nothing online either

cinder patio
#

Everything you require gets cached

ancient nova
#

so that means I can't execute it multiple times?

#

what else can I use though?

cinder patio
#

you could read the file and run it with eval

coral sigil
cinder patio
#

or a Worker, but that's more resource intensive

ancient nova
#

can you give me an example?

#

also would eval not pose any ability to break the program?

lament rock
#

eval runs a string of code, so if the code works, then eval will work most likely

cinder patio
#

in your case require does the same thing as eval - you don't need any exports from the file, you only want to run it

ancient nova
#

that's right, and if possible I need it to keep within the program, so any new window is not opened

lament rock
#

eval will work

ancient nova
#

I don't know what to put inside the eval though

#

I didn't use that function for a while but I doubt just putting the directory will work

cinder patio
#
const fs = require("fs");
const file = fs.readFileSync("./file.js", "utf-8");
eval(file);

Is one way to do it. Though perhaps you may want to use Workers instead, at least I would. Or maybe you could spawn the script as a child process

ancient nova
#
require('child_process').exec(`node ./customcommands/${answer.replace('-','')}.js`);
``` didn't do anything
simple stump
ancient nova
#

perhaps workers could work, though I have no idea how to use it as I've never tried it before

simple stump
#

i forgot i had .setAutocomplete afterwards for some reason?? anyways ty

ancient nova
#

hello?

quartz kindle
simple stump
#

How do you utilize autocomplete? I have this code:

let choices = [];
con.query(`SELECT name FROM rbridge WHERE name like CONCAT("%", ?, "%") LIMIT 10`, (err, rows) => {
  if (rows.length < 1) {
    return;
  } else {
    interaction.respond([
      {
        name: rows[0].name,
        value: rows[0].name,
      },
      {
        name: rows[1].name,
        value: rows[1].name,
      },
      {
        name: rows[2].name,
        value: rows[2].name,
      },
    ]).then(console.log).catch((err) => console.error(err));
    }
});

But I'm not sure where to put it

boreal iron
#

my gosh... bid wars have been brutal today

boreal iron
simple stump
#

But yeah I should. I was gonna loop through but I just have it set to 3 options for testing atm.

boreal iron
#

If you just want to show 3 options then set your query limit to 3, too

#

Why is it 10 then?

simple stump
#

ill have a loop that displays the 10 options. ik its super redudant not looping thru i just have it set for that for the sake of making debugging easier

boreal iron
#

Your interaction resonse just shows 3 rows ?!

#

Not 10

#

No need to have a query limit for 10 rows when you just show 3

simple stump
#

yea ik it shows:

              {
                name: rows[0].name,
                value: rows[0].name,
              },
              {
                name: rows[1].name,
                value: rows[1].name,
              },
              {
                name: rows[2].name,
                value: rows[2].name,
              },

i just have that for testing atm

boreal iron
#

Create a loop for them

simple stump
#

i just added those lines cause idk how to display the options for autocomplete yet

#

ik im doin that rn

boreal iron
#

And set the limt you wanna show using the SQL LIMIT

sudden geyser
#

fake

#

they're doing it for debugging

#

looping and limits can come later

simple stump
simple stump
#
con.query(`SELECT name FROM rbridge WHERE name like CONCAT("%", ?, "%") LIMIT 10`, (err, rows) => {
          if (rows.length < 1) {
            return;
          } else {
            for (var i = 0; i < 10; i++) {
              interaction.respond([
                {
                  name: rows[i].name,
                  value: rows[i].name,
                },
              ]).then(console.log).catch((err) => console.error(err));
            }
          }
        });

loop

sudden geyser
#

to me it looks correct, assuming rows[x].name is a number and string and that .name isn't over 100 characters

boreal iron
#

omg no

sudden geyser
#

no that's wrong

#

that'll send the interaction response 10 times

#

which is not what you want to do

simple stump
sudden geyser
#

What you actually want is this:

rows.map((row) => ({
  name: row.name,
  value: row.name;
}));
simple stump
#

oh i see. tysm

sudden geyser
#

Or even

rows.map(({ name }) => ({
  name: name,
  value: name;
}));
boreal iron
#

Eww map

#
con.query(`SELECT name FROM rbridge WHERE name like CONCAT("%", ?, "%") LIMIT 10`, (err, rows) =>
{
    if(!rows.length < 1) return;
    
    let options = [];
    
    for(let i = 0; i < rows.length; i++) options.push({ name: rows[i].name.toString(), value: rows[i].name.toString() });
    
    interaction.respond([options]).then(console.log).catch((err) => console.error(err));
});
sudden geyser
#

that's disgusting

boreal iron
#

I prefer an human readable solution

sudden geyser
#

I'd argue that's less readable

#

Very imperative and step by step

#

as opposed to the declarative .map use

boreal iron
#

Shhh nobody likes map()

simple stump
#

tysm this is super helpful. how do u display the options for autocomplete tho? i do understand that u have to use interaction.respond in the interactionCreate event, but is there a method for like .isAutocomplete() or smth?

boreal iron
#

You need to respond to your autocomplete interaction.

#

There's indeed a method to indentify an autocomplete interaction

simple stump
#

ty

sudden geyser
#

Well, interactionCreate takes an Interaction object, and Discord.js has an Autocompleteinteraction type, so you probably do need to check with .isAutocomplete() just to make sure.

simple stump
#

okay. tysm

boreal iron
#

You can also check the interaction.type

#

just to say

#

Which is what djs internally does

simple stump
#

👍

#

feel bad for asking again but uh im getting the error that interaction.isAutocomplete() isnt a function.

client.on("interactionCreate", async (interaction) => {
  if (interaction.isAutocomplete()) {
    // do smth
  }
});
if (interaction.isAutocomplete()) {
                  ^

TypeError: interaction.isAutocomplete is not a function
    at Client.<anonymous> (/home/container/index.js:480:19)
sudden geyser
#

That's weird. It looks correct.

#

May I ask what version of Discord.js you're using

simple stump
#

yep v13

boreal iron
#

Make sure you're on 13.6.*

simple stump
#

ah. that might be the issue. ill reinstall djs

#

yea was using 13.1 lol

#

whooops

#

Yeah it doesn't throw any errors. For some reason though the options still don't appear.

boreal iron
#

Do they appear in your console log?

simple stump
#
if (interaction.isAutocomplete()) {
    console.log("test");
}

The event gets fired fine, but the options are still empty.

  if (interaction.isAutocomplete()) {
    console.log("test");
    let choices = [];
    con.query(`SELECT name FROM rbridge WHERE name like ` + "a" + ` LIMIT 10`, (err, rows) => {
      if (!rows) return;
        if(!rows.length < 1) return;

        let options = [];

        for(let i = 0; i < rows.length; i++) options.push({ name: rows[i].name.toString(), value: rows[i].name.toString() });

        interaction.respond([options]).then(console.log).catch((err) => console.error(err));
    });
  }
boreal iron
#

I mean you didn’t enter anything

simple stump
#

yea i would type "a" or "aseihrhawehoir" and nothing would appear. when sending the cmd "test" gets logged as expected.

boreal iron
#

And you’re sure the query even has results?

#

Console log your rows before sending the response

simple stump
#

oops. it is undefined lmao. mb

#

ty for the help

boreal iron
#

Well I didn’t change your query

#

You should replace the value you’re searching with "a"

sudden geyser
#

It's probably because of that .respond

#

options is an array yet you're wrapping it in array

#

So what you got is [[{...}, {...}]]

#

Aka replace [options] for options

boreal iron
#

Ah yikes nice typo

sudden geyser
#

also how about the .map instead of the for kumikosmug

boreal iron
#

Yeah I didn’t remove the brackets

pale oasis
#

I love my spelling.

sudden geyser
#

like, come on. would you rather interpret this:

rows.map(({ name }) => ({
  name: name,
  value: name;
}));

Or this:

let options = [];
    
for(let i = 0; i < rows.length; i++) options.push({ name: rows[i].name.toString(), value: rows[i].name.toString() });

Simple is better. :)

boreal iron
#

I mean everybody is free to adjust it of course

pale oasis
#

Just more easily readable with the whitespace.

sudden geyser
#

simple means one objective/task. like one braid

boreal iron
#

Thats efficient but not simple

sudden geyser
#

your for loop has many objectives: create some value, check if it's still valid, increment, and use that value with other variables that still exist in your program

simple stump
sudden geyser
#

your for loop has many braids

simple stump
#
  if (interaction.isAutocomplete()) {
    console.log(interaction.command);
    let choices = [];
    con.query(`SELECT name FROM rbridge WHERE name like 'a%' LIMIT 10`, (err, rows) => {
      if (err) console.log("err: " + err);
      if (!rows) return;
      if(!rows.length < 1) return;

      let options = [];

      for(let i = 0; i < rows.length; i++) options.push({ name: rows[i].name.toString(), value: rows[i].name.toString() });

      interaction.respond(options).then(console.log).catch((err) => console.error(err));
    });
  }

That's what I currently have atm

boreal iron
#

Code examples are usually more detailed and less compressed

sudden geyser
boreal iron
#

Doesn’t mean he just has to copy and paste it

simple stump
simple stump
#

mostly because ive worked w/ for loops a bit more than map

boreal iron
#

Instead of discussing let the people prefer what they choose

boreal iron
simple stump
wooden ember
#

in d.js whats the new verison of new Discord.messageAtatchment?

#

in d.jsv13 i mean

solemn latch
wooden ember
#

thx

#

bruh its the same?

sudden geyser
#

never changed

wooden ember
#

why is it saying discord it not defined then?

#

or rather where am i suposed to define it

boreal iron
#

Because of your lower M

wooden ember
#

?

boreal iron
#

And your typo

solemn latch
#

also spelt wrong

sudden geyser
#

maybe you're also looking for interaction attachments

boreal iron
#

Case sensitive

wooden ember
#

bruh i just typed it here not pasted it

#

the command used to work in v12

#

but i havent touched this part of the code

#

(cuz i forgot it was there tbh)

solemn latch
boreal iron
#

Err well it’s called a constructor not command, to be accurate

wooden ember
solemn latch
#

thats not MessageAttachment being undefined, rather discord

wooden ember
#

yeah thats what i said

boreal iron
#

Maybe also a typo or lower/capital letter issue?

wooden ember
#

no its cuz in v13 you dont have const Discord = require("discord.js") anymore

solemn latch
#

or you're missing this line
const Discord = require('discord.js');

boreal iron
#

I mean if you haven’t required djs in that scope you can’t access the var then

solemn latch
#

its still something you can use

wooden ember
#

wait

#

this update it making less and less sence

boreal iron
#

Of course you can still import djs

#

How else would you get used to it ?

solemn latch
#

if you wanted, or can also import just message attachment too.
const { MessageAttachment } = require('discord.js');

wooden ember
#

oh i see

#

i think thats the way i started the bot somthing like that

#

const {Client, Intents, Permissions, MessageEmbed} = require('discord.js');

#

i miss the days when you could just use ```js
const Discord = require("discord.js")
const bot = new Discord.Client();


cuz now i have to have like 7 lines of crap at the top now instead
boreal iron
#

It’s up to you if you import single structures or the entire lib

wooden ember
#

but which is faster though?

boreal iron
boreal iron
quartz kindle
wooden ember
#

guessing just doing the const DIscord is slower? cuz if so that would make sence

wooden ember
wheat mesa
#

V8 is smart

quartz kindle
#

there is a difference if you use ESM

#

but no difference in commonjs

boreal iron
#

Not a noticeable difference tho

#

NO BENCHMARK PLEASE

quartz kindle
#

lmao

#

nah fuk esm

boreal iron
#

👍

quartz kindle
#

esm is made for browsers

#

it doesnt matter in node

boreal iron
#

Tim’s sympathy points +3

wheat mesa
#

Tim is going to benchmark his own brain’s ability to compile js

quartz kindle
#

lmao

wheat mesa
#

Breaking news: faster than v8

wooden ember
#

so i can infact just impoer all of discord and cut out al these lines then? :```js
const {Client, Intents, Permissions, MessageEmbed} = require('discord.js');
const botIntents = new Intents();
botIntents.add(Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_PRESENCES);
const bot = new Client({intents: botIntents});

#

cuz this hurts my eyes

boreal iron
wheat mesa
#

Gotta CTRL C his brain

boreal iron
#

ouch

wooden ember
#

bruh gtg il be back in a bit ping me

wheat mesa
boreal iron
#

That botIntents var triggers me

wheat mesa
boreal iron
#

But still

wheat mesa
#

Unlike others I’ve seen naming variables like var SomeVariable and var SOME_variabLe and var some_variable all in the same program

boreal iron
#

var a = 1;
var b = a;
print b

#

WHY

wheat mesa
#

Use whatever naming convention you want but KEEP IT CONSISTANT!

boreal iron
#

That’s right and everyone does it differently

#

I’m using this camel shit only for functions/methods and properties

#

For vars only lower case with words split by _

#

Anywhere

quartz kindle
wheat mesa
#

I use essentially typical java naming conventions for js

boreal iron
#

OMG HE SAID IT

#

JAVA

#

You beast! Outta here!

wheat mesa
#

Java isn’t half bad it’s just got some... less than pleasant things about it

boreal iron
#

Ok now you pretend to like it in some way

#

Things are escalating quickly in here

wheat mesa
#

I do like it

earnest phoenix
#

The floor is Java, now what would you do?

wheat mesa
#

But that mainly just applies to OOP

boreal iron
#

pepowot 🔫

wheat mesa
#

Functional isn’t my thing

#

For the most part at least

#

I’m gonna try to get into C a little bit

boreal iron
earnest phoenix
#

More like stick yourself to the ceiling

marble juniper
#

Me when

#

the floor is java

split hazel
#

uwu

lament rock
#

Math.floor
Math.ceil

#

The floor and the ceiling are Math???

earnest phoenix
#

🤯

wooden ember
#

how do you send an atachment?

#

cuz just puting the variable in doesnt work in v13 aparently

#

wait i might have got it

wheat mesa
#

.send({files: [attachment]}) iirc

wooden ember
#

nice

wheat mesa
#

Or maybe it’s .send({attachments: [attachment]})

#

Can’t remember

wooden ember
#

i tryed atachments

#

didnt work

wheat mesa
#

Then it’s probably files

wooden ember
#

yeah it works thx

#

now my random command that i forgot was still on my bot works again

#

even though it was literally just for testing canvas and servs no purpose

prime mist
#

Testing bots be like.

sudden geyser
#

ping pong

austere surge
#

yeah

#

i made a dumb prefix system with regex that supports many custom prefixes

earnest phoenix
#

Any idea when discord.js v14 will be released?

spark flint
#

in the next week apparently

earnest phoenix
#

Oh nice

austere surge
#

👀

earnest phoenix
#

error: syntax error at or near ")"

CREATE TABLE IF NOT EXISTS Users (
            userId text NOT NULL PRIMARY KEY,
            balance bigint DEFAULT 0,
        );
        
        CREATE TABLE IF NOT EXISTS Items (
            itemId INT PRIMARY KEY,
            userId text,
            name varchar(21) NOT NULL,
            description varchar(150),
            value bigint DEFAULT 10,
            rarity text NOT NULL,
            CONSTRAINT fk_user
            FOREIGN KEY(userId)
            REFERENCES Users(userId)
        );

Am I just blind or is there nothing wrong near any of the )

boreal iron
earnest phoenix
#

nvm

#

figured out it was a trailing comma

boreal iron
#

I will never understand why that’s allowed in certain languages

earnest phoenix
#

so many un-necessary things

boreal iron
#

For example?

earnest phoenix
#

like for button colors

#

one sec, let me pull it up

#
style: ButtonStyle.Primary,```
like why, isn't just "PRIMARY" enough?
sudden geyser
#

it's supposed to act like an enum

#

so it can do a bit more

earnest phoenix
#

I just personally don't like it

boreal iron
#

You can pass primary as string

#

Or simply the integer you can find in the API docs

#

Or like you showed by using djs constants

#

As long as there aren’t major, breaking changes it’s okay

woeful pike
#

lol I love how SQL syntax errors are like "you did a wrong thing"

#

won't even tell you where it died

boreal iron
#

I mean it tries to tell where your error “could be around”

#

It’s something at least

boreal iron
#

Hows that annoying?

sudden geyser
#

lol even postgres makes that error

#

thought that was just sqlite

austere surge
#

hows regex ineffecient

boreal iron
#

Regex is a synonym for inefficiency

boreal iron
#

If you know all the prefixes and/or want to add/remove them dynamically an array is the best solution

#

Regex makes sense only if have no other choice and your patterns a very complex

earnest phoenix
#

Regex makes sense in many scenarios if you know how to work with them efficiently, not poorly written regex that can even cause a ReDoS, but for simple scenarios like the prefix checking model, simple data storage in arrays and checking for them is more efficient, although in some cases, regex can be even more efficient, it's all up to what it being checked, how large are the search strings and similar factors

sudden geyser
prime mist
sudden geyser
#

pokes

wheat mesa
#

So I'm making a library for an API to try to start getting used to sending and receiving data through raw api requests, and I'm wondering how I should be modeling responses in typescript. I'm using the chess.com api, and the docs aren't extremely clear on what fields are optional on the json, so it's difficult to tell what I should be doing.

#

I've got stuff like this: ```ts
async getPlayerData(playerName: string): Promise<ResponseTypes.ChessPlayer | null> {
const res = await Axios.get(Endpoints.PlayerEndpoints.PLAYER_PROFILE(playerName)).catch(() => null);
return !res ? null : res.data;
}

#

and my model looks like this: ```ts
export interface ChessPlayer {
url: string;
username: string;
player_id: number;
title?: ChessTitles;
status: string;
name?: string;
avatar?: string;
location?: string;
country: string;
joined: number;
last_online: number;
followers: number;
is_streamer: boolean;
twitch_url?: string;
fide?: number;
}

#

it works, but I'm just not sure if this is the way to approach stuff like this

#

Or should I just not bother modeling response types like this at all

sudden geyser
#

You can use an interface, but knowing what's optional is tricky. In some APIs, the key won't be there, the value will be null, or both. Sometimes it's only available on certain conditions and most fields may be optional. Maybe the API will break its own rules and not be consistent on when something will be there or null.

Instead of trying to play around with that, I suggest you define the interface with no options (no ?s) at all, but use TypeScript's meta type helpers so you can derive types from old ones (i.e. return a new type with the options added). I forgot what it was exactly called.

wheat mesa
#

hmmmm...

sudden geyser
#

Of course, finding what is and isn't optional is harder, but given the alternative would be marking everything as optional, you may want to ask in the community if someone knows.

wheat mesa
#

I love static typing but I hate it when there's bad API docs agh

#

There's a chess api lib out there for this, but sadly it's written in pure js with no typings

sudden geyser
#

link?

wheat mesa
#
Chess.com

The PubAPI is a read-only REST API that responds with JSON-LD data. Our goal is to re-package all currently public data from the website and make it available via the PubAPI. "Public Data" is information available to people who are not logged in, such as player data, game data, and club/tournament information.

sudden geyser
#

well the api does say at times when something is optional

wheat mesa
#

at times

#

the problem is that it only says that about 50% of the time

sudden geyser
#

then shouldn't you assume that it will always be there

#

or are there times where it doesn't state that it's optional yet it still returns null

wheat mesa
#

there's a set of dummy data they have, which instantly shows that there's some fields that are optional but not specified as such in the docs

bright hornet
#

anyone know why my djs v13 turns into v14-dev? i didnt even update any

"discord.js": "^14.0.0-dev.1640865766.780b7ed"

#

and should i update all of my codes into v13 = v14?

boreal iron
#

Well v14 isn’t out yet as well as it’s documentation

earnest phoenix
#

Use the undocumented version yes yes

wheat mesa
#

So as I'm finding out, they use JSON-LD, which might help me out with typings

#

No idea how it works though

prime mist
wheat mesa
#

Should I do that though? I feel like it would be kind of annoying not knowing which types are guaranteed to be there or not, and therefore having to null-check your results

prime mist
#

Ah actually, that isn't great as the field has to be present still. You still need ?

interface Person {
  name: string;
  phone?: string | null;
}
prime mist
wheat mesa
#

alright

#

if only the docs didn't suck!

#

it's literally a forum post

bright hornet
prime mist
#

Either let axios fail, or transform the errors into another error type you control.

prime mist
#

You should probably handle that in your program lol.

myApiMethod().catch((err) => err.status === 404 ? null : throw err);
wheat mesa
#

god these docs are horrendous

#

might just call it quits on this idea lmao

earnest phoenix
wheat mesa
#

an idiot can abuse the api easily, someone that actually wants to make something suffers due to the lack of up-to-date docs

earnest phoenix
#

discord.js is easy

#

we know how much it sucks compared to detritus

lyric mountain
#

it's easy because it sucks and it sucks because it's easy

sudden geyser
#

I think Discord.js is actually nice

#

gets too much hate for the wrong reasons

prime mist
wheat mesa
#

The API docs have examples, it's just annoying because some of the data on the example doesn't exist on other profiles

#

(They only provide one example per endpoint)

prime mist
lyric mountain
#

Best doc example is discord doc

#

Not only it barely explains anything

prime mist
#

Ah right. Quicktype does allow you to input multiple samples.

lyric mountain
#

But also has outdated examples

wheat mesa
#

the last time this api got a real update was in 2017

#

pretty terrible if you ask me, not sure why they don't upgrade their api more

lyric mountain
#

"don't fix what's working" fallacy

wheat mesa
#

it's pretty scuffed for such a massive website tbh

#

one of their endpoints returns EVERY titled player

sudden geyser
wheat mesa
#

an array of 1400+ strings lmao

sudden geyser
#

Just themselves

wheat mesa
#

perfectly balanced, as all things should be

        const res = await Axios.get<ResponseTypes.ChessPlayer>(PlayerEndpoints.PLAYER_PROFILE(playerName)).catch(
            err => {
                if (err.response.data) {
                    throw new Error(`Code: ${err.response.data.code}\nMessage: ${err.response.data.message}`);
                }
                throw new Error(`Something went terribly wrong: ${err}`);
            },
        );
#

that's probably terrible, but hey, it works

#

(if anyone has better suggestions let me know)

sudden geyser
#

How about casting it to your own error representation

#

Since just throwing it with an error string is not easy for machines to consume

lyric mountain
#

Just noticed, but is that a generic on js?

wheat mesa
#

probably a good idea

#

ts

lyric mountain
#

Understandable

wheat mesa
#

what a beautifully designed api am I right

#

this is just GM players btw

#

there's like 10 other categories lol

solemn latch
#

👀 looks amazing

wheat mesa
#

even better, just made a decoy account with literally 0 data, so I can see what's optional and what's not

#

wow okay that's way more barebones than I expected

#

ok so through a mix of testing and painful typing, I think I have a method down for finding the types

bright hornet
#

Is there a way to get the authors presence status?

looks like message.author isn't working

prime mist
#

The rewards were nice though. I can update my discord library to support new features in a couple hours usually.

#

I then sit back and lol at discord.js taking weeks to implements modals.

wheat mesa
#

lmaooo

sudden geyser
#

I see ramda YukariBlush

lucid prawn
#
const escapeRegex = str => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
    const prefixRegex = new RegExp(`^(<@!?${client.user.id}>|${escapeRegex(Prefix)})\\s*`);

    if(!prefixRegex.test(messageCreate.content)) return;

TypeError: Cannot read properties of null (reading 'replace')

lament rock
#

message content is null if you don't have the message intent

#

not all messages have content anyways such as bot messages with only embeds
or just attachments

#

although in that case, they should be an empty string unless that got changed

lucid prawn
lament rock
#

on gateway v10, it is being enforced iirc

lucid prawn
#

ok

lament rock
#

regardless, message content is null and you need to check that

lucid prawn
#

ok

quartz kindle
#

prefix is null

prime mist
#

Haha yep ^^

quartz kindle
#

lmao both tims randomly reply at the same time

lucid prawn
#

thxs

wheat mesa
#

after far too much work figuring out types, I've got all the player apis down

#

also how would I put this in an interface since props can't start with @

#

I would assume just like ```ts
interface Something {
['@id']: string;
otherStuff: string;
}

#

unless there's a better way

lament rock
#

I guess I got confused then

#

I am tired

wheat mesa
#

I meant things like ```ts
interface Test {
@id: string;
}

#

If I do the way you’re doing my prettier gets mad and changes all of my props to be a string instead of a variable name

#

I’d like to still access them with .

#

Rather than ['name']

quartz kindle
#

well you cant

#

its name same way with numeric keys

#

and any other symbols like dashes etc

wheat mesa
#

Alright

#

I’ll settle with having to use subscripts for the id prop and normal dot for everything else

#

The prop isn’t even important really, I just wanted to include it for completeness

wheat mesa
#

Tokyo Night Storm

#

A personal favorite of mine

austere surge
#

i use Moonlight II Dark ||extension name is just moonlight||

earnest phoenix
#

Deep Ocean fastnod

lucid prawn
#
const { Message, MessageEmbed } = require("discord.js");
//const { Default_Prefix, Color } = require("../../config.js");
const Discord = require("discord.js");
const db = require("old-wio.db");
const moment = require("moment");
const fetch = require("node-fetch");

const url = require("url");

module.exports = {
  name: "ss",
  aliases: ["screenshot"],
  description: "Takes a screenshot of any webpage.",
  usage: "screenshot <URL>",
  run: async (client, messageCreate, args) => {
   
    messageCreate.delete();
    const user = messageCreate.author.tag
    const urls = args[0];
    if (!urls)
      return messageCreate.channel
        .send({ content:`${user},where is the link senpai :/`})
        .then(m => m.delete({ timeout: 5000 }).catch(e => {}));
    
 if (urls.length < 8)
      return messageCreate
        .reply(
          { content: "https is too short to reach - 8 limit"}
        )
        .then(m => m.delete({ timeout: 9000 }).catch(e => {}));
    
    messageCreate.channel.send({ content: "Please Wait...."}).then(m => m.delete({
      timeout: 3000
    }).catch(e => console.log(e)));
    
    const site = /^(https?:\/\/)/i.test(urls) ? urls : `http://${urls}`;
    try {
      const { body } = await fetch(
        `https://image.thum.io/get/width/1920/crop/675/noanimate/${site}`
      );

      return messageCreate.channel.send(
        { content: `Here is a screenshot from requested URL`},
        {
          files: [{ attachment: body, name: "Screenshot.png" }]
        }
      );
    } catch (err) {
      if (err.status === 404)
        return messageCreate.channel
          .send({ content: "Could not find any results. Invalid URL?"})
          .then(m => m.delete({ timeout: 14000 }).catch(e => {}));
      return messageCreate
        .reply({ content: `Oh no, an error occurred: \`${err.messageCreate}\`. Try again later!`})
        .then(m => m.delete({ timeout: 13000 }).catch(e => {}));
    }
  }
};

no error, Not sending file

earnest phoenix
#

because if there's sensitive data on localhost like, idk, mangodb compass then the data gets leaked

lucid prawn
#

ok

lucid prawn
earnest phoenix
#

why are you filtering parm

lucid prawn
#

because it's a pg command

#

for all channels

earnest phoenix
pale vessel
#

you have to restrict it to nsfw channels only

lament rock
#

there was something like the us government tried to make an ai for detecting porn, but it gave false positives for sand dunes

split hazel
#

everything is possible

lament rock
#

gl making a porn filter though

#

might as well be a masochist and have a death wish because it will take you your lifetime to finish and it will be excruciatingly painful to make and train and expensive to maintain all of the training material

split hazel
#

Bro I have a dataset website at my disposal

lament rock
#

Alright. Still doesn't change the fact it will take you your lifetime to finish if the us government can't make anything that's totally accurate. Because that kind of filter absolutely has to be 100% accurate

#

natural language and intent processing is already difficult enough

split hazel
#

then I'll make a challenge on Kaggle and set the reward to 100k so that some young machine learning enthusiast can do it for me

#

double freerealestate

woeful pike
#

I think what they meant was prevent ppl from screenshotting NSFW stuff lol

lapis meteor
#

What's wrong ????

const Topgg = require("@top-gg/sdk");
const express = require("express");
const stats = require("../data/stats.json");

const app = express()
app.get('/', (req, res) => {
    res.send('Currently Working.')
})

app.get('/dblwebhook', (req, res) => {
    res.send('Currently Working.')
})

const webhook = new Topgg.Webhook("jesuisleroidumonde")
app.post("/dblwebhook", webhook.listener(async vote => {
    const data = {};
    let user = client.users.cache.get(vote.user);
    if (!user) user = await client.users.fetch(vote.user);
    if (!user) return;
    client.webhook.logger.vote(user);
});
#

why does it spam suddenly

#

It never did that before

pale vessel
#

it will keep on sending the same payload until you acknowledge the request- by sending status code 200

#

ah wait you're using the SDK, it should handle that

lapis meteor
#

That's weird

#

Since the monthly reset it started spamming

boreal iron
#

Maybe an issue on topgg then

#

I mean you can end the request with a 200 anyway to make sure

fiery stream
#

what more can i add here ?

near stratus
fiery stream
#

thats a little complicated in python for me :/

bright hornet
#

What is .setCustomId for in buttons?

near stratus
# fiery stream thats a little complicated in python for me :/
import time
# at the beginning of the script
startTime = time.time()
# ...
def getUptime():
    """
    Returns the number of seconds since the program started.
    """
    # do return startTime if you just want the process start time
    return time.time() - startTime
bright hornet
#

Just seen it and got interested

coral sigil
bright hornet
#

ahh thanks ~

fiery stream
#

n so on

#

thats just random numbers isnt ?

bright hornet
#

oh

#

using .customId to call another page of the command?

#

is that the thing?

#

or im losing

coral sigil
#

It is just for you. You know what button the user pressed when you have a custom id set

near stratus
bright hornet
coral sigil
spark flint
fiery stream
#

like createdat something

near stratus
#

idk

#

I only know how to print hello world in python

#

I just googled those codes

fiery stream
#

💀 smh bruh

slender thistle
#

That's only for Discord objects and it gets the datetime of when the object was created

fiery stream
#

embed.add_field(name='Mem Usage', value=f'{bytes2human(psutil.Process(os.getpid()).memory_info()[0])}', inline=True) how accurate is that mem usage ?

fiery stream
slender thistle
#
        process = psutil.Process(os.getpid())
        mem = round(process.memory_info()[0] / float(2 ** 20), 2)

Found this from my old bot, calculates the memory usage in MB

slender thistle
#

I wouldn't see any other way to calculate it so yeah

fiery stream
#

btw hey quesntion

#

i got this shard latency but like its way to much how do you like not get that

#

cant you get shard latency in ms

#

nvm that was dumb

pale oasis
#

Math.floor(number); if it’s in decimals, use this to round down.

spark flint
#

its python

dry imp
#

round()

fiery stream
wooden ember
#

two things; is this a thing: msg.mentions.members.first().bot
and how do i add the bot invite to the bots profile?

earnest phoenix
#

@woeful pike svelte makes me want to cry
why the heck would they use labels for something so simple

wooden ember
#

what is alert?

#

or is that web js

quartz kindle
#

web js

earnest phoenix
#

web js

wooden ember
#

ah

earnest phoenix
#

web1.js

quartz kindle
#

web3.js

earnest phoenix
#

ethers4life

wooden ember
#

bruh web stuff moved to fast

earnest phoenix
#

everything is overhyped

wooden ember
#

reminds me of a web page i was making for school like 4 years ago

#

bruh cant find the screen cap

#

but it was literally just html gifs and tables

#

no css at all

earnest phoenix
#

i am going to actually cry now

wooden ember
#

looked very 1999

#

also thinking of websites

earnest phoenix
wooden ember
#

yeah

quartz kindle
#

like govind tiwari's blog

earnest phoenix
#

Java + You = Suicide
Uninstall today!

wooden ember
#

just recently i found dome russian forum and it looks like its not been updated in the 20 years of its life

sudden geyser
earnest phoenix
#

i would rather do useEffect with a huge dependency array

sudden geyser
#

So it's compatible with regular JavaScript

#

And to be minimal

quartz kindle
#

thats the beauty of svelte, it compiles everything to raw js, instead of using a virtual dom

earnest phoenix
#

alrighty

#

yo vc party

sudden geyser
#

I don't use svelte but appreciate the distinction with $: for reactive values beyond

#

Rather than being aggressive and treating any dependency on a reactive value as reactive itself

wooden ember
#

does msg.mentions.members.first().bot work or do i have to fetch the member and then see itf its a bot?

quartz kindle
#

.bot does not exist on a member

wooden ember
#

fair enough

#

so im guessing i have to fetch the user then

sudden geyser
#

use .users instead of .members

quartz kindle
#

you dont need to fetch

wooden ember
#

oh cool

#

so msg.mentions.users.first().bot would work?

quartz kindle
#

yes

wooden ember
#

nice

#

thx

quartz kindle
#

provided a user was actually mentioned

#

if no users were mentioned it will error

wooden ember
#

yeah I already filter that

#

wait

#

what does that actually return

#

would it just be true or false or would it just not exist

#

so if i was looking for a mentions user to be a bot it would looks somthing like
if(msg.mentions.users.first().bot) { }

earnest phoenix
#

I keep getting an Unknown webhook error but I am not even using any webhooks.

lusty glade
#

Heelo

#

Hello

wooden ember
#

i mean just catch the error and just return

#

issue gone

#

lol

#

(probably not good practice but eh)

earnest phoenix
#

Wdym just catch the error

#

I am literally already doing that and the interaction still fails and sends an 404 webhook error

sharp saddle
#

is there any way to make the text channel list automatically update when changing name?

pale vessel
#

either have an api that sends a channel list and fetch it in an interval or use websocket and send events on channel update

sharp saddle
#

can you help me with this?

#

im using expresjs

#

expressjs*

pale vessel
#

nope

sharp saddle
#

:(

#

oke

royal portal
sharp saddle
#

oke

#

i wanted an real-time data update

royal portal
#

no need for that

solemn latch
#

probably will want to use websockets then

sharp saddle
#

balls

#

oke

#

ws?

#

which?

solemn latch
#

either should do

sharp saddle
#

oke

quartz kindle
#

you want the page to update automatically when its changed in discord?

sharp saddle
#

yes

#

like this

spark flint
#

I'm doing a similar feature too

#

i'm planning to make a simple api to get server info

#

and it will use probably redis or something to cache the channels

sharp saddle
#

a

lament rock
#

gotta use a weeb socket

#

websockets can be quite expensive on the server

sharp saddle
#

ok

#

balls

#

websocket obvious

earnest phoenix
#

I feel like I am making my life harder rn with my sql stuff

#

:^)

boreal iron
#

How so?

earnest phoenix
#

Well I am rather new to using raw sql so I am probably doing a lot of stuff inefficiently

#

:^)

#

absolute garbo

#

I wanna try and make that updateUserBalance method into just an update method and be able to use it to update any thing

#

even multiple fields at once if possible

quartz kindle
#

ws is for node

#

browsers have built in websockets, but with a different api

sharp saddle
boreal iron
#

You think you got issues? Watch my phone screen

quartz kindle
#

wat

earnest phoenix
#

I still think my issues are bad

#

:^)

fiery stream
#

hi ppl

earnest phoenix
#

Is there a way I can just make one update method that can update multiple fields at once tho?

boreal iron
#

unfortunately it hasn't been dropped

coral sigil
boreal iron
#

Good question. Idk.

earnest phoenix
#

damn I must of mistaken this for the development channel 😔

fiery stream
#

😦

boreal iron
earnest phoenix
#

Oh really?

#

@solemn latch I love u <3

boreal iron
solemn latch
boreal iron
#

Woo biggest troll ever ;D

earnest phoenix
#

lol

coral sigil
#

:D

earnest phoenix
#

love u woo

earnest phoenix
#

🤔

#

That makes sense

#

I think

slender thistle
#

Honestly that sounds like a great idea

earnest phoenix
#

How should I concat them tho if I have to iterate through the object for its keys and values

#
function updateColumns(columns: Record<string, any>) {
  // Declare the SQL UPDATE operation on a table.
  let sqlQuery = `
    UPDATE table_name
    SET `;

  // Iterate over the keys and values to concatenate the column names and values.
  sqlQuery += Object
    .entries(columns)
    .map(([key, value]) => `${key} = ${value}`)
    .join(', ');

  // With a condition if desired.
  sqlQuery += `
    WHERE ...
  `;

  // Perform the query.
  ...
}
woeful pike
#

why not just use a query builder like knex at this point

earnest phoenix
#

I like making my life harder

#

:)

earnest phoenix
sudden geyser
#

Or even some dsl

earnest phoenix
sudden geyser
#

A query builder can be thought of like a dsl

earnest phoenix
#

discord sql list

sudden geyser
#

If you find yourself concatenating strings for some foreign program (like above), you probably want some kind of dsl

#

e.g. html generator

simple stump
#

If I have an array:

const participants = [name, name2, name3, name4];

How would I convert this to JSON?

earnest phoenix
#

JSON.stringify(participants);

simple stump
#

ty

sharp saddle
lyric mountain
# boreal iron

tf you were supposed to have fixed that phone a month ago

molten totem
#

hey,
yall know why a discord.py bot could straight up just literally stop working?
the bot is thousands of lines of code long and it worked just fine until recently
the bot logs in as it displays the on_ready message, but then just refuses to reply to commands, to handle events, tasks, nothing...
i'm not sure what's wrong with it...

boreal iron
lyric mountain
boreal iron
#

Didn't magically disappear for some reason

lyric mountain
#

tell me, are we talking about a single file or the whole codebase?