#development

1 messages ¡ Page 2039 of 1

ancient nova
#

yep

#

it's working

sharp geyser
#

Could of said that instead of us still trying to help

#

:p

ancient nova
#

my bad I thought you just wanted to know what was wrong Joeidk

sharp geyser
#

Well yes cause that helps with helping u PepeHands

wooden ember
#

how would you get the length of msg.content?

#

is it just msg.content.length?

split hazel
#

yeah

wooden ember
#

im really tired so if i soulnd dumb thats why

#

wait really

#

damn

sharp geyser
#

yes

split hazel
#

being real with you

wooden ember
#

fair

#

some one managed to break my bot buy sending it a 3k character msg

#

didnt even know that was a thing tbh

sharp geyser
#

2k for non nitro users 4kfor those who do have nitro

wooden ember
#

oh fair enough

#

ima just make it send an error to the user to shorten the msg

sharp geyser
#

Up to you

wooden ember
#

yeah cuz the bot cant send msgs over 2k

#

and it to early to deal with thrying to make its send two msgs

sharp geyser
#

Sending two messages can get messy to begin with

dry imp
#

misty i finally make a github account

sharp geyser
#

Good

#

now you can actually be cool

#

jk

dry imp
#

imma spread beautifully written code with correct indentation

split hazel
sharp geyser
dry imp
#

later when im on laptop

sharp geyser
#

okie

sharp geyser
#
    async fetch(id: Snowflake, options: MessageFetchOptions = { cache: true }) {
        if (options.cache) {
            const response = await this.client.rest.get(`/channels/${this.channelId}/messages/${id}`);
            this.channel.messages.set(id, response);
            return response;
        }
        return this.channel.messages.get(id);
    }

Should I cache if it is true, or should I check cache if it is true

#

I don't really think it matters but I want your guys opinion on this

hybrid cargo
#

I would suggest to keep the cache's purpose as, if it is true, the bot checks the cache for the message, if not goes to fetch the message. If cache is false, it fetches the message directly from discord itself. So the user could choose between directly making a request to discord, or to possibly save a request

quartz kindle
#

that wouldnt be very intuitive

