#development

1 messages · Page 45 of 1

rich flume
#

no as i said it is working in whatever guild i tried it in, so i dont think the code is to blame

boreal iron
#

well that might be true tho but ephermal messages just not showing up is something I've never heard of or read anywhere before

rich flume
#

my handler gets the component in which the button is and then it response to it

boreal iron
#

makes me curious

rich flume
#

it drives me crazy lol

boreal iron
#

is the response instantly?

lyric mountain
#

how are u verifying that the eph doesn't show?

rich flume
#

even more because i cant replicate it so no debugging possible 😦

boreal iron
#

you got only 3s to respond for non-deferred interactions

rich flume
#

i know thats why i respond immediately with the please wait message

#

but the 3s timeout always return error

lyric mountain
#

u should defer instead of "please wait"

boreal iron
#

yes it would return "unknown interaction webhook" or something similar

rich flume
#

its my first bot dont even know what defer means lol

#

will look it up

lyric mountain
#

defer is saying "ok I got it, but it'll take some time" to discord

boreal iron
#

That means you respond instantly to the API telling the API your response will take longer than 3s

rich flume
#

oh nice

lyric mountain
#

any command that's not instantly replied must be deferred

boreal iron
#

You will then have another 15m to respond, until the webhook expires

rich flume
#

nice at least something i learned 🙂

boreal iron
#

No message will be shown up in that moment but instead the discord client shows something like "The bot is thinking..."

rich flume
#

nice will rework it in my bot

boreal iron
#

Until your deferred (2nd) response is ready to be send to the api

#

that still doesn't explain why the inital ephermal response wouldn't show up tho

#

still makes me curious

rich flume
#

still makes me hit my head against the table lol

lyric mountain
#

show the relevant part of the code

boreal iron
#

Did the bot reviewer incl. a link to a screenshot or similar in his description?

#

If no response would be recieved the discord client will show "Interaction failed"

rich flume
lyric mountain
#

the decline reason doesn't mention not receiving ephemerals tho

boreal iron
#

So... just a non-existing message going into the void can't really happen without an error on the client or api side

boreal iron
rich flume
lyric mountain
#

are you 100% sure?

boreal iron
#

oh well that's a different thing then

rich flume
#

because the reply itself does not return error

lyric mountain
#

what if the reviewer disposed of the message?

rich flume
#

hmm

lyric mountain
#

u can't trust any ephemeral be valid at any time

boreal iron
#

are you sure you're catching the errors correctly and awating the promises you get (if that's a thing in .net)?

lyric mountain
#

if .net is like java, it doesn't use the concept of promises

boreal iron
#

move on java boy

lyric mountain
#

but it does have exception handlers for async stuff

boreal iron
rich flume
#

it should crash when sending the reply but it didnt

lyric mountain
#

they "can"

boreal iron
#

of course

lyric mountain
#

but u cant trust they'll be available

rich flume
#

but he could dispose of the message that would do it i guess

lyric mountain
#

since switching channels will delete it

rich flume
#

as you said

boreal iron
lyric mountain
#

no?

boreal iron
#

closing the client will clear them

#

that's the same across all clients

lyric mountain
#

hm, nvm then

#

but well, simply change ur "please wait" message to be a defer instead

boreal iron
#

but he can't delete ephermal messages of course

rich flume
#

but i dont see that he would every time he tried it always dispose the message

lyric mountain
#

and let discord handle that

lyric mountain
rich flume
#

yes will do that

boreal iron
#

well just to remind you, the concept you're using replying with a "please wait" is wrong anyways

rich flume
#

yes i didnt know about the defering stuff 🙂

boreal iron
#

Without replying with a deferred status the webhook will expire

rich flume
#

so will defer it and resubmit and we will see

lyric mountain
#

make sure to catch all async tasks

boreal iron
#

So the order to respect is:

Interaction event ->
Instant response (within 3s)  **OR**
DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE (ACK an interaction and edit a response later, the user sees a loading state) ->
respond later
lyric mountain
#

worthy to note, there are 2 kinds of defferal

#

one for reply and one for edit

boreal iron
#

yes but button interactions it would be DEFERRED_UPDATE_MESSAGE

#

as reference

rich flume
boreal iron
#

What you can do however is (when deferring a response):

