#development

1 messages · Page 1923 of 1

earnest phoenix
#

I don't got corona I got jose

boreal iron
#

Don’t wanna stinky feet touching me

#

If that’s your fetish, ok but not for me!

earnest phoenix
#

my feet don't stink so rude

boreal iron
earnest phoenix
#

also its not a fetish of mine thats weird

slender thistle
#

Prove it

earnest phoenix
#

shiv

#

😳

boreal iron
#

Alright time for some sleep

slender thistle
#

Sleep well

boreal iron
#

Feet save and hidden from you!

slender thistle
earnest phoenix
slender thistle
#

Totally not

quartz kindle
#

time for some sleep indeed

#

kthxbai

slender thistle
#

sleep well

quartz kindle
#

likewise my fren

boreal iron
#

bai

#

Ha! See I’m a modern fancy dude, too

slender thistle
#

Keeping up with modern times must be rough for an old man, I know 😂

boreal iron
#

Shhh it’s not about how old you are but how old you feel

earnest phoenix
#

shiv

#

they use php

#

thats not modern times

#

👀

slender thistle
#

I'm a damn retiree

slender thistle
boreal iron
earnest phoenix
#

I dont have feet fetish

#

I have shiv fetish

boreal iron
#

You do! We know it! Stop resisting!

slender thistle
earnest phoenix
#

what am I being arrested or smth

boreal iron
#

Yes jail for you, now!

#

Together with shiv and a Java developer

#

Hardest sentence you can get

earnest phoenix
#

shiv I enjoy

#

and java dev eh

#

they are toleratable

#

now if you put me next to php or js

#

i'd hate it

boreal iron
#

*has thrown his phone away

earnest phoenix
#

lol

#

well I got bot idea ima work on

#

idk how ima bring it into light but who knows

#

time to read discordgo wiki

vivid sage
#

What can I use to make music commands?? BDFD doesn't do music....

#

yes sad

wheat mesa
#

don't use bdfd

vivid sage
#

ahhh ok

wheat mesa
#

simplest solution tbh

vivid sage
#

then what do i useee

wheat mesa
#

a programming language

vivid sage
#

blegh

#

my hand is covered in poppcorn help

wintry ice
#

I get and erro

#

cannot read property Id of undefined

#

@vivid sage can u help

#

:/

vivid sage
#

wut

#

wow

#

the second } doesn't seem to belong... unless you did ( instead of {

#

wait nv,

#

nvm

pale vessel
#

It's not a syntax error, from the looks of it

vivid sage
#

I'm bad at codingggg

pale vessel
#

Maybe client.user is undefined?

#

Log what client is

wintry ice
#

Uhh

#

Should I send whole code? @carmine topaz @pale vessel

vivid sage
#

probably

wheat mesa
#

might've not instantiated a client? maybe

#

doubt it but

#

but yeah send your code

wintry ice
#

Its

wheat mesa
#

What's your server file look like

wintry ice
wheat mesa
#

I don't see any exporting of your client there

wintry ice
#

then at my index I should do const client = new Discord.Client ?

#

@wheat mesa

wheat mesa
#

No...

wintry ice
#

Then

acoustic cave
#

add:
exports.client = client

wheat mesa
#

export your client from that file if you're trying to import it in a different file

acoustic cave
#

to your servers file

wintry ice
#

Leme try

acoustic cave
#

kinda like I have here:


const client = new discord.Client({
   "restRequestTimeout": time.mid,
   "shards": "auto",
   "messageEditHistoryMaxSize": 0,
   "messageCacheLifetime": 30,
   "messageSweepInterval": 90,
   "messageCacheMaxSize": 0
});
const auth = require("./core/auth");

// ---------------
// Event Listener
// ---------------
const events = require("./events");

events.listen(client);
exports.client = client;```
wintry ice
acoustic cave
earnest phoenix
#

I hope you guys know that client exists on a lot of discord.js classes

#

such as message.client

wheat mesa
#

Yes

#

client can be accessed through a lot of objects

delicate shore
#

people are dumb retards to think I am inspect elementing it when I was literally testing my chrome extension

#

they keep dming me

long lagoon
#
 @commands.command(name='select-test')
  async def select_test(self, ctx):
    await ctx.send("We are testing selects!",
    components=
      [Select(placeholder="Choose what you want to see!",
                            options=[
                                SelectOption(
                                    label="Option 1",
                                    value="option1",
                                    description="See option 1",
                                    emoji="😄"
                                ),
                                SelectOption(
                                    label="Option 2",
                                    value="option2",
                                    description="See option 2",
                                    emoji="😄" 
                                ),
                            ])]
                            ) 
    e1 = discord.Embed(title="embed1", description="a really exciting embed")
    e2 = discord.Embed(title="embed2", description="a really exciting embed")

    while True:
      try:  
        event = await self.bot.wait_for("select_option", check=None)

        label = event.component[0].label

        if label == "Option 1":
                    await event.respond(
                        type=InteractionType.ChannelMessageWithSource,
                        ephemeral=True,
                        embed=e1
                    )

        elif label == "Option 2":
                    await event.respond(
                        type=InteractionType.ChannelMessageWithSource,
                        ephemeral=True, 
                        embed=e2
                    )


      except discord.NotFound:
                print("error.")```
#

Getting interaction failed on select menu

#

Any help would be much appreciated

earnest phoenix
#

Hey can u help me in this

app.get('/tv/1', (req, res) => {
    //var li = req.params.li;
    var data={};
    data.titles = [];
    data.links = [];
    
        axios.get(`https://www.topcartoons.tv/cartoon/beast-awake-bottomless-lake`).then(urlResponse =>{
        const $ = cheerio.load(urlResponse.data);
        $('div.entry-title').each((i,element) =>{
            
            const link =  $(element).find('a').attr('src')
            data.links.push(link.trim());
            const title = $(element).find('h3.title').text()
            data.titles.push(title.trim());
            
        });
    })
    .then(() => {
        res.send(data);
    })

})

i am getting error in console

#

what error

#

thats py and you are giving an js code

long lagoon
#

🥲

stable widget
#

hi guys my bot has occur this error how do i solve this

earnest phoenix
#

wait and fix your code

long lagoon
#

I should have mentioned it... It's fine.... Thanks for trying tho

#

Thanks!!!

