#development

1 messages · Page 59 of 1

quartz kindle
#

is it only one guild or are you fetching members from multiple guilds?

sterile lantern
#

one guild

#

message.guild

quartz kindle
#

hmm weird

#

can you try with this ^

sterile lantern
#

just did

#

nothing

#

unless its taking a really long time

#

i mean it worked fine without the

quartz kindle
#

if nothing is coming then there is something wrong with the request

sterile lantern
#

user: shuffled

quartz kindle
#

are you on djs v14?

sterile lantern
#

13

quartz kindle
#

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

sterile lantern
#

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

quartz kindle
#

ah i just checked

#

there is actually a limit of 100 ids per request

#

wait no, thats only if you dont have the intent

sterile lantern
#

how do you like

#

check if the user is in the guild

#

!guild.member(id) isnt working

boreal iron
#

You need to fetch the member

sterile lantern
#

wouldnt that return a err

quartz kindle
#

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

sterile lantern
#

then all ids in here are valid

boreal iron
quartz kindle
#

try limiting the number of ids, for example try with 50, then try with 100, then 200, etc

sterile lantern
#

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

rustic nova
#

presence intent

quartz kindle
#

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

solemn latch
#

I thought it was members that are required for presence

quartz kindle
#

its both

#

but he has all intents

solemn latch
#

Even with intent, djs doesnt support users having presences

#

From what I can see

sterile lantern
#

wdym

#

theres a whole section on the djs guide

#

about checking a users presence

solemn latch
#

a user, or a members?

#

user doesnt contain presence.

#

member does

#

You're checking user right?

sterile lantern
#

uh

#

yeah

#

but thats not even the issue bc

#

the fetching fails to work

#

it gives a timeout error

solemn latch
#

the error was you hit a cap on the number you can get i think

solemn latch
quartz kindle
#

those are members tho

solemn latch
quartz kindle
#

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

quartz kindle
solemn latch
#

Then they are checking in the wrong spot maybe?

quartz kindle
#

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

rustic nova
#

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

neon leaf
#

how can I check if a user has admin / owner in server x? Using my client.

rustic nova
#

you probably need to fetch the users permissions and see if their permissions contains admin, using .permissions is my guess per docs

#

and then compare it to the user you're checking

neon leaf
#

how do I get the permissions of a user though?

rustic nova
#

which contains the permissionbitfield of the guild member, from which you could check if it contains Administrator

neon leaf
#

for some reason this is my user

rustic nova
#

has to be a GuildMember, so you'd need to fetch that user from the guild

#

trying to find it right now

#

using .fetch

neon leaf
#

I am already using all these though

neon leaf
rustic nova
#

what happens when you dont do .user

#

since that obtains a user from the guildmember

neon leaf
rustic nova
#

yup thats the one you need

#

that one contains .permissions

neon leaf
#

where?

rustic nova
neon leaf
#

ah, idk why it doesnt show in the json

#

PermissionsBitField { bitfield: 2199023255551n }

rustic nova
#

yeah uses the roles one

neon leaf
#

this should be true when owner or admin, eight?
await m.permissions.has(PermissionsBitField.Flags.Administrator)

rustic nova
#

yes

neon leaf
#

key, thank you so much!

rustic nova
#

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
neon leaf
#

yeah, I only need to know if he has admin rights, so that should be enought, right?

rustic nova
#

should be enough, unless you have configuration sections that require the user to be the owner

neon leaf
#

so, this is about 0% done but in the last try statement, will the return be for the entire function or only the try?

rustic nova
#

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

neon leaf
#

why isnt it grabbing the cookies? (koa)

#

or does it grab the cookies of the api, not the dashboard?

rustic nova
#

depends on the endpoint your user is on

#

or wait

#

where is stats/guild used?

neon leaf
#

on the dashboard (www.x.x)

rustic nova
#

print out the cookies and see if they're available

neon leaf
#

when I log them they are NaN

rustic nova
#

is your api on a different domain by any chance?

neon leaf
#

ya

#

api.x.x

rustic nova
#

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?

neon leaf
#

koa

rustic nova
#

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

neon leaf
#

ig Ill just use headers then, its just 3 anyway

rustic nova
#

nah gimme a sec

#

could you show me how you're setting the cookies, aswell as where you're setting them?

