#development

1 messages Ā· Page 51 of 1

ancient nova
#

ayyy yooo

#

i just discovered the best samsung feature ever

boreal iron
#

it works properly?

ancient nova
#

yeah

#

did you guys know this was possible

#

like dammmmm

#

😩😩😩

#

you can now split screen between two apps

lyric mountain
#

ye, been using that since I bought my xiaomi

#

tho I use mostly the poppable view feature

ancient nova
#

yeah I saw that too, it's also pretty cool

astral path
#

my moto e4 can do that too

lyric mountain
#

I think that was added on android Q

#

not a brand-specific thing

astral path
#

yup

ancient nova
#

but that's also why android > apple

cinder patio
#

There's no way includes or any other built-in method which accepts a string builds a regex from that string

lyric mountain
#

replace

#

and yes, includes doesn't

earnest phoenix
lyric mountain
#

for regex there's match or smth

sick agate
#

i have enjoyed multitasking on my iPad for years

earnest phoenix
#

It just got improved with Android 10 or 11 I believe

#

I do agree it's pretty nice, just never used it

#

Same with the "one hand" mode

#

That thing, Discord doesn't really support it well

ancient nova
#

can't figure out how to turn it on on my new phone tho

earnest phoenix
#

I suppose it's because of the React-Native rewrite, it's not polished yet

#

It used to work well with the Java version

earnest phoenix
#

Literally takes me minutes to get it enabled

lyric mountain
#

tho for me it's kinda useless since my fingers are big

earnest phoenix
#

I just use normal mode with one hand

lyric mountain
#

but I can see why it exists lmao

earnest phoenix
#

Not hard to use when you've been doing it for years

lyric mountain
#

I've met some people whose thumb does not reach the other side of the screen

#

and no, they weren't kids

earnest phoenix
#

lmao

ancient nova
#

I can use the whole keyboard with one hand without using the one-handed mode šŸ˜Ž

ancient nova
lyric mountain
#

ye, u can adjust it

earnest phoenix
#

Yeah it's not that hard

lyric mountain
#

goes all the way down to 50%

ancient nova
#

but idk how to enable it, I used to do it on my old phone by holding down the middle button and sliding to the bottom left corner

lyric mountain
#

a feature I find quite neat is the dual-phone mode

ancient nova
#

it doesn't work with my new one

lyric mountain
#

I can set two patterns, one for each "phone"

#

and neither can see the other side

#

tho I don't see myself ever using it, but it's neat if someone gets stolen frequently

#

or if you have *ahem*, relationship issues

ancient nova
#

just got it working

#

nice

ancient nova
#

šŸ’€

#

I wish I didn't see it

earnest phoenix
#

Can anyone help? I'm getting this error

node --no-warnings index.js

0=======================0
|    Events     | Stats |
|===============|=======|
| guildmember   | āœ…     |
| ready         | āœ…     |
| slashcommands | āœ…     |
0=======================0
0========================0
| Slash Commands | Stats |
|================|=======|
| help           | āœ…     |
| invite         | āœ…     |
| ping           | āœ…     |
| role           | āœ…     |
0========================0
/home/runner/HellStorm/events/ready.js:29
  client.channels.cache.get(config.mcplayChannel).setName(playersChannelName)
                                                 ^

TypeError: Cannot read properties of undefined (reading 'setName')
    at updateChannel (/home/runner/HellStorm/events/ready.js:29:50)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
exit status 1
lyric mountain
#

did you clone "your" code from somewhere?

earnest phoenix
#

No

#

Do you know of a way to fix the output?

#

I’m trying to use the channels edit feature and it isn’t really working

wheat mesa
#

Channels are not guaranteed to be cached

lyric mountain
#

client.channels.cache.get(config.mcplayChannel) returns undefined, you should always check if a channel exists before using it

boreal iron
wheat mesa
#

Fetch the channel

boreal iron
#

I assume the var in the config isnot set or wrongly set

wheat mesa
#

Either that, or the channel is not cached

lyric mountain
# boreal iron Not only once