Interaction event ->
Defer the response ->
Edit the response showing ("Please wait") ->
Edit the response (again) returning your result```
lyric mountain
boreal iron
#

But the "please await" message is obsolote since the loading state exists

boreal iron
#

Literally for any sort of async action

#

You have to perform before sending the reponse

lyric mountain
#

I'd say more like 2s, to allow space for net latency

#

and eventual discord slowness

boreal iron
#

well even a defer response state can fail

#

that's why error handling should always be present

#

but I have to say I haven't seen that sort of error for a long time now

rich flume
#

Ok thx to both of you, will change the bot and test it a bit after to make sure its working properly 🙂

boreal iron
#

alr

lyric mountain
#

test as if you were the most idiot user to exist

boreal iron
lyric mountain
#

that's a rule for debugging

boreal iron
#

that's not so easy to perform tbh

rich flume
#

yep

#

🙂

lyric mountain
#

ik, that's why I have a testing team mmLol

rich flume
#

😄

boreal iron
#

after years of developing community panels I always found somebody who causes an error and I never understood how a "normal" human would have managed to do so

dry imp
#

you should question their sanity

lyric mountain
#

as the wise guard of yellowstone once said "There's a considerable overlap between the dumbest visitors and the smartest bears"

boreal iron
#

which isn't an assumption

frigid thicket
#

I don't know if this is the correct place for this and please let me know where I should put it if not. I'd like to be able to create a role and add everyone from another discord server to it on my server. Or, better yet, create a role on my server and have them auto added to the role as soon as they connect to my server. Like from a list that I create.

spark flint
#

it has both mass roling (add role to everyone) and give set role(s) on join

#

oh wait

#

are you developing a bot

frigid thicket
spark flint
#

👍

eternal osprey
#

hey guys

#

i have a problem understanding the shift operator

#

5 << 3 for example.

#

So 5 is of course made by 2^0 and 2^2 right?

#

so we will have this:

#

2^0, 2^1, 2^2, 2^3, 2^4, 2^5, 2^6 with the marked spots being the current bits

#

what the fuck should i shift to where lmao

#

i mean, shifting a 8, or a 2 is ez but 5 is made out of 2 bit placeholders

lyric mountain
#

hm...what

#

shift works like this

before: 0000 0101 = 5
after: 0010 1000 = 5 << 3 = 40

#

when you << 3 you move the bits 3 places to the left

#

no need to do...whatever math u did

#

simply use binary notation when using bitwise ops, you're not really meant to look at it in decimal

#

5 can be written as const val = 0b101 in most langs

lyric mountain
#

binary is always RTL, so << increases and >> decreases

#

a way to check active flags is like:

var arrayOfValues = {...};
for (int i = 0; flags != 0; i++, flags >>= 1) {
  if ((flags & 1) == 1) {
    // arrayOfValues[i] is enabled
  }
}
eternal osprey
#

i know i got it done already!

#

So apparently if you have a number like 3

#

it's consisted of 2^1 and 2^0, so you need to make each bit basically move individually and then sum up the total new value

lyric mountain
#

stop thinking as 2^N

#

think as an array

#

also u don't need to sum anything

#

simply do bitwise OR

#

0b1 | 0b100 = 0b101 = 5

eternal osprey
#

my university tells me to

lyric mountain
#

tell u to what?

#

like, does the problem ask u to do in 2^N notation?

ember quarry
#

hey guys,
I am using discord.js and I added bot to the server but it is not showing in server settings>integrations. Any idea what I did wrong?

lyric mountain
#

did u add application scope to the invite?

ember quarry
#

scope=bot%20applications.commands

#

this is the scope

lyric mountain
#

does ur bot have any slashes?

ember quarry
#

yes

lyric mountain
#

if u type / does it appear in the menu?

ember quarry
#

no, it do not appear

lyric mountain
#

hm, are ur commands registered as global commands?

#

it might take a while to update

topaz bloom
#

Anyone know any good website commission servers?

lyric mountain
#

do u mean hiring?

topaz bloom
#

Yes

ember quarry
lyric mountain
ember quarry
#
const rest = new REST({ version: '10' }).setToken(process.env.BOT_TOKEN);
rest.put(Routes.applicationGuildCommands(process.env.CLIENT_ID,GUILDS), { body: getCommands() })
    .then(() => console.log('Successfully registered application commands.'))
    .catch(console.error);

here is I am registering me commands

lyric mountain
topaz bloom
lyric mountain
#

I dont know any

ember quarry
lyric mountain
#

guild slashes are per-server and wont be added automatically

#

for that u need global slashes

ember quarry
lyric mountain
#

...guild commands are guild-specific

ember quarry
#

yes

lyric mountain
#

they're local, not global

ember quarry
#

correct!

lyric mountain
#

they wont be added automatically on-join

#

to have commands added when joining u must register global commands

#

OR register the guild commands on-join

ember quarry
#

I am registering the commands before call of "ready" function

#

const GUILDS = '844603478436479047' //'787957265462067221'
const rest = new REST({ version: '10' }).setToken(process.env.BOT_TOKEN);
rest.put(Routes.applicationGuildCommands(process.env.CLIENT_ID,GUILDS), { body: getCommands() })
    .then(() => console.log('Successfully registered application commands.'))
    .catch(console.error);

client.on("ready", async(): Promise<void> => {    

    const commands = await client.application.commands.fetch();
    //Returns a collection of application commands
    console.log(commands);
    console.log(client.guilds)
    console.log("Bot Online")
})

like this

lyric mountain
#

it wont work

#

as I said, guild commands DO NOT apply to all guilds

#

they only apply to a single, specific guild

ember quarry
#

I want it to work for my only

lyric mountain
#

then register for your, specific server

ember quarry
#

I am registering to "844603478436479047" this my server

lyric mountain
ember quarry
#

the problem is when I am fetching guild commands, it shows that commands are registered and list all my commands , it is showing no errors but the when I try use it, it is not working

#

this is what I am getting, that means command is registering

lyric mountain
#

that doesn't guarantee anything

#

it just means it didn't error in the previous step

#

what does getCommands() return?

ember quarry
#

it is working fine, I check all those

lyric mountain
#

try printing what it's returning

ember quarry
#

Is it possible that the bot is in the server and it is not listed in bots & apps in server settings > interactions?

ember quarry
# lyric mountain try printing what it's returning
[
  {
    options: [ [Object], [Object] ],
    name: 'addfeed',
    name_localizations: undefined,
    description: 'Add new feed webhook',
    description_localizations: undefined,
    default_permission: undefined,
    default_member_permissions: undefined,
    dm_permission: undefined
  },
  {
    options: [ [Object], [Object], [Object] ],
    name: 'delfeed',
    name_localizations: undefined,
    description: 'Add new feed webhook',
    description_localizations: undefined,
    default_permission: undefined,
    default_member_permissions: undefined,
    dm_permission: undefined
  }
]
#

I also tried adding bot and removing 2-3 time from the server

lyric mountain
#

ah, wait, just noticed

#

that wont work

#

you're registering outside of the ready event

#

it might be running before your bot is ready, or even started at all

quartz kindle
#

registration is a one time thing tho, it should work on the next try then

ember quarry
lyric mountain
quartz kindle
#

yeah

lyric mountain
#

also the fact that this didn't execute makes me think the bot isn't finishing to start at all

ember quarry
lyric mountain
#

ah wait, it executed before that line

#

nvm then

#

anyway, tim's more fit to help u, I dont know much about d.js

ember quarry
#

here is the whole console

#
client.on("ready", async(): Promise<void> => {    

    const commands = await client.application.commands.fetch();
    //Returns a collection of application commands
    console.log(commands);
    console.log(client.guilds)
    console.log("Bot Online")


    const GUILDS = '844603478436479047' //'787957265462067221'
    const rest = new REST({ version: '10' }).setToken(process.env.BOT_TOKEN);
    rest.put(Routes.applicationGuildCommands(process.env.CLIENT_ID,GUILDS), { body: getCommands() })
    .then(() => console.log('Successfully registered application commands.'))
    .catch(console.error);

    console.log(getCommands())
})

Here is "ready" event after some changes

ember quarry
#

is that some discord issue or its on my end only

#

My bot is not even listed in bots and apps list.

round cove
#

Mori commented on the site I dev'd for her LETSFUCKINGGO

sudden geyser
#

is this a vtuber

round cove
#

yes

neon leaf
#

[JavaScript]

Lets say I have a function, when its being called with something like function() it will echo something in the console, can I somehow block the function from sending stuff in the console? (no I cant edit the function, its from a package)

rustic nova
#

theres loggers

ember quarry
#

you want to make a logger

rustic nova
#

veryLoggers loggers

neon leaf
#

what exactly does that mean in this case?

lyric mountain
#

basically use loggers that have different loglevels

#

but then

no I cant edit the function, its from a package
it wont do much

#

what are u trying to block?

neon leaf
#

unnessesary logs from a package, aka it spams like 40lines of junk every time I start up

lyric mountain
#

most loggers (or at least the good ones) allow u to filter what packages are allowed to log or not, but take my advise, logs are supposed to be very verbose so u can solve related errors later on

lyric mountain
#

I was only addressing what they mentioned

pale vessel
#

Yeah I didn't see the message they sent so I quoted yours instead lul

lyric mountain
#

if I wanted a clean console for manual input I'd just open a child console and listen to it instead

#

instead of muting the logs

knotty quartz
#

Anyone know good image enhancers?

lament rock
knotty quartz
lyric mountain
#

upscalling images, although w2x does a great job, still significantly decreate its details

#

so u end up with an "oil painting" aspect if your image was very detailed

#

also dont be afraid to crank the denoiser to the maximum, unless ur image is supposed to have noisy parts

drifting cairn
#

what would be a good way of dealing with payment requests when using PayPal, since the onApprove function is all front end I don't wanna handle it directly on the front end cuz that's stupid, could someone with more knowledge on this stuff than me tell me what may be a good way of dealing with the request?

lyric mountain
#

depending on what u doing, wouldn't it be better to use another payment service with a better api?

#

like kofi

drifting cairn
#

I'm integrating a 1 time payment for a lifetime subscription but im planning on adding monthly subscriptions to it too

knotty quartz
lyric mountain
#

it's a denoiser/upscaler, not a depixelizer

knotty quartz
lyric mountain
#

"pixaleted" is not necessarily worse, it's just an image with low resolution

#

what image are u trying?

knotty quartz
#

Its bad when uploaded as an emote

boreal iron
lyric mountain
#

that's actually a pretty high quality icon

#

note the emphasis on icon

#

quality != resolution

knotty quartz
lyric mountain
#

that said, that image is pretty simple, u could attempt to draw it yourself using vectors

knotty quartz
#

Tyyyy

drifting cairn
#

this is all i've done so far but then i thought what if someone were to make a post request to that end point them selves with the same body of information the api provides, since there's no like auth key to verify the payment is "legit" or anything I'm quite lost for ideas, would there be any way to perhaps verify that the local fetch request originated from the localhost if so how can i do it 😭

lyric mountain
#

using vectors is literally just moving lines around

knotty quartz
lyric mountain
#

simply upscale that image without interpolation and contour it

lyric mountain
#

except paint

knotty quartz
drifting cairn
drifting cairn
#

there is?

lyric mountain
#

The transaction ID

#

U can use it to fetch the transaction info from paypal

#

But...well...more api to deal with

drifting cairn
quartz kindle
#

ape and i = ape i = api = paypal api

drifting cairn
#

i think i've found a way to do it without having to interact with the api Sip

#

it works stonkers

#

wait no it doesnt

#

i give up

#

paypal sucks

lyric mountain
quartz kindle
#

:^)

lament rock
#

Bandcamp sucks

#

added support for track info and streaming and it was the worst

#

their html is so bad

#

It's also hilarious that they just have a JSON of just about everything you need in the head of the html

earnest phoenix
#

The fuck 👀

#

Why would they even add that

lament rock
#

idk

#

Spotify used to do the same thing

#

Then they removed the JSON and just have everything in the head in the form of og meta tags

#

on another note, I hate minified JS

#

back tracking in that shit to find where track info came from sucks

earnest phoenix
#

Minified code fans when they realize it practically doesn't make anything better

lament rock
#

on very large scales, I can see the data savings being huge, but like lol

#

also I guess makes reverse engineering the api harder

earnest phoenix
#

It only makes the parser parse the code faster and that's it, which the parser is already fast enough that no form of minification is even needed

lament rock
#

the main draw is data savings and user experience when it comes down to load times

earnest phoenix
#

I mean yeah but the minification doesn't save much data honestly KEKW

lament rock
#

on a scale of Spotify, I can see the savings being real

#

for small startups or just small sites in general, useless

#

unless your host/isp limits your data

earnest phoenix
#

Yeah, for extremely large applications it's kinda good, but I've seen a lot of applications that use minification for no reason

lament rock
#

the furthest I go is just webp images

earnest phoenix
#

The good ol' webp

lament rock
#

yup

#

I find it hilarious when sites include image files in the html

#

like ???

earnest phoenix
boreal iron
#

@earnest phoenix any idea?

earnest phoenix
boreal iron
#

No

#

The timer works always

#

Not so in this particular case

earnest phoenix
#

The timer has nothing to do with this, just the modal in general

boreal iron
#

It’s actually really funny since closing the modal ends the interaction then in my case after 45s a response appears in the chat

#

It’s funny tho

boreal iron
#

I send the modal as response then create the 45s timeout which sends a follow up

#

When submitting the modal the timeout will not send the follow up

#

So not submitting always sends the follow up message

#

But it failed in that case and the error message is weird

earnest phoenix
#

And you said sending the follow-up causes that error, and I came up with a possible theory of why

boreal iron
#

Only in this one case

earnest phoenix
#

It happened only once is what you mean?

boreal iron
#

But the webhook can’t be invalid when responding with a modal

earnest phoenix
#

Or just keeps happening when you try to send the follow-up?

boreal iron
#

Yeah ik I shouldn’t really think about it

#

But the error message is really weird in that case

#

Nah just happened once

#

Until now

earnest phoenix
#

That's pretty weird, I would really recommend asking that in the Discord Developers server if you haven't done so already

#

They might actually know what causes it

#

But if you don't mind it then ¯_(ツ)_/¯

boreal iron
#

Yeah it’s really weird

#

I mean I can not defer the response when responding with a modal

#

So the webhook ID can’t become invalid

#

At least not after 45s

#

I’m sure there is a timeout somewhere

#

Maybe my app is broken

#

I can not send DMs to my bot

#

Idk what’s going on tbh

lyric mountain
#

they blocked you

boreal iron
#

It’s my own app you genius

lyric mountain
#

exactly

#

it doesn't want to talk to you anymore

boreal iron
#

Shhhh Java boy

drifting cairn
boreal iron
#

Will just live with the fact the api returns weird stuff for my app and my client is broken

drifting cairn
#

lol

boreal iron
#

Thank you discord!

lyric mountain
#

they blocked u

drifting cairn
boreal iron
hidden gorge
#

i broke gmail

#

i don’t know how

spark flint
#

lol

hidden gorge
boreal iron
#

The submission has nothing to do with the follow up and once the submission of the modal happens the follow up won’t be send

sharp geyser
#
    match Entity::insert(new_message).exec(connection).await {
        Ok(_) => (StatusCode::CREATED, "Record was created.".to_string()),
        Err(err) => {
            println!("{:#?}", err);
            (
                StatusCode::INTERNAL_SERVER_ERROR,
                "Record was not created.".to_string(),
            )
        }
    }

@wheat mesa is this not correct?

wheat mesa
#

When you do Err(err) => { /* something */ } you'll need to explicitly return if the other one doesn't

sharp geyser
#

I see

wheat mesa
#

gimme a sec to work up an example

sharp geyser
#

okay

wheat mesa
#

Actually hold on I'm wrong

#

I don't think that's the part that's wrong

#

@sharp geyser can you show more? Do cargo check and send the error here

sharp geyser
#

```error[E0308]: match arms have incompatible types
--> src\main.rs:85:21
|
80 | Ok(parsed) => match parsed {
| ______________-
81 | | WebMessage::MessageCreate(message) => {
82 | | message_create(message, &mut socket, connection).await
| | ------------------------------------------------------ this is found to be of type (StatusCode, std::string::String)
83 | | }
84 | | WebMessage::MessageDelete(message) => {
85 | | message_delete(message, &mut socket, connection).await
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected tuple, found ()
86 | | }
87 | | },
| |
- match arms have incompatible types
|
= note: expected tuple (StatusCode, std::string::String)
found unit type ()