neon leaf
#

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 "";
}```
rustic nova
#

You need to add another value when setting the cookie, the domain

#

for the entire domain, Domain=.yoursite.com

#

the . is important

#

nvm the first one works too

neon leaf
rustic nova
#

question for someone who can understand js directly KEKW

neon leaf
#

does client.guilds.fetch() use the cache? if so, can I disable it?

rustic nova
#

you can use force = true to bypass the cache

neon leaf
#

like this?

rustic nova
#

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

tame linden
#

What happen if I dont use force

neon leaf
#

yeah, it detects perm changes pretty instant now

rustic nova
rustic nova
#

since you're essentially fetching it every time aka making a request every time

neon leaf
#

yu

lyric mountain
deft rock
#

to send a embed via interaction to the same channel is it interaction.channel.send

lyric mountain
#

and please, use linebreaks without fear, nobody benefits from inline ifs and one-line codes

deft rock
#

interaction is undefined

lyric mountain
#

without code it's impossible to know why

deft rock
#
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

lyric mountain
#

well, the only things defined in that code are exampleEmbed and EmbedBuilder

deft rock
#

ok, I don't remember how I defined interaction, all of my other commands use the slashcommandbuilder

hidden gorge
#

bossnames = ['Mutated Bear', 'Mutated Lion']

print(bossnames, "Health = ", EnemyHealth)```
#

why is it saying my list?

earnest phoenix
hidden gorge
#

i fixed it but now it’s not logging anything

earnest phoenix
#

You may have fixed it, but you didn't added proper indentation

hidden gorge
#

i did now

earnest phoenix
#

So the issue is fixed

hidden gorge
#

no

earnest phoenix
#

You clearly said "i did now"

#

To "but you didn't added proper indentation"

hidden gorge
#

it still doesn’t print a name from the list and when it does it prints both

earnest phoenix
hidden gorge
#

i changed it to for names in bossnames

#

it’s not printing

earnest phoenix
#

Thanks for the code

hidden gorge
#

yeah one sec

#

it’s meant to be .py wtf

earnest phoenix
#

you may want to take a look at the code example again, specifically the indentation

hidden gorge
#

i did

earnest phoenix
#

One part of your code

#

One other

#

So no, you don't use proper indentation

hidden gorge
#

oh wait i’m stupid

#

i added the indentation and still nope

thorny field
#

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?

rustic nova
#

it should still mention that for example your bot collects that and stuff

#

at least for the privacy policy

thorny field
#

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

lament rock
#

people usually abuse brevity of terms of service if it doesn't cover every case

radiant kraken
#

@earnest phoenix please explain

quartz kindle
#

lmfao

earnest phoenix
#

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'

lyric mountain
#

await it

earnest phoenix
#

i just thought to do that

#

lemme try

#

same error

lyric mountain
#

show code

earnest phoenix
lyric mountain
#

btw, why are u even doing all this?

earnest phoenix
#

writing a dashboard

lyric mountain
#

can't u just use the avatar directly from the oauth?

earnest phoenix
#

also so that i don't send requests to discord's api 50 times / second

lyric mountain
#

retrieving the avatar technically doesn't count as an api request

earnest phoenix
#

oh sugar i didn't think of that

lyric mountain
#

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

tidal jackal
#

how do I embed css in the long description? can I get an example?

lyric mountain
#

just like you'd do in html

#
#

but without the html structure (without <head> or <body>)

tidal jackal
#

right ok thanks

#

so you can only use inline css?

lyric mountain
#

no, styles blocks work too

tidal jackal
#

ah dope ok thanks

crimson dagger
#

how do i add images/gifs like this?

lyric mountain
#

html image tag

crimson dagger
tired jacinth
#

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

earnest phoenix
tired jacinth
neon leaf
#

whats the best way to display a timer without <t:unixtime:R>?
Because that requires the Users Clock to be synced

rustic nova
#

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
sterile lantern
#

heres the full code

neon leaf
sterile lantern
sterile lantern
# sterile lantern

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
    },```
rustic nova
#

it's really the users fault if their clock is behind

quartz kindle
#

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

sterile lantern
#

yellow is the members.length im fairly sure

quartz kindle
#

can you show the code you used to print?

sterile lantern
#
      console.log(x.d.presences.length)```
#

if u wanted members.presences.length thats undefined and crashes

quartz kindle
#

presences are not inside members in the raw data, they are separate

quartz kindle
#

1000 members, 94 presences, 1000 members, 104 presences, ...

sterile lantern
#

why arent all the presences being fetched then

quartz kindle
#

they are

