#development

1 messages · Page 1889 of 1

proven lantern
#
console.table(client.guilds.cache.map(guild => guild.name))```
boreal iron
#
for(guild of client.guilds.cache) console.log(`ID: ${guild.id} | Name: ${guild.name}`);
lyric mountain
#

c# dev I see

slow ibex
#

Whait.. that cant be that easy

solemn latch
#

console.table(client.guilds.cache.map(guild => [guild.name, guild.id, guilld.icon]))
guess you could do this too? ^

boreal iron
solemn latch
#

isnt that what you want for a table?

boreal iron
spark flint
#

wow complicated stuff i don't understand

proven lantern
#

does table support that?

solemn latch
#
// an array of arrays

var people = [["John", "Smith"], ["Jane", "Doe"], ["Emily", "Jones"]]
console.table(people);
proven lantern
slow ibex
solemn latch
#

obvs can add the parameters you want, just grabbed a few random ones

boreal iron
slow ibex
solemn latch
#

technically it works with objects too, just the guild object may be a bit much to do that with

slow ibex
#

Now i only need to edit the table headers xD

#

Thats the main problem i kinda had.

solemn latch
#

if you need it to be presentable(not 0, 1, 2)

console.table(client.guilds.cache.map(guild => [guild.name, guild.id, guilld.icon]), ["name", "id", "icon"])
#

ye

#

probably a cleaner way to do it. but im lazy 👀

slow ibex
#

cough i.. s.. sorry,.. but.. uuh

#

hehe

#

Now the table is empty

woeful pike
solemn latch
slow ibex
#

But its correct.. i guess.. i read a bit in the documentation for console.table

reef stump
#

@signal flax

solemn latch
#
console.table(client.guilds.cache.map(guild => {name: guild.name, id: guild.id, icon: guild.icon}))

would be the correct way to get everything to work, I would think.

console.table(client.guilds.cache, ["name", "id", "icon"]))

also could work.

#

tbh, not worked with tables enough

slow ibex
#

But i just realised why it cant work that easily. Its not an Associative Array

solemn latch
#

sorry copied the wrong thing ^_^

boreal iron
#

Is it worth to spend time on printing the table of guilds into your console instead of working on bot features?

slow ibex
#

hehe

#

All the tables

boreal iron
#

Ha! Got you, Sir!

slow ibex
#

Personally i really like knowing where my bot is, what it does and stuff like that

#

All my web apps had extensive logging features so... hehe

woeful pike
#

why not use something like honeycomb or datadog

slow ibex
woeful pike
#

or just get a proper database explorer like pgadmin

boreal iron
#

Yeah well

slow ibex
#

Im working on it on my Dev-Bot

#

The connection to MariaDB is established xD

boreal iron
#

Well then save guilds your bot got added to in the associated event and additionally again in the ready event

#

As well as commands users used etc. IF you really need to

#

Anything else is cached by your lib already

reef stump
#

Hi I Need Project Moderation bot

slow ibex
#

I guess i would do that.. but i wouldnt to that in prod.

boreal iron
#

Hmm depends on your bots features

slow ibex
boreal iron
#

I generally do that for statistics and metrics

slow ibex
boreal iron
#

What’s the purpose of this database?

slow ibex
#

Cutting of the only Google API i use

boreal iron
#

Not sure if music bots have a future especially if they use YT

woeful pike
#

why are you even trying to print a table

slow ibex
woeful pike
#

but why even print it in the first place

slow ibex
boreal iron
slow ibex
blissful coral
#

What node version are you using

#

ok

solemn latch
#

nah, its bad code. somehow messed that one up twice

#

adding parenthesis around the object will fix it, the arrow function thinks the brackets are the body.

#

console.table(Array)

signal flax
#

@reef stump gyan

stiff lynx
#

pls help, I'm trying to do a music command but i still get this err

reef stump
signal flax
#

@reef stump aaa

reef stump
#

@signal flax wara aw projecta chak bkayn

signal flax
#

@reef stump kura wa ba xom xarika damrm walla

#

Esta na magar sa3at 3 yan 4

reef stump
signal flax
#

@reef stump nauala kulera froshm😂

reef stump
signal flax
#

🥺

reef stump
#

@signal flax aley Boxoman Serverman Nya Hatuyn Lera qsa akayn 😂 😂 😂

slow ibex
#

Console.log(„Serverid. | etc.“)

signal flax
#

@reef stump toy ni leray😂

reef stump
#

@signal flax Hatiw la hamu shwenek ham

signal flax
#

Kura aaa😂

slow ibex
#

It’s only for „not forgetting what coloumn was what“

boreal iron
slow ibex
#

Btw.. what are these guys speaking… is that php8?

#

Referencing this one function that’s was named in Hebrew… kinda funny tbh.

timid robin
#

do

boreal iron
slow ibex
#

*error

#

In computer programming, scope is an enclosing context where values and expressions are associated. The scope resolution operator helps to identify and specify the context to which an identifier refers, particularly by specifying a namespace. The specific uses vary across different programming languages with the notions of scoping. In many lang...

boreal iron
#

Should have said idc oldEyes

slow ibex
boreal iron
#

God thanks I disabled animated emojis or gifs smirk

slow ibex
#

:insertEmojiThatShowsHowDisappointedIAm:

#

Btw. Thanks for help (at)all

boreal iron
#

Np gonna send over the invoice real quick

slow ibex
#

I’ll let my accountant know

boreal iron
#

And I’m gonna do some work …
At least somebody needs to keep up the economy

eternal osprey
#

how do i chheck if an item is not in here?

#
for (const key in de){
    if(de[key].A.toLowerCase() == maka){
z = de[key].B

    }if(!de.toString().includes(maka)){
        z = 'This item isn`t in the database!'
    }
 
}```i have this now, where de is the ss i sent. This always returns me 'item not in database'. How would i fix it?
blissful coral
#

console.log(key)

eternal osprey
stiff lynx
#

How can I fix that? I'm trying to do a music bot!
Error: Error: Cannot find module '/root/novabotv13/node_modules/@discordjs/voice/node_modules/@discordjs/opus/prebuild/node-v93-napi-v3-linux-x64-glibc-2.28/opus.node'

eternal osprey
#

so to loop i used de[key]

grim aspen
#

can't find module

#

that means you're missing a module

blissful coral
#

I mean

#

Instead of using in

stiff lynx
blissful coral
#

you can do for(const key of Array[])

grim aspen
#

opus package?

blissful coral
#

Replace Array with your array

eternal osprey
#

this is de[key]

blissful coral
#

And you won't have to call it by index

eternal osprey
stiff lynx
#

this?

grim aspen
#

yes

#

should work

stiff lynx
#

already did

blissful coral
#

yeah

#

for(const var of Array) will work

#

the same way

#

and you don't have to call the index

grim aspen
#

it's deprecated

blissful coral
#

Use the new package

stiff lynx
#

oh

#

ehm

#

where I find it? lol

grim aspen
#

lemme see my old code

#

i have it in it somewhere

blissful coral
#

@discordjs/voice

#

is the new one

#

opus doesn't work with v13

#

@grim aspen

grim aspen
#

that's what i meant

stiff lynx
#

but doesnt work

grim aspen
#

remove opus

blissful coral
#

Remove opus completely

stiff lynx
#

how?

#

I've never removed a package

grim aspen
#

npm uninstall -g <package>

stiff lynx
#

npm uninstall

#

ah damn

#

I googled it 🙂

grim aspen
#

so it would be npm uninstall @tepid scrollordjs/opus

stiff lynx
#

I'm kinda lazy

grim aspen
#

oops

solemn latch
#

Poor disc

grim aspen
#

another victim of a non needed ping

stiff lynx
grim aspen
#

npm uninstall <@discordjs/opus

stiff lynx
#

37 packages are looking for funding
What is this?

grim aspen
#

ignore them

solemn latch
#

Tbh, always thought it was like donations

stiff lynx
#

That's my ninja way, dattebayo

solemn latch
#

But never looked into it 👀

#

Yeah it is

stiff lynx
#

I send the full err

solemn latch
#

They are looking for help funding the development

stiff lynx
#

maybe is more usefull

blissful coral
#

what node version are you using

stiff lynx
#

16

blissful coral
#

.?

stiff lynx
#

novabotv13]# node -v
v16.10.0

blissful coral
#

hmmm

stiff lynx
#

latest is 16.10?

grim aspen
#

show the code

#

just the part for opus

stiff lynx
#

I'm using @koenie06/discord.js-music

#

maybe is this package?

grim aspen
#

no, it's looking for opus

stiff lynx
#

but in local worked and on vps no, i dont get it

solemn latch
#

Different djs versions?

grim aspen
#

wait i used that once

#

that package was ratelimited because youtube put a strike on it

stiff lynx
#

I dont get y on local works and uploaded not anymore

twin marsh
#

How do I count the amount of documents in mongoDB?

stiff lynx
#

How can I make a message autodestroy itself?

#
            msg.delete({timeout:5000})
        })```
