#development

1 messages · Page 1928 of 1

earnest phoenix
#

when there is no common server

#

how

#

how do i loop ik i'm stoopid

#

oh

#

k

#

i'll try

#

with the verification done, i can be more free at coding

molten cosmos
#

i need a music player package that doesnt use youtube links

#

i used to use discord music player, does that still work?

lament rock
#

wdym doesn't use yt links

molten cosmos
earnest phoenix
#
client.guilds.cache.forEach
```?
molten cosmos
#

or is there a package that can disable that?

#

basically i need a new music package

#

ik

#

im trying to avoid youtube support in my code

lament rock
#

Depends what sources you want to support. You can use SoundCloud as a default source instead of yt since most bots default to yt

#

All bots route Spotify through yt btw

#

or whatever their default source is

molten cosmos
#

but like is there a package i can use? something similar to discord music player?

earnest phoenix
#

ok

lament rock
#

I've never heard of that package. I would just use soundcloud-scrapper if soundcloud is something you're interested in

molten cosmos
#

no its fine, ill just use discord music player

lament rock
#

alternatively, use LavaLink

molten cosmos
lament rock
#

I also made a lightweight LavaLink rewrite in node, but eh.

earnest phoenix
#

you cant

#

you can only play one song at a time and good luck figuring out the ws of spotify

#

the other bots who plays spotify songs are only getting song metadata and searching it on yt and playing it from yt

#

just looking at spotifys ws connection makes me question tf is this

#

its so confusing

#

i prob can clone spotify but i have to figure out its ws most importantly

#

the api is fine, the ws is the most confusing

#
(node:498) UnhandledPromiseRejectionWarning: TypeError: guild.members.cache.fetch is not a function
#

remove the cache

#

without cache gives errors too

#

and these are blasting the console with 98 rejected ids so i can't get the errors from before

#

i'll remove the cache and send that error

#

whats guild?

#

ik i'm noob, don't judge me```js
client.guilds.cache.forEach(async (guild) => {
const member = await guild.members.fetch(message.member);
console.log(member)
})

#

ok

#

it blasted the console but first it appeared my data

#

like fetched

#
(node:639) UnhandledPromiseRejectionWarning: DiscordAPIError: Unknown Member
earnest phoenix
proven lantern
#

you have one member and looking up that member in each guild

earnest phoenix
#

i exist

proven lantern
#

well they probably dont exist in each guild

earnest phoenix
#

then what can i do?

proven lantern
#

so try/catch

#

or .catch(console.log)

earnest phoenix
#

ok

#

ok

proven lantern
#
const guildsWithMemberInIt = client.guilds.cache.reduce(async (acc, guild) => {
  try {
    await guild.members.fetch(message.member);
    return acc.concat(guild);
  }catch(ex) {
  }
});
#

that might work

earnest phoenix
#

ok

#

that's a bit complex