also the fact most stuff is using a config file (not much reason to have one if it's for a private bot) and the step-by-step comments

boreal iron
#

Well fake got a config file, too freerealestate

wheat mesa
#

Fake is a pro though

boreal iron
#

True story

#

But regarding comments…

#

Keep Bae’s code and comments in mind

wheat mesa
#

Bae comments WAY too much

#

Granted sometimes it’s helpful to understand what his 5 billion character regex does

boreal iron
#

Regex is like math

#

You either understand it and can use it or not

#

But yeah reading absurdly long regex is like reading an alien language

wheat mesa
#

I can see the usefulness of regex

#

But when it becomes too complex, I feel like it might be easier to parse at least part of whatever you’re matching before doing a regex tbh

boreal iron
#

Yeah pretty much

earnest phoenix
#

Flashbacks to Discord mobile using a regex-based parser for their markdown and syntax highlighting

#

Took me weeks to implement the JavaScript and TypeScript highlighters for it because of how scuffed it was

wheat mesa
#

I hate when people use regex for the wrong reasons

#

I can see how incredibly useful it is for matching basic things and validating forms for frontend and such, but once you start getting into HTML regex parsers I think it’s being used for the wrong reason

#

Although regex is very very very useful for describing the syntax of languages, not necessarily parsing them though

earnest phoenix
wheat mesa
#

Awh hell nah

#

ā€œSimpleASTā€ meanwhile the world’s most complex regex is being compiled for 43 minutes and 22 seconds

earnest phoenix
#

Discord's regex-based parser also prevented me from highlighting template literals inside template strings, since it needs outer and inner global checks which is basically impossible with regex alone

wheat mesa
#

Regex isn’t meant for non context free grammars afaik

#

That’s why it’s difficult

#

Because you need lookahead and context to parse things sometimes

#

And regex just isn’t the proper tool for that

earnest phoenix
#

Indeed, but Discord went with it anyway

#

They should've used vendors/grammar-based parsers

wheat mesa
#

I can see why they went with regex

#

Each language would require a different parser to be written for it and those take quite a bit of time

#

Especially with the complexity of certain languages

earnest phoenix
wheat mesa
#

But honestly discord should’ve just used a lib maintained by someone else

#

So that the masses can contribute to syntax highlighting

earnest phoenix
wheat mesa
#

Yeah fair

#

Imo regex is like python

earnest phoenix
wheat mesa
#

Good concept at its core but people tend to use it for the wrong purposes

earnest phoenix
#

Honestly that concept applies for all programming languages DogKek

wheat mesa
#

Yeah that’s fair

#

I kinda want to write some code but I’m a bit burnt out

#

And I don’t know what to work on

#

I don’t wanna work on my lang rn cus I want to keep motivation for it

#

Maybe I’ll just play terraria

earnest phoenix
#

The good ol' Terraria

wheat mesa
#

Calamity mod 😈

#

Started a playthrough on Saturday

#

Just beat plantera

earnest phoenix
#

Nice

sharp geyser
#

@wheat mesa I bought terraria like youve been telling me to

wheat mesa
#

GOOD JOB

#

whoops cc aps

sharp geyser
#

lol

boreal iron
#

Damnit

#

I was telling you to call me daddy but you didn’t

#

Wouldn’t have cost you anything

radiant kraken
#

easy

#

sanest regex developer

leaden ibex
#

Thats my code 😢

#

I mean i copy my bot code and rùn it

lyric mountain
#

Copy from where

leaden ibex
#

My files

#

My code bro

lyric mountain
#

But didn't u say u forked it?

leaden ibex
#

Ahh

#

I forked my code from replit

#

In windows we copy and in replit fork means make anew project with this code

#

@lyric mountain wanna test bot?

lyric mountain
#

No

leaden ibex
#

K

#

Now its in 39 server's

civic scroll
#

nice

deft rock
#

css jail?

quartz kindle
#

css jail

deft rock
#

yeah whats up with that?

indigo apex
#

Could I get any suggestions as to what replace Pug with? Plain html is terrible + pug seems very buggy

earnest phoenix
#

@civic scroll since you are angular nerd

<li class="mr-6 my-2 md:my-0">
  <a routerLinkActive="text-primary-fg-color border-primary-fg-color" [routerLinkActiveOptions]="{exact: true}" routerLink="/logs" class="block py-1 md:py-3 pl-1 align-middle text-gray-500 no-underline hover:text-gray-100 border-b-2 border-gray-900 hover:border-gray-100">
    <i class="mr-3 text-primary-fg-color"><fa-icon [icon]="faFolderOpen"></fa-icon></i><span class="pb-1 md:pb-0 text-sm">Logs</span>
  </a>
</li>

Why doesn't the routerLinkActive values get marked as !important or whatever is needed to overwrite the styling when it's not on the route.

Used to work 12 months ago when I was working on the project, yesterday updated packages and now it doesn't work. The classes are applied but they don't overwrite the default. (Using Tailwind)

rustic nova
#

there's something else marked as ! important then

earnest phoenix
#

It simply doesn't apply because the other one is not getting removed

#

text-gray-500 is the styling when not on route and text-primary-fg-color is when on route

#

Should look like that

#

Instead of the current

#

i could add custom css with like .active and use !important but what's annoying me is that it worked before and using custom css is not convenient

sharp geyser
#

Sounds like a peculiar problem

civic scroll
#

or am i missing something

stiff dust
#

Hello everyone silly question about js
I have const array = [1,2,3,4,5]
I know 3 is in the array now how can I find the index of it?

stiff dust
#

tnx

#

and whats the different of indexOf and findIndex?

cinder patio
#

findIndex accepts a function

stiff dust
#

ok tnx

earnest phoenix
#

the classes are applied

#

they just don't overwrite the default ones

earnest phoenix
#
<a routerLink="/user/bob" routerLinkActive="class1 class2">Bob</a>

Other projects also use that

cinder patio
#

your first issue is that ur using Angular

tepid sequoia
#

my webhook dont working.

#

Im hosting bot on localhost (windos 11 rdp machine)

#

bot don't want to post when someone vote

whole knot
#

"Doesn't work" is not really helpful. Please share the structure of your code and try to explain what you tried to do

tepid sequoia
#

Wait a sec

#

dm?

#

or here?

whole knot
#

Here, as others may want to help too

tepid sequoia
#

this doesnt working

#

where problem can be

#

someone told me its because im hosting on localhost

civic scroll
#

idk what affected those tho
normally i would use a custom class for that

earnest phoenix
#

like make an active class in custom css that is text-primary-fg-color border-primary-fg-color

#

because

.active {
    --tw-border-opacity: 1;
    --tw-text-opacity: 1;

    border-color: rgb(159 177 176 / var(--tw-border-opacity));
    color: rgb(159 177 176 / var(--tw-text-opacity));
}

works but it's kind of annoying, specifically when changing colors in tailwind config

pearl trail
#

based on ur statement

earnest phoenix
#

Found a workaround

#

probably shit but it works

#

Basically just did

colors: {
  "primary-fg-color": "var(--primary-fg-color)",
  "primary-fg-color-dark": "var(--primary-fg-color-dark)",
  "primary-fg-color-light": "var(--primary-fg-color-light)",
  "accent-fg-color": "var(--accent-fg-color)",
  "accent-fg-color-light": "var(--accent-fg-color-light)",
  "bg-color": "var(--bg-color)",
}

and added

.root,
:root,
#root,
#docs-root {
  --primary-fg-color: #9fb1b0;
  --primary-fg-color-dark: #434848;
  --primary-fg-color-light: #5b6262;
  --accent-fg-color: #c1d8d8;
  --accent-fg-color-light: #daf1f1;
  --bg-color: #2e303e;
}

to the global css file KEKW

civic scroll
earnest phoenix
#

ah true that exists completely forgot it

grizzled finch
#

Jh

deft rock
#

Id link an opinion, I made a bot in V13 (d.js) Should I update it all to V14 or just keep 13 till it dies

surreal sage
#

no way I actually did a switch statement with a random number

#

And case (e.g 40)
case (e.g 39)
case (e.g 38)
case (e.g 37)

lyric mountain
#

switch-case does accept random number for input

#

just not for cases

wheat mesa
#

Documentation

pure sage
#

im using firebase as database but it's limited
please can someone tell me a good and unlimited datadabase
for free šŸ™‚

lyric mountain
#

any + hosted locally

pure sage
lyric mountain
#

or if u can't use service-based databases, use file-based options

lyric mountain
pure sage
lyric mountain
#

yes

pure sage
#

but idont how ican insert it in the the databse

#

with php

#

im a front end dev

lyric mountain
#

the same way u do currently but using localhost

#

or didn't u even start using it?

pure sage
#

ok

eternal osprey
#

hey guys

#

in c++ i have this enum: Month easter_month

#

where easter_month is a certain month like January etc, that starts at count = 1;

#

How would i go forth one month? So ideally something like easter_month++?

lyric mountain
#

I don't think u should start January at 1

eternal osprey
#

So it would for example go from January -> February

eternal osprey
lyric mountain
#

But well, simply make a reverse method to get by value

eternal osprey
lyric mountain
#

Put that ain't enum, that's a magic constant

lyric mountain
#

Then iterate over the fields and get the one with that value

quartz kindle
#

you have an enum of strings? or what?

eternal osprey
lyric mountain
#

No it isn't

quartz kindle
#

he probably meant for you to create it

lyric mountain
#

You'll be the one making it

quartz kindle
#

can you show the actual code?

lyric mountain
#

Also what tim pointed is a thing, why do u need to even get the variable?

eternal osprey
#

This is the enum:

#
enum Month
{
  January = 1,
  February,
  March,
  April,
  May,
  June,
  July,
  August,
  September,
  October,
  November,
  December
};
lyric mountain
#

Month.values()

eternal osprey
#

i was thinking can't i just use the static_cast

quartz kindle
#

so basically thats an enum to get the month number using the month name