#

I think this is where it's failing

event = await self.bot.wait_for("select_option", check=None)```
feral nexus
#

why is guild.channels.fetch not a function?

earnest phoenix
#

do <Client>.channels.fetch instead

#

nope

feral nexus
#

no

#

thats not with fetch

#

xd

feral nexus
#

yeah works thxx

#

😉

#

does message.guild.channels.fetch work?

#

cuz its from message.guild?

wheat mesa
#

You wouldn’t need to fetch channels if you have the guild object

#

Just do message.guild.channels.find

feral nexus
#

I did guild.channels.fetch

#

i first fetched the guild

wintry ice
#

@wheat mesa @acoustic cave it gives cannot Read property of null

wheat mesa
#

What’s your code

feral nexus
wheat mesa
#

It doesn’t have to be cached if you have the guild object

#

You’re not getting it from the cache, you’re getting it from the object

wheat mesa
#

Lol

feral nexus
#

ai yeah ty

iron stirrup
#

i went as the guide said but it says my bot is offline in my server and it doesen't reply to my ping

iron stirrup
vital void
iron stirrup
#

wait sorry its client login

#

yea changed that string to the token

vital void
vital void
iron stirrup
#

how do you run a code on atom?

vital void
#

Alt + R ?

iron stirrup
#

still offline

#

lemme recheck everything

wintry ice
iron stirrup
#

not working still 😦

#

const { Client, Intents } = require("discord.js");
const client = new Client({
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES]
});

client.on("ready", () => {
console.log("I am ready!");
});

client.on("messageCreate", (message) => {
if (message.content.startsWith("ping")) {
message.channel.send("pong!");
}
});

client.login("");

#

oh wait

earnest phoenix
#

messageCreate?

split hazel
#

yeah discordjs deprecated the "message" event

earnest phoenix
#

finally

split hazel
#

First time I've seen them deprecate instead of immediately remove like they've done always

#

if they deprecated things it would be a lot easier to update

#

because 1 your bot would still run 2 you can find what's deprecated and fix it easily

earnest phoenix
#

compatibility table looking terrible for a feature every website has

split hazel
#

but no they just give you a giant change log to navigate through and say "here are the changes"

earnest phoenix
#

why not just do

client.channels.get = function (...args) {
  console.warn("client.channels.get is deprecated, use client.channels.cache.get instead")
  return this.cache.get(...args);
}
wintry ice
#

Pls help

terse steppe
#

Show ss

earnest phoenix
#

shouldn't it be app.post

wintry ice
#

Ahh

wintry ice
earnest phoenix
#

its better to not question it for the sake of not losing your brain cells

#

the only thing detritus sucks at is documentation

#

tho that's probably typedoc's fault

#

typedoc just sucks

#

without a parser or whatever

#

it redirects you to / on 404

#

sometimes it redirects when you click a search result

#

how tf is that a non existent page

sly sierra
#

detritus sucks

#

ass

#

anuyways

earnest phoenix
#

is the db on localhost?

#

if it's not mongo(ose) idk what's the problem

#

maybe the db never saved to disk so it gets cleared on restart

#

it's a function so yeah

cinder patio
ruby halo
#

Your life isn't your's If you always care what others think.

earnest phoenix
ruby halo
#

@earnest phoenix Then what channel is this?

earnest phoenix
#

programming and writing code

ruby halo
#

@earnest phoenix See if I can get into the project.

earnest phoenix
#

get into what?

ruby halo
#

Then can I be a part of the project?

earnest phoenix
#

i need someone with brain cells for my "project"

ruby halo
#

Maybe I can help her out a little bit.

earnest phoenix
#

wtf

stiff lynx
#

I'm doing a lockdown command, but when I turn it off, the channel permissions changes and everyone can see it

#

same for lock and unlock command

boreal iron
stiff lynx
raw nest
#

hello guys, quick question. How can I pass f.e. req.body.id from the main function/route to my middleware? Because I can't access it from the middleware and I can't send it as a parameter because it's before req gets defined.

lyric mountain
#

hmmm...middleware?

#

are you dealing with a Promise? if so, await it to extract result

raw nest
#

yes

#

gimme 1 min I maybe got a solution 🤷‍♂️ but noone knows xDD

lyric mountain
#

...just await it

#

let req = await <Promise>

raw nest
#

nah

earnest phoenix
lyric mountain
#

req is inside the promise, so it wont clash

#

or just name is res then

earnest phoenix
raw nest
#

what??

lyric mountain
#

let res = await <Promise>

raw nest
#

I have f.e. this at the beggining of my middleware:

 const validPerm = (perms) => {
    return (res, req, next) => {
        console.log(req.body.token);

And req.body.token doesn't work because it doesn't know req

#

because at the start of the route thing itself app.all("/api/post/role", validPerm(2), function (req, res) { req gets defined later

lyric mountain
#

errr...why u have an arrow function returning an arrow function?

raw nest
#

hmm..

#

wait, how should I do it now?

lyric mountain
#

an arrow function is like a normal function, in ur case perms is whatever is passed to it

#

so when you do (perms) => { (res, req, next) => { ... } } res, req and next are whatever is passed to em

#

in this case, nothing

#

for example

earnest phoenix
#

okeh res before req

cinder patio
lyric mountain
lyric mountain
cinder patio
#

me?

raw nest
#
const validPerm = (perms) => {
    return (req, res, next) => {

        console.log(req.body.token);
        
        const token = req.body.token

        if(token.length > 80) {
            next()
        }

    }
}
earnest phoenix
#

lenght

raw nest
lyric mountain
#

length

#

show where u call the returned function

raw nest
#

yes okay that's just the typing error...

earnest phoenix
raw nest
#

app.all("/api/post/role", validPerm(2), function (req, res) {

lyric mountain
#

ok so, remove next, and it might work now that you've flipped the params

#

at this point, res was the actual req

#

now it's right

raw nest
#

but you need next if it's true

raw nest
lyric mountain
#

does it work now?

raw nest
#

bruh... I feel kinda stupid rn xDDD

#

yes it works..

#

thank you alot guys<333

lyric mountain
#

it was just a flipped param, code913 was the one who first pointed it

raw nest
#

^^ thank you all for you help and time

lyric mountain
#

yw

earnest phoenix
#

So let's say I have this, previously I had it to just check a role if it had it would kick, but on another server which I am a mod on, how would I just change it so it would work as a permission?

#

I know I have it probably written wrong but I only wanted to look something similar as the finished product

lyric mountain
#

this is called POG where I live

#

but well, Member has permissions property, you can use it to check

earnest phoenix
#

Pog as in pogChamp or as in something different

lyric mountain
#

pog as in "Projeto Orientado a Gambiarra"

#

basically, doing things in a weird and improvised way

earnest phoenix
#

as long as it works it's good for me

lyric mountain
#

I wouldn't bet on it

earnest phoenix
#

It worked previously when I only had it for a specific role on my main

#

it doesn't work now because I change that highlighted area because that's what I want to change...

lyric mountain
#

yes, the way you wrote it will probably work

#

but please at least remove that setTimeout

earnest phoenix
#

nah

#

Don't see why

lyric mountain
#

I don't see why you have it at first place

earnest phoenix
#

Because it doesn't send a message into dms?

#

Once the command was written, the person gets kicked and that's it

lyric mountain
#

ever heard of await/then?

earnest phoenix
#

man that's not the problem I came here for...

#

If it works, it works

lyric mountain
#

all it takes is a 1001ms delay to kill ur code

#

which, considering discord, is not that impossible to happen

lyric mountain
#

that rule is a sin against programming

earnest phoenix
#

I didn't come here to get made fun of for what I have written, I am still very new to this, I only do this in my free time.

#

I just wanted to know to what should I change the highlighted area to

tribal crow
#

Hey! How would i reply with attachments in discord.js v13? :)

lyric mountain
#

I aint making fun of you

#

I'm pointing code flaws which WILL get you in trouble later on

#

especially now that node terminates the process on uncatched exceptions

woeful pike
#

I don't even understand the question

tribal crow
#

Xetera?

woeful pike
#

talking about barnis's question

tribal crow
#

Ik

earnest phoenix
#

So I had this previously

#

Which does indeed work

modest maple
#

Yikes

earnest phoenix
#

I wanted to change that section into another thing which would look for a specific permission

wheat mesa
#

async await 😩

woeful pike
#

I imagine you need a database to store what permissions you're looking for

#

you're looking to only be able to kick people with a specific permission that changes from server to server right?

earnest phoenix
#

I only want the command to work for people who have a KICK_MEMBERS permission thru roles

woeful pike
#

does the yellow highlighted part from your last message not work?

errant flax
earnest phoenix
woeful pike
#

oh

earnest phoenix
#

The newer picture I sent does work on my server

#

because it is "attached" to a role

woeful pike
#

probably what slay said then

#

discord / library api specific questions are no fun

earnest phoenix
#

what's wrong now

pale vessel
#

Users don't have permissions

earnest phoenix
pale vessel
#

Members do

earnest phoenix
#

That literally explains absolutely nothing to me

#

I have 3 brain cell max

pale vessel
#

message.author is a user

wheat mesa
#

Author is a User object

earnest phoenix
#

mhm

slender thistle
#

message.author points to the User- fuck offflaze

wheat mesa
#

message.member is a Member object

pale vessel
#

Also, how come you misspelled that but the error's spelling is just fine

earnest phoenix
#

isdgohjdfgo

#

i just fuck

slender thistle
#

We all do

pale vessel
#

I wish I do the same

earnest phoenix
#

i rewrote it XD

#

my england skill 101%

slender thistle
#

It happens

earnest phoenix
#

so basically I only need to change author to member?

pale vessel
#

Yes

slender thistle
#

Give it a try

woeful pike
#

if only you were using a language that showed you whether or not message.member includes the permissions field

earnest phoenix
wheat mesa
#

That’s a simple error

lyric mountain
#

'KICK_MEMBERS'

wheat mesa
#

Does djs not have a permissions enum?

pale vessel
#

Or use Permissions.FLAGS

#

Doesn't really matter

wheat mesa
#

Imo I think the enum is a lot better to use

earnest phoenix
#

I like how it just suicides with a .44 magnum each time i run that command

wheat mesa
#

catch errors

earnest phoenix
#

I mean what

#

now it just works

woeful pike
#

a feeling we can all relate to right now

earnest phoenix
#

yeah i missed the ''

#

Now I wonder why did it not work yesterday

wheat mesa
#

Could’ve used it in dms

lyric mountain
#

well, currently your code is a russian roulette tbh

#

sometimes it'll crash

#

sometimes it'll work

wheat mesa
#

Since in that case message.member would be undefined

earnest phoenix
#

Oh nvm I know why it wouldn't work

#

I just missed a ) on ban command

#

perfect

#

Welp now it does work, massive thank you for everyone who helped

tribal crow
#

How would i reply to a command with an attachment? I tried interaction.reply({ attachments: [attachment] }); since the embeds are sent that way, but it doesnt work :/ Any help is appreciated! :)

earnest phoenix
#

feels like math class once again where everyone is just screaming

wheat mesa
#

Isn’t it files: [file]?

#

I’m probably wrong

tribal crow
#

ill try

lyric mountain
pale vessel
#

It should work, unless they haven't updated it to use form data if there's attachments

wheat mesa
#

Haven’t used djs in a long time so I’m not sure

tribal crow
wheat mesa
#

👍

lyric mountain
#

aaand he ignored, nice

earnest phoenix
#

nah

lyric mountain
#

well, anyway, he'll be back soon

#

oh u there

earnest phoenix
#

could've pinged me ya know

#

then explain me what's different about await and setTimeout in dms so it doesn't flood here

lyric mountain
#

it won't be a flood really, it's very basic

pale vessel
#

Why kick later when you can kick straight away?

lyric mountain
#

dm messages

wheat mesa
#

Await the message being sent, then kick the user

#

Makes it a lot easier

lyric mountain
#

in ur case, u want to send a message THEN kick, all u need to do is wait previous action to finish

#

send, kick, whatever are async actions

#

that means they're processed in parallel to current execution

modern birch
#

guyz where do i report for problems ?

wheat mesa
#

If you use settimeout then there’s a chance that discord takes a long time to respond and it could error

pale vessel
lyric mountain
#

so it could finish before or after you reach the kick action

modern birch
#

cg vote didnt wrk for me thats why

pale vessel
lyric mountain
#

all u need to do is await <action>

modern birch
lyric mountain
#

that guarantees the code will wait for the action to finish before moving on

wheat mesa
#

(And make your function async)

lyric mountain
#

ye, that too

earnest phoenix
#

now I literally have no fucking clue what to change and what to do

wheat mesa
#

Async just allows you to use await afaik

earnest phoenix
#

it does things probably

pale vessel
#

Ahhhhhh let's just confuse the heck out of them

wheat mesa
#

And allows you to await the call of the function

lyric mountain
#

basically flag it as "don't process in main thread"

wheat mesa
#

No point in using async if you don’t need it

lyric mountain
#

js doesn't have actual threads, it probably wouldn't matter

earnest phoenix
#

i think brain become mush

lyric mountain
#

but dont flag it without necessity

lyric mountain
wheat mesa
#

Basically you just need to await the sending of the message

earnest phoenix
#

Nothing the problem now Wass, kuuhaku is trying to explain to me that I should use await instead of setTimeout

wheat mesa
#

And then kick the user

earnest phoenix
#

so this small part

wheat mesa
#

await waits for the line to be executed before going on

slender thistle
#

Can y'all stop talking over each other first

earnest phoenix
slender thistle
#

You're doing the opposite of helping

pale vessel
#

Won't even work because the timeout's function isn't async

#

Anyway, just stop

wheat mesa
#

It would still work, he’s adding await to the send line, not the kick

pale vessel
#

Ah sorry I was looking at kick method, not send

#

But I don't see a point in confusing them

earnest phoenix
#

wat

#

what is this 200 iq+ people talk

wheat mesa
#

I’ll let someone else explain this without interrupting this time, sorry

earnest phoenix
#

Like this or an extra line?

feral nexus
#

why would you do await user.send?

earnest phoenix
#

no clue

#

that's what I was said to do

feral nexus
#

Like u dont get a promise back

#

if u wanna catch it

wheat mesa
#

Trust the process

pale vessel
#

Because you want to send a DM before kicking them (you can't send DMs on a user after they are kicked unless you share same servers)

cinder patio
earnest phoenix
#

It literally now sends that message, deletes the bread.kick command and kicks the person...

feral nexus
pale vessel
#

If you don't await it, it can go in any order

feral nexus
#

and the kick has 1s delay

pale vessel
#

That's 1s

wheat mesa
pale vessel
#

:|

#

Suit yourself my man

earnest phoenix
#

It literally works like that right now Waffle

feral nexus
#

😂

earnest phoenix
#

IT LITERALLY WORKS LIKE THAT RIGHT NOW

feral nexus
#

ok

wheat mesa
#

I know

feral nexus
#

both

#

😂

wheat mesa
#

But as Kuuhaku said your code was a Russian roulette before the await

#

If discord took longer than 1000ms to send your message to the user (a very real possibility) then your code would error

#

Because after 1000ms you would kick the user and then it would message the user which wouldn’t be possible at that point

earnest phoenix
#

oh so basically now it's guaranteed to stop for a bit before doing the next bit?

wheat mesa
#

That’s why we’re helping

#

Yeah

earnest phoenix
#

That explanation I just sent was more clear than any of you have said

#

im sorry but my brain is now complete mush

wheat mesa
#

I did say that I believe Thonk

earnest phoenix
#

I seriously appreciate the help 😄

#

now to test it

feral nexus
#

like if someone dm is closed, you cant send him the message.

#

Then u get a err

earnest phoenix
#

eh?

#

now you fucked my brain up even more

#

good job

feral nexus
#

😂

pale vessel
#

"Hey, await this! Await that! Oh, catch the error too? Nah."

earnest phoenix
#

"no"

feral nexus
#

why the fuck use a await

earnest phoenix
#

I DON'T KNOW

#

AAAAAAAAAAAA

feral nexus
#

just use a .catch and a .then

feral nexus
wheat mesa
#

I don’t believe that this is helping

earnest phoenix
#

.catch("these hands")

pale vessel
#

Look, spaghettis are great but not when it's in your code

earnest phoenix
#

yeah fuck this im going for a piss

wheat mesa
#

Then it’s just a hearty meal

lyric mountain
#

there, finished my example

wheat mesa
#

I should make a detritus example repo

lyric mountain
#

note how A got printed after B even though it's earlier on the code

slender thistle
#

@earnest phoenix I would suggest reading up on JS promises

#

Like, take a small step back and just read up on them

#

Take it a bit slower

earnest phoenix
#

I'll probably never to that but cheers might have to

wheat mesa
#

I highly doubt your bot is only using 16mb of ram Thonk

#

Takes more than that to even run a gateway connection

#

(On node at least)

lyric mountain
#

basically this is what happens when you use a promise, a new branch is created so you don't have a sequence anymore

wheat mesa
#

I feel like you’re not measuring the right statistic

#

Because that doesn’t seem right

#

Especially on djs

#

Well that’s why

#

Use rss

lyric mountain
wheat mesa
#

That’s how much space is allocated for your process on the ram

#

Resident stack size

lyric mountain
#

it's a fundamental feature that's used in pretty much anything

#

notably channel.send

earnest phoenix
#

i literally only wanted it to send BREAD PICTURES but somehow came across with making other stuff...

wheat mesa
#

Like my heapUsed is 50mb rn but the rss is 130mb

#

Although I’m not sure why my ram usage is so high

lyric mountain
#

pre-allocated space maybe?

wheat mesa
#

I do cache channels which I don’t need to do so I should probably get rid of that

#

but only like 400-500 channels cached

#

I don’t use channels in the cache

#

The only cache I use is my own prefix cache

#

That’s a problem to solve later though

lyric mountain
#

a crab

tribal crow
#

With slashcommands (interaction.), is it possible to send a message without replying?

boreal iron
#

Sure

lyric mountain
#

ye, you can get the channel where the event happened

boreal iron
#

interaction has the property channel

#

You can simply use it send a message

#

interaction.channel.send()

#

You can still mention the interaction.user.id

tribal crow
#

ah

boreal iron
#

If you like to

tribal crow
#

ty

urban moon
#
How to take input as image from user?
quartz kindle
#

you have to get the image url and download it with requests or another http lib

earnest phoenix
lyric mountain
#

```
message
```

#

you can also use language highlighting in it

earnest phoenix
#
Hm try

earnest phoenix
earnest phoenix
#
const message = "webi wabo";
console.log("%c " + message, "color: blue");
tribal crow
#

bruh

#

i am server owner and it says i dont have permission to ban :(

#
         const noPermEmbed = new MessageEmbed()
             .setTitle(`Error! You don\'t have permission to use this command!`)
             .setColor("RED")
         interaction.reply({ embeds: [noPermEmbed] });
         return;
}```
lament rock
#

That checks all roles for if they have ADMINISTRATOR. Owners don't explicitly have ADMINISTRATOR perms and only have it implicitly. You have to check if guild.ownerId === interaction.member.id

tribal crow
#

administrator was just an example

#

i tried MANAGE_GUILD which i know my role has

willow mirage
#

anyone know nextjs?

eternal osprey
#

how would i scrape the nft's from this site? (their market volume). I tried network tab, tried inspect element etc, but it seems unscrapable.
https://www.flownft.co/market

The best place to analyze, track and discover NFTs. Real time digital asset tracking to help you to navigate NFT markets with transparency and confidence.

quartz kindle
#

https://nonfungible.com/api/v4/market/history?filter=%5B%7B%22id%22%3A%22blockTimestamp%22%2C%22value%22%3A%5B%222021-11-09T18%3A48%3A10.230Z%22%5D%7D%5D&internal=true&length=10&sort=%5B%7B%22id%22%3A%22usdPrice%22%2C%22desc%22%3Atrue%7D%5D

lament rock
eternal osprey
#

hmmm wait really

eternal osprey
#

does the link autoamtically change info? Or does the link change each day?

#

with other words, if i would request a get request to that link you sent, would that output the right info each day (so it doesn't stay static as the link has changed or anything)

split hazel
#

i've never heard the word nfts until the discord controversy

#

then everyone starts using it

#

its like that with every word i dont know

spark flint
eternal osprey
#

i also just discovered i tbh

lyric mountain
boreal iron
#

Back to feet fetish discussion?

eternal osprey
#

one last qeustion before i fuck off:

#

let result = body
how do i convert the body buffer into an array?

split hazel
#

are nfts like bitcoin

#

things that have "money value" that dont exist?

eternal osprey
#

I tried using [...body] but it still logged the buffer

eternal osprey
#

even w/o paying for it

#

it keeps fuckin returnin me a buffer

lyric mountain
#

can't u just create a string from it?

#

like, new String(buf) nvm, read below

eternal osprey
#

I know i can use toString, but is there a way to make it an array?

#

Like should i manually push it to an arary?

lyric mountain
#

I mean, why make it an array?

#

it's meaningless unless converted to the original format

eternal osprey
#

as i need to get the info from it

#

success":true,"data":{"sales":[{"name":"goatz","sales":[{"blockchain":"ethereum","transactionHash":"0x3fd23f939a512e8de3444fe5d441e3a60c9c5c6d277ed65475d5e31c33913b4c","blockNumber":13600544,"blockTimestamp":"2021-11-12T09:32:34.000Z","assetId":"1837","project":"boredapeclub","nftAddress":"0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d","nftTicker":"BAYC","marketAddress":"0x0159c7f6cc9e28fdb1b6b127a371d5118af931b5","usdPrice":1573335.09,"tokenAddress":"0x0000000000000000000000000000000000000000","tokenTicker":"ETH","totalPrice":"333000000000000000000","totalDecimalPrice":333,"feeUSDPrice":78666.75449999998,"feeTotalPrice":"16650000000000000000","feeTotalDecimalPrice":16.65,"feeCollectors":it's in such form. So i don't want to stringify it as i need it in an array to get those info's .

quartz kindle
#

you need to json parse it

#

json parse supports buffers

#

JSON.parse(body)

#

although converting it to string yourself is actually slightly faster

eternal osprey
#

aha. Tim always knows the anwers. Thank you!

quartz kindle
#

JSON.parse(body.toString())

lyric mountain
#

it represents the characters themselves

simple stump
#

I’m trying to delete a message that was sent, but if a message gets deleted the bot crashes since the message returns undefined. However, adding:
if (!message) doesn’t fix the issue. How would I check if the message I’m trying to delete is undefined or not?

wheat mesa
#

Should work fine, are you sure you’re passing in the right message? Have you named some other variable message as well?

simple stump
#

There’s only 1 variable name msg

wheat mesa
#

Can you send your code from before that?

simple stump
#

Aight

wheat mesa
#

Log message again

#

Why would message be undefined in the first place Thonk

#

Even after deletion, message would not be undefined. You should check if the message has been deleted before trying to delete it

simple stump
wheat mesa
#

No, that wouldn’t change anything

#

You can’t make it constant either

simple stump
#

Aight I’ll test it

#

Or I mean log message lol

wheat mesa
#

Well, I guess you can by making a new variable

simple stump
#

Yea that’s what I mean idk

wheat mesa
#

Check if(message.deleted)

#

Before trying to delete

simple stump
#

Huh message logs fine

wheat mesa
#

Because it isn’t going to be undefined

simple stump
simple stump
wheat mesa
#

Brb

simple stump
#

Alr np

#

Adding if (message.deleted) worked! Thanks

tardy hornet
#

it shows the servers that a shard is looking at

#

how can i fix that?

quartz kindle
#

send the server count with the shard id

slender wagon
#

Is there a way to solve the interaction failed issue cuz of ratelimits

spark flint
#

@idle coral there is an indent

#

It needs to line up with responses

idle coral
#

oh?

#

oh shit yeah]

idle coral
#

Command

spark flint
#

Alr

#

whats the issue?

idle coral
#

I typed the command, and no response.

spark flint
#

i see

idle coral
#

The issue:

spark flint
#

@client.command()

#

you missed the parenthesis

idle coral
#

wait

#

oh

wheat mesa
#

python moment

idle coral
#

god dammit

#

WHAT THE FUCK

#

I am so sorry bro

#

My vision today

spark flint
#

lmao

wheat mesa
spark flint
#

i get that all the time

idle coral
#

I'm so sorry to bother lmao

wheat mesa
#

ellipses is ...

spark flint
idle coral
#

I need a nap-

wheat mesa
#

English is cringe

idle coral
#

I feel like a dumbass

idle coral
#

Yo @spark flint need MORE assistance..

So I am trying to make a clear command.

#

It wouldn't work, and the errors were:

plain talon
#

You have to provide a limit

#

Afaik you can only do up to 100 messages at a time with the API

rustic nova
fresh bluff
#

How do I make my bots status streaming?

slender thistle
spark flint
#

Make sure limit is defined

quaint wasp
#

hey

#

When I make a random number

#

and want it to repeat smth like.. idk

#

lets say O

#

and I got 15

#

how do I place O 15 times ?

#

ping in replies

earnest phoenix
quaint wasp
#

idk why but.. they cant

earnest phoenix
#

Why not though? Here’s the full error

File "/home/pi/.local/lib/python3.7/site-packages/aiohttp/connector.py", line 975, in _wrap_create_connection
raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host discord.com:443 ssl:default [None]

quaint wasp
#

Maybe ask them to check their wifi?

earnest phoenix
#

Okay

boreal iron
#

port 443 opened up?

earnest phoenix
#

?

quaint wasp
earnest phoenix
quaint wasp
#

?

#

what do you mean?

earnest phoenix
#

Just use loops if you want to get a message a certain amount of times

quaint wasp
#

nah nah im not doing it with discord.js

#

I am doing an API and am trying to replace a NUMBER witha STRING

earnest phoenix
#

Oh okay

quaint wasp
#

kinda forgot javascript in past few months..

earnest phoenix
#

Rip

sacred aurora
quaint wasp
#

yep

hybrid cargo
#

<string>.repeat(count)

sacred aurora
#

You can just .repeat

quaint wasp
#

thanks

sacred aurora
pale vessel
#

that's after 15m

feral nexus
#

If u look in the error its wanting to post some think and it cant.

#

Do u want to change the post?

earnest phoenix
#

why do node docs tell you to asynchronously import("crypto") in esm instead of import { stuff } from "crypto"?

vestal gate
# fresh bluff How do I make my bots status streaming?

If it's in python and has to be done in a command

import discord
from discord.ext import commands

bot = commands.Bot(command_prefix=",")

@bot.command()
async def stream(ctx, *, message_to_stream):
    stream = discord.Streaming(
        name=message_to_stream,
        url=stream_url, 
    )
    await bot.change_presence(activity=stream) 

bot.run("YOUR-BOT-TOKEN")  ```
#