proven lantern
#
const guildsWithMemberInIt = [] 
client.guilds.cache.forEach(async (acc, guild) => {
  try {
    await guild.members.fetch(message.member);
    guildsWithMemberInIt.push(guild);
  }catch(ex) {
  }
});```
pale vessel
#

Need to use a for loop

proven lantern
#

oof

#

for is a code smell

earnest phoenix
#

[]

earnest phoenix
#

Oh wait, do i need any intent to do this?

woeful pike
#

pushing things into an array in any kind of loop is a smell

#

including forEach

earnest phoenix
#

pls help

spark flint
#

with

earnest phoenix
#

getting that

#

if the user is in any server or it leaved completely the bot

spark flint
#

check if the user is in any server

earnest phoenix
#

how

spark flint
#

what language

earnest phoenix
#

js

spark flint
#

ah i'll wait for someone good with js to help

proven lantern
#

forEach is a code smell too

#

map or reduce can always replace it

pale vessel
#

Dude what the fuck are you on about

proven lantern
#

there are so many array functions

#

i never use most of those

#

if you had to only have one array function it would be reduce

split hazel
#

some of them are quite useless

#

reduce right feels like it could be fit into reducewith an extra param stating the direction

proven lantern
#

i bet they fought about that at the spec meetings

#

i wonder if reduceRight is more efficient than reversing the array and then reducing

#

it wont modify the original array with the reverse() which is better

#

idk

quartz kindle
#

most of those methods exist for convenience, not performance

#

for example a loop with push and a reverse at the end is way faster than a loop with unshift

#

concat is much slower than making a new array and spreading the old one into it

boreal iron
#

Imagine thinking these are many functions, you should take a look into PHP

quartz kindle
#

yes php is even worse

boreal iron
#

There’s like function for any need

boreal iron
#

I call that more user friendly

quartz kindle
#

tell php to decide if they want the array as a first or second parameter

#

and stop mixing it up

boreal iron
#

Omg that discussion again

quartz kindle
#

lmao

#

why are you booing me, you know im right

boreal iron
#

Even if that’s a thing, yeah it’s usability and the inbuilt possibilities are far ahead of Js

proven lantern
#

the most important thing is that the program makes sense

#

at least for applications

#

systems programming is different

boreal iron
#

I also think parameters can be passed as options with PHP 8, no more sort order then

#

But I’m not sure if that counts for all functions

quartz kindle
#

they should rename the lang to p8

#

double acronym

boreal iron
#

Mail me your address, gonna send you over some php enthusiasts bringing you back on the right way, Tim

quartz kindle
#

lmao

#

imagine if other langs also used a recursive acronym

#

sjs > sjs java script

wheat mesa
#

sjsjs

boreal iron
#

Are we going to hate languages because of their names?

#

cough python

quartz kindle
#

ccpp > ccpp c plus plus

#

im not hating

#

im making fun of it

#

its different

#

:^)

#

imagine if they made it php to avoid being confused with harry potter

#

hp

boreal iron
#

Horse power, Sir!

quartz kindle
#

it was more likely because of hewlett packard

#

or whatever the name is

#

the hp that makes laptops

#

honestly the name is ingenious

boreal iron
#

My gosh

#

Comparing it to HP is like comparing something to shit

#

And I mean shit, yes shit shit, the shit leaving your butt

#

There isn’t anything worse than HP not even Java

#

It’s a little off our discussion but it was important to say that

quartz kindle
#

lmao

boreal iron
#

database download worked out successfully btw

#

Quick restart and some fine tuning and I’m still getting a nice response time

#

just the network performance wasn’t great at all but yeah at least I had a consistent connection

quartz kindle
#

ayy

finite wagon
#

I NEED Role Mangament bot command ideas
pls help

wheat mesa
#

Mangament

earnest phoenix
boreal iron
#

Fetching all members in all guilds? Why?

#

Also requires the right intent

#

As well as privileged intent

earnest phoenix
wheat mesa
#

but... why are you fetching like that...

earnest phoenix
#

getting one member, when it leaves a server the bot will check if the user is available in other servers

earnest phoenix
solemn latch
#

might want to use oauth instead

pearl trail
#

its easy to get rate limited, isnt it?

solemn latch
#

yes, if you dont respect ratelimits

earnest phoenix
pearl trail
#

fetching every guild's member in the same time

earnest phoenix
#

ok

solemn latch
#

you can get all of a users guilds in one request

split hazel
#

oh and you constantly have to refresh the token

#

but yeah there isn't a good way of doing this

solemn latch
#

just depends on what you really need I guess.

pearl trail
#

the best way for it is, get the guild member intent and let guild members be cached, and get user via cache instead of fetching

solemn latch
#

huge increase in ram usage though

boreal iron
split hazel
#

if you really insist you could... store ids in a database

#

could go out of sync quickly though

solemn latch
#

^ was about to suggest that

#

without message intent, probably not worth doing, as you cannot update as often too.

#

unless it doesnt need to be 100% accurate

earnest phoenix
#

oh wait if the user ain't in any bot's servers, the bot can't track the user

#

right?

split hazel
#

you can only request basic data about them

earnest phoenix
#

so it's possible to fetch them?

boreal iron
#

Only to get very basic informations

split hazel
#

if you have the ID such as username, tag, creation date etc

boreal iron
#

But since you used the word track, any more discussion is useless

#

Tracking is a no go

quartz kindle
#

you can always fetch users

#

just not members

earnest phoenix
#

ok

#

and if I get the user with client?

quartz kindle
#

from the cache?

earnest phoenix
#

yes

quartz kindle
#

only if the user is cached

pearl trail
quartz kindle
#

theres no efficient way to do that

earnest phoenix
#

so is there any other way to implement this?

quartz kindle
#

what are you storing?

earnest phoenix
#

user ids

#

nothing more

marble juniper
#

I kinda think I could code this better but idk how

#

im just like super unsatisfied with the result

#

lol

quartz kindle
#

what do you use those user ids for?

earnest phoenix
quartz kindle
#

why do you need to store the ids for that?

earnest phoenix
#

so i don't need to?

#

I need help I do not see my server on here or nothing

quartz kindle
#

for fetching user information no?

#

you can just fetch the user anytime

earnest phoenix
quartz kindle
#

i mean what do you do with those ids?

#

then thats not only ids l

#

you said only ids...

earnest phoenix
#

i don't store anything more from discord

quartz kindle
#

are those coins global or per guild?

earnest phoenix
#

global

quartz kindle
#

and discord asked you to do that? where did they said that? email?

quartz kindle
earnest phoenix
#

you're asking the 30 days thing from before?

#

yeah

#

in my verification ticket

quartz kindle
#

you got an email saying that?

earnest phoenix
#

but they said i can inform them if any inconvenience so i let them know that i can't implement it?

quartz kindle
#

well the only thing i can think of is that you did not explain what your bot does and how it works very well in your verification form

#

because thats not a thing they care about

#

my bot literally stores shit for 1 year, and i wrote that in my verification, and it was verified

boreal iron
#

If you wanna delete any user related data then add a last_seen timestamp, create a routine and remove all users which weren’t seen for 31 days

earnest phoenix
#

so i explain it to them?

boreal iron
#

If that’s a concern for you

quartz kindle
#

you made them think your bot is storing much more user information than it actually is

split hazel
#

or you can lie you implemented it trollformation

quartz kindle
#

anyhow, the only way to do what they said is to store guild ids and user ids together

#

so that when a user leaves, you check if that user has other guild ids

earnest phoenix
#

i'll let them know if they misunderstood and if no ._. i'll come back here

slender wagon
#
.addStringOption((option) => option.setName('channelid')
        .setDescription('Insert the id of the channel where your message is located at!')
        .setRequired(true)
        .addStringOption((option) => option.setName('messageid')
        .setDescription('Insert the id of the message that you want to post!')
        .setRequired(true))
post.js:12
        .addStringOption((option) => option.setName('messageid')
         ^

Someone help me out with this shit

boreal iron
quartz kindle
#

yeah

#

i told them i delete info if a user hasnt interacted with the bot for over 1 year

#

although i didnt actually do that yet, gonna do it now in january for the first time

boreal iron
#

Which is what I suggested him a few seconds ago

quartz kindle
#

because i didnt have any kind of tracking setuo before

solemn latch
#

Tbh just logging member/ in the reason is plenty.

boreal iron
#

Makes sense if your bot is in many guilds and you need to reduce the database size

solemn latch
#

Tf

quartz kindle
#

i only added createdAt and lastSeenAt timestaps after like 2 years of running

solemn latch
#

Kek whoops

#

I had that typed hours ago

slender wagon
coral sigil
#

What to do when my bot is getting unknown interaction errors, even when the first thing on client.on("interactionCreate") is await interaction.deferReply()?

quartz kindle
boreal iron
#

Well didn’t defer in time then

#

Happens sometimes

coral sigil
#

It happens like every other time my bot receives a command...

boreal iron
#

Huge network latency?

solemn latch
#

Deferring 100% of the time isn't a good option anyway

#

Imo

coral sigil
#

It was just so you know whats the case here

coral sigil
slender wagon
#
post.js:12
        .addStringOption((option) => option.setName('messageid')
         ^
quartz kindle
#

theres an arrow pointing at setName

#

great error

#

...

boreal iron
slender wagon
#

wooops

#

my bad lmao

#
TypeError: option.setName(...).setDescription(...).setRequired(...).addStringOption is not a function
quartz kindle
#

which doesnt exist

slender wagon
#

but it worked earlier

#

now i added another one and it doesn't work

quartz kindle
#

you added it wrong

#

or did somethig else wrong

coral sigil
# boreal iron Is your code unresponsive then?

The commands work sometimes, and sometimes they dont. Even when making the same command multiple times in a row, its really weird. I timed everything I do after the deferReply and looking at the results, I can say that the problem is not my code or a database connection or anything like that...

slender wagon
#

yeah pretty sure that's the issue

#

can't find out where

quartz kindle
#

show full code

quartz kindle
#

from the defer itself, or from the response after defering?

coral sigil
#

Defer itself.

quartz kindle
#

then you are receiving interactions too late

coral sigil
#

It seems like Im getting the interactionCreate event already late :D

#

yea

quartz kindle
#

log their timestamps

boreal iron
#

So back to network latency

coral sigil
#

Yea it seems that the network is the only thing here

boreal iron
#

I mean it could theoretically also be an issue caused by Discord

coral sigil
#

Yea, but everyone else's bot is working...

quartz kindle
#

it could also be websocket congestion

coral sigil
quartz kindle
#

what other events do you listen to?

coral sigil
#

I listen to interactionCreate, guildCreate, guildDelete, and ready

quartz kindle
#

are your intents also setup to only receive those events?

coral sigil
#

My intents are only "GUILDS"

quartz kindle
#

how long do your interaction responses take on average?

#

why a folder called gitignore?

coral sigil
quartz kindle
#

gitignore is a file

#

not a filder

#

its a text file with the names that you dont want on the repo

marble juniper
marble juniper
#

I tested the regex before and it worked but idk why its not working in my code

coral sigil
#

Its just the names like node_modules

quartz kindle
#

names separated by newlines

#

no quotes

#

yes

coral sigil
marble juniper
coral sigil
#

yep

quartz kindle
# coral sigil Under one second

can you test if your code is blocking the process? ie if you run 3 commands at once, do they all respond simultaneously, or does the next one have to wait for the previous? try asking 2 other people to run the command at the same time

slender wagon
#
interaction.client.guild.iconURL()

is this correct?

earnest phoenix
#

im not sure if this is a good place to put this but
I am trying to get when a interaction was created using interaction.createdTimestamp
while it shows some base of consistency of some kind im not getting the proper data from the unix timecode.
I simply want the minutes from when it was created so my listener doesnt listen to buttons from x amount of time ago
this is my code
Please note the weird numbers are from when i tried to grab it from getHours() though they are completely wrong/incorrect

marble juniper
pale vessel
boreal iron
#

Yeah nvm

slender wagon
#

f how do i access guild with interaction

marble juniper
#

interaction.guild

#

bruh

slender wagon
#

i tried

marble juniper
#

also read the docs

coral sigil
quartz kindle
#

ok so the only option left would be network issues

#

everything else looks fine

#

could be either your vps or discord

#

try logging the raw events and their timestamps

#

to see if you can find any pattern

coral sigil
#

I'll try it out. What would I be looking for?

slender wagon
quartz kindle
#

to see which format it uses

#

could be a string instead of a number or a number in seconds instead of millis

earnest phoenix
#

i misread the graph they shown

quartz kindle
#

alright, so then just compare it to Date.now()

coral sigil
quartz kindle
#

age = Date.now() - timestamp

earnest phoenix
#

was just about to write that xD

quartz kindle
coral sigil
#

Oh, so it is only on interactioncreate event, sry

earnest phoenix
#

i did that and its still weird

#

not sure what Date.now() returns but

#

doesnt look right

quartz kindle
#

maybe a large guild blocks the websocket for a while

earnest phoenix
#

the interaction is from 3-4 hours ago

quartz kindle
#

you can also log your own Date.now()

earnest phoenix
#

ow?

coral sigil
#

I am actually getting guildDelete events from unavailable guilds, but checking for guild.available in guildDelete and guildCreate.

quartz kindle
earnest phoenix
#

it returns

#

something

quartz kindle
earnest phoenix
#

huh?

#

i am logging when someone presses a button using the interactionCreate event

quartz kindle
#

every time a button is clicked, it creates a new interaction

earnest phoenix
#

☠️

quartz kindle
#

so tje createdTimestamp is always fresh

earnest phoenix
#

is there a away to get around this?

quartz kindle
#

you have to check the timestamp of the message the buttons are attached to

earnest phoenix
#

createdAt?

quartz kindle
#

ye

#

or whatever messages use

earnest phoenix
#

thats why copilot was trelling me to use createdAT

coral sigil
# quartz kindle ye thats normal

Okay, i just thought to mention that because it takes like 15 seconds longer for the bot to have the ready event because its garbage collecting or something like that

earnest phoenix
#

it still returns less then 500

quartz kindle
#

welp i g2g

coral sigil
#

@boreal iron Do you have any ideas?

boreal iron
#

Unfortunately I’m driving, can’t really go deep into code suggestions

coral sigil
#

Okay, if you come up with some ideas and you have time and are not driving, let me know

boreal iron
pale vessel
#

Close discord right now

coral sigil
boreal iron
#

If the issue persists it’s probably a network issue on your side

boreal iron
pale vessel
boreal iron
#

I answered it wtf

#

Made a suggestion

slender wagon
#
await i.update({ content: `${cool.content}`, components: [] }); 

so this is how i update a message content inside a interaction, how do i delete this message and not update it. i.delete doesn't exist

#

btw

#
 collector.on('collect', async i => {
#

that's how i is defined

pale vessel
#

You need to delete the original message

#

Wait

slender wagon
#

that's what i am trying to do

pale vessel
#

Is that from a button?

slender wagon
#

mhm

boreal iron
#

Woah interactions and collectors okeh

pale vessel
#

Isn't there button.message?

slender wagon
slender wagon
boreal iron
#

Or interactions in general

slender wagon
#

o it worked

#
 await i.message.delete();  
#

aka button.message

slender wagon
boreal iron
#

I hear that a lot

#

Why even bother with coding then?

quartz kindle
slender wagon
#

Shhh being lazy for this particular project

#

And i work at this one kinda late so my brain is kinda fucked by then

quartz kindle
#

not really related to garbage collection

slender wagon
#

Ooo how can u make that kinda stuff for buttons

#

Even if the bot turns off

coral sigil
#

but then of course, under it is this

quartz kindle
#

thats just discord.js bullshit finalizers

coral sigil
#

yea so how do we fix my prob :D

#

I made a test app and a few commands, i am getting the events instantly on there

#

its has to be either the code or something weird

quartz kindle
#

try running the same code on the test app

#

another test you can try, create a separate client for interactions, without the guilds intent

coral sigil
quartz kindle
boreal iron
#

With exactly your code as I suggested

#

In a different app without all guilds

#

Just your Test guild

coral sigil
#

makes sense

#

sry for not getting it

quartz kindle
#

that would test if the guild events are interfering with interaction events

boreal iron
#

Yee step by step

quartz kindle
#

do interaction events have an intent? or do they bypass intents?

boreal iron
#

No intent afaik

coral sigil
#

I dont think they have intent

quartz kindle
#

so ye no intents

coral sigil
#

ill test the code on the test bot token first

quartz kindle
#

👍

boreal iron
#

But they been requiring the authorization using the scope

#

An intent doesn’t make sense as you have to receive the event

#

Since without a bot scope there’s no gateway connection

quartz kindle
#

you can have interactions via webhook, so you dont really need the bot scope

spark flint
#

(not sure the js way of doing this so referring to python) how do i do something like for entry in entries

boreal iron
quartz kindle
#

for(let entry in/of entries) {}

#

depending what entries is

coral sigil
spark flint
#

i'm getting from my database a list of entries

boreal iron
spark flint
#

another way i know in python i know i could do

for i in range(0, len(entries)):
  title=entries[i].title
  pfp = entries[i].pfp``` etc etc
