#development

1 messages · Page 4 of 1

lyric mountain
#

in theory u are free to dm them for support-related questions

#

but again, there are mods and mods

ancient nova
#

I'll just dm them

#

nvm they are not accepting req

quartz kindle
#

you need to be in the server for the bot to work?

ancient nova
#

they said that I need to be in their server to add the bot at all

quartz kindle
#

wut

ancient nova
#

but I couldn't join so I decided not to add it but somehow it got added either way

quartz kindle
#

when/where did they say that

ancient nova
#

on their website

quartz kindle
#

dafuq

ancient nova
#

when I clicked the add bot button it said I need to be in their server in order to add my bot

quartz kindle
#

you need to be in this server

ancient nova
quartz kindle
#

not the bot testing server

ancient nova
#

yeah but I could not join

quartz kindle
#

but you're here?

ancient nova
#

because the invite they provided was invalid

ancient nova
quartz kindle
#

you need to be here, on top.gg server

#

you already are here

ancient nova
#

I know I'm not talking about this bot list

quartz kindle
#

oh lol

ancient nova
#

read dis

quartz kindle
#

you cant talk about other bot lists here

ancient nova
#

my bad

#

@quartz kindle how does github API Work?

#

been reading about command ideas an this one is pretty cool
"The GitHub Discord server command allows you to generate information about a Github repository." is it possible?

quartz kindle
#

the same way any other api works, it allows you to access your github account and do things with it

#

you can fetch public repository information yes, you dont even need a key for that

#

but you need an access token to do other things like publish commits or access private repos

quartz kindle
ancient nova
quartz kindle
#

https://api.github.com/repos/OWNER/REPO

wheat mesa
sudden geyser
#

isn't the rest api deprecated

#

or do they just develop both separately

earnest phoenix
#

The REST API was never deprecated, it's the main API

sudden geyser
#

what's the difference?

earnest phoenix
#

I don't think there's a difference here

lyric mountain
#

What was deprecated is using user + pass

#

Now you're forced to use a token for everything

proven escarp
ancient nova
#

how do I use the lyrics api?

proven escarp
ancient nova
#

I thought it was an API for lyrics?

proven escarp
#

link?

ancient nova
proven escarp
ancient nova
proven escarp
ancient nova
#

of course

proven escarp
ancient nova
#

it appears to need the song ID not a query..

proven escarp
ancient nova
#

this doesn't explicidly show any lirycs

proven escarp
indigo tangle
#

i havent worked with anything like webhooks before, how do i read data that was posted( java)? Either code or the general steps would be very helpful.

ancient nova
#

lyricss

proven escarp
#

search the song, get the document, read document

ancient nova
#

and from what I see you need to write a scrapper to get the lyrics

proven escarp
#

yes

#

indeed

ancient nova
#

so that's pretty pointless

proven escarp
#

no?

#

it does what you want to do: get lyrics

ancient nova
#

writing a scrapper will be slow, I did that with a subdomain scrapper and it was slow

#

unless u have a better way of writing a scrapper than me

#

I just fetched the website HTML and formatted it into JSON

ancient nova
#

that's python

proven escarp
#

the second one isn't

ancient nova
proven escarp
#

you didn't specify a language

#

bro what do you expect

ancient nova
#

sorry, I'm using discord.js

proven escarp
#

you give no info

earnest phoenix
proven escarp
#

help us help you

#

🤦‍♂️

ancient nova
#

then I parsed it into json

#

using a bunch of regex

#

it was really slow

ancient nova
#

took a couple seconds

earnest phoenix
#

In this you're supposed to scrape the HTML of the song page

#

With the ID you were given from the search endpoint

ancient nova
#

ohh that makes sense

#

but do you have a better way of scrapping the HTML?

#

my parsing was slow as fuck it literally took a couple seconds to parse

#

by a couple seconds I mean 5-10 seconds

#

which isn't ideal

earnest phoenix
#

Cheerio is the best way to scrape HTML in JavaScript, it's pretty fast so you can just use that

ancient nova
earnest phoenix
#

Cheerio parses the HTML to nodes, so you can traverse it or narrow it down to whatever you're looking for

#

Have a look at their examples

indigo tangle
#

i havent worked with anything like webhooks before, how do i read data that was posted(i use java)? Either code/pseudocode or the general steps would be very helpful.

earnest phoenix
indigo tangle
#

top.ggs

ancient nova
#
    const lyricsEmbed = new MessageEmbed();
    lyricsEmbed.title(`${lyricsResult.title} by ${lyricsResult.author}`);
    lyricsEmbed.setDescription((lyricsResult.lyrics.length >= 1024) ? (lyricsResult.lyrics.slice(0, 1024) + "and more...") : lyricsResult.lyrics);
    lyricsEmbed.setColor(commandColor);
    
    return message.channel.send({ embeds: [lyricsEmbed] });

would it be better to slice it into pages somehow?

earnest phoenix
lyric mountain
#

Nonono

#

If ur going to use it DON'T use the version listed there

lyric mountain
#

It'll error

earnest phoenix
lyric mountain
#

I switched from the lib to doing it raw (topgg api is quite small and easy to write your own wrapper)

#

And no, it doesn't include webhook afaik

ancient nova
#

whoops

#

wait what

#

how is it thinking it's a funtion

earnest phoenix
#

setTitle()

ancient nova
#

bruh my bad I confused title with the lyrics response I'm too tired

earnest phoenix
#

It's not thinking it's a function, title is a property of the embed instance

lyric mountain
#

It's very easy to setup a simple Spring endpoint if u want to

ancient nova
#

okay that works now about pagination, how does that work again?

earnest phoenix
lyric mountain
ancient nova
ancient nova
#

the lyrics endpoint returns a string I would have to split the text then cast that into an array..

lyric mountain
#

[1, 2, 3, 4, 5, 6] becomes [[1, 2], [3, 4], [5, 6]] for example (chunks of 2 entries)

ancient nova
#

how do I even split a text in two parts?

earnest phoenix
lyric mountain
ancient nova
#

wait do I have to create buttons for the pagination

#

nvm I'll do reactions

#

I hate interaction system 😠

earnest phoenix
#

You can calculate the length first to get an idea of how many parts it'll be split to, and then create an array and iterate over to split accordingly