sharp geyser
#
    async fetch(id: Snowflake, options: MessageFetchOptions = { cache: true }) {
        return this._parse(
            options.cache
                ? this.channel.messages.get(id)
                : await this.client.rest.get(`/channels/${this.channelId}/messages/${id}`),
        );

So you mean like this then?

quartz kindle
#

especially as discord.js already uses the cache option to mean a different thing

sharp geyser
#

Are you talking about me tim or vis?

quartz kindle
#

both

sharp geyser
#

I was thinking when using the term cache, it would fetch from discord itself and cache it then return, and if it is false it would just fetch from the cache and return

quartz kindle
#

discord.js uses the cache option for a different thing

sharp geyser
#

I see

#

They probably use it in a sense of if it is true check cache first right?

quartz kindle
#

their fetch method always checks cache first regardless, the cache option just toggles whether the returned data should be cached or not

sharp geyser
#

Ah, that makes sense

quartz kindle
#

they use the force option to not check cache before fetching

sharp geyser
#

What is the point of not checking cache first tho

#

if it is in cache it saves you from making a pointless request

quartz kindle
#

in rare situations its possible that the cached data is bad/broken/modified/corrupted

#

for example if you somehow accidentally cache a partial

sharp geyser
#

I see

quartz kindle
#

channels.set(id, { id })

#

then the fetch method would not fetch, even if the cached channel only has the id and nothing else

sharp geyser
#

the guild channels I cache to the client are partials

dry imp
#

anyone here use beautifulsoup4?

sharp geyser
dry imp
#

scraping lib

#

fandom site is annoying af

sharp geyser
#

Seems like you just give it something to parse and then you can access what you need

earnest phoenix
#

It's just Cheerio for Python

dry imp
#

misty, the structure of the site makes me wanna kms

sharp geyser
#

This is why you dont use python kidding

dry imp
sharp geyser
#

make your own scrapper

#

ez

dry imp
#

but the fandom site is the problem

sharp geyser
#

make a better fandom site ez

pale vessel
fathom sonnet
#

hii guys, so i have this code for my clear command on my old bot, and its used with prefix, i would like to create same but with slash commands any idea on how could i do that?

#

and this is code with slash commands, ofc it will not delete msg, this was just test so I can see will everything work

fathom sonnet
#

hehe great... 😐

spark flint
fathom sonnet
#

oh...tnx

spark flint
#

Or just interaction.user for the user object

fathom sonnet
#

yea, i need to check if user have permissions to use specific commands

spark flint
#

You’ve just copy pasted some code into a slash commands handler, make sure you define everything

split hazel
#

anyone know how you make it so instead of a new line it adds an ellipsis for the link

#

i tried text-decoration: ellipsis but it didnt work

pallid zinc
#
text-overflow:ellipsis;
``` maybe what you are looking for
earnest phoenix
#

anybody got this github issue before? this is my first time getting this issue

spark flint
#

whats the issue

#

oh i see

#

try selecting the repo again

earnest phoenix
#

oki

#

still the same

lyric mountain
#

try doing git status on cli to see if anything is unadded

#

if so, just do git add .

earnest phoenix
#

Oki

earnest phoenix
lyric mountain
#

did u commit already?

earnest phoenix
#

i stashed everything 😳

lyric mountain
#

well then, that's why it says nothing changed

earnest phoenix
#

oh

#

is there a way to reverse it?

lyric mountain
#

you unstash it

earnest phoenix
#

how? restoring everything? through a command?

lyric mountain
earnest phoenix
lyric mountain
#

are u sure u stashed?

earnest phoenix
lyric mountain
#

do git diff origin/master

earnest phoenix
#

oki

lyric mountain
#

or origin/main if ur using the new github naming scheme

earnest phoenix
lyric mountain
#

is ur remote branch named main?

earnest phoenix
#

yes

lyric mountain
#

then idk what u did

earnest phoenix
#

me too

#

i went to bed last night

#

and when i woke up this issue was there

lyric mountain
#

did u check if the changes weren't saved to remote?

#

like, on github

earnest phoenix
#

remote? but there is only one branch which is the main branch...

lyric mountain
#

you have a remote repository no?

earnest phoenix
#

no

lyric mountain
#

that IS the remote repository

#

remote = not on ur pc

earnest phoenix
#

oh my bad

lyric mountain
#

looks like u already pushed to it

earnest phoenix
#

no i worked on it via the website

lyric mountain
#

then u need to pull the changes

#

git pull

earnest phoenix
#

oh oki lemme try

#

Your remote identifier is broken, refs/remotes/origin/main is invalid

#

oh- is there a way to fix it?

#

Delete the local .git/refs/remotes/origin/main file/directory on the working directory of the project and run git fetch to fetch the original identifier

#

uhm... how do i do that? i am not quite sure esp with commands

#

rm -rf <path>

lyric mountain
#

careful with that command

earnest phoenix
#

oki

#

uhmm idk... nothing seems to be working...

#

i googled how to fix it earlier on but nothing works

slender thistle
#

@vivid fulcrum You got any advice on site accessibility?

digital swan
#

typescript error with new discordjs version?

sharp geyser
#

What the fuck

#

If you are using the master version of djs don't

#

it isn't stable

#

I'd highly recommend downgrading

digital swan
#

no its the last released version

#

13.7.0

sharp geyser
#

I see, you could try asking in the djs server then I am sure by now people have started complaining about it and the actual pros who use djs has found a fix

digital swan
quartz kindle
digital swan
earnest phoenix
#

discord.js where every update breaks the TypeScript typings

digital swan
#

nah its not on strict mode i dont believe

earnest phoenix
quartz kindle
#

set strict: true in compilerOptions of tsconfig.json

digital swan
#

dont think it errors for djs anymore but theres now 4.4k errors in my code 😢

wheat mesa
#

Lmao

quartz kindle
#

djs requires using ts in strict mode

dry imp
#

lmao what

#

why so mucg

#

h

wheat mesa
#

I don’t get the point of not using strict mode in ts

earnest phoenix
#

Using TypeScript without strict mode is like using a bulletproof vest but it's not actually bulletproof

safe rose
#

anyone wanna send me some

split hazel
#

using typescript is like using performance enhancing drugs

#

it'll help but it can fuck you over

split hazel
#

I can send you some

#

im working on this cool email

slender thistle
#

Get some

quartz kindle
split hazel
#

all is good until typescript tells you you cannot do something

quartz kindle
split hazel
#

but then you can use any or ts-ignore!!!!!!

cinder patio
#

it happens every 5 seconds if your code is shit 😩

quartz kindle
#

my bacalhau is shit

spark flint
#

ok debate time

#

i'm making an antiscam lib

#

is it better to emit events with EventEmitter from its own class, or should the user pass the client object and emit events from the client class so users can handle the event from their events folder

#

(djs)

slender thistle
#

The first option raises the question of client object access in the events

spark flint
#

a lot of djs specific libs i see handle it like that

#

pass the client object so it can emit events

earnest phoenix
#

The first option would be the most ideal, the second option would not only confuse those who read the code but it also breaks typings, so it's better to just emit them from it's own class

spark flint
#

ah ok

#

i tested today, its as simple as literally doing client.emit(<eventName>, <whatever i need to pass>)

sharp geyser
#

Are you proud of me :)

earnest phoenix
#

Of course, I'm proud of you

sharp geyser
#

:D

#

I at least fixed the bug I was experiencing

split hazel
#

guys

#

is there a way to run a specific event handler before any other handler in js:):(

cinder patio
#

like EventEmitter callback? Is that what you mean by handler

split hazel
#

nieee

#

nodejs nono

#

browser yesyes

cinder patio
#

I searched a bit and I don't think it's possible

lament rock
#

so. I think I made something cursed. the @types/node package exports Object.assign as a weird definition. It has multiple type signatures for merging up to 8 Objects I believe. index signature being target & source. Next one being target & source1 & source2 and so on and so forth.

This can be an issue because you might want to merge more than however many signatures there are and still get typings. I present to you my cursed solution;

type Assign<T extends { [k: string | number | symbol]: any }, SR extends Array<{ [k: string | number | symbol]: any }>> = SR extends Array<infer O> ? T & O : never;
fathom sonnet
#

so i have this code, which should be used to ban members from the server, but I also got this error, so if could anyone help me on what i do wrong, it would be nice```js
const { SlashCommandBuilder } = require('@discordjs/builders')
const { DeveloperID, OwnerID } = require('../config/config.json')
const { Permissions, member, Message } = require('discord.js')

const run = async (client, interaction) => {
let member = interaction.options.getMember('user')
let duration = interaction.options.getNumber('duration')
let reason = interaction.options.getString('reason')

if(!member) return interaction.reply('Invalid Member')

try {

    await interaction.guild.members.ban(member, duration, reason)
    return interaction.reply(`${member.user.tag} Has been banned from the server!`)

} catch(err) {
    if (err)
    console.error(err)
    return interaction.reply(`Failed To Ban ${member.user.tag}`)
}

}

module.exports = {
data: new SlashCommandBuilder()
.setName('ban')
.setDescription('Ban user from the server')
.addSubcommand(subcommand =>
subcommand
.setName('user')
.setDescription('User you want to ban')
// .setRequired(true)
)
.addSubcommand(subcommand =>
subcommand
.setName('duration')
.setDescription('Duration of the BAN')
// .setRequired(true)
)
.addSubcommand(subcommand =>
subcommand
.setName('reason')
.setDescription('eason of the BAN')
// .setRequired(true)
)

/*
async execute(interaction, member, message) {

    if (!interaction.user.id === DeveloperID || interaction.user.id === OwnerID || interaction.user.id.permissions.has('BAN_MEMBERS')) {
        interaction.reply('You Dont Have Required Permissions To Use This Command!')
        return
    }
    if (interaction.user.id === DeveloperID || interaction.user.id === OwnerID || interaction.user.id.permissions.has('ADMINISTRATOR')) {
        interaction.reply('Mentioned Member Has Been Banned')
        return
    }
}

*/
}

wheat mesa
#

Well, your code has a LOT of things wrong with it

#

This is commented out either on purpose or on accident; but regardless, you’re not passing the arguments in the right order

fathom sonnet
#

and that is not very importnat

wheat mesa
#

Well, there’s no execute function while it’s commented out

fathom sonnet
#

actualy

wheat mesa
#

So command.execute() does not exist

fathom sonnet
#

that is used so owner of the bot or it developer can use this command either if they have permissions or no (if they want to use it on diferent servers)

wheat mesa
#

You have not exported an execute function to go along with your command

#

That’s why you’re getting that error

#

That function does not exist

fathom sonnet
#

ah amm uncomented async but yea still have things to fix

#

now i dont getting error but bot dosent respond

wheat mesa
#

Can you show the code you’re using now?

#

You’re probably still passing the arguments in the wrong order

fathom sonnet
#

well... ```js
const { SlashCommandBuilder } = require('@discordjs/builders')
const { DeveloperID, OwnerID } = require('../config/config.json')
const { Permissions, member, Message } = require('discord.js')

const run = async (client, interaction) => {
let member = interaction.options.getMember('user')
let duration = interaction.options.getNumber('duration')
let reason = interaction.options.getString('reason')

if(!member) return interaction.reply('Invalid Member')

try {

    await interaction.guild.members.ban(member, duration, reason)
    return interaction.reply(`${member.user.tag} Has been banned from the server!`)

} catch(err) {
    if (err)
    console.error(err)
    return interaction.reply(`Failed To Ban ${member.user.tag}`)
}

}

module.exports = {
data: new SlashCommandBuilder()
.setName('ban')
.setDescription('Ban user from the server')
.addStringOption(option =>
option
.setName('user')
.setDescription('User you want to ban')
// .addUserOption(option => option.setName('target').setDescription('The user'))
// .setRequired(true)
)
.addStringOption( option =>
option
.setName('duration')
.setDescription('Duration of the BAN')
// .setRequired(true)
)
.addStringOption(option =>
option
.setName('reason')
.setDescription('eason of the BAN')
// .setRequired(true)
),

async execute(interaction,client) {

/*
if (!interaction.user.id === DeveloperID || interaction.user.id === OwnerID || interaction.user.id.permissions.has('BAN_MEMBERS')) {
interaction.reply('You Dont Have Required Permissions To Use This Command!')
return
}
if (interaction.user.id === DeveloperID || interaction.user.id === OwnerID || interaction.user.id.permissions.has('ADMINISTRATOR')) {
interaction.reply('Mentioned Member Has Been Banned')
return
}
}
*/
}
}

wheat mesa
#

My man you have all the code inside of your execute function commented out of course it’s not going to respond 😆

fathom sonnet
#

yea lemme try uncommenting this

#

TypeError: Cannot read properties of undefined (reading 'has')

#

after i uncommented permissions

wheat mesa
#

interaction.user.id is a string, it won’t have any permissions property

lament rock
#

interaction.member.permissions.has

#

but interaction.member is not always present, so you'll have to set the dm permissions as false or check if the command was executed in a DM

celest gate
#

it's taking too long

fathom sonnet
#

well.. u will have to wait for it to finish

celest gate
fathom sonnet
#

and from some reason i get this error of undefined id: ```js
async execute(interaction,client) {

    if (!interaction.member === DeveloperID || interaction.member === OwnerID || interaction.member.permissions.has('BAN_MEMBERS')) {
        interaction.reply('You Dont Have Required Permissions To Use This Command!')
        return
    }
    if (interaction.member === DeveloperID || interaction.member === OwnerID || interaction.member.permissions.has('ADMINISTRATOR')) {
        interaction.reply('Mentioned Member Has Been Banned')
        return
    }
}
quartz kindle
split hazel
#

@quartz kindle mail is torture 💀

#

i think i need to watch a low level email crash course before i can continue

quartz kindle
#

good luc

split hazel
fathom sonnet
# quartz kindle console.log(interaction.guild.roles.cache)

ok, here we go: ```
Collection(0) [Map] {}
TypeError: Cannot read properties of undefined (reading 'id')
at get cache [as cache] (D:\discord_bot\Sushi_Bot\node_modules\discord.js\src\managers\GuildMemberRoleManager.js:36:101)
at get permissions [as permissions] (D:\discord_bot\Sushi_Bot\node_modules\discord.js\src\structures\GuildMember.js:262:39) at Object.execute (D:\discord_bot\Sushi_Bot\commands\ban.js:40:33)
at Client.<anonymous> (D:\discord_bot\Sushi_Bot\index.js:45:23)
at Client.emit (node:events:527:28)
at InteractionCreateAction.handle (D:\discord_bot\Sushi_Bot\node_modules\discord.js\src\client\actions\InteractionCreate.js:83:12)
at module.exports [as INTERACTION_CREATE] (D:\discord_bot\Sushi_Bot\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (D:\discord_bot\Sushi_Bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:351:31)
at WebSocketShard.onPacket (D:\discord_bot\Sushi_Bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22) at WebSocketShard.onMessage (D:\discord_bot\Sushi_Bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)

lament rock
#

looks like the Collection is empty

#

also, if you're using vscode, turn on checkJS

quartz kindle
#

or do you have the guilds intent disabled?

earnest phoenix
#

hey, how can this be improved?

fathom sonnet
#

make a list

earnest phoenix
#

can the wording, style, layout, etc be changed?

#

wdym

fathom sonnet
#
- Incomming call to {channel} from {user}
- Call Satrted by {user} from {channel}
- To answer use /answer
- To Decline use /decline
slender thistle
#

The text is fine imo, maybe just add an empty line before the last one

#

That way it's

There is ...
The call was started ...

Answer the call by using `/answer` or decline with `/decline`
#

There

lyric mountain
#

put it as footer

errant dragon
#

I'm having trouble with a Java class

sage bobcat
#

One message removed from a suspended account.

errant dragon
#

In one class I have a method
Public void decider
And in the other I have

Calculator calculator = new Calculator;
calculator.decider();

But I'm getting a Cannot make a static reference to a non static method error

vivid fulcrum
#

what is your exact code

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

errant dragon
sage bobcat
#

One message removed from a suspended account.

quick ginkgo
#

and how you dont add () to the new Calculator

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

sage bobcat
#

One message removed from a suspended account.

quick ginkgo
#

same

#

or java

vivid fulcrum
quick ginkgo
#

also why is your Public capitalized

sage bobcat
quick ginkgo
#

public should be all lowercase

sage bobcat
#

One message removed from a suspended account.

vivid fulcrum
#

that's why i asked them for the exact code

errant dragon
#
//this is the class in main
    public static void main(String[] args) {
        Area_calculator AC = new Area_calculator();

        Scanner input = new Scanner(System.in);

        System.out.println("Welcome!");
        System.out.println("1) Area calculator\n2) Exit");
        try {
            int x = input.nextInt();
            if (x == 1) {
                Area_calculator.main();
            }
        }
        catch (InputMismatchException e) {
            System.out.println("Invalid input");
        }
    }
sage bobcat
#

One message removed from a suspended account.

quick ginkgo
#

WHAT THE FUCK

errant dragon
#

wait i just noticed it

quick ginkgo
#

EW

#

YOU DEGENERATE

sage bobcat
#

One message removed from a suspended account.

errant dragon
#

ive used it for maybe an hour...

lyric mountain
#

Area_calculator kekw

vivid fulcrum
#

literally calm down

lyric mountain
#

I'm gonna die

quick ginkgo
#

i use camel case in EVERYTHING
python, java, c#, c++

lyric mountain
#

that's friggin murder

quick ginkgo
#

its the sexiest

vivid fulcrum
#

stop being toxic

errant dragon
#

good to know this was a good spot to ask

sage bobcat
#

One message removed from a suspended account.

quick ginkgo
sage bobcat
#

One message removed from a suspended account.

vivid fulcrum
#

im so fed up with people in this channel acting elitist, either provide feedback or just shut up, calling people degenerates makes you one

#

joke or not

#

doesn't matter

quick ginkgo
#

im 100% bias

vivid fulcrum
#

@solemn latch deal with this <33

quick ginkgo
#

dudes calling the mods on me rip

#

@sage bobcat i discovered jquery recently, and oh my god its hot as hell

vivid fulcrum
#

i don't have the nerves to continue on with this lol, you got called out on your behavior and now you're trying to switch up subjects really quick and seem like a better person

#

toxic

quick ginkgo
#

no offense, i dont care

sage bobcat
#

One message removed from a suspended account.

quick ginkgo
#

anyways

sage bobcat
#

One message removed from a suspended account.

quick ginkgo
#

faith

$(document).on('click', 'a[href!="javascript:void(0);"][target!="_blank"]', function(event) {
    event.preventDefault();
    $("#root").fadeTo(500, 0);
    $("#root").promise().done(function(){
        window.open(event.target.getAttribute("href"), event.target.getAttribute("target")!=undefined ? event.target.getAttribute("target") : "_self");
    })
});
setTimeout(function(){
    list = $(".caret");
    lsize = list.length, size = 0;
    list.each(function(){
        if($(this).parent().attr('caret-text')!=undefined){
            for(i = 0; i < $(this).parent().attr('caret-text').length; i++){
                var $this = $(this);
                setTimeout(function(value, last){
                    $this.before($this.parent().attr('caret-text').charAt(value));
                    if(value == last-1){
                        $this.remove();
                        size++;
                        if(size==lsize){
                            $("#content").fadeTo(1000,1);
                        }
                    }
                }, (($this.parent().attr('caret-speed')!=undefined?parseInt($this.parent().attr('caret-speed')) : 200)*i), i, $(this).parent().attr('caret-text').length)
            }
        }
    })
}, 1000)
#

its hot

solemn latch
#

cry is kind of right, please dont insult people based on their code/personal preferences.

sage bobcat
#

One message removed from a suspended account.

sage bobcat
#

One message removed from a suspended account.

quick ginkgo
vivid fulcrum
#

SPAs are where there cool kids are at in 2033

#

2022

quick ginkgo
#

what the fuck is a SPA

sharp geyser
#

Single Page Application

sage bobcat
#

One message removed from a suspended account.

vivid fulcrum
#

single page app - react, angular etc

quick ginkgo
sharp geyser
#

How is it ew tho

#

it is becoming a standard practice now a days

quick ginkgo
#

why

sharp geyser
#

It is faster for one

vivid fulcrum
#

wellllll

quick ginkgo
#

what if you have a lot of information

#

to display

sharp geyser
#

I've noticed it is faster at least

vivid fulcrum
#

SPAs are meant just for that, apps that contain lots of information or routes

quartz kindle
vivid fulcrum
#

jquery is fine if you're doing some light websites like a portfolio

sage bobcat
#

One message removed from a suspended account.

quick ginkgo
#

what if you want a user to be able bookmark certain things

quick ginkgo
sage bobcat
#

One message removed from a suspended account.

quartz kindle
quick ginkgo
#

that sounds invasive

sage bobcat
#

One message removed from a suspended account.

quartz kindle
#

js can access the browser history and modify the url without reloading the page

sage bobcat
#

One message removed from a suspended account.

quick ginkgo
#

thats invasive as fuck

quartz kindle
#

and js can also detect url changes to change content

quick ginkgo
sage bobcat
#

One message removed from a suspended account.

vivid fulcrum
#

spsaking of SPAs, i just learned about solid - https://youtu.be/hw3Bx5vxKl0
seems like a really nice alternative to react without virtual DOM

SolidJS is a JavaScript framework for building fast, declarative UIs on the web. It shares many ideas with React, but does not use the virtual DOM to deliver a more performant and pragmatic developer experience.

#webdev #programming #100SecondsOfCode

🔗 Resources

Solid Docs https://www.solidjs.com/
Solid GitHub https://github.com/solidjs/solid...

▶ Play video
quick ginkgo
quartz kindle
sage bobcat
#

One message removed from a suspended account.

quick ginkgo
#

motherfucker

#

2003

quartz kindle
#

i still prefer svelte because i dont really like react's api

sage bobcat
#

One message removed from a suspended account.

quick ginkgo
#

im 18??

#

nerd

vivid fulcrum
#

have yet to try out svelte but it seems like it has a nice niche

sage bobcat
quick ginkgo
vivid fulcrum
#

i love JSX though so solid has my priority rn

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

quick ginkgo
#

well can you illegally operate a forklift?

sage bobcat
#

One message removed from a suspended account.

quick ginkgo
#

i refuse to have any respect for anyone

sage bobcat
#

One message removed from a suspended account.

quick ginkgo
#

when you come down to my shithole and pay for it?

sage bobcat
#

One message removed from a suspended account.

quick ginkgo
#

i aint made of money granny

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

hi

sage bobcat
#

One message removed from a suspended account.

quick ginkgo
quick ginkgo
#

@earnest phoenix i was speaking of things such as ✨ murder ✨

vivid fulcrum
#

that it isn't a web standard anymore

sage bobcat
#

One message removed from a suspended account.

quick ginkgo
#

deal

earnest phoenix
sage bobcat
#

One message removed from a suspended account.

vivid fulcrum
#

in the meantime react creates it's own virtual DOM mmLol

#

its

#

without the apostrophe

sage bobcat
#

One message removed from a suspended account.

quick ginkgo
#

i will single handedly bring back jquery as an industry standard with a lot of force and violence

vivid fulcrum
#

the next standard is WASM mmLol

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

sharp geyser
#

I need to brush up more on web dev related shit

quick ginkgo
#

what the fuck is a wasm

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

quick ginkgo
#

ew

#

fuck that

sharp geyser
#

That sounds pain

sage bobcat
#

One message removed from a suspended account.

vivid fulcrum
#

i compiled an old qt app for wasm and it was actually super fast

sage bobcat
#

One message removed from a suspended account.

vivid fulcrum
#

you don't write wasm yourself

quick ginkgo
#

or actually good

sharp geyser
#

:)

quick ginkgo
#

im going to find you

vivid fulcrum
#

it's going to work fine for most scrapers

quick ginkgo
#

and then cry in front of your face

earnest phoenix
quick ginkgo
#

just so you feel more responsible

#

for your actions

vivid fulcrum
#

however it's useless if the scraper also evaluates js, i.e. if it uses puppeteer

sharp geyser
#

idc

#

cry

#

it makes me happy

#

:)

earnest phoenix
sage bobcat
#

One message removed from a suspended account.

vivid fulcrum
#

it's called growing! :))

#

i resent the way i used to be

sharp geyser
#

I wish I had knowledge

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

vivid fulcrum
#

id call you smart, if you're always yearning to learn more i consider you smart

#

i love when people are actually interested into what they're doing

#

which is a rare occasion in this channel

sharp geyser
#

I am interested in what I do

#

but I fuck it up so bad

#
    constructor(client: BaseClient, data: GuildTextChannelData, guild: Guild) {
        super(client, data, guild);

        this.name = data.name;
        this.position = data.position;
        this.nsfw = data.nsfw;
        this.parentId = data.parent_id;
        this.lastMessageId = data.last_message_id;
        this.topic = data.topic;
        this.lastPinTimestamp = data.last_pin_timestamp;
        this.rateLimitPerUser = data.rate_limit_per_user;

        // Gotta come up with a better way to do this......
        (async () => {
            for (const message of await this.client.rest.get(`/channels/${this.id}/messages`)) {
                this.messages.set(message.id, message);
            }
        })();
    }

like wtf is this

#

I am sure there is a better way to do this

#

😔

#

out here making random functions

vivid fulcrum
#

i do that too when im too lazy to abstract code into its own function lmfao

sharp geyser
#

Lmao

vivid fulcrum
#

arrow functions for the win!

sharp geyser
#

Oh fuck just realized I don't have strict mode on in ts

#

now all my code is erroring

sage bobcat
#

One message removed from a suspended account.

vivid fulcrum
#

i always have it off because i mostly work in react

#

im sorry but i am not typing out React.MouseEvent<T>

#

where T is an unnecessarily long name of an element

#

any is easier

quartz kindle
sharp geyser
sage bobcat
quartz kindle
sharp geyser
#

It was just to see if it actually worked

#

turns out it does

#

I am going to find a better place to actually cache the messages

quartz kindle
#

that wont cache all of them, only the last 50

#

or whatever the default limit is

sharp geyser
#

Well yea

#

Ima include a cache option for messages which will have a limit

#

default will be 50 tho

quartz kindle
#

but like

#

why

#

no lib does that

sharp geyser
#

Mmm, actually I might of though about this wrong haven't I

sage bobcat
vivid fulcrum
#

ram usage skyrockets faster than the stock market

sharp geyser
#

I should not be caching all the existing messages should I

#

Only the ones being sent during the bots process

quartz kindle
#

libs only cache incoming messages

sharp geyser
#

If they want

wheat mesa
#

inb4 “my program keeps crashing idk why”

quartz kindle
#

they dont retroactively attempt to cache past messages

vivid fulcrum
#

not even all of them, there's usually a cache limit

sharp geyser
#

Yea, I just thought of that

vivid fulcrum
#

normally around a 100

#

per channel

sharp geyser
#

Ima let them decide but I will have a default limit

vivid fulcrum
#

i have better idea! download them locally then have your library first query local messages mmLol

#

better performance but at what cost

earnest phoenix
#

Is git rm a command or is it just rm

split hazel
#

@quartz kindle do you know anything about email authentication

#

for some reason every library tells me to set a "username and password"

#

but why

#

you dont need an email or password to send an email to someone do you

lyric mountain
#

it's useful when u gotta update .gitignore files

lament rock
vivid fulcrum
#

you're most likely using an smtp library

#

you need to authenticate with your smtp server to send emails

earnest phoenix
lament rock
#

Windows is rmdir

vivid fulcrum
#

you can also create your own server but that's a hundred times more annoying than just using an already established one like google's

split hazel
#

i dont want to sync or send emails

#

just have a server that can receive them

#

anyways i got it working but still dont know anything about imap/smtp

#

the hard part is now parsing them

earnest phoenix
split hazel
#

luckily there are libraries that already did all the hard work

#

very nice

rocky dagger
#

so i got this basic mongodb filter js let ifAdded = await Dino.findOne({ guildID: guildID, dino: dino }); but if i do console.log(ifAdded, guildID); this is my output https://srcb.in/wNq1lWoZJC but that shouldnt get outputted bc the guildID variable isnt equal to the one that i get from the database

quartz kindle
rocky dagger
#

i want to return the function if the dino variable is already in the array and guildID is already declared

#

so i get a input where guildID is 123 and dino is pt i want to check if thats already in the collection and if it is i want it to return a message

#

if that makes sense

quartz kindle
#

then you probably want something like ```js
.findOne(
{
$and: [
{ guildID : guildID },
{ dino: { $in: [ dino ] } },
]
}
)

rocky dagger
#

nope, didnt work

quartz kindle
#

or actually thats wrong

#

it should be $elemMatch according to the docs

#
.findOne(
   {
     $and: [
            { guildID : guildID },
            { dino: { $elemMatch: dino } },
          ]
   }
)
#

i think?

#

idk mongo is confusing af, i really dont like it

dry imp
#

true

#

i use mongo

rocky dagger
quartz kindle
#

or is it ```js
.findOne(
{
$and: [
{ guildID : guildID },
{ dino: { $elemMatch: { $eq: { dino: dino } } } },
]
}
)

quartz kindle
#
const data = await ....findOne({ guildID : guildID });
if(data?.dino?.includes(dino)) {

}
rocky dagger
#

i haven't thought about doing that

rocky dagger
rocky dagger
quartz kindle
#

do you somehow have multiple documents with the same guild id? or maybe you dont have any document with that guild id so it falls back to something else?

#

idk i dont use mongo

rocky dagger
#

then it should log as undefined

quartz kindle
#

what about ```js
.findOne({ $eq: { guildID : guildID } });

rocky dagger
#

nope

#

i gotta figure out this tomorrow its getting late here but thanks for your help

quartz kindle
#

idk i feel like there is something very wrong with your schema

rocky dagger
#

It worked before when I tested it in only one server

sharp geyser
#
Argument of type 'GuildChannels' is not assignable to parameter of type 'GuildTextChannelData'.   Type 'GuildTextChannel' is missing the following properties from type 'GuildTextChannelData': parent_id, last_message_id, last_pin_timestamp, rate_limit_per_user, guild_id

At this point I don't get what I am doing wrong

#

I get what the error is stating, but I am sure that this should be working

#
        if (client.options.cache?.channels) {
            for (const rawChannel of data.channels.values()) {
                switch (rawChannel.type) {
                    case ChannelTypes.GUILD_TEXT: {
                        const textChannel = new GuildTextChannel(this.client, rawChannel, this);
                        this.channels.set(textChannel.id, textChannel);
                        break;
                    }
                    case ChannelTypes.GUILD_VOICE: {
                        // @ts-expect-error
                        const voiceChannel = new GuildVoiceChannel(this.client, rawChannel, this);
                        this.channels.set(voiceChannel.id, voiceChannel);
                        break;
                    }
                    case ChannelTypes.GUILD_CATEGORY: {
                    }
                }
            }
        }
quartz kindle
#

show full error

sharp geyser
#

That is the full error

#

🤔

quartz kindle
#

wheres the line numbers and shit

sharp geyser
#
const textChannel = new GuildTextChannel(this.client, rawChannel, this);

Doesn't tell me what line it refers to in the error itself but this is one of the two affected

#

the other is the new GuildVoiceChannel()

quartz kindle
#

show more code then

sharp geyser
#

I am unsure of what you'd want to see... as the affected code is already shown?

quartz kindle
#

the code you showed and the error make no sense to each other

#

which variable is of type GuildChannels? how did you define that type? where did you assign that type?

sharp geyser
#

Mmm I thought the error would be self explanatory to the situation. GuildTextChannel takes in 3 params, client, channel data, guild. The GuildTextChannel requires the data to be of type GuildTextChannelData

export interface GuildTextChannelData extends GuildChannelData {
    name: string;
    position: number;
    permission_overwrites?: Array<PermissionOverwrites>;
    parent_id: null | Snowflake;
    last_message_id: Snowflake | null;
    topic: string | null;
    nsfw: boolean;
    last_pin_timestamp: string | null;
    rate_limit_per_user: number | null;
}

Which is this

#

This was my mistake for not supplying proper information my bad

quartz kindle
#

Argument of type 'GuildChannels' is not assignable to parameter of type 'GuildTextChannelData'

#

whatever you are passing into the constructor is not the right type

#

idk what is GuildChannels type

sharp geyser
#
export type GuildChannels = GuildTextChannel | GuildVoiceChannel;

Now that I think about it, this would probably be more helpful to make this be the Data instead of the channel itself ngl

#

Actually that wouldn't make sense nvm

quartz kindle
#

where are you assigning this type?

sharp geyser
#

in my Constants file

quartz kindle
#

are you making rawChannel be this type?

sharp geyser
#

RawChannel is an array of GuildChannels

quartz kindle
#

thats wrong

#

the variable rawChannel has to be of type GuildChannelData

sharp geyser
#

Oh? What do you suggest it to be then?

quartz kindle
#

the variable data.channels is an array of GuildChannelData

#

somehow you are making rawChannel be channel after conversion, instead of before conversion

sharp geyser
#

Actually that makes sense

#

It isn't going to be a channel until it is converted so it should be the data instead

#
                switch (rawChannel.type) {
                    case ChannelTypes.GUILD_TEXT: {
                        const textChannel = new GuildTextChannel(this.client, rawChannel as GuildTextChannelData, this);
                        this.channels.set(textChannel.id, textChannel);
                        break;
                    }
                    case ChannelTypes.GUILD_VOICE: {
                        const voiceChannel = new GuildVoiceChannel(
                            this.client,
                            rawChannel as GuildVoiceChannelData,
                            this,
                        );
                        this.channels.set(voiceChannel.id, voiceChannel);
                        break;
                    }
                    case ChannelTypes.GUILD_CATEGORY: {
                    }
                }

So I could do this then right?

quartz kindle
#

so yeah, the actual problem is nowhere in any of the code you showed

sharp geyser
#

Yea sorry that was my negligence heh

quartz kindle
#

that will work yes

#

but it would be more correct to fix the root type

#

instead of having to cast

sharp geyser
#

Mmmm

#

I thought I wouldn't have to cast cause they all extend GuildChannelData but then again it makes sense it wouldn't

quartz kindle
#

yeah but you were giving it GuildChannels, not GuildChannelData

sharp geyser
#

I changed it to be GuildChannelData

quartz kindle
#

👍

crystal wigeon
#

hey so, i have a large query param in the url

#

but the server says the route itself doesnt exist

#

if i remove a few words from the url it works

#

im not able to find the right words to explain but hope im making sense

#

http://localhost:5013/assets/v3/ultimate-small-2022-03-09T11:40:42.980Z-gbV7b8cP0YCk4nZuh_O4V-imgonline-com-uaaaaaasdasdasdasdasdasd-nkhzpE3Ql4BXXt.jpeg

#

this is the entire url and the route is /v3/:filename

#

if i remove some letters the route is detected and goes to the appropriate function.

spark flint
#

I think the : would have to be url encoded

crystal wigeon
#

i thought the same

#

but you see uaaaaaaass stuff?

#

i remove that and the route works

spark flint
#

Odd

crystal wigeon
#

yeah i find it very odd

#

is it cause the path is too big or something

#

idk

#

its not even max size

drifting cairn
#

that shouldn't be the issue but im not sure what else could be causing it pepeshrug

#

probably to do with the way you handle it server side

crystal wigeon
#

same

#

no the route itself is 404

drifting cairn
#

oh

crystal wigeon
#

it says the route isnt there at all

drifting cairn
#

uhh

crystal wigeon
#

which is why im confused even more

drifting cairn
#

i cant rlly be much help without knowing how you handle the route SAdGE

crystal wigeon
#

its basic express.get()

drifting cairn
#

uhhh

#

lemme try to recreate the issue on my local machine gimme a min

crystal wigeon
#

sure

#

im using fastify btw

#

maybe they have an issue

drifting cairn
#

oh

crystal wigeon
#

yeah i've tried asking in their discord. but you can give it a shot too and let me know ig

drifting cairn
#

cn you show me your code of how you handle it because i tried recreating it and it works fine for me

crystal wigeon
#

you put in the same url?

drifting cairn
#

i made a file with the same name and it worked for me so

crystal wigeon
#

i guess its fastify, im not handling it in any custom way, just using their defaults

drifting cairn
#

most likely yea

crystal wigeon
#

yeah it was an issue with fastify, they have a limit of 100 characters for some reason

#

well actually it states its for ddos protection, they've given the option to increase limit so all good ig

earnest phoenix
#

on the same issue not sure why

earnest phoenix
#

Nvm was able to fix it

fathom sonnet
#

guys is there a way to use all intents in discord.js

earnest phoenix
#

Although that's not what intents are for, you're supposed to choose the ones you only need

fathom sonnet
#

ahh tnx a lot man

quartz kindle
#

or just do intents: 0b11111111111111111

fathom sonnet
#

ah man, I really love these "id" errors: ```js
let user = interaction.options.getMember('user')
const member = interaction.guild.members.cache.get(user.id) || await interaction.guild.members.fetch(user.id).cache
let reason = interaction.options.getString('reason')

#

my bad

#

fixed it

wheat mesa
#

The error isn’t about the id, it’s the object before id that’s null

pale vessel
vestal quiver
#

anyone here know aoi.js?

cinder patio
#

gross

quartz kindle
#

all i know is stay away

vestal quiver
#

oh

#

okay

vivid fulcrum
#

just took a peek at it

rich wren
#

Слава Украине!

vivid fulcrum
#

my god that library goes against all programming conventions in node.js

split hazel
#

bros coding in php without using php with that library

quartz kindle
#

isnt aoi.js just the next version of dbd or whatever it was called

#

bdfd

#

yeah aoi.js is the successor of dbd.js

hybrid cargo
#

So I am trying to fetch the content of a .txt or a .json attachment that is sent as a message in discord. And the content inside is gonna be the message content object. I wanna fetch the file, and get the object inside the file (to be able to use that as a payload to create a message).

Using axios to get the file link (discord's cdn link of the file), to make a get request with the responseType being json. Then I am using JSON.stringify() and then JSON.parse() the stringified element. But for whatever reason, the JSON.parse is still returning a typeof string instead of a object.

What am I doing wrong, or is there a better way to do this?

#

This is the .txt file

earnest phoenix
hybrid cargo
#

*also i just realized that i missed a " after embeds nvm

hybrid cargo
earnest phoenix
#

Oh man, Axios' documentation is the worst

#

You should just use node-fetch or undici honestly

quartz kindle
#

you are stringifying a string

#

res.data is already a string

#

JSON.stringify(string) is basically the string again

#

but with extra quotations and escape characters

earnest phoenix
quartz kindle
#

i just figured out a new way of obfuscating code

#

or rather, json

#

:^)

earnest phoenix
#

Average code of a user in the discord.js support server

hybrid cargo
#

But I face this aswell, when I dont stringify the body

ancient nova
#

how do I give the image a specific name?

earnest phoenix
ancient nova
#

??

earnest phoenix
quartz kindle
hybrid cargo
quartz kindle
#

huh

#

why is the response already an object if you set the responseType to text

ancient nova
hybrid cargo
#

Yeah I'm confused aswell... responseType is mentioned as text, but the response is actually an obj

earnest phoenix
#

Axios is dumb

hybrid cargo
#

fair enough

quartz kindle
#

undici >>>> *

earnest phoenix
#

Hell yeah

hybrid cargo
#

Time to move ig?

ancient nova
earnest phoenix
#

Undici > node-fetch > Axios

ancient nova
#

request > undici

quartz kindle
#

undici > http > node-fetch > axios

ancient nova
#

http > all

hybrid cargo
#

HTTPRequest > Everything

ancient nova
#

okay well

#

I still need help

#

I want something like this but it needs to actually work

quartz kindle
#

undici is actually not based on http like everything else, it was made to replace node's native http

#

so yeah, undici > http > everything else because everything else is built with http

ancient nova
#

some packages use http better than http does itself

quartz kindle
#

thats not physically possible

#

they can use http better than how you would use http yourself

ancient nova
#

meaning, making it easier to work with

quartz kindle
#

but if they can do it, so can you

ancient nova
#

I'm not going to write my own package for that if there's plenty that do it better

quartz kindle
#

you dont need to write a package, http is not hard to use by itself

ancient nova
#

using a package is more convinient though

#

better in the long run

quartz kindle
#

yeah it is, hence why undici is so good as it offers both

#

an easy to use package and is better than http

ancient nova
#

I've never used undici so I can't really have a say so I'll just say that you're right

earnest phoenix
# ancient nova how do I attach is to the message then?
import { MessageAttachment, MessageEmbed } from 'discord.js';

// Initialize the attachment.
const attachment = new MessageAttachment(/* Buffer or URL */, /* Name of the attachment */);

// Initialize the embed.
const embed = new MessageEmbed()
  // Set the attachment to use the attached image, using the `attachment://` prefix and the name of the attachment.
  .setImage(`attachment://${attachment.name}`);

await <TextBasedChannel>.send({
  // The attachments.
  files: [attachment],
  // The embeds.
  embeds: [embed]
});
ancient nova
#

how does files work? does it automatically convert given attachment to setImage?

lament rock
fickle arch
#

I'm using better-erela.js-spotify and erela.js-vk for spotify search, how do I set clientID and secret, I already have them in music.json ?

quartz kindle
earnest phoenix
ancient nova
#

it's quite bad, I rewrite everything once I make sure it works

earnest phoenix
#

Either that API doesn't return an image, or the attachment name has a space when someone uses it, it doesn't work if it has spaces

quartz kindle
#

does it work if you send the url without the attachment? like does discord resolve it into an image?

ancient nova
quartz kindle
#

if you send the attachment, is it sent as a file instead of an image? or does it not send at all?

earnest phoenix
ancient nova
quartz kindle
#

if you send the attachment, is it sent as a file instead of an image? or does it not send at all?

earnest phoenix
ancient nova
#

{'attachment': 'https://some-random-api.ml/canvas/triggered?avatar=https://cdn.discordapp.com/avatars/603128116914683974/36b874038d55d194e27d859bd20094f6.webp?size=1024', 'name': 'mrHeavenli-triggered'}

ancient nova
#

no errors

quartz kindle
#

show what the bot sends

#

the embed

ancient nova
#

an empty embed, like so

quartz kindle
#

if i open that url i get this

boreal iron
#

Remove the size parameter

quartz kindle
#

jpg works for me

#

webp doesnt

ancient nova
#

is it because I set the dynamic to true? I wanted the GIF to be the output

#

so the image is not static

quartz kindle
#

gif and webp does not work for me, jpg and png does work

earnest phoenix
#

It can also be caused because of the attachment name not having an extension, since that also changes what it's supposed to be

ancient nova
#

I broke it

quartz kindle
#

at least you have an attachment now

#

that means its working

#

now you have to give it a valid extension like voltrex said

ancient nova
earnest phoenix
#

Not like that though

ancient nova
#

I want the attachment to show up in the embed

quartz kindle
#

you put the gif here

#

not there

ancient nova
#

oh I see

#

it still gives me the empty part of the embed

#

no image shows

quartz kindle
#

show code

ancient nova
quartz kindle
#

thats the old code

#

show your current code

ancient nova
#

I just swapped where the .gif was

earnest phoenix
#

Uh

#

In the displayAvatarURL() method, remove the dynamic option and replace it with the format option set to png

earnest phoenix
#

It's because the API (The "Some Random API" one) doesn't support GIFs nor WEBP files

ancient nova
#

I see, I just stumbled upon it so didn't really know

#

thanks

fickle arch
#

what is the api/dependacies that bot usually use to find spotify song/album/playlist

#

I can't seems like to make erela work on mine

earnest phoenix
fickle arch
#

javascript

earnest phoenix
fathom sonnet
#

so i making lock command and got error:

#

so how am I suposed to define channel?

#

here you got the code

earnest phoenix
#

You're using parameters that are not even passed or declared, the current channel would be interaction.channel

quartz kindle
#

what even is channel and message in this context?

#

show where you call the execute function

wheat mesa
#

(He passes it as interaction, client I believe @quartz kindle)

quartz kindle
#

then thats obviously gonna be undefined

wheat mesa
#

Learn js before making a discord bot™️

ancient nova
#

any idea why my code sorts all of the most recently added commands to the top? shouldn't it be random?

#
    const sorted = commands.sort((p, c) => p.help.category > c.help.category ? 1 :
      p.help.name > c.help.name && p.help.category === c.help.category ? 1 : -1);
``` I'm sorting it by category, but I don't see why it would line the categories in a specific order if I haven't told it to do so
vivid fulcrum
#

read the docs

#

that method is built specifically for things that you exactly don't want to do

ancient nova
#

I'm trying to get an array of sorted channels and roles

#

and if the value is over a certain length then slice it

#

how come does it say that there is none?

ancient nova
#

can anyone help?

quartz kindle
#

where does it say there is none? also show actual code? not a cut pic that hides part of it

ancient nova
# quartz kindle where does it say there is none? also show actual code? not a cut pic that hides...
    let slicedChannels = message.guild.channels.cache.fetch(channel => `<#&${channel.id}>`);
    if (!slicedChannels) slicedChannels = "No Channels In The Server";
    if (slicedChannels.length > 16 && slicedChannels.length != 0) {
        slicedChannels = slicedChannels.slice(0, 16);
        slicedChannels = slicedChannels.join(", ");
    }
    
    let slicedRoles = message.guild.roles.cache.fetch(role => `<@&${roles.id}>`);
    if (!slicedRoles) slicedRoles = "No Roles In The Server";
    if (slicedRoles.length > 16 && slicedRoles.length != 0) {
        slicedRoles = slicedRoles.slice(0, 16);
        slicedRoles = slicedRoles.join(", ");
    }
#

basically I want to get all the roles and all the channels, if there is none show a text, if there is go ahead and if there is too much slice them and join them via a coma

#

but it says that join is not a function

wheat mesa
#

Why are you checking if slicedRoles.length > 16 && slicesRoles.length != 0

#

That’s redundant

ancient nova
#

if it's not over certain length and if it's not empty

#

that's not redundant

wheat mesa
#

?? Yes it is lol

#

If it’s under 16 it’s not going to return true anyways

#

0 is less than 16

#

So it’s redundant

ancient nova
#

oh yea

#

I'm dumb

#

well it still doesn't work

wheat mesa
#

Just pointing out the redundancy, haven’t looked at the problem really

ancient nova
#

I see

quartz kindle
#

is this your actual code?

#

because that makes zero sense

wheat mesa
#

Is this even a real thing?

quartz kindle
#

pretty sure you want .map not .fetch lol

#

if (!slicedChannels) needs to be if (!slicedChannels.length)

ancient nova
#
    let slicedChannels = message.guild.channels.cache.filter(channel => `<#${channel.id}>`);
    if (!slicedChannels) slicedChannels = ["No Channels In The Server"];
    if (slicedChannels.length > 16) {
        slicedChannels = slicedChannels.slice(0, 16);
    }
    slicedChannels = slicedChannels.join(", ");
    
    let slicedRoles = message.guild.roles.cache.filter(role => `<@&${roles.id}>`);
    if (!slicedRoles) slicedRoles = ["No Roles In The Server"];
    if (slicedRoles.length > 16) {
        slicedRoles = slicedRoles.slice(0, 16);
    }
    slicedRoles = slicedRoles.join(", ");
quartz kindle
#

.filter is also wrong

ancient nova
#

I updated it slightly, although now it says that roles doesn't exist

quartz kindle
#

its .map

#

if (!slicedChannels) needs to be if (!slicedChannels.length)

ancient nova
#

roles is not defined

quartz kindle
#

(role => `<@&${roles.id}>`);

ancient nova
#

this is the error

quartz kindle
ancient nova
#

yeah I just noticed that

#

thanks

#

@quartz kindle do you know how to filter out the channel categories?

#

since they aren't highlighted it looks quite ugly

quartz kindle
#

.filter(x => x.type !== "GUILD_CATEGORY").map(...)

split hazel
#

@quartz kindle sharing a bit of what ive learnt

#

there really isnt many resources on making your own email server so i kind of had to try and fail

#

so to receive emails i think you need to have a running SMTP server with a valid MX record

#

but sending emails gets a little more complicated

#

you need to first lookup the domains MX record (the emails domain) and then connect to the domains SMTP server

#

and once you connect you can then send the email to it

#

i thought it was much simpler than that

#

and I think email servers can verify if the email it is sent from is indeed sent from where it was supposed to be sent from by reverse searching the MX record

earnest phoenix
#

👀

spark flint
#

does anyone here know if Hetzner DNS supports glue records

#

(for custom nameservers)

simple stump
#

When I use JSDOM's runScripts: "dangerously", the content is returned first and then the scripts are run. How can I do the opposite, which is run the scripts and then get the returned content?

let url = ...;

await something(url); // Logs a script from the page last.
async function something(url) {
  let dom = await createDOM(url);
  return console.log(dom.window.document.body.innerHTML); // Logged first
}
async function createDOM(url) {
  let dom = await JSDOM.fromURL(url, { pretendToBeVisual: true, runScripts: "dangerously", resources: "usable" });
  console.log("a"); // Logged first.
  return dom; // Returned first
}

If the page contains <script>console.log("hello");</script>, what is logged is:

"a"
some_html_here
"hello"
quartz kindle
#

this virtual console then redirects the output to the nodejs console

#

and apparently this process is not synchronous

#

the script itself is still run first, just the console part of the script that has an extra round trip

sharp geyser
#

So I'm restarting from scratch on my lib and I wanna do it right this time which means building it from the ground up in steps. For now I really wanna focus on the gateway and make sure everything about it is good enough to be used in a production level bot. Which means I have to take into account basic error handling from the gateway, dispatch events and other things. My main focus right now is how I should effectively handle errors from the gateway so people at least know why the bot crashed.

#

Should I handle the errors as the events happen or make use of the websocket error event

quartz kindle
#

there are 3 layers of possible errors

#

the tcp layer, the websocket layer and the discord layer

#

typically your websocket library will handle the tcp layer internally, so you dont need to worry about that

#

but you need to handle the websocket layer and the discord layer separately

sharp geyser
#

I assume the websocket layer & discord layer would be handled in the websocket.on('error')

quartz kindle
#

the websocket layer includes the websocket error and close events (close can happen without errors)

#

for the discord layer, you need to check the close codes from the websocket

sharp geyser
#

How does a error response from discord look like do you know?

quartz kindle
#

close codes simply close the websocket, and the close event should give you the close code

sharp geyser
#

Ah okay

quartz kindle
#

there are some things that dont close the websocket, for example invalid session

#

those you will receive as an opcode instead

sharp geyser
#

Yea, that makes sense

#

So I won't really need to worry about any error handling in the message event will I?

#

Or is it not safe to assume that if any error happens the error event will catch it?

quartz kindle
#

from opcode 0 no, but you can receive other opcodes from the websocket message event, like invlid session

sharp geyser
#

Mmm well yea

#

Thanks :)

