#development

1 messages · Page 2044 of 1

earnest phoenix
#

but is thinking

#

13.1.0

boreal iron
#

that's just a little bit outdated

sharp geyser
#

even in 13.1.0 it was componentType

#

Also the new stable is 13.7 isn't it?

wheat mesa
#

in 13.1.0 this is the docs

boreal iron
#

oh 13.7 is a thing?

#

what's new

wheat mesa
#

but if it works for you, then use type:

earnest phoenix
earnest phoenix
#

all commands stoped worked but when i removed ephemeral it working right

quartz kindle
#

this is the code

#

so yes, componentType is correct and type is incorrect

#

this is is how the type is checked ```js
if (this.componentType && interaction.componentType !== this.componentType) return null;

#

so if you dont use a correct componentType it will default to any type / all types

split hazel
#

is there a way in html to escape user-inputted html without replacing any characters - in other words preventing the browser from rendering it as html and only as text

#

cant use javascript

quartz kindle
split hazel
#

:c

#

fine i'll just replace the tags

#

with a more friendly alternative:)

#

like (

boreal iron
#

u usually want to replace a few more

quartz kindle
#

but those were removed in html5

boreal iron
#
& (ampersand)        &
" (double quote)     "
' (single quote)     ' (for HTML401) or '
< (less than)        &lt;
> (greater than)     &gt;
split hazel
boreal iron
#

if not the browser will render it instead of showing it as code?!

split hazel
#

quotes?

boreal iron
split hazel
#

last time i checked speedb doesnt use sql

#

i think just gt and lt should be fine

boreal iron
#

pfff bad db then

#

gib sql support

split hazel
#

only when i die

#

cant lie that looks clean

boreal iron
#

make sure to refuse the (re)delivery attempt only if a valid reason is givin

#

such as recipients postbox is full

#

or your ip is blacklisted

#

there are only a few reasons mail servers stop the resending

quartz kindle
split hazel
#

through smtp interfaces only option for errors i've been given is just a string

#

so if the inbox is full

#

skill issue get good get a good job get a family start a business get rich get rich man email get lots of bytes

boreal iron
#

seems accurate

spark flint
#

pls help

#

can't install npm or node-gyp wah

sharp geyser
#
{
  "statusCode": 404,
  "message": "Cannot GET /v1/images/dogs?",
  "error": "Not Found"
}

So for some reason when I am making a form request to my api it adds a ? to the end causing this to occur

#
import {useState} from "react";
import {NativeSelect} from "@mantine/core";

function Index() {

    const [location, setLocation] = useState('manga')

    console.log(location)

    return (
        <>

            <NativeSelect
                value={location}
                onChange={(event) => setLocation(event.currentTarget.value)}
                data={['manga', 'dogs']}
            />

            <form action={`http://localhost:3001/v1/images/${location}`}>
                <input type={'file'} multiple accept={'image/gif, image/jpeg, image/png'} />
                <input type={'submit'} />
            </form>
        </>
    )
}

export default Index;
lost holly
#

Random idea nothing to do with fixing the error sorry... But couldnt someone set the location as "../../../../" and make it return more important files?

#

nvm im stupid i think

woeful pike
#

usually webservers are scoped to only serve files within a specific folder so path traversal attacks don't work directly like that

#

but there are cases where that can be a vulnerability

lost holly
#

yeah i just noticed aswell that the location is the action value and isnt from the input

woeful pike
#

also ? shouldn't be the thing causing an error there

lost holly
#

mhmm

sharp geyser
slender wagon
#

so i got 2 servers

sharp geyser
#

so it doesn't matter

slender wagon
#

and i wanna start a mini hosting service

#

what should i beggin with

lost holly
#

Pterodactyl

sharp geyser
#

why

slender wagon
#

OS first

lost holly
#

well i use Ubuntu 20.04 and then install Pterodactyl

sharp geyser
#

I'd go with the standard os of every linux vps out there

#

unless you wanna use a windows server

slender wagon
#

hell no wtf

sharp geyser
#

ubuntu is the standard

#

from what i've seen at least

slender wagon
#

lighter one?

lost holly
#

Ubuntu has the most support and i dont know if any host give the option for a lighter one

slender wagon
#

how about CentOS

#

I've seen vps's use that alot

sharp geyser
#

CentOS is a good option as well from what I remember

#

I haven't fucked with linux that much tho so not sure if I can't really comment

lost holly
#

personally never tried it

slender wagon
#

hmm

#

and how about the dashboard

sharp geyser
#

Are you looking to make profit from this or is this just free services?

lost holly
#

Pterodactyl is a free open src webpanel that lets u install eggs that are used to host applications

slender wagon
#

working with one of my customers

sharp geyser
#

I see

lost holly
# slender wagon and how about the dashboard

https://pterodactyl.io/ <- its fast to install, secure and really easy to scale if u want more nodes

slender wagon
#

gta mod servers

#

and ofc web hosting

sharp geyser
#

ello papi

lost holly
#

you can probably find an egg for these apps somewhere or make your own

sharp geyser
#

:p

lament rock
#

discord bots are usually anything but scalable

slender wagon
slender wagon
lament rock
#

most of the Discord libs out there are memory hogs. Good luck getting around that

slender wagon
#

fr fr

#

can't u like put a limit on the resource usage

sharp geyser
#

👀

#

I am starting to wanna lean more towards performant then user friendly

slender wagon
lost holly
sharp geyser
#

You can't have best of both worlds imo

#

Trying to be user friendly can easily end up being less performant

#

and I don't wanna become another djs

lost holly
#

yup

#

its easy to setup a hosting service these days the only annoy bit is picking the right hosting and fighting ddos attacks

slender wagon
#

i am good at that last one

#

also wym by picking the right hosting?

sharp geyser
#

Do you have servers at home or are you using some companies cloud services?

slender wagon
#

i got my own servers

sharp geyser
#

O sick

slender wagon
#

currently in US

sharp geyser
#

electricity bill go brr

slender wagon
#

we'll be working that out

lost holly
lost holly
#

yeah its just cheaper but less secure 🙂

vivid fulcrum
#

not necessarily

slender wagon
#

bet u can't scale with them as u would with your own

sharp geyser
lament rock
vivid fulcrum
#

if you aren't a complete idiot, you cannot go wrong with hosting bots on your on hardware

sharp geyser
#

I was already thinking of not caching but wdym by class based interfaces

lost holly
lament rock
#

Shit like the Message interface from Discord.js

sharp geyser
#

oh I have classes that I convert the raw data into so the methods stick with it but other than that

lament rock
#

nobody needs a class to represent a message if the properties are similarly named. The only things you should offer are the helpful utility functions as utils

vivid fulcrum
#

the first step to having a performant lib is not using node in the first place mmLol node objects are going to be heavy no matter what you do

sharp geyser
#

Mmm true

sharp geyser
#

😔

vivid fulcrum
#

worth exploring other languages!

lament rock
#

I remade lavalink (java) in node and the performance gains are huge

sharp geyser
#

trying to go into a language with the goal of making a discord lib out of it seems scary

#

👀

vivid fulcrum
#

c#, rust and kotlin are my top 3 as of 2022

sharp geyser
#

I am learning java

#

but I don't wanna fuck with java and a discord lib

lament rock
#

java's overhead is nasty

vivid fulcrum
#

this

lament rock
#

You can take your Java knowledge into C# for the most part

vivid fulcrum
#

not a fan of using JVM in the first place, but it gets the job done

lament rock
#

TypeScript as well to some degree

sharp geyser
#

I was learned C# a while back but never stuck with it

lament rock
#

I've been working on a Unity game, so C# has been fun

sharp geyser
#

My biggest issue with learning a language is what to do with it to learn shit

#

Like learning the basic types of a language is usually easy as majority of the langs I have used have a similar type structure

vivid fulcrum
#

.net 7 brings us native AOT compilation

lost holly
lament rock
#

whats that

#

@sharp geyser make lavalink in rust for me kthx

sharp geyser
vivid fulcrum
#

