#development
1 messages · Page 59 of 1
just did
nothing
unless its taking a really long time
i mean it worked fine without the
if nothing is coming then there is something wrong with the request
user: shuffled
are you on djs v14?
13
i've seen this happen if there are invalid ids in the array
check if maybe you have an undefined or bad id in shuffled
that actually could be possible because my bot was down for sometime and thus there may be members not in the guild in the db
i'll loop through and remove them rn
ah i just checked
there is actually a limit of 100 ids per request
wait no, thats only if you dont have the intent
how do you like
check if the user is in the guild
!guild.member(id) isnt working
You need to fetch the member
wouldnt that return a err
ids not in the guild will not cause this issue
only invalid ids do
not-found ids are returned in a separate array that djs ignores
then all ids in here are valid
Yes you would have to catch this and if the call doesn’t return a member object, then there’s no member with that ID in that guild
try limiting the number of ids, for example try with 50, then try with 100, then 200, etc
tried with 50
console.log(members) works now
but
the presence status still returns undefined
also it seems like the max is
750
for fetching
otherwise it returns that error
i have other work to do but lmk if theres a solution
presence intent
they have the intents
honestly i dont know, i dont have those intents so i cant really test it myself, also its been a while since ive used djs lol
I thought it was members that are required for presence
a user, or a members?
user doesnt contain presence.
member does
You're checking user right?
uh
yeah
but thats not even the issue bc
the fetching fails to work
it gives a timeout error
the error was you hit a cap on the number you can get i think
this?
Yeah, in v13 user.presence was removed.
https://discordjs.guide/additional-info/changes-in-v13.html#user
those are members tho
it doesnt make sense for 750 to be the max, since you can fetch all members even if they are thousands, and discord doesnt even use weird numbers like 750, they would use either 100 or 1000 as a limit
a property inside the member object
Then they are checking in the wrong spot maybe?
since you apparently have thousands of ids anyway, maybe its better to just fetch all lol
still doesnt explain why presences are not working
are you using the code i gave you?
this one ^
there you can see the raw data, if there are no presences in the raw data, then discord is simply not giving them to you
Wait, isnt there a difference between a Member and a User?
since you'd have to either share a guild with a user or be friends with one (selfbot ew) to be able to see their presence
could that be the case?
nvm says GUILD_MEMBERS_CHUNK
how can I check if a user has admin / owner in server x? Using my client.
you probably need to fetch the users permissions and see if their permissions contains admin, using .permissions is my guess per docs
for the owner, fetch the guilds owner using https://discord.js.org/#/docs/discord.js/main/class/Guild?scrollTo=ownerId
and then compare it to the user you're checking
how do I get the permissions of a user though?
which contains the permissionbitfield of the guild member, from which you could check if it contains Administrator
has to be a GuildMember, so you'd need to fetch that user from the guild
trying to find it right now
https://discord.js.org/#/docs/discord.js/main/class/GuildMemberManager from https://discord.js.org/#/docs/discord.js/main/class/Guild?scrollTo=members
using .fetch
I am already using all these though
what happens when you dont do .user
since that obtains a user from the guildmember
where?
should have .permissions per docs: https://discord.js.org/#/docs/discord.js/main/class/GuildMember?scrollTo=permissions
it uses the roles from the user, then gets the permissions from that, according to the GuildMember.js too https://github.com/discordjs/discord.js/blob/7083df7ceff4a4ae5b2ca05ab939258d26ded655/packages/discord.js/src/structures/GuildMember.js#L236
ah, idk why it doesnt show in the json
PermissionsBitField { bitfield: 2199023255551n }
yeah uses the roles one
https://discord.js.org/#/docs/discord.js/main/class/PermissionsBitField has that then, which you could use https://discord.js.org/#/docs/discord.js/main/class/PermissionsBitField?scrollTo=has on
this should be true when owner or admin, eight?
await m.permissions.has(PermissionsBitField.Flags.Administrator)
yes
key, thank you so much!
to note, this will also return true if the user is the owner since the owner has all permissions
so you'll need to check the ownerid of the guild within that check, so:
- check if admin
- if admin, check if owner
yeah, I only need to know if he has admin rights, so that should be enought, right?
should be enough, unless you have configuration sections that require the user to be the owner
so, this is about 0% done but in the last try statement, will the return be for the entire function or only the try?
entire function if thats how javascript does it
if it fails to fetch the guild and/or the guild member, it would return false
otherwise doesnt return anything
why isnt it grabbing the cookies? (koa)
or does it grab the cookies of the api, not the dashboard?
on the dashboard (www.x.x)
print out the cookies and see if they're available
when I log them they are NaN
is your api on a different domain by any chance?
subdomain?
oh
yeah the cookies can only be accessed on the same domain, one sec
you might need to set some parameter within your cookie-setting functions
what webserver package are you using? is that express?
koa
cookies can by default not be used across domains, so you'd need to allow it on the entire domain including subdomains
because thats intended that you cannot access the cookies, as you're making a request to a different domain
ig Ill just use headers then, its just 3 anyway
nah gimme a sec
could you show me how you're setting the cookies, aswell as where you're setting them?
Im using react, setting cookies with this script:
// Format Cookie Content
let cvalue = cval
cvalue = cvalue.replace(';', '/#SEMICOLON#/')
cvalue = cvalue.replace('=', '/#EQUALS#/')
cvalue = cvalue.replace('?', '/#QUESTION#/')
cvalue = cvalue.replace('&', '/#ANDSYMBOL#/')
const d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
let expires = "expires="+ d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
exports.get = (cname) => {
let name = cname + "=";
let decodedCookie = decodeURIComponent(document.cookie);
let ca = decodedCookie.split(';');
for(let i = 0; i <ca.length; i++) {
let c = ca[i];
while (c.charAt(0) === ' ') {
c = c.substring(1);
}
if (c.indexOf(name) === 0) {
// Format Cookie Content
let output = c.substring(name.length, c.length)
output = output.replace('/#SEMICOLON#/', ';')
output = output.replace('/#EQUALS#/', '=')
output = output.replace('/#QUESTION#/', '?')
output = output.replace('/#ANDSYMBOL#/', '&')
return output
}
}
return "";
}```
You need to add another value when setting the cookie, the domain
so adding Domain=yoursite.com for example
for the entire domain, Domain=.yoursite.com
the . is important
nvm the first one works too
thanks!
last question, would this be secure?
https://hastebin.com/jerujofiwe.js
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
question for someone who can understand js directly 
does client.guilds.fetch() use the cache? if so, can I disable it?
you can use force = true to bypass the cache
like this?
actually nvm, I thought thats a thing on guilds.fetch too
I think it does access both the cache and fetching the guilds
so it does have forcing
so yes that should work
What happen if I dont use force
yeah, it detects perm changes pretty instant now
I think it would only use the cache
just keep ratelimits in mind
since you're essentially fetching it every time aka making a request every time
yu
pretty much, yeah, although that code could be optimized to reduce redundancy
to send a embed via interaction to the same channel is it interaction.channel.send
and please, use linebreaks without fear, nobody benefits from inline ifs and one-line codes
ig so
interaction is undefined
without code it's impossible to know why
const { EmbedBuilder } = require('discord.js');
// inside a command, event listener, etc.
const exampleEmbed = new EmbedBuilder()
.setColor(0x0099FF)
.setTitle('Some title')
.setURL('https://discord.js.org/')
.setAuthor({ name: 'Some name', iconURL: 'https://i.imgur.com/AfFp7pu.png', url: 'https://discord.js.org' })
.setDescription('Some description here')
.setThumbnail('https://i.imgur.com/AfFp7pu.png')
.addFields(
{ name: 'Regular field title', value: 'Some value here' },
{ name: '\u200B', value: '\u200B' },
{ name: 'Inline field title', value: 'Some value here', inline: true },
{ name: 'Inline field title', value: 'Some value here', inline: true },
)
.addFields({ name: 'Inline field title', value: 'Some value here', inline: true })
.setImage('https://i.imgur.com/AfFp7pu.png')
.setTimestamp()
.setFooter({ text: 'Some footer text here', iconURL: 'https://i.imgur.com/AfFp7pu.png' });
channel.send({ embeds: [exampleEmbed] });
I changed it back to channel, I use to do embeds but dont remember what I edited
well, the only things defined in that code are exampleEmbed and EmbedBuilder
ok, I don't remember how I defined interaction, all of my other commands use the slashcommandbuilder
bossnames = ['Mutated Bear', 'Mutated Lion']
print(bossnames, "Health = ", EnemyHealth)```
why is it saying my list?
You may have fixed it, but you didn't added proper indentation
i did now
So the issue is fixed
no
it still doesn’t print a name from the list and when it does it prints both
Thanks for the code
yeah one sec
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
it’s meant to be .py wtf
you may want to take a look at the code example again, specifically the indentation
i did
oh wait i’m stupid
i added the indentation and still nope
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
My bot is pretty simple. It’s just used to manually track how many items you have collected in a certain game and I just store all that info in a database. So is it ok if I have a pretty small ToS?
it should still mention that for example your bot collects that and stuff
at least for the privacy policy
Yeah I’m pretty much saying that the bot collects only data that relates to the bot and only activity that relate to the bot is logged
people usually abuse brevity of terms of service if it doesn't cover every case
lmfao
The constructor war
i got an error
ok so
i want to scream
essentially
i have a caller and a function
the caller is an endpoint, set up in express, to get a discord user's profile picture via the oauth2 endpoint and send it to the user
the function is what the endpoint calls to get the user's profile picture and save it to the cache, it also returns to the caller the response from discord's api (or redis)
small problem
the value from discord's api/redis is being returned before the file is saved
and so the browser, on the first time getting the user's pfp, sees an error looking like this: Error: ENOENT: no such file or directory, stat 'C:\Users\banan\Desktop\BTSBot\cache\profile-pictures\fa65ef73a62e769bb5169e4c86d657b0.png'
await it
show code
the caller: https://hastebin.com/amaduzehug.js
the function: https://hastebin.com/aqonicocif.js
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
btw, why are u even doing all this?
writing a dashboard
can't u just use the avatar directly from the oauth?
also so that i don't send requests to discord's api 50 times / second
retrieving the avatar technically doesn't count as an api request
oh sugar i didn't think of that
like, the avatar is already stored in discord cdn, all u need to save is the avatar hash
nothing under cdn.discordapp.com counts as an api request
how do I embed css in the long description? can I get an example?
just like you'd do in html
but without the html structure (without <head> or <body>)
no, styles blocks work too
ah dope ok thanks
how do i add images/gifs like this?
html image tag
i see
Hello is there are any way to fetch the rules channels from the guild ?
M building a welcomer event and want to auto detect the rules channel that the owner did select in the community tab
Not really, Discord does not tell you what channels are marked as the rules channels, so all you can do is guess work by channel names, this can lead to false positives of course
Yea indeed well thanks a lot the reply
Have a nice day
whats the best way to display a timer without <t:unixtime:R>?
Because that requires the Users Clock to be synced
a string formatted by you
if someone hasn't synced up their clock on their pc, they shouldn't use discord to begin with lol
pros on timestamps by discord
- no need to format
- goes from the users time
- easier use
pros on formatting yourself
- control over time
- often allows forced localisation
this doesn't print anything -- if it does, it's the same timeout error
heres the full code
what do you mean exactly? I dont think discord would like me editing a message every second
if i fetch all members this is what the raw thing prints:
user: [Object],
roles: [Array],
premium_since: null,
pending: false,
nick: 'Goku587499',
mute: false,
joined_at: '2022-07-25T00:34:43.231000+00:00',
flags: 0,
deaf: false,
communication_disabled_until: null,
avatar: null
},```
if you're looking for dynamic timestamps like the ones discord provides, there's no other way
it's really the users fault if their clock is behind
the raw thing should give you this
you showed an item from the members array, check if there is a presences array in there
you can print x.d.members.length and presences.lenght instead of the whole thing
so it doesnt spam your logs
or print [0] to just print one instance of it
undefined
yellow is the members.length im fairly sure
can you show the code you used to print?
console.log(x.d.presences.length)```
if u wanted members.presences.length thats undefined and crashes
presences are not inside members in the raw data, they are separate
then the first number is members, the second number is presences, and so on
1000 members, 94 presences, 1000 members, 104 presences, ...
why arent all the presences being fetched then
just console.log one of them to see
console.log(x.d.members[0])
console.log(x.d.presences[0])
idk why is it logging a bunch of undefiends tho
{
user: {
username: 'Val',
public_flags: 0,
id: '868325035058790471',
discriminator: '1017',
bot: false,
avatar: '6e674a9e0dfec679717c327cf9cb9633'
},
roles: [ '925980438839853066', '918238024670773300' ],
premium_since: null,
pending: false,
nick: 'macksrol',
mute: false,
joined_at: '2022-02-06T20:20:06.931000+00:00',
flags: 0,
deaf: false,
communication_disabled_until: null,
avatar: null
}```
might be from the cmd
thats a member, what about a presence?
user: { id: '976229317644259338' },
status: 'online',
client_status: { mobile: 'online' },
activities: []
}```
add this to you code, right after the members fetch: console.log(message.guild.presences.cache.size)
then there are 751 non-offline members
then i dont know, discord issue
you have to ask in discord developers or something
kk
member.presence should work, unless its one of the members without a presence, ie, they are offline
yeah i check that
if for some reason it doesnt work, you can also try doing guild.presences.cache.get(member id)
if there is no presence it will return undefined (i think it used to return an offline presence in the past, but now it returns undefined)
btw how many guilds is that bot in?
one
well
actually 2 i think
its a testing bot
yeah 2
i still cant access
presence status for some reason
await message.guild.members.fetch({ withPresences: true }).then(async members => {
for(const userDocs of shuffled) {
let guildMem = members.filter(m => m.user.id === userDocs);
if(pickedDiscordIDs.length < amount) {
let search = await users.find({ DiscordID: userDocs })
let user = search[0].DiscordID;
if(guildMem.presence != null || guildMem.presence != undefined) {
console.log(guildMem.presence);
pickedDiscordIDs.push("<@" + user + ">");
pickedRobloxUsers.push(search[0].RobloxUser);
console.log(pickedDiscordIDs.length);
console.log(pickedDiscordIDs);
}
}
}
});```
the part console.log(guildMem.presence) doesnt work and i dont know why
there is at least one person online in the database (me)
if your bot is in only 1 guild, and you have both members and presences intent
then you should already be receiving them at login
you shouldnt even need to fetch them
hello i need help please
With?
in dashboard, How to create a page that no user can access except for the people whose ID I entered
fetch the users id
compare with list of users allowed to access page
if not in list, 403 aka no access
if in list, allow access
In this type of string -
Request by: Someone Random#6969 •| Page 1 of 40
How do I get I Someone Random#6969 and 1? Split won't work because Someone Random can also be SomoneRandom or Some One Random and also Some One #Random
Ig it's impossible?
Your goal is a regex then
Ah like how will I use regex in it like username may also contain. #
is there a way to estimate how long a loop will take?
like the bot gives the user an approximation of how long it'll take to loop through <x> users
Max 50 (0-50)
It can just be /(.+#\d{4}) •\| Page (\d+) of \d+/
The first capture group will be the tag (username and discriminator), and second one will be the current page
wait is that actually possible?
You're literally a Top.gg mod, Aurel stink
Cool thanks i will just test it out
Cool thx aurel and voltrex
I at least tried lmao
Regex is pretty easy to work with if you know it's special identifiers, clauses, and grouping methods
It can take a while to master but it's not hard
but I didnt know this was possible lmao
Which part of it did you think was not possible?
the d+ one
: ([a-zA-z0-9 ]+#[0-9]{4}) this was my attempt at getting the username, match group 1
lmao
am smort much
Since usernames can contain all kinds of Unicode characters it's better to just match everything until the last # delimiter
yeah
anyone know how i can parse a date that just defines it’s time zone as “ET” not est/edt in js
ET/CT/MT etc
Why does nobody use the \w or \d regex groups :c
@earnest phoenix i get current page but not tag like it's mixed with Requested by: shoul i just remove it out from the group or like edit something in regex?
I use exec method
Ah it's because it also matches the Request by: appendix, you can fix that by /Request by: (.+#\d{4}) •\| Page (\d+) of \d+/
Thanks!
Can you provide an example date string with one of the aforementioned timezones?
“2022-10-17 21:00:00 ET”
Technically these are timezone abbreviations and they're not supported by many date/time libraries, since they're not standard and can have different meanings and offsets, the best you can get close to that for the ET timezone abbreviation is to parse it with the America/New_York timezone and replace ETC or anything similar with just ET from the date string
You're not gonna have fun parsing timezone abbreviations in any language 
I wonder which software spits something like that out
I mean… it isn’t much difficult to just add the offset to the time
And still if you like to the local timezone name after
At least that could be parsed successfully
does anyone know what could cause this?
how do i?
Using sql?
yes
Why are you querying a table if you don't even know how to make a table
CREATE TABLE example (
someField DataType
)
where do i put it?
Wait do you already have a predefined table?
sorry i’m confused now
Oh wait nvm thats a list of tables you have
This is basic sql on how to create a table, idk what you are using to access the sql database but whatever you use, you'd structure the sql like this
i used a website that gave me a server
mysql 😔
oh im out
fuck that
someone else help em I don't do mysql
iirc mysql does it the same
but anything beyond that I have no clue about
where's ur database?
why are u showing the information schema?
💀
So first i'd think about what you want to store
as a beginner in database management mysql was probably the worst option to choose not like its even a good option to begin with
If you only wanna store basic stuff, i'd just go with a sqlite database for now, and you can migrate later if need be.
this is ur database
everything above doesn't matter
you need to create its structure
Before creating a table you gotta have to create a database
its mostly already provided if you're directly buying a mysql database
instead of selfhosting one
thats so dumb

S & D have fixed determinations and are even known by Date bcz America/New_York uses them but can't figure it out on it's own
That’s the issue without standardization
True but I dunno the context if that’s the case here
If so he would need to select the database anyways before creating a table
But yeah….
I'm working with interaction. Does any solution for user can use two interaction in a time
I was using two customId but it's still cause a Interaction has already been acknowledged. error
elaborate "use two interaction in a time"
you can't have custom IDs with the same value
I have use different customId generated by timestamp
When an interaction still wait for user action, I start a new interaction
Two customId but the button at two interaction have pressed two time
I dont know why

not possible how you're explaining it
if you're referring to a interaction being responded to later, then that could be done
but not the way you're explaining that, though still can't 100% tell what you're trying to do
You are not alone
I tried a countdown for user but its so annoying
You can use a single interaction as many times as you want
You just need to respond accordingly
How can i do that
In your case an user interacting with a button for example, will trigger an interaction event
It has a custom ID you can use to identify the component
You simply respond to that interaction like you would do, with a message for example
Sometime, user use the commands, and press an incorrect button. The start over a commands
And cause a Interaction has already been acknowledged error

An interaction is unique
This error means you’re trying to respond again to the same interaction
You can either edit responses or defer them and respond later
But not respond two times
You can however send a follow up response
Yes, two commands but one interaction
you can edit the message, but you can't respond to it again
Except doing a follow up message
But you should provide some code that causes the error
And we explain why
probably an edge case where forgot to edit if already responded to
I fucked up once before, but to my credit, it was from a code base upgrade
Tbh I’m not entirely sure what he actually wants to do or is doing exactly
If I use edit, its will cause a The reply to this interaction has not been sent or deferred.
you reply or defer it first and then edit
just like how you cant edit a message that doesn't exist
I mean you can also edit without deferring but just within the 3s timeout

Which doesn’t make much sense
Yes, so I use update a Loading message for that
The first message work well
Sometime, user use the commands, and press an incorrect button.
are you waiting for the loading message to be sent first
You sent a “loading message”?
The start over a commands. Press the button and the update cause a Interaction has already been acknowledged error
Don’t send a loading message
Defer the response
That will automatically show the loading status
“Bot is thinking…”
every other call after that should be an edit original interaction response
myth: you can't edit a ephemeral message
funny you can
You can’t delete em
Yes
I'm using em
So I can not follow up

Damn Aurel next Sherlock Holmes

You can follow up em, too
But that can fail once the initial ephemeral response is already gone
iirc if the original response has been dismissed u cant
lel
one handed mobile be like
Aye
the other hand is shoving food in my mouth dw
cough driving cough

Actually having trouble to see what’s “not” working
Like I said provide the code the causes the error, please
You’re responding multiple times
When i do two message, it will cause the error
But it run well if i run 1 message
I try to find a solution if doesnt do a cooldown, let's user user two message in the same time
SHOW THIS PART OF THE CODE PLEASE
you responding two times wrongly
I can’t open that on mobile
You will have to upload that
And please NOT the entire file
Just that part of the code causing the error
It will cause an error every time I pressed a button or select menu, etc. when an other message still waiting for an action
const amountCollector = interaction.channel.createMessageComponentCollector({ amountFilter, componentType: ComponentType.Button, time: COLLECTOR_TIMEOUT, max: 1 });
amountCollector.on('collect', async amountInteraction => {
console.log(customID);
await amountInteraction.update({ content: string.LOADING_STRING, components: [] });
const accountActived = await checkAccountActived(interaction);```
Like this
update work well in the first time, if user start over the commands, an error occurs
Thank you very much, everyone. Thanks for supporting me with the bug. I think I will continue to use the cooldown
It's make everything works well btw