#

just not all of them

#

offline presences are not fetched afaik

sterile lantern
#

oh

#

hmm

#

then how come the command doesnt work

quartz kindle
#

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

sterile lantern
#
{
  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

quartz kindle
#

thats a member, what about a presence?

sterile lantern
#
  user: { id: '976229317644259338' },
  status: 'online',
  client_status: { mobile: 'online' },
  activities: []
}```
quartz kindle
#

yeah thats a presence

#

so presences are indeed coming in

sterile lantern
#

so how would i get that

#

in my code

#

bc doing <id>.presence doesnt work

quartz kindle
#

add this to you code, right after the members fetch: console.log(message.guild.presences.cache.size)

sterile lantern
#

prints 751

#

theres

#

like 8000 members

quartz kindle
#

then there are 751 non-offline members

sterile lantern
quartz kindle
#

then i dont know, discord issue

sterile lantern
#

how do i get the presence of a member tho

#

like checking it

quartz kindle
#

you have to ask in discord developers or something

sterile lantern
#

kk

quartz kindle
#

member.presence should work, unless its one of the members without a presence, ie, they are offline

sterile lantern
#

yeah i check that

quartz kindle
#

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?

sterile lantern
#

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)

quartz kindle
#

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

earnest phoenix
#

hello i need help please

earnest phoenix
jovial nimbus
#

in dashboard, How to create a page that no user can access except for the people whose ID I entered

rustic nova
#

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

fervent moss
#

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?

rustic nova
#

Your goal is a regex then

fervent moss
rustic nova
#

I'll try to make a baseline regex for that

#

the page numbers go till what?

sterile lantern
#

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

fervent moss
earnest phoenix
rustic nova
#

voltrex you smel

earnest phoenix
#

The first capture group will be the tag (username and discriminator), and second one will be the current page

rustic nova
#

wait is that actually possible?

earnest phoenix
fervent moss
#

Cool thanks i will just test it out

rustic nova
#

it does actually work

#

why did I think regex is pain

fervent moss
#

Cool thx aurel and voltrex

rustic nova
#

I at least tried lmao

earnest phoenix
#

It can take a while to master but it's not hard

rustic nova
earnest phoenix
#

Which part of it did you think was not possible?

rustic nova
#

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

earnest phoenix
#

Since usernames can contain all kinds of Unicode characters it's better to just match everything until the last # delimiter

rustic nova
#

yeah

slim heart
#

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

wheat mesa
#

Why does nobody use the \w or \d regex groups :c

fervent moss
#

@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?

rustic nova
#

then the : should be first

#

no?

fervent moss
#

I use exec method

earnest phoenix
fervent moss
#

Thanks!

earnest phoenix
slim heart
#

“2022-10-17 21:00:00 ET”

earnest phoenix
# slim heart “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 troll

boreal iron
#

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

hidden gorge
#

does anyone know what could cause this?

sharp geyser
#

Table wasn't found in the database

#

did you create it?

hidden gorge
#

how do i?

sharp geyser
#

Using sql?

hidden gorge
#

yes

sharp geyser
#

Why are you querying a table if you don't even know how to make a table

hidden gorge
#

that’s what i have rn

sharp geyser
#
CREATE TABLE example (
 someField DataType
)
hidden gorge
#

where do i put it?

sharp geyser
#

Wait do you already have a predefined table?

hidden gorge
#

sorry i’m confused now

sharp geyser
#

Oh wait nvm thats a list of tables you have

sharp geyser
hidden gorge
#

i used a website that gave me a server

lyric mountain
#

mysql 😔

sharp geyser
#

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

lyric mountain
#

why are u showing the information schema?

hidden gorge
#

idk

#

i have never used mysql before

sharp geyser
#

💀

#

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.

lyric mountain
#

this is ur database

#

everything above doesn't matter

#

you need to create its structure

boreal iron
rustic nova
#

its mostly already provided if you're directly buying a mysql database

#

instead of selfhosting one

slim heart
#

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

boreal iron
#

That’s the issue without standardization

boreal iron
#

If so he would need to select the database anyways before creating a table

#

But yeah….

tame linden
#

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

rustic nova
#

elaborate "use two interaction in a time"

#

you can't have custom IDs with the same value

tame linden
#

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

rustic nova
#

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

boreal iron
#

You are not alone

tame linden
#

I tried a countdown for user but its so annoying

boreal iron
#

You can use a single interaction as many times as you want

#

You just need to respond accordingly

tame linden
boreal iron
#

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

tame linden
#

And cause a Interaction has already been acknowledged error

boreal iron
#

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

tame linden
#

Yes, two commands but one interaction

boreal iron
#

That’s impossible

#

Any interaction is unique as I said

rustic nova
#

you can edit the message, but you can't respond to it again

boreal iron
#

Except doing a follow up message

#

But you should provide some code that causes the error

#

And we explain why

lament rock
#

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

boreal iron
#

Tbh I’m not entirely sure what he actually wants to do or is doing exactly

tame linden
lament rock
#

you reply or defer it first and then edit

#

just like how you cant edit a message that doesn't exist

boreal iron
#

I mean you can also edit without deferring but just within the 3s timeout

lament rock
boreal iron
#

Which doesn’t make much sense

tame linden
#

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.

lament rock
#

are you waiting for the loading message to be sent first

boreal iron
tame linden
#

The start over a commands. Press the button and the update cause a Interaction has already been acknowledged error

boreal iron
#

Don’t send a loading message

#

Defer the response

#

That will automatically show the loading status

#

“Bot is thinking…”

tame linden
lament rock
#

every other call after that should be an edit original interaction response

rustic nova
#

myth: you can't edit a ephemeral message

lament rock
#

funny you can

boreal iron
#

You can’t delete em

rustic nova
#

is what I discovered recently

#

yeah only edit em

tame linden
#

I'm using em

#

So I can not follow up

boreal iron
#

Damn Aurel next Sherlock Holmes

#

You can follow up em, too

#

But that can fail once the initial ephemeral response is already gone

lament rock
#

iirc if the original response has been dismissed u cant

boreal iron
#

lel

lament rock
#

one handed mobile be like

boreal iron
#

Aye

lament rock
#

the other hand is shoving food in my mouth dw

boreal iron
#

cough driving cough

lament rock
#

FakE was killed in a car crash today..

#

no response

boreal iron
tame linden
#

I have do a screen capture, lets see what happen with me

boreal iron
#

Well yeah

#

Can’t watch it anyways

tame linden
#

At the end, it crash with error

#

'Interaction has already been acknowledged.',

boreal iron
#

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

tame linden
#

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

boreal iron
#

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

tame linden
#

Please wait a minute

boreal iron
#

Sure

#

Will be back in a few minutes

tame linden
# boreal iron Sure

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

boreal iron
#

How do you respond before that?

tame linden
#

If the collector end, it works

boreal iron
#

Well you have to respond

#

Like showing the select menu

#

Then creating a message collector

tame linden
#

The problem occur if user doesnt finished it

#

And start over

boreal iron
#

Explain this please:
/command -> response (select menu) -> response (string loading) -> ???

tame linden
#

/command -> response (select menu) -> update(string loading) -> editReply (select menu) -> /command -> response (select menu) -> update(string loading) -> error

boreal iron
#

update and editReply seem to be wrong here without deferring

#

Try the following

tame linden
#

update and defering works well in the first time btw

boreal iron
#

Remove update(string loading) entirely and use deferReply() and editReply() after

tame linden
#

And defer still cause an error if start over the command

#

I have tried this

boreal iron
#

Executing the command again has nothing to do with the one before, like I said each interaction is unique

tame linden
boreal iron
#

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

tame linden
#

Thank you Fake, I this I will continue to use the cooldown, Its make everyone happy

boreal iron
#

When im back at my Pc

tame linden
#

You and me

boreal iron
#

I wonder how that should fix the error

#

Without responding accordingly you will see “interaction failed”

tame linden
#

Everyone weren't felt in this bug btw, I was search on Google. I think this is my problem

tame linden
#

The server down by error, and discord didnt receive any respond cause the problem

boreal iron
#

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

tame linden
#

If you excited with my problem, see you tomorrow

boreal iron
#

Sure until tomorrow, bye

fervent moss
#

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

lament rock
#

You cannot set them as already selected unless they were disabled

#

selected checkmarks are reserved for while the user is selecting from the menu

earnest phoenix
#

how can we add box like this in description of topgg

#
hello```
gilded plankBOT
boreal iron
#

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