ahead of time, eliminates the need to have an interpreter in the middle to translate to machine code

lost holly
sharp geyser
lament rock
#

so like JIT but at compile time?

vivid fulcrum
#

yup!

#
The main advantage of Native AOT is in startup time, memory usage, accessing to restricted platforms (no JIT allowed), and smaller size on disk. Applications start running the moment the operating system pages in them into memory. The data structures are optimized for running AOT generated code, not for compiling new code at runtime. This is similar to how languages like Go, Swift, and Rust compile.
lament rock
#

Sounds insanely complicated

vivid fulcrum
#

the technology behind it is, it's insane

#

but actually producing AOT binaries is super easy

#

just an extra argument in the .net CLI

lament rock
#

any code/patterns that might need changing?

sharp geyser
#
{
  "statusCode": 404,
  "message": "Cannot GET /v1/images/dogs?",
  "error": "Not Found"
}

Still can't figure this shit out

#

react be doing smth weird with the form submitting

slender wagon
sharp geyser
#

I used go a while back

sharp geyser
#

it is ight

vivid fulcrum
lament rock
#

GET can have a body, but it's non standard

vivid fulcrum
#

why are you even using libs for something as simple as forms

sharp geyser
#

OH RIGHT

#

I am blind

#

didn't realize I was doing a get request this entire time

#

😔

lament rock
#

its ok

sharp geyser
#

Well now it isn't even uploading the file to minio like it was before

#

got it working

#

:D

split hazel
#

dev update: speedb is going to be refactored because quite frankly im embarrassed to put it on github let alone submit it for my school assignment

#

might also switch over to a faster json parsing library called rapidjson

ancient nova
#

any idea why this doesn't send?

wheat mesa
#

thanks for cutting off useful information in your screenshot such as what channel actually is 😉

ancient nova
#

it was nothing, actually, I forgot to change channel to welcomeMessageChannel

#

also is that text good enough?

#

I don't really know what to type there

vivid fulcrum
#

well, you cut off the screenshot

ancient nova
#

it's gonna be a introduction sorta

#

oh ye hold on

vivid fulcrum
#

and id kick the bot if it introduced itself like that

sharp geyser
#

^

vivid fulcrum
#

you should just be concise and straight to the point

ancient nova
#

Yo! Thanks for adding the bot.\n\nBefore using it though, there is a few *optional* steps you have to do in order to fully set the bot up in your server.\nFirstly, run the -set command in order to set up admin, mod and muted roles. Also set up the, this time really optional logging and welcome channels.\nSecondly, if you need to you can also set up a fully customized prefix for your server, and incase you're lost, the default one will always be `-`, and if you ever forget it, just mention the bot and it will respond with the current configuration.\n\nWith that out of the way, I hope you enjoy the bot. CYA!

#

so what should I change then

vivid fulcrum
#

also, one thing i wanted to note is that if you didn't get an error for the issue you were having, it's hinting that you aren't handling errors properly

ancient nova
#

I am, I have a logging system, the entire code I showed was in a try catch statement though

#

more importantly, what do you mean my concise and straight to the point?

#

I'm trying to explain in detail how to make the bot work properly

vivid fulcrum
#

write it professionally

#

what i, as an end user, would want is a simple thanks, tell me the prefix and where to get started with the bot

#

that's all

#

not a wall of text

ancient nova
#

so something like
Yo! Thanks for adding the bot\n\nTo get started run the -set command and set up the important stuff\nThat's all, bye.

#

better?

vivid fulcrum
#

better but not professional

ancient nova
#

how would you write it?

#

can you show an example?

vivid fulcrum
#

something along the lines of

thanks for inviting me
my prefix is x
you can view my commands with y

if your bot needs to be set up first, add an extra line telling me how to do it

#

only tell the user information they need to know

#

visible at a glance

#

i don't want to scan a paragraph to find out how to use something as simple as a bot

#

put yourself in the shoes of an end user and think like one, you'll instantly write a better experience for your users

ancient nova
#

I feel like like that's decent enough

vivid fulcrum
#

yup

#

loving that

ancient nova
#

great

vivid fulcrum
#

id remove the And in to get started personally

ancient nova
#

gotcha

vivid fulcrum
#

but it's very good as it is

ancient nova
#

aight that's great then

#

thanks for help

#

this isn't working...

#

.send is supposedly undefined?

split hazel
#

maybe the channel could not be found

sharp geyser
#

welcomeMessageChannel is undefiend then

split hazel
#

you commented out the very condition that should stop that

#

also you should just do if (welcomeMessageChannel) instead of channel !== undefined

#

it may return null instead of undefined

#

that handles both cases

ancient nova
#

well I still need to find the channel? I'm inviting with admin perms and there is plenty of text channels so there clearly is something wrong

split hazel
#

i think your channel type statement is wrong

#

in your case it would be GUILD_TEXT instead of text

ancient nova
#

I assume it's been changed?

split hazel
#

well they change things every little release so probably

#

thats why i dont use djs anymore

ancient nova
#

I see, that's kind of confusing

ancient nova
#

what do you use?

split hazel
#

well uh nothing i dont exactly develop bots anymore

#

theres not really a good alternative

sharp geyser
vivid fulcrum
#

it's not even lib devs to blame

#

it's discord themselves

#

the api is very inconsistent

split hazel
#

a lot of people say the constant changes are not a "big deal" and it makes developers "work on their bots" but obviously they havent touched a large bot ever and realized how stressful and difficult it is to stay up to speed alongside over things such as bugs and features

vivid fulcrum
#

the discord api is a programmer's representation of borderline personality disorder

split hazel
#

and its not like you can stay on one version forever eventually the api version will be dropped by discord

vivid fulcrum
#

this

split hazel
#

and it doesnt take very long either

#

i think versions stay alive for like a year or 2 max

ancient nova
#

discord is gonna remove text commands supposedly

#

if they get removed I stop making bots

split hazel
#

well thats their mission

vivid fulcrum
#

the final nail in the coffin to stop working with the api altogether (userbots included) were interactions and discord implementing changes that bot developers clearly don't approve of

#

at least for me

split hazel
#

you can keep using text commands - that is if one of your bot features qualify for the message intent

ancient nova
#

I agree, discord even took a poll and then completely ignored the results

vivid fulcrum
#

it's such an oxymoron

#

discord killing the major thing that's keeping their platform alive

#

lol

ancient nova
split hazel
#

i dont get the whole "privacy" point of this, discord aint supposed to be a private platform and a self bot can easily scrape thousands of users and messages without an ich - and server owners should also be responsible for what channels the bots are allowed to view

vivid fulcrum
#

never was privacy

ancient nova
#

yeah I don't get the point of this

ancient nova
split hazel
#

too much

#

also you know guys it will only take discord one database data breach and its over

ancient nova
#

I'm hoping they finally start listening to what people have to say or seriously I think everyone will stop making bots at some point

split hazel
#

nothing is encrypted or end to end

#

and tencent is already dipping their fingers into discord

ancient nova
vivid fulcrum
#

their goal is to make their platform friendlier to people who aren't tech savvy at the cost of the sanity of api consumers, privacy is just a term they use as a coy to not receive as much backlash

#

it's just smart marketing

ancient nova
#

I think they already do

#

at least all the smart people trash talk discord

split hazel
#

only a matter of time until the chinese have their hands on every single message and activity data of every user

#

probably already the case

vivid fulcrum
#

this

#

love talking about it since it's a gray area, you don't know whether if it's true or not and it's impossible to find out without a leak

split hazel
#

im excited for a discord data leak

vivid fulcrum
#

all corporations value your data a lot, pander to you that they're keeping it safe and not selling it to anyone

split hazel
#

if someone dont do it i'll do it myself 💀

vivid fulcrum
#

i havent for myself, just speculating based on how much legal trouble FAANG went through

split hazel
vivid fulcrum
#

i dont know why but it doesn't bother me that my data is stored and sold, it bothers me that corporations lie about it

split hazel
#

I've just accepted it at this point