How do you respond before that?
Dont do anything, just start over the command
If the collector end, it works
Well you have to respond
Like showing the select menu
Then creating a message collector
Yes, the first message can do it well
The problem occur if user doesnt finished it
And start over

Explain this please:
/command -> response (select menu) -> response (string loading) -> ???
/command -> response (select menu) -> update(string loading) -> editReply (select menu) -> /command -> response (select menu) -> update(string loading) -> error
update and defering works well in the first time btw
Remove update(string loading) entirely and use deferReply() and editReply() after
Executing the command again has nothing to do with the one before, like I said each interaction is unique
I hope so, but the second message have cause the error in trust
I feel like i need to see the entire file
But I can’t on mobile unfortunately
Unless somebody else getting into it at this time I guess you will have to wait until tomorrow
Thank you Fake, I this I will continue to use the cooldown, Its make everyone happy
When im back at my Pc
I wonder how that should fix the error
Without responding accordingly you will see “interaction failed”
Everyone weren't felt in this bug btw, I was search on Google. I think this is my problem
Yes, If I do a defer
The server down by error, and discord didnt receive any respond cause the problem
I mean it isn’t a bug, at some point you’re just responding wrongly or another response doesn’t happen in time
But without seeing any response I can’t figure it out unfortunately
If you excited with my problem, see you tomorrow
Thank you very much


