#development

1 messages · Page 18 of 1

sharp geyser
#

but like

winged linden
#

Yo for slash commands, if i have my commands registered for all servers (global) do they get registered automated for new server that add the bot or i need a script to reregister the commands each time a bot gets added into a guild?

boreal iron
#

Enough to live roughly?!

#

Maybe not for the US tho

sharp geyser
#

Min wage here is 14.75/h

#

I get paid weekly

lyric mountain
#

tbh, I'm also quite busy lmao, but now you have a project to gather people for it

#

still rewriting my bot

boreal iron
sharp geyser
#

the option to invite is grayed out

lyric mountain
#

weird

winged linden
boreal iron
#

My answer literally answers that

#

[…] they been pushed to guilds adding your bot automatically

winged linden
#

Ah cool cool, just wanna be 100% sure. Thanks sir

boreal iron
#

No matter your bot is online or not

winged linden
#

🤝

boreal iron
ancient nova
#
    // First of all, let's try fetching our member 
    let memberHackBanned = false, member = message.mentions.members.first()
    || message.guild.members.cache.get(args[0])
    || message.guild.members.cache.find(r => r.user.username.toLowerCase() === args.join(' ').toLocaleLowerCase())
    || message.guild.members.cache.find(r => r.displayName.toLowerCase() === args.join(' ').toLocaleLowerCase());
    if (!member) {
        await client.users.fetch(args[0]).then((fetchedMember) => {
            member = fetchedMember; memberHackBanned = true;
        }).catch((err) => {
            memberHackBanned = false;
        }); if (!member) return message.reply({
            content: `I was unable to fetch the mentioned member.`
        });
    }; const hackBannedMemberTag = !memberHackBanned 
    ? member?.user?.tag 
    : `${member.username}#${member.discriminator}`;
