#development

1 messages Β· Page 1778 of 1

earnest phoenix
#

bro putty terminal

spare badger
#

Linux?

earnest phoenix
#

yes

quartz kindle
#

use nvm

earnest phoenix
#

say full

#

nvm

spare badger
quartz kindle
spare badger
#

nvm allows you to have multiple node versions on your machine

earnest phoenix
#

is node 12 is good for now say

#

node 12 is good now in 2021

lusty quest
#

node 14 adds some nice stuff

#

like optional chaining

quartz kindle
#

node 16 is already out too

near stratus
earnest phoenix
#

becuse node 12 cnt work disocrd button

earnest phoenix
near stratus
earnest phoenix
near stratus
#

discord.js dosen't

vivid fulcrum
#

node 15 has AbortController <33

lusty quest
#

they use one function that requires node 14

quartz kindle
#

node 12 can use buttons, but discord.js requires v14. its a discord.js problem not a node problem

near stratus
#

You can use discord api with plain node-fetch no extra modules needed

earnest phoenix
#

It works. But... I let him react to this message that he sended when i reacted on the message, but then he already sends the message he should say when I react to the 2nd message

earnest phoenix
#

why it not easy

#

npm node version

#

like this

#

@near stratus cb you say how update is i change version in package is it change

#

Like I do. V help (V is my prefix) and then he sends the message u just help me fix, but if I react to this one and he sends the next message, the "answers" from this question already Pop up. @near stratus

#

Even if i didnt react yet

near stratus
#

what you just said I don't understand it at all

tulip knoll
sick agate
#

yup

tulip knoll
#

how to fix that issue :')

near stratus
earnest phoenix
#

wht si new js version

#

i update node

#

done

slender thistle
#

print(__import__("sys").version_info) at the top of your file

earnest phoenix
#

@near stratus I use the same command as the one u just fixed (I did copy and past) but now when I didnt react yet he already sends the messages that will Pop up AFTER i reacted

near stratus
lusty quest
#

current LTS is node 14 the latest is Node 16

earnest phoenix
#

Ok

earnest phoenix
#

bro

lusty quest
#

12 is current version

#

V13 is about to release this month

boreal iron
old cliff
#

Beta geng

near stratus
earnest phoenix
#
npm ERR! notarget No matching version found for yt-search@^4.8.2.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! notarget 
npm ERR! notarget It was specified as a dependency of 'container'
npm ERR! notarget 

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/container/.npm/_logs/2021-06-10T09_55_21_953Z-debug.log```
#

wht this

near stratus
lusty quest
#

i dont use d.js anymore, so i dont really care

earnest phoenix
#

Idk how its littleary the same command as the one that works

old cliff
#

@earnest phoenix tbh use buttons... reactions are getting outdated....

near stratus
# earnest phoenix Yes
message.react('πŸ‘').then(() => message.react('πŸ‘Ž'));

const filter = (reaction, user) => {
    return ['πŸ‘', 'πŸ‘Ž'].includes(reaction.emoji.name) && user.id === message.author.id;
};

message.awaitReactions(filter, { max: 1, time: 60000, errors: ['time'] })
    .then(collected => {
        const reaction = collected.first();
        if (reaction.emoji.name === 'πŸ‘') {
            message.channel.send('Upvote');
        } else {
            message.channel.send('Downvote');
        }
    })
    .catch(collected => {
        message.channel.send('you reacted with neither a thumbs up, nor a thumbs down.');
    });

Try this and say what it says

earnest phoenix
#

Ok

old cliff
#

Beta gang

near stratus
#

wait no
DETRITUS GANG

old cliff
#

Does it still work? Lmao... even the api endpoint is outdated

#

For 11

near stratus
lusty quest
#

V11 is dead dead

lusty quest
boreal iron
#

that’s very dead

old cliff
#

I'd suggest using djs 13 beta... instead of a package

quartz kindle
#

v11 still works with a few mods

old cliff
#

It'll release this month

lusty quest
#

just use Detritus

#

does so much stuff just better

quartz kindle
#

just use D++ :^)

boreal iron
#

Oh no… the infection is spreading

old cliff
#

Already made a wrapper which supports handling normal and slash cmds with same methods

lusty quest
#

but yea, the docs are kinda shite and there are missing geatures

near stratus
# lusty quest there is a npm module for buttons on d.js

I made my own though

class InteractionMessage {
    constructor (client, interaction, readonly){
        this._client = client;
        this._interaction = interaction;
        if(!readonly){
            this._message = { data: {
                type: 4,
                data: {
                    content: "",
                    embeds: [],
                    components: []
                }
            }}
        } else {
            this._message = { data: {
                type: 4,
                data: {
                    flags: 64,
                    content: "",
                    embeds: [],
                    components: []
                }
            }}
        }
    }
    send(){
        this._client.api.interactions(this._interaction.id, this._interaction.token).callback.post(this._message);
    }
    setContent(messageString){
        this._message.data.data.content = messageString;
    }
    addEmbed(embed){
        this._message.data.data.embeds.push(embed);
    }
    addButton(buttonObj){
        let a = 0;
        while(true){
            if(!this._message.data.data.components[a]){
                this._message.data.data.components.push({
                    type: 1,
                    components: []
                });
            }
            if(this._message.data.data.components[a].components.length >= 5){
                a ++;
            }else{
                break;
            }
        }
        if(a >= 5){
            console.log("maximum number of buttons reached");
        }else{
            this._message.data.data.components[a].components.push(buttonObj);
        }
    }
}
lavish bramble
#

How can I make it wildcard

lusty quest
near stratus
lusty quest
#

just use schema.find({},Command:)

earnest phoenix
lavish bramble
lusty quest
near stratus
#

And there's no reaction πŸ‘ on that message ?

earnest phoenix
#

Yes it is

lavish bramble
#

I mean if I send hello then it sends message but if I send hello m then its not

lusty quest
#

are you sure its database related?

lavish bramble
#

Nope

near stratus
lavish bramble
#

Its not related to database

#

πŸ˜…

earnest phoenix
old cliff
#

Wdym?

near stratus
old cliff
#

Just await message.react

earnest phoenix
#

Bc I have like a vote there

old cliff
#

Then make collector

near stratus
#

oh I get it

earnest phoenix
#

So I have to click on it and then he says it

#

And not before

old cliff
#

Can you please explain clearly?

near stratus
#
message.send().then(m => {
    m.react('πŸ‘').then(mm => {
        //add listner
    })
});
old cliff
#

Bot reacts -> User reacts -> bot sends message?

earnest phoenix
#

So I have like 2 Reactions that are Set by the bot. Like πŸ˜‹ and πŸ’© . I want it so I click on it and then he says an message. Not that he sends it before i click on it

earnest phoenix
#

cn any one give me meme api of reddit pls

#

But my bot is like : bot react -> bot message

near stratus
# earnest phoenix Yes

then use this

message.send().then(m => {
    m.react('πŸ‘').then(mm => {
        //add listner
    })
});

earnest phoenix
#

Ok i try

near stratus
#

just add .json in the end

earnest phoenix
#

i use fetch

old cliff
#
await message.react('πŸ‘').then(() => message.react('πŸ‘Ž'));

const filter = (reaction, user) => {
    return ['πŸ‘', 'πŸ‘Ž'].includes(reaction.emoji.name) && user.id === message.author.id;
};

await message.awaitReactions(filter, { max: 1, time: 60000, errors: ['time'] })
    .then(collected => {
        const reaction = collected.first();
        if (reaction.emoji.name === 'πŸ‘') {
            message.channel.send('Upvote');
        } else {
            message.channel.send('Downvote');
        }
    })
    .catch(collected => {
        message.channel.send('you reacted with neither a thumbs up, nor a thumbs down.');
    });```