If it has to be done when the bot starts

import discord

bot = discord.Client()

@bot.event
async def on_ready():
    stream = discord.Streaming(
        name=message_to_stream,
        url=stream_url, 
    )
    await bot.change_presence(activity=stream)

bot.run("YOUR-BOT-TOKEN")```
slender thistle
#

🥄

lament rock
#

Aren't rate limits for interaction per interaction and not some global route? amandathink

#

You might be having some serious issues

stiff lynx
#

const channel = interaction.guild.channel.cache.get(target.id);

#

what should I use? fetch instead of cache?

nova basin
#
/home/runner/jhgfrftgyhvfbqheinjsbdiquhiznjd/node_modules/discord.js/src/rest/RequestHandler.js:93
        throw new HTTPError(error.message, error.constructor.name, error.status, request.method, request.path);
              ^

HTTPError [AbortError]: The user aborted a request.
    at RequestHandler.execute (/home/runner/jhgfryioqsminfbqheinjsbdiquhiznjd/node_modules/discord.js/src/rest/RequestHandler.js:93:15)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async RequestHandler.push (/home/runner/jhgfrftgnfbqheinjsbdiquhiznjd/node_modules/discord.js/src/rest/RequestHandler.js:39:14) {
  code: 500,
  method: 'patch',
  path: '/channels/864910356584202270/messages/910487644369190912'
}
#

help me pls

idle coral
spark flint
#

send a ss of your code

#

or the code

idle coral
#

ima cnp it

#
@client.command()
async def clear(ctx, limit:int):
        await ctx.channel.purge(limit-amount)
spark flint
#

why amount

idle coral
#

Okay..

spark flint
#

just await ctx.channel.purge(limit)

idle coral
#

ok

#

Okay let me test it.

spark flint
#

alr

idle coral
#

@spark flint

spark flint
#

hi

idle coral
#

I can't clear anything.

spark flint
#

ah

idle coral
#

*?

#

I should put the star

#

For input?

spark flint
#

oh i knmow

#

await ctx.channel.purge(limit=limit)

idle coral
#

ok

#

lemme try that

spark flint
#

ok

idle coral
#

Dude I'm really sorry

boreal iron
idle coral
#

But I forgot how to do the admin thing.

spark flint
#

make it admin only?

idle coral
#

if message.author.top_role.permissions.administrator

spark flint
#

no

idle coral
#

Oh?

spark flint
#

@commands.has_permissions(administrator=True)

idle coral
#

How would I do it then?

spark flint
#

add that under @client.command()

idle coral
#

Okay

spark flint
#

Then you just need to add error handling

idle coral
#

Error handling?

spark flint
#

if user doesn't have permissions then return an error

idle coral
#

So

#

If =false then?

spark flint
#

no

idle coral
#

exept

#

lol sorry I am a newbie

spark flint
#
@clean.error
async def command_error(ctx, error):
    if isinstance(error, commands.MissingPermissions):
        await ctx.send("You cant do that!")```