``` third variation (most likely a version that won't break)
#

I had to rewrite it like 3 times because something kept breaking

#

this should fetch properly

#

if the member is in the server, it will work with ID name and mention properly, will check for permissions etc.
if the member isn't, we just create a ban, and send confirmation with the fetched details

#

no need to check for the members permissions since they are not in this server

lyric mountain
#

that code makes me angry and sad at the same time

ancient nova
#

why?

boreal iron
ancient nova
#

😭

lyric mountain
#

the proper question would be "why not"

ancient nova
#

I fully tested it, no errors at all, now it only hack bans if the user isn't in the guild

#

it's perfect

#

I will also update the guild.ban.create function a little bit

#

to make it safer and avoid errors

lyric mountain
#
const id = args[0];
const parsedArgs = args.join(' ').toLowerCase();
const condition = r => r.user.id === id || r.user.username.toLowerCase() === parsedArgs || r.displayName.toLowerCase() === parsedArgs;
const member = message.mentions.members.first() ?? message.guild.members.cache.find(condition) ?? (await client.users.fetch(id));

if (!member) {
    return message.reply({ content: `I was unable to fetch the mentioned member.` });
}

const hackBannedMemberTag = (member.user ?? member).tag;
#

much better

ancient nova
#

did u test this code?

lyric mountain
#

nope, ain't gonna install d.js just for that

#

but users.fetch returns an user

sharp geyser
#

That is when you

lyric mountain
#

ah wait

ancient nova
#

ye it's going to error

sharp geyser
#

fix the parts

#

that don't work

#

😎

ancient nova
lyric mountain
#

there

sharp geyser
#

Can't always rely on the end user being correct

#

so if you can fix it, fix it yourself

ancient nova
#

still won't work

sharp geyser
#

wdym

ancient nova
#

if u use fetch there isn't a tag property anywhere

sharp geyser
#

How won't it work

#

Tf

#

you are 100% wrong

#

.tag is a prop all users have

#

so if you fetch a user

#

ofc it will have it

lyric mountain
ancient nova
#

u have to do member.username + # + member.discriminator

sharp geyser
#

Wrong

ancient nova
#

to get the tag

#

I'm not wrong tag property don't exist

sharp geyser
ancient nova
#

bro

lyric mountain
ancient nova
#

I'll prove u wrong

lyric mountain
#

sure

sharp geyser
#

Idgf what you do

#

the docs are there

lyric mountain
#

(A ?? B) will grab A if it exists, or B otherwise

#

that's how null-coalescing operator works

#

also called elvis in other langs

sharp geyser
ancient nova
#

@sharp geyser

sharp geyser
#

...

ancient nova
#

no tag property

sharp geyser
#

Ofc it doesn't exist in the fucking raw data

#

discord.js implements it themselves

lyric mountain
#

^

sharp geyser
#

Reading

lyric mountain
#

it's basically a getter

sharp geyser
#

docs

#

are

#

important

lyric mountain
#

with getters u can makeup any value you want transparently to the end user

#

also why stuff like private fields exist

ancient nova
#

how the fuck are u going to get the tag then

lyric mountain
#

tag is a getter

ancient nova
#

show the code u used

sharp geyser
#

Are you actually ignoring everything I said?

ancient nova
#

I'm just not understanding

sharp geyser
#

Discord.js does it for you

ancient nova
#

but howm

#

how?

sharp geyser
#

They basically do what you just did

#

but for you

lyric mountain
#

tag is a getter that concats username#discrim

#

it doesn't exist as a raw property

ancient nova
sharp geyser
#

but it does exist as a property on the user object itself

ancient nova
#

ok how do u turn the raw data into normal user fetch from djs

sharp geyser
#

Internally djs casts the raw data into a user object

#

and then they do stuff internally to make your life easier

#

such as forming the tag for you

#

by doing user.username#user.descriminator

#

as you can see here

#

if you actually read my fucking messages

ancient nova
#

bro ur not going to get the fucking d.js user property when doing client.users.fetch?????

#

it returns RAW data as you said

sharp geyser
#

🤔

ancient nova
sharp geyser
lyric mountain
#

Fetch returns an user buddy

sharp geyser
#

it returns a Promise of the User

#

I get it if you really don't know

#

but you seem like you don't even bother checking docs

#

so it pisses me off when you try and say it doesn't

ancient nova
sharp geyser
#

What exactly are you doing

#

Show the code

ancient nova
#

const member = client.users.fetch("714962308631101500"); member.user.tag;

#

where is the user proprty?

sharp geyser
#

just cause you call it a member

#

doesn't mean it is

#

client.users.fetch

#

you are fetching a user

#

not a member

#

so therefor member.user isn't a thing

#

it would be member.tag

ancient nova
#

client.members.fetch isn't a thing in d.js

sharp geyser
#

well obviously

ancient nova
#

then I am right?

#

u can't get the tag property

sharp geyser
#

Okay I refuse to help further if you ignore what I say

ancient nova
#

doing member.tag returns undefined also

sharp geyser
#

What you are doing

#

is fetching a USER

#

users do not have a .user property

ancient nova
#

const user = client.users.fetch("714962308631101500");
user.tag;

#

returns undefined

#

cause

#

tag

#

does

#

not

#

exist

sharp geyser
#

but

#

you

#

are

#

wrong

ancient nova
#

no

#

I'm

#

not

sharp geyser
#

Okay lets walk through this

ancient nova
#

I just evaled that

sharp geyser
#

Client is your client class right

ancient nova
#

yes

sharp geyser
#

Client#users returns a UserManager

#

fetch is a method of UserManager

#

and what does fetch return?

ancient nova
#

yes?

sharp geyser
#

A user

#

so therefore

ancient nova
#

the user property, but it does not have a tag property in it

sharp geyser
#

.tag in any way possible

#

does exist

ancient nova
#

come to my server

#

I will

#

show

#

it

#

to u

sharp geyser
#

The only way possible it doesn't exist

#

is if user itself is not what you think

ancient nova
#

just come, I'd be better to explain it with actions rather than words

sharp geyser
#

I don't join people's servers

#

sorry

ancient nova
#

you'll see for yourself

#

ok then add my bot to yours and invite me

sharp geyser
#

Have you tried logging what user is

ancient nova
#

I showed you above what it is

#

tag isn't a thing in there

sharp geyser
#

So the result of you fetching is a raw user object?

ancient nova
#

yes

sharp geyser
#

Then you are doing something majorly wrong

#

Cause it gives me the correct thing when I fetch

ancient nova
#

literally not

sharp geyser
#

Literally are

#

I just fetched a user, and was able to get their tag easily

ancient nova
#

just invite me to yours server, and eval what I tell you

#

you'll see

sharp geyser
#

@ancient nova without code I can't help you further

#

I already have proven what you need to do works

#

So at this point you are just doing something else wrong

ancient nova
#

no I am fucking not

sharp geyser
#

Why are you awaiting and then using .then

ancient nova
#

@lyric mountain join my server i will show you and then u tell that to Misty since she clearly does not underatand

lyric mountain
#

Modifying variables inside promises is never a safe thing

ancient nova
sharp geyser
#

😔

#

remind me never to offer you help

#

your code is just a mess

ancient nova
#

bro I'm doing NOTHING wrong

winged linden
#

Got a stupid question, in args we can do
const name = args.join("underscore")

How can i do that for a slash command option? To hoin the string spaces with "underscore"

sharp geyser
#

You are if you can't even get a proper user

#

I literally did the exact same thing of fetching a user and I can access all the fields a user has

#

Also

#

You can just set the result of fetching to the variable since you are awaiting it

#

why use .then

ancient nova
#

alright ok

#

I believe you

sharp geyser
#

Can slash command names even have special characters

lyric mountain
# ancient nova bro I'm doing NOTHING wrong

Look, you're referring to the way I rewrote ur code right? The only scenario where tag wouldn't exist is if both member.user and member are null, thus making the coalescing return null

sharp geyser
#

^

#

which I tried saying before

lyric mountain
#

If member is an user, it'll return null and fallback to the second option

lyric mountain
#

If member is indeed a member, I'll return an user and go with that

sudden geyser
#

of what you want to happen

winged linden
sudden geyser
#

So .replaceAll?

ancient nova
#

alright, sure

winged linden
ancient nova
sharp geyser
#

🤷‍♀️

#

idk what to tell ya

#

works perfectly fine for me

lyric mountain
#

(member.user ?? member) works for both scenarios, same as if u did ```js
if (member.user) {
member.user.tag
} else {
member.tag
}

sudden geyser
#

Yeah, so <input>.replaceAll(" ", "_") should work.

sharp geyser
#

guess you're just unlucky

ancient nova
#

but you see I'm doing nothing different than you are

lyric mountain
sharp geyser
#

You could be getting a partial user ig

lyric mountain
#

You'll see it

winged linden
#

If yeah thanks alot sir

sudden geyser
#

works on any string

ancient nova
lyric mountain
#

Partial doesn't contain username does it?

sharp geyser
#

Idk anymore

sudden geyser
#

please for our sanity use the ?? form

sharp geyser
#

djs is fucking weird

lyric mountain
winged linden
sharp geyser
#

This is my first time using djs in years

#

so

ancient nova
ancient nova
#

I'm on 12.8

#

13.8****

sharp geyser
#

v14

#

and don't say it is a difference in version

#

cause

#

it has been around nearly as long as djs has

ancient nova
#

then idk

lyric mountain
#

Show the code u tried when getting tag

ancient nova
lyric mountain
#

Whatever u tried that returned the error

ancient nova
#

why does it now show in the user property tho

sharp geyser
#

So basically

#

it is a getter

#

I don't think getters show up in the data

#

but it does existt

lyric mountain
#

If they do you're doing something really wrong

sharp geyser
#

and now I am wondering

#

if you ever even tried doing user.tag

ancient nova
sharp geyser
#

or you just kept saying it doesn't work cause yyou didn't see it in the data

ancient nova
sharp geyser
#

not really

#

getters and setters should never show up in the data iirc

ancient nova
#

but then if I save it later in a different variable it won't work

lyric mountain
#

Changing variables from inside a promise is never a good option

#

Oh also, is ur eval command awaiting the supplied code?