quartz kindle
#

if entries is an array, use of

coral sigil
spark flint
#

im trying to make my ejs render a card for each entry

quartz kindle
#

for in is for keys
for of is for values (but only works on arrays)

coral sigil
#

I am now very curious on what happens with no intents

boreal iron
#

Well you registered for no events means you basically receive no event other than ready

coral sigil
#

You are correct

boreal iron
#

And connection events

#

Or states

coral sigil
#

So wtf do we do about this? The code works on a bot with 1 guild but not on the main bot

boreal iron
#

Turn on your intents to be same like in your other code

#

Test it again

coral sigil
#

I tested the exact code on the test bot

boreal iron
#

With same intents ?

coral sigil
#

I just tested with no intents on the main bot and received no interactionCreates

coral sigil
#

Test bot had the same code and "GUILDS" intent, just like the main bot.

#

Test bot works really fast, main doesnt

quartz kindle
#

so you dont get interactions without guilds?

coral sigil
#

Test bot used the same db too...

coral sigil
#

And i used global commands, not guild commands

boreal iron
#

Wut really?

#

I’m curious

quartz kindle
#

thats weird

#

theres nothing in the docs about that

coral sigil
#

I'll test again on the test bot this time.

#

Test bot is getting interactions

#

with no intents

boreal iron
#