simple stump
quartz kindle
#

i dont think there is a way to force the virtual console to work synchronously

#

what you can do is follow the same strategy they recommend for loading async scripts for example

#

return the result from the script directly into the dom, and then get it from the dom

simple stump
#

Ah okay. Ty!

quartz kindle
simple stump
#

Ah I see. Ty that’s super helpful 👍

sharp geyser
#
export const GatewayEventCloseCodes = Object.freeze({
    4000: { message: 'Unknown Error', reconnect: true },
    4001: { message: 'Unknown Opcode', reconnect: true },
    4002: { message: 'Decode Error', reconnect: true },
    4003: { message: 'Not Authenticated', reconnect: true },
    4004: { message: 'Invalid Token', reconnect: false },
    4005: { message: 'Already authenticated', reconnect: true },
    4007: { message: 'Invalid Sequence', reconnect: true },
    4008: { message: 'Rate Limit Exceeded', reconnect: true },
    4009: { message: 'Session timed Out', reconnect: true },
    4010: { message: 'Invalid Shard', reconnect: false },
    4011: { message: 'Sharding Required', reconnect: false },
    4012: { message: 'Invalid API Version', reconnect: false },
    4013: { message: 'Invalid Intent(s)', reconnect: false },
    4014: {
        message:
            'Disallowed Intent(s), please make sure you have enabled said privileged intent.',
        reconnect: false,
    },
});
let error = GatewayEventCloseCodes[data.code];