#

with this?

pale vessel
#

What version of discord.js are u using?

stiff lynx
#

v13

pale vessel
#

The timeout option was removed in v13

stiff lynx
#

discord.js

#

rip

#

and now?

#

.delete()

#

right?

pale vessel
#

You'd have to use .then(sent => setTimeout(() => sent.delete(), 5000))

stiff lynx
#

Deletes a message, even if it's not cached.

stiff lynx
#

Can I get the id from someone who used a slash command?

pale vessel
#

Yes

#

Interactions have the user property

errant flax
#

if i did this
<ClientApplication>.commands.cache
would have something right?

blissful coral
#

Is it .cache?

#

Damn djs really is shit

#

LOL

#

They put a cache on slash commands

errant flax
#

whats wrong with that

hybrid cargo
blissful coral
#

Discord-rose ftw

#

Raw API

errant flax
#

what wrong with caching slash commands

#

also it only cache when .fetch them

kind palm
#

A

boreal iron
# errant flax whats wrong with that

Nothing. In terms of updating commands without restarting the app, comparing name, description and options with the cache instead of fetching the commands is useful.

#

Not like a few commands would increase the cache size dramatically

blissful coral
#

define client?

#

learn js first

green kestrel
blissful coral
#

D++ bot too

#

nice

green kestrel
#

i wanted something to stream my personal music collection on my server, so i made this... and it became something more because others said they wanted to contribute to it

blissful coral
#

cpp best for music bots KEKW

boreal iron
#

Somehow looks like Brain has too much time

blissful coral
#

fr

#

lul

#

Brain become mod again and crush queue

#

Then no more time

green kestrel
#

you'd think that, this is about 8 hours work

blissful coral
#

Small numbers

green kestrel
#

i'd spend more than 8 hours a week wrestling the damn turkbots out of the queue

blissful coral
#

Turk bots exist still?

#

I haven't seen them in a bit ngl

green kestrel
#

ARA911 FBI ATATURK LOL

blissful coral
#

I barely get turk bots anymore

#

lul

green kestrel
#

say, do any of them even have slash commands yet?

blissful coral
#

Nope

#

In the past 3 weeks

green kestrel
#

🤣

boreal iron
#

lol

blissful coral
#

I have maybe had 2?

green kestrel
#

queue used to be 90% turkbot

#

5% portugese bot

#

2% russian bot

#

the rest english

boreal iron
#

Well it’s still enough time til may, don’t worry smirk

green kestrel
#

and 99% broken

boreal iron
#

lol

blissful coral
#

nah

#

queue is better now

#

Just big again

#

I am gonna crush it next time I have a free week

#

Waiting on getting quarantined again ;ekwk

green kestrel
#

lmao, this song really took some encoding

#
[INFO] Begin mp3 decode of file: Nightwish - Ghost Love Score
Note: Illegal Audio-MPEG-Header 0x4c595249 at offset 17287437.
Note: Trying to resync...
Note: Hit end of (available) data during resync.
[INFO] End mp3 decode of file: Nightwish - Ghost Love Score [4.95 seconds]
[INFO] Begin opus encode of file: Nightwish - Ghost Love Score
[INFO] End opus encode of file: Nightwish - Ghost Love Score [92.73 seconds]
#

92 secs 😮

#

good job it can start playing while its encoding the opus lol

cold ruin
#

what the css property to chnage top.gg background

lyric mountain
#

F12 -> inspect element

cold ruin
lyric mountain
#

After u select the background, look at the bottom right corner, the classname will be listed there

lyric mountain
#

Try it

molten flint
#

When i close ticket my bot turn off and drop this error

dense flame
#

code?

molten flint
#