ancient nova
lyric mountain
#

That's the issue

ancient nova
#

how??

lyric mountain
#

Async runs on its own time, you can't expect it to return before your outer scope finishes

ancient nova
#

ah I see the error I made in my code

lyric mountain
#

If you need to extract a result, you need to await all the way to the top

ancient nova
#

it's cause I set the member property up and the updated it

#

that's why the tag property didn't exist

#

is there anything else hidden like that?

ancient nova
#

async function nonAnonFunc() {
//code
await something
}

await nonAnonFunc() is going to wait tho

lyric mountain
#

Yep, but is your eval command expecting an async function?

ancient nova
#

not really

#

I tried making it resolve async functions tho

lyric mountain
#

Then it doesn't know it has to await for a promise result

#

You can't really "resolve" a promise

ancient nova
lyric mountain
#

Imagine it as throwing a ball to the sky

#

You don't know when it'll fall unless you wait for it

#

No matter what u do, the ball WILL fall, but the exact time is unknown

#

So like, if you try to kick that ball, you'll fail because the ball hasn't fallen and grabbed yet

#

Thus undefined

#

But if u wait the ball and grab it, now u can kick

ancient nova
#

I'm actually kinda weirded out by this rn, but then how did a .then break the entire thing and not give me the .tag property?

#

if I await it, and after it's done I do .then?

lyric mountain
#

I don't know the exact reason, but weird things happen unless you have thread-safe variables (or atomics)

#

Js doesn't have them afaik

#

(nor threads)

#

So the safest is to just await the value and manipulate it afterwards

#

Like I did

ancient nova
#

okay thanks for the explanation then 0_0

lyric mountain
#

Async goes a long way, and is reeeeally hard to debug if you don't know what ur getting into

ancient nova
#

I'll rewrite the ban command to tomorrow since it does work, just less efficiently ig

lyric mountain
#

Ironically, it's easier to handle async stuff in statically typed langs since they'll not allow u to compile

ancient nova
#

like what lanuage for example?

#

for some reason the first thing that popped up in my mind was lua

lyric mountain
#

I can only speak for java

#

But pretty much any other static lang

#

Lua isn't static

ancient nova
ancient nova
lyric mountain
#
ExecutorService exec = // Initialize executor pool
int value = 0;

exec.submit(() -> {
	value = 1; // Compilation error
}).get();

Logger.info(value);
#