Can I not do this?

#
TS7053: Element implicitly has an 'any' type because expression of type 'any' can't be used to index type 'Readonly{ 4000: { message: string; reconnect: boolean; }; 4001: { message: string; reconnect: boolean; }; 4002: { message: string; reconnect: boolean; }; 4003: { message: string; reconnect: boolean; }; 4004: { message: string; reconnect: boolean; }; ... 8 more ...; 4014: { ...; }; }>'.

When doing something similar other places it doesn't cry about a type mismatch or whatever

#

data.code is a number btw

quartz kindle
#

did you give a type to data.code?

sharp geyser
#

yes

#
    private _onError(data: { code: number }) {
        let error = GatewayEventCloseCodes[data.code];
        if (error.reconnect && this._sessionId) {
            this._resumeConnection();
        }

        Promise.reject(new Error(error.message);)
    }
quartz kindle
#

you either need to change GatewayEventCloseClodes to a generic type like Record<number, { message:string, reconnect:boolean }> or you need to change data.code to 4000 | 4001 | 4002 | ... instead of number

sharp geyser
#

Ah okay, thanks

#

Giving it a type worked

#

:p

dense patio
#

hello friends, i am trying to edit a reply to a slash command after a user presses a button```js
client.on(interactionCreate, async interaction => {
interaction.update(hi);
});

```response: { message: 'Unknown interaction', code: 10062 }```
something else i tried was ```js
interaction.editReply(`hi`);
``` however this tells me: ```The reply to this interaction has not been sent or deferred.

