#development

1 messages · Page 1987 of 1

pale vessel
#

nobody could do it except the user itself so i doubt a bot could do it

rocky hearth
#

so if a member dont join a thread, they can't see thread in the channels list either, right?

pale vessel
#

yep

#

they need to click the threads button on top right

rocky hearth
#

hmm ok

pale vessel
#

active threads also show up when you hover over a channel afaik

#

i'm not sure if you need to join them or not for them to appear

quartz kindle
#

threads were a dumb idea

#

good morning

pale vessel
#

good morning indeed

rocky hearth
lyric mountain
rocky hearth
#

so can the bot too invite peoples?

lyric mountain
#

probably

#

although I'd not rely on private threads

#

since discord was dumb enough to make it boost-only

earnest phoenix
#

no one

earnest phoenix
feral aspen
#

Is there a word you call discord.js buttons and dropdowns?

#

Is there like an overall word or sentence for it?

lyric mountain
#

interactions

feral aspen
#

Interactions? Sure!

lyric mountain
#

yeah

#

both are interactions

wooden ember
#

i know this is probably self explanatory but i ran npm i discord.js

#

that downloaded d.js v12 didnt it

#

cuz theirs a file in node modules calld discord-12

earnest phoenix
#

It got changed to npm ui discord.js

wooden ember
#

?

earnest phoenix
#

Just try it

wooden ember
#

what does ui do?

#

(i mean whats the diference between that and just i)

earnest phoenix
#

Uninstalls a package

wooden ember
#

ah

#

so how do i get v13? though

#

is it just npm i discord.js@13.14.0

#

or did it just install both or somthing for compatability

cobalt junco
wooden ember
#

i cant remember the version number of the top of my head i just remember there being a 4 in it

cobalt junco
wooden ember
#

yee

atomic kindle
#

Or to install the latest stable one, npm i package@latest

earnest phoenix
atomic kindle
#

Ay!

earnest phoenix
#

wait shouldn't it be ui instead of i

wooden ember
wooden ember
earnest phoenix
#

how?

#

I learned mongodb from CodeLyon, and he uses it like this

#

oh I didn't use await (well, quick.db don't need it so I never had to put async/await)

wheat mesa
#

async await is very important for db calls

split hazel
#

soon it will be just await

#

all hail top level await

earnest phoenix
#

already exists in esm modules and deno

wheat mesa
#

Yes

lyric mountain
#

not because their content, but because they don't get updated

lyric mountain
#

fireship?

earnest phoenix
#

awesome yt channel

sudden geyser
#

fireship isn't much better

#

all they try to do is give you an introductory into what some tool is about

lyric mountain
#

the issue is getting the habit of learning from videos instead of documentation/actual searching

earnest phoenix
sudden geyser
#

code most people here clearly don't learn best from videos

earnest phoenix
#

wha....

#

callback(new error_1.MongoServerError(document));
^
MongoServerError: The field 'ownedCards' must be an array but is of type object in document {_id: ObjectId('621679876f6cc343063b8670')}
at MessageStream.messageHandler (/workspace/node_modules/mongodb/lib/cmap/connection.js:462:30)
at MessageStream.emit (node:events:520:28)
at processIncomingData (/workspace/node_modules/mongodb/lib/cmap/message_stream.js:108:16)
at MessageStream._write (/workspace/node_modules/mongodb/lib/cmap/message_stream.js:28:9)
at writeOrBuffer (node:internal/streams/writable:389:12)
at _write (node:internal/streams/writable:330:10)
at MessageStream.Writable.write (node:internal/streams/writable:334:10)
at Socket.ondata (node:internal/streams/readable:754:22)
at Socket.emit (node:events:520:28)
at addChunk (node:internal/streams/readable:315:12) {
ok: 0,
code: 2,
codeName: 'BadValue'
}

lyric mountain
#

not always there'll be a video for your exact case, that's why so many "programmers" don't even know how to use stackoverflow

earnest phoenix
#

I didn't save it as array tho

lyric mountain
#

and end up with a ton of boilerplate without knowing what it's doing

earnest phoenix
lyric mountain
#

ownedCards isn't an array

#

it's an object

earnest phoenix
#

yeah

lyric mountain
#

The field 'ownedCards' must be an array

earnest phoenix
#

in type it's object

#

check the image that I sent above

sudden geyser
#

You can learn from watching videos, but not the kind of "follow the tutorial" we see from #development. Presentations, talks, and slides introducing or building on software are a great way to learn new things imo

#

Fireship does that but not to the extent of other videos I've seen

earnest phoenix
#

I just needed some reference

#

fireship has very less tutorials

split hazel
#

yeah because he wants you to buy fireship pro

earnest phoenix
#

lmao

sudden geyser
#

$25 a month yikes

earnest phoenix
#

why that error?

lyric mountain
#

with 25 a month you buy a metric ton of courses

lyric mountain
earnest phoenix
#

refactor?

lyric mountain
#

like, if it previously accepted Arrays it'll expect Arrays

sudden geyser
#

for the subject of the courses and how many he has, isn't worth it to me personally

lyric mountain
#

even if u changed the type, u still need to change the current content

#

else it'll conflict

sudden geyser
#

I've seen some others, like jetbrains academy also charge a lot but have a lot more and spread out the subjects

lyric mountain
#

again, this is a sql thing, idk if mongo has this

#

or any structure at all

earnest phoenix
#

nope

#

It's like this from the start

#

I'll delete all the mongo data and check

#

anyways there's no data at all

#

same

lyric mountain
#

then idk, check the docs

earnest phoenix
#

ok

#

I think push is the one

#

giving error

#
await profileModel.findOneAndUpdate({userID: message.author.id}, {$push: {ownedCards: {rarity: [`${chsa}`]}, all: [`${chsa}`]}});
earnest phoenix
#

How can i add a function to message so when i do message.embed() it sends embed message

earnest phoenix
cinder patio
#

It's not really a big deal unless ur making a library though. discord.js would never create a message.embed function

earnest phoenix
#

my message create funtion

wheat mesa
#

still though, not a great practice to modify the prototype

#

helper function is just the way to go

#

pass in your message object to the helper function and your embed

cinder patio
#

yeah

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

Just wanna use protoype to learn

wheat mesa
#

you could extend the message class couldn't you? Or does djs prevent that

earnest phoenix
#

Not only could it cause prototype pollution, but you wouldn't really need that method on every message instance, if you modify the prototype, that method will also be present on every message instance, which can increase the memory usage unexpectedly

#

Although this wasn't really a problem in the older discord.js versions where extendable structures existed

cinder patio
#

Eeeeh I doubt you would see a change. V8 definitely makes sure to optimize that.

earnest phoenix
#

I am using v14

#

You're using the dev builds, so it still applies mmLol

earnest phoenix
sudden geyser
earnest phoenix
wheat mesa
#

and just call it like any other function

earnest phoenix
#

Calling this function everytime with message comes like death for me

#

That's the nature of helper methods, especially external ones

wheat mesa
#

modifying the internal lib of djs also sounds like death waiting to happen but up to you

cinder patio
#

You could replace the Message class from the require.cache

#

no prototype pollution then

earnest phoenix
#

I had client.send(type, text) it didnt cause any problem

earnest phoenix
#

Not prototype

earnest phoenix
sudden geyser
cinder patio
#

it still would

#

AFAIK require.cache is global. Replacing the Message before discord.js uses it will do it

sudden geyser
#

please just use the function

earnest phoenix
#

You can't replace it before discord.js uses it, since it imports everything it needs before anything in your code is executed, which would make it impossible to replace it in the context of the library, although the only thing you can to is to modify the library yourself, which is not a good idea