U gotta do ```java
ExecutorService exec = // Initialize executor pool
var value = new AtomicInteger(0);

exec.submit(() -> {
value.set(1);
}).get();

Logger.info(value.get()); // Logs 1

ancient nova
#

Javascript really messed it up when the code 1. seems valid and runnable

#

😩

sharp geyser
#

Imagine using java

#

and not kotlin

ancient nova
#

I can kinda agree kotlin is more useful for mobile apps sometimes

lyric mountain
#

I swear many issues would be prevented if people paid attention to java/C classes

ancient nova
#

sometimes

lyric mountain
#

Even tho college uses rock age java

#

Kotlin, java, groovy, scala, etc all compile down to bytecode, so it doesn't matter much which u use for mobile

sharp geyser
#

Unless you care about syntax

lyric mountain
#

JVM is quite eclectic

ancient nova
#

depending on the use case writing with a different lang can be easier

lyric mountain
#

I love groovy for that reason

ancient nova
#

did u guys know u can actually write a mobile app with lua

lyric mountain
#

Makes writing card effects way easier

sharp geyser
#

You can write a mobile app in a lot of langauges

#

it isn't a new concept

ancient nova
sharp geyser
#

you can write mobile apps with js

lyric mountain
#

Groovy works anywhere java works

#

It's like JS and TS

ancient nova
#

oh that's quite cool

sharp geyser
#

Groovy is a superset then

ancient nova
#

are they cross compatible

sharp geyser
#

Java is valid groovy

ancient nova
#

java and groovy?

sharp geyser
#

but groovy isn't valid java

lyric mountain
#

But u get stuff like 5.times { println it }

ancient nova
lyric mountain
#

Which will print from 0 to 4

ancient nova
#

0 to 4?

sharp geyser
#

0 based index

lyric mountain
#

Exclusive

sharp geyser
#

probably

lyric mountain
#

Yep

ancient nova
#

oh yea

lyric mountain
#

If it printed 5 it'd be 6 times

ancient nova
#

me when + 1

sharp geyser
#

1++

ancient nova
ancient nova
lyric mountain
#
0
1
2
3
4
5
#

6 lines

sharp geyser
#

if you tell it to print 6 times

ancient nova
sharp geyser
#

it will start at 0

#

and go up

#

and starting from 0 will always end up being a less number than what you start with

ancient nova
#

that's why I had to recalculate my pagination at least 6 times before it worked properly

lyric mountain
#

If u want inclusive u can do (0..5).each { println it }

ancient nova
#

I kept adding and subtracting 1 in random places until it worked

ancient nova
lyric mountain
#

0 to 5

ancient nova
#

1..5 then?wtfyoulookinatmeClose

lyric mountain
#

If u want to start at 1, yes

ancient nova
#

okay good

lyric mountain
#

There're online groovy compilers, you could see how it feels

#

It's a non-typed java basically

sharp geyser
ancient nova
#

me when print 5 = 6

lyric mountain
#

it is the default iterator btw, if u don't declare one

#

Also u can override operators which is noice

sharp geyser
#

I don't use java

ancient nova
#

I think I like groovy

sharp geyser
#

I prefer C#

#

Matter of fact

#

Why don't I make my bot in C#

#

tf am I doing it in ts for

lyric mountain
#

Does C# have a superset btw?

sharp geyser
#

F#

#

maybe?

#

idk

lyric mountain
#

F?

sharp geyser
#

F

#

F#

ancient nova
sharp geyser
#

what is the diff

#

other than a #

lyric mountain
#

What if someone makes A++?

#

Assembly but ++

sharp geyser
#

also

#

F# is a valid programming lang

#

another lang microsoft made iirc

lyric mountain
#

At this point Microsoft owns the # suffix

sharp geyser
#

pretty much

ancient nova
#

Malbolge

#

is a programming language

lyric mountain
#

A self-encrypting one, yes

sharp geyser
#

there is A#, C#, F#, J#, M#, Q#, and X#

#

MS owns like 2-3 of those iirc

ancient nova
lyric mountain
#

Xharp

sharp geyser
#

XSharp

#

is the actual name apparently

ancient nova
#

what's the diff between normal c and objective c?

pale vessel
#

It would've been better if it had Se at the front

lyric mountain
#

C is bare, you get what you see

#

Objective C is the nightmare of many old devs

sharp geyser
#

Objective C > C

pale vessel
#

Objectively speaking, that's true

ancient nova
sharp geyser
ancient nova
#

indeed

lyric mountain
#

I mean, it is indeed bigger

pale vessel
#

You know what else is bigger

#

I don't know

lyric mountain
#

Ur mom

pale vessel
#

Gahhhh

#

Should've retreated early

lyric mountain
ancient nova
#

👁👅👁

#

and with that, I have ended the conversation

#

gn guys

lyric mountain
#

Btw, another "only in groovy" moment:

use (TimeCategory) {
	println 3.hours.from.now
}
sharp geyser
#

So it prints 3 hours from now?

lyric mountain
#

It prints the timestamp yes

#

Using categories is like using macros tbh

round cove
#

any rsx enjoyers

sharp geyser
civic scroll
#

react but rust

sudden geyser
#

I'm amazed yet scared.

#

What shocks me the most are these two lines

#

As for the inline HTML, I have mixed feelings about it in general personally.

earnest phoenix
#

why am I here. Just to suffer.

sudden geyser
#

Have you tried deleting your account?

wheat mesa
#

The closest thing is F#, but that’s more of a sister functional language version of C#

radiant kraken
#

looks promising

ancient nova
#

yo setStatus doesn't seem to work for me

rustic nova
#

general question to y'all:

what do you prefer: accuracy or speed?

that was essentially a question I had thought for myself when making image generation associated with a Webserver and had to decide between caching or only fetching the data and if it's the same, resend the cached image

rustic nova
#

accuracy is probably the wrong word, but lets say the following:

I'm generating images that contains data that updates often (such as a spotify player with the time per-se). Would you prefer the accuracy of the timer or would you cache the image it sends if nothing much has changed

sharp geyser
#

So timer as in how far it is into a song?

rustic nova
#

essentially yes

radiant kraken
sharp geyser
#

If so Id value accuracy

rustic nova
#

And what about if your spotify playing service starts to get more used by people? When's the break-off point where you'd prefer speed? Since generating these images will always take a lil more resources and will start to become slow in loading

sharp geyser
#

I'd say value having the timer in real time

#

At a certain point don't even bother with the image

#

If it comes to be too resource intensive that is

#

You could also compress the images ig

#

It'd make em smaller and faster to serve

rustic nova
#

that is true

sharp geyser
#

What

urban quiver
#

I need help something

#

anyone free now?

sharp geyser
ancient nova
earnest phoenix
#
#

Hmm, which programming language do you understand the most then?

radiant kraken
#

and how vast and advanced their C++ codebase are

earnest phoenix
#

It would absolutely help if they understand C++, but unfortunately they don't seem to

radiant kraken
#

no, it still doesn't help if you understand C++ either

#

like i bet you don't understand what that C++ code does

earnest phoenix
#

It's not too complicated to understand the code, and you can already see where everything is located just by going back and worth

#

Here we go again with arguments like this, featuring null; episode 500

radiant kraken
#

Voltrex pretending he's smart; episode 500

civic scroll
earnest phoenix
radiant kraken
#

then tell me what the macros HTML_BEGIN_STATE, END_STATE, HTML_ADVANCE_TO and HTML_RECONSUME_IN do

civic scroll
#

this is long

#

i think i will need some recursion

#

hmmm

radiant kraken
#

@carmine topaz try to make an XML parser first before going for HTML

#

so you get the idea

#

of it

civic scroll
#
assume var input: string
var currentTags: string.None
var currentTree: string[]
match tokens...
for token of tokens {...}
#

so example i would parse it into something like```
{
"tag.child": "all content before the another child"
"tag.child.anotherchild": "content"
}

radiant kraken
#

yes

#

both are Markup Languages

earnest phoenix
# radiant kraken then tell me what the macros `HTML_BEGIN_STATE`, `END_STATE`, `HTML_ADVANCE_TO` ...

I don't think you understand how parsing anything really works, there are almost states like this in every advanced parser where they call between each other back and forth to not only check the characters they need to consume, omit, or advance to; and this is exactly what's happening here, if you look around the code just a little bit, and the source of the functions and macros that are being used, you'll understand it, in this case it checks for the current character (cc) and depending on what it equals to, in most of the statements it converts the current character to a buffer character which then tells the parser to either advance to another state or the same state, or reconsume a state to check the aforementioned state again

civic scroll
#

i have an idea

#

assume that i have this string

radiant kraken
#

since we're utilizing lots of goto calls

#

back and forth

civic scroll
#
<desc>
  For <number>2</number> seconds, increase the <stat>ATK</stat> by <percentage>180%</percentage> while also cause <fx><i>Stun</i></fx> to <number>3</number> enemies
</desc>
radiant kraken
#

parsing XML is easy through recursion

earnest phoenix
#

Even the Linux kernel recommends doing this

radiant kraken
#

they are both the same - considering they are both markup languages

#

it's basically the same

earnest phoenix
#

You don't need to look at the whole thing just to get an idea of how to implement whatever you're looking for, just some simple aspects of it

civic scroll
civic scroll
radiant kraken
earnest phoenix
#

It doesn't matter, not only are most of it optimized at the end but most parsers utilize huge switch statements all over, literally

civic scroll
#

so i just check the type

#

if it's a string, it's text

#

if it's an object, the key shall be the key

#

and the array shall be its children

#

no

#

this model contains tags and what contains in it