Did you invite it with the right scope?

coral sigil
#

yea, bot and application.commands

boreal iron
coral sigil
#

Yea but why didnt the main bot get interactions with no intents ::DDD

quartz kindle
#

did you log the raw events?

#

are you getting spammed with anything?

#

besides the initial guild creates

boreal iron
#

Log your ready event please

#

And a timestamp from starting the processs to receiving the ready event

coral sigil
coral sigil
coral sigil
#

ohh i got it

boreal iron
#

Yeah just log the time in ms in your ready event and in the beginning of your process

#

I mean app

#

Useless auto correct

#

In your Main bot

#

You said you didn’t receive any interaction event without intents

#

I somehow believe your bot wasn’t even ready when you tried that

coral sigil
#

Makes sense for you to believe that

boreal iron
#

Means it couldn’t receive events

#

But once it is they will be delivered immediately

#

All missed

coral sigil
#

Okay so testing: no intents, timestamps and when i get the second timestamp, i will try to make a command

#

main bot with guilds

boreal iron
#

Just share the timestamps

coral sigil
#

start: 1637800935, ready: 1637800937

#

that is with no intents

#

so 2 sec

boreal iron
#

wow that’s fast

#

How many guilds?

coral sigil
#

Yea i turned off sharding too for this...

#

Only 77 i think

quartz kindle
#

well no intents means no guilds

#

so it should be fast

coral sigil
#

With intents: start: 1637800974, ready: 1637800994

#

start is logged under the client.login and ready is logged the very first thing in client.on ready

boreal iron
coral sigil
#

I didnt have the "guilds" intent so no guilds for me

quartz kindle
#

you mean the actual websocket ready?

boreal iron
#

Yeah

quartz kindle
#

it gives an array of guild ids basically

coral sigil
#

Do you have anymore ideas?

boreal iron
#

Ok so unresponsive or unavailable guilds aren’t the issue then regarding that timings

quartz kindle
coral sigil
#

Without the intents on the main bot, the commands are not working

boreal iron
#

Huh

quartz kindle
#

didnt you say they worked afterwards?

#

do the raw events work?

coral sigil
#

I might've misunderstood, I'll test the raw events now.

#

Okay so no intents, main bot, raw events are working. But the client.on("interactionCreate") isnt working.

quartz kindle
#

then its discord.js being stupid

boreal iron
#

Main bot right scope as well?

quartz kindle
#

just fire it yourself

coral sigil
coral sigil
#

ill emit interactionCreate on raw interactioncreate?

quartz kindle
#

i dont remember by head, but check the djs source code and make the raw event go through their constructors then emit it yourself