#

I just care to not make sure my very personal info is in that mix

#

humanity is really gonna kill itself before any natural disaster does

vivid fulcrum
#

this tbh

#

even if you try to dig into this topic on the surface web you'll barely find anything

#

google and microsoft censor this

#

should just accept it too

boreal iron
#

After reading that I feel I put a disclaimer in my site, telling anybody I take all their data I can get and sell it to anybody I want

#

No more secrets smirk

earnest phoenix
#

Hello so i need help with checking if a user is actually user ?

#

i tried using typeof User === user but is not working how i thought it would work

hybrid cargo
#

You are type checking with a class. You gotta use instanceof and not typeof

#
ObjectName instanceof ClassName // returns boolean
earnest phoenix
#

oh that makes more sense thank u sir

lament rock
#

give me some money from my data

lyric mountain
#

They changed codeblock styles on mobile

#

No more margin and smaller padding

hybrid cargo
#

Isnt this been there for over 3 months now?

#

cuz i remember seeing it like this for that long

quartz kindle
#

looks bad

lyric mountain
#

What was the last css change discord did that didn't look bad?

quartz kindle
#

exdee

restive karma
sharp geyser
#

So I have googled what vite is and I know it is some kind of web dev tool but still not entirely sure what it is

lyric mountain
simple stump
#

I have a slight dilemma. Essentially, I have a "storage" server which is https://my_site.com/content/some_url_here.png. I can then use my Express server to fetch images and whatnot via links like that. I also have an external script that requires an image URL (ex. https://example.com/info.png) which I then pass in my website to do something. Essentially:

let data = await imgReverser("https://my_site.com/content/info.png"); // External script that reverses an image.
console.log(data);

However, since I use CloudFlare, fetching that image is blocked for some reason. I can't send requests to https://my_site.com/content/info.png, therefore if I execute that external script, nothing happens. Is there a way to bypass CloudFlare to access images from my web server?

quartz kindle
#

you have to configure your cloudflare to not block it

sharp geyser
#

vite.config.ts

import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import WindiCSS from 'vite-plugin-windicss'
import Pages from 'vite-plugin-pages'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    react(),
    WindiCSS(),
    Pages({
      dirs: 'src/pages',
      exclude: ['**/components/*.tsx']
    })
  ]
})

main.tsx

import React, { Suspense } from 'react'
import ReactDOM from 'react-dom/client'
import './index.css'
import {BrowserRouter, Route, Routes, useRoutes} from "react-router-dom";
import Home from "./pages/Home";
import {MantineProvider} from "@mantine/core";
import 'virtual:windi.css'
import Navbar from "./components/navbar";

import routes from '~react-pages';

const App = () => {
  return (
    <Suspense fallback={<p>Loading...</p>}>
      {useRoutes(routes)}
    </Suspense>
  )
}

ReactDOM.createRoot(document.getElementById('root')!).render(
  <React.StrictMode>
    <MantineProvider
    theme={{
      colorScheme: 'dark'
    }}
    withGlobalStyles
    >
      <Navbar />
      <BrowserRouter>
        <App />
      </BrowserRouter>
    </MantineProvider>
  </React.StrictMode>
)

navbar.tsx

import {Link} from "react-router-dom";

export default function Navbar() {
    return (
        <>
            <header>
                <nav className={'flex flex-col'}>
                    <h1>Everything API</h1>
                    <ul>
                        <li><Link to={'#'}>About</Link></li>
                    </ul>
                </nav>
            </header>
        </>
    )
}
#

So I was giving vite a shot and it seems like I am fucking up horribly. I am trying to introduce routing and I tried the vite-plugin-pages vite plugin to help mitigate the entry of using react-router-dom (as using it on its own seems ot just fuck up) but I am still experiencing issues.

earnest phoenix
#

I have a problem with my bot. There people to help me!!!

slender thistle
#

Maybe

earnest phoenix
#

My help command doesn’t work

#

My language bot is JavaScript

#

My code is

#

Can they help me?

rustic nova
#

I'd suggest properly naming your variables tbh

#

for example fff

earnest phoenix
#

Okk thx

#

Wtf

winter pasture
# earnest phoenix

In your startup, you define the bot/client. In those options, you need to give a array of client intents

#

Numeric WebSocket intents. All available properties:

GUILDS
GUILD_MEMBERS
GUILD_BANS
GUILD_EMOJIS_AND_STICKERS
GUILD_INTEGRATIONS
GUILD_WEBHOOKS
GUILD_INVITES
GUILD_VOICE_STATES
GUILD_PRESENCES
GUILD_MESSAGES
GUILD_MESSAGE_REACTIONS
GUILD_MESSAGE_TYPING
DIRECT_MESSAGES
DIRECT_MESSAGE_REACTIONS
DIRECT_MESSAGE_TYPING
GUILD_SCHEDULED_EVENTS

https://discord.js.org/#/docs/discord.js/stable/typedef/ClientOptions

earnest phoenix
#

Thx bro

#

I fix it yeah

#

Full thx

#

Yeah it’s working

timber fractal
#

What does this error mean? ```node:_http_outgoing:651
throw new ERR_HTTP_HEADERS_SENT('remove');
^

Error [ERR_HTTP_HEADERS_SENT]: Cannot remove headers after they are sent to the client
at new NodeError (node:internal/errors:371:5)
at ServerResponse.removeHeader (node:_http_outgoing:651:11)
at write (C:\Users\Luckie\node_modules\finalhandler\index.js:282:9)
at AsyncResource.runInAsyncScope (node:async_hooks:199:9)
at listener (C:\Users\Luckie\node_modules\on-finished\index.js:170:15)
at onFinish (C:\Users\Luckie\node_modules\on-finished\index.js:101:5)
at callback (C:\Users\Luckie\node_modules\ee-first\index.js:55:10)
at IncomingMessage.onevent (C:\Users\Luckie\node_modules\ee-first\index.js:93:5)
at IncomingMessage.emit (node:events:406:35)
at endReadableNT (node:internal/streams/readable:1343:12) {
code: 'ERR_HTTP_HEADERS_SENT'
}And how could I possibly fix it? I assume it's this part of code. js
app.get("/verify", (req, res, next) => {
console.log("verify")
if(req.session.backURL){
req.session.backURL = req.session.backURL
} else if(req.headers.referer){
const parsed = url.parse(req.headers.referer);
if(parsed.hostname == app.locals.domain) {
req.session.backURL = parsed.path
}
} else {
req.session.backURL = "/"
}
next();
res.redirect("/callback");
})```

split hazel
#

calling next basically means you are happy with the request and ready to move it onto another one

#

in this case you should remove the next

#

because you dont need it to process anything beyond this point

timber fractal
#

alright thanks

#

is there some kind of guide to understand the passport npm module and how to use it or some examples, i just dont understand it

winter pasture
timber fractal
#

thank you

onyx remnant
#

hello, how to change bot developer?, actually i'm de DrackRPG bot developer but the before developer deleted his account and he has access from bot in topp.gg.

#

ty for your feedback and help

real rose
onyx remnant
#

Ok ty, how am i prove ownership?

real rose
#

You will need to change the bot in some way whilst live

#

Contact a moderator for more information/instruction thumbsUpCat

onyx remnant
#

ok, with anywhere moderator?

real rose
#

Any moderator can help you with owner transfer, yes. Feel free to dm me if needed

onyx remnant
#

ty so much

stiff lynx
#

there is something in node process for 'avaible memory'? I would like to create a graph with process.memoryUsage() but I need the max avaible, or I put it by hand, but I would prefer a method

ocean harbor
#

i dont know if this is the correct channel to ask questions but my discord bot is starting to get people's attention and i need some help and advice about what should i do with my bot before it can be verified. if you have some to tell me, feel free to dm me!

pine nova
#

does anyone know how to send a canvas buffer as attachment/image in channel?

#

using eris not discord.js

solemn latch
#

(Bottom two parameters in createmessage)

pine nova
#

oh yes

#

thank u

#