#

thats all i'll give

idle coral
#

Where shall I put that though

spark flint
#

anywhere in the code

idle coral
#

I am not used to coding this way

#

I always did if msg.startswith("")

spark flint
#

oh yeah i hate that

idle coral
#

So this is all new to me.

idle coral
#

Just a mess

#

And just a very basic, beginner, easy way of coding.

spark flint
#

yep

idle coral
#

Undefined name clean

#

import clean nvm

#

God dammit.

#

@spark flint

Traceback (most recent call last):
  File "main.py", line 110, in <module>
    @clean.error
AttributeError: module 'clean' has no attribute 'error'
#

I got an error,

spark flint
#

do you have a module called clean?

idle coral
#

yes I do

spark flint
#

thats why

idle coral
spark flint
#

alr lemme just code something

idle coral
#

Should I not have clean in there?

#

I am really sorry to bother, sometimes I tend to be annoying.

spark flint
#

put that instead

spark flint
idle coral
#

okay

#

So shall I delete import clean?

spark flint
#

nope

idle coral
#

Okay

spark flint
#
@client.event
async def on_command_error(ctx, error):
    if isinstance(error, commands.MissingPermissions):
        await ctx.send("You cant do that!") 
    else:
        print(error)```
idle coral
#

okay

#

Sick!

#

Thank you bro, it works.

#

I'll probably be back again.

hybrid cargo
spark flint
spark flint
idle coral
#

I kinda want to try and make it say "number of messages purged has been cleared."

#

I know how to do that

#

I think

#
        await ctx.send(f'{limit} messages have been cleared.')
spark flint
#

then add ```py
await ctx.reply(f"{limit} messages has been cleared``")