Try..
near stratus
# earnest phoenix i use fetch

Did I ask ?
I don't care you use fetch, axios or request (dep)
An api is an api
They all work the same way
I won't spoonfeed you some code
Just send a GET request to https://reddit.com/r/memes.json and see what it returns

near stratus
#

huh ?

earnest phoenix
#

this

#

so i ask

old cliff
#

It would work... just try it

earnest phoenix
#

ok bro

near stratus
earnest phoenix
#

no

old cliff
earnest phoenix
near stratus
old cliff
#

use node fetch

#

@near stratus is node fetch in built?

near stratus
# earnest phoenix no

Anyway here are some resources that'll help you get started with APIs and requests

near stratus
boreal iron
near stratus
#

^^ these will help you learn more about APIs and requests

#

Like how to send requests

#

GET POST

earnest phoenix
#

i learn how make meme commmand in yotube but

lavish bramble
#
if(message.content.include("yo")){
    message.channel.send("yo")
  }```
Code is not working
earnest phoenix
#

api cnt work

lavish bramble
old cliff
near stratus
earnest phoenix
#

wait i give my codes say there

near stratus
#

This is how you use an api

earnest phoenix
#

this is meme codes

near stratus
boreal iron
#

Imagine including Discord 2x KEKW

lavish bramble
#
if(message.content.includes("yo")){
    message.channel.send("yo")
  }```
Still not working
earnest phoenix
#

but memes are not good

#

so i ask

near stratus
old cliff
#

The reddit endpoint has a different twmplate

earnest phoenix
old cliff
#

You'll need to change ur code according to its structure

earnest phoenix
#

ok i try

#

bye

old cliff
#

Phew

earnest phoenix
#

if i need ask one thing

earnest phoenix
#

cn i say

lavish bramble
old cliff
#

dont ask to ask

near stratus
boreal iron
earnest phoenix
#

how add download link in image [avtar commmand]

lavish bramble
#

In small

near stratus
#

Edit of the above message

data {
    data {
        children: [
            {
                data: {
                    //All the good things on earth
                }
            }, {
                data: {
                    //All the good things on earth pt2
                }
            }, {
                data: {
                    //All the good things on earth pt 3
                }
            }
        ]
    }
}
earnest phoenix
boreal iron
#

Is the statement inside the right event (on_message)?

near stratus
earnest phoenix
#

hmm

#

pls check carl bot pfp command @near stratus

earnest phoenix
#

and say how add download link

earnest phoenix
lavish bramble
#
const schema = require("./models/custom-command")
client.on("message",  async message => {
  if(message.author.bot) return 
const a = message.content
  if(message.content != ""){
    const data = await schema.findOne({Guild: message.guild.id, Command: message.content})
    if(data) message.channel.send(data.Response)
  } else if(message.content.includes("yo")){
    message.channel.send("yo")
  }
  
})```
boreal iron
near stratus
near stratus
#

you can use it

boreal iron
#

Wrap it in β€œcontent”

earnest phoenix
#

you cnt define command module

#

@lavish bramble

lavish bramble
#

Thats in db

near stratus
earnest phoenix
#

say

near stratus
copper cradle
#

they literally just gave you what you need

earnest phoenix
#

i say for gernal question

#

its download link need to add

boreal iron
near stratus
#

@earnest phoenix

earnest phoenix
#

oh ok

#

this ${Member.user.displayAvatarURL}

#

@near stratus

near stratus
#

not property

earnest phoenix
#

hmm

#

yes

#

ok nothing

#

bye

#

tc

near stratus
#
let av = await User.displayAvatarURL({ size: 512 })
message.reply(`{av}`)
near stratus
boreal iron
#

finally

lavish bramble
earnest phoenix
#

thx @near stratus

boreal iron
#

Your statement is wrapped into other statement.
First check if they are actually true/false
(if you actually get to the include statement)

#

I’m not gonna explain scopes tho

rocky hearth
boreal iron
#

Alright I'm at the PC right now

#
  if(message.content != "")
  {
    const data = await schema.findOne({Guild: message.guild.id, Command: message.content})
    if(data) message.channel.send(data.Response)
  } 
  else if(message.content.includes("yo"))
  {
    message.channel.send("yo")
  }

Ask yourself why includes will never be checked

summer torrent
boreal iron
wide wharf
#

I want to make my bot publish automatically all the messages in my announcement channel, how do I do it?

summer torrent
#

what lib

lavish bramble
#

Its working now

#

Thnx

#

So how can I connect that with db

#

πŸ˜…

boreal iron
#

database is a huge segment

#

you may wanna specify which one

wide wharf
summer torrent
#

message.crosspost()

lavish bramble
boreal iron
#

alright, can't help you with that one

lusty quest
earnest phoenix
#

hello

lavish bramble
lusty quest
#

so it should be a random item from the database?

lavish bramble
#

Like if trigger is yo it says yo but if content is udhdh yo then still it send yo

lusty quest
#

ok

lavish bramble
lusty quest
#

did you have a snippet?

lavish bramble
#

Like?

lusty quest
#

what you got for now?

lavish bramble
#

Well my command is working but not in wildcard

lusty quest
lavish bramble
#
client.on("message", async message => {
  const a = message.content
  if(message.author.bot) return 
  if(message.content.includes(a)){
    const data = await schema.findOne({Guild: message.guild.id,  Command: a})
    if(data) message.channel.send(data.Response)
  }
})```
#