fervent moss
boreal iron
#

Show me what u did

#

Is the select menu the only message component?

boreal iron
#

cough

fervent moss
boreal iron
#

You should read again what I told you about options[]

fervent moss
#

Yeah my bad i need to replace it with index I'm noob

boreal iron
fervent moss
#

Or i am wrong?

boreal iron
#

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?

fervent moss
#

Yes

#

Correct

fervent moss
boreal iron
#

You don’t need to

#

One second

fervent moss
#

Okay

boreal iron
#

Just log interaction.message.components[0].options for me please

#

When selecting an option of your select menu

fervent moss
boreal iron
#

No component does only exist for the select menu interaction

#

It’s the components property when accessing the message property

fervent moss
#

But thing what you told me to get is undefined

boreal iron
#

Did you paste in within your select menu interaction?

fervent moss
#

Can i just do it from the row component which i send initially cuz that is outside so i can acess it

boreal iron
#

If you still have access to the builder var, you can use that as well

fervent moss
boreal iron
#

Log interaction.message for me please

#

You must been doing something wrong

#

The attached message of a component interaction is always available

fervent moss
#

Oh wait w sec

boreal iron
#

Oh oops

fervent moss
boreal iron
#

log interaction.message.components[0].components

#

I forgot the components are an object holding components