any ideas?
discord.js v13

#

thanks in advance, please ping me if you know

wheat mesa
#

you need to check if the interaction is a command afaik

#

actually I'm not sure

#

I don't use djs

dense patio
#

it crashes

quartz kindle
#

what type of interaction is it?

#

command? button?

dense patio
#

a button

#

oh i think something just clicked.

#

well interaction.update updates the original message

#

and then crashes the bot and gives an error, even though it did what i wanted it to do

quartz kindle
#

do you have multiple interactionCreate listeners?

#

you said you're editing the response from a slash command, where is the slash command code?

dense patio
#

i've got this code in a separate file so i can make button pages without having to have it in each command, there would be multiple listeners but there should only be one in this example as i only used the command once

quartz kindle
#

um... what

#

i mean

#

do you have more than one .on("interactionCreate") running?

#

if so, you need to isolate the interactions

#

because you cant run multiple codes for the same interaction, and you cant run button code on slash commands and slash code on buttons

dense patio
#

well i do, but this one only gets buttons

quartz kindle
#

how do you make it only get buttons?

dense patio
#
if (!interaction.isButton()) return;
quartz kindle
#

then please include that in the code you show

dense patio
#

didn't realize it was related, my bad

quartz kindle
#

can you show the full error that crashed your bot?