#

so it was somewhere else

#

nice

#
match serde_json::from_slice::<WebMessage>(&msg.into_data()) {
            Ok(parsed) => match parsed {
                WebMessage::MessageCreate(message) => {
                    message_create(message, &mut socket, connection).await
                }
                WebMessage::MessageDelete(message) => {
                    message_delete(message, &mut socket, connection).await
                }
            },
            Err(error) => {
                if socket.send(Message::Text(error.to_string())).await.is_err() {
                    return;
                };
                socket.close().await.unwrap();
                return;
            }
        };
earnest phoenix
#

Ok. So discord added forum channels. How do I check the name of one when it is created?

lament rock
#

CHANNEL_CREATE if the client didn't create the channel or if you are creating the channel, you can get the response of the create request

#

The inner payload of CHANNEL_CREATE is an object that has a name property

earnest phoenix
#

is a forum post a channel or thread?

lament rock
#

thread

#

threads are channels though

earnest phoenix
#

oh I see

lament rock
#

It's all the same POST /channels/:channel_id/messages

#

Oh I may have interpreted your question wrong

#

for posts created in forum channels, THREAD_CREATE is fired

#

for when a forum channel is created though, CHANNEL_CREATE

#

THREAD_CREATE is essentially the same as CHANNEL_CREATE though, just the channel type is limited to 10, 11 or 12

sharp geyser
#

Why discord gotta be so weird with their api

lament rock
#

Who knows

sharp geyser
#

I wonder how my API will end up looking on my mock app

#

Probably more horrendous

lament rock
#

What's bizarre to me is that Discord has API versions for a reason, but they're scared shitless to make actual breaking changes

sharp geyser
#

The only breaking changes they have is when they discontinue a version

lament rock
#

like, THREAD_CREATE is useless. Just put it all in CHANNEL_CREATE

sharp geyser
#

It breaks a lot of libs

lament rock
#

I know a friend still using discord.js v11

sharp geyser
#

How

lament rock
#

v11 was really rigid

sharp geyser
#

I couldn't sanely use djs let alone v11

lament rock
#

I liked v11 more than any other version tbh

#

it was less convoluted

sharp geyser
#

I liked v11 only for structures

lament rock
#

that was v12

sharp geyser
#

V12 removed structures no?

lament rock
#

that was v13

sharp geyser
#

either way

#

After they removed structures I couldn't use it anymore

#

It was too much of a hassle to extend a class and get it working in ts

#

I always had some weird typing errors that even djs support couldn't fix

lament rock
#

I abused Structures by making optimized class structures

sharp geyser
#

Also I feel threads are useless now

#

What's the point of a thread when you can make a forum post

lament rock
#

assuming there are forums

sharp geyser
#