fervent moss
#

I told you it's interaction.message.components[0].components[0].data.options[x]

boreal iron
#

Yeah

rustic nova
#

literally:

get components
get first
get first components

#

why

boreal iron
#

Yeah

#

Because any option are also components

#

It’s just…

fervent moss
fervent moss
boreal iron
#

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

fervent moss
boreal iron
#

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 topggDoge

boreal iron
#

Why are you logging it?

#

You should set the property

#

.default = true;

#

Then this option is your default option

fervent moss
#

Umm...okay

boreal iron
#

Then update the message components as I mentioned above

#

Told you that above already

#

You need to set this property called default

#

To true

fervent moss
boreal iron
#

Show me what u did

fervent moss
# boreal iron 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] });
boreal iron
#

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

fervent moss
#

Then?

#

Like component: [interaction.message..]

boreal iron
#
interaction.message.components[0].components[0].data.options[0].default = true;

await interaction.update({ content: “…”, components: interaction.message.components});```
boreal iron
#

components already is an array of components

fervent moss
#

Okay

boreal iron
#

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

fervent moss
fervent moss
boreal iron
#

interaction.values

The values selected, if the component which was interacted with was a select menu

fervent moss
#

You mean value or defaukt as null?

boreal iron
#

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

fervent moss
boreal iron
#

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

fervent moss
#

Ik that's my problem but give some example

#

If possible

fervent moss
boreal iron
#

Man that’s pain to write on mobile

#

One second

fervent moss
# boreal iron One second

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 innocent

boreal iron
#
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});```
fervent moss
#

Woah thanks!!!!

boreal iron
#

Won’t work for multi-select menus of course

#

As there can’t be multiple default options

fervent moss
#

Yeah not multiselcet menues

raw nest
#

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
    }
}
earnest phoenix
#

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)

raw nest
earnest phoenix
#

well that's not how it should be done

#

must be

1 << 0
1 << 1
1 << 2
1 << 3
...
raw nest
#

but like in a condition if can read you would have to check if read OR update OR delete etc.

raw nest
earnest phoenix
#

that's a left shift

raw nest
#

which means?

earnest phoenix
#

used for bitwise operations

#
1 << 0 = 1
1 << 1 = 10
1 << 2 = 100
#

in binary, not decimal

raw nest
raw nest
earnest phoenix
#

no

#

would be 1000

raw nest
#

hmm okay interesting

earnest phoenix
#

1 << x is basically shift 1 by x to the left in binary

raw nest
earnest phoenix
#

no decimals

const READ = 1; //   0001
const DRINK = 2; //  0010
const SING = 4; //   0100
const DELETE = 8; // 1000
raw nest
earnest phoenix
#

and that's the left shift

earnest phoenix
#
const READ = 1; //   0001 => 1<<0
const DRINK = 2; //  0010 => 1<<1
const SING = 4; //   0100 => 1<<2
const DELETE = 8; // 1000 => 1<<3
raw nest
#

yes sure and I did the same just already combined

raw nest
earnest phoenix
#

yeah that'd be better

raw nest
#

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.

earnest phoenix
#
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?

raw nest
earnest phoenix
raw nest
# raw nest So I don't have to check multiple permissions if I want to check if he can read.

@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)
earnest phoenix
#

essentially every permission is unique either way

raw nest
earnest phoenix
#

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

raw nest
radiant kraken
#

or just 0b1001