#

also await your promises

#

await interaction.update(...)

dense patio
quartz kindle
#

thats not a good reason to stop using it, in fact it helps create more problems and useless errors

dense patio
#

give me a sec i'm gonna try something

#

ok i got it

dense patio
#

thanks for your help

quartz kindle
#

yeah all interactions come trough the same listeners

#

thats why it needs isolating with isButton, etc

dense patio
#

one last question, how do i make it so the buttons don't expire after 3 seconds?

dry imp
#

defer

dense patio
#

what do i defer, exactly?

#

the original message? the bot's reply? the button interaction? i can't seem to figure it out

#

nvm got it

sharp geyser
earnest phoenix
#

i deleted my team

#

But in Creator it is showing

#

My development name

#

And saying I'm unauthorized

fervent goblet
#

I have a general question of a challenge i am facing with mongodb with node.js. I want to be able to create documents rather quickly and auto increment a number per document. The issue i am facing when it concerns many users running commands at once the bot often will duplicate a document. Does anyone know work around for this?

cinder patio
#

Put all documents that will be created in a queue

fervent goblet
#

or

#

omg nvm i got it thanks

split hazel
#

@earnest phoenix does node's crypto support rsa-sha256?

#

i need to verify a signature in emails

earnest phoenix
#

Although if you're talking about the main Crypto APIs rather than the Web Crypto APIs, it depends on the method