i am so blind fr searching since 3 days

#

😔

split hazel
#

but be aware measuring memory usage with nodejs is very messy

#

theres like 5 different metrics for measuring memory with nodejs

#

and when you stop using a piece of memory it may still show up as being used because node is garbage collected and will only clear that memory once it is running low

#

i think the only easy and reliable way of seeing how much memory is in use is by asking the os for it

silver perch
#

Hello

quartz kindle
#

good bye

ancient nova
#

how do I make it fetch the message by somebody's ID?

#

I know after takes in only message Ids

pale vessel
#

that's only available on user accounts

ancient nova
#

I thought they were against tos

acoustic reef
#

they are against tos

lyric mountain
#

it's not because something exists that it is allowed

ancient nova
#

TypeError: image/gif is not a legal HTTP header name

#

y

#

I'm trying to fetch an API and determine whether the resulting image is a gif or not

ancient nova
#

seems pointless

cinder patio
#

image/gif is the value

rustic nova
tidal parrot
#

You realise the API is being used by a user account to post that

#

It's being used as intended for the discord client, not your selfbot

lyric mountain
#

no user endpoint = cannot have user clients

#

any site with user features have an user endpoint

#

the only difference is that most don't have it documented and/or isn't supposed to be used by third-parties

ancient nova
ancient nova
sharp geyser
#

Wait what exactly are you trying to do here

ancient nova
#

but since there is no endpoint of that I have to write it manually

sharp geyser
#

But you caan literally get people's banners with djs

timber fractal
#