#

for example Month.May === 5

eternal osprey
#

like: static_cast<Month>(value++)

lament rock
#

enums are already auto incrementing off of the previous value cast

eternal osprey
#

so basically Month.January === 1

eternal osprey
#

as i want to add 7 weeks to a certain day-month value,

lyric mountain
#

Uh oh

lament rock
#

Then you can just set the month you want as a specific number like for instance, May = 7 (which is incorrect, but just an example)

lyric mountain
#

So yk months might not always have 30 or 31 days right?

lament rock
#

7 weeks is about 2 months

eternal osprey
#

I did it using this: js int carnival = 49; int counter = 0; int daysinmonth = number_of_days_in_month(year, easter_month); while(counter != carnival){ counter++; if(easter_day != 0){ easter_day--; }else{ easter_month = static_cast<Month>(easter_month + 1); daysinmonth = number_of_days_in_month(year, easter_month); easter_day = daysinmonth; } }
and this is my whole function

eternal osprey
#

using switch cases, accounted for leap years as well

lament rock
#

perhaps I misunderstand the situation

eternal osprey
#

I basically have to code a function that will calculate when carnival is

#

based off the easter day and month

#

carnival is always 49 days before easter.

lament rock
#

That's... Okay then

eternal osprey
#

So I made this function. It would keep on removing days (and if the day is 0, remove 1 month count and redefine the new month and it's day)

eternal osprey
lament rock
#

Uh idk

#

it's one approach

quartz kindle
#

well, the math approach is always faster

lyric mountain
#

For sure

quartz kindle
#

ie, subtract number of days in the current month from 49

#

instead of looping one by one

eternal osprey
#

Thats the thing

#

i cannot use any packages

#

\0/

quartz kindle
#

if easter day is 15, just subtract that amount, 49 - 15 = 34

#

then subtract 1 month

#

no you're at day 34 of the previous month

#

now subtract the number of days in that month

#

if the month has 30 days, go back one more month, and subtract the remaining 4 days

#

basically you do 3 steps instead of 49 steps

#

using math and a couple ifs

eternal osprey
#
string show_carnival(int easter_day, Month easter_month, int year)
{
int carnival = 49;
int counter = 0;
int daysinmonth = number_of_days_in_month(year, easter_month);
while(counter != carnival){
if(easter_day != 0){
  easter_day--;
}else{
  easter_month = static_cast<Month>(easter_month + 1);
  daysinmonth = number_of_days_in_month(year, easter_month);
  easter_day = daysinmonth;
}
}
string date = easter_day + " " + easter_month;
return date;

}```why is this function not returning anything?
lyric mountain
#

infinite loop

eternal osprey
#
#ifndef TESTING
int main()
{
 
cout << show_carnival(6, January, 2000);
 
}
#endif
#

owh fuck i forgot to ad the counter increment

#

thanks kuu you rock

lyric mountain
#

lmao

#

btw, u can use for instead

boreal iron
#

Lies he doesn’t

lyric mountain
#

for (int i = 0; i < carnival; i++)

#

or omit carnival entirely and use 49 in place

eternal osprey
#

Owh that's really smart indeed

#

thanks!

lyric mountain
#

yw

eternal osprey
#

One issue tho, it says that construct null is not valid?

#
string date = easter_day + " " + easter_month;
return date;```this is what i am returning
lyric mountain
#

return easter_day + " " + easter_month instead

#

construct null?

eternal osprey
#

onstruct null*

#

still get the same error

lyric mountain
#

show the error

eternal osprey
#
return easter_day + " ";``` i used this for testing
#

M_construct null not valid

#

easter_day is an int here

radiant kraken
#

oh

#

you can't add an int to a string in C++

#

it's not like in dynamic languages like JavaScript

#

use std::to_string to convert the integer to a string

eternal osprey
#

owh wow really

#

my js knowledge really intervenes with c++ lmao

radiant kraken
eternal osprey
#

request for member error?

radiant kraken
#

no

eternal osprey
#

omg

radiant kraken
#

an int is a primitive type

#

its not an object, like in JS

eternal osprey
#

so it should be inside the ()

radiant kraken
#

yes

#

read the documentation for std::to_string

eternal osprey
#

awesome i love you rust

radiant kraken
eternal osprey
#
string show_carnival(int easter_day, Month easter_month, int year)
{
int carnival = 49;
int counter = 0;
int daysinmonth = number_of_days_in_month(year, easter_month);
while(counter != carnival){
 
if(easter_day != 0){
  easter_day--;
}else{
  easter_month = static_cast<Month>(easter_month - 1);
  daysinmonth = number_of_days_in_month(year, easter_month);
  easter_day = daysinmonth;
}
 counter++;
}
return "Day:" + to_string(easter_day) + "Month: " + to_string(static_cast<Month>(easter_month));
}
```hey guys, i think that i am almost done but i have a critical issue
#

if i input show_carnival(8, April, 2023); it returns me Day: 20Month:2

#

while the correct date should be 18:2

#

so it's off by 2 days

timber fractal
#

How do I join guilds for a user when they're authorized with my application with the guilds.join scope?

quartz kindle
#

day goes 2, 1, 0, 31

#

so make it easter_day != 1

eternal osprey
#

it's still returning me crazy results

#

wait let me get you an example

#

it seems to be working lol

#

tim i would honestly hug you

#

thanks

#
  easter_month = static_cast<Month>(easter_month -1);
  daysinmonth = number_of_days_in_month(year, easter_month);
  easter_day = daysinmonth;
}
}
return "Day:" + to_string(easter_day) + "Month: " + to_string(static_cast<Month>(easter_month));```i am having one last thing. I now get returned an actual number of easter_month, but shouldn't the static cast already convert that int to a Month?
#

So January for value 1 for example

hidden gorge
#

I want the bot to change its nickname on the server when the name is changed on the dashboard how could i make it do that?

quartz kindle
#

i dont think you can do that with an enum

neon leaf
#

ok, I got this button; how do I edit the text in js?

hidden gorge
astral path
hidden gorge
#

ok but would i do bot.setNickname?

quartz kindle
neon leaf
#

yes, in a <script></script>

#

I basically want to check if the user is already logged in

quartz kindle
#

you need to find the element using selector functions like getElementById or getElementByClassName or querySelector

#

then edit the innerText property

astral path
hidden gorge
#

This is what i have typed in for the settings

hidden gorge
astral path
#

actually, you'd have to get it as a guildmember, which i'm not sure exactly how you'd do, probably get the guild from the id or whatever then get the bot's user through the guild object, then call setNickname on that

hidden gorge
#

yeah

rustic nova
#

is that a http based bot?

#

or what is that

quartz kindle
#

for example

hidden gorge
quartz kindle
#

you can probably skip the fetch there as the bot member is usually cached

astral path
#

is that how your dashboard interacts with the bot?

hidden gorge
cursive musk
#

I'm trying to make a reaction role system, and I'm not sure what I'm doing wrong. I keep getting the error "Please Provide me with a valid message ID"

if (Object.prototype.hasOwnProperty.call(data, "send")) {
      //channel
      let channelValid = await guild.channels.cache.find(
        (ch) => `#${ch.name}` === data.sendChannel
      );

      let channel;
      if (channelValid) {
        channel = channelValid.id;
      } else {
        renderTemplate(res, req, "./new/mainreactionroles.ejs", {
          guild: guild,
          alert: `Please Provide me with a valid Channel`,
          emojiArray: EmojiArray,
          settings: storedSettings,
        });

        return;
      }

      let message;
      if (data.messageID) {
        try {
          const emojimessage = await channel.messages.fetch(data.messageID);
          message = emojimessage;
        } catch {
          renderTemplate(res, req, "./new/mainreactionroles.ejs", {
            guild: guild,
            alert: `Please Provide me with a valid message ID`,
            emojiArray: EmojiArray,
            settings: storedSettings,
          });
          return;
        }
      } else {
        renderTemplate(res, req, "./new/mainreactionroles.ejs", {
          guild: guild,
          alert: `Please Provide me with a valid message ID`,
          emojiArray: EmojiArray,
          settings: storedSettings,
        });

        return;
      }