Sure until tomorrow, bye
Hey quick question... I am sending a select menu in interaction from which user select an option but then i want to set that select option as an already selected option.. how would I do that?
Yeah ik i have to update message but how do I do that like how do i add default: true in an option of select menu which use selected just from the component full without rewrting it
You cannot set them as already selected unless they were disabled
selected checkmarks are reserved for while the user is selecting from the menu
You can achieve this using Markdown or HTML in your bot's description. You can ask in #development for help or use this HTML and Markdown cheatsheet for more resources.
A select menu just is a message component
Once the user selected the option you can just access the message property and therefore the components
interaction.message.components[0].options[??].default = true;
options is your array of options in the select menu
You gotta need to find the right key
Thanks!
Yes
cough
Yeah my bad i need to replace it with index I'm noob

The thing you told wasn't correct i think so i scratched it up and found there is no deafult property in it
Or i am wrong?
There’s no default property in it (by default), yes
You want to set an option as default one (for anybody) after it has been selected, or am I wrong?
Then how do i do what i want to like set it to default option in an interaction?
Yes
Correct
But like i don't wanna keep copying the whole builder for every option it's huge
Okay
Just log interaction.message.components[0].options for me please
When selecting an option of your select menu
That's undefined it's . component[0]. component [0].data.options[0]
No component does only exist for the select menu interaction
It’s the components property when accessing the message property
But thing what you told me to get is undefined
Did you paste in within your select menu interaction?
Can i just do it from the row component which i send initially cuz that is outside so i can acess it
Yeah
If you still have access to the builder var, you can use that as well
Yeah I do have if yes thengow can i dot that?
Log interaction.message for me please
You must been doing something wrong
The attached message of a component interaction is always available
Oh wait w sec
Oh oops