i tried using passport, but for some reason it keeps redirecting me to the failure page. What could be the mistake? js app.post('/login', passport.authenticate('local', { failureRedirect: '/login?code=err' }), async (req, res) => {

ancient nova
#

there is no endpoint for that

sharp geyser
ancient nova
sharp geyser
#

You can get their banner hash and then reform the banner with the hash

#

Which is 10x easier

#

cause no matter what format gif or not it will display properly

ancient nova
#

well that's interesting

sharp geyser
#

read this it tells you how to form the banner url

#

Also it gives you a nice little note for gif

#

So just check if the hash you get back starts with a_ unless djs already does that for ya idk haven't used it since the banner stuff

sharp geyser
#
import {Link} from "react-router-dom";

export default function Navbar() {
    return (
        <>
            <header className={'h-10'}>
                <nav className={'flex flex-row'}>
                    <h1>Everything API</h1>
                    <ul className={'flex flex-row'}>
                        <li><Link to={'/'}>Home</Link></li>
                        <li><Link to={'/about'}>About</Link></li>
                    </ul>
                </nav>
            </header>
        </>
    )
}
#

Any idea on how I can center this within the 2.5rem height ?

lyric mountain
#

oh no, oh no, is this...the classic "how to center a div" issue????

#

well, jokes aside, you need to have a flex flex-column div too

#

row for horizontal, column for vertical

#

or use justify-content set to middle

slender thistle
#

center

sharp geyser
#

I don't like how it hugs the top of the page

quartz kindle
#

option 1: give the div a fixed height, then use vertical-align, or margin top with calc, or padding

#

option 2: make the div a flexbox, like kuuhaku said

sharp geyser
#

padding worked

#

Now to figure out how to get the nav links to go to the end

#

I am ashamed at how poor my css is

#

even with a lib like tailwind I am managing not to get it to work

#

😔

wheat mesa
sharp geyser
#

fuck off

wheat mesa
#

I meant for him dingus

sharp geyser
#

I know

#

I am dreading it

lyric mountain
#

align-content is center

slender thistle
sharp geyser
slender thistle
#

I don't remember middle being used in CSS

lyric mountain
#

I might be mixing with react-native then

slender thistle
#

Probably

lyric mountain
#

I swear there was an alignment property that used middle instead of center

vivid fulcrum
#

it's a property for vertical-align

sharp geyser
#

yea

#

vertical-align uses middle iirc

lyric mountain
#

ah yeah, that's the one

sharp geyser
#

what is flex-end

#

never heard of that

lyric mountain
#

it aligns all children to the end of the flex layout

#

in a column everything goes to bottom, in a row everything goes to the right

vivid fulcrum
#

i love flexbox

#

if i could, i'd marry it

lyric mountain
#

it'd be a flexible relationship

sharp geyser
#

well flex end doesn't seem to be working

#

I fucking hate css

#

why does the css of the parent not relate to the child

#

😔

lyric mountain
#

set the background color to red or something noticeable

#

see if the container size is filling the available space

#

sometimes it's not a matter o alignment, it's just sizing issues

sharp geyser
#
import {Link} from "react-router-dom";
import './navbar.css'

export default function Navbar() {
    return (
        <>
            <header className={'h-15 text-xl text-white font-mono'}>
                <div className={'flex flex-row pt-2'}>
                    <h1>Everything API</h1>
                    <nav className={'flex justify-end'}>
                        <ul className={'flex-row'}>
                            <li className={'px-10'} ><Link to={'/'}>Home</Link></li>
                            <li><Link to={'/about'}>About</Link></li>
                        </ul>
                    </nav>
                </div>
            </header>
        </>
    )
}

Okay but like, if nav has the flex class and ul has the flex-row class

#

shouldn't the flex also carry to the children?

#

or am I misunderstanding how css works

wheat mesa
#

Misty I think you need to take a course on color theory

sharp geyser
#

waffle...

#

it is to test the boundaries

wheat mesa
#

The boundaries of my eyes

sharp geyser
#

waffle go back to what you were doing

#

before I show up to your house and break ur doors down

wheat mesa
#

Also why not use mantine

#

Built in grid system

sharp geyser
#

Cause I don't know the grid system well enough

#

nor can I be bothered to try and learn it

#

:D

wheat mesa
#

And aren’t you using next.js already

sharp geyser
#

no

#

using plain ol react and vite

wheat mesa
#

It’s just dividing the page into 12 rows

sharp geyser
#

then you come do it

#

nerd

wheat mesa
#

Ok

#

I will

#

Later

#

Throw it on GitHub and invite me to it, I’ll make it pretty :p

#

Fair warning I might use mantine though

#

Because mantine is a fucking godsend

sharp geyser
#

I already have mantine installed

#

I also have framer motion to do animations

wheat mesa
#

Also I would recommend tabler-icons-react for little button icons

sharp geyser
#

ok

#

well do what you want with it

wheat mesa
#

Clean and customizable

#

I’ll send you some design ideas when I get back to my pc

vivid fulcrum
#

it's relatively quick

#

and the article provides nice visualisations

#

i used it when learning flexbox and grid systems

split hazel
#

pov you use css grid

slender thistle
wheat mesa
#

Huh

slender thistle
#

I was confused too when I saw it

#

But last time I checked it used flexboxes for them

wheat mesa
#

Yes it uses flexboxes

#

iirc

slender thistle
#

Yup

wheat mesa
#

Took me like a whopping 10 minutes to understand though so

#

Not too complex

slender thistle
#

Lmao true

plush copper
#

Is there a reason I got an error about getaddrinfo failed?

#

The full error is Cannot connect to host top.gg:443 sll:default [getaddrinfo failed]

split hazel
#

maybe

plush copper
#

Is there something I can do to prevent this from happening?

rustic nova
#

Is your server perhaps losing connection occasionally/bad DNS server?

#

or perhaps a firewall blocking outgoing port 443 etc?

plush copper
#

Im not sure, I just woke up to see that error

#

Its only happened once, so I don't think its the firewall blocking

rustic nova
#

Then likely either your server losing the connection or a dns server coincidentally being bad while the dns entry for top.gg isnt cached

plush copper
#

Hm, alright, thank you

viral plover
#

I'm having trouble creating an invite link for a scheduled event. Does anyone have an example of what it looks like?

plucky loom
#

does anyone know how to remove special characters from a string where the special characters are not at the start or end? Something like this:

"Apples, Oranges, Bananas"

and change it to:

"Apples Oranges Bananas"

#

basically, .strip but for the inside of a string

viral plover
#

I don't know of a built-in function but I've made a manual function for it using .slice and .indexOf.

plucky loom
# lyric mountain `<text>.replace(",", "")`

Here's the pastebin: https://pastebin.com/98ZZgXrT

I can't get it to await ctx.send any 3 random emojis or number 7, without having single quotes and commas. I tried what you suggested, but the IDE wasn't happy with your suggestion because it kept thinking there was a missing parenthesis when there wasn't one missing.

Lmk if you find a way to get it printing cleanly

lyric mountain
#

instead of using the emote itself for resutl checking

quaint wasp
#

yo

#

how do I access the url?

#

I did response.data.url

#

didn't work

#

pretty sure it's because its in an object

#

but I'm not sure how to get into it

#

ping in replies 👍

#

halp

quartz kindle
quaint wasp
#

right..

#

how do I get into that array if it has no name.. like js something: [ fds: 2534 ]

quartz kindle
#

arrays use indexes

#

aka, the number of the item inside it

quaint wasp
#

ohh

#

so response.data[1].url?

quartz kindle
#

arrays are zero-indexed

#

they start at 0

quaint wasp
#

im stupid sometimes

#

thanks

#

👍

plucky loom
# lyric mountain why dont u just use numbers to represent each emote?

Here's the updated code: https://pastebin.com/YrGvHn71

I'm still not getting clean output, but I am using the index values to result check now instead of the emotes. Still have commas and single-quotes delineating the emojis in my output

I also added some newlines to make reading the debugger code output easier

lyric mountain
#

I'm still quite unsure what .strip("[], ''") is supposed to do

#

That whole thing is a mess (no offense intended)

#

For instance A == B == C will never be true unless C is a boolean

#

That's because A == B will resolve to a boolean, invalidating the next check

plucky loom
lyric mountain
#

But WHY are you doing that, that's the question

#

Also as I saw in the docs strip only works for leading and trailing characters

#

When I said "use numbers instead of emotes" I meant something like 112 where 1 and 2 represent slots

#

But EVEN if you wanted to use emotes, there's no reason to work with a stringified array instead of the actual array

plucky loom
#

yea... getting back into python after doing Data Structures & Algos in Java, so I'm a little off my game

#

Probably best to scrap the whole function and start fresh I take it?

lyric mountain
#

Ye

#

Think with arrays, not with strings

#

Make symbols to represent each slot, like numbers or letters

#

Then compose a sequence of those numbers

#

Like

int[] result = new int[3];

for (int i = 0; i < 3; i++) {
	result[i] = (int) Math.random(7);
} 

// ... compare array combination
wheat mesa
#

wait Math.random() can take a number as input? never knew that

#

I'm gonna assume that's a psuedocode explanation or something cus looking at the javadocs it doesn't take a param lol

plucky loom
#

yea, it's a psuedocode explanation in Java of something I'm trying to do in Python

bright thorn
#
collector.on("end", () => {
          msg.edit({
            content: "Action aborted!",
            components: [],
            embeds: [],
          }).catch(() => { });
        })
#

i want this action only if the nothing selected in collections

#

for button and menu

#

how can i?

plucky loom
#

Starting from scratch was a great idea, and my code is cleaner

pine nova
#

💀

slender thistle
#

'owo'.strip('o') == 'o'

slender thistle
earnest phoenix
#

I'm stuck with this here, how do I fix it? using typescript

fathom sonnet
#

hii guys so i want to create simple user info where bot will display, user server joined date but... Instead of doing that with moment which is no longer supported & updated, Which would be good alternatives to create this with? I read that Luxon is good alternative, so i "read" some part of docs, and tried to do something like this:

            .setDescription(`**User Tag**: ${user.tag}\n**User ID**: ${user.id}\n**Joined Server**: ${DateTime.utc()(member.joinedAt).toFormat('dd/mm/yyyy')}`)

#

but thing is staht this display current date

#

so rn i really have no idea how else i should make this

rustic nova
#

which you'd just need to pass the seconds to, so you could do this thing for example

I just sent this message <t:1653984420:R>

earnest phoenix
sharp geyser
#

Post that issue with the error then if you need help

earnest phoenix
#

It cant read the 0 index

sharp geyser
#

Okay what the fuck are you doing

#

Sorry excuse my French

#

Just very confused

wheat mesa
#

Sometimes I really wonder why people over complicate the fuck out of things

sharp geyser
#

Just use math.random my g

earnest phoenix
#

I want to loop over them 1 by 1

sharp geyser
#

Why loop

wheat mesa
#

Well first off, don’t change status every 5 seconds. You’re gonna get ratelimited

earnest phoenix
#

I dont want math random

#

Its for testing

#

I wont

sharp geyser
#

Testing or not 5s is still too short

earnest phoenix
#

yes I know

wheat mesa
#

Secondly, increment a variable every x time, and when it reaches activities.length, set it to 0 again

#

Also misty why are you still awake

earnest phoenix
#

the issue is

#

It loops over all of them then when it comes to 0 again it throws the error

wheat mesa
#

Whatever you’re doing looks complicated

sharp geyser
wheat mesa
#

Just ```ts
let x = 0
setInterval(() => {
if(x >= activities.length) x = 0
// do stuff with activities[x]
x++
}, interval)

#

I have no idea why you’re making this boolean argument timer stuff, that’s massively overcomplicating it

earnest phoenix
wheat mesa
#

Probably doesn’t help that it’s 4am for me rn but still

sharp geyser
#

2am almost for me 😔

earnest phoenix
#

thanks tho, I know its simple but the issue I fixed before completely blown my head and its completely blank now

wheat mesa
#

Lol

earnest phoenix
#

so idk what i'm even doing

sharp geyser
#

You should feel my head after waffle was done with it

#

😔

#

My head still hurts

wheat mesa
#

Taught this poor guy some quadratic algorithms earlier 😉

earnest phoenix
#

I was copy pasting the codes someone gave me

wheat mesa
#

Yeah, lesson learned… don’t do that

sharp geyser
#

That's usually never a good idea

#

Only paste what you understand

earnest phoenix
#

its not that lol, I just need a break

sharp geyser
#

If you don't understand it and something happens no idea how to debug it

#

I need sleep

#

But waffle made it so algorithms is all I can think of pandasad

earnest phoenix
#

the one gave me that code is someone um what its called..

#

brother?

#

maybe

#

he knows coding very well

#

so i just blindly copy pasted XD

wheat mesa
#

I am beginning to question that statement after seeing that timer function lol

#

That was a brainfuck and a half

earnest phoenix
#

yeah idk what was that

#

he typed it for me

sharp geyser
#

Is he a js/ts dev?

earnest phoenix
#

yeah

sharp geyser
#

sadge

earnest phoenix
#

he codes in C++

#

very well

#

thats why maybe lol he loves complicated codes

wheat mesa
#

Not the greatest of solutions to a simple problem…

#

I’ll give him the benefit of the doubt though

sharp geyser
#

C++ is a brainfuck for me

earnest phoenix
#

yeah. I'll be fine if I take a break.

wheat mesa
#

C++ isn’t too bad tbh

#

Standard library is bloated though imo

#

C++ is just used for scarily complex shit

sharp geyser
wheat mesa
#

Where’s my beautiful frontend

earnest phoenix
wheat mesa
sharp geyser
wheat mesa
#

I would think that you would not want to go out of bounds here mmLol

sharp geyser
#

If it kept going past the length of activities you'd experience out of bound

#

Waffle taught me out of bounds all too well

earnest phoenix
sharp geyser
#

😔

sharp geyser
#

It's a one line statement

earnest phoenix
#

ah okay

wheat mesa
sharp geyser
#

If you're writing multiple lines it's highly recommend to

earnest phoenix
#

okay

sharp geyser
#

Technically I think you can write it all on one line but separate your stuff with ;

#

Waffle can confirm this

wheat mesa
#

Yes I believe so

sharp geyser
#

You could write your entire bot on one line mmLol

wheat mesa
#

You could write anything on one line

sharp geyser
#

If you do make waffle format it without a linter that'd be fun

wheat mesa
#

Fun fact, python accepts semicolons optionally

#

So you could one line an entire python project

sharp geyser
wheat mesa
#

Fun fact, using C# improves your chances of finding a stable and healthy relationship by 100%

sharp geyser
#

Ok fuck typescript

wheat mesa
#

He’s beginning to believe

sharp geyser
#

Waffle I'm rewriting everything API into cs

wheat mesa
#

Lmao no

#

You’ll give up on that quite quickly

sharp geyser
#

Yes

#

Fuck asp

wheat mesa
#

So so so so so much easier to write it in ts when you have 0 C# experience

sharp geyser
#

Hey I have some C# experience

#

I know basic types

#

Except I found out tuples were a thing earlier but still

wheat mesa
#

You’ll appreciate C# for both its simplicity and complexity, but if you’re like me you’ll dread having to learn 40 different design patterns to accomplish anything with it

sharp geyser
#

Idm C# so far

#

Does C# have async

#

Or the concept of Promises like js does

wheat mesa
#

Async await is a thing in C#

sharp geyser
#

Nice

wheat mesa
#

Tasks are the equivalent of Promises

sharp geyser
#

Ah I see

#

Well I'ma go sleep

earnest phoenix
#

Damn dude u saved me

sharp geyser
#

2:01

earnest phoenix
#

thanks

#

Now I can eat my lunch without any worries

copper cradle
#

Rewrite it in go

vivid fulcrum
#

fun fact

#

c#'s async workflow coined the design you know today

#

async/await keywords etc

split hazel
#

what does the coined mean

vivid fulcrum
#

made a standard or something in that fashion

#

don't know the exact definition

#
adjective
(of a word, expression, etc.) invented or made up:
A coined word, such as Xerox, is one of the most easily protected categories of trademark.
rocky dagger
#

can u force embeds to be wider?

quartz kindle
#

nop

rocky dagger
#

f

slender thistle
#

Feed them until they get overweight

spark flint
#

There’s an annoying embed bug

#

Where timestamps (if “x seconds ago”) constantly get wider and narrower

lament rock
#

sounds like a time precision error either on your viewing device or on whoever's end who created the embed

split hazel
#

time issue

#

@sharp geyser :o why is your library archived

lyric mountain
slender thistle
#

🤣

viral spade
#

Hello, im using discord.js 13.
Is it possible to "hide" certain slash commands from everyone except myself (one userId) for stuff like maintenance commands only used by the bot creator?

Currently the only method i can think of is deploying one set of commands globally for every guild, while having one set of adminCommands deployed only in my personal guild.

compact briar
# viral spade Hello, im using discord.js 13. Is it possible to "hide" certain slash commands f...

no there is not. the only other soultions i have thought of are

  1. have another bot that is private
  2. just check if the interaction.user is you. if not just return.
  3. what i use for my eval is a button in my support discord that only i can see, and i have a modal that runs when i click the button and then it evals whatever i input into the modal. (only using a modal so i can space out things and make it look neater)
tulip ledge
#

you can't hide them, you can however add a permission check or make them guildonly for your dev guild

opaque acorn
#

how is the embed edit in v13

earnest phoenix
#

Bro one verified bot is nuking servers

winter pasture
earnest phoenix
#

Kk wait let me do it

winter pasture
earnest phoenix
#

Kk

#

Thx

spark flint
#

trying to get to "all_domains"

#

but <json object>.data returns undefined

#

tried two things so far

#
connection.onmessage = e => {
    const msg = JSON.stringify(JSON.parse(e.data),null,2);
    console.log(msg.data)
}```
#

and js connection.onmessage = e => { console.log(e.data.data) }

earnest phoenix
#

how do i make this manage role

onyx atlas
#

what

earnest phoenix
#

it needs manage.guild

#

how can i make it be manage.role

earnest phoenix
spark flint
#

good point

#

blame gogle

#

e.data returns a json object

#
{"data":{"cert_index":1056358569,"cert_link":"http://ct.googleapis.com/logs/argon2022/ct/v1/get-entries?start=1056358569&end=1056358569","leaf_cert":{"all_domains":["*.turingengenharia.com.br","turingengenharia.com.br"],"extensions":{"authorityInfoAccess":"CA Issuers - URI:http://r3.i.lencr.org/\nOCSP - URI:http://r3.o.lencr.org\n","authorityKeyIdentifier":"keyid:14:2E:B3:17:B7:58:56:CB:AE:50:09:40:E6:1F:AF:9D:8B:14:C2:C6\n","basicConstraints":"CA:FALSE","certificatePolicies":"Policy: 1.3.6.1.4.1.44947.1.1.1\n  CPS: http://cps.letsencrypt.org","ctlPoisonByte":true,"extendedKeyUsage":"TLS Web server authentication, TLS Web client authentication","keyUsage":"Digital Signature, Key Encipherment","subjectAltName":"DNS:turingengenharia.com.br, DNS:*.turingengenharia.com.br","subjectKeyIdentifier":"C3:E8:7E:5C:B3:20:00:B1:D8:41:EA:BC:AA:FC:46:A9:56:25:14:C8"},"fingerprint":"6C:C0:0D:3A:C0:C3:C4:D0:E2:FD:E4:0E:A1:6F:6F:D8:A0:6B:29:30","issuer":{"C":"US","CN":"R3","L":null,"O":"Let's Encrypt","OU":null,"ST":null,"aggregated":"/C=US/CN=R3/O=Let's Encrypt","emailAddress":null},"not_after":1661799167,"not_before":1654023168,"serial_number":"49F96F2496D775CA2A90F4620A169DED8EF","signature_algorithm":"sha256, rsa","subject":{"C":null,"CN":"*.turingengenharia.com.br","L":null,"O":null,"OU":null,"ST":null,"aggregated":"/CN=*.turingengenharia.com.br","emailAddress":null}},"seen":1654026860.151305,"source":{"name":"Google 'Argon2022' log","url":"ct.googleapis.com/logs/argon2022/"},"update_type":"PrecertLogEntry"},"message_type":"certificate_update"}```
#

example data

simple stump
#

I have this bit of code that reverses an image based on an array of URL's. However, since the process takes so long, using Promise.all is faster in the long run than awaiting. The issue with this is that if I were to append the image in the .then, the images will be appended out of order. Because of this, I have to use Promise.all. But this doesn't make sense if there's a lot of images, so is there a way to sort or append an image at a specific "index"? Or to append an image in order? My goal is to have something like this:

for (let i = 0; i < urls.length; i++) {
  let url = urls[i];
  console.log("Loading " + url);
  imgReverser("/content/" + url).then(canvas => {
    console.log("Saving " + url);
    const uri = canvas.toDataURL('image/jpeg', 0.9);
    sorted.push([uri, i]);
    sorted.sort((a, b) => a[1] - b[1]);

    for (let i = 0; i < sorted.length; i++) {
      if (sorted[i][0] === uri) {
        let newP = document.createElement('img');
        newP.src = uri;
        newP.classList.add('asdfasdf');
        document.getElementById('chapter_container').append(newP, some_index);
      }
    }
  });
}

https://sourceb.in/Z477FpR6wJ

earnest phoenix
spark flint
#

e.data returns that

earnest phoenix
#

Try logging typeof e.data

spark flint
#
const WebSocket = require('ws')
const connection = new WebSocket(`wss://certstream.calidog.io`)

connection.onopen = () => {
    console.log("connected to certstream")
}

connection.onerror = error => {
    console.log(`error: ${error}`)
}

connection.onmessage = e => {
    console.log(e.data)
}```
#

ok

#

wait its a string

#

string

earnest phoenix
#

JSON.parse(e.data).data

spark flint
#

alrighty

#

ty

earnest phoenix
#

You're welcome

spark flint
#

works lmao

earnest phoenix
#

Awesome

spark flint
#

very

earnest phoenix
#

is manage roles on discord.js MANAGE_ROLES

spark flint
#

yes

earnest phoenix
#

or is is MANGAGE_ROLE

earnest phoenix
simple stump
#

My goal is to sorta optimize my script so that it reverses all images as fast as possible, then display the images without having to wait a long time. The imgReverser function can take up to 0.5 seconds per image, meaning an array of 50 links will take 25 seconds to load everything. Currently with the method I have I got that time down to about 5-6 seconds, but it's still way longer than it should be.

tribal crow
#

Hello hello people

#

im here today

#

because i need help with something

#

I want to update one, and only one, object in an array in my database. I've figured out the hard way that

#

await UserSave.findOneAndUpdate({ userID: interaction.user.id, guildID: interaction.guild.id }, { inventory: inventory } );

#

replaces the whole array with 'inventory'

#

so i wonder

#

if any of you know how to do this?

earnest phoenix
# simple stump My goal is to sorta optimize my script so that it reverses all images as fast as...

You can create an image element, append it to the parent element, and modify it's source once it has loaded, so it would all be in order

const chapterContainer =
  document.getElementById('chapter_container');

for (const url of urls) {
  console.log(`Loading ${url}`);

  const image = document.createElement('img');

  chapterContainer.append(image);

  imgReverser(`/content/${url}`).then((canvas) => {
    console.log(`Saving ${url}`);

    image.src = canvas.toDataURL('image/jpeg', 0.9);
  });
}
tribal crow
#

yes :)

tribal crow
#

thats how its sorted

#

so

#

how would i find one of the objects?

earnest phoenix
#

So you want to update one of the objects in the inventory array?

tribal crow
#

yes

earnest phoenix
#

If so, by index or by conditions of whether the object contains a specific value or what?

tribal crow
#

all objects have different "id"s

earnest phoenix
#

So you want to update the object based on their id property?

tribal crow
#

yes

pine nova
# tribal crow yes
Schema.findOneAndUpdate('inventory.id': wtvhere, {
$set: {
'inventory.$.<property>': wtv here
}
}).then().catch()
#

bad indentation cuz on phone

#

😔

earnest phoenix
# tribal crow yes

Then you can use array filters to do so (this example is based on the code you showed), the following example increments the count property of the object with the 4534 as it's id property in the inventory array by 5

await UserSave.findOneAndUpdate({
  userID: interaction.user.id,
  guildID: interaction.guild.id
}, {
  $inc: {
    'inventory.$[findId].count': 5
  }
}, {
  arrayFilters: [{ 'findId.id': '4534' }]
});
tribal crow
#

$[findId]

#

do i replace that with anything?

earnest phoenix
#

Nope, that's just the name of the array filter, set in the arrayFilters property

ancient nova
#

is that a thing exclusive to djs?

pine nova
#

finds a document and update the data in it

tribal crow
pine nova
#

no its a method for mongoose

ancient nova
#

oh that's interesting

earnest phoenix
#

That method is available in both the official MongoDB driver and Mongoose

tribal crow
#

so

ancient nova
#

is it easier to learn than other DBs or harder?

tribal crow
#

its not 4535 every time

tribal crow
earnest phoenix
#

You can just set the ID in the arrayFilters property to the one you want to find based on input for example

pine nova
tribal crow
#

yes

ancient nova
#

anyone knows where I can get ideas for stuff I can add to a bot?

tribal crow
#

so

earnest phoenix
tribal crow
#

idk what it is

earnest phoenix
tribal crow
#

ooooh

#

ok

#

now i get it

ancient nova
#

@earnest phoenix could you tell me the difference between <client>.ws.on and <client>.on

#

I'm trying to see how they work and if I can use anything like that to add a custom event, if that's possible

#

for example an event where someone gets muted or warned

tribal crow
#

what does that mean?

earnest phoenix
# ancient nova <@456226577798135808> could you tell me the difference between `<client>.ws.on` ...

Both the client and it's websocket manager (<Client>.ws) extend the EventEmitter class from the node:events built-in module, the <Client>.on() method adds an event listener for the pre-defined event listeners, such as ready, messageCreate, interactionCreate, and so on, which emit the data they've taken from the Discord API and turned it into a class instance or a more easier-to-work with type of data, although you can add non-pre-defined event listeners, but they won't emit any data unless you do so using the <EventEmitter>.emit() method (<Client>.emit()), the <Client>.ws.on() adds an event listener to the websocket manager of the client, which doesn't really have pre-defined event listeners on the typings (these event listeners can all be listed in Discord's official API documentation), which receives raw Discord API data and is not meant to be used by the user, but rather by the client itself

ancient nova
#

EventEmitter how would I define this though?

earnest phoenix
earnest phoenix
tribal crow
ancient nova
#

okay so any variable I put as 'bar' will be emmited, but how about functions?

#

can I, for example emit an entire function and then do something with it using client.on?

earnest phoenix
#

You can emit anything

earnest phoenix
# tribal crow https://sourceb.in/U7SVSDtbP7

I don't think that error is caused by that execute() method you've got there, probably something with your command handler, although which version of discord.js are you using?

tribal crow
#

v13

ancient nova
#
client.emit('userMuted', getSomethingDoSomething(variable, variable2));

client.on('userMuted', (data) => {
  //what would doing just
  data 
  //by itself do anything? I presume it would return a promise so data() would work to execute the function?

  //for example
  let var1, var2;
  data(var1, var2);
});

#

I don't think that would work though, how would it know what variable and variable2 is

earnest phoenix
ancient nova
#

or maybe just structure the function in the emit instead of calling it in the emit??

tribal crow
#

discord.js@13.4.0

earnest phoenix
#

You should update to the latest version

#

npm update --save

#

Although that error occurs because it tries to create an initial reply to the interaction after an error occurred while executing that command, as the interaction already received an initial response in that command

tribal crow
#

earnest phoenix
#

So you can do

await interaction.reply({
  content: 'An error occured',
  ephemeral: true
}).catch(() =>
  interaction.followUp({
    content: 'An error ocurred',
    ephemeral: true
  })
);
tribal crow
earnest phoenix
ancient nova
#

does anyone know how I can check if args[1] is a valid value, say 1m or 1y?

earnest phoenix
#

You can use a regex for that

ancient nova
#

wait this one time you actually approve of me using regex

#

😮

wheat mesa
#

Oh my he finally found a legitimate use for regex

#

I find it ironic that the one thing you don’t think to use regex for is one of the few things that it should be used for… KEKW

earnest phoenix
#

Test it against that, if it doesn't match then it's invalid

ancient nova
#

am I stupid or what cause those if checks aren't working

#

I did 1y and it didn't show the message

earnest phoenix
#

Have you tried logging both of the timeToMute variable and ms('24h')?

ancient nova
#

I haven't had the chance to, but I'm sure the value is right.. it's not like a massive package with millions of downloads wouldn't work

earnest phoenix
wheat mesa
#

I don’t think the point was the package not working, I think the point he was trying to make is it might not be what you’re expecting

#

Don’t roll along with the mindset of “just because it’s a library it has to work exactly like I expect it to”, you need to test things when you’re debugging

ancient nova
ancient nova
earnest phoenix
#

Avoiding enough testing for debugging purposes will just lead to more confusion while blindly trying random things to try and fix the issue, and waste more time

wheat mesa
#

If you want to save more time, use a debugger

ancient nova
#

that's the value both return

earnest phoenix
#

I'm not asking for the human-readable value, I'm asking for the exact values they return, show it to us

ancient nova
#
        if (member.roles.cache.has(roleToMute.id || member.roles.cache.find(role => role.name === roleToMute).id || roleToMute)) {
            return message.channel.send("The member is already muted.");
        } else {
                const memberHierarchy = member.roles.highest.position;
                const muterHierarchy = message.member.roles.highest.position;
                if (muterHierarchy >= memberHierarchy) {
                    if (args[1]) {
                        const timeToMute = ms(args[1]);
                        const timeToMuteMax = ms("24h");
                        console.log(timeAgo(timeToMute) + timeAgo(timeToMuteMax));
                        
                        // Lets also require us the regex we need to check if the time is valid.
                        const timeValueCheckReg = /(?:\d+\s*(?:[smhdwy]|mo))*/;
                        if (!timeValueCheckReg.test(timeToMute)) return message.channel.send("I couldn't mute because the timeout value provided is not a valid time value.");
                        if (timeToMute >= timeToMuteMax) return message.channel.send("You can't mute for longer than 24 Hours at a time.");
                        try {
                            setTimeout(() => {
                                member.roles.remove(roleToMute);
                            }, timeToMute);
                            
                            return message.channel.send(`:thumbsup: **${member.user.tag}** was successfully muted by **${message.author.tag}** for **${timeAgo(timeToMute)}**.`);
                        } catch {}
                    } else {
                        member.roles.add(roleToMute);
                    }
                } else {
                    return message.channel.send("Could not mute the mentioned user, because they're higher in power hierarchy than you.");
                }
        }
#

sure

#

30000 and 86400000

#

@earnest phoenix it does return the correct value it seems, but then what is causing the error

earnest phoenix
#

Error?

ancient nova
#

no errors

#

I used a try catch just in case I guess it would be better if I remove it for testing

earnest phoenix
#

what is causing the error
no errors

sharp geyser
#

I'm dumbfounded by this interaction

ancient nova
#

man

ancient nova
ancient nova
#

@earnest phoenix your reg is bugging out

split hazel
#

💀

#

i hate regex

split hazel
#

the library will return NaN if the number is invalid

#
ancient nova
#

something like that?

split hazel
#

for some reason when directly checking for NaN like that it sometimes bugs out and says its not nan even though it is

#

you should use isNaN(value)

earnest phoenix
ancient nova
#

I feel like isNaN bugs out a little bit more for some reason for me

#

isNaN(float) <--- false

#

is that supposed to be the case?

split hazel
#

very stupid considering you can check for undefined and null just fine

earnest phoenix
split hazel
#

ah so its to keep the math weebs happy

#

are these kind of like

#

imaginary numbers

earnest phoenix
#

Yes

split hazel
#

actually now i do wonder what happens if you try to square root a negative number

#

since when does c++ have-

#

talk about the language being bloated

#

i'll try c then

#

nevermind c is worse

#

bro c is actually fucked

#

not touching that shit again

wheat mesa
#

wait wtf

#

is it fucked because you're formatting a double as int?

split hazel
#

idk man honestly i dont want to know

exotic meadow
#

how could i have an array (or dictionary) of items and load them in as choices in a slash command

#

let dictionary = {
  "name": "description"
}


// this part would be inside of the slash command creation
choices: [
           {
              // add name and description here          
           }
#

like this

#

i want to be able to add and remove things from the dictionary through other code and have it update

earnest phoenix
spark flint
#

I can't send a twitter DM with twit, it returns js Unhandled rejection Error: Sorry, that page does not exist.

#

hoping someone here knows twit js lmao

split hazel
#

well the page doesnt exist

#

:)

vivid fulcrum
spark flint
#

thats the default twitter error

vivid fulcrum
#

outdated lib

spark flint
hollow bobcat
vivid fulcrum
spark flint
#
T.post("direct_messages/new", {
            user_id: "1167570399959420929", // USER_ID is parameter from directMsg object
            text: reportMsg
        });```
#

it was a string anyways

vivid fulcrum
#

hm, not that familiar with the twitter api as much, try snooping around that repo's issues

#

quick browse over at the twitter api docs gave me this

#

but that's using events

#

here's the link to the doc regardless

lyric mountain
#

Well at least the "code" overlay isn't a tree call or tracert

spark flint
wheat mesa
#

This... seems like a very abusable idea

spark flint
#

Its locked for just select approved users

#

Everyone else only has the basic whois domain and ip buttons and the report buttons

#

Not the report to registrar and report to ASN buttons

frosty ruin
#

hi

timber fractal
#

im using the npm dependency passport-local to authenticate users, but for some reason every time i use passport.authenticate it goes to the failureredirect page, and i cant find why. what could be the cause of this?

fathom sonnet
#

Hey guys, so when i want to DEBUG ma welcomer.js file, i got this error (client.on) is not a function.

here is my code: welcomer.js

const client  = require('../index')
const Schema = require('../database-schema/welcomeSchema')
const { MessageEmbed, Discord } = require('discord.js')
const {welcomeMsg, RandomMsg} = require('../data/wlcmMsg')


        client.on('guildMemberAdd', async (member) => {
                    Schema.findOne({ Guild: member.guild.id }, async (e, data) => {
                        if (!data) {
                            return console.log('No channel to send the message!')
                        }
                            
        
                        const channel = member.guild.channels.cache.get(data.Channel)
                        let role = member.guild.roles.cache.get(data.Role)
        
                        const embed = new MessageEmbed()
                            .setTitle('Welcome!')
                            .setColor('#ff173e')
                            .setDescription(`${RandomMsg}`)
                            .setTimestamp()
        
                        channel.send({ embeds: [embed] })
        
                        /**
                         * 
                         *
                         * Guild.rulesChannel
                         * 
                         */
        
                        member.role.add()
                    })
                })       
split hazel
fathom sonnet
# split hazel show the contents of ../index.js

here, my whole code: ```js
const { Client, Intents, Collection, Interaction, MessageEmbed, Guild } = require('discord.js')
const { CLIENT_ID, OWNER_ID, prefix } = require('./json/config.json')
const { Routes } = require('discord-api-types/v9')
const { REST } = require('@discordjs/rest')
const mongoose = require('mongoose')
const { GiveawaysManager } = require('discord-giveaways')
const { Schema } = mongoose
require('dotenv').config()
const { readdirSync } = require('fs')

const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_BANS, Intents.FLAGS.GUILD_INVITES , Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_MESSAGE_REACTIONS, Intents.FLAGS.DIRECT_MESSAGE_REACTIONS ] })
require('./systems/giveawaysys.js')(client)

module.exports = client

client.on('ready', () => {
console.log('Apolo is alive!!')

mongoose.connect(process.env.MONGO_DB || '', {
    keepAlive: true,
})

setInterval( () => {
    client.user.setActivity(`Serving on ${client.guilds.cache.size} servers.`, { type: 'WATCHING' })
}, 60000)

})

const rest = new REST({
version: "9"
}).setToken(process.env.TOKEN)

client.commands = new Collection()
client.events = new Collection()
const commands = []

const commandFolders = readdirSync('./commands')

for (const folder of commandFolders) {
    const commandFiles = readdirSync(`./commands/${folder}`).filter(files => files.endsWith('.js'))
for (const file of commandFiles) {
    const command = require(`./commands/${folder}/${file}`)
    commands.push(command.data.toJSON())
    client.commands.set(command.data.name, command)
}
}

rest.put(Routes.applicationCommands(CLIENT_ID), { body: commands })
.then(() => console.log('Successfully registered application commands.'))
.catch(console.error)

client.on('interactionCreate', async (interaction, message) => {
if (!interaction.isCommand()) return

const command = client.commands.get(interaction.commandName)

if(!command) return    
const WarningEmbed = new MessageEmbed()
.setTitle('Warning!!')
.setDescription(`You are not allowed to use this command here!!`)
.setColor('RED')
.setTimestamp()

if(!interaction.guild) return interaction.reply({embeds: [WarningEmbed]})

try {
    await command.execute(interaction, client, message)
}
catch(err) {
    console.log(err)

    await interaction.reply({
        content: 'Error has occured and Im not able to reply!',
        ephemeral: true
    
    })
}

})

client.login(process.env.TOKEN)
// client.dbLogin()

#

i exported client in index.js so i should be able to use it inside welcomer.js but still nothing

#

ok, debuged without errors now, but still need to find the reason why its not sending any messages

split hazel
#

I'm not sure it should work

#

can you log client inside of welcomer?

fathom sonnet
sacred aurora
#

i don't think you should do it that way

#

making an event handler would a better way

#

similar like you handle the command