Ok i send

#

So? you find the problem?

lament rock
#

Don't use Discord buttons package. Discord.js v13 has them built in

molten flint
#

So i need delete buttons package?

dense flame
#

buttons.channel seems undefined

#

I havent worked with buttons so im not sure how to fix the issue

lament rock
#

It's recommended to use the official wrappers for Buttons.

But I'll go ahead and tell you that the channel ID passed to the wrapper doesn't exist

#

If you're using v13, there's a specific casing for Id

#

I forgor what it is

molten flint
#

Damn thats mean no fix XD

#

12.5.3DISCORD.JS Version

earnest phoenix
lament rock
#

Yeah. Update Discord.js to v13 and have fun fixing bugs and syntax changes from v12 to 13

#

I'm am dummy 💀

#

English

molten flint
#

Oh shit

lament rock
#

v12 is deprecated btw

#

will stop working sooner than later

onyx carbon
#

I’m having issues voting

earnest phoenix
#

Bots using discord.js v12 already crash upon encountering a stage channel mmLol

onyx carbon
#

Like, every time I try to vote, the page refreshes during the ad

earnest phoenix
#

v11 is dead

#

v12 at least works but would crash upon encountering a stage channel

molten flint
#

Damn if i upgrade to v13 my bot gonna be deadddd

earnest phoenix
#

It's fairly easy to update to v13

molten flint
#

Yeah but i dont have so much time to work on bot i have school

earnest phoenix
earnest phoenix
#

and crashes

#

some ppl found a fix to this but wait until 2022 april(?)

#

v11 can't even connect to the gateway

#

it can

#

There has been changes that breaks the entire thing

#

great for people who only copies codes lmao

lament rock
#

Gateway v6 is still active

#

somehow

earnest phoenix
#

Discord API v6 will probably become inactive entirely after they offically enforce the message content intent

lament rock
#

probably sooner

#

I REALLY have to update my Discord libs because Discord sucks and updates super frequently for whatever reason

#

and then I also have to catch up with commits to Discord.js

#

Idk how or why they have so much activity

#

it's like they're pulling shit from their ass

earnest phoenix
#

They basically pull something new out of their ass entirely out of the blue, it's really annoying for lib devs honestly, it's the reason discord.js v13 was so delayed KEKW

lament rock
#

frfr

#

It's made me super de-motivated from updating my lib forks

#

plus I like spending time with my wife

earnest phoenix
#

Reject lib development, live happy with wife mmLol

lament rock
#

Might as well hire people to update the libs for me

#

Hey Voltrex, what's your rates?

earnest phoenix
#

Rates of?

lament rock
#

Coding

#

How much do I pay you to code shit I don't want to

earnest phoenix
#

It's great, well as you know I maintain Node.js and V8 which is kinda pretty hard to do so and many other projects, well you can count on me; but not sure how much you would pay, it's really up to you for the pricing, I've made tons of stuff for people for free

lament rock
#

Nah. Taking up an offer on free dev is self destructive to the dev unless they were super dedicated helping to the project. I burned myself out over the years of doing everything I did for free or next to nothing. If not for my own enjoyment or benefit, then it's not worth it for me

earnest phoenix
#

Good point, well you can hit me up anytime for the development of your projects or new ones so I can see what I can do and discuss the pricing if you're up to it

lament rock
earnest phoenix
urban slate
#

guys how do i get the tags of all the owners of all the servers my bot is a part of

pale vessel
#

You can get owner IDs from guilds and resolve them to users

urban slate
#

how

#

pelase help me

#

i want to die right now my bot got into many servers because of good feature set and discord flagged it for inorganic growth

#

so i want to check if there are people who just invited the bot to multiple servers

urban slate
#

can someone please help me

mint pewter
#

forEach is synchronous iirc, so it'll console.log before running the .then()

pale vessel
#

Use a for loop

#
for (const guild of client.guilds.cache.values())
    console.log(await client.users.fetch(guild.ownerId));```
#

Or u could map it to an array and use Promise.all()

woeful pike
cinder patio
#

...sooo node-fetch only works with esm imports now

pale vessel
#

Yes

#

It's so stupid

#

v2 still get security updates though

cinder patio
#

I don't wanna use old versions though, looks like I'll have to switch

pale vessel
#

It's not like u lose anything

#

Fetch is just fetch end of the day

stiff lynx
#

could this work?

inter.member.id

pale vessel
#

Try it and see

pale vessel
#

U have to use import since node-fetch v3

stiff lynx
old cliff
#

no longer const fetch = ....?

pale vessel
#

Or actually use import if you're dealing with ESM

cinder patio
#

Now typescript can't find the declaration files for node-fetch even though I've installed them 😩 what a mess

stiff lynx
#

?

pale vessel
#

But they're built-in?

pale vessel
cinder patio
#

yeah for 3.0.0...

pale vessel
#

inter.member is only for guild-only command interaction

stiff lynx
pale vessel
#

There is

stiff lynx
#

ops

#

I'm blind

#

nvm

pale vessel
cinder patio
#

I changed my mind

stiff lynx
#

still doesnt work :/

earnest phoenix
#

Tonkku#0107

#

wheres tonkku

#

;c

narrow sedge
#
if(msg?.includes('{User}')) replaced_message.replace(`{User}`, `\${member.user.username}`)
if(msg?.includes('{Server}')) replaced_message.replace(`{Server}`, `\${member.guild.name}`)
``` Why is it not replacing the words?
cinder patio
#

replace doesn't modify the string in-place

#

it returns a new string

narrow sedge
# cinder patio replace doesn't modify the string in-place
 let replaced_message = msg;

          if(msg?.includes('{User}')) replaced_message = replaced_message.replace(`{User}`, `\${member.user.username}`)
          if(msg?.includes('{Server}')) replaced_message = repreplaced_message.replace(`{Server}`, `\${member.guild.name}`)