log interaction.message.components[0].components
I forgot the components are an object holding components
I told you it's interaction.message.components[0].components[0].data.options[x]
Yeah
ikr its so weird
literally:
get components
get first
get first components
why
Is it possible with the full action row builder which has default property
That’s already what you need
.data.options[??].default = true;
Then insert the components when editing the message
interaction.update({ components: interaction.message.components});
That’s it
.default = undefined
Why undefined
Thought you wanna set the select one as default one
Undefined doesn’t exist when being stringyfied anyways
It has to be null if so
Is there already a default option before setting one?
One you set as default in the first place?
Stop confusing me 

Why are you logging it?
You should set the property
.default = true;
Then this option is your default option
Umm...okay
Then update the message components as I mentioned above
Told you that above already
You need to set this property called default
To true
Okay i did error :
Show me what u did
const row1 = interaction.message.components[0].components[0].data.options[0].default = true ;
await interaction.update({ content: `${stickerPack} was selected!`, components: [row1] });
That’s not what I told you above lol
You can pass the entire select menu as component only not just option
You dont create a var
interaction.message.components[0].components[0].data.options[0].default = true;
await interaction.update({ content: “…”, components: interaction.message.components});```
Components in []?
Okay
Just paste it like I wrote with accurate quotes
Just as note if you wanna update that default option continuously you will have to loop through all options and set their default value to null
TYSM IT works , how do i get index of the option selected by user like i can get the value but how index to replace it with 0 and etc...
Loop all options how? And if i set it as null it will just error by discord.js
interaction.values
The values selected, if the component which was interacted with was a select menu
You mean value or defaukt as null?
You will have to loop through interaction.message.components[0].components[0].data.options to compare the name with the select one
To get its key
You can also simply use filter() on the array
Which is far easier
Oh got it like if value is 'wumpus' and i have soemthing like this
const sticker =
wumpus : [ index : 0 ],
something: [ index : 1],
And then sticker[interactio.values[0]]
But looping though makes sense in this case as you wanna set default to null for every option before setting it to true for your select one
I don't rlly understand 
Ik that's my problem but give some example
If possible
Which of them as null?
Okay and also if i set Wumpus as default and then select some other value and set it as default then won't the both value being deafult true clash?
I'm also working on mobile 
let options = interaction.message.components[0].components[0].data.options;
for(const option of options)
{
option.default = null;
if(option.value === interaction.values[0]) option.default = true;
}
await interaction.update({ content: “…”, components: interaction.message.components});```
Woah thanks!!!!
Won’t work for multi-select menus of course
As there can’t be multiple default options
Yeah not multiselcet menues
How would I structure a bitwise permission system for CRUD?
Like because if you have update you also should have read and stuff like that. I just made a little sketch of my mind:
{
"users": {
"create": 1,
"read": 2,
"update": 6, // 4 + 2
"delete": 10, // 8 + 2
"manage": 16 // Have all the permissions
}
}
assign each permission a bitwise operator first
1 << 0 -> create
1 << 1 -> read
...
then assign the permissions of the user with (1 << 0) | (1 << 1) | ... = user_permissions
then check if the user has create permissions with (user_permissions & (1 << 0)) == (1 << 0)
or read permission (user_permissions & (1 << 1)) == (1 << 1)
Well I did but e.g. update already has permisison read (2) + update (4)
but like in a condition if can read you would have to check if read OR update OR delete etc.
why with this 1 <<?
that's a left shift
which means?
used for bitwise operations
1 << 0 = 1
1 << 1 = 10
1 << 2 = 100
in binary, not decimal
I always did it some sort like this and then just check:
if (userPermission & json.users.read) {
// Go on...
}
So if userPermission would be 3 he would had read (2) in it
Then 1 << 3 = 101 would be?
hmm okay interesting
1 << x is basically shift 1 by x to the left in binary
Look at: https://gist.github.com/prof3ssorSt3v3/ac03e6db33bf5d71a646320605b20e8c
it's from a YT vid but at the top of the file after the comment he did it too with decimals
no decimals
const READ = 1; // 0001
const DRINK = 2; // 0010
const SING = 4; // 0100
const DELETE = 8; // 1000
and what would be 1001? You don't do that you just give 1000 and 1?
and that's the left shift
??
const READ = 1; // 0001 => 1<<0
const DRINK = 2; // 0010 => 1<<1
const SING = 4; // 0100 => 1<<2
const DELETE = 8; // 1000 => 1<<3
yes sure and I did the same just already combined
This would actually be:
{
"users": {
"create": 1,
"read": 2,
"update": 4,
"delete": 8,
"manage": 16 // Have all the permissions
}
}
yeah that'd be better
yes but now listen xD I wrote it in the comments at the end
if you have update permission you also are able to read that's why I made 6 because of 4 + 2 (two previous permissions)
So I don't have to check multiple permissions if I want to check if he can read.
const Permissions = {
users: {
create: 1,
read: 2,
update: 4,
delete: 8,
manage: 16
}
};
const Users = {
admin: Permissions.users.manage,
moderator: Permissions.users.delete | Permissions.users.update,
basic: Permissions.users.read
};
like this?
well this is like how you'd create roles
yeah but that is an example on the bitwise permission structure
@earnest phoenix With this it would be
// Check if can read
if (userPerm & json.users.read || userPerm & json.users.update || userPerm & json.users.delete || userPerm & json.users.manage) {
// Go on..
}
With combined permissions:
// Check if can read
if (userPerm & json.users.read || userPerm & json.users.manage) {
// Go on..
}
// Because e.g. json.users.update also has read (2)
yes correct
essentially every permission is unique either way
yes but either you have a lot of more conditions to make or not.
You get what I mean?
no because you need to check for that permission either way? don't really get your point
the user should have update permission or not, depending on that they can update or not
yes but now if a user can update he should and is also able to read. So update = update + read
0b1000 | 0b1
or just 0b1001
or 0b1000 + 0b1
well using | and + does not lead to the same at the end
that is how permissions work though