#

For ciphers, it depends on OpenSSL so you can see all the algorithms by running openssl list -cipher-algorithms

The hash algorithms depend on the available algorithms supported by the version of OpenSSL on the platform, which you can run openssl list -digest-algorithms to list them

For signatures and verification, the name of the signature algorithm can be used such as the one you just said, as pulled from the documentation:

In some cases, a Sign instance can be created using the name of a signature algorithm, such as 'RSA-SHA256', instead of a digest algorithm. This will use the corresponding digest algorithm. This does not work for all signature algorithms, such as 'ecdsa-with-SHA256', so it is best to always use digest algorithm names.

split hazel
#

very nice

#

does nodes crypto support nfts

earnest phoenix
#

No! Absolutely not

#

Smh

quartz kindle
#

lmao

wheat mesa
#

Java has NFTs

#

No Fucking Tuples™️

earnest phoenix
#

Java is an NFT language

#

No Fucking Thanks™️

wheat mesa
#

Speaking of Java I have a programming contest in Java today in my CS class lmao

earnest phoenix
#

Yell "The floor is Java" in the contest, watch everyone lose their minds

wheat mesa
#

I can’t ruin my classmates’ dreams, it’s the only language they know!

#

It’s a way of life for them

quartz kindle
#

java the hutt

quartz kindle
wheat mesa
#