I mean yes

lament rock
#

rn, forums are only available in community servers

sharp geyser
#

But if it's important enough I'd assume a forum would exist

sharp geyser
#

At least they have it enabled

lament rock
sharp geyser
#

They like having access to those niche things

#

Anyway I go night night

lament rock
#

ok night night

earnest phoenix
#

ok

#

so

#

how do I check if the bot can delete one of the posts?

#

because thread.manageable returns false. even when the bot has admin

earnest phoenix
#

nvm

rotund river
#

how can i send more button in unique line?

#
interaction.channel.send({ content: `<@&1018078468686233650>`, embeds: [embed], components: [row1, row] });
spark flint
#

just make one row

#

and add multiple buttons to it

rotund river
rotund river
# spark flint and add multiple buttons to it
        client.on('interactionCreate', async interaction => {
            if (!interaction.isSelectMenu()) return;
            if (interaction.customId == "SupportSelect") {
                //interaction.deferUpdate();
                if (interaction.values[0] === "minecraft") {

                    const row = new ActionRowBuilder()
                        .addComponents(
                            new ButtonBuilder()
                                .setStyle(ButtonStyle.Danger)
                                .setEmoji("🔒")
                                .setLabel('Close')
                                .setCustomId("ticket-close")
                        )
                        .addComponents(
                            new ButtonBuilder()
                                .setStyle(ButtonStyle.Secondary)
                                .setEmoji("👥")
                                .setLabel('Claim')
                                .setCustomId("ticket-claim")
                        );

                    const embed = new EmbedBuilder()
                        .setTitle("Categoria: Minecraft")
                        .setDescription(`<@!${interaction.user.id}> ha creato un **Ticket**!\n\nLo staff è già stato avvisato del tuo ticket!\n\nPremi il bottone 🔒 per chiudere il ticket!\n\n**Per favore, non pingare nessuno staffer!**`)
                        .setColor(client.config.embedColor)
                        .setFooter({ text: `${client.config.embedfooterText}`, iconURL: `${client.user.displayAvatarURL()}` });


                    
                        interaction.channel.messages.cache.first().delete()
                        10000,
                        interaction.channel.send({ content: `<@&1018078468686233650>`, embeds: [embed], components: [row] });

                }
            }
        })
#

it spam message

spark flint
#

hmm

#

shouldn't od

rotund river
# spark flint shouldn't od
  <rejected> DiscordAPIError[10008]: Unknown Message
      at SequentialHandler.runRequest (/home/bot/Shark/node_modules/@discordjs/rest/dist/lib/handlers/SequentialHandler.cjs:287:15)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async SequentialHandler.queueRequest (/home/bot/Shark/node_modules/@discordjs/rest/dist/lib/handlers/SequentialHandler.cjs:99:14)
      at async REST.request (/home/bot/Shark/node_modules/@discordjs/rest/dist/lib/REST.cjs:52:22)
      at async MessageManager.delete (/home/bot/Shark/node_modules/discord.js/src/managers/MessageManager.js:245:5)
      at async Message.delete (/home/bot/Shark/node_modules/discord.js/src/structures/Message.js:767:5) {
    rawError: { message: 'Unknown Message', code: 10008 },
    code: 10008,
    status: 404,
    method: 'DELETE',
    url: 'https://discord.com/api/v10/channels/1019890810155696138/messages/1019890811388821534',
    requestBody: { files: undefined, json: undefined }
  }
}  reason:  Unknown Message
#

i resolve it

rotund river
#

why?

Uncaught Exception: TypeError: Cannot read properties of undefined (reading 'user')
(node:379757) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 interactionCreate listeners added to [Client]. Use emitter.setMaxListeners() to increase limit
(Use `node --trace-warnings ...` to show where the warning was created)
[FATAL] Possibly Unhandled Rejection at: Promise  Promise {
  <rejected> TypeError [InvalidType]: Supplied parameter is not a User nor a Role.
      at PermissionOverwrites.resolve (/home/bot/Shark/node_modules/discord.js/src/structures/PermissionOverwrites.js:184:28)
      at /home/bot/Shark/node_modules/discord.js/src/managers/GuildChannelManager.js:245:90
      at Array.map (<anonymous>)
      at GuildChannelManager.edit (/home/bot/Shark/node_modules/discord.js/src/managers/GuildChannelManager.js:245:60)
      at TextChannel.edit (/home/bot/Shark/node_modules/discord.js/src/structures/GuildChannel.js:279:32)
      at PermissionOverwriteManager.set (/home/bot/Shark/node_modules/discord.js/src/managers/PermissionOverwriteManager.js:71:25)
      at Object.execute (/home/bot/Shark/events/tickets/claimTicket.js:31:54)
      at Client.<anonymous> (/home/bot/Shark/handler/index.js:27:58)
      at Client.emit (node:events:525:35)
      at InteractionCreateAction.handle (/home/bot/Shark/node_modules/discord.js/src/client/actions/InteractionCreate.js:81:12) {
    code: 'InvalidType'
  }
}  reason:  Supplied parameter is not a User nor a Role.````
#
            interaction.channel.permissionOverwrites.set([
                {
                    id: interaction.user.id,
                    allow: [PermissionFlagsBits.ViewChannel, PermissionFlagsBits.SendMessages, PermissionFlagsBits.AttachFiles, PermissionFlagsBits.EmbedLinks],
                },
                {
                    id: client.ticketsSupportRoles,
                    deny: PermissionFlagsBits.ViewChannel,
                },
            ]);````
boreal iron
# rotund river

Your error messages reveals that you’re creating multiple event listeners for the interactionCreate event

#

You’re only supposed to create one not multiple

spark flint
#

making a class, js constructor(options) { super(); this.options.debugging = options?.debugging || false; }

pearl trail
#
constructor(options) {
  super();
  this.options = {
    debugging: !!options?.debugging
  }
}
#

you can't make object on a var by just set the key

earnest phoenix
#

[FATAL] Possibly Unhandled Rejection at: Promise Promise { <rejected> DiscordAPIError[10008]: Unknown Message at SequentialHandler.runRequest (/home/bot/Shark/node_modules/@discordjs/rest/dist/lib/handlers/SequentialHandler.cjs:287:15) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async SequentialHandler.queueRequest (/home/bot/Shark/node_modules/@discordjs/rest/dist/lib/handlers/SequentialHandler.cjs:99:14) at async REST.request (/home/bot/Shark/node_modules/@discordjs/rest/dist/lib/REST.cjs:52:22) at async MessageManager.delete (/home/bot/Shark/node_modules/discord.js/src/managers/MessageManager.js:245:5) at async Message.delete (/home/bot/Shark/node_modules/discord.js/src/structures/Message.js:767:5) { rawError: { message: 'Unknown Message', code: 10008 }, code: 10008, status: 404, method: 'DELETE', url: 'https://discord.com/api/v10/channels/1019890810155696138/messages/1019890811388821534', requestBody: { files: undefined, json: undefined } } } reason: Unknown Message

#

oh yee

boreal iron
#

await your promises and catch errors

#

also the message you wanna delete simply doesn't exist anymore

#

if you try to do delete an ephermal message, that ain't gonna work

earnest phoenix
#

My bot can delete messages in a thread but not a thread from a forum. Its using the same code.

spark flint
#
const bloxyClass = class Bloxy extends EventEmitter {
    constructor(options) {
        super();
        this.options.debugging = options?.debugging || false;
    }

    issueEvent(event, ...args) {
        if (this.options?.debugging) console.log(`[Bloxy] Event emitted: ${event}`);
        this.emit(event, ...args);
    }
}