``` So if i use it like this it would work?
pale vessel
#

Yes

narrow sedge
#

Works now , thx guys

earnest phoenix
#

Is there an equivalent of array.filter that only returns element indexes?

cinder patio
#

I'd use a for loop

#

cause there isn't

earnest phoenix
#

another for loop for every interaction
seems fun

cinder patio
#

another?

earnest phoenix
#

I have four

cinder patio
#

well a filter is basically a for loop too, soooo

pale vessel
earnest phoenix
quartz kindle
#

better just use a for loop

#

otherwise map.filter.map is 3 loops

#

a for loop can do it in one

boreal iron
#

Imagine using PHP calling array_keys()

quartz kindle
#

imagine using PHP

#

👀

spark flint
#

im lazy and use wordpress

#

but maybe i'll teach myself a new language soon

boreal iron
quartz kindle
#

lmfao

#

go explode(string, delimiter) yourself

boreal iron
#

hehe lmao

#

At least it sounds like it’s doing something

quartz kindle
#

for those who dont know, .split() in js is explode() in php

boreal iron
#

And Sir we’re proud of having this

quartz kindle
#

5/7 naming scheme

boreal iron
#

I wonder if there’s a spit alias these days

#

Need to check

quartz kindle
#

there used to be split, was removed in 7.0

#

there is also str_split

outer perch
#

should I open my bot repo? it's already organized so I don't leak critical stuff Thonk

quartz kindle
#

which splits by number of chars

outer perch
#

the better question would be, would anyone be interested in improving my code and request to pull those improvements?

quartz kindle
#

does php have any prototype/class methods on strings? or is everything funcional?

tired panther
quartz kindle
#

ye, youre likely only gonna get contributions from people who use your bot and/or code

outer perch
#

yeah, makes sense

#

and probably 99% of the users don't code

#

idk, I was thinking of some kind of GitHub lurker looking for code to contribute

tired panther
outer perch
#

ain't there a way to make it public but deactivating the clone option?

tired panther
boreal iron
tired panther
#

And explode()

outer perch
tired panther
#

Yeah, you can never be safe....

prime glacier
#

UnhandledPromiseRejectionWarning: TypeError: allmembers.send is not a function
allmembers.send('Test')

quartz kindle
#

allmembers.send is not a function

#

aka, .send does not exists in the variable allmembers

prime glacier
#

how to do that now?

#
let allmembers = message.guild.members.cache.filter(member => member.presence.status !== "offline")

    allmembers.send('Test')```
quartz kindle
#

do what?

#

you cant use something that doesnt exist

prime glacier
#

oh

quartz kindle
#

if you want to send a message to multiple members, you have to send one by one

prime glacier
#

okie

quartz kindle
#
for(const member of allmembers) {
  await member.send("test")
}
boreal iron
#

Imagine using send() on the whole user collection… fun guaranteed

quartz kindle
#

imagine if discord supported batch/bulk endpoints for everything

boreal iron
#

Discord "a safe place" you know

quartz kindle
#

check logs

prime glacier
quartz kindle
#

then you did something wrong, or didnt save

#

that will throw an error if the message fails to send

quartz kindle
#

yes

errant flax
#

what i mean by isnt is it is