Lmao

#

Our teacher thought that js array indexes started at 1

earnest phoenix
quartz kindle
#

Lol

wheat mesa
earnest phoenix
#

public static void volatile verbose package implicit casting transitioning const Main(String args[]) {}

quartz kindle
#

imagine

#

if

#

nodejs

#

was made with java

earnest phoenix
#

Thank God it isn't!

quartz kindle
#

and you had to install jre to use it

#

and update java on every node update

earnest phoenix
#

I would rather make a game in pure LLVM IR than having that

quartz kindle
#

make a gayme

earnest phoenix
#

I'll make you a gayme for you to become a gaymer

#

That reminds me of the old console wars where they gave the consoles a name of their own, PlayStation to GayStation, Xbox to Shitbox, and so on

quartz kindle
#

pcmr > *

wheat mesa
#

There’s so many keywords in Java I didn’t even know existed until I looked at standard lib code

#

Like transient

earnest phoenix
#

you might end up with your emails not being received

split hazel
#

tho making it reliable isn't hard just keep it up

#

some services even resend email

quartz kindle
#

the issue with email is that there is a massive safety infrastructure out there created to fight against spam and scam

#

and this infrastructure often involves trusted/safe ip addresses

#

so some systems might refuse to communicate with your server because its not part of its list of safe servers

#

people who work with email marketing for example, they explain how important it is to chose your email provider wisely when sending marketing campaigns

#

because using a less known service may lead to increased number of rejections

split hazel
#

:c

simple stump
#

I'm trying to send a POST request to a website, but since the website that is sending it uses ajax and I'm using NodeJS, I have to "convert" their request to axios. But when I send the request from NodeJS, the request is valid but data is null. I've copied the request headers of the website and tried around 15 different request in the same format, but data is returned null every time. I retyped the ajax request into dev tools on the website itself and the response works, but with axios it doesn't. What is the difference between an ajax request and axios itself?

ajax request:

$.ajax({ url: "./data/searchdata-test.php", type: "post", data: { 'anime': "a" }, dataType:"html" });

axios request:

axios.post(this.url + "/data/searchdata-test.php", { anime: "a" }, { responseType: "html" });

I'd also like to mention that I tried the standard fetch method in dev tools and get the same result as when I use axios in Node (data returns nothing/no response).

fetch request:

fetch('./data/searchdata-test.php', { method: 'POST', body: JSON.stringify({ anime: 'a' }), }).then(console.log)
quartz kindle
#

what is the website?

#

if you dont mind me testing it

simple stump
#

idk if i can send it here but:
||removed||

#

they use an unofficial api

#

(imma delete the link in a sec)

slender wagon
#

Is it possible to manipulate top.gg's server count api (just wondering)

solemn latch
#

manipulate in what way?