lyric mountain
#

Buttons are easier to deal with

ancient nova
#

no way u said they're easier

lyric mountain
#

Buddy, I made a whole pagination lib, trust me, they are heaven

vivid fulcrum
#

they're way easier

#

you don't have to bother with spam protection

ancient nova
#

okay can I create a collector without a filter for the buttons?

#

nvm

#

okay how exactly do I detect if I'm slicing the word? if I do simply lyrics.slice(0, 1024) I can slice it in the middle of a word

lyric mountain
#

Regex or iterating over its words

#

U can also split by line count

ancient nova
#

regex boiii

lyric mountain
#

Since lyrics are always structured vertically

wheat mesa
#

don't encourage this behavior kuuhaku

lyric mountain
#

Regex or splitting by line?

wheat mesa
#

regex :C

ancient nova
#

how do I split by word count?

lyric mountain
#

Do I need to repeat it again?

ancient nova
#

yes please

lyric mountain
#

Regex or iterating over its words

ancient nova
#

.. how

#

code?

sudden geyser
#

ooga /w?af+le$/g

lyric mountain
ancient nova
#

I'm too tired to think :>

#

please just give me the 1 line snippet I need it

#

I promise to write the entire collector myself afterwards

#
    // Create the embed for the first page.
    const lyricsEmbed = new MessageEmbed();
    lyricsEmbed.setTitle(`${lyricsResult.title} by ${lyricsResult.author}`);
    lyricsEmbed.setColor(commandColor);
    
    // Lets now create a pagination system if the word count is over the setDescription limit.
    if (lyricsResult.lyrics.length >= 1024) {
        
    } else {
        lyricsEmbed.setDescription(lyricsResult.lyrics);
        return message.channel.send({ embeds: [lyricsEmbed] });
    }  
};
#

it's pretty simple but this is what I fgot for now, if it's over 1024 chars then paginate if not return the lyrics

#

but I haven't gotten to the paginate part yet

#

@lyric mountain you don't have to write the entire script 😭

lyric mountain
#

For example:

String[] words = lyrics.split(" ");

List<String> parts = new ArrayList<>() ;
StringBuilder sb = new StringBuilder();
for (String word : words) {
	sb.append(word);
	if (s.length() >= charLimit) {
		parts.add(sb.toString().trim());
		sb.setLength(0);
	}
	sb.append(" ");
}

if (!sb.isEmpty()) {
	parts.add(sb.toString().trim());
}

// parts will have the chopped text parts
#

There, have fun converting to js

ancient nova
#

that's java

#

please

#

please

#

why are you doing this to me

lyric mountain
#

Well, u asked for code, not for js code

vivid fulcrum
#

split string by space
iterate over the array
if array[index] length + arbitrary string length is over 1024, create another arbitrary string and store current one in an array
else add array[index] to the arbitrary string

ancient nova
#

I feel like you like torturing me

lyric mountain
#

Only a little

#

Gotta exercise those mitochondrias

ancient nova
#

I forgot what even StringBuilder was 😭 I haven't done java in over a year

earnest phoenix
#

This shouldn't even be hard, I don't know how you're struggling with it

lyric mountain
#

It's an optimized way of building strings in a loop

earnest phoenix
#

C'mon androidskull

lyric mountain
#

U can do it with common strings, just won't be as fast

ancient nova
#

okay give me a second I can do it

#

jeez

lyric mountain
#

Go on buddy, ganbare!

sudden geyser
vivid fulcrum
#

if you can't map it out in your mind, map it out with comments in your code and slowly start implementing it

sudden geyser
#

this scares me

earnest phoenix
#

That's the skull emoji that existed in one of the obscure Android phones

sudden geyser
#

how could anyone approve that as a design

lyric mountain
#

I still remember android 3 and it's "satanic pact"

earnest phoenix
#

People approve a lot of shitty design, so I'm not surprised

lyric mountain
#

I think it was android 3

vivid fulcrum
#

up until android 12, the sparkles emoji (✨) was a box with sparkles in it on samsung

don't question brands

lyric mountain
#

The one with the zombies image as easter egg

sudden geyser
#

samsung has some awful designs

vivid fulcrum
#

almost

sudden geyser
#

notable the grinning one

ancient nova
#

is this even JS or am I getting confused

for (object in Object) //do something
lyric mountain
#

Of

ancient nova
#

of?

lyric mountain
#

In will get the indexes iirc

ancient nova
#

wot

sudden geyser
#

It's valid JS, but probably not what you're looking to use.

earnest phoenix
lyric mountain
#

If ur converting what I wrote, what u want is for (word of words)

#

Words being an array not object

earnest phoenix
#

And better to also use let or const before the variable name in that expression

lyric mountain
#

Just noticed I said almost the same thing as volt

ancient nova
#
        const words = lyricsEmbed.lyrics.split(" ");
        const parts = [];
        let sb;
        for (word of words) {
            sb.append(word);
            if (sb.length >= 1024) {
                parts.add(sb.toString().trim());
                sb = 0;
            }
            sb += " ";
        }
        
        if (!sb) {
            parts.add(sb.toString().trim());
        }