#

The helper method is the best option stuff

sudden geyser
#

even with the prototype or function it's not going to compose well

cinder patio
#

You can just require the file the Message class comes from

#

not the entire lib

sudden geyser
#

you can only reply and only with an embed. nothing more, nothing less. want to include some message content, or an attachment? too bad

earnest phoenix
# cinder patio not the entire lib

You could, but what I mean is that the code in the libraries are already executed in a partial way before you even import them, which is what makes it impossible to replace those internally used classes, which reminds me of that guy
"Ah yes, kill all the bots that use extendable structures properly"

#

discord.js™️

cinder patio
#

I'll test it out

#

alright you can't

feral aspen
#
const nFilter = (int) => int.message.id === n.id && int.user.id === interaction.member.id;
const nCollector = interaction.channel.createMessageComponentCollector({ nFilter, max: 1, componentType: 'BUTTON', time: 30000 });

How to check each value in the nFilter example check the value of int.message.id, n.id int.user.id and interaction.member.id? I want to check each value of those?

#

I tried debugging, didn't know what I was doing, honestly.

#

I JUST REALISED, it's filter: nFilter. cryIgnore

#

Well, problem solved.

cinder patio
#

the best way to check it is to make a Set and check if it's size is 1

#

wait how do you want to check them exactly? You want to check if all of them are the same

earnest phoenix
lyric mountain
#

did ya search in SO or in the docs?

earnest phoenix
#

so?

#

oh

#

yeah

#

in StackOverflow

lyric mountain
#

usually everything can be found there

earnest phoenix
#

I found it there

#

but it doesn't work

earnest phoenix
#

ohhh

#

wait

#

I have to put it without [] right?

earnest phoenix
lyric mountain
#

the whole thing is in brackets, so it's an object

#

I can't really help u with mongo

#

and very few here are experient with it

earnest phoenix
#

what you need help with

lyric mountain
#

@earnest phoenix ^

earnest phoenix
#

ok wtf is $push

#

that kind of stuff @cinder patio is experienced with

#

kthxbai

round cove
lyric mountain
#

if (code913) throw new IDFKException();

round cove
earnest phoenix
#

each?

#

I'm adding only one thing

round cove
#

Yes so it says insert each item from this array into "rarity"

#

Because it's an array type it has to use it.

earnest phoenix
#

oh

#

will give it a try

#

rarity is an array

#

something like this?

#
await profileModel.findOneAndUpdate({userID: message.author.id}, {$push: {ownedCards: {rarity: {$each: [`${chsa}`]}}, all: chsa}});
lyric mountain
#

in the dark of the night, I wonder

is mongo really easier than sql?

#

idk, it feels very messy and confusing

earnest phoenix
earnest phoenix
sudden geyser
lyric mountain
# earnest phoenix

that's the thing, like, people say it's easier, but from everything I see around it feels extremely confusing

#

I can't even imagine maintaining a big database transaction

earnest phoenix
#

for me too

lyric mountain
#

not that kind of confusing

#

like, it's the kind of thing you write once and never maintains

#

cuz u need a specific mindset to understand what and why you did something

earnest phoenix
#

well

#

when I complete my bot, I will never touch it

lyric mountain
#

that's what u think

earnest phoenix
#

it looks cool when using it but the coding is extremely bad

lyric mountain
#

I mean, eventually it'll start to break apart

#

bots are services, and services are never truly finished

earnest phoenix
#

well i've maintained many commands but it's inefficient

earnest phoenix
#

$each didn't work

#

it says ownedCards is marked as array in document

#

the document

round cove
#

not the owned cards

earnest phoenix
#

oh

#

what did I do to you mongodb....

#
/workspace/node_modules/mongodb/lib/cmap/connection.js:462
callback(new error_1.MongoServerError(document));
^
MongoServerError: The dollar ($) prefixed field '$push' in 'ownedCards.$push' is not valid for storage.
at MessageStream.messageHandler (/workspace/node_modules/mongodb/lib/cmap/connection.js:462:30)
at MessageStream.emit (node:events:520:28)
at processIncomingData (/workspace/node_modules/mongodb/lib/cmap/message_stream.js:108:16)
at MessageStream._write (/workspace/node_modules/mongodb/lib/cmap/message_stream.js:28:9)
at writeOrBuffer (node:internal/streams/writable:389:12)
at _write (node:internal/streams/writable:330:10)
at MessageStream.Writable.write (node:internal/streams/writable:334:10)
at Socket.ondata (node:internal/streams/readable:754:22)
at Socket.emit (node:events:520:28)
at addChunk (node:internal/streams/readable:315:12) {
ok: 0,
code: 52,
codeName: 'DollarPrefixedFieldName'
}
rocky hearth
#

Can a thread be permanent like text channels?

grim aspen
spark flint
#

does anyone here know how to delete a file with aws-sdk

quartz kindle
#

aws-sdk pls delete file with magick kthxbai

spark flint
#

or even better, how can i bulk make everything public in a do space

earnest phoenix
# rocky hearth Can a thread be permanent like text channels?

Threads are temporary text channels, so they can't stay unarchived on their own forever, the maximum duration a thread can stay unarchived on it's own is 1 week, although staff members can unarchive the channel when it gets archived, so you can for example give your bot the permission to unarchive threads and unarchive that thread when it gets archived

earnest phoenix
wheat mesa
#

On the off chance someone here has experience with this, I would greatly appreciate any help/advice I can get on fixing this repo: https://github.com/Jwaffled/MathExpressionParser/tree/master/WaffleCompiler/Core

My current issue is that I got the greater than and less than tokens to work properly, but it crashes when I try to use other operators, because I structured it to return a bool and such, which isn't correct

GitHub

For educational purposes. Contribute to Jwaffled/MathExpressionParser development by creating an account on GitHub.

quartz kindle
wheat mesa
#

jester's privilege 😉

stiff lynx
#

I have to cache for the parent of a channel that I want to create?