#

or 0b1000 + 0b1

earnest phoenix
#

well using | and + does not lead to the same at the end

radiant kraken
#

i know

#

but he requested 1001 so

earnest phoenix
radiant kraken
earnest phoenix
#

it's really bad

raw nest
earnest phoenix
#

to me they should be each separate and checked individually

radiant kraken
#

are you making some sort of enum system with bitwise operations

earnest phoenix
#

i just don't understand what you mean so maybe i might be wrong kryptonShrug

raw nest
earnest phoenix
#

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

raw nest
#

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?

raw nest
#

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

earnest phoenix
#

well that's when you use 1<<6 | 1<<5 to know if the user has both permission afterwards with &?

raw nest
#

I think now we're talking about the same thing xD
Assignes updaet = adds update + read (because it know update has read too)

earnest phoenix
#

you just don't need an additional permission and save that one as well

#

it's a mix of two

raw nest
#

Alright, Imma go make it the clean way and have one "value" per permission and just check multiple conditions^^ Thanks

earnest phoenix
#

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

leaden ibex
#

hello

raw nest
earnest phoenix
#

it's fine, probably me being pepega Prayge

raw nest
#

nah xD

digital swan
#

is there any info on when the self role assignment thing is gonna be available for all servers?

rustic nova
#

the what? selfroles are already a thing

#

or what do you mean

rustic nova
#

oh lol

#

nah first time seeing that

digital swan
#

rip

earnest phoenix
#

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

uneven tartan
#

ok i forgot how do i edit a json value

#

just trying to change these 😭

{
    "build": {
        "count": 0
    },
    "orchan": {
        "count": 0
    }
}```
neon leaf
#

javascript? json.build.count = 69

uneven tartan
#

how do i actually update it in the json file though

#

i forgor

rustic nova
#

read file
make change
override

#

so just read the file as a json object, make the changes, write back to the file

uneven tartan
#

what is

#

SyntaxError: Unexpected token u in JSON at position 0

#

oh im

#

stringing it

uneven tartan
#

i am over thinking this

rustic nova
#

hi

#

yes you are

uneven tartan
#

😭

rustic nova
#

dafoq

uneven tartan
#

i mean

#

it works but

rustic nova
#

you misunderstood overriding

uneven tartan
#

its stupid

rustic nova
#

why the json parse

uneven tartan
#

spoonfeed me aurel uwu

rustic nova
#

cant you just write the file directly

#

what is the json.parse for

#

on the second one

uneven tartan
#

I DONT KNOW

boreal iron
#

oof what in the world and why

rustic nova
#

it reminds me of python having

with xyz:
do this

uneven tartan
#

i havent like locally edited a json file with js

rustic nova
#

you wont need json.parse

uneven tartan
#

or any file for that matter

rustic nova
#

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

uneven tartan
#

you dont need it on the first part either right

rustic nova
#

just writeFileSync like already there, but use the json stringified

#

you do

#

to read the json data

#

that

uneven tartan
#

yes

rustic nova
#

you need the first one

boreal iron
#

you don't even have to read the file and parse it

uneven tartan
#

omg it works ily aurel

boreal iron
#

just import it

uneven tartan
#

oh

#

file = require(file)
file.writeFileSync()etcetc\

#

well

boreal iron
#

let usage = require("./usage.json");

rustic nova
boreal iron
#

then edit usage

rustic nova
#

though honestly, does that make a significant difference between readfile and then writing back?

boreal iron
#

then save it to the file by stringifying it

rustic nova
#

the require doesnt update does it?

#

if you write the file

boreal iron
#

the files are cached, like always

uneven tartan
#

yes

boreal iron
#

you gotta clear it, yes or read the file

rustic nova
#

cant you stringify the json

uneven tartan
#

whysob

#

it work

boreal iron
#

yet again FakE wondering why people create a var they only use once

uneven tartan
#

me for literally everything

#

just have a list of organized vars that i can scroll through :)

boreal iron
#

I should literally stop wondering or asking

#

or thinking

quartz kindle
fervent moss
rustic nova
#

/Request by: (.+#\d{4}) •

fervent moss
#

Basically getting ID10T#6969 FROM Requested by: ID10T#6969

quartz kindle
# uneven tartan
const json = require("./usage.json");

json.build.count++;

writeFileSync("./usage.json", JSON.stringify(json));
fervent moss
rustic nova
#

then /Request by: (.+#\d{4})

#

wait

fervent moss
#

Ohk

rustic nova
#

what does your message look like now

rustic nova
#

/Requested by: (.+#\d{4})/

quartz kindle
#

they want to remove the requested by part

fervent moss
earnest phoenix
# fervent moss <@456226577798135808> or <@669452973755072524> (sry for pings) but remember me i...

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/

#

From basic character groups to trivial conditioning and lookaheads

fervent moss
#

Oh wow i will learn it in my free time thx

quartz kindle
#

rege
xone

wicked pivot
#

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

quartz kindle
#

use the twitter api, get the image whenever netflix posts it, run it through OCR, parse it, and there you go

#

:^)

tired jacinth
#

Is there any one have the full flag badges here ?

deft rock
#

?

rustic nova
tired jacinth
earnest phoenix
#

Contains some undocumented flags if you need them

deft rock
#

Oh that flag

tired jacinth
#

But is there not booster or nitro ?

deft rock
#

No

sharp geyser
#

although not everyone with nitro will change their discrim

#

Actually that seems to be a system flag

#

nvm

tired jacinth
#

Oh right true

#

High iq move

sharp geyser
#

idk if it will show up as a user flag

#

as it seems to be under system flags

tired jacinth
#

I will try ^^

#

Ty ty

stiff dust
#

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?

rustic nova
#

use .limit(amount) according to the docs

#

to at least get only the first 10 users, gotta sort first though

sterile lantern
#

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"] });```
rustic nova
#