``` how is this?
#

didn't test idk if it's going to work

earnest phoenix
#
for (const word of words) ...
ancient nova
#
  • forgot to change some lines now I only noticed
lyric mountain
#

Append would be +=

ancient nova
lyric mountain
#

Which is basically concatting strings

earnest phoenix
lyric mountain
#

Ye, u need to initialize it with ""

ancient nova
#

there that should do it I think

earnest phoenix
#

sb is already a string so there's no point in calling the toString() method

lyric mountain
#

Thaaat too

ancient nova
#

okay that's one optimization

lyric mountain
#

I had to call toString because in my code it wasn't one

ancient nova
#

now how exactly do I use that?
parts[pageNumber]?

vivid fulcrum
#

id suggest checking if you're going to exceed the limit before concatenating strings, but ig it doesn't matter since the char limit in embed descriptions is 4096

lyric mountain
#

Ah, good catch

#

But ye, 1024 is a pretty safe value with a ton of error margin

lyric mountain
#

Then increment it and update the message with the part in that index

ancient nova
#

should I start with 0?

lyric mountain
#

Ye

earnest phoenix
#

You're supposed to reassign it to an empty string, not 0

ancient nova
#

whoopss

#

almost done

#

wonder if I can make it work first tryy

earnest phoenix
#

And the last condition is supposed to be sb not !sb, because it's supposed to check if the string is not empty

lyric mountain
#

Pagination ain't hard, u just cut the bread and eat each slice individually

ancient nova
#

the hard part for me is the collector lmfao

#

second time using it ever in my entire life

#

bruh it's taking so long

#

yall still here?

lyric mountain
#

Yep, partly

ancient nova
#

done

#

gotta upload to hastebin cause it's too long

#

hope this code doesn't hurt your eyes too much

#

so will this work or nah?

#

wanna get it first try if I can so won't test until I get yalls opinion

lyric mountain
#

I don't know much abt how djs collectors work, but at first glance it's all right

ancient nova
#

okay then time to test it out

lyric mountain
#

Did ur ide say anything?

ancient nova
#

Cannot read properties of undefined (reading 'split')

#

that's what it said

#

after compiling

lyric mountain
#

Usually most syntax-related issues can be solved before clicking run

#

Sometimes even logic-related issues

ancient nova
#

which is my fault

#

so Imma fix that rn

lyric mountain
ancient nova
#

that's why I hate those fucking dumbass fucking interactions

#

no idea how to fix that shit

wanton pawn
#

what is your problem?

boreal iron
#

Because you didn’t respond in time

ancient nova
#

"This interaction failed"

wanton pawn
#

like

#

in vscode

ancient nova
ancient nova
wanton pawn
#

with interactions

#

discord gives you about like 15 seconds i think

ancient nova
#

I don't have copilot or whatever yall use I just have intelisense

wanton pawn
#

thats fine

#

you have to deferReply

#

meaning it will do the "bot is thinking..."

#

and then when you finish your code

#

you do interaction.editReply()

ancient nova
#

I have a function to either follow up or reply

boreal iron
wanton pawn
#

lol

#

yea

#

i forgot

#

very short

ancient nova
#

no?

#

I don't think so?

wanton pawn
#

thats the issue

#

@ancient nova are you able to call?
i can explain

ancient nova
#

no I gave it a fucking 30 second timer in the collector

wanton pawn
ancient nova
wanton pawn
#

its okay you don't have to speak

#

just listen

#

i hate typing 💀

ancient nova
#

I can't ion got headphones near me and if I make any noise I'm dead

wanton pawn
#

💀

#

nice

ancient nova
#

should I send the updated code?

wanton pawn
#

can i see the code @ancient nova

#

yea

ancient nova
#

ik yall hate the way I write my code so it may be a lil confusing

boreal iron
#

The collector is only there to collect a response but you need to defer interaction in the first place or responding after 30s won’t work

#

You will also get an error like unknown webhook

ancient nova
lyric mountain
#

The timer in collector is related to the collector not the buttons as fake said

ancient nova
#

if anyone is wondering this is the replyOrFollowUp function

function replyOrFollowUp(interaction, ...args) {
  return interaction.reply(...args).catch(() =>
    interaction.followUp(...args)
  );
}
lyric mountain
#

U need to defer if ur going to take longer than 3s

wanton pawn
#

where tf are you running the interaction

#

💀

#

like where is it

ancient nova
#

how do I defer and where do I defer?

ancient nova
wanton pawn
#

@ancient nova do you understand what interactions are?

#

becuase this looks like code that was meant for like djsv12

wanton pawn
#

can you console.log inside this

#

and check if this code is even running

boreal iron
#

He’s actually massively confusing himself with his collectors and interactions all the time

wanton pawn
#

like i have never seen someone write code like this

#

💀

#

i mean

#

i guess

#

@ancient nova tbh my opinion is too actually just watch a video on best practices for interactions

ancient nova
ancient nova
#

I just need to fix that you said I need to defer it somehow right?

#

how?

wanton pawn
#

okay

#

i will try

ancient nova
#

please bro 😭

wanton pawn
#

if (i.id === "basckwardsBtn")

#

do

ancient nova
#

ye I updated something cause I had an error in the code either way but I fixed it now

wanton pawn
#
await i.deferReply();
ancient nova
#

it still says interaction failed tho

wanton pawn
#

yea

#

it still gonna say that

ancient nova
wanton pawn
#

you can't use tho if you do defer ply

ancient nova
#

bro then what's the point :/

wanton pawn
#

the point is

#

you never reply

#

💀

#

thats why it says interaction failed

ancient nova
#

bruh then it won't work at all

wanton pawn
#

💀

#

hmm

#

okay 1 sec

ancient nova
#

it will fail if u don't reply at all

#

that's why I'm saying interaction system IS SFUCKING GARAGAE TRASH

wanton pawn
#

hmmm no @boreal iron i think it can reply in 3 seconds

ancient nova
#

just stick to the reaction collectors

wanton pawn
#

sounds like just you

#

im lovin it

ancient nova
#

either that or I'm legit retarded cauuse I can't get some 2 buttons to work

boreal iron
#

It’s pretty easy as I explained before
Your collector just collects the interactions for you like you would receive them in your event

That means pressing the button triggers the interaction and your collector collects it
You then have 3s to respond to it or defer it

#

(to respond later)

ancient nova
#

then how did my rock paper scissors game work?

wanton pawn
#

so

#

look at this

#

the thing is

ancient nova
#

u can respond anytime in 30 seconds and I never defer it

boreal iron
#

Can’t watch code while driving

wanton pawn
#

yae

#

don't lol

ancient nova
wanton pawn
#

you can't

ancient nova
wanton pawn
#

it has to be defered

ancient nova
wanton pawn
#

bet

ancient nova
#

dm

boreal iron
#

When you press your button your collector collects the interaction, log that

#

To see if that actually works accurately

#

If so use interaction.deferReply()

#

You can then respond with editReply() later

#

Also sending a followUp of course

#

Really don’t know why you always struggle with interactions

#

Any interaction always expects a response immediately or in less than 15 mins after deferring the response

ancient nova
#

yo @boreal iron @lyric mountain I fixed it

lyric mountain
#

Nice

ancient nova
#

the buttons work and the backwards button kinda works but ur pagination script don't work

#

ERROR Unhandled rejection: TypeError: Cannot read properties of undefined (reading 'toString')
TypeError: Cannot read properties of undefined (reading 'toString')

#

if I do parts[0] which is the first page it works but it doesn't appear to store the second page

#

cause if I do parts[1] it's undefiend

#

any ideas?

#

want the updated code?

#

please @lyric mountain ik u can fix that 😭

lyric mountain
#

Hm, ur forward button is reversed

ancient nova
#

nono I fixed that

#

do u need the updated code?

lyric mountain
#

Yes

ancient nova
lyric mountain
#

if (!sb)

#

Invert that

ancient nova
lyric mountain
#

"if there's anything remaining, add as a chunk"

ancient nova
#

somehow it created a third page, interaction failed at the 2nd and I can't go the the third one

lyric mountain
#

Remove the + 1 from total pages

#

If the array has 2 entries it'll already return 2

#

Index counts from 0, but size counts from 1

ancient nova
#

oh I see it's my bad thinking

#

although why did it fail?

lyric mountain
#

Maybe ur trying to access page 2 (third item)

#

Which doesn't exist

#

currPage < parts.length

#

Not <=

ancient nova
lyric mountain
#

Btw, don't trust === that much when checking ranges

#

Weird things 🌈 happen 🌈

#

Always use < or > (and their "or equals" counterparts)

ancient nova
#

I'm starting to really hate javascript 😭

#

in javascript weird things happen over EVERYTHING

lyric mountain
#

That ain't really a js thing, happens in any lang

ancient nova
#

haven't seen that happen in any others I code with, on some === doesn't even exist

lyric mountain
#

All it takes is a little double click and ur out of the boundaries

#

Or concurrency issues

#

Like 2 things updating the same variable

ancient nova
#

:dude maybe that's what caused the first interaction error

lyric mountain
#

Worth a try

ancient nova
#

anyway it seems to work now so W

#

ty for the help

lyric mountain
#

Yw

ancient nova
#

also is voice channel pinging a thing

#

how is that even a thing

boreal iron
#

Voice channels have chats iirc

#

Only if you’re inside

ancient nova
#

lmfao

wheat mesa
#

yeah vcs have chats

#

relatively new feature, probably only been out to every platform for a few months

lyric mountain
#

And of course totally necessary

#

As if voice channels could handle twitch-levels of chat

earnest phoenix
#

does sb know how I hide my token in a public repository

#

I am trying to use replit and synced it up with my github (desktop)

wanton pawn
#

did you do this just now or made the current repo public?

earnest phoenix
#

I use .env where my token is, and

#

I tried .gitignore where I have .env inside

wanton pawn
#

why didn't that work?

#

@earnest phoenix

earnest phoenix
#

no idea

#

also those files seem public to anyone

wanton pawn
earnest phoenix
#

cant

#

im using replit

wanton pawn
#

ah

#

okay

#

are you able to call

#

i can show you what to do

earnest phoenix
#

sure

#

but can't talk

warm ferry
proven escarp
#

This should work

lyric mountain
#

git rm -r --cached . && git add .

lyric mountain
eternal osprey
#

hey guys i am currently making an invite tracker to track how many invites a user has:

#
   member.guild.fetchInvites().then(guildInvites => { 
        guildInvites.each(invite => { 
            if(invite.uses != client.invites[invite.code]) {
console.log(invite.uses)
}
}
}) ```
#