#

it has to be converted to discord.js interaction object

#

anyway im going to be now

#

good luck!

coral sigil
#

:D thanks

boreal iron
#

Oh wow down to Edge, great

coral sigil
#

That is really weird

boreal iron
#

Indeed

coral sigil
boreal iron
#

Hmm not much more to suggest

spark flint
#

if thats the output, then why is ejs rendering an extra field

boreal iron
# coral sigil Are you looking into this anymore?

Something time consuming if I had to would end up specifying a webhook URL for receiving the interactions and to check if you send a commands you immediately receive that webhook or if there’s a delay too

spark flint
boreal iron
#

But that’s probably the last thing to do

coral sigil
woeful forge
#

may i ask, in v-shaped model, can we add new requirements after software development phases was completed? like update the software?

coral sigil
#
message.reply(lvlUpdate).then(msg => msg.delete({timeout: 4500})).catch(err => {})
#

you can do like i sent

#

it catches with no response

boreal iron
#

It’s probably worth the try to ask about your issue in the discordjs server, explaining your issue and what you tried detailed in one message to see if somebody can help

spark flint
#

lol

boreal iron
#

Wasn’t for u

coral sigil
boreal iron
#

Well np

#

At least it one reason to hate djs for being weird

coral sigil
#

For our good night sleep, it seems that the raw event might fire a bit earlier than the client.on interactionCreate, so it might be the way to go

boreal iron
#

If Erwin would be here he would tell you to switch to detritus and all issues would magically disappear

coral sigil
#

:D Whats detritus :D

boreal iron
#

A ts lib

coral sigil
#

And is that any good

boreal iron
#

For people wanna use ms ts shit show

coral sigil
#

I like ts

boreal iron
#

Personal preferences

coral sigil
#

True

boreal iron
#

Tbh

spark flint
#

alr so my forEach loop is adding one extra loop

coral sigil
#

Detritus looks cool tho

#

It has more useless stuff around the important

boreal iron
#

Oh no did I advertise it after blaming anyone who did after all that time?

#

Shame on me

coral sigil
#

:D I had to look it up

boreal iron
#

No no no!!!1!

coral sigil
#

The last thing im doing is switching frameworks :D

#

or libs

#

however u call them

boreal iron
#

Yeah understandable

coral sigil
#

Before that event, I'll have a full discord api wrapper with axios :D

boreal iron
#

Still think it’s code or network related

#

Can’t imagine why there’s always a delay just for you

coral sigil
#

Same feelings

boreal iron
#

I mean it happens quite some time and I also have that issue sometimes

#

But not that frequently

coral sigil
#

Yea for me its like the commands rarely work...

#

But the webhook endpoint thing is interesting, i might test it tomorrow

#

It'll for sure give some interesting results

boreal iron
#

If you haven’t found any other solution it’s worth a try before contacting the discord support

#

But they will probably say it’s an issue related to your code or lib instead of troubleshooting it

#

I assume

coral sigil
#

Well you cant blame them

#

I can imagine the amount of messages like those :D

boreal iron
#

Yeah probably

coral sigil
#

And at the end the issue is in their code

#

But doesnt the test bot working prefectly with the code prove that the code has nothing wrong with it?

#

Ahhhhh, it would be so easy with the old type prefix commands, nothing would be wrong

boreal iron
#

Does the issue only happen for global commands?

coral sigil
#

What are you thinking?

boreal iron
#

Actually nothing tbh I’m out of ideas tho, not sitting in front of the code staring on it makes it hard

#

The event is the same so it’s actually nonsense

coral sigil
#

Can i send a dm

boreal iron
#

Not worth still driving

#

Not that I could look on code on mobile

#

It’s horrifying

coral sigil
#

:D just thought that you could look at it when you are home

boreal iron
#

Gonna take a shower and sleep after tbh

coral sigil
#

Look at it when you have time and motivation to do so

boreal iron
#

Sure why not

wheat mesa
#

detritus is amazing

#

I can confirm with firsthand experience

boreal iron
#

Oh no what did I do

coral sigil
#

:D

#

u summoned them

coral sigil
#

it needs to be lowercase

wheat mesa
#

I read a little bit back but not far enough to get to the gist of what your issue is

earnest phoenix
#

How can I fix this error for my Discord bot?


internal/fs/utils.js:332
    throw err;
    ^

