#development
1 messages · Page 4 of 1
you need to be in the server for the bot to work?
they said that I need to be in their server to add the bot at all
wut
when/where did they say that
on their website
dafuq
when I clicked the add bot button it said I need to be in their server in order to add my bot
you need to be in this server

not the bot testing server
yeah but I could not join
but you're here?
because the invite they provided was invalid
what?
I know I'm not talking about this bot list
oh lol
read dis
you cant talk about other bot lists here
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?
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
what's the endpoint?
no, like what's the specific endpoint for getting specific repo information
https://api.github.com/repos/OWNER/REPO
documentation probably has all this :p
The REST API was never deprecated, it's the main API
what's the difference?
I don't think there's a difference here
What was deprecated is using user + pass
Now you're forced to use a token for everything
There is!!!
The REST api is well rested and slept a lot already
The normal api is really tired and soon gonna be deprecated and go to sleep!
how do I use the lyrics api?
what's lyrics api? link?
link?
also https://genius.com/ for the main page
Damn right, good doggo
:)
yeah I tried searching for a lyrics endpoint there is nothing of sorts
do you have an api key?
of course
it appears to need the song ID not a query..
combine the two and then it should work
this doesn't explicidly show any lirycs
song is the document with the lyrics hosted
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.
lyricss
search the song, get the document, read document
and from what I see you need to write a scrapper to get the lyrics
so that's pretty pointless
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
that's python
the second one isn't
and that's a npm package
sorry, I'm using discord.js
you give no info
I used cheerio for scrapping the html
then I parsed it into json
using a bunch of regex
it was really slow
then this https://github.com/farshed/genius-lyrics-api works
took a couple seconds
In this you're supposed to scrape the HTML of the song page
With the ID you were given from the search endpoint
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
Cheerio is the best way to scrape HTML in JavaScript, it's pretty fast so you can just use that
you're saying cheerio auto parses the html to json?
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
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.
What webhooks? Discord's? Top.gg's? Or just webhooks in general?
top.ggs
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?
Top.gg has an API wrapper for Java, but I'm unsure if it implements webhooks, you can ask about it in #topgg-api
https://docs.top.gg/libraries/java/
alright ty
It'll error
Yes, simply just paginate it
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
lyricsEmbed.title is not a function?
whoops
wait what
how is it thinking it's a funtion
setTitle()
bruh my bad I confused title with the lyrics response I'm too tired
It's not thinking it's a function, title is a property of the embed instance
It's very easy to setup a simple Spring endpoint if u want to
okay that works now about pagination, how does that work again?
You're always too tired 
Split the array into chunks of N entries
cause I always start coding when I'm supposed to be sleeping 😭
there isn't an array
the lyrics endpoint returns a string I would have to split the text then cast that into an array..
[1, 2, 3, 4, 5, 6] becomes [[1, 2], [3, 4], [5, 6]] for example (chunks of 2 entries)
Same concept applies
how do I even split a text in two parts?
Split the string based on the maximum width you want to split by
Regex or iterating over its words
wait do I have to create buttons for the pagination
nvm I'll do reactions
I hate interaction system 😠
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
Buttons are easier to deal with
no way u said they're easier
Buddy, I made a whole pagination lib, trust me, they are heaven
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
regex boiii
Since lyrics are always structured vertically
don't encourage this behavior kuuhaku
Regex or splitting by line?
regex :C
how do I split by word count?
Do I need to repeat it again?
yes please
Regex or iterating over its words
ooga /w?af+le$/g
Yes
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 😭
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
Well, u asked for code, not for js code
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
This shouldn't even be hard, I don't know how you're struggling with it
It's an optimized way of building strings in a loop
C'mon 
U can do it with common strings, just won't be as fast
Go on buddy, ganbare!
what the fuck is this emoji
if you can't map it out in your mind, map it out with comments in your code and slowly start implementing it
this scares me
That's the skull emoji that existed in one of the obscure Android phones
how could anyone approve that as a design
I still remember android 3 and it's "satanic pact"
People approve a lot of shitty design, so I'm not surprised
I think it was android 3
up until android 12, the sparkles emoji (✨) was a box with sparkles in it on samsung
don't question brands
The one with the zombies image as easter egg
Glitter?
samsung has some awful designs
almost
notable the grinning one
is this even JS or am I getting confused
for (object in Object) //do something
Of
of?
In will get the indexes iirc
wot
It's valid JS, but probably not what you're looking to use.
Technically that would work because you're supposed to use the in keyword over actual objects, if you're using an array then you're supposed to use the of keyword
If ur converting what I wrote, what u want is for (word of words)
Words being an array not object
And better to also use let or const before the variable name in that expression
Just noticed I said almost the same thing as volt
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
for (const word of words) ...
- forgot to change some lines now I only noticed
Append would be +=
ye
Which is basically concatting strings
The sb variable has no value, so it's undefined not a string
Ye, u need to initialize it with ""
const words = lyricsEmbed.lyrics.split(" ");
const parts = [];
let sb = "";
for (const word of words) {
sb += word;
if (sb.length >= 1024) {
parts.push(sb.toString().trim());
sb = 0;
}
sb += " ";
}
if (!sb) {
parts.push(sb.toString().trim());
}
there that should do it I think
sb is already a string so there's no point in calling the toString() method
Thaaat too
okay that's one optimization
I had to call toString because in my code it wasn't one
now how exactly do I use that?
parts[pageNumber]?
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
Yes, you'd need to keep track of current page
Then increment it and update the message with the part in that index
should I start with 0?
Ye
I just noticed, you're reassigning the sb variable to 0
You're supposed to reassign it to an empty string, not 0
And the last condition is supposed to be sb not !sb, because it's supposed to check if the string is not empty
Pagination ain't hard, u just cut the bread and eat each slice individually
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?
Yep, partly
done
gotta upload to hastebin cause it's too long
hope this code doesn't hurt your eyes too much
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
so will this work or nah?
wanna get it first try if I can so won't test until I get yalls opinion
I don't know much abt how djs collectors work, but at first glance it's all right
okay then time to test it out
Did ur ide say anything?
Cannot read properties of undefined (reading 'split')
that's what it said
after compiling
Usually most syntax-related issues can be solved before clicking run
Sometimes even logic-related issues
My guess is lyricsEmbed has no lyrics prop
that's why I hate those fucking dumbass fucking interactions
no idea how to fix that shit
Because you didn’t respond in time
"This interaction failed"
that's not it bro I gave it a fucking 30 second timeout and when it ends it removes the buttons so I see that
no
so
with interactions
discord gives you about like 15 seconds i think
I don't have copilot or whatever yall use I just have intelisense
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()
I have a function to either follow up or reply
So did you defer your button interaction?
3s
no I gave it a fucking 30 second timer in the collector
thats not what im saying
2am not rly
I can't ion got headphones near me and if I make any noise I'm dead
ik yall hate the way I write my code so it may be a lil confusing
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
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
The timer in collector is related to the collector not the buttons as fake said
if anyone is wondering this is the replyOrFollowUp function
function replyOrFollowUp(interaction, ...args) {
return interaction.reply(...args).catch(() =>
interaction.followUp(...args)
);
}
so what do I do
U need to defer if ur going to take longer than 3s
how do I defer and where do I defer?
wdym
@ancient nova do you understand what interactions are?
becuase this looks like code that was meant for like djsv12
can you console.log inside this
and check if this code is even running
He’s actually massively confusing himself with his collectors and interactions all the time
yea
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
bro u ain't had to say that tho 😭
naw fuck that
I just need to fix that you said I need to defer it somehow right?
how?
please bro 😭
ye I updated something cause I had an error in the code either way but I fixed it now
await i.deferReply();
it still says interaction failed tho
fasho lemme try
bro then what's the point :/
bruh then it won't work at all
it will fail if u don't reply at all
that's why I'm saying interaction system IS SFUCKING GARAGAE TRASH
hmmm no @boreal iron i think it can reply in 3 seconds
just stick to the reaction collectors
💀
sounds like just you
im lovin it
either that or I'm legit retarded cauuse I can't get some 2 buttons to work
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)
then how did my rock paper scissors game work?
u can respond anytime in 30 seconds and I never defer it
Can’t watch code while driving
we don't want u to crash
you can't
THAT'S WHY I'M SO CONFUSED
it has to be defered
na bro I'll show u that shi rn join my server
dm
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
yo @boreal iron @lyric mountain I fixed it
Nice
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 😭
Hm, ur forward button is reversed
Yes
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
fosho
"if there's anything remaining, add as a chunk"
somehow it created a third page, interaction failed at the 2nd and I can't go the the third one
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
Maybe ur trying to access page 2 (third item)
Which doesn't exist
currPage < parts.length
Not <=
ur looking at the old code again
Btw, don't trust === that much when checking ranges
Weird things 🌈 happen 🌈
Always use < or > (and their "or equals" counterparts)
I'm starting to really hate javascript 😭
in javascript weird things happen over EVERYTHING
That ain't really a js thing, happens in any lang
haven't seen that happen in any others I code with, on some === doesn't even exist
All it takes is a little double click and ur out of the boundaries
Or concurrency issues
Like 2 things updating the same variable
:dude maybe that's what caused the first interaction error
Worth a try
Yw
yeah vcs have chats
relatively new feature, probably only been out to every platform for a few months
And of course totally necessary
As if voice channels could handle twitch-levels of chat
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)
looks like you pushed your token to github in the commit history
did you do this just now or made the current repo public?
make your github repo private?
This is because you’re already tracking the file with VCS (git). To remove it completely, you can save the content, delete the file, commit, push, recreate the file (with it in gitignore) and then commit & push to github
This should work
no need
git rm -r --cached . && git add .
also I believe replit doesn't work with .env anymore, u need to use the secrets menu
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?
lemme help me read that:
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));
}));```
member.guild.fetchInvites().then(guildInvites => {
guildInvites.each(invite => {
if(invite.uses != client.invites[invite.code]) {
console.log(invite.uses)
}
}
})
we can’t find the issue
ok so, u need a way of tracking changes to the number of invites
then just do storedUses - (storedUses - currentUses)
no idea how passport work, so I can't help
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?
I do have that already, however the bot already counts the previously used invites
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?
use util native library
import { inspect } from 'util';
ok so how would I auto format json in a message?
Example:
{"hello":{"test":"1","test":"2"}}
to
{
"hello":{
"test":"1",
"test":"2"
}
}
no, not without spamming the api
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)
you need to set a periodic task to refresh the invite values
Buffer.from() expects an array of bytes, not objects
@forest drift
how to delete someone from team ?
you can stringify your array first, then pass that to Buffer.from()
yeah I did this, thank ya doe. Didn't know they had one for hiding credentials
so you use inspect to return the pure string representation of the object
yeah it worked ty
thanks
then pass the output via beautify
btw beautify is an external library
for this use JSON.stringify
I think it's the other way around, parse
no
i said
format
so object -> string
parse does not return the string

@lyric mountain how can i not be naive
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
you need to fetch before doing anything
Fetch how?
HIT - Hacker In Training™️
<Guild>.fetch()
Ah
actually
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()
Ah
anything that has Manager in its type name has the capability to fetch
it aint work
show me how you called it
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
You ain't told me what to do w it
kk
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
idk ask yourself
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

and to fetch all members you need the members intent
assume he has it
How cn we fetch user votes in bot?
use webhooks for accurate results
Also why the heck were they fetching all roles just to get a specific one later
some people seem to have weird use cases
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
Are you using your user tokens in a headless browser for scraping or something like that with the API with the search feature?
is there any way of getting a random row from a sql resultset without using ORDER BY random()?
Not that I know
Also is random() an alias of rand()?
Other methods to assign a new unique ID are significantly slower than this
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
idk, postgresql uses that for random double
pls help
Your woo bot is starting a webserver on port 3000
There’s already one running on that port
Maybe the same process but not stopped carefully
it doesn't work like that, people who understand your question will eventually answer
😦
Kill all processes and restart to see if the error still occurs
so what should i do ?
Yeah random() might be an alias then
Following what I wrote above
this ?
This wouldn’t make sense
Selecting a random column?!
You wanna select a random row
i changed the port to 3001 but didn't work
just to show rand doesnt exist in postgres
u can call functions directly, no need for SELECT * FROM function()
Ah well maybe they renamed it to random but by default it’s rand iirc
Pls Help me
You just add a new entry and set the id property to the ID of the role
They’re a little bit differently
A command that gives you command ideas

how did you get that bro
btw I'm legit 3 servers away from verification
it's so hard to think about it
antibots
Your command ideas usually end in this channel since you’re doing stuff weird sometimes confusing yourself
I know right, nobody could've ever thought of it
wdym?
yea yea
antibots command to prevent bots from joining
Don't they already do that all the time
You should try implementing GTA V in a Discord bot
Surely will get a ton of attention

Tf who’s still playing that old game nowadays
A lot of people still play it, and when I say a lot I mean it
I started that download god knows how long ago
Hmm isn’t it already like 10y old?
it is but it's constantly updated

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
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
do you know max payne 2 ?
Not really but I know the original developers of the gtav online (private multiplayer servers) have moved to max payne 2 or 3
There are clever people out there
Always
Which bother with stuff nobody else has time for or wanna deal with it seems
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) { ... } }
can you get users discord bio using discord.js?

what?
No, because the "about me" sections of users aren't exposed to the public Discord API
How does it not work exactly?
Have a closer look at the options, you have a typo there
autocomleate -> autocomplete
can you somehow get it otherwise or would that be against ToS?
for example https://discord.com/api/v9/users/.../profile
There isn't really an exact way of getting it, you would have to scrape the Discord profile somehow
would be against tos
that fixed it thank u
as that would be selfbotting
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
hold on how is that self botting?
I'm just gonna do a GET request
Looks like they enforce that bullshit now in preparation of the app discovery release
yupp
bro they really asking me to write a ToS of my own now
ion even gotta domain mine expired
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
You don’t need a domain
dont u need a passport or drivers license?
The TOS url can target anything like a document as long as it’s publicly accessible
or identification
For the verification yeah
rip me
passport expired
everything
is expired
would they still accept expired id?
how tf u let every single document expire?
anyone know any cool html effects I can put on my bots website without much effort?
uhh
passport expired in 2016
i dont have an id card
cus never needed
until now
cant get a drivers license until 18
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
Alright, thanks!!
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
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
np
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)
}
);
Wait i am looking at their docs and tried calculating with it
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?
Owhhh really?
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/
Progress bar
Whahahah thanks fake.
that's a huge xp scaling
it's mee6's.
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
how much xp do u get?
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
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
bruh
do u have many servers with the same member/owner in it?
1 xp each message with a 1 minute cooldown
just made all of them leave
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 😭
meanwhile i have like 5 testing server and didnt have to deal with that shit
with your current account as an owner for each?
hey is there a way to use an import package system, and transform it into a require?
I can remember i did it once
no
you cant transform it into a require
but you can use the async import function
what about createRequire?
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
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.
top.gg webhooks*
yeah i dont think i understood well... i never did anything with http bfore so what should i use? is reg java stuff good enough?
define "reg java stuff"
without maven imports
are you willing to keep your sanity?
yeah
then use maven imports
well i guess i can import then lol
more specifically, Spring Boot
alr ill have a look ill come back if i have questions
sure
ty for your help
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
yea
tho there is a week where my bot grows very slowly
Hey ChittyKat long time !
idts it matters cuz my test bot is in 3 servers and I am owner of all of them so it just shows as 1 server
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(??????, ??????);```
You can just load the image using the loadImage() method provided by Canvas
And access it's width and height properties to get the values you need respectively
I'm just getting this Image { _src: <Buffer ff d8 ff e0 00 10 4a 46 49 46 00 01 01 00 00 01 00 01 00 00 ff db 00 43 00 08 06 06 07 06 05 08 07 07 07 09 09 08 0a 0c 14 0d 0c 0b 0b 0c 19 12 13 0f ... 40132 more bytes> }
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
uh
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
https://www.reddit.com/r/discordapp/comments/iibxms/if_anyone_needs_regex_to_match_an_emote_mention/
10 votes and 3 comments so far on Reddit
/<@&(\d{17,25})>/g
Also you need to increase the limit once in a few years since it's a snowflake
I feel sad for all those mysql databases that'll break trying to make the field larger
don't they just use a string for it?
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
containerX + (containerWidth - rectWidth) / 2
what's containerX
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
I tried
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
loadImage.width - loadImage.height ??
I was just trying to get the shortest length of the image and then make a square out of it
Yo
basically running this gives me those results
Anyone knows how to check if a character is a letter or not
In djs
that's because u misunderstood what are the rect params
rect(x, y, width, height)
yeah the first two are positions the last two is the size of the rectangle
yes, u created a rect with the same size as the canvas' height
?
I was trying to make this so I had to use the size of the canvas height
ye
Anyone knows how to check if a character is a letter or not
if (Number.isInteger(parseInt(message.content)))
basically checks the message you send
if its a int, do whatever
else
do something else
try loadImage.width / 2 - loadImage.height / 2 to see if it changes anything
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
no idea
isnt that theoretically the same; yeah it gave me the same results
first thing you must remember, js doesnt make sense all the time
only the drawing part
If a character
Is only a letter
Not other characters
Like &!(#%
then pass the character to the function
ohh you mean like specific letter?
Any
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
do this lol
return if its an int
Isnt that for numbers?
that checks if the message is a number
if its not a number
then it must be a letter
so if its a number
It can be any character
Bro
^€&@(@
(/[a-zA-Z]/).test(char) check if character is from alphabet, will return true or false
Aight
Lemme try
it does look centralized on codepen
np man
ah, ik the issue
is it because I divide it by 1.5
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
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
I don't think it's because of the thickness
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
had to add / 1.5 to the rect too
nonono
context.rect(( loadImage.width / 1.5 - loadImage.height / 1.5) / 2, 0, loadImage.height / 1.5, loadImage.height / 1.5);
just resize the output instead
that did it for me
oh
instead of repeating xxx / 1.5 everywhere simply resize the output
or do ```js
const ctxWidth = loadImage.width / 1.5
const ctxHeight = loadImage.height / 1.5
oh yeah
hey, when you have like 3 shards, are the cache based on all 3 shards together or on individual shards, only
discord.js
js cant multithread at all, so iirc it uses separate processes
which would mean per-shard cache
oh, so if I want to fetch a server, but i have like no idea which shard it is in, what do i do
you broadcast eval
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?
yeah ig
btw, it'll be guilds no guild
it'll send the eval to all shards, which will probably return an array
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
then it isn't cached
what now
fetch
has to await too
still undefined
bot.shard.broadcastEval(async client => await client.guilds.fetch("ID"))[0];
well, then idk, you'll need someone more experienced with d.js
oh, wait, hold on
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
<array>.find(o -> o)
or <array.find(Boolean)>
broadcast eval sends that function to all shards and returns the result from all shards
so the shard that has the guild will respond with it, all other shards will respond with empty, because they didnt find the guild
aint that the same I said?
yes
how can i make it so i can define x with the value of that returned object
i did the broadcast eval part
you need to take the array, and find which item contains the response, and ignore all other items
array.find() does exactly that
bot.shard.broadcastEval(client => client.guilds.cache.get("ID"));
i cant just add at the end of the code
it returns the first item in the array that matches the condition
why not?
bot.shard.broadcastEval(client => client.guilds.cache.get("ID")).find()
wont work like that
because broadcastEval is a promise