#
GuildChannelManager.create(nomeServer, [{ parent: categoria }]);```
sudden geyser
#

I have some HTTP server for a personal site I'd like to host. Where should I look?

quartz kindle
#

remove the []

stiff lynx
quartz kindle
#

{ parent: categoria }

earnest phoenix
stiff lynx
earnest phoenix
#

categore 👀

compact pier
#

the stats in Cloudflare are sux

#

Google analystics are better

wheat mesa
#

my brain is dying

boreal iron
#

Somebody here to check a link for me for Discord scam?

#

Can’t inspect the website on mobile

earnest phoenix
earnest phoenix
earnest phoenix
stiff lynx
#

I'm getting troubles about passing a costant from a file.js to file1.js

#

I get them as undefined

cinder patio
#

are both files requireing each other?

earnest phoenix
#

syntax errors..

#

30+ mins changing stuff

#
await profileModel.findOneAndUpdate({userID: message.author.id}, { $push: {`ownerCards.$.${rarity}`: {$each: [chsa]}, $push: {all: {$each: [chsa]}}}});
#

what's wrong

#

"Property Assignment expected" in ownerCards.$

#

',' expected

#

Declaration or statement expected

cinder patio
#

You need to put the string literal inside brackets

#

[...]:

earnest phoenix
#

ok

#

oh yeah

#

it solved all

#

tysm

#

the check doesn't work

#
let check = await profileData.all;
let truemsg;

if (check.includes(chsaa)) {
#

check is an array

cinder patio
#

What is profileData?

#

can you console log check

earnest phoenix
#

profileData is the user's profileData got from the db

earnest phoenix
rocky hearth
#

whats the point of archived threads if people can still message there?

sudden geyser
#

so the thread is marked as inactive and is harder to find

#

e.g. using threads for questions and archiving them so people can still look at them and reply if they have something to say

earnest phoenix
#

this appears

rocky hearth
#

and how long can a thread be? Is there any limitation?

sudden geyser
#

depends on the server

#

servers with boosts can set the time longer

#

the longest is a week

#

shortest is a day

#

with some points in between

rocky hearth
#

no, I mean the message counts.

sudden geyser
#

ah, no message limit

rocky hearth
#

we can hv a thread forever right

sudden geyser
#

theoretically yes

rocky hearth
#

I hv used threads like this to better organize channels,
and let members join their interest of threads

austere surge
#

oo

lyric mountain
#

I know what ur thinking, don't try sending a message every X minutes to keep it alive

austere surge
#

yeah dont do that

#

a good idea for organization though

lyric mountain
#

btw, u can just use those characters if u want that tree-like organization

austere surge
#

¯_(ツ)_/¯

lyric mountain
austere surge
#

i keep almost putting the middle finger instead of the pointer finger reaction

lyric mountain
#

├ Do
├ It
├ Like
└ This

rocky hearth
austere surge
#

yea

lyric mountain
#

well, yea

sudden geyser
#

you might as well create a regular channel for that

rocky hearth
#

yeah, thx

rocky hearth
#

does discord notices the pattern?

lyric mountain
#

as klay said, threads aren't really meant to be kept open for too long, there HAS to be a reason they didn't just add an unlimited time option

#

if you keep it open for too long, they will notice it eventually

earnest phoenix
#

it doesn't push anything ```js
await profileModel.findOneAndUpdate({userID: message.author.id}, { $push: {[ownerCards.$.${rarity}]: {$each: [${chsa}]}, $push: {all: {$each: [chsa]}}}});

#

no errors

quartz kindle
#

are you sure you want to do

{
    $push: {
        [`ownerCards.$.${rarity}`]: {
            $each: [`${chsa}`]
        },
        $push: {
            all: {
                $each: [chsa]
            }
        }
    }
}
``` and not ```js
{
    $push: {
        [`ownerCards.$.${rarity}`]: {
            $each: [`${chsa}`]
        },
        all: {
            $each: [chsa]
        }
    }
}
``` ?
#

i mean, it doesnt make sense to have one push inside another

earnest phoenix
#

the second one

#

but it gives error

quartz kindle
#

then show the error?

earnest phoenix
#

syntax error

#

"Property assignment expected"

#

oh wait no

#

my code was the problem

#

will try and see

#

it didn't update ownedCards.rarity but did update all

#

rarity is the card's rarity so it adds in the correct rarity

earnest phoenix
#

yep changed it for that

#

and same

#

well, will check "unstringing" chsa in the ownedCards like in all

#

Is it not pushing the specified element to the ownerCards.<rarity> array?

earnest phoenix
#

oops

#

ownedCards...

#

Typos are the worst

#

will check now

eternal osprey
#

hey guys i have an error: java.java:104:23: error: local variable voornaamtext is accessed from within inner class; needs to be declared final```java

  String addon1 = voornaamtext.getText();

public void actionPerformed(ActionEvent e) {
String addon1 = voornaamtext.getText();
String addon2 = achternaamtext.getText();
String addon3 = tussenvoegseltext.getText();
String naam = addon1 + " " + addon3 + " " + addon2;
String addon4 = straattext.getText();
String addon5 = huistext.getText();
String straat = addon4 + " " + addon5;
String addon6 = plaatstext.getText();
String addon7 = postcodetext.getText().concat(letterstext.getText());
String postcode = addon6 + " " + addon7;
System.out.println(naam + "\n" + straat + "\n" + postcode);
System.out.println(straat);
System.out.println(postcode);
voornaamtext.setText("");
achternaamtext.setText("");
tussenvoegseltext.setText("");
straattext.setText("");
huistext.setText("");
plaatstext.setText("");
postcodetext.setText("");
letterstext.setText("");
verstuurbutton.setEnabled(false);
JTextArea textvak = new JTextArea();
textvak.setBounds(20,240,240,140);
frame.add(textvak);
textvak.setText(naam + "\n" + straat + "\n" + postcode);

}
earnest phoenix
#

tysm worked

sudden geyser
#

oh god

earnest phoenix
#

goldenfredy wtf

sudden geyser
#

i.e.

class A {
  int b = 5;

  class C {
    public C(int d) {
      System.out.println(b + d);
    }
  }
}
#

So the compiler is asking you to mark b as final so it can't be modified.

earnest phoenix
#

how can I pick 10 of an array?

#

instead of array[0] and so on that picks 1 i want to pick multiple (10)

sudden geyser
#

ten of what? apples? oranges? the first ten? last 10? a random sample of ten?

earnest phoenix
#

the first 10

sudden geyser
#

use .slice

#

e.g. [1, 2, 3, 4, 5].slice(0, 2)

earnest phoenix
#

ok

#

ty

sudden geyser
#

but why the error

lyric mountain
#

because you can't change the value of a variable to be passed to an inner class (reference issues)

lyric mountain
#

second, define a new variable to hold the value to be passed to the inner class

#

you can also use an anonymous class or an object array

#

or an atomic variable

#

in your case, you could do ```java
YourClass voornaamtext = ...;
voornaamtext = ...; // changing the variable value

YourClass finalVoornaam = voornaamtext;
public void actionPerformed(ActionEvent e) {
String addon1 = finalVoornaam.getText(); // this wont error
}

#

or for atomic: ```java
AtomicReference<YourClass> voornaamtext = new AtomicReference(...);
voornaamtext.set(...); // changing the atomic value

public void actionPerformed(ActionEvent e) {
String addon1 = voornaamtext.get().getText(); // this wont error
}

wheat mesa
#
    private Node ParseGreaterThanLessThan()
    {
        var lhs = ParseAddSubtract();

        while (true)
        {
            Func<double, double, bool> compareOp = null;

            if (_tokenizer.Token == Token.GreaterThan)
            {
                compareOp = (a, b) => a > b;
            } else if (_tokenizer.Token == Token.LessThan)
            {
                compareOp = (a, b) => a < b;
            } else if (_tokenizer.Token == Token.Equals)
            {
                compareOp = (a, b) => a == b;
            }

            if (compareOp == null)
            {
                return lhs;
            }
            
            _tokenizer.NextToken();

            var rhs = ParseAddSubtract();

            lhs = new NodeBinary(lhs, rhs, compareOp);
        }
    }

public abstract class Node
{
    public abstract double Eval(IContext ctx);
}
``` I have this setup for a function, and I need Eval to return bool when the the last generic arg of `Func` is bool, but I have no idea how to accomplish that
#

That last lhs = new NodeBinary() line doesn't work because NodeBinary takes a Func<double, double, double> and not a Func<double, double, bool>

cinder patio
#

What are you doing anyways 🤔

wheat mesa
#

math parsing

cinder patio
#

Maybe have the function return either 0 or 1 instead a boolean?

#

or use an enum to store all possible values, not sure if java has those

wheat mesa
#

the problem is that the function that calls this needs a node back

#

(c# btw)

cinder patio
#

oh

wheat mesa
#

because I use this for calling it ```cs
public Node ParseExpression()
{
var expr = ParseGreaterThanLessThan();

    if (_tokenizer.Token != Token.Eof)
    {
        throw new SyntaxError($"Unexpected characters at end of expression");
    }

    return expr;
}
#

I think I might need a complete redesign

#