#

so like ```js
{
tag: [content_in_between_said_tag]
}

#

it's very inefficient

#

but atm it's what i could think of

#

you can store object wise to target something to

#

we use array to track deepness

#

so when we encounter a closing tag, we pop the tag of the array

#

that's why you see the following output in my code

radiant kraken
#

think of it like this

#

whenever you find a new element, call the current function again to handle that element - it's easier when you utilize recursion

civic scroll
#

but i think it looks similar to domtree

#

just dumber

radiant kraken
#

you can store it through an array of token objects, which acts as a token tree

urban quiver
#

someone help?

radiant kraken
#

pretty much

versed shoal
#

how can i do an animation counter with VueJS 3?

I tried using gsap but it gives error

radiant kraken
#

then check for tag names that does that, like meta

civic scroll
#

alright
so
assume we have this

<parent>a <child>b</child></parent>

parse

<parent>a <child>b</child></parent>
        ^
currentTag: ["parent"]
currentChild: "a", "text"
...
<parent>a <child>b</child></parent>
                 ^
currentTag: ["parent", "child"]
currentChild: "b", "text"
...
<parent>a <child>b</child></parent>
                          ^
currentTag: ["parent"]
currentChild: ""
radiant kraken
#

basically treat every element as the same, an element can have a child and a parent

civic scroll
#

we can pop the tag out when the closing tag matches the last element of currentTag array

civic scroll
civic scroll
#

for a list of tags

#

you can use RegExp

#

i would embrace it

#

my xml parser uses regexp

radiant kraken
civic scroll
civic scroll
#

i don't have alot of tags

#

so it's totally safe

radiant kraken
#

imagine this scenario: <troll inner="<trolled>yes</trolled>"></troll>

#

a regex can't tell a string from an element

civic scroll
#

but

#

the thing is

#

input is controlled

#

for that case it's totally safe

radiant kraken
#

that's fair

civic scroll
#

for accurate one it should have been character-based lexer

#

i'm just an artist

earnest phoenix
#

HTML tokens jumpscare

civic scroll
#

guys please

#

i'm here to consume the html

#

not understanding how it's parsed WAH

radiant kraken
#

that's good, just needs parsing on the element attributes

civic scroll
#

uhh gsap

#

what error tho

versed shoal
#

i use like this

civic scroll
#

in a web page

#

💀

#

where's your build tool

#

parcel, vite, webpack, snowpack, any?

versed shoal
#

oh

radiant kraken
#

just check if an element contains a key="value"

versed shoal
civic scroll
#

then you insert script tags

#

after that GSAP is a global object

versed shoal
#

i used that on html file

#

but it gives same error

civic scroll
versed shoal
#

what exactly do vite, webpack etc. do?

#

what can not i do without these?

#

@civic scroll

quartz kindle
#

they are programs that "build" the website files for you

civic scroll
quartz kindle
#

for example they take all the things you import and pack them in a single light weight js file

quartz kindle
versed shoal
#

so, for optimization

#

i get it thanks

quartz kindle
#

its more for productivity than optomization

#

it does a lot of stuff that you would need to do manually

civic scroll
#

the code you use in frameworks are server-side code

#

so when you specify relational paths in the browser it turns to client-side

#

unless you include those files in the assets directory, those files won't be available

#

so what those packers do is that they analyse your code, determines what it uses, then combine them all and minifies them in a single js file

#

so your web app would behave on the browser like the way it would on a nodejs environment

#

plus the thing is it only includes parts of the code that you actually use

#

for node_modules, you include everything

#

so packers essentially reduces the size of required files for you

#

makes the web page loads faster

quartz kindle
#

it also does things like cache control, for example when you update a js file, it appends a hash to the file name in all your html files to make sure the browsers fetch the updated file and dont use the old one

versed shoal
#

oh cool, thanks for the answers

quartz kindle
#

and has a billion plugins and extensions, for example to transpile typescript into browser js, minify css, etc...

eternal osprey
#
Error: Expected token to be set for this request, but none was present```dafuck?
#
    await rest.put(
            Routes.applicationGuildCommands(n.clientid, n.guildid),
            { body: commands },
        );```it's coming from here
boreal iron
#

You might wanna use djs inbuilt functions to deal with the registration

#

In your case <client>.application.commands.create(<commands array>);

#

In your case you might forgot to construct the REST class passing your bot token to it

winged temple
#

what happened to this?

earnest phoenix
#

is it possible to do something when a person has voted for a server? (discord.py)

#

like is there a way to track server votes?

tired panther
bright thorn
#

a folder is present in my directory and i mentioned right path but bot unable to get it!

boreal iron
#

guildCommands.find((cmd) => cmd.name === loadedCommand.name || loadedCommand.localeName.includes(cmd.name));

While editing my command initialization code I'm now going to support name localizations, too
As we were talking about yesterday and you asked, how would you even check for a localized name, I responded with code snippet above
Actually that's redundant...
You will always retrieve the registered command name by the API
The command name is not the localized executed one but the registered one
The command interaction you're recieving in your event also includes the name_localized property, which indicates a localized command name have been executed
https://discord.com/developers/docs/interactions/application-commands#localization
https://discord.com/developers/docs/interactions/application-commands#retrieving-localized-commands
... so finding the command name for the localized name, as mentioned above, actually doesn't seem to be required atl all

#

The command interaction you're recieving in your event

#

of course same goes for fetching the (guild) commands

earnest phoenix
#

Github stopped updating the codes I was editing, does anyone know how to fix this?

#

like, the page is giving an error and doesn't update when I start

#

happened after i switched to private repository

#

and I went back to the public and it continues like this

earnest phoenix
earnest phoenix
boreal iron
#

https://discord.com/developers/docs/interactions/application-commands#application-command-object
So... default_member_permissions accepts a serialized permission bitflag
That means it's not possible to specify if a member has a permission A or B?
How am I supposed to know then which permissions include each other?
Let's say I wanna define if the member either has Administrator, ManageGuild or ManageChannels permissions...
Would I just need to create a bitfield for default_member_permissions representing the ManageChannels permission value?

lyric mountain
#

what

#

like, if u have the bitflags u can just extract which ones are true or false if u know their indexes

pale vessel
#

Also you don't need administrator

#

Just 1 << 4 | 1 << 5 will do

#

Discord already accounts for administrator

boreal iron
#

The client expects the member to have both permissions

#

Not just one

#

Or the command wont be shown

boreal iron
#

Once the default_member_permissions field is defined, the Discord client will only show up the slash commands if the member has this permission(s)

lyric mountain
#

yes?

boreal iron
#

what the heck you don't understand?

#

it doesn't seem to be possible to specify multiple permissions where the guild member only requires at least one of it

#

am I that confusing? freerealestate

boreal iron
#

Ok explain that:

radiant kraken
#

no :)

boreal iron
#

console.log(command.defaultMemberPermissions, command.defaultMemberPermissions?.toArray());

#

TypeError: command.defaultMemberPermissions?.toArray is not a function

#

How tf is that possible

#

I mean how can the optional chaining FAIL?

#

command.defaultMemberPermissions logs a djs permissionbitfield

radiant kraken
#

so you're calling undefined

boreal iron
#

wait... it comes undefined not null?

sharp geyser
radiant kraken
boreal iron
#

why tf is it calling toArray then?

#

defaultMemberPermissions: command.defaultMemberPermissions?.toArray() ?? null

#

if mean it's called optional chaining

#

so if the defaultMemberPermissions property is null or undefined the last property or method in this case shouldn't be called at all

stuck dawn
#

how can i ignore the "e"? i am using input number

lyric mountain
#

where is that?

sour oar
#
onst { COLORS, PREFIX, ROLES } = require('../../settings/config');

module.exports = {
    name: "i", 
    cooldown: 2,
    
    run: async (client, message, args) => {

        const roles = message.guild.members.cache.get(message.author.id)._roles;

        if(roles.some((role) => ROLES.includes(role))) {
 
            message.channel.send(`Hello`)

        } else {
            message.channel.send("Premium")
        }
        
    }
}

how can I make the premium role take over from the support server and give the premium permission to other servers as well

boreal iron
#

and give the premium permission to other servers as well

Well you would be required to create your "premium role" in every other server, then check if the member is part of that group

#

which is an horrible idea tbh

sour oar
#

ok

#

and which system would be better

boreal iron
#

Or you gonna save the user ID in your database along with the premium status and check once a "premium command" is being executed if the user has the premium status by querying your database

#

this one

sour oar
#

ok

eternal osprey
#

hey guys, how do i actually return in a for loop?

#
for(const key in shopdata){
if(key === 'test'){
return
}
// this return should completely stop the for loop instead of exiting the first key
}```
stuck dawn
#