New code

#

But not working

lusty quest
#

yea bcs you check if the message contains the message

boreal iron
#

wtf

#

That's not what I told you.

lusty quest
#

the issue is not database related tho

lavish bramble
#

Now if I send hlo its sending hlo but if I send bro hlo then its not

#

How can I fix this

lusty quest
#

make an array of possible triggers, and check if the message contains any of the triggers

vivid fulcrum
#

wtf are you doing

lavish bramble
boreal iron
#

Oh... you guilds have multiple prefixes and you wanna use all of them.

lusty quest
#

make a schema that lists your triggers in an array, make a schema for each trigger and query all of them with find() then make a array or map from the object you get

#

there are many ways

boreal iron
#

The easiest way to handle this is to loop through ALL guilds you got in the READY event, get their prefixes from the database and cache them into an array.

#

incl. the guild ID as key

lusty quest
#

just call Guildschema.find({})

#

will return all guild docs you have, then just loop over it and map it or push it in an array

boreal iron
#

Well might work, but don't do that every time in the message event

lavish bramble
#

Thnx too all

lusty quest
#

you do this in the ready event, and attach the map or array to the client

#

or export it

#

just dont forget to update it when you get a new Guild

boreal iron
#

As well as if there's a command to edit/add/remove the triggers/prefixes

#

That's why I said to add the guild ID as key

earnest phoenix
feral aspen
#
switch(args[0]) { ... }
#

.. can it be.. this?

earnest phoenix
#

?

feral aspen
#
switch(args[0].toLowerCase()) { ... }
earnest phoenix
#

what are you trying to do

feral aspen
#

Checking args[0] lowercasely.

earnest phoenix
#

all the case statements inside the switch should be lowercase too

feral aspen
#

Example, if someone did !help eCoNoMy

#

Can this be used?

#
switch(args[0].toLowerCase()) { ... }
boreal iron
#

yeah

feral aspen
#

.. but put the cases lowercased?

boreal iron
#

if case "economy"

feral aspen
#

.. like case: "economy"

#

Yes.

#

Alright! πŸ‘

boreal iron
#

Correct.

feral aspen
#

πŸ‘

feral aspen
#

How can I get .guild? .. I want to get the .guild.id.

summer torrent
#

can you access message from MessageReaction

feral aspen
#

Ooo.. yes I can! messageReaction.message.guild.id?

summer torrent
#

yeah

feral aspen
#

Thank you.

vale garden
#

hi

#

does anyone know why this is happening

#
@bot.event
async def on_member_join(member):
  global invites
  inviter = None

  for invite, use in invites.items():
    print(invite, use, invite.uses)
    if invite.uses > use:
      invites.update({invite: invite.uses})
      inviter = invite.inviter
shadow frigate
#

What's more important for a discord bot, memory or CPU?

vale garden
#

i basically have this to check invites on a server

#

but for some reason

#

even when an invite has 10 uses

#

if the invite had only 9 when the bot started, it always shows 9

#

but when i reload the bot, it shows 10 uses

earnest phoenix
#

hello

#

why it cnt work

#

.setColor("RAINBOW")

#

any one say pls

#

RAINBOW is not a valid embed color, if you want a random color, use RANDOM

#

.setColor("RANDOM")

earnest phoenix
#

soory this

#

bro

earnest phoenix
boreal iron
#

Or just use hex codes (ffff00 -> 0xffff00)

earnest phoenix
#

bro i see groovy bot embed

#

it work in role colour embed

boreal iron
#

Well then fetch the role the user has, get it's color and set it as embed color.

earnest phoenix
#

see when i add role it come in role colour

#

when i remove it in default

#

@boreal iron

boreal iron
#

Well then fetch the role the user has, get it's color and set it as embed color.

earnest phoenix
#

how bro

#

i ask that

boreal iron
#

Try yourself and get back in here if it doesn't work

earnest phoenix
pale vessel
#

If you want it to match Discord's color, use member.displayHexColor

#

Discord uses the highest role that has a color set for display

boreal iron
#

One step less... let's blame Voltrex

pale vessel
#

@ npm How

rustic nova
#

ask and wait

pale vessel
#

What library

rustic nova
#

no need to ping mods

pale vessel
#

What library are you using?

boreal iron
#

πŸ€¦β€β™‚οΈ

pale vessel
#

I see

#

I'm afraid I can't help you there, buddy.

boreal iron
#

At least you tried your best.

pale vessel
#

What programming language are you using?

earnest phoenix
#

there are other libraries for python?

pale vessel
#

I'm asking him

slender thistle
#

client.guilds: list[discord.Guild] = [...]

pale vessel
#

It's a question, not a statement.

earnest phoenix
#

No mine was a question

#

I didn't know there was other libraries for python

slender thistle
#

They're not as popular

earnest phoenix
#

makes sense

#

d.py is pretty pog other then te fact I don't know python

slender thistle
#

d.py caching is... not for evetuone

pale vessel
#

Are you sure?

slender thistle
#

everyone

pale vessel
#

I see

#

Seek shivaco's help then

slender thistle
#

client.guilds is a list of discord.Guild objects

earnest phoenix
#

what does flazepe use

slender thistle
#