idle coral
#

I know bro.

spark flint
#

yep

idle coral
#

Thanks though.

#

atleast I got it

#

without assistance

#

Yet I put two awaits..

#

Is that okay?

spark flint
#

should work

delicate shore
#
function executeScript(tabId) {
  chrome.tabs.executeScript({
    target: { tabId },
    files: ["script.js"],
  });
}

My code for Mozilla Firefox extension

#

this works flawlessly in chrome

#

I get this error

wheat mesa
#

Perhaps it works well in chrome because it looks like it’s using a chrome api of some sort...

delicate shore
#

I figured it out

#

I never read Mozilla docs

tepid crane
#

anyone guide me how to shard using mangodb ??

delicate shore
high crown
#

guys

#

is there any way to print bot cache

#

in megabytes

#

?

lyric mountain
#

don't think so

#

but u can print the used space

high crown
delicate shore
#

just print the bot cache

lyric mountain
#

[[object Object], [object Object], [object Object], [object Object], [object Object], [object Object], [object Object]]

high crown
#

it would reply null

#

or invalid

delicate shore
#

ya me dumb

high crown
lyric mountain
#

u can't really retrieve the space used by a collection at all due to runtime optimizations

#

I mean, you can estimate, but not get the absolute value

high crown
#

yes

#