But I'm not sure where to start tbh

cinder patio
#

Well If I were u I'd group all binary expressions into one to make parsing a lot easier

#

and I wouldn't create functions while parsing

wheat mesa
#

What would be perfect is if I could inherit from the Node class but override the type signature to be bool

cinder patio
#

create an AST first and then run it

wheat mesa
#

But I don't believe that's possible sadly

#

I'll look into ASTs, I've heard of them but I don't have any idea how to create one or what it is

cinder patio
#

It's basically a tree structure which represents the program

wheat mesa
#

Oh that's similar to what I'm doing

#

looking at this, if it's right then that's what I'm doing pretty much

cinder patio
#

so for example a + b would be

BooleanExpression {
   op: "+",
   left: Identifier { name: "a" },
   right: Identifier { name: "b" }
}
#

yeah that's it

#

but I see that you're also creating the functions while parsing

wheat mesa
#

yeah

cinder patio
#

It'd be better to create the full AST first then traverse it

wheat mesa
#

that's one of the biggest issues

#

so yeah i'll look into how to do that AST thing

cinder patio
#

look into recursive descent parsers

split hazel
#

So i have two interface types here

#

does anyone know if you can overload interfaces so if ACK = Failure, error response properties become available

coral sigil
#

pp

lament rock
# split hazel So i have two interface types here

You'd need something like

interface PayPalBaseNVPResponse {
  ACK: 'Success';
}

interface PayPalNVPErrorResponse {
  ACK: 'Failure';
  L_SHORTMESSAGE0: string;
  L_ERRORCODE0: string;
}

export type PayPalNVPResponse = PayPalBaseNVPResponse | PayPalNVPErrorResponse;

When you check if ACK === 'Failure', it will type narrow down to the error response interface

split hazel
ember lodge
#

Any idea how to make fs to edit a file without permissions?

#

i want to edit /etc/hostapd/hostapd.conf but just root can edit it

#

and for some reason my user can’t be root

woeful pike
#

become root and give your user edit permissions

ember lodge
#

how can i do that?

quartz kindle
#

do you have root access to the machine?

#

or is it a hosting service that does not give you root access?

ember lodge
#

It's just my raspberry pi, i already fixed it tho, thanks

#

Does fs corrupt files or something? Because for some reason when i modify the hostapd.conf file the service stops working, then it works again only if i delete it and paste everything again manually.

lyric mountain
#

Fs is...iffy, to say the least

#

You need to exert extreme caution when writing to files to not have 2 operations running at once

lucid prawn
#

puts the prefix as space for some reason

const filter2 = (reaction, user) => {
    return (msg) => msg.author.id === messageCreate.author.id
}
      let prefix = await messageCreate.channel.awaitMessages({ filter3, max: 1, errors: ["time"], time: 30000 })
      if (!prefix.first())
        return client.sendTime(
          messageCreate.channel,
          "You took too long to respond."
        );
      prefix = prefix.first();
      prefix = prefix.content;

      await client.database.guild.set(messageCreate.guild.id, {
        prefix: prefix,
        DJ: GuildDB.DJ,
      });
quartz kindle
#

that filter wont work

#

first of all you define filter2 but use filter3

#

second, you cant do that

#

{ filter3 } is a shortcut for { filter3: filter3 } but filter3 is not a valid option

lucid prawn
#

here filter3

const filter3 = (reaction, user) => {
    return user.id === messageCreate.author.id &&
        ["1️⃣", "2️⃣"].includes(reaction.emoji.name);
};
quartz kindle
#

that makes no sense either

#

you're using awaitMessages not awaitReactions

lucid prawn
#

this won't work anymore

 let emoji = await ConfigMessage.awaitReactions(
      (reaction, user) =>
        user.id === messageCreate.author.id &&
        ["1️⃣", "2️⃣"].includes(reaction.emoji.name),
      { max: 1, errors: ["time"], time: 30000 }
    )

quartz kindle
#

thats a completely different thing, it has nothing to do with the code you showed about prefixes

lucid prawn
#

prefix used to = let prefix = await messageCreate.channel.awaitMessages( (msg) => msg.author.id === messageCreate.author.id, { max: 1, time: 30000, errors: ["time"] } );

quartz kindle
#

that makes more sense

lucid prawn
#

nothing happens when I use that

quartz kindle
#

then your problem is somewhere else

lucid prawn
#

umm

quartz kindle
#

what is messageCreate?

lucid prawn
#