How do you get length of a list

pale vessel
#

Rose

earnest phoenix
#

Sick

earnest phoenix
pale vessel
#

Discord.js -> Eris -> Discord.js -> Discord.js-light -> Rose

slender thistle
#

Misty plz I'm trying to help people learn topggSob

earnest phoenix
#

I am teaching unow

#

shhh

slender thistle
#

I ain't the one who needs to be taught here

#

angy

earnest phoenix
#

Yes you are

#

python noob

slender thistle
#

Bet I write better Python than you

earnest phoenix
#

Yea right

#
print("Hello world")
#

ez

slender thistle
#

Fucking do this without help

earnest phoenix
#

No thanks

#

Is that a 5D array/list

slender thistle
#

Yes

#

With list comprehensions

earnest phoenix
#

No thanks

slender thistle
#

πŸ˜‚

earnest phoenix
#

I accept defeat

slender thistle
#

I should do 10D just for funsies

earnest phoenix
#

I don't like working with 2D arrays

#

I ain't touching a 5D

earnest phoenix
#

Ikr

#

Detritus bad

cinder patio
#

Does this error look juicy?

#

do you like the formatting?

earnest phoenix
cinder patio
#

bug lol

earnest phoenix
cinder patio
#

thank u thank u

earnest phoenix
cinder patio
#

ty, there's an extra arrow cause when the error is found the position is already at the empty line

earnest phoenix
#

Saw that in your repo as well, really nice

#

Written in Rust PogU

cinder patio
#

As rust fanboys would say: sPeEd

earnest phoenix
#

"I'm speed"

#

Maybe

clear marlin
#

@earnest phoenix wanna crash my bot?

earnest phoenix
#

Maybe

clear marlin
sage bobcat
#

One message removed from a suspended account.

rocky hearth
#

how can I convert all a tags into p tags on a site? from chrome devtools
I want to select and copy, link text.

boreal iron
#

"converting" them, wut?

pale vessel
#

Why Reply?

lavish bramble
#

Thats inline reply

#

Function

quartz kindle
#

why Reply

#

with big R

lavish bramble
#

This

#

The error is cannot read property type 'id'

quartz kindle
#

show full error

boreal iron
#

Guess he wanna send a reply like v13 does

earnest phoenix
#

How can I fetch all users? i am using d.js v12 and i have server members intent i dont have presence intent

boreal iron
#

As the docs says

User to reply to (prefixes the message with a mention, except in DMs)

boreal iron
earnest phoenix
# lavish bramble

If you're willing to reply to a message like that you could easily use <Client>.api if you're not using the master branch

#

Other than that, your error doesn't seem to be occuring there, you may want to show the stacktrace of the error as well

woeful pike
#

cool api key bro

round cove
#

?

boreal iron
lavish bramble
quartz kindle
wide wharf
#

@quartz kindle AYO

#

Help me

#

How do I make my bot auto publish all messages in a certain announcements channel?

summer torrent
#

???

#

did you understand what i sent

wide wharf
summer torrent
#

read it again

wide wharf
summer torrent
#

hmm πŸ€” "I asked how to publish message in announcement channel and someone sent message.crosspost(). What is it? Oh... my answer!"

wide wharf
#

And do I have to put this under something like this?