I can get the cpu tough

lyric mountain
#

different stuff

high crown
#

yos yos

lyric mountain
#

a thing u can do is, right after u start the bot save current used rss to a global var

#

then when retrieving used space subtract that value as an offset

#

the resulting value will be the total used space - initial usage

high crown
#

ohhhhhh

#

why don't I get these thoughts

lyric mountain
#

do that right after starting tho, not on ready event

high crown
#

okay

#

thanks man

lyric mountain
#

np

quartz kindle
#

just log the heapUsed

#

90% of that will be the bot cache, unless you store other things

lyric mountain
#

removing the initial load will get u closer to actual size

#

also ain't it better to use rss instead of heapUsed?

boreal iron
#

Sure it's just an object, not more

lyric mountain
#

the magic of OOP

#

reuse, reduce, recycle

boreal iron
lyric mountain
#

where are u calling that require?

delicate zephyr
#

he figured it out

#

lol

lyric mountain
#

ah, didn't see that

boreal iron
#

messages to brazil... ping 200k ms

tribal crow
#

Hey! I wanna make a mute command for my bot, but i cannot figure out how i get/fetch/map/whatever all the roles a member has. Does any of you know how? :)

lyric mountain
#

the member object has all the current roles

#

user can't have roles at all

wheat mesa
#