module.exports.Bloxy = bloxyClass;```

```js
new Bloxy({ debugging: true });```
quartz kindle
#

you cant add something to this.options because this.options doesnt exist

spark flint
#

ah

#

so put js this.options = {}

#

?

boreal iron
#

TF

quartz kindle
#

yes

boreal iron
#

scroll up bun

#

my gosh

spark flint
#

oh

#

shit my memory is awful

#

i apologise

boreal iron
#

DENIED

spark flint
#

now i have more code issue sobby

#

2 secs

quartz kindle
#

lmao

spark flint
#
if (bloxyClass?.options?.debugging) issueEvent("debug", "Loading methods...");
for (file of fs.readdirSync("./methods").filter(f => f.endsWith(".js"))) {
    module.exports[file] = require(`./methods/${file}`);
    if (bloxyClass?.options?.debugging) issueEvent("debug", `Loaded method: ${file}`)
}
const { getAvatar } = require('./index.js');

(async () => {
   console.log(await getAvatar("1"))
})()```
#

im trying to make my life easier but its not working kek

quartz kindle
#

dont import stuff from index

#

@_@

boreal iron
#

dont u wanna show us how you export it?

spark flint
#

2 secs

quartz kindle
#

2 secks

boreal iron
#

anything takes 2 sneks

spark flint
#
module.exports = async (userid) => {
    if (!userid) return null;
    
    const req = await http(`https://thumbnails.roblox.com/v1/users/avatar?userIds=${userid}&size=720x720&format=Png&isCircular=false`).json()

    if (req?.errors) return null;

    return req?.data[0]?.imageUrl || null;
}```
#

thats getAvatar.js

boreal iron
#

BUN

#

const { getAvatar } = require('./index.js');

#

thats getAvatar.js

quartz kindle
#

the why you import from index

#

import from getavatar.js

spark flint
#

because its going to be a package kek

quartz kindle
#

wat

#

show index then

spark flint
#
const fs = require('fs');
const { EventEmitter } = require('events');

const bloxyClass = class Bloxy extends EventEmitter {
    constructor(options) {
        super();
        this.options = {
            debugging: !!options?.debugging
        }
    }

    issueEvent(event, ...args) {
        if (this.options?.debugging) console.log(`[Bloxy] Event emitted: ${event}`);
        this.emit(event, ...args);
    }
}

module.exports.Bloxy = bloxyClass;

if (bloxyClass?.options?.debugging) issueEvent("debug", "Loading methods...");
for (file of fs.readdirSync("./methods").filter(f => f.endsWith(".js"))) {
    module.exports[file] = require(`./methods/${file}`);
    if (bloxyClass?.options?.debugging) issueEvent("debug", `Loaded method: ${file}`)
}

module.exports.version = require("./package.json").version```
pale vessel
#

Is if (req?.errors) return null; necessary

spark flint
#

well its how the roblox API returns things

pale vessel
#

Wouldn't data not exist anyway if there's an error?

boreal iron
#

you already return null if no data or imageURL is available

spark flint
#

true

pale vessel
#

req?.data?.[0]?.imageUrl || null;

quartz kindle
#

that debugging wont work lol

spark flint
#

ik i haven't tested it yet

#

im trying to Bye

quartz kindle
#

do console.log(require(index))

spark flint
#
 {
  Bloxy: [class Bloxy extends EventEmitter],
  'getAvatar.js': [AsyncFunction (anonymous)],
  'getPreviousUsernames.js': [AsyncFunction (anonymous)],
  'getUserFromID.js': [AsyncFunction (anonymous)],
  'getUsersFromSearch.js': [AsyncFunction (anonymous)],
  'getUsersFromUsernames.js': [AsyncFunction (anonymous)],
  version: '1.0.0'
}```
quartz kindle
#

you set the entire filename as keys

spark flint
#

ah

#

this is a brainfart moment

quartz kindle
#

remove the .js

spark flint
#

ok done

#

ok that worked 💀

#

i think it was just me being stupid kek

quartz kindle
#

now for the debugger, that wont work because the bloxyClass object doesnt have .options

cinder patio
#

So? many? question? marks?

spark flint
#

ah

quartz kindle
#
typeof bloxyClass // "function"
typeof bloxyClass.options // "undefined"

const instance = new bloxyClass()
typeof instance // "object - Bloxy"
typeof instance.options // "object"
spark flint
#

hmm

quartz kindle
#

everything that uses this only exists after you use new

spark flint
#

alright

cinder patio
#

Also having every method in a separate file especially for a library is kinda silly

spark flint
#

true

#

how would people recommend I do caching

atomic estuary
#

So I cant think how would I go about str.replaceAll(str, newstr) but I want unique values for each str it replaces, Any easy ways of completing such?

boreal iron
#

a loop, using replace not replaceAll

#

once the first "needle" has been replaced it will jump to the next one in the iteration

atomic estuary
#

I guess im brain dead

boreal iron
#

an endless loop incl a statement if your string (still) includes your "needle", if not return - for example

lament rock
#

replaceAll can as well iirc

daring apex
#

How can I fix it

boreal iron
#

Cough python -> indentations

#

also line 7 ; instead of : (I guess)

daring apex
#

There that error

boreal iron
#

Cough python -> indentations

#

Take a look at line 11 and 12

#

You will notice a difference

#

You will soon run into the same error again for line 15 and 16

#

Use the indentation to move em into on_message event scope

daring apex
spark flint
boreal iron
#

Why do you even use python in the first place?

#

Those are the fundamental fundamentally fundamentals

#

… to know

quartz kindle
daring apex
#

That's my old file i was just trying to remake it

quartz kindle
#

check the indentation of those lines and its easy to see what the problem is

boreal iron
quartz kindle
#

do you not see which lines are incorrectly indented?

#

line 8 and line 15-16

daring apex
#

Oh I see

boreal iron
#

Tf Tim just repeats what I said already

#

Why didn’t you see before

#

arrrrggghh

quartz kindle
#

people dont trust your word i guess

#

:^)

boreal iron
#

Bullying fake in every channel

#

Rude

lyric mountain
#

python is just a turing-complete yaml

surreal sage
#

I have 5 rows,
In total there can only be 5 of "some character here"
The rest has to be "some other character here"

#

How to

#

Randomly choose the rows the first character would be in?

#

I know how now 😃

lyric mountain
#

what

surreal sage
#

Yes.

lyric mountain
#

are u trying to make a hangman game?

surreal sage
#

Don't worry about that just help 😄

#

5 rows and 5 columns

#

Maximum of 5 "yada" in it (see it as 5 arrays with length of 5)

#

The index of "yada" is random within the length of 5

#

I think I have something in mind

#

Again

lyric mountain
surreal sage
#

No worries then

eternal osprey
#
void path_agent() {
    int initiator = -1;
int tiles_with_no_balls = 0;
    while(initiator == -1){
       if(!on_ball()){
          tiles_with_no_balls = tiles_with_no_balls + 1;
          cout << tiles_with_no_balls;
       }
       if(on_ball()){
          tiles_with_no_balls = 0;
       }
      if(tiles_with_no_balls > 3){
          initiator = 0;
         bot_quit();
        
      }
      if(on_ball() && !in_front_of_wall()){
          
         step();
      }else{

      
      bot_check_corner_angle(true);
      }
}
}```hey does anyone know why my variable titles_with_no_balls doesn't work? For some reason it literally surpasses the number 3, but the if statement never fires. The out doesn't even fire as well, even if i put it right after the while loop. The code is in c++
lyric mountain
#
void path_agent() {
    int initiator = -1;
    int tiles_with_no_balls = 0;
        
    while (initiator == -1) {
        if (!on_ball()) {
            tiles_with_no_balls = tiles_with_no_balls + 1;
            cout << tiles_with_no_balls;
        }
            
        if (on_ball()) {
            tiles_with_no_balls = 0;
        }
            
        if (tiles_with_no_balls > 3) {
            initiator = 0;
            bot_quit();
        }
            
        if (on_ball() && !in_front_of_wall()) {
            step();
        } else {
            bot_check_corner_angle(true);
        }
    }
}
quartz kindle
#

thank you god bless

#

lmao

lyric mountain
#