prime glacier
# quartz kindle then you did something wrong, or didnt save
const discord = require("discord.js");
module.exports = {
    name: "massdm",
  category: "moderation",
  usage: "purge <number of message>",
  run: async (client, message, args) => {
    let allmembers = message.guild.members.cache.filter(member => member.presence.status !== "offline")
    for(const member of allmembers) {
      await member.send("test")
    }
  }
}```
prime glacier
#

🙄

#

😂

errant flax
#

still

#

api abuse lmfao

#

like dont u know how 100 members is rlly is?

#

thats huge misosface

prime glacier
#

xD

errant flax
#

srsly dont do it

#

ull get a:

  1. ban from topgg(if ur doing that on ur bot that is in topgg)
  2. get ratelimited
quartz kindle
#

const member of allmembers.values()

prime glacier
errant flax
#

if its an ip ban

prime glacier
#

F

#

🙄

solemn latch
#

it also can affect your account

prime glacier
#

oh

errant flax
#

like in general why do u want to MASS DM 100 members

solemn latch
#

discord can by their TOS close your account for your bots api abuse.

prime glacier
#

okie

#

thanks for info

#

❤️

errant flax
#

just dont do it misosface

#

why do u even want to dm 100 people

boreal iron
#

Btw. you need the intent to get presences

boreal iron
solemn latch
#

for a private bot?

boreal iron
errant flax
#

also low chance of everyone is being in the bots cache

boreal iron
#

Ding dong, and we found another example of sarcasm resistance

errant flax
#

only if u do .fetch

old cliff
#

Caching all members will have a lot of memory footprint

wheat mesa
#

Damn moddums slow

#

They’ll get them soon enough

boreal iron
#

Hmm can't click the nitro button without JS enabled...

#

Sad

rustic nova
stray seal
#

/home/runner/Snake/node_modules/discord.js/src/rest/RESTManager.js:32
const token = this.client.token ?? this.client.accessToken;
^

SyntaxError: Unexpected token '?'
Hint: hit control+c anytime to enter REPL.

Error ^

const SnakeGame = require('snakecord');
const Discord = require("discord.js");
const client = new Discord.Client();

const snakeGame = new SnakeGame({
   title: 'Snake Game',
   color: "GREEN",
   timestamp: false,
   gameOverTitle: "Game Over"
});

const config = {
   prefix: "!"
}

client.on('ready', () => {
   console.log("Clearing Console");
   console.clear();
   console.log('Ready!');
   client.user.setActivity(`${config.prefix}snake`);
});

client.on('message', message => {
  if(!message.content.startsWith(config.prefix) || message.author.bot) return;

  const args = message.content.slice(config.prefix.length).trim().split(/ +/);
  const command = args.shift().toLowerCase();

  if(command === 'snake' || command === 'snakegame') {
    return snakeGame.newGame(message);
  }
});

client.login(process.env.TOKEN);

Code ^

earnest phoenix
stray seal
#

I am on replit, how i update?

earnest phoenix
#

Use a Node version manager

stray seal
#

There is a way, someone told me how to do it before

#

lol

earnest phoenix
#

Oh you're using repl.it, just use Tim's solution

stray seal
#

I don't know what Tim's solution is

#

^ ^ ^

earnest phoenix
quartz kindle
#

you can use the official nix solution now

#

the nix repo updated their stable node to 16.8

old cliff
#

link?

quartz kindle
#

previously this solution was limited to node 16.4 since it depends on the nixos stable repo, but nix updated it recently to 16.8

#

my bash solution is still the only one that supports unofficial builds tho

#

like the pointer-compression build

split hazel
#

tim only you are hyped about pointer compression

#

I'm sorry

quartz kindle
#

i dont care

#

ofc im hyped

lyric mountain
#

compres ion??

earnest phoenix
#

🗜️

boreal iron
#

Voltrex get out of development!

quartz kindle
#

i'll take free 30-40% memory reduction anyday

earnest phoenix
split hazel
#

only 4gb ram imagine

boreal iron
#

Ha! I'm not at the moment

split hazel
#

what if repl suddenly lets people use 5gb ram and times change

quartz kindle
#

they dont even let you fully use 512mb lmao

split hazel
#

lol

quartz kindle
#

so thats still a long way to go

#

plus, even in a vps, you will rarely use 4gb ram on a single node process

#

you will likely process shard way before that

split hazel
#

what if its a turkum bottomom using lots of memory with internal sharding

quartz kindle
#

they can go fuck themselves

earnest phoenix
#

Oh no npm i * bottums

quartz kindle
#

also, if they're using 5gb, with pointer compression it will likely use less than 3gb

#

so still within limits

#

:^)

solemn latch
#

🤔 pointer compression?

quartz kindle
#

yes

split hazel
#

what if hypothetically they used 9gb

quartz kindle
#

less memory usage for free

#

then they need help

split hazel
#

they have lots of image buffer cached

solemn latch
#

o hype

split hazel
#

and fetching from disk takes 20 seconds each

quartz kindle
#

yup, they definitely need help

#

mental help

split hazel
#

lmao

quartz kindle
#

just-js >>> node+jemalloc+pointercompression > deno > node

#

lmao

earnest phoenix
#

Just yelling at the computer > *

quartz kindle
#

in russian accent: work or i wiw kiw you

earnest phoenix
boreal iron
#

Weird

#

Thought that’s part of any Russian sentence

quartz kindle
#

blyat job tvoyu mat

spark flint
#

wdym

#

never seen that before - looks pretty handy

solemn latch
#

tbh, would double check the code for it before using it.
But if it works I dont see why not

earnest phoenix
#

I don't recommend using that all-in-one lib since it can be pretty outdated and not updated in a long time, and it also limits the functionality than just using the official libs provided by the bot lists

lament rock
solemn latch
#

most botlists will probably error without an actually listed bot

lyric mountain
#

Also chances are it'll just end up bloating ur code

#

Since rarely someone will have a bot in ALL supported lists

#

just do individual calls

#

or write ur own multi-post wrapper

simple stump
#

I’m trying to install node canvas, but I keep getting the error npm ERR! code 1 And afterwards npm ERR! command failed. My node.js version is 16. I heard that you can try downgrading to version 14, but I believe Discord.JS requires version 16. Any way to fix this or alternatives to node canvas?

worn sonnet
#

Hii,

    futures = []
    with ThreadPoolExecutor(max_workers=len(accounts)) as executor:
        for users in get_user_followers(username):      # get_user_followers is generator
            for scraper in scrapers:
                future = executor.submit(get_followers_email, scraper, users)
                print(users)
                print("Next")
                futures.append(future)

        for fut in as_completed(futures):
            fut.result()
  1. what i'm trying is get the values from generator
  2. there are two workers, so each worker should process the different values
    but in here both workers are processing same values
tulip ledge
#

can someone help me? Trying to use react with typescript

pale vessel
#

Did you use the TS template?

tulip ledge
#

nvm, but I am getting this error when running tho:

Could not find an open port at 0.0.0.0.
Network error message: listen EACCES: permission denied 0.0.0.0
earnest phoenix
pale vessel
#

no

earnest phoenix
#

deno better than node every other way tho

#

if only it supported commonjs :(

worn sonnet
earnest phoenix
earnest phoenix
#

it is a js runtime like nodejs (made by the same guy)

#

question: what is the limit for how many buttons an action row can have

earnest phoenix
#

ty

#

25 buttons are possible ,If your text is small

#

ok

#

is 5 button limit for a poll command enough?

#

because having more than 1 row === extra logic and headaches

tulip ledge
#

how do I solve

earnest phoenix
#

or maybe that port is in use

#

idk try another port

tulip ledge
#

I tried many different ports

earnest phoenix
#

allow nodejs access to network through windows firewall

tulip ledge
#

alright i'll try

scarlet rune
#

how do I set a prefix for discord.js?

earnest phoenix
#

also if you're using slash commands / is the prefix

earnest phoenix
#
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const clientId = "848292306088230922"
const commands = [{
  name: 'ping',
  description: 'Replies with Pong!'
}]; 

const rest = new REST({ version: '9' }).setToken(process.env.token);

(async () => {
  try {
    console.log('Started refreshing application (/) commands.');

    await rest.put(
      Routes.applicationCommands(clientId),
      { body: commands },
    );

    console.log('Successfully reloaded application (/) commands.');
  } catch (error) {
    console.error(error);
  }
})();

const Discord = require('discord.js');
const client = new Discord.Client()
// I have intents but didnt put 

client.on('ready', () => {
  console.log(Logged in as ${client.user.tag}!);
});

client.on('interactionCreate', async interaction => {
  if (!interaction.isCommand()) return;

  if (interaction.commandName === 'ping') {
    await interaction.reply('Pong!');
  }
});

client.login(process.env.token);

Console

Sucsesfully reloaded (/) comannds

/ping
no response
Whats my error

simple stump
boreal iron
#

You should not register commands anytime you start the script.

earnest phoenix
#

Is there other way?

boreal iron
#

Sure fetching the registered commands, comparing them to yours and if they're match, return, if they don't match each other, update them, if they're missing, create them.

earnest phoenix
boreal iron
#

And don't use the fucking rest lib shit...

#

djs anything inbuilt already

earnest phoenix
#

news flash detritus encourages you to do exactly that (not necessarily for slash commands tho)

#

Still didnt respond

earnest phoenix
earnest phoenix
boreal iron
#

I know, but it's trash

earnest phoenix
boreal iron
#

There's no slash command registered

pale vessel
simple stump
#

Aight

earnest phoenix
boreal iron
#

If so the UI would pop up

#

You need to wait up to 1 hour until global commands are deployed

#

or pushed

earnest phoenix
#

why do global commands update instantly for me?

#

is it just registering a fresh new command that takes time

boreal iron
#

BECAUSE updating is NOT registering

boreal iron
#

Sometimes updating a command can result in a interaction command failed.

earnest phoenix
#

no it appears instantly when i type /newcommand and wait only 5 seconds

broken harbor
#

What can i do ?

split hazel
#

cry

boreal iron
simple stump
earnest phoenix
# split hazel cry

im crying because my tictactoe command is complete non working spaghetti

boreal iron
#

skill issue

earnest phoenix
#

I made my commands to guild

#

But now it says Missing Acsess.

boreal iron
#

Does the app even has permissions to create slash commands?

earnest phoenix
#

applications.commands is missing

#

How do i give this perm

#

you need both bot scope and applications.commands

earnest phoenix
#

Its the first time i am using application commands

boreal iron
#

Changing the scope for your invite

earnest phoenix
#

Ohh

#

but put scope=bot%20applications.commandsin the url instead of scope=bot

pale vessel
#

drake_nope =bot%20applications.commands
drake_dope =bot+applications.commands

boreal iron
#

I see a not encoded char hashflushed

#

How dare you...

earnest phoenix
#

Why isnt there eaiser way

boreal iron
#

An easier way of what?

earnest phoenix
#

?

#

Why my msg is deleting

earnest phoenix
boreal iron
#

Because guild owners need to grant the permission

#

Imagine every bot could register like 200 slash commands

#

without your permission

earnest phoenix
#

is there a way to quickly resigter global slash commands

boreal iron
#

I sent the link to the docs already.

simple stump
#

I’m doing some canvas stuff, but when I try to do var someImgIdk = new Image(); I get the error, “Image isn’t defined.

coral palm
#

Morning, someone here understand anything about the new handlers with aliases and etc?
Im trying to study them
but i cant understand anything about it

boreal iron
#

new handlers with aliases

huh?

coral palm
#

yeah

#

Discord V13 Handlers

#

Permissions changed etc

boreal iron
#

Is there a specific issue you're running into?

coral palm
#

yeah

#

1m

earnest phoenix
coral palm
#

Code:

fs.readdirSync("./ARCHERSBOT/Commands")
    .filter(file => file.endsWith(".js"))
    .forEach(file => {
        /**
         * @type {Command}
         */
        const command = require(`./Commands/${file}`);
        console.log(`Command ${command.name} loaded`);
        client.commands.set(command.name, command);
    });
boreal iron
#

Don't use relative path for FS

#

Use absolute paths.

#

__dirname/commands

coral palm
#

errno: -4058,
syscall: 'scandir',
code: 'ENOENT',
path: '__ARCHERSBOT/Commands'
}

boreal iron
#

wtf

#
fs.readdirSync(`${__dirname}/ARCHERSBOT/Commands`) ...
coral palm
#

oh

#

ok

#

ahahhahaha

#

Dumb me

boreal iron
earnest phoenix
#
const commands = client.application?.commands

commands?.create({
  name: 'ping',
  description: 'pong',
})
  .then(console.log)
  .catch(console.error);

client.on('interactionCreate', async interaction => {
  if (!interaction.isCommand()) return;

  if (interaction.commandName === 'ping') {
    await interaction.reply({ content: 'Pong!', ephemeral: true });
  }
});
#

I did this and it worked

boreal iron
#

wtf is this optional chaining... these properties always exist

#
let command = {
  name: 'test',
  description: 'A test command',
};

client.application.commands.create(command);
earnest phoenix
boreal iron
#

Each command needs to be registered by it's own, using the mentioned djs method.

#

Create an object of all your commands, then loop through it, register each one in the loop.

#

Or an array... whatever you like.

#

It's an object in JS anyways freerealestate

#

I'm gonna give you an example:

earnest phoenix
boreal iron
#
let commands = 
{
  {
    name: 'test',
    description: 'A test command'
  },
  {
    name: 'test2',
    description: 'A test command2'
  }
};

for(const command of commands) client.application.commands.create(command).catch(console.error);
earnest phoenix
#

Unexpected token '{'

boreal iron
#

Oops... accidentally put a ,

feral aspen
#

How can I fix this?

var lastEditted = await bot.users.fetch(server.lastEdited).catch(() => null);

.setFooter(lastEditted ? lastEditted.displayAvatarURL({ dynamic: true, size: 4096, format: 'png' }) : null, `Settings last edited by ${lastEditted ? lastEditted.username : "no one"}.`)
#

Not sure how I can code this properly. :/

earnest phoenix
boreal iron
#

Fixed the code already.

earnest phoenix
#

Still same error

#

There is a red line under the { on Line 2 of the code

boreal iron
#

huh, gimme a screenshot, please

earnest phoenix
boreal iron
#

lol put { } instead of [ ] around

#

I mean you can also use a map.

#

Better to work with

earnest phoenix
#

@boreal iron

boreal iron
#

Are you on v13 already?

earnest phoenix
#

Yes

#

v13.1.0

#

Latest

boreal iron
#

You're client is already logged in when calling the methods?

earnest phoenix
#

Yes

boreal iron
#

Watching your first screenshot, it isn't.

earnest phoenix
#

It didnt change when i did

#

I log client after define client

boreal iron
#

You're calling the method before login in.

#

Make sure to register commands for example in the ready event

#

Or later...

earnest phoenix
#

Okay it doesnt give any error in console but didnt load commands also

stark moth
#

guys can someone help me (if you can help me its a discord bot, DM me for the github code idk why it doesnt work (+ server invite for test))

boreal iron
earnest phoenix
#

My bot just in 1 guild

boreal iron
#

If you wanna experiment with them, create guild commands.

boreal iron
#

Doesn't matter in how many guilds it is.

earnest phoenix
#

client.application.guilds.commands.create ?

boreal iron
#

There are two ways... guilds.commands.create()

#

Or passing the guild ID like so:

#

client.application.commands.create(command, guild_id).catch(console.error);

#
let commands = 
[
  {
    name: 'test',
    description: 'A test command'
  },
  {
    name: 'test2',
    description: 'A test command2'
  }
];

for(const command of commands) client.application.commands.create(command, "guild-id").catch(console.error);
earnest phoenix
#

So annoying

boreal iron
#

That's why you build a proper command handler once, like for casual commands, and that's it.

earnest phoenix
#

Good news it worked

#

But there are 2 more slash commands i deleted codes

boreal iron
#

You need to be careful registering the same commands over and over again, as well as mixing guild ones with global ones.

#

It's tricky but once you got it, it's actually easy

south timber
#

I removed slash commands from my bot a while ago and they are still showing up

earnest phoenix
#

Fetch and delete them

#

I think it works

south timber
#

How

#

They aren't in my code anymore

earnest phoenix
#

let x = await client.application.commands.fetch()
x.forEach(a => a.delete())

#

Something like that

meager kindle
#

Is there a way to fix this? To force caching of users?

boreal iron
#

client.application.commands.set([]);

earnest phoenix
#

not really

#

because its something with the discord client

boreal iron
#

Will update any to "nothing" aka. removing them

meager kindle
#

What was the point of even writing user interactions if I can't do this

boreal iron
#

You can of course fetch users.

meager kindle
boreal iron
#

If you got the user IDs you can force fetch them from the API

meager kindle
#

They'll show up on some clients but won't on others, I have no control

earnest phoenix
#

Oh nwm i made my commands guild commands

boreal iron
#

Can’t actually tell you if the update is immediately or will take some time, too

#

(speaking about global commands)

brave tendon
#

Can someone explain to me why this won't work?
I am using MongoDB and want to display the current amount of documents as the name of a voice channel.. if I console.log the amount it logs the 1 but the channel name does not update :/

earnest phoenix
#

Do you know how can i delete guild commands also

#

I tried guild.commands.set([]) but didnt work

earnest phoenix
brave tendon
earnest phoenix
#

@boreal iron

boreal iron
#

FakE will be right back, please hold the line

#

Well if you wanna use the guild obj/class then define it

#

Or fetch the guild you're trying to work with

#

Or get it from the cache etc.

earnest phoenix
#

const guild = client.guilds.cache.get(guildId)

south timber
#

I'm new to cogs so can someone tell me what self is used for and when to use it
Also what do I put in def init

earnest phoenix
#

I made it message.guild and worked

boreal iron
#

Can't tell you if set([]) still works but you will notice when catching the errors

#

But it should

earnest phoenix
#

Should i keep bot online for register all slash commands?

#

To all guilds

boreal iron
#

Registering them as guild commands is mostly for testing porpuse only

earnest phoenix
#

I wanna make them public

boreal iron
#

They need to be registered as global commands then.

earnest phoenix
split moth
#

I have my python bot hosted on heroku and want to be able to change text files in the repository. How can I make the changes from say f.write(“foo bar”) persist and not reset?

boreal iron
earnest phoenix
#

Ill change it to command files

#

But register time is really much i think

#

And my bot relogs 4 5 times in a day

boreal iron
#

A proper command handler will load your (export) modules, fetch the ones already registered, compare them to each other, register/update/delete new/old ones, and that's it.

earnest phoenix
#

If i use it like normal command file will it cause any problem?

boreal iron
#

Ahh nope, I'm doing the same

earnest phoenix
#
const cmdF = ["moderation", "info", "others", "config", "giveaways"]
cmdF.forEach(x => {
const command = fs.readdirSync(`./commands/${x}`).filter(file => file.endsWith('.js'));
for (const file of command) {
	const command = require(`./commands/${x}/${file}`);
	if (typeof command.name === "object") {
    command.name.forEach(x => {
      client.commands.set(x, command);
    });
  } else {
    client.commands.set(command.name, command);
  }
}
});
boreal iron
#

I'm taking the command name and description as slash command name and destription

earnest phoenix
#

It will take much time ||bc i am all alone||

boreal iron
#

Using the same structure to build slash commands

#

With additional properties like options etc. for components

wooden kindle
#

i thought of rythm and made this

#
  let channels = guild.channels.cache;

  textchannels = channels.filter(c => c.type == "text");
  cnl = textchannels.map(c => c.id);

  console.log(cnl)

  ch = guild.channels.cache.get(cnl[0]);

  console.log(ch);

  const Embed = new Discord.MessageEmbed()
    .setTitle('')
    .setDescription(``)
    .setColor(`RANDOM`) 
    .setURL(``) 
    .setThumbnail(``) 
    .setTimestamp();
  ch.send({embed: Embed}).catch((e)=>{console.log(e)});
})```
wheat mesa
#