What I usually do is make an array of strings, push to that array based on conditions, and then join that array by newlines in the final embed

tribal crow
lyric mountain
#

you might need to fetch before depending on whether the lib does that for u or not

#

but that'd be a simple .fetch after roles

tribal crow
#

ait

#

interaction.member.roles.fetch like that?

lyric mountain
#

I guess so

#

check the docs to be sure

tribal crow
#

returns undefined

#

TypeError: interaction.member.roles.fetch is not a function

#

i have checked the docs, all i find is rolemanager

lyric mountain
#

ya, no need to fetch

#

it already returns the whole list

tribal crow
#

uhm

blissful bridge
#

e

tribal crow
#

Returns the longest array/object i've ever seen.

boreal iron
#

Guess you never saw the data being provided with the ready event

tribal crow
#

huh?

#

nvm i just realised i dont need to do this :)

delicate shore
#

ok

tardy hornet
#
 bot2.shard.fetchClientValues('guilds.cache.size')
        .then(results => {
        message.author.send(`guilds: ${results.reduce((acc, guildCount) => acc + guildCount, 0)`)
    })

i have that code but it only shows some of the servers the bot is watching, not all

lyric mountain
#

cache is never equal to the total count

#

I mean, it shouldn't at least

quartz kindle
#

how many are there in total? how many does it show?

tardy hornet
quartz kindle
#

how do you know its 710?

spark flint
#

its caching deleted bot farm servers

tardy hornet
undone carbon
#

Hi, my testing bot generates all kinds of errors but some of them cause the bot to restart. Is there a way to catch these errors without specifically doing try-catch for every function? I mean like in a general way

quartz kindle
#

the invite page uses an approximate number, not a real number

tardy hornet
#

then how can i know in how many it actually is?

spark flint
#

how you are currently doing so

#

706 is close enough

quartz kindle
#

pretty sure 706 is the correct number

spark flint
#

yep

#

mine says 154 on invite page but is actually in 151

#

its because discord deleted 3 of the bot farms it was in

quartz kindle
#

mine shows 9540 in the invite page

#

but its in 9536 servers

#

the bigger the bot, the more approximate it will be

#

for example, for a very big bot it may show 1245000 in the invite page

#

thats way too rounded to be true

delicate shore
#
function executeScript(tabId) {
  chrome.tabs.executeScript({
    tabId:  parseInt(tabId) ,
    file: "script.js",
  });
}
#

Literally in the docs

quartz kindle
#

this is what it shows up for dyno lol, no way that number is true, its a super approximation

spark flint
#

yup

earnest phoenix
#

any clue?

quartz kindle
slender thistle
#

"figure it out"

earnest phoenix
quartz kindle
#

lol

earnest phoenix
#

its too obv

delicate shore
#

wait

#

holy shit

#

it should be ```js
function executeScript(tabId) {
chrome.tabs.executeScript(parseInt(tabId),{
file: "script.js",
});
}

#
function executeScript(tabId) {
  chrome.tabs.executeScript(parseInt(tabId),{
    file: "script.js",
  });
}
```*
quartz kindle
#