The code shows 250 users, but 125 left.

#

Is there any way to make the bot display 125 instead of 250?

lyric mountain
#

lemme help me read that:

hidden gorge
#
passport.serializeUser((user, done) => done(null, user));
    passport.deserializeUser((obj, done) => done(null, obj));

    passport.use(new Strategy({
        clientID: config.website.clientID,
        clientSecret: config.website.secret,
        callbackURL: config.website.callback,
        scope: ["identify", "guilds", "guilds.join"]
    },
    (accessToken, refreshToken, profile, done) => {
        process.nextTick(() => done(null, profile));
    }));```
lyric mountain
#
member.guild.fetchInvites().then(guildInvites => { 
  guildInvites.each(invite => { 
    if(invite.uses != client.invites[invite.code]) {
      console.log(invite.uses)
    }
  }
}) 
lyric mountain
#

then just do storedUses - (storedUses - currentUses)

lyric mountain
forest drift
#

hey so im trying to send a map as a message. So for example you know how if you were to console.log(message) it would show a whole map? How would i send a map in a message that looks how itd look if you console.log that map?

lyric mountain
#

.toString()

#

console.log casts everything to string internally

eternal osprey
#

It for example shows 1788, while 500 people already left. They are of course not stored already.

#

The storage starts as soon as the bot is up. However, is there a way to check for each one of those 1788 users if a user already left?

civic scroll
forest drift
#

ok so how would I auto format json in a message?
Example:

{"hello":{"test":"1","test":"2"}}

to

{ 
  "hello":{
    "test":"1",
    "test":"2"
  }
}
lyric mountain
earnest phoenix
#
client.users = [{ user: "test" }, { user: "test2" }]
const attachment = new MessageAttachment(Buffer.from(client.users), 'backup.txt');
message.channel.send({ files: [attachment] });

Someone know why it send an empty attachment (using djs v13.6.0)

lyric mountain
#

you need to set a periodic task to refresh the invite values

vivid fulcrum
civic scroll
#

@forest drift

wise crown
#

how to delete someone from team ?

vivid fulcrum
civic scroll
earnest phoenix
civic scroll
#

so you use inspect to return the pure string representation of the object

forest drift
#

thanks

civic scroll
#

btw beautify is an external library

earnest phoenix
civic scroll
#

no

#

i said

#

format

#

so object -> string

#

parse does not return the string

#

@lyric mountain how can i not be naive

surreal sage
#

Coding Discord.js
<Role>.members doesn't give out all members and not at the same time, like maybe you do the command once: nothing, twice: 1 member, third time: 2 members

civic scroll
surreal sage
#

Fetch how?

civic scroll
#

since that only represents cached data

#

hold on, fetching docs

#

sayuri is rusty

lyric mountain
civic scroll
surreal sage
#

Ah

civic scroll
#

you need to access a RoleManager instance

#

then call <RoleManger>.fetch()

#

that way you don't have to fetch the whole guild

#

alright do <Guild>.roles.fetch()

surreal sage
#

Ah

civic scroll
# surreal sage Ah

anything that has Manager in its type name has the capability to fetch

surreal sage
#

it aint work

civic scroll
#

show me how you called it

surreal sage
#
 interaction.guild.fetch().then(async (guild) => {
                                await guild.roles.fetch()
                                staffRoles.forEach(r => {
                                    guild.roles.cache.get(r).members.forEach(m => {
                                        staffMembers.push("<@" + m.user.id + ">")
                                        console.log(m.user.id)
                                    })
                                })
                                managementRoles.forEach(r => {
                                    guild.roles.cache.get(r).members.forEach(m => {
                                        managementMembers.push("<@" + m.user.id + ">")
                                        console.log(m.user.id)
                                    })
                                })```