Error: ENOTDIR: not a directory, scandir './commands/.DS_Store/'
    at readdirSync (fs.js:1047:3)
    at /Users/User319183/Desktop/profanityblocker.js/handlers/command.js:5:26
    at Array.forEach (<anonymous>)
    at module.exports (/Users/User319183/Desktop/profanityblocker.js/handlers/command.js:4:32)
    at /Users/User319183/Desktop/profanityblocker.js/index.js:15:37
    at Array.forEach (<anonymous>)
    at Object.<anonymous> (/Users/User319183/Desktop/profanityblocker.js/index.js:14:13)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32) {
  errno: -20,
  syscall: 'scandir',
  code: 'ENOTDIR',
  path: './commands/.DS_Store/'
}
user@user-IMac profanityblocker.js %```
wheat mesa
#

you're running your bot from the wrong directory probably

#

(assuming you use relative pathing)

boreal iron
#

Nah ds_store files are exclusive Mac OS files

#

You’re trying to scan a directory which actually is a file

#

You have to exclude, filter or ignore these files when scanning for directories

#

Or remove them as they’re useless on any non Mac OS anyways

#

If you’re on Mac don’t thread them as folders, they aren’t

#

Generally they are hidden files in Mac like any files starting with a dot in their name

delicate zephyr
#

hmm

lament rock
#

the opposite of sqrt is pow

earnest phoenix
#

O fun math

#

one of the things I hate about my life

delicate zephyr
#

gimme 5 I should be able to do it LUL

#

Thats

#

a steep fucking curve

#

lmfao

earnest phoenix
#

It basically is just straight up

delicate zephyr
#

No

#

its because of the scale I have it at

earnest phoenix
#

that looks cool

#

did you use desmos luke

#

or some other website

delicate zephyr
earnest phoenix
#

o dang

delicate zephyr
#

not a bad curve

#

its okay

earnest phoenix
#

Now I feel dumb

delicate zephyr
#

people will level like crazy though

earnest phoenix
#

cause idk whats going on

delicate zephyr
#

you need exponential gain

#

Oh

#

only after like

#

level 50

#

lmfao

#

2500~ xp for level 10

#

eh

#

seems good

#

anyway

#

lets flip this bitch

earnest phoenix
#

math hurts my brain :c

#

How do typical xp systems work?

delicate zephyr
#

Using equations

#

like that one

lyric mountain
#

Send message, get xp

#

Apply equation to xp, get level

earnest phoenix
#

Does the amount of xp earned go up every level or is the amount of xp just go up and you can take ages to reach the next level if you get high enough

lyric mountain
#

If u use dynamically calculated levels u can even alter the used equation

earnest phoenix
#

Is there supposed to be a level cap?

#

or can it go on forever

delicate zephyr
#

which is nice

#

easy way to alter everyones level without having to change anything in the db

#

Just calculate the level on the fly

#

people find ways

lyric mountain
#

If u use fibonacci as growth equation, after level 20 everything becomes impossible

delicate zephyr
#

so

delicate zephyr
#

as far as I know

#

it would be the following for you xwass

lyric mountain
#

Scary

earnest phoenix
#

skeleton

#

ha nerd

#

too slow

#

woah spam

#

report

lyric mountain
#

Get spooked

delicate zephyr
#

Math.pow(xp * (Math.sqrt(5 ** 5) - 1))

earnest phoenix
#

don't blame em

delicate zephyr
#

I think?

#

dont quote me on that

lyric mountain
#

Err, why sqrt of 5^5?

delicate zephyr
lyric mountain
#

** is pow

delicate zephyr
#

so yea

lyric mountain
#

So sqrt is the inverse

delicate zephyr
#

Math.pow(xp * 4)

#

lol

delicate zephyr
lyric mountain
#

Don't think so

#

Although I'm also bad at reversing equations

delicate zephyr
#

lol

lyric mountain
#

Y = sqrt(x / (5^2 + 1)
Y^2 = x / (5^2 + 1)

#

Y^2 * (5^2 + 1) = x

#

So exp = level ** 2 * (5 ** 2 + 1) ig

delicate zephyr
#

bingo

lyric mountain
#

U could also use the actual number instead of that parens since it's a hardcoded value

#

26

#

exp = level ** 2 * 26

slender thistle
#

Take a break, yeah

hallow stream
#

Hello i full the applictaion of the bot When will you take the roll here and download the bot at top.gg
@here

wheat mesa
#

What

coral sigil
errant flax
earnest phoenix
#

can some one help me with this

#

regex

round cove
#

With what?

#

Is that your stack overflow?

narrow sedge
#

Anybody know how to separate words with each " " for example , I typed "title" "bla bla bla" "blo blo blo" , it will result as

Option 1 is : title
option 2 is : bla bla bla
option 3 is : blo blo blo
#

I was thinking of using the split() method , but I don't know exactly what to split

delicate zephyr
narrow sedge
# delicate zephyr just `.split(" ")` would work

I used that

console.log('"hello world" "hello magic" "hello args"'.split(" "))
``` , it resulted in ```[ '"hello', 'world"', '"hello', 'magic"', '"hello', 'args"' ]```
The result I am looking for is like
```[ '"hello world"', '"hello magic"', '"hello args"' ]```
delicate zephyr
#

then you're looking more for regex matching

#

like "".match(/"[aA-zZ ]+"/gm)

#

that should return an array of all matches

narrow sedge
#

Ok ima try that

delicate zephyr
#

yup

narrow sedge
delicate zephyr
#

No problem

earnest phoenix
#

uh I have regex problem

Discord
Dev

regex /\n/gm
code text.replace(regex," ")
problem nothing happens

cinder patio
#

replace doesn't modify the original string

#

it returns a new one

earnest phoenix
#

Ik i save it into a new var

quartz kindle
#

remove the m flag

earnest phoenix
#

let me describe my whole problem,since it it little bit complicated

#

I want to convert html to plain text without any libary
Text

<span style="..."> text
Test
</span>

Goal is to remove the line break and only output the text

quartz kindle
#

remove the m flag

earnest phoenix
#

it detects it but doesn't want to replace it with "" other work

quartz kindle
#

show code

earnest phoenix
#

nvm when i am at home,I can show the data and so on

quartz kindle
#

if the file is using windows style line breaks, you have to replace \r\n

earnest phoenix
#

I formatted the html using vscode,it could be ,let me try

#

perfect ,it works now,regexr.com doesn't show \r\n in text sadly

quartz kindle
#

👍

earnest phoenix
#

thx tim you saved hours poggythumbsup

spark flint
#

time is a myth, tim is a god

quartz kindle
#

lmao

#

its just experience, im the dude who already wasted all those hours for you

spark flint
#

lol

high crown
blissful falcon
#

hello, i was wondering how to make a say command that can say more than one word, because i have a say command but it just says one word

quartz kindle
#

slice and join

#

after splitting

boreal iron
#

its just experience, im the dude who already wasted all those hours for you

#

listen to the old men kids

quartz kindle
#

yes, listen to this old man ^

boreal iron
#

You’re older, Sir, don’t blame me!

raven urchin
#

Oops didn't mean it here

quartz kindle
#

ops not you

quartz kindle
boreal iron
#

Wtf no

#

That proves you’re older… almost forgot anything 5 min after a conversation

quartz kindle
#

lmao

#

im getting senile

boreal iron
#

Aye I’m at ~10 min, still got some time until I’m down to 5

quartz kindle
#

play a game of league

#

and surrender at 10

earnest phoenix
#

Just submitted my 4th bot onto Top.GG

#

poggers

spark flint
#

nice

earnest phoenix
#

yes

spark flint
#

-bots

#

oh wait

quartz kindle
#

too many bots

spark flint
#

i only have 4

#