like that?

eternal osprey
boreal iron
#

gonna share that later

stuck dawn
eternal osprey
boreal iron
#

Weird... use the break keyword then

stuck dawn
#

idk but you can always create an aux variable and then set the value you want and use break

eternal osprey
#

Strange asf

#
const winnerembed = new MessageEmbed()
.setColor("RANDOM")
.setFooter({text: `Treasure Cove | Admin Configuration`})
.setTitle(`⚠️ | Shop System changes detected`)
.addFields(
  { name: 'Type:', value: 'Added an item' },
  { name: 'item:', value: interaction.options.getString('item')},
  { name: 'Price:', value: interaction.options.getNumber('price') },
  { name: 'Admin:', value: interaction.member },
  { name: 'Used in:', value: interaction.channel },
)```Uncaught DiscordjsError RangeError [EMBED_FIELD_VALUE]: MessageEmbed field values must be non-empty strings.
#

wha

boreal iron
#

interaction.options.getNumber('price')

#

is not a string

#

the value must have the type STRING

eternal osprey
#

Owh shit how would i fix that

boreal iron
#

Either use template strings or toString()

eternal osprey
#

I see

#

i still get the same error

boreal iron
#

well take a look at your last two fields

#

interaction.member and .channel will both return an object

eternal osprey
#

Won't it just ping the member and channel?

boreal iron
#

wut

eternal osprey
#

like @eternal osprey

boreal iron
#

no

eternal osprey
#

huh i always did that

boreal iron
#

It's just a field value

#

If so you need to turn the member object into a mention

#

You can use the util (now importable from the global scope) userMention(<user ID>)

#

const { userMention } = require("discord.js");

#

or simply write the field value yourself

#

Like so:

#
value: `<@${interaction.member.id}>`
earnest phoenix
#

Or just call the .toString() method on the guild member, which returns the mention

boreal iron
#

oh does it?

earnest phoenix
#

Yeah

boreal iron
#

Ah never saw that method returning a mention

#

good to know

eternal osprey
#

I see!

#

Thank you guys, i got it working!

boreal iron
#

Ahh... same applies for the channel, I see

earnest phoenix
#

For roles as well

eternal osprey
#

Another question, js for(const key in shopdata){ row.addComponents( new MessageButton() .setCustomId(key) .setLabel(`${key}`) .setStyle('PRIMARY'), ); }Would there be any way to actually add multiple buttons using a for loop

#

rn it tells me that it exceeds the maximum width

boreal iron
earnest phoenix
#

I thought you already knew

eternal osprey
#

Ah it;s cuz it tries creating 6 buttons

#

got m

boreal iron
#

yee 5 is the maximum per row

earnest phoenix
#

Just create a new row every time the maximum amount of buttons is reached, AKA 5

eternal osprey
#

owh that's fucked. How would i code in that if one row is full, it should write it into the next row called wo1.

sharp geyser
eternal osprey
eternal osprey
#

Break stops the whole loop while return only returns the current cycle.

sharp geyser
#

Yea

#

Do you know about the continue keyword in a loop?

eternal osprey
#

Yeah i do

sharp geyser
#

Nice nice

#

You hardly ever use it tbh

#

But it's still useful

boreal iron
#

Do you know PHP supports scopes for continue and break? like continue 2, continues the outher loop

#

should be a thing in JS

sharp geyser
#

Okay php man

boreal iron
#

imagine you can stop the outher loop by doing break 2;

#

shitty javascript

sharp geyser
#

Also isn't using a loop here not a good idea?

#

Can't you just map it into an action row

#

Or wait no

#

Nvm

#

Ignore me

eternal osprey
#

I need to create buttons based on the amount of items in a certain array

sharp geyser
#

I was thinking you could just map it and make an array of buttons

#

But

#

That won't work unless you were not using a builder

boreal iron
#

you literally use a simple loop and an index value, ones 5 buttons are created, you increase the index value by 1

#

which is the array index of your next row

eternal osprey
#

Right now it does work, but after it hits the max it ofc errors. So i need to know a way on how to write the next keys into a new row if it's full

sharp geyser
#

Unrelated but interested

boreal iron
#

errr wut?

#

in real life or coding?

sharp geyser
#

You have a job no?

boreal iron
#

lmao

sharp geyser
#

You always talk about it

eternal osprey
sharp geyser
#

I'm talking about your actual job

boreal iron
#

that depends very much how much I need to do, how many times I assist others since people/employees are currently missing anywhere, and how much money I wanna earn that month

sharp geyser
#

Ah I see

boreal iron
#

mo, thu, wed are each 13h this week

sharp geyser
#

What's min wage where you live?

boreal iron
#

I'm running my own business so... I'm the one making the price

sharp geyser
#

I see

#

What does your business specialize in?

boreal iron
#

I never complained about money tbh, but I'm far away from being considered as rich and I also have very bad times and of course good times as well

#

but I can actually live a nice live, at least that's what I consider to be nice of course

#

opinions are very differently about that

sharp geyser
#

That's good

boreal iron
#

Well my main branch is logistics and transportation as well as doing accounting for others and me

#

has a wide range from planning, organizing, booking, executing and driving myself if nobody else is available

wheat mesa
boreal iron
#

shhh move on with your Java stuff

feral aspen
#

Question, overall difference between MongoDB and MySQL?

I mean, I know for a fact that Mongo is all based on JSON objects and how you're only storing information to access later, however, what makes MySQL special (other than it being mostly used in websites, and etc.).

wheat mesa
#

Biggest difference is that mongo is a nosql db and MySQL has SQL in the name

feral aspen
boreal iron
#

it depends as I said

wheat mesa
#

Well, most SQL databases are table-based (I don’t know how to describe it) compared to mongo which is document based

feral aspen
#

Other than that, is it that SQL databases are based on tables and such?

boreal iron
#

the more you know and can the better your chances are to have a well payed job

feral aspen
wheat mesa
#

It’s more based on what you’re comfortable with. I believe that mongo is quite a bit slower than most SQL databases

tulip ledge
#

Most sql databases are faster than nosql tho

sharp geyser
#

MySQL is still a shit sql db tho

lyric mountain
#

I mean, it's Structured Query Language after all

quartz kindle
#

but its a language, it can be adapted/transpiled to work on anything

#

pretty sure there are a few multilanguage dbs that work with sql

#

without necessarily storing data in tables

ancient nova
#

would a command to show information about a certain token be against ToS?

sharp geyser
#

Wdym

#

What kind of token?

ancient nova
#

any, user, bot

sharp geyser
#

I would refrain from doing so

ancient nova
#

and by info I mean like the date it was created, who it belongs to

ancient nova
sharp geyser
#

You don't want people just posting their tokens in chat to your bot

ancient nova
#

oh yeaweirdsip

#

I'm out of command ideas tho

sharp geyser
#

same with a bot

#

That kind of information is also private

#

so

ancient nova
#

I mean if u can get it from the api aPES2_ShrugFuckYou

#

wrong emoji

sharp geyser
#

Yes but to get that information you'd have to use their token to do so

#

and that is a no no

ancient nova
#

I see

#

alr

sharp geyser
#

If you wanna display information on something just do it the normal way

#

Only limitation would be whether the bot shares a guild with that user/bot

ancient nova
#

ik

#

do u have any command ideas?like literally anything

sharp geyser
#

No

#

I personally never make multi purpose bots

#

so no

ancient nova
#

misty I actually took ur advice and gave my bot a specific purpose

sharp geyser
#

What purpose is that?

ancient nova
#

mod / automod or anti raid bot

sharp geyser
#

Then do things focused around that

#

One thing you can do is look at your current commands and think of how you can make it better

wheat mesa
#

wtf do u mean showing user tokens

#

how do you even get that

sharp geyser
#

They were talking about users giving tokens and the bot using them to get information on them

wheat mesa
#

giving... what tokens?

sharp geyser
#

user and bot tokens dingus

wheat mesa
#

that is the worst idea I have ever heard

sharp geyser
#

It is also against tos

#

so

ancient nova
#

I got

#

no more ideas

sharp geyser
#

It doesn't matter what you added

#

it matters how you can improve on what you added

#

You can always improve on it

wheat mesa
#

That's just dumb

sharp geyser
#

That is the point I already made waffle

wheat mesa
#

You know damn well he gonna be storing them in plaintext too, there's no reason to ever give your token away to anyone else

sharp geyser
#

you are late to the conversation

wheat mesa
#

I know I'm just baffled

sharp geyser
#

On another note

#

ima make a bot in C# cause I am bored and now have little time to do anything else

wheat mesa
#

That's a good idea

#

C# is a good language for bot development

sharp geyser
#

It indeed is

#

I was going to make Gwent

#

but I don't know any graphic libraries

#

so

#

no idea how to make the cards

#

and all the ones I found were from ages ago and have poor documentation

ancient nova
sharp geyser
#

Okay here's an idea that might be viable or not as I have never tried it

#

You can make a ban command that can list a paginated select menu of all the people in the current guild and when you select a user(s) a modal will pop up asking for a reason and bam it bans those members

#

Again probably not viable

#

but

#

It is a spitballed idea

wheat mesa
#

That's the most popular one for that use case

sharp geyser
#

Might work

ancient nova
ancient nova
#

that definitely won't work

sharp geyser
#

IT could

ancient nova
#

how

wheat mesa
#

You can easily do 25k

ancient nova
sharp geyser
#

You can also allow them to jump pages

#

or list users themselves

wheat mesa
#

Cake has an emoji listing command and it still works with like 10 thousand pages

sharp geyser
#

If you don't wanna do it

ancient nova
sharp geyser
#

I 100% will

ancient nova
#

okay lmao

#

let me know how it looks once done

sharp geyser
#

It is a good idea though

wheat mesa
sharp geyser
#

That could easily work

ancient nova
#

I just got the BEST

#

IDEA

#

EVER

sharp geyser
#

You can have a embed showing the users, and a select menu allowing you to select the users on the page

ancient nova
#

basically use some emoji listing site's API to fetch emojis by name like that command above, BUT you can select a specific emoji and the bot will automatically add it

#

how does that sound 0_0

#

actually nvm I got no way of embedding the images

sharp geyser
#

Sounds usless for a mod bot

ancient nova
#

since u can't do more than 1 image

sharp geyser
#

Untrue

wheat mesa
#

Just have pages of them..?

sharp geyser
#

^

ancient nova
wheat mesa
#

It's a good idea

ancient nova
#

1 emoji per page tho? pepeStraightFace

sharp geyser
#

Glad spotify emailed me about my premium renewing soon

#

im a broke bitch

ancient nova
#

want my spotify

sharp geyser
#

No

ancient nova
sharp geyser
#
using var image = Image.Load("original.jpg");
image.Mutate(x => x.Resize(image.Width / 2, image.Height / 2));
image.Save("result.jpg");

@wheat mesa wtf is this syntax

#

using var image = Image.Load("original.jpg");

#

why is using here

wheat mesa
#

It automatically calls .Dispose() when you're finished using it

sharp geyser
#

Ah

wheat mesa
#

It's syntactic sugar so you don't cause memory leaks

sharp geyser
#

Makes sense then

#

I also gotta not embed my token in the file directly if I am making this bot open source

#

I just have not gotten to the point of grabbing from json files in C# yet

wheat mesa
#

Or just use env like a normal person

#

json is INCREDIBLY easy to use in C#

#

It's practically built for it

sharp geyser
#

I always had env problems though

#

My environment variables never load

wheat mesa
#

json is just fine just don't push it to your github

#

Super super super easy to use

sharp geyser
#

Yes but how 😢

wheat mesa
#
class ModelClass 
{
  [JsonProperty("key_name")]
  public string Value { get; set; }

  [JsonProperty("another_key")]
  public int AnotherValue { get; set; }
}

var myModelClassInstance = Json.Deserialize<ModelClass>(jsonDataHere);
#

easy as that

sharp geyser
#

I see

#

The stuff online was telling me all sorts of things

#

Okay dumb question, but I forgot how to inherit a class that takes in something

#
using DSharpPlus;

namespace Gwent.Structures;

public class GwentClient : BaseDiscordClient()
{
    public GwentClient(DiscordConfiguration config) : base(config) {}
}

iirc was this not how you do it?

wheat mesa
#

I think that's how you do it

#

Why are you using some obscure C# lib

sharp geyser
#

Wdym

#

I am using D#+

wheat mesa
#

Oh

sharp geyser
wheat mesa
#

Okay

sharp geyser
#

I am wanting to attaching a config option to the client

#

so I don't have to get deserailizing my config if I need it

#

Then again I just won't bother tbh

sharp geyser
#

Cause it wouldn't load the token variable in time or at all

wheat mesa
#

What?

sharp geyser
#

Using an env file the variable I specify in there isn't being loaded in time or at all

#

so my project can't usei t

wheat mesa
#

then you're doing something wrong

#

ask the c# discord server

boreal iron
sharp geyser
#

Nice

#

I'll check it out after work

boreal iron
#

Now supports anything the API also supports...
The structure (djs like)

{
    name: "name",
    nameLocalizations:
    {
        "fr": "fr-nameLocalization"
    }
    description: "description",
    descriptionLocalizations:
    {
        "fr": "fr-descriptionLocalization"
    },
    options:
    [
        ...
    ],
    defaultMemberPermissions: ["Administrator"],
    dmPermission: false,
    guilds: ["264445053596991498"],
    disabled: true,
    async execute(...)
    {
        ...
    }
}
#

disabled: true removes global/guild commands

#

deleting the entire command module would only remove the global command, as due rate limits you can't fetch all commands of any guild to check if the local one still exists or not

#

no matter the depth of the options or choices it will be flattened and gets formatted

#

The push_guild parameters of initCommands() is available to call the function inside your GUILD_CREATE event to push possible guild commands to the guild without fetching/reloading the global commands (again)

#

I wanna say that's actually a pretty nice command handler

warm swan
#

I have a pretty bad issue in my database that i can't find out how to fix-

whitelisted = fields.ManyToManyField("Bot.UserModel", on_delete=fields.SET_NULL, null=True, related_name="whitelisted")
vanity_whitelisted = fields.ManyToManyField("Bot.UserModel", on_delete=fields.SET_NULL, null=True, related_name="vanity_whitelisted")

The issue is coming from those 2 lines that are associated in the UserModel

class UserModel(DiscordDBModel):
    """Base User model, meant to be reference by extensions"""

    def discord_get(self, bot: discord.Bot) -> discord.User:
        """Returns the associated ID for the given user."""

        return bot.get_user(self.id)

They are inside the same file, the issue is that using ManyToManyField i will have to reference inside the UserModel where to put the user IDs and that's what i don't know how to do, i looked up for some examples but i can't find a good logic for it.

This is the traceback that i get from the code when i try to init my database - https://hastebin.com/yerafaciri.rust

proven escarp
#

||i don't even wanna read that whole thing||

lyric mountain
#

I don't even know what exactly I'm looking at

#

IF I understood right, you DEFINITELY doesn't want to have a M <-> M field, make instead a middleman table

#

but other than that, I can't see what exactly ur trying to achieve