Huh

pale vessel
#

What's the point of all those variables when you can just use const channel = guild.channels.cache.find(c => c.type === "text")

#

Too many unnecessary mutations

boreal iron
#

Also sending an empty embed, wut?!

wooden kindle
#

its not empty

#

its got stuff in it

#

its just that it will look long asf if i had the text in it

boreal iron
#

Ah alright

wooden kindle
#

this is what it looks like normally

boreal iron
#

Also keep in mind what flazepe mentioned

wooden kindle
#

true

#

thats just what i found worked

#

i didnt try anything els i just did that first tbh lol

boreal iron
#

Yeah just to say, creating vars makes sense only if you use then multiple times

solemn latch
#

tbh, if you are speed coding something and do that its fine, but always clean them up if possible.

wooden kindle
#

ye true

boreal iron
#

Like counting an array 10 times for example is ineffective, creating a var once, then using the var is effective

wooden kindle
#

its just im trying to add simple little things for new version

proven lantern
#

which api call can get me the count of members that belong to a guild?
This endpoint doesn't have the info https://discord.com/api/v9/guilds/{GUILD_ID}

solemn latch
#

Only on guild create

earnest phoenix
#
client.commands = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));

for (const file of commandFiles) {
    const command = require(./commands/${file});
    client.commands.set(command.name, command);
  console.log(command.name)
}