while (initiator == -1) could be replaced with while (true) + break; after bot_quit();

#

if (!on_ball()) and if (on_ball()) could be replaced with if (...) { } else { }

quartz kindle
#

yeah

lyric mountain
#

also, your error is there

quartz kindle
#

and a lot of the flow can be simplified

lyric mountain
#

because the second block literally invalidates what u did on the first

#
void path_agent() {
    int no_balls = 0;

    while (no_balls < 3) {
        if (on_ball()) {
            no_balls = 0;

            if (!in_front_of_wall()) {
              step();
            }
        } else {
            no_balls++;
            cout << no_balls;

            bot_check_corner_angle(true);
        }       
    }

    bot_quit();
}
quartz kindle
#
void path_agent() {
    int tiles_with_no_balls = 0;
    while (true) {
        if (tiles_with_no_balls > 3) {
            bot_quit();
            break;
        }
        if (on_ball()) {
            tiles_with_no_balls = 0;
            if(in_front_of_wall()) {
                bot_check_corner_angle(true);
            } else {
                step();
            }
        } else {
            tiles_with_no_balls++;
            cout << tiles_with_no_balls;
            bot_check_corner_angle(true);
        }
    }
}
#

lmao

lyric mountain
#

I think I can't reduce any more than that

#

unless count << ++no_balls;

eternal osprey
#

but this has nothing to do with my issue ?

lyric mountain
#

it does

lyric mountain
#

meaning it'll never be higher than 0

#

so it can never enter the if (no_balls > 3)

eternal osprey
#

but that int tiles_with_no_balls = 0; only is defined at the begin of the function

#

and inside the while loop we are adding a 1 to the integer

#

or am i doing something stupid rn

lyric mountain
#

I dont meant that

#

show what ur on_ball() is doing

eternal osprey
#

It's a school assignment

#

let me bin my ode

#

code*

#

it basically needs to follow this trail

#

it works, however at the end of the trial it is not stopping

lyric mountain
#

honestly, that'd be easier to accomplish with arrays

eternal osprey
#

i am not allowed to use that yet

lyric mountain
#

a

eternal osprey
#

else i would have finished it a bit easier

lyric mountain
#

hm, u can use a proxy actor to check the next step

eternal osprey
#

basically at the end it walks at the 3 marked empty tiles

#

so then i am using the variable++

#

and checking what the variable is

#

if it's 3 it should return but it doesn;t

lyric mountain
#

you'd need to use ++variable actually

#

if ur using an inline check

eternal osprey
#

okay i see

#

really strange but that varialbe doesn't seem to work

lyric mountain
#

so well, if u were to use a second actor it'd be simpler to check

eternal osprey
#

what's a second actor

lyric mountain
#

like, have the second one always be 1 step ahead of the actual actor (red arrow)

#

@drowsy crag

lyric mountain
#

@oak cliff please

eternal osprey
#