run: async (client, messageCreate, args, { GuildDB }) => {

quartz kindle
#

you'll need to show more code then

lucid prawn
#
  sendTime(Channel, Error) {
    let embed = new MessageEmbed()
      .setDescription(Error);

    Channel.send({ embeds: [embed]});
  }
lament rock
#

multi line strings in code don't translate to new lines being inserted into the string

ember lodge
lament rock
#

iirc

"this\
will\
turn\
into\
this"
// "this will turn into this"
pale vessel
#

they use ` though

#

although you need to remove the indentations

lament rock
#

it doesn't matter for \

pale vessel
#

that's not what they doing?

#

isn't this what their expected result is?

#

not sure if the extra indentations were what caused the error

lament rock
#

Are you using \?

ember lodge
pale vessel
#

yeah

#

remove the indentation

#

or strip them using a function

#

cause that code looks ugly

quartz kindle
lucid prawn
#

ok

#

I can use let emoji = await ConfigMessage.awaitReactions( (reaction, user) => user.id === messageCreate.author.id && ["1️⃣", "2️⃣"].includes(reaction.emoji.name), { max: 1, errors: ["time"], time: 30000 } ).
instead of filter3

elder jewel
#
@tasks.loop(minutes=10.0)
async def update_stats():
    print("run")
    plt.clf()
    plt.cla()

    y = []
    s = int(time.time())
    for i in range(36):
        a = s - 3600
        b = a - 3600
        count = 0
        for g in client.guilds:
            if f"u{g.id}.json" not in os.listdir("data"):
                continue
            
            with open(f"u{g.id}.json", "r") as f:
                data = json.load(f)
            for t in data['blocked']:
                if int(t) > b and int(t) <= a:
                    count += 1
        count += i
        y.append(count)

    x = [i for i in range(1, 37)]

    print(x, y)

    #x.reverse()

    # setup axis labels
    ax1 = plt.gca()
    ax1.set_ylabel('URLs')
    ax1.set_xlabel('hours ago')

    # plot
    plt.xticks(rotation=17)
    ax1.spines['bottom'].set_color('white')
    ax1.spines['top'].set_color('white') 
    ax1.spines['right'].set_color('white')
    ax1.spines['left'].set_color('white')
    ax1.tick_params(axis='x', colors='white')
    ax1.tick_params(axis='y', colors='white')
    ax1.yaxis.label.set_color('white')
    ax1.xaxis.label.set_color('white')
    ax1.title.set_color('white')
    ax1.set_facecolor((0.0, 0.0, 0.0))

    plt.plot(x,y, label='Blocked')
    # beautify the x-labels
    plt.gcf().autofmt_xdate()
    plt.gca().set_xlim(36, 1)
    #plt.gca().set_xlim(1, 11)

    plt.fill_between(x, y, 0,
        facecolor="blue", # The fill color
        color='blue',           # The outline color
        alpha=0.2) # Transparency of the fill

    plt.legend(labelcolor='white', facecolor='black')
    plt.suptitle('---Recent Player Counts---', color='white')
    plt.gcf().set_facecolor('xkcd:black')

    #plt.show()

    n = "graph.png"
    plt.savefig(n)
#

this is not working, It does not give me any errors

#

any ideas

quartz kindle
lucid prawn
#

with my old code I didn't use filters

#

I don't know anything about them

quartz kindle
#

look

earnest phoenix
#

this has nothing to do with filters

quartz kindle
#

awaitMessages expects an object of options

#

like this

elder jewel
#

anyone have a idea for me?

quartz kindle
#
{
  filter: your filter here,
  max: your max here,
  time: your time here,
  ...etc
}
#

you are not giving it a filter option

earnest phoenix
#

{ emojiFilter } would become { emojiFilter: emojiFilter } instead of { filter: emojiFilter }

quartz kindle
#

{ filter3 } is not the same as { filter }

#

{ () => {} } is not the same as { filter }

#

the name filter has to be the correct name

earnest phoenix
#

why do they even have so many filters for the same thing

quartz kindle
#

so you have to do either { filter } or { filter: filter3 } or { filter: () => {} }

#

understood?

lucid prawn
#

yes I'm dumb sorry

quartz kindle
#

see the difference?

lucid prawn
#

oh ok

#

messageCreate.channel.awaitMessages({ filter: filter2, max: 1, errors: ["time"], time: 30000 })

#

yes?

earnest phoenix
#

yes

lucid prawn
#

yay

earnest phoenix
#

gg

lucid prawn
#

GG sir bloblul

#

next error lol

#

/question

#

Is it okay if I start shards early?

austere surge
#

you can make a sharding manager before needed yeah

#

just dont make too many shards

lucid prawn
# austere surge just dont make too many shards
const { ShardingManager } = require('discord.js');

const manager = new ShardingManager('./bot.js', {
    totalShards: "auto",
    token: process.env['Token'],
    spawnTimeout: -1,
    respawn: true
});

manager.on("shardCreate", shard => {
  shard.on('reconnecting', () => {
    console.log(`Reconnecting shard: [${shard.id}]`);
  });
  shard.on('spawn', () => {
    console.log(`Spawned shard: [${shard.id}]`);
  });
  shard.on('ready', () => {
    console.log(` Shard [${shard.id}] is ready`);
  });
  shard.on('death', () => {
    console.log(`Died shard: [${shard.id}]`);
  });
  shard.on('error', (error) => {
     console.error(error)
  })
});

manager.spawn(manager.totalShards, 5500, -1).catch(e => console.log(e))
austere surge
#

looks right to me

lucid prawn
#

this normal?

#

Error [SHARDING_READY_DIED]: Shard 0's process exited before its Client became ready.

austere surge
#

theree should be an error above

lucid prawn
#
Died shard: [0]
Spawned shard: [0]
Error [SHARDING_READY_DIED]: Shard 0's process exited before its Client became ready.
    at Shard.onDeath (/home/runner/mika/node_modules/discord.js/src/sharding/Shard.js:161:16)
    at Object.onceWrapper (node:events:510:26)
    at Shard.emit (node:events:402:35)
    at Shard._handleExit (/home/runner/mika/node_modules/discord.js/src/sharding/Shard.js:399:10)
    at ChildProcess.emit (node:events:390:28)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12) {
  [Symbol(code)]: 'SHARDING_READY_DIED'
}
austere surge
#

does it run fine without shard

lucid prawn
#

with it and without

austere surge
#

?

lucid prawn
#

The bot still runs with that error

austere surge
#

whats the actual error

lucid prawn
#

Shard 0's process exited before its Client became ready.

austere surge
#

why would that appear without shard

lucid prawn
#

when I use shards

#

I get this error

#

Shard 0's process exited before its Client became ready.

austere surge
#

the manager hsa something wrong then hold on

#

i just have manager.spawn();

#

might be why

lucid prawn
#

ok

#

do I keep client.login() in my main file?

austere surge
#

yes

lucid prawn
#
  reject(new Error('SHARDING_READY_TIMEOUT', this.id));
               ^

Error [SHARDING_READY_TIMEOUT]: Shard 0's Client took too long to become ready.
lament rock
#

The error is self explanatory

#

either Discord was slow or your MCWifi came into play

flat copper
#

how to create htmlImageElement in nodejs

rocky hearth
#

I want to make a channel where sending messages is not allowed, instead members have to create threads to start discussion on any topic.

#

Is it possible?

#

I tried but then, threads inherit channel permissions. and messages cant be send their too

earnest phoenix
azure lark
#

why can i not here the audio from the bot?

module.exports = {
  name: "play",
  aliases: ["pl"],
  usage: "play <song>",
  description: "play a song",
  run: async (client, message, args) => {
 let stream = ytdl("https://www.youtube.com/watch?v=QnL5P0tFkwM", {
            filter: "audioonly",
            opusEncoded: true,
            encoderArgs: ['-af', 'bass=g=10,dynaudnorm=f=200']
        });
    const { joinVoiceChannel, createAudioPlayer, createAudioResource, StreamType, setVolume, NoSubscriberBehavior } = require('@discordjs/voice');
 
const player = createAudioPlayer({
    behaviors: {
        noSubscriber: NoSubscriberBehavior.Play,
    },
});
    const connection = joinVoiceChannel({
    channelId: message.member.voice.channel.id,
    guildId: message.guild.id,
    adapterCreator: message.guild.voiceAdapterCreator,
})

      
const resource = createAudioResource(stream, {
  inputType: StreamType.Opus,
  inlineVolume: true
});
    
    
    await player.play(resource)
    resource.volume.setVolume(100);
await console.log(resource)
    
    await connection.subscribe(player)
    
    }
};```
green pebble
#

yoo.. another custom css doubt.. im trying to use some shortcut ways to enhance my css.. why aint this block quote thingy working

#

"theoretically" it shld look like this

#

im a newbie in css so pls help

#

btw do you know how to update this? like.. idk it aint updating

earnest phoenix
earnest phoenix
rocky hearth
earnest phoenix
rocky hearth
#

and what could be the alternatives?

earnest phoenix
#

Soundcloud

rocky hearth
#

If a thread gets auto archived, and then a mod unarchive it back. Does the members who have joined the thread get reset?

#

Do they have to join again?

azure lark
earnest phoenix
#

Soundcloud has an api

split hazel
#

they really won't care or do anything unless you grow to the size of rythm but yeah

earnest phoenix
#

yeah im gonna grow my bot and cry myself to sleep when it gets banned

earnest phoenix
split hazel
green pebble
#

But y ain't it dotted

split hazel
#

how does postgres differ from mysql/mariadb

#

ive never used postgres

#

apparently its "better" according to the community

earnest phoenix
#

better according to the community is why i hate npm

woeful pike
#

all 3 are good dbs

#

mysql doesn't have any way to seed rows which is really annoying

round cove
split hazel
#

i dont see why people hate oracle so much but anyways mariadb is oss

#

without oracle we wouldnt have a lot of the tools we have today

woeful pike
#

with pg you can generate test data with

insert into your_table
SELECT generate_series(1,100000), 'some value' as column_name
#

I cry every day working on auctions because it doesn't have this lol

split hazel
#

.. nice

#

moving over to postgres now

earnest phoenix
split hazel
#

over 2 billion devices

woeful pike
earnest phoenix
#

You forgot 2020
0 devices running java

spark flint
austere surge
#

just 3

spark flint
#

oh shit yeah

#

probably should have specified (in billions)

earnest phoenix
#

@spark flint why is there just a picture of minified javascript

spark flint
#

blame @royal portal

royal portal
fiery stream
#

Refused to load the image 'https://scontent-bos3-1.cdninstagram.com/thissupposedtobeaimagelink' because it violates the following Content Security Policy directive: "default-src 'self'". Note that 'img-src' was not explicitly set, so 'default-src' is used as a fallback.

#

what causes that error ?

#

i tried googling it and having a hard time understanding what it even means

split hazel
#

bruh can you really do that

fiery stream
split hazel
#

block people from using your images via security policies

fiery stream
#

no-

split hazel
#

yes

fiery stream
#

lol no im making a insta-dp like website n my website is blocking from using images from 3rd party sources

#

using=loading

fiery stream
#

it started happening after i installed flask-talisman cuz i want users to go to https:// by default

#

n apparently it goes the security polices too n which i didnt know how to use/work with

cinder patio
#

omfg why is it so hard to use chakra.ui dynamic sizes with next.js images this shit is taking me hours

earnest phoenix
#

there's nothing you can do because next image has 3 divs forcing your image to be the same size

cinder patio
#

I used the useBreakpointValue hook but that's still not really working properly

earnest phoenix
#

show code

sick agate
stiff lynx
#

Can I forward a message starting from the message.id?

lament rock
#

wdym forward

stiff lynx
quartz kindle
#

if the message still exists, yes

stiff lynx
#

Tim is the person that makes me still believe in humanity

#

how I search for the message?

messageId = id;

#

how can I search for the message?

wheat mesa
#

fetch the message by id

stiff lynx
#

message.fetch(messageId)

#

?

wheat mesa
#

No

#

Look at the docs

stiff lynx
#

.fetch(force)

#

what is this bool force?

cinder patio
#

discord.js usually first looks in the cache to check if the object is there

#

if you set force to true discord.js will ignore the cache

stiff lynx
#

ok, then still don't get how to pass the id as an arg

wheat mesa
#

I don’t know the specific method because I use detritus but I know it’s possible

stiff lynx
#

neither do I

#

lmao

#
  .then(message => console.log(message.content))
  .catch(console.error);```
marble juniper
#

anyone know sql

#
INSERT INTO guilds (id, logs)
VALUES ($1, $2)
ON CONFLICT (id)
DO UPDATE SET logs = $2

is this sql query valid?

#

im just trying to upsert

#

$1 and $2 will be populated with actual values in the code

#

cuz I use node postgres

marble juniper
simple stump
#

If I have a JSON object like this:

{
  'Hello, this has spaces.': 'i have spaces to',
  'ur mom: 'idk'
}

How would I access those objects? I can't necessarily do:

someObject.Hello, this has spaces;
marble juniper
#

in what language

simple stump
#

JavaScript

marble juniper
#

object['key']

simple stump
#

ah. ty

atomic kindle
#

what lib are you using link?

marble juniper
#

im using postgresql

atomic kindle
#

use sequelize or smth

#

it'll make your life easier

marble juniper
#

no

#

it will not

atomic kindle
#

it runs atop the native pg lib

marble juniper
#

I want to use raw sql

#

bruh

#

I don't wanna use an orm

#

just help me with my question or don't

#

don't tell me to go use another lib

#

ur not helping with that

atomic kindle
#

just a suggestion iara_smh

marble juniper
#

will you help me or not

atomic kindle
#

it'll work

#

looks fine to me

#

i'm assuming id is the default auto-incrementing id

sudden geyser
#

id is a parameter: not a value

#

I'm pretty sure what you (Link) wrote is correct.

half bear
#

do interaction button's functions go inactive some time later?

#

i'm doing a registeration system with buttons on a different system that gives user the role (interaction user of command) but i'm worried about that

#

like do i need to store a database for that

cinder patio
#

I don't think they do

stiff dust
#

How can i check that user vote to my bot in top gg?

spark flint
marble juniper
#

since im storing discord guild ids

boreal iron
marble juniper
#

is it ok if I do

UPDATE bot SET scanned = scanned + 1

without using the WHERE clause

#

I only have a single column in the table

#

or do I need to do

UPDATE bot SET scanned = scanned + 1
WHERE id = 1
sudden geyser
#

It's fine without the WHERE, technically.

#

It'll just increment all the values in the scanned column, even though you only have one row.

marble juniper
#

ok

#

ty

sudden geyser
#

Me personally, if you have a table with only one row, it probably doesn't make sense to include it in your database.

marble juniper
#

Well I just store statistics for my bot there

spark flint
#

TypeError: user.kick is not a function

#

discord.js

cinder patio
#

btw, only guild members have a kick method

#

so yeah, you need to get the guild member instead of the user in order to kick them

craggy pine
junior pecan
#

Help me on my bot: can someone tell me how to find a REST API for my bot?

sudden geyser
#

What kind of REST API.

spark flint
#

requirements:

must be a REST API

sudden geyser
#

well if you're nihilistic you may be interested in hypixel's api

junior pecan
#

It's those image links That you can put text or stuff on them just by editing the link. , I can show you what it is if you want

spark flint
junior pecan
#

My bot script is BDscript

junior pecan
split hazel
#

here

junior pecan
#

When I tried to use an api, it gave error

pale vessel
junior pecan
#

Yeah i tried

pale vessel
#

check the endpoint url

azure lark
#

do i need to enable something in the discord developer portal dashboard to allow my bot to play audio inside voice channels?

pale vessel
#

no

#

you just need guild voice states intent in the gateway

azure lark
#

can i just do this then?

const client = new discord.Client({
    intents: allIntents
  });```
earnest phoenix
#

uhhhhh

#
workspace/commands/useful/battle.js:212
await profileModel.findOneAndUpdate({ userID: message.author.id }, { $inc: { gold: coinamount } });
^^^^^
SyntaxError: await is only valid in async functions and the top level bodies of modules
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1032:15)
at Module._compile (node:internal/modules/cjs/loader:1067:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at /workspace/handlers/command.js:20:24
at Array.forEach (<anonymous>)
#

there IS async

hidden gorge
#

const Discord = module.require("discord.js");
const memberModel = require('../../database/welcome')

module.exports = {
  name: "suggest",
  description: "Anything",
  run : async (client, message, args) => {
    const msg = args.join(" ");
    if (!msg) {
      return message.channel.send("Add a suggestion please");
    }
      
     const data = await memberModel.findOne({
        GuildID: message.guild.id,
    })

    if (!data) return;
     const guild = await client.guilds.cache.get(data.GuildID);
    const schannel =  await guild.channels.cache.get(data.ChannelID)
    await message.channel.send(
      `${message.author}, Your Suggestion has been submitted!`
    );

    const embed = new Discord.MessageEmbed()
      .setTitle("New Suggestion")
      .setDescription(`${msg}`)
      .setFooter(`Suggested by ${message.author.tag}`)
      .setColor("RANDOM");
      
     console.log(schannel)

    schannel.send({ embeds: [embed] })
      .then(function (message, str) {
        message.react(":suggestionyes:946209266044370964");
        message.react(":suggestionx:946208906521231420");
      })
      .catch(function () {});
  },
};```
earnest phoenix
#

schannel is undefined

hidden gorge
#

oh ok

boreal iron
earnest phoenix
#

it's in the end

#

and nope, I didn't close async by mistake abov

#

e

#

it's in the end too

boreal iron
#

Well it’s so poorly formatted I can’t see if it’s wrapped in another (sync) function

earnest phoenix
#

idk what happened with this code but since some time, I can't use await in it

boreal iron
#

It your database code wrapped in any other function? Like foreach etc?

earnest phoenix
#

no

#

I think it's not

#

oh wait yeah

#

in a setTimeout

boreal iron
#

Yeah there you go

#

It has to be async too

earnest phoenix
#

ok

boreal iron
#

That’s why proper indentation is so important

earnest phoenix
#

so js setTimeout(function () { to ```js
setTimeout(function async () {

boreal iron
#

lol

earnest phoenix
boreal iron
#

async function

earnest phoenix
#

ok

boreal iron
#

or arrow expressions

#

async () => { …

earnest phoenix
#

too late

#

but will keep it in mind next time

boreal iron
#

Alright

lucid prawn
#
TypeError: interaction.reply is not a function
    at Object.run (/home/runner/mika/commands/Music/bassboost.js:80:32)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
#

I use return client.sendTime(interaction, for message to be a embed

lament rock
#

is the interaction an instance of CommandInteraction

earnest phoenix
#

bruh

#

when finally activated bot after some weeks

#

they keys are repeating and giving error

#

I made it unique

#

and made the bot to firstly check if there's already a key

#

well key or document

sharp saddle
#

can someone tell me why my bot fails to play an audio-live?

#

like, you run the command, after 5 seconds the audio stops

wheat mesa
#

well, any errors?

sharp saddle
#

no

#

just stop.

#

and nothing happens

sterile lantern
#

Is it possible to change what the title says for an alert() function in a website? I want it to say something else for the title (rn it says: Website says:)

pale vessel
#

check the documentation

#

that's not how you provide parameters

#

use https://some-random-api.ml/canvas/youtube-comment?username=$username&var=$var...

lament rock
#

pog. Telk's api

junior pecan
#

Oh

#

Sure i will give a try

junior pecan
#

THANK YOU SO MUCH

pale vessel
neat ingot
#
const channel = interaction.channel;
const collector = channel.createMessageComponentCollector(options);
collector.on('collect', async i => {
    // randomly throws unknown interaction error
    await i.update({content:"stuff"}); 
});

I keep randomly getting unknown interaction errors from code like this. is this incorrect? are failed interaction errors common?

#

note ~ works like 95% of the time

pale vessel
#

does it happen instantly or after 3s?

neat ingot
#

no idea, but the only errors in my log are from unknown interactions lol

pale vessel
#

so it updated late

#

actually no

#

that'd be 15m iirc

wheat mesa
#

@lyric mountain you're the java wizard, you got any idea what causes this? fixed it, it's something weird about package access level not working with multiple classloaders

#

for reference, AstPrinter and Expr.Visitor are both in the same package and have no access specifiers, so it should work in theory

quartz kindle
#

sometimes due to network slowness or slowness in the discord api, you receive them already expired or too close to expiration to respond to them in time

#

this is very common issue when using interaction events via gateway

neat ingot
quartz kindle
#

wdym?

neat ingot
#

like, the button collector event from the collector is the 'interaction' in the cast of the i.update... no?

pale vessel
#

the interaction would be the button interaction

#

you have to respond within 3s or defer it

#

you might want to defer it first

neat ingot
#

but im able to set the timeout for the collector, doesnt that also set the timeout for the interactions potential response time?

#

like, if i make 'wait_s' set to 60, it waits 60 seconds for the interaction

quartz kindle
boreal iron
#

You’re mixing things, once a client has pressed your button you need to respond to API within 3s

quartz kindle
#

the 3 seconds time limit is discord waiting for you

#

it has nothing to do with your code

neat ingot
#

ooooooohhhhhhhhh

boreal iron
#

Doesn’t matter if you reply with a message or defer the response but you have to respond to the API with something within 3s

quartz kindle
#

if discord does not receive any response using that interaction's unique token, it deletes the interaction from their end

boreal iron
#

Or the interaction fails

neat ingot
#

ok ok im following now. so then how would i defer the reply within the collectors on collect event?

#

just i.deferReply() ?

boreal iron
#

If you respond to the interaction by telling the API you will respond later (deferring) you will have time to respond with actual message

#

But you still have to confirm to the API once an interaction happens you’re there and yes you received the event

quartz kindle
#

however, that will not make a difference if you're already using .update() immediately anyway

boreal iron
#

I mean if haven’t any async calls and can respond within the 3s there’s literally no need to defer the response

neat ingot
#

see this is whats got me i think. all my collector does is literally update the interaction right away. surely... if thats all its doing, it wouldnt be able to simply defer the reply either. cause isnt it just a case of my network is too slow in receiving the interaction data to actually respond to it?

#

wouldnt that also happen with the defer?

quartz kindle
#

exactly

neat ingot
quartz kindle
#

you have 3 options, none of them are a real solution

#
  1. complain to discord
  2. use interactions via webhook instead of gateway
  3. check the interaction timestamp and ignore it if its older than 2-3s
boreal iron
#

I mean you should get rid of the collector anyways

#

Interactions have an unique ID you can work with to indentify the action and handle it’s request

neat ingot
boreal iron
#

Any user initiated interaction will trigger the interaction event

neat ingot
#

interactionCreate i assume?

#

so basically your suggesting i could remove the collector for the interaction, and then process the interactions similar to how i would with commands?

#

ie: do some processing there to handle them..

boreal iron
#

In the same you’re dealing with slash commands

#

I’m dealing with it like with slash commands handling the interactions by checking if the unique ID exists in my interaction files and if so execute it’s code

#

I’ve got literally two handlers checking if an interaction is a command or something else then dealing with it like you do with commands

quartz kindle
quartz kindle
#

create a route or subdomain, setup a webserver, and add the url to your discord dev page

#

once you add the url there, you will no longer receive interactionCreate events, you will only receive them via the webserver

neat ingot
#

that'd be better for responding to interactions long after they are sent too i guess

quartz kindle
#

also, the webserver needs to comply will all the discord security crap

#

so you probably want to use a library for it

#

i made one myself, but there are others

neat ingot
#

interesting. so I can basically get my server to get send the interaction webhook data which i can then process from there?

quartz kindle
#

yes

neat ingot
#

that seems like more work than its worth tbh

quartz kindle
#

if your bot needs features that can only work via gateway, its not worth it

#

but if your bot could be moved to interaction-only, it is worth it

boreal iron
#

At the end it doesn’t require an active gateway connection but still needs to be able to receive the requests - it needs to be online anyways

quartz kindle
#

getting rid of the gateway altogether means byebye shards, byebye disconnections and reconections, byebye bloat from events you dont need

boreal iron
neat ingot
#

~ side note: easier than i thought 🙂

quartz kindle
#

well then its not worth it

#

but interactions via websocket are this iffy

#

one thing you could try tho, but its still uncertain, is to have a separate bot with 0 intents

boreal iron
#

iffy?

quartz kindle
#

to receive interactions only

neat ingot
#

iffy - uncertain

boreal iron
#

Oh ok

quartz kindle
boreal iron
#

Yee ty driving pepowot

neat ingot
#

unfortunately going a webhook route isnt viable for this particular bot 😦

#

I will be looking into that though for sure. probably make a small tester bot to check it all out

#

I remember someone in here had setup aws lambdas or something to handle his interactions

#

that seemed pretty nifty 😛

quartz kindle
#

ye

#

webhook interactions can be easily scaled the same way you scale websites

boreal iron
#

The advantage of a gateway connection is that event usually don’t disappear

#

While an offline webserver can not deal with requests and they are probably gone forever

neat ingot
quartz kindle
#

nope, you can scale with node cluster of pm2 cluster for example

neat ingot
quartz kindle
#

and you dont need any special configuration to scale like you do with shards

neat ingot
boreal iron
#

Well the size isn’t an issue but your backend has to respond to the request

neat ingot
#

tbh, i was wondering how i'm going to handle multiple shards with docker

#

like, i dont have it setup to spawn a new container for each shard

quartz kindle
#

one docker or multiple dockers?

neat ingot
#

i use docker-compose to combine multiple docker services under one roof

quartz kindle
#

one docker per shard seems like a very bad idea

neat ingot
#

yea, but all shards in one container is equally poor

#

which is how its setup atm

quartz kindle
#

better than the former

neat ingot
#

should be fine for upto say 3-4 shards, but yea

quartz kindle
#

one docker instance can run multiple prcesses and use multiple cores, can it not?

neat ingot
#

tbf my bot has like 3 servers.. so... not exactly a worry atm 😄

quartz kindle
#

so then there is no need for mroe than one

#

just make one docker that runs multiple things

neat ingot
#

as long as im willing to scale vertically and get more ram etc, yea one container could potentially handle it all at scale

quartz kindle
#

you wont need to scale horizontally unless you hit millions of guilds

boreal iron
#

Still one powerful container wastes less resources on itself than lots of containers

neat ingot
#

there is also some library to improve the sharding for d.js

#

it makes some shards internal and spawns threads and combines methods or something

quartz kindle
#

yes

#

another well known library that does it is kurasuta

#

although its known to have some issues at times

#

a single node process can only ever use 1 cpu core, however a single shard will never fully use one core

#

so you want to get as many shards under one process as a single core can handle

neat ingot
#

yea that makes sense

#

~ I've actually been slowly optimizing various parts of the overall dockerized framework that I use. Hoping to eventually release it for others to use if they wanted 🙂

boreal iron
#

Tbh I don’t think there a perfect way to start at 0 and being able to scale to something larger without optimizing or recoding things

#

Whatever you try to plan or do at some point you expectations are blown up which requires a rethink of your infrastructure and ecosystem and therefore some work, recode etc

lament rock
#

I have all of my gateway cons on one thread and my bot logic on another

#

very responsive

neat ingot
quartz kindle
#

there is a certain point in scaling that you have to give up on performance and focus on stability instead

boreal iron
#

At least cost and efficiency wise

quartz kindle
#

for example, nothing beats a local database, but if you get into horizontal scaling then you will want to exchange performance for availability, adding several databases over the wire, increasing latency and decreasing performance, but retaining availability

neat ingot
#

yea, tbh at my current scale i just want stability. i can easily scale up later as required

quartz kindle
#

focusing too much on availability too early can give you bad performance, focusing too much on performance can give you availability issues at a certain point

earnest phoenix
#
(`Link`)
quartz kindle
#

nice link

earnest phoenix
#

wait i got a question lol

#

im sending it

#
(`Link`)

How do I make that text a working hyperlink?

quartz kindle
#

[name here](link here)

#

only works in embeds

earnest phoenix
#

ok thank you!

earnest phoenix
#

I can't do it in a normal message?

neat ingot
#

[website](http://url "some tooltip text")

coral sigil
dry imp
quartz kindle
earnest phoenix
#

like this is my actual code so far:

client.channels.cache.get(global.config.server.channels.log).send(`Test`)
earnest phoenix
#

or only embeds

dry imp
#

only embeds

quartz kindle
#

only embeds

coral sigil
quartz kindle
#

<link> works for hiding the preview

#

but it doesnt allow you to set a name

coral sigil
#

oh they want to set a name?

earnest phoenix
#

without the link turning into an embed

quartz kindle
#

then yeah, use <link>

austere surge
#

http >:o

quartz kindle
earnest phoenix
#
(`<link>http://google.com/</link`)
neat ingot
#

https:google.com is also valid 🤯

earnest phoenix
#

I can't use the link tag in the `

quartz kindle
#

literally like i showed

#

int he image

earnest phoenix
#

I want my bot to send it 😃

#

not me

#

lmao

coral sigil
#

does this work for suppressing the embeds also?

quartz kindle
#

make it send what i sent lol

coral sigil
#

or is it used for something els

quartz kindle
#
channel.send(`<${url}>`)
earnest phoenix
quartz kindle
#

its a new thing

earnest phoenix
quartz kindle
#

if you have raw text you dont need ${}

spark flint
#

😂 the bot list person again

earnest phoenix
earnest phoenix
quartz kindle
#

no

earnest phoenix
#

I'm so lost 😦

quartz kindle
#

do you understand what string templates are?

earnest phoenix
#

yes, i know what they are

quartz kindle
#

well you are not using them correctly

earnest phoenix
#

they are just literals enclosed in backticks

quartz kindle
#
const variable = "abc";
`some text here plus some ${variable} here`;
#

= some text here plus some abc here

earnest phoenix
#

ohh

#

${}

#
channel.send(`<${{https://universe-list.xyz/server/${guild.id}}>`)
quartz kindle
#

...

earnest phoenix
#

man this is so confusing 😭

boreal iron
#

Look at Tim’s example

quartz kindle
earnest phoenix
#

i thought we need ${} for the whole lin

#

k

neat ingot
#

not to give you the answer, but this is how it should be:

const site = `https://universelist.xyz/server/${guild.id}`;
const link = `[Test](${site} "This will take you to some website")`;
quartz kindle
#

yes but they dont want embeds

#

they just want to hide the url autoembed

boreal iron
#

Hey Tim was there a specific reason you literally told me to fuck off with my process dilemma?
Doesn’t it make sense to be able to reload the code structure without reconnecting to the gateway and database?

quartz kindle
#

i mean

#

its possible

#

but the risk is quite high

earnest phoenix
quartz kindle
#

you risk dirtying your process with bad data basically, leaving things unclosed, memory uncleansed, etc

#

if your code structure is as simple as attaching a required file to an event listener, then yes its easy to do, thats how people reload commands

#

but if you have anything more complex than that, then its suddenly much much harder

boreal iron
#

Hmm so it requires not to mix the child’s data with the master in order to get rid of any data and memory when killing the child process

earnest phoenix
#

found this on stackoverflow. Could I do something like this?

#

in my start file

coral sigil
#

try

quartz kindle
#

you want to remove all embeds from all messages that people send in your server?

boreal iron
earnest phoenix
quartz kindle
#

what you can do tho, if this is a discord connection, is to store the session data and resume

#

however you will still lose all your memory and cache

neat ingot
#

hey btw, ty @quartz kindle && @boreal iron . our earlier discussion was quite insightful 🙂

boreal iron
#

That’s why the idea was that the master holds any active connection and the child sends its request to the master which will handle it

quartz kindle
#

the connection itself or only the connection information?

#

because if the master holds the connections itself, then its the same as running internal sharding, all shards in the same process

boreal iron
#

The master holds the connections not only the information

#

The child will emit an event the master receives with the data the master processes

#

Like an event listener for database calls, gateway calls whatever

#

Or sharing the instances with the child process like I would share (pass) my arguments to a module

#

But that goes a little bit off my experience here

#

That’s why I’m asking

quartz kindle
#

so you have all the discord shards in the master process?

#

and the children are just the command/event processors?

sharp saddle
#

Talking about sharding?

quartz kindle
#

i'll shard you

sharp saddle
quartz kindle
#

btw i finished my websocket benchmarks, and detritus is the slowest lib lul

boreal iron
sharp saddle
#

Should I use discord.js itself for sharding, or do I use some other library for this?

quartz kindle
#

leave the connections in the master

spark flint
sharp saddle
#
spark flint
#

That’s what I use

boreal iron
quartz kindle
#

then youre fine

boreal iron
#

Alright

quartz kindle
#

your child processes should be stateless

#

you should be able to destroy and restart them as you wish

#

unless specific children can only do specific jobs

neat ingot
spark flint
#

It’s a rewrite which isn’t completed yet so idk yet