#

you can practically ignore the last parts

civic scroll
#

bruh

#

you ignored the return value

surreal sage
#

You ain't told me what to do w it

civic scroll
surreal sage
#

kk

civic scroll
#

alright gimme a sec

surreal sage
#
                            interaction.guild.fetch().then(async (guild) => {
                                let roles = await guild.roles.fetch()
                                staffRoles.forEach(r => {
                                    roles.get(r).members.forEach(m => {
                                        staffMembers.push("<@" + m.user.id + ">")
                                        console.log(m.user.id)
                                    })
                                })``` still nothin
#

and yes r is a id

civic scroll
#

wait

#

what was the call to interaction.guild.fetch() for

surreal sage
#

idk ask yourself

civic scroll
#

?????????

#

alright

quartz kindle
#

that has nothing to do with it, afaik discord does not offer a way to get all members with x role without fetching all members first

surreal sage
quartz kindle
#

and to fetch all members you need the members intent

civic scroll
#

assume he has it

surreal sage
#

guild.members.fetch() did the job

#

ty

civic scroll
#

oh

earnest phoenix
#

How cn we fetch user votes in bot?

near stratus
#

use webhooks for accurate results

sharp geyser
#

Also why the heck were they fetching all roles just to get a specific one later

near stratus
#

some people seem to have weird use cases

wooden ember
#

when im looking through search results on github why does it say "you've exeded a secondary rate limit." ?

#

happens every now and again compleatly at random

#

some times its every time I go to the next page and some times its only once in about 10 pages

#

been happening for a couple of years but just curious

proven escarp
#

Are you using your user tokens in a headless browser for scraping or something like that with the API with the search feature?

lyric mountain
#

is there any way of getting a random row from a sql resultset without using ORDER BY random()?

boreal iron
#

Not that I know

#

Also is random() an alias of rand()?

#

Other methods to assign a new unique ID are significantly slower than this

earnest phoenix
#

when i install discord-backup package it give me this error

#
            {
              id: int.guild.id,
              deny: ['VIEW_CHANNEL', 'SEND_MESSAGES']
            },
            {
              id: int.member.id,
              allow: ['VIEW_CHANNEL', 'SEND_MESSAGES']
            },
            {
              id: client.user.id,
              allow: ['VIEW_CHANNEL', 'SEND_MESSAGES']
            },
            {
              id: ['1001550302291435650'],
              allow: ['VIEW_CHANNEL', 'SEND_MESSAGES']
            }
          ]
        });```

How Do I Add a Role Permission
Rol İzni Nasıl Eklerim
lyric mountain
earnest phoenix
boreal iron
#

There’s already one running on that port

#

Maybe the same process but not stopped carefully

lyric mountain
earnest phoenix
#

😦

boreal iron
#

Kill all processes and restart to see if the error still occurs

earnest phoenix
boreal iron
boreal iron
earnest phoenix
lyric mountain
boreal iron
#

This wouldn’t make sense

#

Selecting a random column?!

#

You wanna select a random row

earnest phoenix
lyric mountain
#

u can call functions directly, no need for SELECT * FROM function()

boreal iron
#

Ah well maybe they renamed it to random but by default it’s rand iirc

earnest phoenix
earnest phoenix
boreal iron
#

They’re a little bit differently

ancient nova
#

anyone got a cmd idea?

earnest phoenix
#

A command that gives you command ideas

ancient nova
boreal iron
#

Voltrex big brain freerealestate

earnest phoenix
ancient nova
#

btw I'm legit 3 servers away from verification

earnest phoenix
#

it's so hard to think about it

ancient nova
#

too bad none of these servers came from top.gg

earnest phoenix
boreal iron
#

Your command ideas usually end in this channel since you’re doing stuff weird sometimes confusing yourself

earnest phoenix
ancient nova
earnest phoenix
boreal iron
#

Why don’t you tell us what you need and we provide the code?

earnest phoenix
earnest phoenix
ancient nova
#

smart so onjoin if member is a bot insantly ban them?

earnest phoenix
#

You should try implementing GTA V in a Discord bot

#

Surely will get a ton of attention

ancient nova
boreal iron
#

Tf who’s still playing that old game nowadays

ancient nova
#

bro gta v is still downloading for me

earnest phoenix
ancient nova
#

I started that download god knows how long ago

boreal iron
#

Hmm isn’t it already like 10y old?

ancient nova
#

it is but it's constantly updated

earnest phoenix
#

And Rockstar Games is still milking the shit out of the game

#

Milking it dry

ancient nova
boreal iron
#

So people are still playing it because Rockstar games couldn’t take down the modding community

#

I guess

#

Take2Interactive took down the first huge community projects on modding iirc then the source code got leaked and others didn’t give a fuck

#

I think that was story

#

Don’t remember anymore

earnest phoenix
#

I remember when someone that just regularly plays GTA V debugged the game to find out why the online load time was so slow, and apparently they fixed it and let Rockstar Games know about it, and now they work at Rockstar Games

earnest phoenix
boreal iron
#

Not really but I know the original developers of the gtav online (private multiplayer servers) have moved to max payne 2 or 3

earnest phoenix
boreal iron
#

There are clever people out there

#

Always

#

Which bother with stuff nobody else has time for or wanna deal with it seems

rocky dagger
#

i have a subcommand called add breeder with a option using autocomplete but it doesnt work while i got another command with autocomplete named claimed that worksjs if (interaction.type === InteractionType.ApplicationCommandAutocomplete) { console.log(1) if (interaction.commandName === 'claim') { const focusedValue = interaction.options.getFocused(); const choices = ['option 1', 'option 2']; const filtered = choices.filter((choice) => choice.includes(focusedValue) ); await interaction.respond( filtered.map((choice) => ({ name: choice, value: choice })) ); } else if (interaction.commandName === 'add') { const focusedOption = interaction.options.getFocused(true); console.log(focusedOption) let choices; if (focusedOption.name === 'breeder') { choices = ['option 1', 'option 2']; } const focusedValue = interaction.options.getFocused(); const filtered = choices.filter((choice) => choice.includes(focusedValue) ); await interaction.respond( filtered.map((choice) => ({ name: choice, value: choice })) ); } }``````js module.exports = { data: { name: 'add', description: 'Adds a dino or breeder', options: [ { name: 'breeder', description: 'Assignes a user to a dino to breed', type: 1, options: [ { name: 'user', description: 'Select a user', type: 6, required: true, }, { name: 'dino1', description: 'Enter a line for the user to breed', type: 3, required: true, autocompleate: true, }, ], }, ], }, async execute(interaction, client, colors) { ... } }

ancient nova
#

can you get users discord bio using discord.js?

rocky dagger
earnest phoenix
earnest phoenix
rocky dagger
#

the options doesnt appear

earnest phoenix
#

autocomleate -> autocomplete

ancient nova
earnest phoenix
#

There isn't really an exact way of getting it, you would have to scrape the Discord profile somehow

rocky dagger
spark flint
#

as that would be selfbotting

earnest phoenix
#

There is another way of getting it which is through oauth2, prompting the user to consent to what information you'll be looking at that is not exposed to the public Discord API

ancient nova
#

I'm just gonna do a GET request

spark flint
#

discord doesn't expose it via the API tho

#

as volt said

ancient nova
#

that's the backend api though

#

that won't work?

ancient nova
#

what does this mean?

winged temple
#

add a category

#

to ur bot

#

so if its moderation

#

type moderation

boreal iron
#

Looks like they enforce that bullshit now in preparation of the app discovery release

winged temple
#

yupp

ancient nova
#

ion even gotta domain mine expired

boreal iron
#

You can already configure the app discovery site as well as watching a preview of it

#

Not really finished yet

#

Also some features or categories you can select require a 2FA

#

smh

boreal iron
winged temple
#

dont u need a passport or drivers license?

boreal iron
#

The TOS url can target anything like a document as long as it’s publicly accessible

winged temple
#

or identification

boreal iron
#

For the verification yeah

winged temple
#

rip me

#

passport expired

#

everything

#

is expired

#

would they still accept expired id?

boreal iron
#

Not passport

#

ID card

lyric mountain
#

how tf u let every single document expire?

boreal iron
#

Or drivers license

#

Well mine is expired as well

#

I don’t give a fuck

ancient nova
#

anyone know any cool html effects I can put on my bots website without much effort?

winged temple
#

passport expired in 2016

#

i dont have an id card

#

cus never needed

#

until now

#

cant get a drivers license until 18

eternal osprey
#

hey guys, in mee6, does 1 message equal to one xp being earned?

#

I can't find it in their docs and i am trying to copy their leveling system

winged temple
#

no

#

ill give you an example

eternal osprey
winged temple
#

if you send 100 messages a minute you will earn 1 xp

#

if you send 1 message a minute you will earn 1xp

#

the amount of messages doesnt matter

#

therefore spamming wont benefit you

eternal osprey
#

so basically, it has a cooldown set to 1 minute. It for example adds you to a new set. After that cooldown, it checks if your id is in and adds you the xp point? Owh that's cool

#

Thanks man

winged temple
#

np

cursive musk
#

Hi everyone, i'm currently trying to login to spotify through their endpoint but i keep getting
errorInvalidCredentials
though they are working when i'm manually authenticating, does anyone have any idea ?

    cookies = "__Host-device_id=AQAtNH7JdlQVkNv2GQK30xp13HCVyrMtRC2kkXKp36BhEreUWnPfax8vk8eo_ATeQKIPY4xE9eCQzdskQQ4ivxTXx-mVgWmZjPg;__Host-sp_csrf_sid=" + csrf_sid_token + "; __Secure-TPASESSION=AQBpIXkph5jxCu3Zs9t4qWKkQbLKc/hNbM+GVLzp3e0hRwfVae8sJJ++EypZ/TlzzcZixQJT6INy8NFiSKYIqsvT2kWa0/6EmPU=; sp_sso_csrf_token=" + csrf_token + "; sp_tr=false"
    payload = {
        username: email,
        password: password, 
        remember: "false", 
        recaptchaToken: captcha_token, 
        continue: "https://www.spotify.com/us/account/overview/"
    }
    
    let header = {
        headers: {
            "Accept" : "application/json",
            "Alt-Used": "accounts.spotify.com",
            "Connection": "keep-alive",
            "Content-Type": "application/x-www-form-urlencoded",
            "Cookie": cookies,
            "Origin": "https://accounts.spotify.com",
            "Referer": "https://accounts.spotify.com/en/login?continue=https%3A%2F%2Fopen.spotify.com%2F",
            "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0",
            "X-CSRF-Token": csrf_token
        }
      }
      
    axios.post('https://accounts.spotify.com/login/password', payload, header).then(function (response) {
        console.log(response.data);
    }
    ).catch(function (error) {
        console.log(error)
    }
    );
eternal osprey
#
let lvl = 0
let xp = 0
let m = 5 * (lvl ^ 2) + (50 * lvl) + 100 - xp
let final = xp / m
console.log(final)``` Would this be a valid statement (final = xp / m > 1), to check if the user can levelup?
quartz kindle
#

^ is a bitwise operator, not a power

#

you can use ** if you want powers

eternal osprey
eternal osprey
#

guys, what is that thingy called: that displays the percentage of a total? So if i am level 50 of the 100, the bar is half full

#

\0/

boreal iron
#

Progress bar

eternal osprey
#

Whahahah thanks fake.

eternal osprey
lyric mountain
#

also, I'd recommend not saving the level at all, instead calculate from the formula anytime u need it

#

else u might face desync issues where xp doesn't reflect the level at all

lyric mountain
#

like, mine is 15/msg

#

and level formula is sqrt(xp / 100)

#

at around level 400 it takes almost a whole week to level up

ancient nova
#

bro ain't no way

#

I just spent 3 hours making a website, getting a domain writing terms and privacy policy and they hitting me with that

austere surge
#

bruh

lyric mountain
eternal osprey
lyric mountain
#

holy

#

poor users

#

ah wait, different OP

ancient nova
#

I think

#

I filtered each server by owner ID and then left each leaving only 1

#

now I got 67 servers from 76 I hope that will be enough

#

but now I gotta wait ages again cause nobody be adding my bot 😭

dry imp
#

meanwhile i have like 5 testing server and didnt have to deal with that shit

pearl trail
eternal osprey
#

hey is there a way to use an import package system, and transform it into a require?

#

I can remember i did it once

quartz kindle
#

you cant transform it into a require

#

but you can use the async import function

radiant kraken
quartz kindle
#

afaik thats for using require inside an esm project to import cjs libs

#

if you have a cjs project, you cant use require on an esm package

indigo tangle
#

i was wondering how i would use java to read the POST data from the webhook. I have very limited experience with servers/clients and no experience with reading/writing to https.

lyric mountain
#

I think I answered u yesterday

#

what are you using for receiving http requests?

indigo tangle
lyric mountain
#

define "reg java stuff"

indigo tangle
#

without maven imports

lyric mountain
#

are you willing to keep your sanity?

indigo tangle
#

yeah

lyric mountain
#

then use maven imports

indigo tangle
#

well i guess i can import then lol

lyric mountain
#

more specifically, Spring Boot

indigo tangle
#

alr ill have a look ill come back if i have questions

lyric mountain
#

sure

indigo tangle
#

ty for your help

lyric mountain
#

inb4: you'll come back in exactly 47 minutes
reason: can't find out how to import spring boot

#

it's not as clear on how ur supposed to do it, had to spend quite a few minutes figuring out what exactly I had to import

#

see baeldung, it's probably the best reference you'll find

dry imp
#

tho there is a week where my bot grows very slowly

next eagle
next eagle
earnest phoenix
#

uh, how would I get the width and height of an image in js?
I am also using undici and canvas. I am trying to make a visible square 1:1 frame centered within the original file size of the image

#

like, why the fuck is discord not using an example of a case where natural value width and height of the image is needed, why use avatars as an example

#
const { body } = await request(`https://media.discordapp.net/attachments/9998572750932394763/1001608114395363419/IMG_20220622_051020_923.jpg?width=427&height=605`);
        
const avatar = new Canvas.Image();


//const canvas = Canvas.createCanvas(??????, ??????);```
earnest phoenix
#

And access it's width and height properties to get the values you need respectively

earnest phoenix
#

const loadImage = await Canvas.loadImage(url)

#

Yes, that's correct

#

oh

#

I had to add .width and .height to it ig

#

I couldnt see the full object

#

The width and height properties are getters, not normal properties, that's why they're not shown when you log it

#

the width and height aren't correct values

#

the image looks weird

#

it's supposed to have a larger height

#

I'm gonna have to remind you that the Discord CDN does not allow you to just resize the image by query parameters in the URL

#

nevermind

earnest phoenix
#

Both of the width and height query parameters are invalid, only the size query parameter is the valid one

#

and how'd I create canvas based on size

#

You can then again get the width and height properties, they'll give you the correct sizes you need to work with

#

oh

compact pier
#

Anyone have the regex pattern for validating discord mention?

#

to id

near stratus
#

/<@&(\d{17,25})>/g

#

Also you need to increase the limit once in a few years since it's a snowflake

old cliff
#

all bots depending on old regex gonna break soon as new users use them lmao

near stratus
#

I feel sad for all those mysql databases that'll break trying to make the field larger

old cliff
#

don't they just use a string for it?

near stratus
#

Write the code yourself and you won't need any libraries
Just like @quartz kindle always does

#

fetching the content

#

rendering it

#

Drawing it (IDK what it's actually called)

#

then simulate actions and scrape data

#

keep doing the last step as long as you like

#

you can skip the rendering for static sites or sites that are generated from server side

#

but it seems to be a waste for mobile apps

#

I'd rather make a server myself that scrapes data and saves them
and then the user can fetch from it

#

Giving this to the users will pretty much be like running a chrome tab in backend

#

Yea you don't have to think about getting blocked by cf if you do that

#

everyone happy

#

except the site owner

earnest phoenix
#

does someone know how I can center a rect() canvas

#
lyric mountain
#

containerX + (containerWidth - rectWidth) / 2

earnest phoenix
lyric mountain
#

the container X coordinate

#

if it's the canvas itself just consider that as 0

#

for vertical alignment just replace X with Y and width with height

earnest phoenix
#

const loadImage = await Canvas.loadImage(url)

const canvas = Canvas.createCanvas(loadImage.width / 1.5, loadImage.height / 1.5);
context.drawImage(avatar, 0, 0, loadImage.width / 1.5, loadImage.height / 1.5);

context.beginPath()
context.rect( ( loadImage.width - loadImage.height ) / 2, 0, loadImage.height, loadImage.height);

#

loadImage is the whole image but I'm dividing the canvas and image by 1.5 so that the file wont be too big

lyric mountain
#

loadImage.width - loadImage.height ??

earnest phoenix
lyric mountain
#

ah, that's the rect width

#

what didn't work?

earnest phoenix
#

Yo

earnest phoenix
#

Anyone knows how to check if a character is a letter or not

#

In djs

lyric mountain
#

rect(x, y, width, height)

earnest phoenix
#

yeah the first two are positions the last two is the size of the rectangle

lyric mountain
#

yes, u created a rect with the same size as the canvas' height

earnest phoenix
winged temple
earnest phoenix
winged temple
#

if (Number.isInteger(parseInt(message.content)))

#

basically checks the message you send

#

if its a int, do whatever

#

else

#

do something else

earnest phoenix
#

Nah

#

Not for numbers

lyric mountain
winter pasture
#

Anyone aware of a way to get all the slash commands from a bot using another bot?
Closest I have gotten is with this endpoint https://discord.com/api/v10/applications/769772015447703592/guilds/788692852640317451/commands/permissions:

[
    {
        "id": "769772015447703592",
        "application_id": "769772015447703592",
        "guild_id": "788692852640317451",
        "permissions": [
            {
                "id": "788692852640317451",
                "type": 1,
                "permission": false
            },
            {
                "id": "788692852640317450",
                "type": 3,
                "permission": false
            },
            {
                "id": "804804029023518731",
                "type": 1,
                "permission": true
            },
            {
                "id": "966614770230915103",
                "type": 3,
                "permission": true
            },
            {
                "id": "805148383110365205",
                "type": 3,
                "permission": true
            }
        ]
    }
]

But it does not return the slash command name, just ID

winged temple
#

no idea

winged temple
#

u talking symbols?

earnest phoenix
lyric mountain
#

technically, yes, but who knows

#

show a print of ur current code

winged temple
#

first thing you must remember, js doesnt make sense all the time

lyric mountain
#

only the drawing part

earnest phoenix
#

Is only a letter

#

Not other characters

#

Like &!(#%

lyric mountain
#

then pass the character to the function

winged temple
earnest phoenix
#

Any

earnest phoenix
#

Letter

#

From the alphabet

#

I mean

#

I can put an array

#

Of letters

#

And say that if its a letter

#

Then do....

#

But its kinda messy

winged temple
#

return if its an int

earnest phoenix
#

Isnt that for numbers?

winged temple
#

that checks if the message is a number

#

if its not a number

#

then it must be a letter

#

so if its a number

earnest phoenix
#

It can be any character

#

Bro

#

^€&@(@

#

(/[a-zA-Z]/).test(char) check if character is from alphabet, will return true or false

winged temple
#

bro u aint explaining shit

#

you jusy saying

#

check character

earnest phoenix
#

Lmao

#

If its a letter do something

#

Only if its a letter

lyric mountain
earnest phoenix
#

Lol

#

Works ty @earnest phoenix

earnest phoenix
lyric mountain
#

ah, ik the issue

earnest phoenix
#

is it because I divide it by 1.5

lyric mountain
#

at least I think I do

#

yes

#

the line is too thin

#

so it gets zero width after the division

#

try increasing the line size

earnest phoenix
#

oh yeah I had to remove the / 1.5

lyric mountain
#

if u make the line 3px wide u can still divide the size

#

but yeah, it'll become weird bcuz one side will always be 1px thicker

earnest phoenix
#

but because I was trying to compress the image/make it smaller in width and height to avoid going over 8MB limit

#

me dividing by 1.5 causes this

lyric mountain
#

hm, ah wait

#

ur resizing before processing

earnest phoenix
#

had to add / 1.5 to the rect too

lyric mountain
#

nonono

earnest phoenix
#

context.rect(( loadImage.width / 1.5 - loadImage.height / 1.5) / 2, 0, loadImage.height / 1.5, loadImage.height / 1.5);

lyric mountain
#

just resize the output instead

earnest phoenix
#

that did it for me

earnest phoenix
lyric mountain
#

instead of repeating xxx / 1.5 everywhere simply resize the output

earnest phoenix
#

true

#

I'm new to canvas, how'd I resize the output ( docs or idk )

lyric mountain
#

or do ```js
const ctxWidth = loadImage.width / 1.5
const ctxHeight = loadImage.height / 1.5

earnest phoenix
#

oh yeah

last tapir
#

hey, when you have like 3 shards, are the cache based on all 3 shards together or on individual shards, only

lyric mountain
#

individual I believe

#

but depends on what library

last tapir
#

discord.js

lyric mountain
#

js cant multithread at all, so iirc it uses separate processes

#

which would mean per-shard cache

last tapir
#

oh, so if I want to fetch a server, but i have like no idea which shard it is in, what do i do

lyric mountain
#

you broadcast eval

last tapir
#

or like get a server from cache, im not sure how i do that

#

like js let guild = <Client>.shard.broadcastEval(client => client.guilds.cache.get("server ID"))

#

like that?

lyric mountain
#

yeah ig

#

btw, it'll be guilds no guild

#

it'll send the eval to all shards, which will probably return an array

last tapir
#

oh

#

so i did something and it returned [ [Object] ]

#

?eval let guilds = bot.shard.broadcastEval(client => client.guilds.cache.get("ID")); guilds

#

when it came to guilds[0], it returned undefined

lyric mountain
#

then it isn't cached

last tapir
#

what now

lyric mountain
#

fetch

last tapir
#
bot.shard.broadcastEval(client => client.guilds.fetch("ID"));
#

like this, right

lyric mountain
#

has to await too

last tapir
#

still undefined

#
bot.shard.broadcastEval(async client => await client.guilds.fetch("ID"))[0];
lyric mountain
#

well, then idk, you'll need someone more experienced with d.js

last tapir
#

i had 1 shard, and then when I made it 3, i got this result

#

[ null, null, [Object] ]

#

if ill be having like 10 shards, how am I supposed to be handling this

lyric mountain
#

<array>.find(o -> o)

quartz kindle
#

or <array.find(Boolean)>

last tapir
#

im confused

#

how exactly

quartz kindle
#

broadcast eval sends that function to all shards and returns the result from all shards

last tapir
#

in an array yes

#

and we're expecting one result

quartz kindle
#

so the shard that has the guild will respond with it, all other shards will respond with empty, because they didnt find the guild

last tapir
#

and that one result is an object in an array of nulls cause of one result

#

yes

lyric mountain
quartz kindle
last tapir
#

how can i make it so i can define x with the value of that returned object

#

i did the broadcast eval part

quartz kindle
#

you need to take the array, and find which item contains the response, and ignore all other items

#

array.find() does exactly that

last tapir
#
bot.shard.broadcastEval(client => client.guilds.cache.get("ID"));
last tapir
quartz kindle
#

it returns the first item in the array that matches the condition

quartz kindle
last tapir
#
bot.shard.broadcastEval(client => client.guilds.cache.get("ID")).find()
#

wont work like that

quartz kindle
#

because broadcastEval is a promise