as of now js if (on_ball()) { tiles_with_no_balls = 0;is resetting it

#

even at thend

#

the end** while it isn't on a ball

#

and for some reason the cout doesn't even work lmao

slim heart
#

i need a good interview question for a javascript developer, anyone have any good ideas?

lyric mountain
#

ask them to write a calculator

#

if they use var, you already have a flag there

pale vessel
#

Is that a question

lyric mountain
#

"If you were to write a calculator, how would you do it?"

pale vessel
#

Mf gonna speak the entire code

lyric mountain
#

lmao

pale vessel
#

Just listen for a "var"

lyric mountain
#

var, forEach, many unnecessary comments, waaaay too long/short variables, too few/many variables, etc

#

oh and whether they keep everything in a single file or spread among specialized ones

#

and how often a piece of code appears across the codebase

#

the last one is a serious sign of poorly written code (single-responsability rule)

eternal osprey
slim heart
lyric mountain
#

I have, that's how I work as a programmer today

#

but most of the usual "tech" questions are superfluous and/or don't represent how good the coder is

#

"Invert a binary tree" ok, when was the last time u applied such knowledge?

pale vessel
#

I mean it's an interview? I thought it'd be more of a question abt experiences n stuff

lyric mountain
#

imo having good habits is way more valuable than something you could google for

eternal osprey
#

Okay guys

#

i have changed my code but i still can't get it right

#
void path_agent() {
bool para = false;
    while (initiator == -1) {
     if(on_ball()){
        step();
       tiles_with_no_balls = 0;
     }
     if(!on_ball()){
        tiles_with_no_balls = tiles_with_no_balls + 1;
        para = true;
     }
     while(para){
        turn_right();
        turn_right();
        step();
        turn_right();
        if(on_ball()){
           para = false;
        }
     }
     if(tiles_with_no_balls >= 3){
        initiator = 0;
        para = false;
     }
    }
     initiator = -1;
        para = false;
}

```So my code works now.. however at the end i can't stop it
lyric mountain
#

now u have an infinite loop

#

just use while (tiles_with_no_balls < 3)

#

that should solve the problem

eternal osprey
lyric mountain
#

your previous code was mostly right, the issue were that u checked > 3, which can never be true

eternal osprey
#

the code still thinks that it's not on a ball of course

#

and tries to initiialize that search ball function

#

however that's the end of the line so it should stop there

eternal osprey
#

I can't as bot check angle was a long function that didn't want to wor

#

work

#

it wasn't already in the program

lyric mountain
#

hm

eternal osprey
#

So everything works great the only issue is that i can't let this fucking bot stop walking at the end

#

as it tries to initialize another search for balls function

lyric mountain
#

did u change >= 3 to > 3?

eternal osprey
#

yes

#

but as seen in the video, it only takes 1 step tho

lyric mountain
#

or use while (no_balls < 3)?

eternal osprey
#

but it would still not work right?

lyric mountain
#

try it

#

if it still loops at the end decrease the limit by 1

eternal osprey
#

because the code is only running once

lyric mountain
#

all codes run only once

eternal osprey
lyric mountain
#

< 2 then

eternal osprey
#

i know, but i mean, it only takes one step

#

so where would we get the 3 from

#

😭

lyric mountain
#

?

#

idk what u mean

eternal osprey
#

have you seen that video?

lyric mountain
#

yes

eternal osprey
#

If it isn't standing on a ball, it will check it's environment**

lyric mountain
#

yes

#

the loop will exit when no_balls reach 3 or more

#

since u said it still does the same, reduce to 2

eternal osprey
#
void path_agent() {
bool para = false;
    while (initiator == -1) {
     if(on_ball()){
        step();
       tiles_with_no_balls = 0;
     }
     if(!on_ball()){
        tiles_with_no_balls = tiles_with_no_balls + 1;
        para = true;
     }
     while(para){
        turn_right();
        turn_right();
        step();
        turn_right();
        if(on_ball()){
           para = false;
        }
     }
     if(tiles_with_no_balls > 3){
        initiator = 0;
        para = false;
     }
    }
     initiator = -1;
        para = false;
}
void cave_agent() {

}```
lyric mountain
#

...no

eternal osprey
#

but this code inplies that if it's on a ball it will reset it

#

implies*

lyric mountain
#

remove this entirely ```cpp
if(tiles_with_no_balls > 3){
initiator = 0;
para = false;
}

eternal osprey
#

okay

lyric mountain
#

change while (initiator == -1) to while (tiles_with_no_balls < 3)

#

see it it solves the issue, if it doesn't, change to while (tiles_with_no_balls < 2)

eternal osprey
#

okii

#

still the same

lyric mountain
#

even with both changes?

eternal osprey
#

yes and i will explain why

#

So if the bot is on a ball, it will reset the balls okay. If it isn't on a ball, it will take 1 step max and increment the tilewithnoballs with 1. This means that at the end of the path, the bot will try to take another step.

#

as it will try to search for another ball,

lyric mountain
#

yes

eternal osprey
#

And it will find it, and reset the count again

#

so it will get onto an infinite loop

lyric mountain
#

not if u changed the while as I said

eternal osprey
#

i did

#
void path_agent() {
bool para = false;
    while ((tiles_with_no_balls < 2)) {
     if(on_ball()){
        step();
       tiles_with_no_balls = 0;
     }
     if(!on_ball()){
        tiles_with_no_balls = tiles_with_no_balls + 1;
        para = true;
     }
     while(para){
        turn_right();
        turn_right();
        step();
        turn_right();
        if(on_ball()){
           para = false;
        }
     }
   
    }
     initiator = -1;
        para = false;
}```
lyric mountain
#

no u literally didn't

eternal osprey
#

oowh i did

lyric mountain
#

compare what u have with what I wrote

eternal osprey
#

i just changed it for another test

eternal osprey
#

like right now

lyric mountain
#

this is the order of events

#

while (no_balls < 3) means the last try will be at tile 3

#

next iteration will quit

eternal osprey
#

okay wait i will try it out again with my old code

#

one sec

lyric mountain
#

those are the tiles ur checking (in green)

#

now lemme rotate it and you'll see the issue

#

from what I saw in ur video, the check is being done one step ahead

#

the check at step 1

#

the check at step 2

#

see how it finds there's an available path to the left?

eternal osprey
#

yeah

lyric mountain
#

u need to check without moving the actor

#

and without rotating it

eternal osprey
#

we cannot that's the catch

lyric mountain
#

oh u can

#

or actually, there's an even simpler way

eternal osprey
#

our school gave us a step(); function and that's it

#

do you want my whole code rn?

lyric mountain
#

nope

#

the simple solution: count the number of rotations

#

not the number of tiles

eternal osprey
#

We cannot

lyric mountain
#

...how so?

eternal osprey
#

It must work for all path variations

#

we could have lots of paths so this alghoritm must work for all contagious paths

#

a variant for example

lyric mountain
#
while (!on_ball) {
  step();
  if (on_ball) break;
  undo();

  rotateLeft();
  step();
  if (on_ball) break;
  undo();
  rotateRight();

  rotateRight();
  step();
  if (on_ball) break;
  
  stop_bot();
}

...

function void undo() {
  rotateLeft();
  rotateLeft();
  step();
  rotateLeft();
  rotateLeft();
}
#

it'll check forwards, left then right, if neither find a ball tile, quit

#

undo will simply move backwards so u can start again from the original tile

eternal osprey
#

i am not allowed to use break iirc

#

they are really making it fucking hard for no reason

lyric mountain
#

use nested ifs then

#
step();
if (!on_ball) {
  undo();

  rotateLeft();
  step();
  if (!on_ball) {
    undo();
    rotateRight();

    rotateRight();
    step();
    if (!on_ball) {  
      stop_bot();
    }
  }
}
#

ugly yes, but the same as if using break

eternal osprey
#

that code is far from working

#

i will send a gif in a sec

#

will technically it did work

#

but it did some crazy things at the end

#

it kept looping again

lyric mountain
#

then ur doing something else, this literally cant loop

#

unless the map is a literal loop (like a circle)

eternal osprey
#

i can't hardcode it

#

so i had to change the while loop parameters

lyric mountain
#

hardcode?

eternal osprey
#

it's because the code MUST run for like 100 variations or something

lyric mountain
#

...but this will run in any variation as long as the map isn't a loop

eternal osprey
lyric mountain
#

it isn't moving left, then right, then forwards, etc

#

it is checking for available paths in one of the 3 directions

#

THEN proceeding to check again after going to the next tile

#

if u change anything in that code I sent it'll no longer work

eternal osprey
#

Okay i will try it out again

lyric mountain
#

do make sure to have that while inside the main loop

#

else it'll check once and quit even if there's a valid path

#
bool stop = false;
while (!stop) {
  ...
  while (!on_ball) {
    // the code I sent
  }

  if (!on_ball) stop = true;
}
eternal osprey
#

but where's the code where the actual bot will walk>

#

?

lyric mountain
#

before the inner while

eternal osprey
#

Because right now the bot will be on a ball, and the whole while function won't even run

#

I see

lyric mountain
#

I believe all variations of the map have steps > 1 right?

#

like, no single-tile maps

eternal osprey
#

yup

lyric mountain
#

actually, u don't even need to move beforehand

#

the code will step for itself, only calling undo() if it resulted in an empty tile

#

this will make sure it works even in single-tile maps

eternal osprey
#

okay wow this atually worked

lyric mountain
#

it's a basic pathfinder algorithmn, there was a game similar to what ur doing (used to play it a lot)

#

it was a robot that needed light all blue tiles

#

lightbot was its name

eternal osprey
#

So what this does, correct me if i am wrong pls, it steps and if it isn't on a ball it will check the environments around it. If it still can't find a ball it will check the right side of his environment.

eternal osprey
lyric mountain
#

note the panel to the right

lyric mountain
#

the undo() method is simply rotating the actor 180°, moving one tile then rotating 180° again, thus ending at the same state as it was before moving

#

undo() can be replaced if ur teacher added a function to move backwards

#

but given they didn't allow break, I find it unlikely

eternal osprey
#

this is so cool

#

really convenient

#

so basically it first steps, then it checks the right, then it checks the left. If it still didn't find a fucking ball it will return

#

bro this is majestic

lyric mountain
#

give that game a try, it's good to understanding how to optimize ur code and think with states

#

(if flash still runs)

eternal osprey
#

I will definitely do!

#

I will just optimize this code with a parameter to check walls and i should be done!

#

there seems to be one big issue with the code tho

#

which is my fault for not letting you know

#

there are some variations

#

that have the balls next to a wall

#

right now the bot tries to go throught it XD

lyric mountain
#

does step() still move or does it block?

#

also is there anyway for u to know there's a wall ahead? like a getPos() or an exception being thrown

eternal osprey
#

will return a boolean value

eternal osprey
lyric mountain
#

nice

#

then simply use try and catch on top of the if (!on_ball)

eternal osprey
#

also not allowed whahaha

lyric mountain
eternal osprey
#

i know, but then it stops the code for the other variations as well

#
void check_for_path_angle() {
   if(!in_front_of_wall()){
  turn_left();
  turn_left();
  step();
 turn_left();
 turn_left();
   }
}

void path_agent() {
bool stop = false;
while (!stop) {
   if(!in_front_of_wall()){
  step();
   }```
lyric mountain
#
bool moved = move();
if (!moved || !on_ball) {
  undo();
  moved = false;

  rotateLeft();
  moved = move();
  if (!moved || !on_ball) {
    undo();
    rotateRight();
    moved = false;

    rotateRight();
    moved = move();
    if (!moved || !on_ball) {  
      stop_bot();
    }
  }
}

function bool move() {
  if (!in_front_of_wall() {
    step();
    return true;  
  }

  return false;
}
eternal osprey
#

what's this?

lyric mountain
#

the same code but added wall checking

#

the function move() will check if it's not in front of a wall, if it isn't then move and return true, else return false

#

if the actor didn't move OR isn't in a ball, retry on another direction

#

truth table:

moved  |  on_ball  |  retry? (if not on last try)
----------------------------
  Y    |     Y     |    No
  Y    |     N     |    Yes
  N    |     Y     |    Yes
  N    |     N     |    Yes
maiden gazelle
#

can someone help me with my shooter game pls dm me so i know when someone wants to help me

lyric mountain
#

why don't u ask here instead?

maiden gazelle
#

Bc it is hard to explain

lyric mountain
#

it'll also be hard on dms

drifting cairn
#

lmao

eternal osprey
#

so we are basically checking if it's in front of the wall, and assigning that to a moved bool?

#

However, isn't the in_front_of_wall() funtion already doing that?

#

So why are we overcomplicating it?

lyric mountain
#

you're not checking if there's a wall, you're checking if you moved at all

#

you need to move to know if the next tile has a ball, but u cant if there's a wall, so you must first check if you can move

#

it should only retry if there's a wall in front of the actor or the next tile doesn't have a ball

#

you have no way to know the next tile before moving, that's why I assign the result of move() to a variable (else it'll crash as u said)

#

you can actually remove the variable althogether and use move() inside the check

#
if (!move() || !on_ball) {
  undo();

  rotateLeft();
  moved = move();
  if (!move() || !on_ball) {
    undo();
    rotateRight();

    rotateRight();
    moved = move();
    if (!move() || !on_ball) {  
      stop_bot();
    }
  }
}

function bool move() {
  if (!in_front_of_wall() {
    step();
    return true;  
  }

  return false;
}
#

does it make more sense now?

eternal osprey
#

ah yeah i see now!

#

i am also now allowed to use a bool function

#

i can only provide a bool as a parameter

#

like: void name (bool test)

ancient nova
#

so you guys are smart huh 🗿

#

how do you spell 12th then

#

🤨🤨

solemn latch
#

12th

eternal osprey
#

due to that function bool

ancient nova
#

in

solemn latch
#

^_^

ancient nova
eternal osprey
lyric mountain
#

Tf is up with ur teacher

#

Well, simply place whatever is inside the function where the calls are

#

You'll need to use the previous variable method tho

#

Since it's cpp, u can also pass the variable as reference to not have to type the same thing everytime

eternal osprey
#

i've tried doing that but it doesn't work lmao

boreal iron
#

Kahuwakakbanka doing others homework?

eternal osprey
#

nah but this fuking program is so dumb

#

i tried dodging that wall but it's still trying to fucking penetrate it

lyric mountain
#

before each if, then set moved = false after undo

lyric mountain
#

I'd hate to have such teacher

eternal osprey
#

its because it's the 4th class of the year so they made their own environment with lots of restrictions

#

we can only use what we learned so far

boreal iron
#

Just obfuscate your code and tell him you fulfill all conditions

eternal osprey
#

really annoying but yeah

boreal iron
lyric mountain
boreal iron
#

aye

lyric mountain
#

or compile into a dll and call it a day

#

nobody is gonna read the asm instructions

eternal osprey
#
void check_for_path_angle() {

  turn_left();
  turn_left();
  step();
 turn_left();
 turn_left();
   
}
bool passed_wall_check = false;
void check_front_wall(){
if (!in_front_of_wall()) {
  step();
  passed_wall_check = true;  
}
}

void path_agent() {
  
   bool stop = false;
while (!stop) {
   

  step();
  
   

 check_front_wall(); 
if (!on_ball()) {
  
  check_for_path_angle();
  passed_wall_check = false;
  turn_left();
  step();
  check_front_wall();
  if (!on_ball()) {
     
    check_for_path_angle();
    passed_wall_check = false;
    turn_right();
    turn_right();
    step();
    

  if (!on_ball()) stop = true;
}


}
}```i might be ugly but it doesn't want to run anymore
lyric mountain
#

why do u hate formatting

eternal osprey
#

why would i format while still not having the code finished

#

imo formatting is an end job

lyric mountain
#

formatting is as important as coding

#

because many bugs become evident on a properly formatted code

#

also it wont run obv, u didn't check if there's a wall before stepping

eternal osprey
#

nope that ain't it

#

i put a check on it now

#

look at what happens

lyric mountain
#

u changed my code so much that idk exactly what I'm looking at

eternal osprey
eternal osprey
#

only the function names are different

boreal iron
#

maybe remove drunk()

eternal osprey
#

yeah that's the thing, i am not sure what's wrong with it either

lyric mountain
#

try running my code 1:1 to see if it works

#

if it does, work from there onwards

eternal osprey
#

alrighty i fixed it

#

and it works now

#

however the only issue is that it doesn't stop anynore wahhaha

#

nevermind

#

i fixed it

#

i am so damn smart

#

nevermind

#

it still doesn't work

eternal osprey
#

@lyric mountain so apparentely the code cannot run when there's a wall right next to the balls

#

it tries to enter the wall

wheat mesa
near ether
#

does anyone know a good way to accept payment through discord? previously, i used donatebot, but its been down all of today and honestly the devs dont seem to care much anymore, so im looking to switch

ideally:

  • users would be able to make one-time purchases by logging in with discord and then paying through paypal/stripe/whatever. they would then receive rewards in my bot
  • users can also sign up for a recurring monthly subscription through the same method above
earnest phoenix
#

If that's really what you're looking for... Although it's still in development, so you would have to wait

eternal osprey
#

And my teacher neither

#

I will just wait on kuukahu then

wheat mesa
#

u need java help?

lyric mountain
sterile lantern
#

i have two github accounts (also generated two ssh keys), and i want to use them both on one computer. is it possible to set git config differently for each repo i clone?

near ether
near ether
boreal iron
#

It’s not like you need a bot or third party service for this

near ether
drifting cairn
#

do you have a domain?

#

@near ether

near ether
drifting cairn
#

if you have a website already built i'd recommend integrating either stripe or paypal, if not then check out things like patreon or upgrade.chat which allow you to just handle the requests in the backend without having to have a frontend setup to create payments etc...

near ether
#

gotcha, ty!

drifting cairn
boreal iron
#

That’s your way into managing payments

worn pecan
lament rock
#

Might be that the code is an ES Module, but trying to run CJS only code

hasty mulch
#

How do I disable a command in d.py 1.7.3?

boreal iron
#

You mean application commands?

#

Delete em

pale vessel
#

If you literally mean disable them you'd have to do that in settings yourself

#

The bot can't do it

dry imp
#

also d.py 1.7.3 is very old

knotty quartz
#

My friend is asking how you import discord on discord.py and Idk because I use discord.js

earnest phoenix
civic scroll
eternal osprey
eternal osprey
sharp geyser
#

it fixes everything

earnest phoenix
sharp geyser
#

Alright

dry imp
eternal osprey
tepid totem
#

Helloo

void pier
#

Good morning, so I'm using wordpress to create a website, there is a plugin called WooCommerce, which you can sell things on the website with it.

So I wanted to put it in my bot for when someone buys the bot to receive a signal and send a message, but I have no idea how to make a WooCommerce api keep checking every hr, it would be like the messageCreate event, that when someone sends a message the bot automatically identifies that someone sent it, but I don't know how to make this system keep checking if someone bought it, could someone help me?

the documentation is this: woocommerce.github.io/woocommerce-rest-api-docs

I don't speak English, so if the translator made a mistake, I'm sorry

earnest phoenix
#

Just create a custom PHP webhook that is getting triggered upon purchase, you won't need to make any requests from any bot

lyric mountain
rustic nova
#

gotta love stepping into walls

#

out of context

civic scroll
#

@rustic nova gaming?

rustic nova
#

gaming.

daring apex
#
const Discord = required ('discord.js')
const client = new Discord.Client()

client.on("ready", () => {
  console.log(`Logged in as ${client.user.tag}!`)
})

client.on("message", msg => {
  if (msg.context === "!hello") {
msg.reply("Hello")
}
})

client.login(process.env.TOKEN)```
#

I need help ^

cyan bane
#

can anyone help me

#

to make markdown

#

bot info

daring apex
cyan bane
#

can anyone help me
to make markdown
in top.gg
bot info

daring apex
#

How to

spark flint
#

bruh mr doge did you really move from python to js

#

you still need to learn the language

cyan bane
#

🥲

daring apex
spark flint
#

not really

#

discord.py is pretty much all prebuilt for you, discord.js is more like a jigsaw puzzle as you have to build command handlers etc

#

yes

spark flint
daring apex
#

And in python that discord. Ext is kind of difficult

cyan bane
spark flint
#

i haven't made a py bot in like 6 months but im pretty sure its ```py
from discord.ext import commands

client = commands.bot(prefix="!")

@client.event
async def on_message(message):
print(message)

client.login("TOKEN")```

spark flint
#

yes