astral path
# hidden gorge yes

so, you're trying to write the req.client.settings.set function for the given guild id and newname?

vivid fulcrum
#

it's just a visual thing in the client

cursive musk
astral path
hidden gorge
#

ok

cursive musk
#
if (Object.prototype.hasOwnProperty.call(data, "send")) {
      //channel
      let channelValid = await guild.channels.cache.find(
        (ch) => `${ch.name}` === data.sendChannel
      );

      let channel;
      if (channelValid) {
        channel = channelValid.id;
      } else {
        renderTemplate(res, req, "./new/mainreactionroles.ejs", {
          guild: guild,
          alert: `Please Provide me with a valid Channel`,
          emojiArray: EmojiArray,
          settings: storedSettings,
        });

        return;
      }
#

I'm not sure what I'm doing wrong.

#

I'm trying to make a reaction role system.

eternal osprey
#
tring show_whitsuntide(int easter_day, Month easter_month, int year)
{
int carnival = 50;
int counter = 0;
int daysinmonth = number_of_days_in_month(year, easter_month);
while(counter != carnival){
 counter++;
if(easter_day != daysinmonth){
  easter_day++;
}else{
  easter_month = static_cast<Month>(easter_month + 1);
  daysinmonth = number_of_days_in_month(year, easter_month);
  easter_day = daysinmonth;
}

}
return "Day: " + to_string(easter_day) + " Month: " + to_string(static_cast<Month>(easter_month));
}```now i need to calculate 50 days after a given date for example 18 september. Right now it's returning me day 34: month 34.
#

Why?

rustic nova
#

are you still trying to manually parse times?

spark flint
#
new Date().toLocaleString("en-GB", { timeZone: "Europe/London" })``` is returning `28/09/2022, 19:23:34`, which doesn't have PM at the end so its returning Invalid Date when trying to get timestamp
#

but js new Date().toLocaleString("en-US", { timeZone: "America/New_York" })
returns 9/28/2022, 2:23:54 PM, which works

solemn latch
#

you can add 50 days to any date object just by adding the current date(day of the month) + 50.

neon leaf
#

how can I center this?

solemn latch
#

I personally would use a flexbox.

neon leaf
#

for some reason the text is now weird

compact pier
#

I how I can prevent animation started before page fully loaded

#

cause I checking the event by checking if it is in the view port

#

and when my page load, the component was loaded in the view port

lyric mountain
eternal osprey
eternal osprey
#

For some reason it displays me 34:34 or 64:64 etc etc

#

Only thing I did was get the code of previous functions and instead of incrementing it we are decreasing the days and months

quartz kindle
#

not daysinmonth

astral crown
#

How can I switch to slash commands so I don't need intent privileges?

I coded in Python and I am using the discord library.

finite frost
#

Hi..?

lament rock
deft rock
#

What is a common cause for Unknown Interaction even tho the interaction was a command?

astral crown
wheat mesa
deft rock
#

could this happen when a command is spammed? for say /server-info then /ping etc

wheat mesa
#

I don’t see why it would no

lament rock
# astral crown I can do that but how to get rid off intents?

in your client where you pass the intents you need, just supply what intents you need and don't include the ones you don't need anymore.

If you mean what intent is tied to getting interaction create, there is none. You get interaction events even with no intents

wheat mesa
#

Other than your bot being overwhelmed with requests and not responding within 3 seconds of the original interaction

#

But that shouldn’t happen usually

deft rock
#

ok, @lucid tapir tried my bot and it didnt work and my error was Unknown Interaction he states that he did all the commands

lament rock
#

Unknown interaction can happen if you don't respond to one in time

astral crown
wheat mesa
#

The first thing you should do when receiving an interaction is defer it in 99% of cases

deft rock
lament rock
#

not responding in time can especially happen if your bot is getting interactions through the gateway and is forced to reconnect and unfortunately as an interaction comes through

lament rock
#

The most sure-fire way to get interactions on time is through the http route method instead of through the ws connection

wheat mesa
#

I have a feeling he’s not deferring is the issue

lament rock
#

and then from there, it's all down to how quick you can route that message to your bot and properly respond to interactions

#

should the process to respond need to take some time due to async tasks, defer it and then edit the original response later

deft rock
lament rock
#

realistically, what you could do is use worker threads to handle the tasks on the website end so that the HTTP response can be the result, otherwise, you'd need to use a rest wrapper to respond which is fine and is what I do along with getting messages over the gateway on a per cluster basis

#

I just wish Discord didn't tell me to resume so often because the process of resuming sometimes take more time than how long I'm allotted to respond to an interaction

#

what language and library are you using?

lucid tapir
#

@deft rock ^

deft rock
#

Discord.js and Javascript

lament rock
deft rock
#

what?

lament rock
#

Dumb question I guess

#

how do you receive your interactions? via gateway or http

quartz kindle
#

you cant read other messages

deft rock
#

so id assume gateway

astral crown
lament rock
#

client.on("interactionCreate"… ?

lament rock
astral crown
#

To read the command

deft rock
quartz kindle
lament rock
# deft rock yes

ok so Discord tells your websocket to reconnect quite frequently. If you're using the most up to date discord.js, it should happen less often because Discord is awesomeā„¢ļø and the times where you literally can do nothing to ensure the interaction is responded to is lessened

quartz kindle
#

the slash command has the command

lament rock
#

if you know how to do http routing and such, then go for that for sure, otherwise, suppress the errors and live happy and in blissful ignorance

lament rock
#

You might be fine

#

so just ignore the errors if it works most of the time

deft rock
#

its 14.3.0 rn right?

quartz kindle
lament rock
#

idk I don't use discord.js. I use libs I make myself

deft rock
lament rock
#

that's the drawback of doing interactions over the gateway

#

the upside is automatic clustering/sharding of handlers

deft rock
#

how would I go about doing it http?

quartz kindle
#

first of all you need a domain with ssl

lament rock
#

make a website and make a route for Discord to post to

#

that too^^

rustic nova
#

Cloudflare does it

#

just put your Webserver/routes behind Cloudflare

deft rock
#

ok, bout how do I route it

quartz kindle
#

stuff like replit also works

#

their app url has ssl

deft rock
#

I have replit lol

#

hate*

quartz kindle
#

lmao

deft rock
#

ever since they changed it none of my apps etc work anymore 😦

lament rock
#

skill issue

deft rock
#

just too lazy to update them

rustic nova
#

I generally suggest looking into http based networking first before directly going for http only bots

quartz kindle
#

then you need a library to handle discord's security stuff, for example you have to validate pings, invalid messages, security headers, signature verification

#

unless you wanna do that yourself like i did lel, feel free to use mine

lament rock
#

pain and suffering

#

Im gonna continue to have them piped over the socket because it doesn't happen often enough for my users to complain and they usually just try again and it works

#

most of my logs are just unknown interaction

eternal osprey
lament rock
#

in some cases, it's my own fault like trying to edit the original response without deferring

#

oh also tim, do you know any good wrappers for node 18 around libmp3lame

#

work time

#

save me from the kids screaming in my ears for 6h straight

quartz kindle
#

lmao

#

never worked with audio so idk

#

my answers would be the same as googles

quartz kindle
# eternal osprey huh wdym

in the last code you posted you said youre now going forward in time, meaning days should go 30, 31, 1, 2, ...

#

but when the day is equal to the number of days in the month, you advance it but set the current day to be equal to the number of days in the next month

#

meaning it will go 30, 31, 30, 31, 30, 31

eternal osprey
#

How would i check if a certain cin variable is an int?

#
void show_holy_days(int year)
{

  while(// the cin isnt an int){
  cout << "Welcome User! Please input a year to calculate all Christian Events: \n"<<endl;
  cin >> year;
  }```
quartz kindle
astral crown
rustic nova
#

slash commands do not need message intents

spiral crag
#

hey guys i use discord.py, i use the "on_message" event, i get the too many requests error even though trhere are barely new messsages in the server

earnest phoenix
#

Code? Traceback?

#

Will help people to help you bunNod2

astral crown
#

Does slash command require administration permission?

spiral crag
# earnest phoenix Code? Traceback?
@client.event
async def on_message(message):
  if message.author.id ==  someid:
    await message.channel.send('message')
    await message.channel.send('message2')
rustic nova
#

the bot responds to itself

earnest phoenix
rustic nova
#

@spiral crag make sure that the author is not the bot

spiral crag
#

so it cant be the bot

rustic nova
#

I'd still suggest to catch it

spark flint
#

if message.author.bot isn't it?

#

that would stop any bot

rustic nova
#

what's the traceback

#

which line is it caused by

spiral crag
#

i will send it

rustic nova
spark flint
#

that would make more sense

spiral crag
#
discord.errors.HTTPException: 429 Too Many Requests (error code: 0): <!DOCTYPE html>```
spark flint
#

otherwise someone could use luca for example to trigger the bot troll

spiral crag
rustic nova
#

but to catch it, just check if the author is the bot itself

astral crown
earnest phoenix
#

This is by default, and those are scopes not permissions

astral crown
earnest phoenix
#

It is given by default iirc

rustic nova
#

scope = a definition of your bots purpose, such as "bot" being a bot on the server, "bot.commands" being commands on that bot on the server

permissions = something that grants your bot to do certain things, this mainly applies to bots

astral crown
#

I understand thanks Aurel

astral crown
#

I am getting this error. I don't think the scope was given when it was added to the servers.

earnest phoenix
#

Add the commands globally to the bot

#

And yeah, the scope is enabled by default as said by Discord engineers

astral crown
earnest phoenix
#

There are guild slash commands and global slash commands

astral crown
earnest phoenix
#

Awesome kryptonHype

neon leaf
#

ok, I got an array with values of a user, I know how to parse it and all but how do I make a div for every of the Values? I know how to loop, but how do I create the divs in js?

spark flint
#

what would the best way to automate timezone changes be

#

I;m making a timezones command to get timezones from the format CST, BST etc, how can I easily convert with Node.js?

eternal osprey
#

hey guys

#
bool is_leap_year(int year)
{
  cout << year % 4 << endl;
  cout << year % 100 << endl;
   cout << year % 400 << endl;
  return ((year % 4 == 0) && (year % 100 != 0) && (year % 400 == 0)) ?  true :  false;
}
```how can 2020 output false while it should infact be a leap year
#

i logged every part of the conditional and got:

0
20
20

#

i see the issue! I must change it to c++ return ((year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0)) ? true : false; right

neon leaf
quartz kindle
#

you mean the value of appname changes by the time the function is run?

neon leaf
#

instead of dogo(data[times].appname) is should be dogo('OMMC') in this case

quartz kindle
#

well you can try stringifying it

#
button.onclick = `function() { dogo(${data[times].appname}) }`
neon leaf
#

oh yeah, I dont know why that didnt work before, but it does

#

😐

#

ah, nvm. just removed that whole function() { part

quartz kindle
#
button.onclick = `dogo(${data[times].appname})`
#

yeah

raw nest
#

General question.
What javascript backend frameworks do you guys use or recommend? I love ExpressJS and it's hard to choose something different xD but the thing is that ExpressJS hasn't gotten any updates since years I guess.. ThinkO_O I mean it still does his job but maybe something newer and actively maintained would be better.

I also used NextJS alot and I really love it but I chose to separate backend & frontend this time. (Maybe also thoughts about that?)

hidden gorge
cinder patio
eternal osprey
#

https://hatebin.com/kfkwpngzfs

could anyone help me. I am trying to print a calendar into my terminal,. I chose September as initial month, but instead of starting at thursday it starts at wednesday as you can see and it also prints all numbers below each other instead of next to each other

raw nest
cinder patio
#

No I'm saying if you'll be using React on the front-end Next.js is your best choice

hidden gorge
spark flint
#

floosh

boreal iron
#

FINALLY amazon delivered the right cable

#

not to say it has been the third attempt

#

and FakE can finally use the product he bought weeks ago

#

some sort of irony

flat copper
#
let path = `https://${url}/${data.path}`

    let mp3 = fs.createWriteStream(data.slug + ".mp3")

    request
    .get(path)
    .on('error', function(err) {
      console.log(err)
    })
    .pipe(mp3)

i want to save this mo3 file in a directory

spark flint
earnest phoenix
flat copper
#

oki

quartz kindle
#

restana, 0http

#

rayo

#

if you want stupid performance check out sifrr

#

but sifrr uses a cpp server, so its not pure nodejs

raw nest
raw nest
raw nest
cinder patio
#

but literally why next.js does so much for you

#

SSR and numerous optimizations

#

built-in router

raw nest
#

Ye I absolutely love NextJS, still I want to experience something new and learn new things. Like always everything has pros and cons xD. I really appreciate your heavy suggestion to NextJS and it's hard to resist lmao

raw nest
quartz kindle
#

now i just use raw node http without any framework

raw nest
quartz kindle
#

yeah it was good

raw nest
#

and why now just raw node http?

quartz kindle
#

gives me more control over everything

spark flint
#

does anyone know the best way to get the current zone in different timezones with Javascript?

#

The timezone format is like BST, GMT etc

raw nest
#

thanks^^

spark flint
#

yes

#

im bad at writing

quartz kindle
#

accronyms like GMT BST etc ate not official and not unique either

#

there are multiple timezones which use the same acronym

#

CST

#

central european standard time and also china standard time

spark flint
#

hmm

quartz kindle
#

and other cases like that

#

so its not correct to use them like that

eternal osprey
#

Hey is there anyone who could hlep me fix the spacing in this calendar? Also the 7 must be under sunday, not sure why it isn't!

#
 int days_in_month = calculate_days_in_month(month, year);
 int day = 0;
 int counter = 0;
 string month_begins_at = "";
  string weekdays = "Mon Tue Wed Thu Fri Sat Sun";
  string calendar = "";
int begindate = dayNumber(days_in_month, month, year);
 cout << begindate << endl;
  switch( begindate ) 
        {
            
           etcmetc
             case 5: 
            month_begins_at = "Wed";
            calendar = "";
            counter = 5;
            break;
             case 6: 
            month_begins_at = "Thu";
            calendar = "";
            counter = 4;
            break;
             case 7: 
            month_begins_at = "Fri";
            calendar = "";
            counter = 3;
            break; 
        }
 cout << weekdays + "\n";
 bool starter = true;
 while (day != days_in_month){


 if(day == counter){
starter = false;
 }
 if(day % 7 == 0){

    cout << "\n";
    
  }
 if(starter){
   cout << "   ";
 }else{
cout << day << "   ";
 }
  
 
  day++;

 }

rigid maple
#

node-canvas There are white lines behind the black lines. I want to cut where the black lines and white lines intersect so the black lines will act as a kind of eraser and will not be visible. Any ideas how I can do this?

lyric mountain
#

iterate over each pixel, erase where pixel color is #000

#

told u already

rigid maple
#

the drawn line may also be black in color

eternal osprey
rigid maple
#

because there may be black places in the background and the line drawn by the user may also be black

quartz kindle
rigid maple
#

That's the part I'm having trouble with.

quartz kindle
#

everything that is drawn is forgotten, there is no way to remember it

#

unless you use multiple layers

#

with multiple canvases

earnest phoenix
#

How do I transfer database from MongoDB to JSON

rigid maple
#

I'll try to take the drawing I made on the web as a data:image and send it like that, maybe that's how it works

earnest phoenix
#

Replit

quartz kindle
viscid rose
#

hiring bot dev

lyric mountain
#

use 2 canvases

#

either that or set a clip color

#

but that will result in that color being always removed

rigid maple
#

Can I have the eraser and drawing erased after drawing them on separate layers?

knotty quartz
#

Hi

lyric mountain
#

I suppose both would be the same dimensions

rigid maple
#

I will try

spark flint
earnest phoenix
#

wha

spark flint
#

bruh is discorddead

#

-ping

#

moyai

#

oh luca offline

#

rip

earnest phoenix
#

man

lyric mountain
#

brevs cant do commands ig

spark flint
#

no its down

earnest phoenix
#

bot is just offline

#

we can

spark flint
lyric mountain
#

a

spark flint
#

anyone can use -ping, its not responding

earnest phoenix
#

yeah that too

#

yeah that too

spark flint
#

this is a true

#

moment

earnest phoenix
#

Ian is busy in florida

#

Or somewhere near there

earnest phoenix
gilded plankBOT
#

@viscid rose

You seem to be asking for something you don't have experience for or something that hasn't been done yet, but really need for your bot/server.
You can hire developers from Fiverr or Freelancer to code the things you need for your bot/server.

rigid maple
lyric mountain
#

canvas only has a single layer

#

it's not like gimp/photoshop where a single image can have many layers

rigid maple
#

I can delete it as you can see above (web-canvas)

lament rock
#

you have to start from the bottom (now we here)

lyric mountain
#

actually if u were to make gimp/photoshop using js, you'd use many canvases

#

one for each layer

lyric mountain
rigid maple
lyric mountain
#

it's either 1 or 0, there are no in-betweens

#

either black or red

#

if u use black for eraser, it'll not know what's "below" because there's no below

rigid maple
#

I am using globalCompositeOperation - destination-out for the above

lyric mountain
#

sigh

rigid maple
#

but I don't have such option in node-canvas

lyric mountain
#

you're missing the point

#

a canvas is an image, period

#

images only have a single layer (although they can have many channels)

#

once something is drawn, whatever was in that space is overwritten

rigid maple
#

oh

#

i do it

lyric mountain
#

there are no below or above

rigid maple
#

😃

#

I used ptctx.globalCompositeOperation = 'destination-out'; while opening a new path for the eraser and printing the lines

#

this result

lyric mountain
#

compositing isn't multi-layer or anything like that

#

it just tells the canvas what to do when changing pixels

#

destination-out means the newer pixels will remove the current pixels (iirc)

#

that wont erase, it'll just set the pixels to background color

#

I mean, it is technically erasing

eternal osprey
#

anyone who knows how i can fix these spacing errors

lyric mountain
#

use padding

eternal osprey
#

this is a terminal program in c++
how would i use padding

lyric mountain
#

1 instead of 1

lyric mountain
eternal osprey
#

love you so much kuu

#

but wait

lyric mountain
#

iirc u can use printf("%2s", value)

#

ah wait, that's C

eternal osprey
#

I am just literally using day++ in a while loop

#

so how would i go with using that 1 you told me?

lyric mountain
#

nope, it works

lyric mountain
eternal osprey
#

That would do the same with for example 18. This would still give the spacing problems

lyric mountain
#

nope, padding isn't spacing

#

padding is "reserving" a character space

rigid maple
#

thank you very much for your help

lyric mountain
#

note how it stays '23' for the first 2 images, but becomes ' 23' for the third

#

because I reserved 3 characters (it was 1 and 2 for the first images, but 2 chars >= 1 | 2)

eternal osprey
#

i am using c++ tho, isn't printf for c?

lyric mountain
quartz kindle
#

everything that C can do C++ can also do

#

its basically C with more features

lyric mountain
#

funny because C++ is still C but with incremented value

#

idk if that's an intended pun

#

++C would be D

eternal osprey
#

Yeah this method totally fucked my output tho

lyric mountain
#

not all of it

#

simply use print(" ") for day < 1

eternal osprey
#

thursday*

lyric mountain
#

ik

#

u need to adjust ur leading space

#

and use %3s for each day

#

since weekdays have 3 chars

eternal osprey
#

we are printing ints

lyric mountain
#

then use %3d

eternal osprey
#

ah i understand it now. So d stands for double? I for ints?

lyric mountain
#

d for decimal actually

#

digit

#

I forgot format string doesn't care abt doubles or ints

#

use d for any number, s for any string

eternal osprey
#

oowh i see

#
if(day == counter && initialze){
starter = false;
day = 1;
initialze = false;
daycounter = 1;
 }
if(day == counter+1){
  cout << "\n";
  daycounter = 0;
}
 if(daycounter % 7 == 0){

    cout << "\n";
    
  }
 if(starter){
   cout << "   ";
 }else{
printf("%3d", day);
 }
 
  day++;
  daycounter++;


 }```whatever i try to do, the format is still fucked
lyric mountain
#

had to zoom out

#

apparently, it has both

lyric mountain
#

ur forgetting to also include the margin

#

so u need to do printf("%3i ", day)

#

note the trailing space

#

and use cout << " "

eternal osprey
#

ah i see

#

awesome, it finally works!

#

it only emits one big space after the 4

#

i assume there's padding for the space as well?

lyric mountain
#

the 4?

eternal osprey
#

the "\n" i mean

lyric mountain
#

that's because it'll include the margin for the last item too

#

u can put a conditional for the last day of the week to not include it, but it doesn't matter much

#

you'll miss printf when u return to js btw

#

it's an amazing tool, especially when u need to print colors or other hexadecimal values

#

printf("#%60X", color)

#

done, color printed in #FF1122 format

eternal osprey
#

So i changed the month names to 2 characters only. Thus i also changed the day outputs to %2i.

#

However, now it seemds to go out of bound like this

lyric mountain
#

u need to adjust the leading

earnest phoenix
#

Python?

lyric mountain
#

no by far

#

simply use printf("%Ns ", "") for the leading spaces

#

N being ur leading

#

u can even make it dynamic

eternal osprey
#

leading spaces? You mean the "'\n"?

quartz kindle
#

whatever %N you use, you have to use the same one in your week names

lyric mountain
eternal osprey
#

ah

lyric mountain
#

also for the weekday names

#

since although u changed the name size, u still kept the same total width (2 spaces now)

#

use printf for all of them, it'll result in a responsive calendar

eternal osprey
#

Yeah the width is really strange

lyric mountain
#

2 spaces (total 4 chars per day)

#

1 space (total 3 chars per day)

#

4 != 3, so it does not align

eternal osprey
#

yeah i see

#

but how would i ever change that

lyric mountain
#

use printf for everything

#

printf("%" + padding + "s", weekday)
printf("%" + padding + "i", day)

eternal osprey
#

so printf("%2s", day") etc etc?

lyric mountain
#

or hardcode the padding if u dont want to change it dynamically

eternal osprey
#

😭 wtf

eternal osprey
lyric mountain
#

then do it

eternal osprey
#

so replace all the couts with printf("%2s", var)?

lyric mountain
#

"%2s "

#

remember the margin

#

and u need to use i for days

#

unless u do toString()

eternal osprey
#

I've changed them all

#

still same output

#
 if(day == counter && initialze){
starter = false;
day = 1;
initialze = false;
daycounter = 1;
 }
if(day == counter+1){
   printf("%2s ", "\n");
  daycounter = 0;
}
 if(daycounter % 7 == 0){

    printf("%2s ", "\n");
    
  }
 if(starter){
  printf("%2s ", "");
 }else{
printf("%2i ", day); // i have used this for padding. It otherwise will look ugly due to the change from 1 to 2 digits, so we are making it compacter and basically boxed
// in 3 characters.
 }
 
  day++;
  daycounter++;

 }```
lyric mountain
#

\n doesn't need printf

#

and I don't see u doing starter = true anywhere

eternal osprey
#

yeah that code is above this snippet

#

just thought that it didn't really matter for the padding

#

I somehow fixed it

#

by changing the padding size to 3

#

however the 1, 2, 3, 4 are still fucked up and there's some sort of strange "\n" in the code extra

#

after 4

lyric mountain
#

mine works

#

also with offset adjustment

#

tho I cannot give u the code else it'd be spoonfeeding

#

but u can do all of it with an array of weekday names and 2 for loops

#

perhaps even with a single loop

#

basically what u want to do is loop between -offset and maxDays, printing all positive values + 1

#

the negative values should be printed as a whitespace

#

when (i + offset) % 7 == 0, print \n

#

@eternal osprey read

raw nest
#

I'm curious about licenses.. If I have e.g. a software I want to make Open-Source so the people can see into the code but I don't want them to just use it (legally) without getting a software license for example. Just so the code is not private and secret but can't get copied (legally) and used for unlicensed commercial use etc.
You know what I mean? šŸ˜…

lyric mountain
#

u cant have something open-source and prevent people from using it (privately)

sudden geyser
#

So you want a license that requires people who want to run your project commercially to ask you first

#

AGPL may be close to that.

raw nest
raw nest
lyric mountain
#

there's just a thing tho

raw nest
sudden geyser
#

ye

lyric mountain
#

agpl (and all gpl licenses) is contagious

#

you might want to look into less contagious licenses

lyric mountain
#

you'll need to read them to know

#

but for gpl-based licenses, they require the user to expose the source code

#

tho I dont remember if agpl removes that clause

raw nest
lyric mountain
raw nest
#

ah yes

lyric mountain
#

yes, agpl kept that clause

#

you want a license without that clause

#

also, all of the licenses listed there allow commercial usage

raw nest
#

maybe I should think about making it closed source.. I can still open source it later.

lyric mountain
#

u can write ur own license

sudden geyser
#

You could also just use a non-open source license

lyric mountain
#

just dual-license it

#

one for private usage and one for commercial

raw nest
sudden geyser
#

Aka make the code public but explicitly deny certain uses of the software, which is what I do

sudden geyser
#

yes

lyric mountain
sudden geyser
#

cooperative software license

lyric mountain
raw nest
#

xD

lyric mountain
#

and yes, that is a valid license

sudden geyser
lyric mountain
#

iirc there's a big linux lib that uses that (WTFPL)

sudden geyser
#

If you go out writing your own license though it's at best a scare tactic

lyric mountain
#

and something to refer to should u ever need to sue someone

#

(and should u ever get sued too)

raw nest
#

xD alright thanks guys I will think abou tthat

lyric mountain
#

since they protect u from liability (if u state it)

sudden geyser
# lyric mountain

like no large company will ever use this since it defines no terms

lyric mountain
#

ye

quartz kindle
#

sadly their website was removed

lyric mountain
#

Other gpl?

quartz kindle
#

(thought you'd never ask)

#

lmao

lyric mountain
#

A

boreal iron
sharp geyser
sudden geyser
#

Huge pretzel license?

lyric mountain
#

Hugh Mongus

boreal iron
#

Tf is going on here

#

Once im not here to watch the kids things are escalating

dry imp
sharp geyser
#

so shush

rustic nova
#

@sharp geyser keep it sfw kthx

sharp geyser
#

This is sexist

#

jk love ou aurel

#

have a nice day

rustic nova
hidden gorge
#

I want to make a timeout slash command would i use this in it ```js

member.timeout(5 * 60 * 1000)
.then(() => console.log("Timed out member"))
.catch(console.log);```

dry imp
hidden gorge
#

I’m trying to

lyric mountain
#

Did u check the docs?

boreal iron
lyric mountain
#

Kinky

earnest phoenix
#

anyone know how to fetch all users in every guild?
discord.js v14

sharp geyser
#

api spam is a common occurance

lament rock
#

The solution is to have the presence and members intent

eternal osprey
#

Hey guys I am trying to create a test about vsc. What 5 different categories should I have? Rn I used 1. Basics, 2. Code optimization, 3. Code debugging, and what other 2 should I include?

lament rock
#

alternatively, reconsider what you're doing because you're doing it wrong

#

if you need every user in a guild then what you're doing better be worth it

#

Otherwise, you're wasting memory

lament rock
#

e.g eslint

eternal osprey
#

awesome!

#
  1. Basics (theorem), 2. Code Debugging, 3. Code/file optimizing , 4. VSC user interface/ settings / workplace, 5. Code formatting/standardization.
#

I think this will do I think

lament rock
#

Would you be testing for a specific language? If it's JS, I'd also recommend ensuring the code base is typed strongly

eternal osprey
#

It covers the most important parts I think

eternal osprey
lament rock
#

Okay

#

I guess you can be generic enough about that across every language

eternal osprey
#

yeah eaxsctly!

lament rock
#

some languages have way more strict syntax though and code optimization applies to any editor

eternal osprey
#

yeah that’s true, but we could just cover basic things in that topic like defining the variables on top of the file, not having double code, code being as simple as possible, having your file organized etc

#

it will be challenging to find questions but I hope that it will work out

cinder patio
#

what does code optimization mean in this case? Editors don't optimize your code

eternal osprey
#

hmmm not sure yet

#

do you maybe have a better category in mid?

#

mind*

eternal osprey
#
int days_in_month = calculate_days_in_month(month, year);
 int day = 0;
 int daycounter = 0;
 int counter = 0;
 string month_begins_at = "";
  string weekdays = " Mo  Tu  We  Th  Fr  Sa  Su";
  string calendar = "";
int begindate = dayNumber(days_in_month, month, year);
cout << begindate<<endl;
  switch( begindate ) 
        {
            case 6: 
            month_begins_at = "Sat";
            calendar = "";
            counter = 6;
            break;
             case 0: 
            month_begins_at = "Sun";
            calendar = "";
            counter = 0;
            break;
             case 1: 
            month_begins_at = "Mon";
            calendar = "";
            counter = 1;
            break;
             case 2: 
            month_begins_at = "Tue";
            calendar = "";
            counter = 2;
            break;
             case 3: 
            month_begins_at = "Wed";
            calendar = "";
            counter = 3;
            break;
             case 4: 
            month_begins_at = "Thu";
            calendar = "";
            counter = 4;
            break;
             case 5: 
            month_begins_at = "Fri";
            calendar = "";
            counter = 5;
            break; 
        }
 cout << weekdays + "\n";
 bool starter = true;
 bool initialze = true;
 bool maka = true;
 while (day != days_in_month + 1){
 if(day == (counter) && initialze){
starter = false;
day = 1;
initialze = false;
daycounter = 1;
 }
if(day == counter){
  cout << "\n";
  daycounter = 0;
}
 if(daycounter % 7 == 0 && daycounter !=0){
    cout << "\n";
  }
 if(starter){
  printf("%3s", "");
 }else{
printf("%3i ", day); 
 }
  day++;
  daycounter++;
 }
#

hey guys, why is this code returning such crooked calendars?

neon leaf
#

how can I execute javascript as soon as a specified div loads?

eternal osprey
#

what is easier for a firewall to block, a reverse or direct(bind) shell access?

lyric mountain
lyric mountain
lyric mountain
lyric mountain
eternal osprey
eternal osprey
lyric mountain
#

firewall only blocks ports

#

it's like a literal wall, you remove bricks (ports) from the wall to allow specific accesses

eternal osprey
#

Ah i see!

#

And how could a server be protected against a DoS attack?

#

Like, limit the incoming network requests from one static ip?

lyric mountain
#

not really, DDoS happens when your server acknowledges the connection

#

like, if it manages to reach any kind of processing, it already succeeded

eternal osprey
#

i see

#

but how would we secure our server against such attacks then?

lyric mountain
#

use cloudflare, it'll prevent the attack from even reaching your server

#

or if u wanna do it yourself, have a second server to act as a middleman and tank the attack should it happen

#

if that server gets ddossed your main server will be safe from it

#

obviously this also requires fallback servers to act as alternative routes, so your server is still accessible

#

but tbh, don't worry about it too much, just put your server under cloudflare and call it a day, nobody will try to ddos a nobody's server

#

read what I wrote

#

the same as everything else

#

cloudflare doesn't magically change how accessing it works

#

it just adds a middleman to act as a safety layer

#

like, instead of yourdomain.com -> serverip:port you'll have yourdomain.com -> cloudflare -> serverip:port

eternal osprey
#

my class security

#

a certain question inquires to name 2 different methods to secure your server with against a DoS attack.

#

What i thought as well, was a firewall inclusion that would block too many packets coming in from one certain ip

#

or wouldn't that work?

#

i found it !

#

WAF: Web Application Firewall
• CAPTCHA: Solve a challenge
43

earnest phoenix
#

how does a captcha prevent dos, it mostly prevents bruteforce

#

if you spam the login page without doing any login, you can still dos the website

#

and if the captcha challenge is not coming from a relay, for example, cloudflare it makes no sense because loading the captcha can also lead to dos

#

very skeptical about "Using a captcha will prevent dos"

rustic nova
lyric mountain
quartz kindle
#

but yeah a self hosted captcha would be useless

earnest phoenix
#

yeah that's basically what i meant

#

if you selfhost your own captcha, absolutely useless

earnest phoenix
lyric mountain
#

ah, I mistook that comma placement

earnest phoenix
#

Hello, I want to know if it is possible to somehow display the number of servers on which my bot is on my site?
The bot is written in discordjs

lyric mountain
#

it is, simply make an api that runs alongside your bot to retrieve info from it

opaque marten
earnest phoenix
opaque marten
#

Is your bot already listed?

earnest phoenix
opaque marten
#

Then it won't work

earnest phoenix
#

(

#

ok

opaque marten
#

You can already "pre"-implement it, but it will only work once ur bot is listed and you got your top.gg token

lyric mountain
#

I think they want to list the count on their site, not on topgg specifically

opaque marten
#

@earnest phoenix is that the case?

earnest phoenix
#

wait

#

i want to translate

earnest phoenix
#

The only problem is that I don't know how to do api

manic crane
#

I need some help

lament rock
manic crane
#

It's working fine on my pc

lyric mountain
manic crane
#

just in the vps

#

its acting

lament rock
#

Did you read the error

manic crane