then they can directly write that
it's really bad
Which you mean now?
to me they should be each separate and checked individually
are you making some sort of enum system with bitwise operations
i just don't understand what you mean so maybe i might be wrong 
When I give a user update permissions he has automatically permission to read because without that how would you know what to update. Right?
So when he gets update permissions I want to check if he can read. I want to check for read permission and not also for update permission, you get it? So I put read (2) permission automatically in update (4) permission => 6
no, you would just check for the update permission and add the read as well when changing permission
in the end they will have update and read permission if they are supposed to be able to do both
So you mean if I have 1 read permission and 20 other perms that have bysides their other permission access to read I make a condition that contains 21 permissions?
Yes of course they will but if I give e.g. you update permission. I don't want to extra give read because that's implicitly in update
Well okay nvm maybe it's going a bit too far xD
Yes I understand you and maybe you're right... I can also do it like:
I give you update permission and in the backend it just adds read because it know that it has to have read too for update. Then there's not a 6 in the json but 4 and it just automatically adds both
well that's when you use 1<<6 | 1<<5 to know if the user has both permission afterwards with &?
I think now we're talking about the same thing xD
Assignes updaet = adds update + read (because it know update has read too)
you just don't need an additional permission and save that one as well
it's a mix of two
Alright, Imma go make it the clean way and have one "value" per permission and just check multiple conditions^^ Thanks
it's just that your update permission will be an | of two others
but no need of a separate field
at least that's how i understand it
just confused with your perms and explanations
hello
okay I'm sorry 😅 still thanks for the time
it's fine, probably me being pepega 
nah xD
is there any info on when the self role assignment thing is gonna be available for all servers?
the what? selfroles are already a thing
or what do you mean
if you mean #discord-news message then thats already released
i mean this thingy
if it already released my bad
rip
That's when joining a server, new addition to the welcome screen
At least that's my guess based on the few updates I've seen about that welcome screen
ok i forgot how do i edit a json value
just trying to change these 😭
{
"build": {
"count": 0
},
"orchan": {
"count": 0
}
}```
javascript? json.build.count = 69
read file
make change
override
so just read the file as a json object, make the changes, write back to the file
what is
SyntaxError: Unexpected token u in JSON at position 0
oh im
stringing it
aurel help
i am over thinking this
you misunderstood overriding
its stupid
why the json parse
spoonfeed me aurel uwu
cant you just write the file directly
what is the json.parse for
on the second one
I DONT KNOW
oof what in the world and why
i havent like locally edited a json file with js
you wont need json.parse
or any file for that matter
you need to just write the string content into the file
the first parts are right as far as I'm seeing and knowing
but the second json.parse is unnecessary
you dont need it on the first part either right
just writeFileSync like already there, but use the json stringified
you do
to read the json data
that
yes
you need the first one
you don't even have to read the file and parse it
omg it works ily aurel
just import it
let usage = require("./usage.json");
oh shit yeah js do be funky like that
then edit usage
though honestly, does that make a significant difference between readfile and then writing back?
then save it to the file by stringifying it
you gotta clear it, yes or read the file
also dont think you need the whole stuff within the writeFile
cant you stringify the json
yet again FakE wondering why people create a var they only use once
me for literally everything
just have a list of organized vars that i can scroll through :)
require will cache the object, readfile will actually re-read the file every time
@earnest phoenix or @rustic nova (sry for pings) but remember me i was asking for this regex but now i only want the username tag like username and discrim how would I get it from that regex what parts to remove? Cuz I'm bad at regex and know only little
(If you don't recall me or want additional info see replied msg)
/Request by: (.+#\d{4}) •
Basically getting ID10T#6969 FROM Requested by: ID10T#6969
const json = require("./usage.json");
json.build.count++;
writeFileSync("./usage.json", JSON.stringify(json));
• character doesn't exist
what does your message look like now
@rustic nova
/Requested by: (.+#\d{4})/
they want to remove the requested by part
Thanks 
That to work tho Tim
You should probably just learn regex fundamentals, it's pretty useful and wouldn't take much time to learn, though you can already use the regex I provided but omit the part after \d{4}), and change Request by to Requested by, a good source can be https://regexone.com/
RegexOne provides a set of interactive lessons and exercises to help you learn regular expressions
From basic character groups to trivial conditioning and lookaheads
pog, noted
Oh wow i will learn it in my free time thx
rege
xone
hey, do you know an api that would be given the new additions of the month on netflix FR, a bit like what netflix sends every month to their twitter account (image below) I searched a bit and I couldn't find
use the twitter api, get the image whenever netflix posts it, run it through OCR, parse it, and there you go
:^)
Is there any one have the full flag badges here ?
?
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
Life saver thanks a lot .
https://flags.lewistehminerz.dev/
Might help as well
Contains some undocumented flags if you need them
Oh that flag
Tysm
But is there not booster or nitro ?
No
Well for nitro you can just check if they have a premium discrim
although not everyone with nitro will change their discrim
Actually that seems to be a system flag
nvm
I have a mongodb data base
There is many users and each user has coins I want to get data of first 10 users with most coins what should I do?
use .limit(amount) according to the docs
to at least get only the first 10 users, gotta sort first though
is there a way to get the embed at the top and the attachments at the bottom
code:
m.edit({ embeds: [embed], files: ["./commands/RandomUserSelection.txt", "./commands/RandomRobloxUsers.txt"] });```
not possible, files are always on the top
embeds would always be the last iirc
yup that could work, in 2 separate messages: the embed then the files
Can a regex be optional like regex will have two parts but the string might only have one part or both part to match with?
regexes have groups you can match
using () you can create a group, so for example let's say you have the following regex:
([a-zA-Z0-9]) ([a-zA-Z0-9])
Hello World
Hello would be group 1
World would be group 2
oversimplified
Yes matching groups can be entirely optional
(…) (…)?
Appending a ? behind the match group will make it optional
Which also works for non-capturing groups
(…) (?:…)?
([a-z]+) (?:[0-9]+)?
abcdefg 01234
(group 1) (group 2)
It will also match:
abcdefg
(without the optional second match group)
ignore the space to prevent Flazepe from bullying me again
it is without the pe
Tnx for all
Hmm.. i added one but unexpected token
Removed the space tho shows the error 
Just show me a few examples which the regex pattern should match
Also is that the entire pattern?
Yeah full pattern
/Request by: (.+#\d{4}) •\ Page (\d+) of \d+/ what it does is matches strings like - Requested by ID10T#6969 | Page 3 of 50 and gets me ID10T#6969 but there's a problem here the string can also be Requested by : ID10T#6969 so the regex now errors if it doesn't find page... SO IG i need to optional the page part
(Regex was given by Voltrex)
You need just the name or the page as well?
Both in all cases but rarely only it might happen that there's no page in the string and only usernsme
So in other words... you need the user tag and the current page (if provided)
Yeah
There you go: https://regex101.com/r/RzHSQN/2
Your regex is /requested by\:\s+(.+#\d{4})(?:.+?page\s+(\d+)\s+of\s+\d+)?/i
@fervent moss
ignore the flags g and m, those are just needed to test the regex on multiple lines
Thanks!
that should also respect multiple spaces or other splitters like | or - whatever between name und page .. of ..
as I'm not aware how consistent that matching string is
SHUT UP JAVA BOY
why are u even using regex for?
get data from where? why is a global variable or database not an option?
perhaps there was a better option than using regex
Database stuff is shit what i am doing is when used /command it sends an embed with all info and footer as that thing so if there is an select menu interaction i fetch footer and match it with user tag interaction if not true then stuff if true then stuff
And about page it's like a very long story
Global variable? You mean collection?
not necessarily a collection, but yeah
usually tracking with a variable is preferred over regex
unescaped / in the middle of the regex
there's also no need to escape P there
export default function hashPassword(password: string): { salt: string; hash: string } {
const salt = randomBytes(16).toString('hex');
const hashedPassword = scryptSync(password, salt, 64).toString('hex');
return {
salt,
hash: hashedPassword,
};
}
I have this hash function and I'm wondering if this is enough or let's say decently secure? What can I improve?
const EmbedBuilder
new EmbedBuilder
.setTitle(`i love Sloth`)
.setDescrription(`Sloth loves me :)`)
right Any Package Needed?
soo slashcommands aren't showing up on bot dms for some reason
You Getting Error's?
no
Bot is Not DMing?
what is const EmbedBuilder
seems fine to me tbh
Its a Function
doesn't look like a function to me
Please Help me
oh
your command is very incomplete
I cannot help with your issue
okay nice
Why?
Its Not a Package
don't beg i am pretty sure he would help if he knew
what's your native lang
Native?
first language
indian hmm
Yep
idk if there is any hindi devs here
Alot
here
read it
Ye Bro I was Just Testing
That Top.gg will help xD
There is Missing = require (`discord.js`)
.
had to push public commands since these are the ones that work on dms
Bot Do DM's?
yes
bcrypt and argon2 are more secure for password hashing and have a built-in salt that you don't need to manually keep track of like this
playerStore:Update(function(d)
print(d)
return {
[ore.Name] = d[ore.Name] + ore.Amount.Value
}
end)
ore.Amount.Value -= 5 -- Later plan to make skills be the determining factor of this.
Okay so this is more of a logic question. I have this NumericValue in roblox studio that holds an amount of 10. Each time the player does something it decreases by 5 and that gets added to the player's ore count. But the way it is now it will just add the entire Amount value to the player's inv instead of just the 5 it took away. I am probably being dumb and no realizing how I can do it.