client.on("message", async message => { 
summer torrent
#

yes

wide wharf
#

k

#

thx

#

lemme try

#
[Pterodactyl Daemon]: Updating process configuration files...
[Pterodactyl Daemon]: Ensuring file permissions are set correctly, this could take a few seconds...
container@pterodactyl~ Server marked as running...
:/home/container$ /usr/local/bin/npm i && /usr/local/bin/node /home/container/${BOT_JS_FILE}
npm WARN IsmailZ@1.0.0 No repository field.

audited 15 packages in 4.889s
found 0 vulnerabilities
``` Console says "Running" but my bot's not online... and it didn't log the ready message
#

@quartz kindle help^^

summer torrent
#

stop pinging tim

#

he is not supposed to help you (or anyone)

lyric mountain
#

not "Bot is running"

wide wharf
boreal iron
#

Just log the events to see what happens.

errant perch
#

lets say my cpu has 4 threads, should i only have 4 shards for my bot?

#

and if i were to have more than 4 shards what would happen?

lyric mountain
#

7 lines of log ain't gonna help much

lavish bramble
#

How can I solve this error

solemn latch
quartz kindle
#

if they start crashing for some reason then you can increase the number of processes. there will be a small performance penalty due to context switching but its usually negligible

earnest phoenix
#

How can I fetch all users? i am using d.js v12 and i have server members intent i dont have presence intent

stable eagle
digital ibex
#

hey, so im a bit confused here... so my ajax isn't working for some reason and idk why.

#
               function sendData() {
                  const xhr = new XMLHttpRequest();
                  xhr.open('POST', '/guilds/<%- id %>/general', true);

                  xhr.onload = function () {
                     if (this.status === 200) {
                        console.log(this.responseText)
                     } else {
                        console.log(this.status);
                     }
                  }

                  const form = document.getElementById('changeData');
                  const data = new FormData(form);

                  xhr.send(data);
               }```
#

if i go to the network tab, it doesn't say the status code but it says in the req payload it has been rendered

#

and in my api, i log req.body and it logs an empty object

vivid fulcrum
#

why not use the fetch api

#

way more modern

#

and easier to work with

digital ibex
#

i cant get that to work wo reloading the page

#

thats the only reason :/

earnest phoenix
vivid fulcrum
#

then just loop through the guilds lol

#

map your guilds to the fetch promise

#

and then await Promise.all(mappedPromises)

#

that'll resolve when all of the fetches finished

earnest phoenix
#

okay i will try thanks

undone rose
#

What's up, guys, I've got a general js question that I've been struggling with. Not quite sure how to do this, but I have an array of objects like this

{
      "postHeight": "5",
      "type": "CL",
      "barb": "None"
}

I also have a search function that allows you to search through these objects to find the right one. There will be hundreds of these objects in the array, so if I want to find one specific object with a postHeight of 6, a type of CL, and a barb of straight, it will find the object where all of those match up, and then push that entire object that matched, to a different array. Easy enough. My main problem is that I want to be able to tell the user, if only objects' postHeight and type match their inputs without barb matching their inputs, that No exact matches found, but there is a match that has the correct postHeight and type, just with an incorrect barb.

I'm not quite sure how I should be going about doing that, though. There could be 15 objects with matching postHeights and 20 with matching types, but I want to find the object with the most amount of matches, and then tell the users exactly which properties match, and which ones dont match their search query.

opal plank
#

it'll do just that

undone rose
#

I just looked into it, doesn't seem to be what I'm looking for

opal plank
#

fuse will fuzzy search through those objects and match them by similarity based on what you provided

#

use the keys field to search for postHeight, type and barb

#

in your case you wont be using fuse for whats its known for: fuzzy string matching

undone rose
#

Yeah but there's going to be more than those three properties in the end, and many of them will just be numbers, so it doesn't seem to me like fuse will be able to properly handle that

opal plank
#

you'll be using it to search proximity through the keys

#

you can specify which options you want to be searched with an array

undone rose
#

Yeah it'd search thru them all

opal plank
#

thats the point

#

fuse can do that

#

use score to see if its a perfect match or not

#

if its not, use the closest result

undone rose
#

how do I tell fuse which number is associated with which property? Example:
I need a postHeight of 20 that is of type CL with no barb, but also has 8 OC, 3 OD, and 4 LP?

opal plank
#

you can pass it as string, it should match it just fine

#

if you need OTHER options, you'd have to run the fuse() again

#

you'd search it one at a time

#

for example

#

postHeight of 20 that is of type CL with no barb

#

this is one

#

this is 2 8 OC

#

this is 3 3 OD

#

you'd narrow it down

undone rose
#

The thing is tho, I need something that would match all of that and more

opal plank
#

you need to do one query at a time, for more precise stuff like that, the best i can think of is a database

undone rose
#

Seems like fuse isn't really well built for that task

#

lol

opal plank
#

i dont think you'll find anything that does that

undone rose
#

I'm not necessarily looking for a package tho

opal plank
#

but if you want proximity, like you initally asked, it'll do the task perfectly

#

like "one of the entries didnt match"

#

but you get the closest one

opal plank
#

fuse will do just what u put there

#

search in all entries, and return the closes of your search

#

that'll fullfill what you mentioned there

undone rose
#

Yeah, and you're right, fuse is good for that

#

My issue is that once I start adding more properties to the object it kinda falls apart

opal plank
#

if you need multiple queries at once, then yeah, you'll need to use fuse along with your own logic code or something else entirely

#

you know what you could use

#

postgres

#

or something sql based

hot sage
#

Ok, so, I don't know if this would work, but could I have a main python file, with the things to run a bot, then a seperate python file with commands?

opal plank
#

SELECT * WHERE (postHeight > 20 OR postHeight = 20) AND CL = "no barb" AND (OC = 8 OR OC = 3)

#

im pretty sure u can run conditions in sequence with parenthesis

hot sage
undone rose
#

Yeah I already use a database, though it's a json one

opal plank
#

dont

#

dont ever use a json database

#

ever

undone rose
#

ig I just need to explain what exactly these objects are better

opal plank
#

period

undone rose
#

json databases are fine for some things

hot sage
opal plank
#

not if u writing on them

#

only if u storing

#

but it looks like you're adding more and more

undone rose
#

They work just fine lol

opal plank
#

"works fine" doesnt mean its fine tho

#

writing bad code in js works fine too, doesnt mean its good

#

but regardless, try postgres for dynamic searches like i mentioned

undone rose
#

They're great for portable and easy to install databases, and it doesn't need to be "good" lol

#

You don't always need everything to perform like a champ

opal plank
#

thats what containers in docker are for

#

dont wanna install stuff? put it in a docker file

undone rose
#

You have a point there, but if it aint broke

#

Been using json dbs for years

#

Obv not for everything, but for smaller stuff yeah

opal plank
#

use sqlite or something light then

#

but for the love of god, dont use json for serious projects

#

evie and i had a whole convo about this

#

speically if u start running into atomic operations

undone rose
#

Its really fine for the data I store

#

Been up for years

#

39k lines

opal plank
#

like i said, "its been working fine" isnt an excuse for a bad practice

#

your point was "easily deployable" database

modest crane
#

json db ew

opal plank
#

use sqlite

undone rose
#

No

#

I hate writing sql

opal plank
#

then use mongo or something else

#

nosql

#

anything that is acid compliant

undone rose
#

Yeah but those are always just more painful to use

safe gyro
#

MariaDB ez

opal plank
#

better than one day waking up to corrupted data

#

all the databases i mentioned are corruption free and acid compliant

#

so theres no chance for corruption

#

also security

undone rose
#

Probably fine, but hundreds/thousands of people have been using my stuff for years and nobody has once gotten their data corrupted

#

and it's not a serious thing, just stores some file info

opal plank
#

you would love murphys law

#

but regardless

boreal iron
#

lmao

opal plank
#

im recommending using postgres for your stuff

#

since it has the capabilites of doing what you need

undone rose
#

This also does

#

My issue isn't the db I use tho

opal plank
#

you clearly missed my point

undone rose
#

Just trying to sort through objects to find what Im looking for

opal plank
#

im recommending the database for what it can do, not cuz im bitching about your json database

#

it can run the queries with the stuff you asked

undone rose
#

I think that code stems from a misunderstanding of what I need (my bad for not being descriptive enough). I can already sort through the data to find matches. My issue is that when it does not find an exact match, I need the object with the highest number of matches, and what exactly did match and did not match. Somebody just answered my question tho with this
You could return an array of objects along with the number of fields that matched the criteria. Then you can sort the array by this count.

opal plank
#

that would fall under what i said before, using fuse along with your own logic

#

for example

undone rose
#

Fuse would really not be good for this

opal plank
#

actually

#

just run a bunch of filter()

#

and check for its length

sudden geyser
#

My issue is that when it does not find an exact match, I need the object with the highest number of matches, and what exactly did match and did not match. Somebody just answered my question tho with this
I read your original and current message (none of that back and forth in between), but it sounds like you should sort the results first (since there's a chance none of them match), then inspect the array from the start (since it's sorted, you can play around with it).

opal plank
#
for(let i = 0; i > queries; i++) {
   let arr = input.filter((obj) => { condition });
   if(!arr.length) return {
     reason: `Could not find match for ${condition}`,
     results: arr, 
   }
}

this should give a rough idea

sudden geyser
#

ew raw loops

opal plank
#

keep filtering your results until it either matches all filters or the array lenght is 0

#

that means your previous filter was the last one matched

#

of course, this is not flawless

#

if it fails on the first search, and there are other objects who matches the other criteria, you'd have to either loop them and somehow map some metadata

#

or use something premade that already matches closest thing possible by what you provided(hence why i was suggesting fuse for each iteration)

thin kettle
#

Hi, anybody got experience with slash commands? (Using discordjs here)

Just trying to output an image via a slash command.

const img = new MessageAttachment(imageBuffer, `some_image.png`);

msg.channel.send("Here's your image", {files: img}); //This works

client.api.interactions(interaction.id, interaction.token).callback.post({
  data: {
    type: 4,
    data: {
      content: text,
      attachments: [img],
    },
  },
}); // This only outputs the text, no image, no error

The send way works completely fine, but the interactions response only outputs the text, not the image.

I believe i'm matching the docs https://discord.com/developers/docs/resources/channel#message-object-message-structure, but must be missing something. Any ideas?

boreal iron
#

attachments: [file]
Don’t see file being defined anywhere
Or is it just a placeholder?

thin kettle
#

Sorry should be img, just wrote up the example code quickly, I am using the right one in my test though. will update the previous message

prime mist
thin kettle
#

Ahhh I did not see that, cheers. Doesn't look like it accepts attachments unfortunately though :/ May have to make do with an embed image instead

boreal iron
#

It does

thin kettle
boreal iron
#

The MessageAttachment() function doesn’t create a valid attachment obj for interactions

#

The obj structure is different than normal attachments

thin kettle
#

You sure? It doesn't list attachments as a valid field for interactions callback, don't see what else I could put it as

boreal iron
#

Oh yeah I see

#

Well then wrap it in an embed

thin kettle
#

Yeah that's the plan, not really what I wanted but doesn't particularly hurt

quartz kindle
#

pretty sure they do support it

#

maybe just not documented

#

i remember an issue about it on their repo

thin kettle
#

If they do then it doesn't work with the typical formatting that channel.send accepts

boreal iron
#

Nope as I said

thin kettle
#

or it's called something other that attachments

boreal iron
#

The structure is different

thin kettle
#

Any reference to that structure?

boreal iron
#

I linked it above

thin kettle
#

That matches what MessageAttachment generates

boreal iron
#

Oh nvm copied the wrong one

#

Err I’m probably wrong

thin kettle
#

oh lol np, will keep digging a bit anyway

boreal iron
#

Yeah just play around with it a bit
Maybe you will find the solution

thin kettle
#

Yeah did for a while, seem to either get it to completely crash, or just output the text

hot sage
#

i dont know what exactly this error means

#

im a bit confused

solemn latch
#

'Bot' object has no attribute 'add_Cog' πŸ‘€

hot sage
#

ok

#

how can i fix that (dont answer thinking out loud lol)

pale vessel
#

add_cog????

copper cradle
hot sage
#

i see

#

ok ty

slender thistle
#

frtfd

#

Fucking read the fucking docs

hot sage
#

chill lol

slender thistle
#

Fuck

#

Ok my eyes hurt so I'm outta here

hot sage
#

wut

opal plank
stuck dawn
#

hey anyone knows why it doesn't read the line 68 and 69? I already put a console.log in the next line and it logs but doesn't update and delete the data (mongoose)

prime mist
#

Do you need to await those?

#

Read the mongoose docs πŸ™‚

stuck dawn
#

oh lol

#

thx

prime mist
#

Wow. I dropped erlpack as a dependency and memory usage went from 30mb -> 4mb.

#

Oh, read that wrong. Dropped to 15mb. Still quite a bit though.

slender wagon
#
https://cdn.jsdelivr.net/gh/user/repo@version/file
#

how can i make it so it pulls the latest version

#

from a file

woeful pike
#

literally on the front page

slender wagon
#

but does jquery have anything to do with that

#

or is it there as an example

woeful pike
#

you're smart enough to figure this one out on your own

slender wagon
#

i no have timeee

#

Dylan shush

#

at least i haven't got hacked yet

#

i just wanted to know if there is a repo@version

#

that could get the latest commit

boreal iron
#

Just don’t include it from an external source.
Download it and include the local file.
That will decrease the loading time of the website.

#

It’s not needed to have the latest version of jQuery at any time since their updates aren’t major changes anyways

earnest phoenix
#

Oouuu

#

I got hacked once πŸ§πŸ½β€β™€οΈ

#

It wasn’t hacked I gave my token away

#

I was stupid then

sudden geyser
#

big brain

earnest phoenix
#

😭I was new

#

They ask for it

#

And Ian know what it was

#

Lmao now I’m pro

snow urchin
#

using nextjs

prime mist
#

Just ask your question πŸ™‚

#

nodemon is for development. You would need something that auto-restarts the bot on failure.

#

pm2 can do restart on failure.

crimson vapor
crystal wigeon
#

Is there discord bot support for elixir? I couldn't find any package for it

prime mist
pale vessel
#

no

opal plank
#

its easier to chat about dev stuff here without general lynching me for talking about detritus

earnest phoenix
#

is it good?

opal plank
#

absolutely

#

i have a wall of text as to why itss great

earnest phoenix
#

πŸ‘€

#

it supports clustering too?

opal plank
#

it does

earnest phoenix
#

damn should i use πŸ€”

opal plank
#

sharding and clustering

#

and built in command handling for both normal commands and slash commands

#

its absolutely a bliss

earnest phoenix
#

woah

#

why isnt it popular?

opal plank
#

cuz its in ts and there arent many docs

slender thistle
earnest phoenix
#

i wasnt reading the npm package it looks great

opal plank
#

let me get you the links

#

if you new to ts/discord developing, look at the last detritus-example
if you're very well experienced in both of them, look at cake's repo

#

i'd personally recommend my example, its much easier to understand

earnest phoenix
#

idk ts

opal plank
#

specially cuz @earnest phoenix tried cake's repo and almost gave up

opal plank
earnest phoenix
#

but i have been learning JS for 6 months

earnest phoenix
opal plank
#

TS is js tho

#

theres barely any learning curve

#

any js code is valid ts code

#

ts is just a way to add types to your objects and variables

#

so you remove pesky bugs right ahead, rather than having them fixed later down the line when the error happens

#

i got a vid if u wanna check it tho

earnest phoenix
#

will do!

opal plank
#

short 2 minute video

#

i'd recommend watching the first 2 minutes of the long one first

earnest phoenix
#

is there any siginificant differences between them?

opal plank
#

it gets the "introduction to ts" a little better

#

the small one is just a quick intro

#

the latter goes into teaching you a bit of the basics

#

it goes a little deeper

earnest phoenix
#

will check those 2 videos out

opal plank
#

but for a "why use ts", its better to watch the first 2 minutes of the long one

earnest phoenix
#

got it, I am just curious though, why do a lot of ppl prefer js of ts or py

opal plank
#

i'd js is more flexible, py is more stable, ts is best of both

#

js is super malleable, it can basically do anything

#

you'd have packages or libraries for basically everything, including frontend

opal plank
#

typescript would make js stable, by enforcing types and removing as many bugs as possible

earnest phoenix
#

i always wondered whats the difference between a library and a long lines of code

opal plank
earnest phoenix
#

I read it

#

Chose not to do it tho

opal plank
opal plank
#

its like typescript

#

you just dont go back

earnest phoenix
#

I did

#

Just couldn't be bothered to fix the errors that ensued

opal plank
#

and what EXACTLY did u dislike about it? i might bring feedback to cake

#

errors that you produced with your own code, tho

earnest phoenix
#

and before you say I did something wrong

earnest phoenix
#

I cloned ur repo

opal plank
earnest phoenix
#

Nah couldn't be bothered

#

lol

opal plank
#

thats what a lot of people do

#

npm is full of packages(modules)

opal plank
earnest phoenix
#

yarn better

#

urs

#

for having error prone code

opal plank
#

you never even told me what error u got

earnest phoenix
#

You weren't even online and it was late for me

#

I couldn't of bothered

opal plank
#

wdym i wasnt online

#

i legit dont sleep

earnest phoenix
#

Cap

opal plank
#

i literally sleep every 2 or 3 days

#

i shit you not

earnest phoenix
#

🧒

opal plank
#

giving up after getting thrown an error

earnest phoenix
#

Not giving up

opal plank
#

already did

earnest phoenix
#

Just not bothering

opal plank
#

giving up

#

dev giving up on obstacle isnt good dev

earnest phoenix
#

That is your opinion

#

Sometimes you just gotta accept defeat where it is

opal plank
#

nah, its a necessary skill

earnest phoenix
#

I happened to do it early on

#

cause I just didn't care about trying a new lib to begin with

opal plank
#

if you want be a dev, you need to know how to handle errors

earnest phoenix
#

I agree

#

on something I care about

#

and wanna spend time on

opal plank
#

thats ur own choice, but dnt call the lib bad cuz of ur laziness and unwillingness to use/learn it

earnest phoenix
#

I am calling it bad as a meme to begin with

quiet pawn
#

random question might sound dumb but does adding like music commands use more ram and/or cpu

opal plank
#

then do /s

earnest phoenix
#

I haven't tried it enough to see if its good or bad

opal plank
#

you cant get sarcasm over a message

earnest phoenix
#

I am sorry your highness

#

I will do better next time

opal plank
opal plank
#

next time just /s

quiet pawn
earnest phoenix
#

I figured you caught on by now tho

#

since I was doing /s in the beginning

opal plank
#

i doubt there are any commands that are heavy, its the actual song itself(aka streaming to the voice chat) thats your biggest concern

#

also making sure to save on data on inactive channels n such

#

but a command shouldnt be heavy, at all

earnest phoenix
#

What even increases ram usage anyway

#

what is ram usage

#

what is ram?

opal plank
#

everything uses ram

#

but its negligible

#

a file containing a function and some logic shouldnt use more than a mb

#

thats on the higher end

earnest phoenix
#

node itself uses like 10

#

doesnt it?

opal plank
#

prob about right

quiet pawn
#

so not much anyways

opal plank
#

i know detritus unloaded uses about 50mb

opal plank
quiet pawn
#

yea

#

ik

earnest phoenix
#

I can't remember how much d.js uses

#

I think it is around 100

quiet pawn
#

only 317 servers and 170k users

earnest phoenix
#

Tho I might of heard wrong

quiet pawn
earnest phoenix
#

Nice

opal plank
#

didnt skills benchmark it?

#

1 sec

#

oh yeah, he did

earnest phoenix
#

I'd click it but I am playing rust rn

#

eh screw it

opal plank
#

check this meme out tho

#

"scalable lib"

earnest phoenix
#

Yes

#

very scalable

#

But the thing is

#

I will use discord.js

#

until I actually need detritus

#

I would rather stick with something I know for now and learn something new later on as I start gaining a use for it

opal plank
#

thats what we call "waste of time" in this bussiness

#

you'd be writing a shitton of code knowing you'd have to change it later down the line with a full rewrite

#

usually you want to do it the exact opposite, and make your bot scalable off the bat

earnest phoenix
#

I mean trying to put out a product with something you don't know is bad practice no?

opal plank
#

not mentioning libs, specifically

#

just in general

#

you dont know either

earnest phoenix
#

Wdym

opal plank
#

have you used d.js thoroughly before?

earnest phoenix
#

I'd say I have used it fairly well yea

opal plank
#

then its fine

#

if you were starting on d.js, lets say, less than 2 weeks

earnest phoenix
#

Seems how I have been using it for a good 2-3 years (still suck dick with it but I have used it a good bit)

opal plank
#

then you're fine

#

your saving grace is that detritus's structures are similar to d.js's

#

otherwise you'd be fucked

earnest phoenix
#

I plan on making a switch to detritus soon I just wanna practice more with it which is what I have been doing on the side or at least trying to.

#

Finals are coming so haven't had a lot of time

opal plank
#

im aware, but im still sad you didnt even bother asking me or cake for help when you "gave up"

earnest phoenix
#

kekw

#

I was going to

#

But I have grown used to being yelled at for now knowing something so basic

#

Credits to d.js server

opal plank
#

you clearly havent seen a good community

earnest phoenix
#

Nah

#

Most lib communities are just outright trash

opal plank
earnest phoenix
#

Im in both

opal plank
#

but you havent talked in either

earnest phoenix
#

I have talked in both

#

At least I think I have

#

can't remember

opal plank
#

not much at all

earnest phoenix
#

I honestly forget I am in the TS server

#

Since I use the coding den a lot

opal plank
earnest phoenix
#

Yea the TS server yet to talk in

#

lol

opal plank
#

you spoke less than 100 messages in detritus server, but you should've seen theres no kink shgaming there

#

you can also check the ts server

#

responses are hella slow tho

#

might take a couple hours to get an answer

earnest phoenix
#

Ye

opal plank
#

my point being, both are friendly

#

so idk what kind of shitholes you've been digging

#

but those are fine

#

DAPI might be a bit of a strech

#

they help, but they can be ruthless a lot of the times

#

want help with detritus or ts? => detritus server
want very hard ts questions with no rush? => ts server
want VERY specific questions with rush? => dapi (but expect it going sour with some name calling)

viscid merlin
earnest phoenix
#

Alrighty

#

I will practice some detritus tmrw

#

It is getting rather late so ima finish some stuff up on rust and head to bed

opal plank
#

enjoy

earnest phoenix
#

ty

copper cradle
#

lmao erwin be slippng ads

long crow
#

Feelin like there work is da bomb

rocky hearth
#

what prettier package is for? coz we there's already an vscode extension there. Then y do we need it

lusty quest
#

its a code formater

lusty quest
earnest phoenix
#

Yea

rocky hearth
lusty quest
rocky hearth
#

do I need it, if I already hv a vsc extenion?

lusty quest
#

if you have it as vsc extension you dont need whatever package you talk about

#

you just have to select it as formater

rocky hearth
#

so the package is useful, when someone dont use vsc right?

lusty quest
#

indirect, the code is usually easier to read when formatted with Prettier

#

bcs you have less rats net like functions, etc

rocky hearth
#

using yarn to install packages, also saves it in cache.
Is this cache is saved globally, or only for that project?

lusty quest
#

idk how yarn handles it, for npm if you add -g its globaly other wise only for the project

rocky hearth
#

Would it be possible to not download huge repeated packages, per folder and decreasing the storage space.
And install the package per folder, but which still uses it from global cache.

lusty quest
#

just install it globaly? you dont need to install it for each project

#

atleast Prettier

#

there is no benefit to have it in the project itself

earnest phoenix
rocky hearth
#

i want to install all my packages in a central location. And it still should hv dependency in my projects

lusty quest
#

there is no real difference in the package if installed global or local, so it should pick it from the cache

boreal iron
#

Anyways you will need to cd to the path you wanna install node modules and run npm in there

#

Which will install the packages in this directory

#

That’s at least how the raw location of the modules is always the same

near stratus
#

fuq npm use deno
no more problems with install

rocky hearth
#

I think u guyz didnt got what I'm trying to convey here.
I hv two react projects for example, they both hv node_modules of size approx 400MB each.
I want a way so these, both projects share the same node_modules and also my future project.
So I don't end up wasting storage space of my pc

#

The only closest thing, I hv found is to use, yarn workspaces

cinder patio
#

How much free storage do you have rn

#

I don' t think 400MB is big a deal, you probably have a 1TB disk

#

you're worrying over nothing

rocky hearth
#

only 10gb FREE, Ihv a ssd of just 128gb. I couldnt update my mac

cinder patio
#

hmmm alright then, either install them globally or have them as sub-modules

rocky hearth
#

installing packages gloabally doesnt create a dependency for my project

cinder patio
#

Well I don't think you can do that

prime mist
# lusty quest atleast Prettier

It is quite good to save it in the project along with husky and lint-staged. It will then make sure contributors to the project use it regardless of editor.

snow urchin
rocky hearth
#

make a empty div, with flex: 1 in between the two footer items

snow urchin
#

brilliant, thanks

prime mist
rocky hearth
#

what it is called actually?

#

Ive created, yarn monorepo and published it to github, which has a bunch of packages. I want to clone one of its package in vsc.
Also there is only one parent repository that Ive published, not sub repos for each package.
So how would I do it? Or is it even possible.

cinder patio
#

Alright regex pros I need to match the filename and the line:col from the following string; C:\Users\MyName\Desktop\test.js:8:39

spare badger
#

I always use some janky javascript for these kinds of things. I will never understand regex πŸ˜‚

boreal iron
#

Just check if it matches or need to catch the values?

spare badger
#
const string = "C:\Users\MyName\Desktop\test.js:8:39";
const filename = string.split('\').reverse()[0].split(':')[0];
const line = string.split('\').reverse()[0].split(':')[1];
const col = string.split('\').reverse()[0].split(':')[2];
#

This is what I would do πŸ˜‚

#

Didn't test this code btw

#

@cinder patio /\

cinder patio
#

ye that's what I usually do too lol, can't be bothered with regex

#

oh by filename I meant the entire path, my bad

spare badger
#

Ah even easier

cinder patio
#

yup just split by :

spare badger
#
const filename = string.split(':')[0];
#

Ah no

spare badger
#

: is also used in C:\

#

So everything is fkd

cinder patio
#

you have to concat arr[0] and arr[1]

boreal iron
#

Oh damn Discord ate my brackets

#

One second

#

Assuming is will be a JS always

cinder patio
#

that returns null

boreal iron
#

You said you need to match it only NOT to catch the groups

cinder patio
#

I need to get em

boreal iron
#

Ahh!

#

That’s a little bit different