client.on('interactionCreate', async interaction => {
    if (!interaction.isCommand()) return;

    const command = client.commands.get(interaction.commandName);

    if (!command) return;

    try {
        await client.commands.get(interaction.commandName).run(client, interaction)
    } catch (error) {
        console.error(error);
        await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
    }
});
const Discord = require('discord.js')

module.exports = {
  name: "ping",
  descriptio: "pong",
    async run(client, intereaction) {
      intereaction.reply("Pong!")
    }
}

Why command didnt load

grim aspen
#

maybe because "descriptio"

#

also interaction.reply not intereaction.reply

proven lantern
earnest phoenix
#

So i defined it intreaction everytime lol

grim aspen
#

but description is not going to be correct if spelled "description"

earnest phoenix
#

Yes i fixed it

grim aspen
#

anyways any errors?

earnest phoenix
#

Yes

#

I moved it(intereaction executer) to event files it doesnt respond now

#
module.exports = {
    name: 'intereactionCreate',
      execute (client, intereaction) {
      
    if (intereaction.author.bot || intereaction.guild) return;
    
    if (!intereaction.isCommand()) return;

    const command = client.commands.get(intereaction.commandName);

    if (!command) return;

    try {
        client.commands.get(intereaction.commandName).run(client, intereaction)
    } catch (error) {
        console.error(error);
        intereaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
    }
      
  }
};
grim aspen
#