yup

delicate shore
#

why am I so dumb, I have been literally trying to figure this out for last 3 hours

earnest phoenix
quartz kindle
#

you're too used to discord.js that simply accepts everything the user throws at it

delicate shore
#

sad reality

earnest phoenix
#

it explains all deeply

surreal sage
#

Ay, can anyone provide me with the shorter version of setTimeout()?

I know that you const it somewhere and then can use it without having to use brackets

#

Something like

const timeout = blubdoesthefish

randomBracket {
  // sum code herr
  timeout(1000)
  // morr code herr w/ 1 sec timeout
}```
lament rock
#

There is no shorter version of setTimeout without aliasing it to return a Promise so you can await it.

function timeout(delay) {
  return new Promise(res => setTimeout(res, delay));
}
surreal sage
#

Thanks

pale vessel
#

Unless you are on Node 16+, you can just require setTimeout from timers/promises and use await setTimeout(delay);

lyric mountain
#

they promised the setTimeout?

earnest phoenix
#
const { Client, Message, MessageEmbed } = require("discord.js");
const Schema = require("../models/reaction-roles");

module.exports = {
  name: "panel",
  description: "Reaction-Role Panel",
  category: "Config",
  UserPerm: "ADMINISTRATOR",
async execute(message, args) {
    const channel = message.mentions.channels.first() || message.channel;
    Schema.findOne({ Guild: message.guild.id }, async (err, data) => {
      if (!data) return message.channel.send('no data use -rr-add')
      const mapped = Object.keys(data.Roles)
        .map((value, index) => {
          const role = message.guild.roles.cache.get(data.Roles[value][0]);
          return `${index + 1}) ${data.Roles[value][1].raw} - ${role}`;
        })
        .join("\n\n");
      channel.send(new MessageEmbed().setDescription(mapped)).then(msg => {
        data.Message = msg.id;
        data.save();

        const reactions = Object.values(data.Roles).map(val => val[1].id); //?? val[1].raw);
        reactions.map(emoji => msg.react(emoji));
      });
    });
  },
};```
#

anyone?

split hazel
#

for some reason all of a sudden in visual studio code when i try to push via gui i get this
remote: No anonymous write access.

#

all of a sudden too i made no changes how do i go about fixing it?

simple stump
#

Can I set a thumbnail for an embed using a file in the project? Ex.
.setThumbnaul(“../caution_gif.gif”)

simple stump
#

Thanks!

wicked pivot
#
if (!data[member.user.id]) {
                    data[member.user.id] = {
                        "id": member.user.id,
                        "xp": parseInt(number)
                    }
                } else {
                    data[member.user.id].xp = data[member.user.id].xp + parseInt(number)
                }
                JSONSAVE()```

at the end of some command it gives this (>):

```json
    >"499595256270946326": {
    >   "id": {
    >        "id": "499595256270946326",
    >        "xp": 950
    >    },
    >    "xp": 950
    >},
    > "910554564275613717": {
    >    "id": {
    >        "id": "910554564275613717",
    >        "xp": 800
    >    },
    >    "xp": 800
    >},
    "282859044593598464": {
        "id": "282859044593598464",
        "xp": 600600
    },
    > "557628352828014614": {
    >    "id": {
    >        "id": "557628352828014614",
    >        "xp": 952
    >    },
    >    "xp": 952
    >},```
quartz kindle
#

what exactly is the issue?

#

the code above looks alright, no issues there

surreal sage
#

What's a alternative method to get a element by id in puppeteer?

#

But there is a a element with that id

lyric mountain
#

aren't u supposed to omit #?

pale vessel
#

no since it's an id

#

it accepts a CSS selector

lyric mountain
#

ah

cinder patio
pale vessel
#

and are you sure the page is fully loaded

surreal sage
cinder patio
#

Try using eval to click on the button then

surreal sage
#

Can you give a snippet?

cinder patio
#

though page.click should work fine...

surreal sage
#

And yes i've tried goto but it also gives a error/doesn't work

cinder patio
#
page.evaluate(() => document.getElementById("menu-berichten-new").click());
surreal sage
#

``#appbar div:nth-child(2) tried this also

#

ima try thanks

#

Cannot read properties of null

cinder patio
#

BlobThonk doesn't sound like the error is coming from the snippet I sent you

pale vessel
#

how are you so sure the page is fully loaded

surreal sage
cinder patio
#

can you share more of your code

surreal sage
#

these are the elements im trying to click

#

ill just send everything lol

#
         async function proceedFunction() {
             console.log("Completed Login")
 
             await page.click('dna-avatar')
             await page.waitFor(200)
             await page.click('.ng-star-inserted')
 
             await page.waitFor(5000);
 
             if (!page.$('#help-menu')) {
                 console.error("Wrong page? Please monitor at next start")
             } else {
                 await page.waitFor(5000);
 
                 //page.evaluate(() => document.getElementById("menu-berichten-new").click());
             }
         }```
#

i think this is better lol

#

its commented rn

#

and no error!

#

when its commented*

cinder patio
#

That's super weird because you don't have properties anywhere in your code, which means the error is coming from puppeteer

surreal sage
#

its the latest version

#

puppeteer extra

#

3.2.3

cinder patio
#

wait , do you get Trying to correct page in your console?

#

you need to await that goto as well

surreal sage
#

Nope

pale vessel
#

Try console.log(await page.content()) and check if the selector is inside the HTML

surreal sage
#

saw that yuh

#

ight

#

appreciate the help guys/girls/any other gender

#

It isn't...

#

Inspect says something different lol

#

cant share it cause it contains private info

#

Hmm

#

It's on the wrong page or something

#

It's on a page before what it supposed to be

pale vessel
#

Also, doesn't page.$(...) return a promise?

surreal sage
#

It does

pale vessel
#

You should await it

surreal sage
#

Where is that

pale vessel
#

:/

surreal sage
#

sry

#

ill just replace all

#

fixed that

#

It's on the wrong page somehow

#

It doesn't say its on the wrong

#

But the console says it is

#

i think i fixed it

#

So basicly this site opens a new tab

#

With where it's supposed to be

#

lemme make a screenie

#

left is where its focused

#

and right is where i am

#

yess!

#

it worked

#

Thanks guys/girls/any other gender

#

Really appreciate it