not possible, files are always on the top

sterile lantern
#

of embeds?

#

ah i guess it only works for text

#

f

rustic nova
#

embeds would always be the last iirc

sterile lantern
#

i can probably just

#

send the attachments after

rustic nova
#

yup that could work, in 2 separate messages: the embed then the files

sterile lantern
#

mhm

#

alr thanks

fervent moss
#

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?

rustic nova
#

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

boreal iron
#

(…) (…)?

#

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)

boreal iron
#

ignore the space to prevent Flazepe from bullying me again

dry imp
#

it is without the pe

raw acorn
#

Tnx for all

fervent moss
#

Removed the space tho shows the error dogecorn

boreal iron
#

Just show me a few examples which the regex pattern should match

boreal iron
fervent moss
# boreal iron Just show me a few examples which the regex pattern should match

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)

boreal iron
fervent moss
boreal iron
#

So in other words... you need the user tag and the current page (if provided)

boreal iron
#

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

boreal iron
#

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

lyric mountain
#

why are u even using regex for?

boreal iron
#

you can also use the magical power of your personal god to get the data

lyric mountain
#

get data from where? why is a global variable or database not an option?

boreal iron
#

tf you asking that

#

he wanted a pattern to match that string

#

that's what he got

lyric mountain
#

perhaps there was a better option than using regex

fervent moss
#

And about page it's like a very long story

cinder patio
#

so why isn't a global variable / variable attached to your client not an option?

fervent moss
lyric mountain
#

not necessarily a collection, but yeah

#

usually tracking with a variable is preferred over regex

radiant kraken
#

there's also no need to escape P there

raw nest
#
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?

leaden ibex
#
const EmbedBuilder

new EmbedBuilder
.setTitle(`i love Sloth`)
.setDescrription(`Sloth loves me :)`)
slender wagon
#

soo slashcommands aren't showing up on bot dms for some reason

leaden ibex
slender wagon
#

no

leaden ibex
#

Bot is Not DMing?

leaden ibex
#

Its a Function

slender wagon
#

doesn't look like a function to me

leaden ibex
leaden ibex
slender wagon
#

your command is very incomplete

rustic nova
#

I cannot help with your issue

raw nest
leaden ibex
leaden ibex
slender wagon
slender wagon
leaden ibex
#

Native?

slender wagon
#

first language

leaden ibex
#

Oh

#

HTML

slender wagon
#

indian hmm

leaden ibex
#

Yep

slender wagon
#

idk if there is any hindi devs here

leaden ibex
#

Alot

slender wagon
#

so you could form ur questions better

#

discord.js?

leaden ibex
#

Node.js

slender wagon
#

here

slender wagon
#

read it

leaden ibex
#

Ye Bro I was Just Testing

#

There is Missing = require (`discord.js`)

slender wagon
#

we don't spoonfeed

#

so i couldn't just give you that

slender wagon
slender wagon
slender wagon
#

yes

woeful pike
sharp geyser
#
    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.