they broke luca

#

again

boreal iron
#

What Tim and I wanted to say would be, was there ever a time it wasn’t broken?

spark flint
#

true

#

true

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

earnest phoenix
spark flint
#

yeah no starboard or -bots command now

earnest phoenix
#

It had been answering twice

spark flint
#

thats what is unique about it

earnest phoenix
#

Maybe they fixing it

main trench
#

Custom tags added so more commands can be made

#

Bots coming together well

quartz kindle
lyric mountain
earnest phoenix
lyric mountain
#

I mean, is that a discord feature or a bot configuration?

#

or...*gasp*...dbd

earnest phoenix
#

Hmm mb sorry

main trench
main trench
earnest phoenix
#

I thought you were talking about your new bot feature lol

main trench
#

Yes and no

#

Kekw

main trench
coral sigil
#

@quartz kindle @boreal iron Today the bot has been working perfectly fine, even when I did no changes

wheat mesa
earnest phoenix
#

I got a issue, think about it, try to solve, fail, reset all changes, works fine

wheat mesa
#

I had high ping on a bugged shard once - not sure what caused it - but restarting fixed it

boreal iron
coral sigil
boreal iron
#

Did you check the status site for partial outages in your region?

#

Or high ping

coral sigil
#

I didn't know you can do that

boreal iron
#

Anyways if it works, it works that’s all what matters

#

Well mobile network being down every few meters…
So no chat for me today

split hazel
#

anyone could know whats up? suddenly on my pc monitor faded lines of white objects appear on the screen on the right side of the object

#

kind of as if the object was moving fast

#

its not some weird effect on the os since screenshotting and checking on my phone revels no weird shadow lines

#

doesnt seem like a burn in since the lines immediately follow the bright object with them

wicked pivot
#

Hello I want to make a sweater with a bar system, but I have a problem

function Pourc(max, current, current2) {
            good = `![PCP_BLUELINE](https://cdn.discordapp.com/emojis/912743527891492925.webp?size=128 "PCP_BLUELINE")`
            pk = `![PCP_WHITELINE](https://cdn.discordapp.com/emojis/913481312642404393.webp?size=128 "PCP_WHITELINE")`
            no = `![PCP_REDLINE](https://cdn.discordapp.com/emojis/912743463970279455.webp?size=128 "PCP_REDLINE")`
            let blue = Math.round(current * 10 / max)
            let white = Math.round(current2 * 10 / max)
            let red = 10 - blue - white

            return good.repeat(blue) + pk.repeat(white) + no.repeat(red)
        }```

On image 2 blue, 2 white and 0 red normally but there is red
split hazel
eternal osprey
#
npm ERR! gyp info find Python using Python version 3.8.10 found at "/usr/bin/python3"
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/root/Byetrain1/level/node_modules/integer/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/usr/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/root/.cache/node-gyp/16.13.0/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/root/.cache/node-gyp/16.13.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/usr/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/root/.cache/node-gyp/16.13.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/root/Byetrain1/level/node_modules/integer',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: not found: make
#

why are my modules not installing onto my vps?

pale vessel
#

You need to install build tools

quartz kindle
#

if youre on ubuntu/debian, just run
apt install build-essential

ancient yoke
#

I have an issue with my bot. I have a dev server for it, and I want a role to be added to any guild owner that is using the bot.
Here's what I have so far(I put it in a task to try and fix it; did not work)

@bot.event
async def on_ready():
    #Starts tasks
    print("Starting tasks. . .")
    unpunish.start()
    #check_alpha_testers.start()
    #Declares important variables and makes the global
    print("Declaring variables. . .")
    global home_guild
    global alpha_tester_role
    home_guild = bot.get_guild(898590388053483550)
    alpha_tester_role = get(home_guild.roles, id=alpha_tester_role_id)
    print("DokBot is now operational.")

@tasks.loop(seconds=60)
async def check_alpha_testers():
    for guild in bot.guilds:
        guild_owner = guild.owner
        if str(guild_owner.id) in str(home_guild.members):
            await guild_owner.add_roles(get(home_guild.roles, id=alpha_tester_role.id))

(check_alpha_testers is commented out because that was the task that wasn't working) Whenever the bot get's to the code, it gives this:

Starting tasks. . .
Declaring variables. . .
DokBot is now operational.
Unhandled exception in internal background task 'check_alpha_testers'.
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/tasks/__init__.py", line 101, in _loop
    await self.coro(*args, **kwargs)
  File "main.py", line 1051, in check_alpha_testers
    await guild_owner.add_roles(get(home_guild.roles, id=alpha_tester_role.id))
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/member.py", line 777, in add_roles
    await req(guild_id, user_id, role.id, reason=reason)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py", line 250, in request
    raise NotFound(r, data)

I know that the bot is probably targeting the wrong guild to add the roles. How do I solve this?

lyric mountain
#

sure, shoot your flare

#

use probably levelled up on third message

#

then it went above alas the negative number

#

also u don't need that much parens btw

#

replace (5 ** 2 + 1) with 26

#

gotta reduce calculations whenever possible

#

when first - xp becomes less or equal than zero increase the level

#

ye, it's doing that actually

#

do this

#

console.log('${nextLevel} - ${first - xp}')

#

use ` instead of '

#

show the output

#

bruh

lyric mountain
#

it's a template string

#

not a subtraction

#

it is supposed to write like 1 - 19, 1 - 3, 2 - 7, etc

#

add + 1 to (nextlevel) at first

#

then print it again

#

yes, keep sending messages

#

see if it reaches 2

spark flint
#

what would be the most logical way to schedule daily emails with Python

spark flint
#

alr

lyric mountain
#

so we have a little equation issue

#

change log to this:

#

console.log('Lvl ${currentLevel} (${xp} XP) | Need ${first} XP to next level')

#

we'll find out in a sec

#

ye

#

just renamed it to make more sense

#

round shouldn't cause such issues tho, since it'll at most round +/- 1

#

thing is, "first" is not showing the proper value

#

u said 1 -> 2 should be 26 right?

#

ok, it's not an equation issue