what was the error though?

earnest phoenix
boreal iron
#

The event is called interactionCreate

grim aspen
#

i think that broke my brain

boreal iron
#

not intere

grim aspen
#

i mean his way of doing it

earnest phoenix
grim aspen
#

there should be an error in your console

earnest phoenix
grim aspen
#

what is the error

earnest phoenix
#

No error

grim aspen
#

have you registered slash commands?

earnest phoenix
#

Yes

#

They were working before i move executor to event files

grim aspen
#

there's the issue

#

you moved executor to the event files

#

the executor grabs the code from the event files. an executor would not work in the event files

earnest phoenix
#

Actually no

#

It was working on message

#

Just doesnt work on slash

boreal iron
#

You changed that one?

#

To interactionCreate

#

As event name?

#

not intere

earnest phoenix
#

İnteraction?

grim aspen
#

so you put the command as "interactionCreate"

boreal iron
#

interaction
intereaction

earnest phoenix
#

It was
**```
intereactionCreate

boreal iron
grim aspen
#

ok take back a step

earnest phoenix
#

So i do it interaction

grim aspen
#

the original time*

boreal iron
#

Without the extra E yes

grim aspen
#

i said that earlier

earnest phoenix
#

Thinking

#

And failing

boreal iron
#

Weird to move the events to modules, but why not everybody has its own style

earnest phoenix
#

Have to i use async function in execute thing

#

I dont want crowd in my bot.js

#

I need to use it for my pleasures lol

boreal iron
#

Okay once again what’s not working and what are you trying to do?

#

In a Short Version

earnest phoenix
#

I wanna move INT execute commands SHIT to event files

#

I have event file loader

boreal iron
#

And you fixed that code already?
Because you sometimes added the extra E to the var name and sometimes not

#

Check all vars again

earnest phoenix
#

Beuh

#

Discordjs gay

earnest phoenix
grim aspen
#

who?

earnest phoenix
#

interaction

earnest phoenix
#

Sometimes there are typing intereact

#

Sometimes interact

#

Check guide

grim aspen
#

i think you're reading the wrong guide

earnest phoenix
#

djsv12 to v13?

boreal iron
#

The parameter is called async interaction =>
You’re using intere as var name below which can’t work

#

Man just fix all those wrong var names and the code should work

earnest phoenix
#

interact is true right?

#

Is it true spelling in english?

boreal iron
#

Can’t see any real issue but watching code on mobile is the worst thing to do anyways

#

interACTION

solemn latch
#

woooooooooo

#

awh

boreal iron
#

Don’t ask

#

Auto correct

#

earnest phoenix
#

Then what is InteReaction

grim aspen
earnest phoenix
#

And i found the issue

solemn latch
earnest phoenix
#

I made int.guild not !int.guild

boreal iron
earnest phoenix
#

So int failing

#

Op

boreal iron
#

Even tho it will still fail

#

If I define a var called interaction, I can’t use intereaction later on

#

let x;
console.log(y);

earnest phoenix
#
client.on('interactionCreate', async intereaction => {
    if (!intereaction.guild) return;
    
    if (!intereaction.isCommand()) return;

    const command = client.commands.get(intereaction.commandName);

    if (!command) return;

    try {
        client.commands.get(intereaction.commandName).run(client, intereaction)
    } catch (error) {
        console.error(error);
        intereaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
    }
});
#

Ill define int

#

So similar

boreal iron
#

The property guild is always present, check if guild.available

#

If used in guilds of course

#

Instead of getting the element of your map twice

earnest phoenix
#

Dw i alreay dont have dm intents

boreal iron
#

Use client.commands.has()

#

To check if the element exists

earnest phoenix
#

Okay did

#

Now lets move it to event file

boreal iron
#

Alright will be afk for an hour

#

I believe in you

earnest phoenix
#

It failed

rocky dagger
#

whats the minimum time you can temp ban? i would guess its as short as you want

split hazel
#

less than 1 microsecond

solemn latch
#

no less than your ping 👀

lyric mountain
#

"temp ban" is a concept not a well estabilished thing

#

although you're physically limited to planck time

#

so...well...there you have it, planck time

split hazel
#

I get: free ban
you receive: demotion

solemn latch
ripe prairie
#

Anyone know how to implement a push_front function for a Vector without using insert 3sOwO (c++)

rocky dagger
#

you make a temp ban like this right?js user.ban({ days: time reason: 'reason' });

solemn latch
#

that will delete messages inside the time given

rocky dagger
#

ahh

solemn latch
#

temp bans are bans you unban after a certain time, youll need to track that in a database.

quartz kindle
rocky dagger
ripe prairie
#

It definitely is a bad idea but I just wanna know how efficient I can get with it

#

I have one implementation of it but it's very slow

#

(as it should be)

quartz kindle
#

well i dont think there is any way to do it other than resize + move

#

or alloc a new one and copy

ripe prairie
quartz kindle
#

unless...

#

you make a vector implementation using raw buffers

#

and alloc more memory than needed, but keep adding data to the end

#

lol

ripe prairie
#

I'm in my first month of c++ classes, please go easy on me

#

I'm a python programmer so my intelligence is severely lacking

quartz kindle
#

im not that big on c++ either tbh

#

do you need to keep items in order?

ripe prairie
#

Well if I'm gonna put in numbers from 10 to 1, it should be like, in order yea

#

I'm assuming that's what you mean

quartz kindle
#

ye

ripe prairie
#

yep

#

So it should come out as 1->10

#

Since it's a push front implementation

quartz kindle
#

another way would be to push all the items, then reverse everything at the end

ripe prairie
#

What I'm doing is just

quartz kindle
#

but thats not really a push front implementation

ripe prairie
#

swapping objects every time they're pushed in

#

kekw

quartz kindle
#

yeah, thats another way

ripe prairie
#

but slow

#

sooooooo slow

quartz kindle
#

if you didnt need the order, you could just swap one item xd