#

lvl 2 should be 104

#

ok, I think I found the issue @earnest phoenix

#

you were right abt the Math.round

#

when it reaches ~7 xp it jumps to the next

#

104

#
let test = Math.floor(Math.sqrt(xp / 26));
if (message.author.id === "431487139298017282") {
  let required = (current + 1) ** 2 * 26
  console.log(`Lvl ${test} (${xp} XP) | Need ${required} XP to next level`)
}
#

probably

#

yes

#

isn't 2 -> 3 working too?

#

left side is current xp

#

right side is xp to next

#

just do toNext - xp

#

I forgor to add subtraction

#
let test = Math.floor(Math.sqrt(xp / 26));
if (message.author.id === "431487139298017282") {
  let required = ((current + 1) ** 2 * 26) - xp
  console.log(`Lvl ${test} (${xp} XP) | Need ${required} XP to next level`)
}
#

as it seems it's getting rounded somewhere

#

floor it

#

ah ic

#

for required? nope

#

it should floor only at level

simple stump
#

This is more of a JS problem, but when storing a string in a SQL database, when attempting to get the data the date is converted to a double.

let day = new Date().getDate();
let year = new Date().getFullYear();
let month = new Date().getMonth();
let time = month.toString() + "/" + day.toString() + "/" + year.toString();
console.log("time: " + time); // outputs 10/25/2021

con.query(`SELECT * FROM playtime WHERE id='` + args[2] + `'`, (err, rows) => {
    if (err) throw err;
    if (rows.length < 1) {
      message.reply("There isn't any data for that user!");
    } else {
      for (var i = 0; i < rows.length; i++) {
        console.log(rows[i].time); // outputs 0.000197921820880752
      }
  }
})
lyric mountain
#

ye, what did u change?

#

ah, ye, forgor abt that too

lyric mountain
simple stump
lyric mountain
#

then use id = :id instead of id = ' + args[2]

#

cuz that'd kill ur db

wheat mesa
#

Yeah careful with SQL

lyric mountain
#

just don't subtract xp

simple stump
lyric mountain
#

yes

simple stump
#

aight. yea that function is more of a test. i have some sql methods that use prepared statements

lyric mountain
#
let test = Math.floor(Math.sqrt(xp / 26));
if (message.author.id === "431487139298017282") {
  let required = ((test + 1) ** 2 * 26)
  let remaining = required - xp
  console.log(`Lvl ${test} (${xp} XP) | ${remaining}/${required} XP to next level`)
}
#

nhe again KEKW

#

sorry, I'm doing driver update while we talk

#

so I'm mixing stuff

#

actually, it gotta be:

wheat mesa
#

Math is fun though

lyric mountain
#
let test = Math.floor(Math.sqrt(xp / 26));
if (message.author.id === "431487139298017282") {
  let required = ((test + 1) ** 2 * 26)
  console.log(`Lvl ${test} | ${xp}/${required} XP to next level`)
}
#

for that

wheat mesa
#

Modeling equations for xp curves can be pretty fun if you know what you want

lyric mountain
#

yes, if u REALLY want to zero the xp relative to current level u gotta offset it

#

like this:

#
let test = Math.floor(Math.sqrt(xp / 26));
let offset = (test ** 2 * 26)
let required = ((test + 1) ** 2 * 26)

if (message.author.id === "431487139298017282") {
  console.log(`Lvl ${test} | ${xp - offset}/${required - offset} XP to next level`)
}
#

this will offset both values to zero on current level xp

#

ye, this one I'm sure

#

nice

#

cuz offsets

#

234 - 104 = 130

#

ye

#

so u subtractr next max with current max

#

also nah, I make such mistakes a lot

#

Math.round is one hell of a trap

#

it was you who noted it first

#

nice

boreal iron
lyric mountain
#

Did it work?

#

Ah nvm, it did

#

Nice

spark flint
#

Nice

#

Gg

round cove
#

needed parens lol

lament rock
#

learning about kill signals is cool

#

I may now use this forbidden knowledge to send a kill signal to everyone I hate >:) /s

slender wagon
#

hi so i am working with vanilla javascript

document.getElementById('main').appendChild(div1);

            document.getElementById([i]).appendChild(div2);

            document.getElementById([i]).appendChild(p);

            document.getElementById([i]).appendChild(p1);

            document.getElementById([i]).appendChild(a);

            let bruh = document.getElementsByClassName('bookContainer')
            const testElement = document.querySelector('div');
            const lineBreak = document.createElement('br');
            testElement.appendChild(lineBreak);
            console.log(bruh)

i append the div from the javascript, but it's not formated html and it leads into problems

#

can u guys help out with that

glacial vapor
#

firefox is stoopid still doesnt support manifest v3 for extension uploads

hollow depot
#

is there a way to create server events in discordjs?

feral aspen
hollow depot
#

wdym, i mean the new section “events” in servers

feral aspen
glacial vapor
#

Its a new feature so its probably not implemented on djs

feral aspen
#

Is it in the Raw API?

cinder patio
#

expect it to be added by 2023 in d.js lmao

glacial vapor
#

I dont kneo

glacial vapor
#

I’m waiting for interaction forms to become real

#

its unreleased feature for bots rn

feral aspen
#

Message component input?

spark flint
#

there

#

@hollow depot

#

guild scheduled events

hollow depot
#

oh i didnt find this in docs, thank you

spark flint
#

no problemo

alpine niche
#

whats the error bruh

quartz kindle
#

literally read?

alpine niche
quartz kindle
alpine niche
#

i

earnest phoenix
#

lol

#

Tim will start to get angry

alpine niche
feral aspen
sly sierra
#

Say it

marble juniper
#

My bot is like a scam link detector and stuff

#

rn im just checking links

#

should I check domains too?

#

what I mean is
check google.com too

#

instead of just https://google.com

proven escarp
sly sierra
#

Yea

marble juniper
#

aka links that are not clickable

proven escarp
#

yes

marble juniper
#

ok thats all I needed thanks lol

proven escarp
#

<3

sly sierra
#

Pog