#development

1 messages · Page 88 of 1

neon leaf
#

yeah, its just weird with my specific problem because I dont even use path for anything request related and it somehow still doesnt work on windows

wheat mesa
#

Doing something wrong then

neon leaf
#

obviously, do you want to know the details?

tulip ledge
#

I tried something like this but it doesn't work

const generateString = (x) => {
  let string = "";

  while (string.length < x) {
    let num = list[Math.floor(Math.random() * list.length)];

    string += num;
    if (string.length === x) return string;
    else if (string.length > x) {
      string = string.substring(0, string.length - (num.length))
    } else string += " ";
  }
}
lyric mountain
#

Friends server + music/minigame bot is a thing

#

Not all servers want to be a big community, some just want to chill with friends

chrome orbit
#

Yea but 1 server doesn't effect a verification.

lyric mountain
#

There're also testing servers to check if a bot is dangerous or not before adding to a big server

chrome orbit
#

Bots aren't dangerous, permissions are.

lyric mountain
lyric mountain
chrome orbit
#

You choose the permissions you give a bot when you invite it.

#

A bot can't raid a server if it doesn't have permissions.

lyric mountain
#

A bot with just send messages permission could wreck havoc in a server

#

Or mass dm everyone

#

Raid isn't the only dangerous thing

solemn latch
#

it can severely impact a small community

chrome orbit
#

Yea which is why people go with verified bots. Anyways, my point being back on subject is that a bot requesting verification would have no reason to be in 20+ servers of less than 10 people. That itself just yells botting.

solemn latch
#

honestly, most my servers have less than 30 people 👀

#

and have bots ranging from small and unverified to huge

#

having a limit of 10 severely limits a bots potential growth imo

#

For example, some bots we've had in this community only got invited here due to being in our staffs small servers.

If a small bot gets invited to a large community its probably because some staff member had it in a smaller community first.

chrome orbit
#

Honestly, my bot is in 5 servers currently and has a member count of 1700. It's all just about the contacts.

#

I was going to make a point, but I don't know where I'm going with this lol

deft wolf
#

Congratulations

solemn latch
#

👀 maybe topgg has changed my perspective a bit, but it sounds like your bot targets small communities right now.
Which it sounds silly to cut off a portion of your target audience.

deft wolf
#

I just don't understand why people set some limit of users on the server so that the bot can be added there

#

It's you as the developer who is trying to get users and the user will find another bot if he can't add yours

solemn latch
#

A limit of 1 user okay, maybe?

But I setup bots when creating a server.
Like, me a dev creating a support server before that is sent I'll make sure to have all the important bots first.

deft wolf
chrome orbit
#

I don't set a limit on user count. With my bot being multi purpose, it usually only gets added to bigger servers.

deft wolf
#

Maybe so, but I've always wondered what such people think when they require a certain number of users on the server

#

Because apart from the desire to have the right number of users on average per server and limitations, e.g. database, I see no point in doing something like that

sudden geyser
#

I've only ever encountered one bot with a user count requirement

#

don't know where you're finding them

dry imp
#

ive encountered some bot owner that does that, they said its to prevent sus and inorganic growth

#

idk if thats true or not

sudden geyser
#

probably is

#

common for bots to be added to giant bot farms as well

quartz kindle
#

one of my bots got fucked because of that

#

got denied verification for suspicious activity or whatever

sudden geyser
#

L kid

quartz kindle
#

elk kid

hushed robin
#

and suspicious growth is based on how fast your bot grew

dry imp
#

well thats funny because i added my bot to like 10 testing servers and its still verified xf

hushed robin
#

🤷

rustic nova
#

bots dont get unverified for inorganic growth after it gets verified already

#

its only important before verification

rustic nova
dry imp
#

idk how that works

rustic nova
#

probably when discord barely cared about that yet

#

or their verification team is overloaded again

dry imp
#

maybe

#

ig its when they started verifying bots like crazy

rustic nova
#

yeah

crystal wigeon
#

hey anyone use python here?

#
def main() -> str:
    print(type("backend service"), "here")
    return "Backend service"```

This keeps returning a class type 'byte' in the @after_request decorator
#

but the type being printed here is str

#

any idea whats happening? how do i fix this

rustic nova
#

you cant force it to return a str in a flask response

#

have python handle it iself

spark flint
#

Getting this for MongoDB with Next.js

#

It is from an import

#

this is the part of the code where the function is called

spark flint
#

actually nvm

#

i found the issue

tulip ledge
#

I have this really weird issue. I just made a vite react site and am deploying it to netlify. I noticed that it was a blank page. So I built it on my pc and previewed it and it was also blank! Even though when I run npm run dev it shows the page like it should, but when building it shows a blank page with nothing. When inspecting the page the root element is empty and there are 2 errors in the console TypeError: Go is not a function and TypeError: Go is not a function

rough jackal
#

Verifications are quite slow. I don't see enough activity for it to take that long. Please check the requests.
I am trying to generate content for your page but if the process is this slow, unfortunately if this continues we will have to move with competitors.

spark flint
#

it is because there are hundreds of bots in queue

#

and only so many people to review them

#

today along there are at least 50 new

#

(looking at logs)

sudden geyser
#

why won't they just get more reviewers

spark flint
#

they just got more

#

also because it is 18+ for reviewers

#

and most adults aren't on discord

rough jackal
#

ask for support or artificial intelligence to handle this. We are already in 2023, are we going to depend on 3 people verifying?

spark flint
#

they already just brought some more reviewers on in the last week

#

they are working on it, its clear that they are

rough jackal
#

Thank you, see you soon I hope this lack improves.

boreal iron
spark flint
#

^^^

#

was gonna reply with that

#

you can't use AI to review bots, it would also be selfbotting

sudden geyser
#

you ask bots to whitelist your bot

#

oh interactions

#

yeah good luck

#

pray to discord gods

wheat mesa
#

It’s not fair to expect them to review your bot or you’re going to have to “go to other competitors”

#

You’re in line just like everyone else

rough jackal
proud oracle
#

How can we upload our website in to bot's description in top.gg?

rustic nova
#

iframe

rough jackal
boreal iron
#

While the first part might be true, the terms of service will block you from doing what u want.

rustic nova
#

this

#

AI is useful, but not good in decision-making as a human with common sense

#

take that twitch AI bot for example, that anime girl called Neuro AI

#

got banned for speaking about a certain topic referring to past history

#

And I can heavily tell you, AI will not be able to review bots

rough jackal
#

It probably won't make final approval, but you will have a large percentage of the work done for your 3 reviewers.

rustic nova
#

Then have a site bloated with bots that barely:

  • function
  • follow our rules
  • fail to get stopped during review as it didnt pass common sense related things
pearl trail
rustic nova
#

AI is not able to interpret common sense

#

It knows facts, it tries to apply these facts to prompts, that fails miserably if it uses the wrong facts

#

and you end up with a bot that gets approved, even though it shouldn't be

#

why am I even here talking about it lol

lyric mountain
#

until they manage to give AI conscience most HR jobs are pretty safe

pearl trail
#

also most bots are using slash

#

you can't just make an http request to execute a slash command

rustic nova
#

thats just the technical limitations on AI

#

on the "interface" its talking through

#

unless you let it view a display, control a mouse, control a keyboard

#

then we're back at ethics, understanding and tos

sudden geyser
#

AI (or general automation) would more likely be useful as a means of filtering bad bots

#

So verification is faster

#

but that may just result in more bots getting submitted

sudden geyser
#

pen drop

rustic nova
#

just to put that in here too

rough jackal
#

Anyway see you soon my gg's

urban cape
#

I got a question about the HTML video player.

I have a simple webserver and it serves a mkv file.
I have enabled "Experimental Web Platform features", so that I can change the language of my vid.

When I skip to 1 hour it loads the whole movie (So it loads the first 500mb. How to stop that. I does not want to load the whole vid when I skip part of the video.

Someone any idea?
(I do not want to change any movie file to another type)

lyric mountain
#

the default html player is very crude

urban cape
#

True, so not possible with the default player one?

lyric mountain
#

don't think so, it works by reading the file, when u "skip" ur not really skipping, just telling the player to load to where u placed the seeker

#

players like youtube's work by loading only around the seeker

urban cape
#

Thank you

quartz kindle
#

and convert your videos to a fragmented format like m3u8

#

thats what streaming services use

#

or you can do it yourself using some special browser APIs like MediaSource extensions and SourceBuffers

urban cape
quartz kindle
#

however not all video formats support that without breaking the video without having to create fragments or breakpoints beforehand

#

and the html5 video player does not load video chunks by default, hence the need for advanced control with MediaSource extensions

#

another thing you can look into is the webtorrent protocol, which does support streaming many video formats over torrent

solemn latch
#

Such a good conversation

#

saving this 👀

stiff dust
signal lance
lofty cipher
#

How can i fetch a url in html and displayed in a div?

stark abyss
#

pwetty sure you gotta use JS and some DOM method sounds about right

boreal iron
neon leaf
#

I think he means like fetching stats from an api and displaying them

signal lance
#

oh yea then u need to use javascript

#

but who still uses html. seriously 💀

stark abyss
#

Oh I see

viral badge
signal lance
#

i recommend using axios to fetch an api

earnest phoenix
signal lance
#

cause axios isnt bad

stark abyss
#

isnt fetch built in

neon leaf
#

browser and nodejs

signal lance
urban cape
stark abyss
#

then why recommend axios KEKW

earnest phoenix
earnest phoenix
#

wdym

#

Yeah

signal lance
neon leaf
#

maybe he knows but doesnt know how to display it?

earnest phoenix
#

axios shid
fetch best

lyric mountain
#

axios is an horribly bloated lib

quartz kindle
#

node http best lib

sudden geyser
#

For neovim users, is it normal for nvim to not take up the entire terminal screen (i.e. the borders)

earnest phoenix
lyric mountain
#

Terminals usually have some padding no?

sudden geyser
lyric mountain
#

Probably just padding

earnest phoenix
#

That's normal

sudden geyser
#

ah

stiff dust
earnest phoenix
stiff dust
earnest phoenix
stiff dust
#

But how can I put my github token??

#

I cant put it just there

#

I have to use env variables

solemn cipher
#

i love it when node.js just randomly stops for no reason

deft wolf
#

There must be a reason

#

If you run it on a vps and want the bot to run 24/7, you must probably use a screen

quartz kindle
earnest phoenix
solemn cipher
urban cape
#

I do not understand a thing anymore about dns.
Why does every dns provider see my website, except google?
https://dnschecker.org/#A/videosnl.ga
Anyone an idea?

quartz kindle
#

dns propagation takes time

#

different resolvers have different cache timings

#

a dns entry is only refreshed when the cache expires

urban cape
#

But I cant connect to my website through google dns, but I can through cloudflare. Even when waiting 5 min for google dns, it does not work

lyric mountain
#

use 1.1.1.1 instead

#

cloudflare ftw

urban cape
#

I am using cloudflare dns, but I can not ask every user on the internet to use a specific dns

quartz kindle
#

when did you update the domain's dns?

urban cape
#

A couple of hours ago, but only changed the AAAA record

quartz kindle
#

wait until tomorrow

urban cape
#

Ok

lyric mountain
#

that's weird then

scenic wolf
#

hello

lyric mountain
#

?

scenic wolf
#

how are you ?

quaint wasp
#

How would I be able to access the "quote" property? I can't to do response.1.quote so I am kinda stuck. Ping in replies.

spark flint
quaint wasp
spark flint
#

kek np

chrome orbit
#

Am I dumb or what? I have console.log(user.displayedGuilds), which logs an array of each server I'm in including Id, name, Icon, settingsUrl, etc... If I put console.log(user.displayedGuilds.settingsUrl) or anything I just mentioned, it returns undefined when its clearly defined.

#

Here is an example of what is in user.displayedGuilds

#

and with user.displayedGuilds.settingsUrl, I get this

sudden geyser
#

you probably want to map over it

chrome orbit
#

Possibly. I did it like 2 days ago and it just spam listed each settingsUrl.

sudden geyser
#

well it would get the settingsUrl for each item in the array

#

is there an exact thing you need to do?

chrome orbit
#

Well not exactly, I'm just wondering why its returning undefined. I just wanted to check all the settingsUrl's for something

#

Looking for a way to sort them by servers the bot is in first.

#

And the settingsUrl should have /manage/:serverId for servers the bot is in and https://discordapp.com/blahblahblah for servers the bot isn't.

#

I've already tried using user.displayedGuilds.sort(), but it will only let me sort servers the bot is NOT in first. If I try the other way, it just ignores the sort.

solemn latch
#

👀 displayedGuilds sounds like an array, arrays dont have properties.

#

or well, that property

pearl trail
#

it is indeed an array from the screenshot provided

wispy mural
#

ry

chrome orbit
#

Yea but I can't map something that's undefined.

#

Figured it out. Just added a sort: 0 for servers the bot is in and sort: 1 for servers the bot isn't.

stiff dust
sharp geyser
#
return new Models[category](result);

logging this normally returns the class as it should but if I return it in a function and then log the result of that function it logs as a newline

quartz kindle
stiff dust
north cairn
#

Hey I'm having trouble with slashcommands rn

#

Can someone help?

#

So when I try then command it says application did not respond

#

So what do I do

deft wolf
#

But that doesn't mean anything, there could be more than one reason for this. It may be the fault of the bot itself, which is not online, for example, or it may be the fault of your command code

north cairn
#

Command code ig

#

Bot's normal commands working perfectly

deft wolf
#

Slash commands are not quite like normal commands

#

They have some rules of their own

north cairn
#

const { readdirSync } = require("fs");

const Discord = require("discord.js")

const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const { token } = process.env.token;
const clientId =  "992806051806191626";

const ascii = require("ascii-table");
const client = require("discord.js");
let table = new ascii("SlashCommands");
table.setHeading("SlashCommand Name", "Loaded Status");


module.exports = (client) => { 
   
  const slashCommands = [];
  readdirSync("./SlashCommands/").forEach(dir => { 
    const commands = readdirSync(`./SlashCommands/${dir}/`).filter((file) =>
      file.endsWith(".js")
    );
    for (const file of commands) {
      const pull = require(`../SlashCommands/${dir}/${file}`);
       slashCommands.push(pull.data.toJSON());
         if (pull.data.name) {
        client.slashCommands.set(pull.name, pull);
        table.addRow(pull.data.name, "✅");
      } else {
        table.addRow(
          pull.data.name,
          `❌`
        );
       
      } 
    }
  
  console.log(table.toString());
  });
  const rest = new REST({ version: '9' }).setToken(process.env.token);

(async () => { 
    
try {
        console.log('Started refreshing application (/) commands.')
        await rest.put(
            Routes.applicationCommands(clientId),
            { body: slashCommands },
    );
  
    console.log('Successfully reloaded application (/) commands.')
  } catch(error) {
    console.log(error) 
}
 });
  }
#

Do u think anything is wrong??

deft wolf
#

If the command is displayed in the bot commands and can be used, then this part works as it should. I think so

#

It's probably more about the command and how it is executed

north cairn
#

Yes the bot displays that there's a ping command in my bot

#

But issue comes when running it

deft wolf
#

Then you have to give us the code of the command itself that is executed when the command is used

north cairn
#
const {MessageEmbed, Collection } =  require("discord.js");
const { readdirSync } = require("fs");
const Discord = require("discord.js")
const client = require("../../index")
const fetch = require("node-fetch");
 

const { QuickDB } = require("quick.db")
const db = new QuickDB();

client.on("interactionCreate", async interaction  => {
   
 
  if(!interaction.isCommand()) return;
    const slashCommand = client.slashCommands
  console.log(slashCommand)
    if(!slashCommand) return;
        try {
          if(slashCommand)
 await slashCommand.execute(interaction);
} catch(err) {
            console.log(err)
await interaction.reply({content: "An Error Occured!", ephemeral: true})
        }
})```
#

So this interaction create file

#

So do u see anything wrong

deft wolf
#

It depends, it will most likely only work with one command because you don't extract the command from the collection in any way. Just to be sure, if console.log(slashCommand) is working, that part of your bot is working for now

north cairn
#

@deft wolf error coming

#

Says slashCommand.execute isnt a fucntion

#

Function*

deft wolf
#

Most likely because you didn't select a command from the collection

#

slashCommand is a collection, not a command data

#

You need to do something like this so that your bot selects the appropriate command from the collection and executes its code

command = client.slashCommands.get(interaction.commandName)
#

This code is missing from your interaction create handler

north cairn
#

@deft wolf now command says same and when i logged slashCommand,it says undefined

deft wolf
#

Because you don't have a client value in your handler

north cairn
#

whre?

deft wolf
#

You have access to interaction. You need to get the client out of this

deft wolf
#

All your client in it doesn't exist because you don't have it defined in any way

north cairn
#

so i hve 2 do client = require("discord.js")?

deft wolf
#

Wait, that's so weirdly written

north cairn
#

no

#

its slashcommand handler

deft wolf
#

Okay, where do you log into the bot then?

north cairn
#

index.js

deft wolf
north cairn
#

huh????

#

bro thats clientId

deft wolf
#

You create the client once, you don't have to create it in every file

deft wolf
north cairn
#

i m just defining bruh

deft wolf
#

I don't know, I'm so lost honestly

#

Either I don't understand "your programming style" or I don't know

north cairn
#

sad

#

do u know someone who can help me??

deft wolf
#

You can ask on other servers or wait for others on this server to read these messages and maybe they will know what to do about it

next storm
#

Any way to change the ip/port in ubuntu using console commands?

rustic nova
#

what ip/port?

next storm
#

actually my bot isn't replying so i guess the possible reason for that would be that it got rate limit. So to fix it the only way is to change the ip address of host

rustic nova
#

you cant just "change the ip of host"

#

especially not by just doing commands

craggy pine
#

What you can do however is make a ticket to your VPS to request a change of IP which some do allow for good reasons.

rustic nova
#

yeah you can request a change that is true

#

you can purchase another IP too

#

but you cant just tell linux to "change my ip"

#

unless you were provided an ip then you can change that in the networking config

sudden geyser
sudden geyser
#

e.g. curl -H "Authorization: Bearer <...>" -H "User-Agent: DiscordBot(..., ...)" https://discord.com/api/v10/users/@me

#

<...> is your bot token

next storm
#

and DiscordBot(..., ...)?

sudden geyser
#

it's a user agent discord likes you to attach

next storm
#

so do I've to put something between ()

sudden geyser
#

where to find the library you're using and the version being used

#

e.g. where to find your bot and whatever version

#

probably doesn't matter much here

next storm
#
{"code": 0, "message": "You are being blocked from accessing our API temporarily due to exceeding our rate limits frequently. Please read our docs at https://discord.com/developers/docs/topics/rate-limits to prevent this moving forward."}```💀
solemn latch
#

👀 what in the world are you doing to get ratelimited frequently.

sudden geyser
#

lol

#

try running it again with the -I flag

#

it should display some info about how long in the headers

next storm
#

💀 I've my bot's join logs using webhook, and my bot was added in 200 servers within 5 mins, so you know what would have happened

solemn latch
#

webhooks have their own ratelimits separate from the bot.

spark flint
#

I'm trying to get a user from a database using Next.js and getServerSideProps, but session is being returned as null even though the user is logged in

next storm
#
curl: (3) URL using bad/illegal format or missing URL
HTTP/2 429
date: Sat, 21 Jan 2023 15:43:02 GMT
content-type: application/json
retry-after: 1907
cache-control: no-cache
report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=QpjNfRZ3B75oRIAvhASqlU0EMV0IFgigbPof6celRBQELZayQvRuqm1%2BvYoeBQ1emAlfE1Og2IQ8K7ecXYVRkbd0vyC6neWuFvAW1zq%2FNjZC6vFkPUv87fSFxZw4"}],"group":"cf-nel","max_age":604800}
nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
strict-transport-security: max-age=31536000; includeSubDomains; preload
x-content-type-options: nosniff
server: cloudflare
cf-ray: 78d129c6d83381d5-IAD
alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400
next storm
spark flint
#

actually, i did console.log(user) after fetching with session.user.id and its returning the database user

#

but when I pass through props, it returns as undefined or null

sudden geyser
#

so like 30 minutes

spark flint
next storm
sudden geyser
#

until it expires

next storm
#

you mean after 30 mins it will be fixed?

sudden geyser
#

it should be

#

but you may just get rate limited again if whatever caused it isn't fixed

spark flint
# spark flint

nvm fixed, i was doing Onboarding({ props}) not Onboarding(props)

next storm
sudden geyser
#

this header: retry-after: 1907

#

that's in seconds

next storm
#

ok

sudden geyser
#

since it's just an hour, I have a feeling that you're spamming the api somewhere in a loop, since the rate limit for that is like 10,000 requests in 10 minutes

next storm
#

Thinking_Pedrito I've some high loads command, like lockall, hideall which updates all the channels in the server. It's possible that someone would have spammed it in a server where there's a lot of channels

#

though I've used delay after every channel update

#

it updates channel at a speed of 1.75 second/channel

slender wagon
earnest phoenix
# slender wagon

response.body can be null which seems to be what it's complaining about, assert that it's not null/undefined with the ! operator after the value: response.body!

slender wagon
#

that only solved one issue

earnest phoenix
slender wagon
#

the response comes from an url fetch

#
 const response = await fetch(url); 
earnest phoenix
#

Oh, are you using the built-in fetch() method or?

slender wagon
#

yup

#

easier than node-fetch

#

i am aware it's not stable yet so that might be an issue?

#
  let url = "";
  url = req.query.url as typeof url

  const response = await fetch(url);
  if (!response.ok) throw new Error(`unexpected response ${response.statusText}`);

  res.setHeader('Content-Type', 'application/zip');
  res.setHeader('Content-Disposition', 'attachment; filename=demofile.zip');
  await pipeline(response.body!, res);

here

earnest phoenix
#

The Fetch API is generally stable at the moment

slender wagon
#

this is typescript btw, pretty sure u are already aware

earnest phoenix
#

I know, the ReadableStream instance you currently have is different from Node.js' common streams, because the one you have is a readable web stream, it has a pipeTo() method you can use

next storm
#

@sudden geyser bro I thought my bot was added in 200-300 servers, but now I came to see that it's added in 4.3k new servers 💀

#

bot died while processing 4.3k webhook messages

sudden geyser
#

how'd that happen

next storm
#

I don't even know

slender wagon
lament rock
earnest phoenix
#

I know, but we don't know what their res variable is so that's why I brought that up

lament rock
#

👍

earnest phoenix
slender wagon
#

i am downloading a file

earnest phoenix
slender wagon
earnest phoenix
slender wagon
#

next?

#

res: Override<NextApiResponse, Data>)

earnest phoenix
#

I got that, Next in there goes with the other words so it's not obvious

slender wagon
#

everything i am using is

import stream from 'stream';
import { promisify } from 'util';
import type { NextApiRequest, NextApiResponse } from 'next'
const pipeline = promisify(stream.pipeline);
earnest phoenix
#

So you're piping the readable web stream to a Next.js response object, you can either convert the readable web stream to a Node.js common stream by stream.Readable.fromWeb(), and use that, or you can get the reader of the readable web stream and write (?) to the Next.js response object

const reader = response.body.getReader();

let data = null;
while (!(data = await reader.read()).done)
  // Write to response object with the value of `data.value`
#

I don't use Next.js so I'm not sure if that's feasible or not

craggy pine
#

Not exactly development related, but what's the purpose of these "Hoarding bots" servers? I just got a 15k server and I was like pog until I ran an eval to see who was a bot and who wasn't and 12 people are users KEKW

earnest phoenix
craggy pine
#

I haven;t had a single command ran via these servers.

#

i log each command into my db

earnest phoenix
#

They probably plan to do that later, I mean there's 15k bots as you mentioned there

spark flint
earnest phoenix
#

Flashback to this server having every approved bots here, !help and boom

spark flint
#

i call them "API fuckery" servers

#

they add thousands of bots to spam commands and get bots, channels and servers ratelimited

earnest phoenix
#

When my bot was still alive I made it leave every server that had a lot of bots on join

#

It's a nice way to prevent them from breaking anything or getting the bot ratelimited

craggy pine
craggy pine
#

Ok.

earnest phoenix
#

Although 70% is also good

craggy pine
#

What would the math to that look like

earnest phoenix
# craggy pine What would the math to that look like

For example, for 70% you would have to divide the member count by 10 and multiply it by 7, and compare the number of bots in the server to the member count, if the number of bots is greater than or equal to the 70% of the total member count, leave the server

sudden geyser
#

Does anyone use oh my zsh here? Any recommended plugins?

earnest phoenix
sudden geyser
#

just plugins

#

already have a decent theme

earnest phoenix
rustic nova
#

@drowsy crag hi

drowsy crag
#

hey

rustic nova
#

swag

signal lance
#

anything to remove that form the number type for inputs?

sudden geyser
#

try opening the inspector and seeing what properties is making that show up

quartz kindle
#

or dont use type number

rustic nova
#

use textfield instead and just dynamically check if it is a number

sudden geyser
#

an input with a number here is probably better semantically

rustic nova
#

you cant remove it unless you make it appear as a textbox on mozilla for example

#

also generally probably better to handle the ID as an string imo

compact pier
quartz kindle
#

most standard input types have similar issues

#

thats why its usually preferred to use regular inputs and control them with js

#

the only advantage is that pn mobile it shows the numeric keyboad onstead of default

#

but i think that can also be forced using some html attributes

light jungle
#

Is a global ban list where I can add raider/bot accounts to against TopGG tos? Servers would have to manually enable it in their servers, not on by default.

thorn barn
#

is there a way to test votes on top.gg because i'm doing a reward system on my bot

earnest phoenix
thorn barn
#

by bad

earnest phoenix
wheat mesa
#

Anyone else have this server add their bot? Seems suspicious, in less than 8 hours their guild member count has increased by nearly 2000 members

sudden geyser
#

probably a bot farm

wheat mesa
#

That’s what I’m thinking, haven’t updated my bot to be able to look at bot to member ratio since I haven’t touched the code in nearly 2 years

deft wolf
#

Not this server but the name is similar so it's possible it's their server

wheat mesa
#

That’s the same server, they update the member count in the server name

#

Pretty sure it’s a bot farm, this is odd:

#

Though I believe memberCount in my lib is only for cached users

deft wolf
#

Indeed, it's the same server

wheat mesa
#

Definitely suspicious if they’ve grown 20k members in that short of a time period

#

Might be scraping top.gg and adding every bot that they can

deft wolf
#

My bot was added there on January 19th

#

20,000 bots in 3 days is a lot

wheat mesa
#

3 days

#

Yeah

#

20k legitimate members in 3 days is also a lot

#

Either way I doubt it’s legit

icy burrow
#

Hmm seems like there are a whole bunch of them

wheat mesa
#

It’s the same server, they change the name to update with the server count

rustic nova
#

"Join Server"

#

sus

deft wolf
#

But wait, a server made in 2016?

#

I would have thought they would do something like this on some new servers/accounts

jaunty basalt
#

How to change stuff of npm package we are using in our discord bot??

wheat mesa
#

Why would you do that?

wheat mesa
#

This is an XY problem

#

Tell us why you would want to do that first

#

Because you almost never want to do that to solve a problem

rustic nova
#

"i have this error and I want to remove the error message"

wheat mesa
#

Thats what I’m thinking

#

In which case the error is 99.9% probably from your code, not the package’s

lyric mountain
#

Worth to note, you won't receive any more updates if u do this

#

And you're very likely to wreck something up

wheat mesa
#

I very highly doubt that his issue is from the library

craggy pine
deft wolf
#

At least now we know where "60,000 bot users" come from

rustic nova
lyric mountain
#

Sometimes all u need is to suffer a little to see why people tell u not to do something

#

They never listen otherwise

lofty cipher
#

How can i fix this?

node:events:491
      throw er; // Unhandled 'error' event
      ^

Error [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred.
    at ChatInputCommandInteraction.reply (C:\Users\diana\Documents\vscode\Hundy Bot\Hundybot\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:102:46)     
    at Client.<anonymous> (C:\Users\diana\Documents\vscode\Hundy Bot\Hundybot\index.js:68:25)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Emitted 'error' event on Client instance at:
    at emitUnhandledRejectionOrErr (node:events:394:10)
    at process.processTicksAndRejections (node:internal/process/task_queues:84:21) {
  code: 'InteractionAlreadyReplied'
}

Node.js v18.12.0

earnest phoenix
#

by reading the error

craggy pine
#

The reply to this interaction has already been sent or deferred.

tulip ledge
#

Can anyone help me fix this intellisense issue with vscode. I'm learning go and have declared a type deck in a file called deck.go but when using the type deck in my main.go file vscode gives me this error but I can run the code fine like it should, it's just really annoying.

wheat mesa
#

have you installed the recommended extensions for go?

spark flint
#

I can't get files to upload with Chakra + Next.js

#

the file is not included in the body

quartz kindle
#

you need to add the boundary to the header

#

is that browser side? why not use fetch?

wheat mesa
#

would you be able to use axios client side?

quartz kindle
#

i think axios works on both node and browser

spark flint
compact pier
earnest phoenix
#

Could there be a Pokemon Trade feature for Mudae?

cerulean ingot
#

ive got my website up on my vps with nginx and shit and locally, my api works, but when it try to do it on the vps, i get this:

[blocked] The page at https://domain.com/ was not allowed to display insecure content from http://ip:port/get_sections. (a42c66d.js, line 2)
Not allowed to request resource
Fetch API cannot load http://ip:port/get_sections due to access control checks.
TypeError: Load failed

and btw i do do this:

app = Quart(__name__)
app=cors(app)
app.config['CORS_HEADERS'] = 'Content-Type' # i use cors...

# and

@route_cors()```
but it works when i do ip:port/get_sections just in my search bar...
rustic nova
#

domain.com tries to reach out to ip:port, which fails due to cors not matching ip:port

#

You need to set your cors headers to allow domain.com

#

also, https is needed according to the message?

solemn latch
#

which, if its an api it should have https

cerulean ingot
#

yeah i fixed that

#

for some reason when i run my project locally for a specific file my style is correctly opacity: 75% and when i run it on my server, and npm run build and npm run start it is opacity: 1

lyric mountain
#

Can't u just use 0.75?

cerulean ingot
#

ya ill try that

sharp geyser
lyric mountain
#

Listen here you little shit

earnest phoenix
#

/imagine

rustic nova
#

this aint midjourney

sharp geyser
rustic nova
#

indeed

stiff dust
quartz kindle
#

midjourney, topjourney, junglejourney, botjourney

#

supportjourney

radiant kraken
#

do you know a way on how to compare two binary files? @earnest phoenix

#

like is there a hash file command in linux or something

radiant kraken
earnest phoenix
#

It'll show the SHA256 hash of the binary file, which you can use to compare them

radiant kraken
radiant kraken
#

@earnest phoenix how

earnest phoenix
earnest phoenix
#

If that's what's causing the error

#

Try running node -v and see if it causes that error

radiant kraken
#

nope

#

installed it with sudo apt install nodejs

earnest phoenix
#

You shouldn't use the Node.js binaries provided by those repositories, they can be outdated or not work at all, use https://nvm.sh/

GitHub

Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions - nvm/README.md at master · nvm-sh/nvm

earnest phoenix
#

After installing nvm, run nvm install --lts to install the latest LTS release

radiant kraken
#

damn 😔

#

at this point i think i'm over-engineering my library

#

too much scripts and CI-related things

earnest phoenix
#

Nah it's fine

sudden geyser
#

like your country?

quartz kindle
#

the binary must have corruption like your country

#

lmao

compact pier
#

why is this so?

#
[1-10][a-c-A-C]
subtle nimbus
#

because it requires both

#

[1-10] AND [a-c-A-C]

compact pier
#

Tried something like this, but doesn't work if the number is higher

(([\0-1][0])|[1-9])[a-c-A-C]
#

I don't know a lot about regex so yeah :<

subtle nimbus
#

but that it because the | is an or

#

either or

compact pier
#

what is and ?

subtle nimbus
#

and 1 is the first fetched

#

just write no |

#

then its an and xd

compact pier
#

then it doesn't work :<

#

Can you maybe help me, how I can fix that regex? D:

subtle nimbus
#

([1-9]|[0-1]{1,2})[a-c-A-C]

#

that should fix ur

#

no 100% if it works but it works for me for my cases

light jungle
#

regex makes me want to die tbh

compact pier
#

not really

#

I think I will do manual check with js :<

earnest phoenix
compact pier
#

other cases 11b or 23b won't work

earnest phoenix
#

So the first part should only be 1 through 10?

compact pier
#

yes

#

and second should be a-c (capital too)

earnest phoenix
stiff dust
#

Hi, I want to add music feature into my bot is there any better package than https://distube.js.org/#/ ??

Note: my bot isn't Just Music Bot I want to add music as a feature

light jungle
earnest phoenix
compact pier
earnest phoenix
#

You're welcome

wheat mesa
earnest phoenix
lyric mountain
compact pier
lyric mountain
#

u don't want 22b?

compact pier
#

like every number that bigger then 10

lyric mountain
#

then that'll work

compact pier
#

but I think Voltrex's regex works

lyric mountain
#

voltrex's is probably slower since it uses lookbehind

#

mine simply uses optional digits

hallow shell
#

can i use markdown in the top.gg long description

lyric mountain
#

yes

hallow shell
#

alr

compact pier
#

mhmm, I think I don't care a lot about perfomance issues, cause I do it on client (ikk, but my website, doesn't need backend server)

#

it is school project

lyric mountain
#

performance is still a concern on clientside

#

even more than performance on backend

compact pier
#

yeah.. but I don't have other option

#

a backend server is too expensive for a school project

lyric mountain
#

that's not what I said

#

performance is more noticeable on frontend than on backend

#

because a slow backend will just make processing take more time, a slow frontend will freeze the app/site

#

and users tend to panic when something freezes

compact pier
#

yeah, the user's experience is the most importain

earnest phoenix
lyric mountain
#

why?

earnest phoenix
#

Yours does not filter out numbers larger than 10

lyric mountain
#

?

earnest phoenix
#

Which is what they want

lyric mountain
#

it'll work from 1a to 99c

earnest phoenix
#

They only want it to work from 1 to 10, nothing larger

lyric mountain
#

well, then just /[1-9]0?[a-cA-C]/

#

oh wait

#

ah, now I understand

#

just a sec

earnest phoenix
#

Told ya

lyric mountain
#

yeah that'll require lookbehind

#

however, I don't see why would they process that through regex and not simply check the input

earnest phoenix
#

@compact pier so yeah, you can keep using mine which is correct, but you can also do it without regex

#

Either by parsing or something similar

lyric mountain
#

to do it through code simply strip anything that isn't a letter and check if the number is > 10

#

or get a substring of the first (if length == 2) or first 2 (if length == 3) digits

wheat mesa
#

Parse it as hexadecimal 🧌

lyric mountain
#

@wheat mesa do u have any idea how to check if a bunch of bytes is a webp image?

#

like, png and jpeg have a specific sequence of bytes at the start of the array

#

google docs don't help much

#

nvm, found something in wikipedia

rustic nova
#

Yeah isn't there a filetype definition on the beginning of the file?

lyric mountain
#

there is, I just need to figure out how to properly read it

rustic nova
#

This is a list of file signatures, data used to identify or verify the content of a file. Such signatures are also known as magic numbers or Magic Bytes.
Many file formats are not intended to be read as text. If such a file is accidentally viewed as a text file, its contents will be unintelligible. However, sometimes the file signature can be re...

frosty gale
rustic nova
#

until there's no extension or you're getting a stream of data

#

such as an upload

lyric mountain
cursive musk
#

Experimenting with 0AUTH2, how can I make it so if they're banned from the server then they can't use the 0auth2?

#

Haven't been able to find a response.

rustic nova
#

Can you elaborate "banning from oauth2"?

#

You have control over the callback Webserver that receives the oauth, you could do anything: either compare their User ID with your banlist or ban the IP that made the oauth

#

First one allowing use on a different account, second one entirely disallow on IP

#

Second one being the requirement that they have authorized on oauth2 at least once, dont forget to declare that on your privacy policy though

cursive musk
lyric mountain
#

you can't prevent the user from acessing the oauth2 screen since that's on discord's side

#

but you can simply refuse to do something once they accept it

#

if it's for inviting the bot simply make it leave the servers right away

rustic nova
#

There isn't much docs needed, fetch the user, fetch your servers banlist and done

cursive musk
rustic nova
#

Or whats your general goal? Deny access to your dashboard?

#

They can always use the oauth2 endpoint, but its up to you what you do after them authorizing

lyric mountain
#

oauth2 is nothing more than "you want this data? sure, let me ask them first"

cursive musk
rustic nova
#

oauth -> user authorizes

  • fetch userid from the token, fetch your servers banlist, if user is on banlist, redirect to /banned
  • if not, allow access
#

Just remember to still do that on any dashboard usage, unless you're not even going to give them a session

#

Which is probably easier

hidden gorge
#

AttributeError: 'Member' object has no attribute 'role'

lyric mountain
#

And it indeed doesn't

sudden geyser
#

fact checked: TRUE!

hidden gorge
#

uploading code one second

lyric mountain
#

No need

#

Member doesn't have role

#

(yes, go on, say it)

wheat mesa
#

Me when I keep coming back to the same discord channel for the same error at least once a week for the last 2 years

hidden gorge
#
   if user.role(whitelisted_humans):
                return;```
#

the humans role is an id

#
 whitelisted_humans = [849479291111866380]```
lyric mountain
#

Ok TIFU more than I thought

hidden gorge
#

what

lyric mountain
#

Are you sure that's how ur supposed to check for roles?

hidden gorge
#

i dont ever try this lol

lyric mountain
warm surge
lyric mountain
#

Oops, reply went automatically

#

Tifu means "this is fucked up" btw

#

Naming a Member variable user is the recipe for chaos

#

To check for roles you need to get the roles of a member and check if it contains the desired role

#

U can't simply call functions that don't exist, always check the docs or at least use ctrl + space

hidden gorge
#

if member.guild.get_role(849479291111866380) ^ SyntaxError: invalid syntax

lyric mountain
#

That's somehow worse than it was

hidden gorge
#

ive used it before

wheat mesa
#

Sometimes I wonder if you’ve tried solving the issue or if you’re just looking up a ton of things and copy pasting the code…

lyric mountain
#

Just look at the docs

hidden gorge
#

i try it makes no sense

lyric mountain
#

Isn't ur editor telling u it's wrong?

#

Like, even the most basic code editors have some kind of autocomplete

#

Anyway, you need to learn how to read documentations

#

That's part of being a programmer

hidden gorge
#
TypeError: on_message() missing 1 required positional argument: 'member'
Ignoring exception in on_message```
#
    @commands.Cog.listener()
    async def on_message(self, message, member):
        user = message.author
        if message.author.bot:
            return

        whitelisted_channels = [978933824241147904]
        whitelisted_humans = [849479291111866380] # 131920731490615296 bit.ly in own server.
lyric mountain
#

Is self supposed to be there?

#

Also why are u creating a single-entry array?

carmine summit
#

I need help trying to upload an image to a webhook. The image is in HTML Canvas

radiant kraken
radiant kraken
dry imp
#

yea

rigid maple
#

I can't understand where I went wrong

pearl trail
rigid maple
#

unfortunately there is no solution posted here

final tangle
# rigid maple I can't understand where I went wrong

the error states that the sourceEnd value is out of range and must be between 0 and 3, but the value of 8 was received
try seeing if the code that is trying to access the array/string is properly checking and enforcing the range of the index being accessed, in this case between 0 and 3

#

also in ur code at line 334, it's saying DiscoidVoice

#

not sure if u spelled it wrong

#

i think it should be DiscordVoice

rigid maple
#

no its true

quartz kindle
#

from looking at their code, the fix is not quite correct

#

but it might work

lyric mountain
#

Tim if u don't mind, could u give me some performance advice?

so, let's say I have a huge array (raster data from image) and want to edit some pixels

#

what'd be the optimal way to edit said pixels?

#

like, the specific pixels will be supplied by a mask

quartz kindle
#

the specific pixels are matched by color?

#

so they can be anywhere in the image, right?

#

you dont know their position beforehand

lyric mountain
#

yes

#

the issue being that a linear array iteration is too painfully slow

#

the raster is a width * height * channels sized array

quartz kindle
#

is it rgb or rgba?

lyric mountain
#

rgba, but it can be anything

#

perhaps I could split the array into chunks and process each separately

quartz kindle
#

if there is no hint about the possible pixel position, there is no other way besides iteration, but you dont need to match the entire mask at once for each pixel

#

you can match each rgba byte separately

#

so if the first byte doesnt match you dont need to check the others

lyric mountain
#

wdym?

#

like, the mask is for "cutting" the image

quartz kindle
#

like

#

if you want to change all pixels with a specific color into a different color

#

you dont need to check if the pixel matches all channels with something like buffer compare

#

actually, how are the pixels stored in the first place?

#

2d array?

lyric mountain
#

1d array

quartz kindle
#

so all pixels are merged in the same array, in groups of 4

lyric mountain
#

I believe so

#

ah wait, I just noticed that I can just offset the iterator by the desired channel number

quartz kindle
#

then you can iterate and skip

#

exactly

#

if the first byte doesnt match, skip the next 3

#

if the first matches, but the second doesnt, skip the next 2

#

etc

lyric mountain
#

ic, ty tim

quartz kindle
#

what lang btw?

lyric mountain
#

java

quartz kindle
#

another thing you can try is using array indexOf, or equivalent

lyric mountain
#

trying to optimize my renderer, it's taking too long for some pixel ops

quartz kindle
#

in my experience that function is faster than if you were to iterate yourself

#

at least it is in js lol

lyric mountain
#

btw, I ran a benchmark on some webp vs png

#

5 warmups for each iteration

#

I didn't expect webp to be half as fast as png

#

I could run a bigger sample, but the step results were way too consistent

#

for example

quartz kindle
#

half as fast? isnt the score 1887 vs 1742?

lyric mountain
#

ah wait

#

I was looking at error lmao

quartz kindle
#

xD

lyric mountain
#

well, 0.1 ops/s diff isn't that bad then

quartz kindle
#

webp is lossy compressed isnt it?

#

png is usually losless or at least color indexed

lyric mountain
#

both were compressed at 80% quality

#

webp lossy yes

#

I don't really mind the loss, I just need transparency

quartz kindle
#

so not surprising, webp algorithm is more complex

#

how fast is jpg?

lyric mountain
#

lemme throw it into the benchmark

#

tho it'll take a while

quartz kindle
#

im gonna get my groceries off the car lol

lyric mountain
#

ain't done yet, but I think it'll be like fishing with a cannon

#

btw, it's a 1000x1000 image with randomly rolled pixels

#

the image is created for each iteration

#

too bad I cant use jpeg

quartz kindle
#

so jpg is 10x faster than the other 2

#

lmao

lyric mountain
#

png and webp gave bigger results for some reason

#

maybe it's because of cpu load

quartz kindle
#

lel

#

i had a feeling jpg would be much faster

#

but not that much

lyric mountain
#

jpeg is basically the UDP of image formats

quartz kindle
#

unified department of police?

#

xD

#

btw

#

that benchmark is basically encoding performance no?

#

time taken to generate said pixels and encode them into the format

#

what about a decoding benchmark?

#

time taken to actually read and decode the pixels

sudden geyser
lyric mountain
#

I hate wrongly done benchmarks

#

this one is using the openjdk benchmark lib

#

which makes sure all runs are done equally

whole glen
#

I’ve been trying to find something about this but anyone know a resource on how to do a video pop out like this in html?

craggy pine
#

Quesiton: Is 50 servers a cap of some sort for unverified slash commands? I woke up today to not being able to run slash commands in my own server. Also noticed my little description I have for my bot where you can click commands to autofill them are no longer highlighted.

torpid crystal
craggy pine
#

ah cool

#

I was kinda spooked.

lyric mountain
#

when the user clicks on it, make the modal visible

whole glen
#

Thanks

rustic nova
lyric mountain
#

lmao

thorn spruce
#

Does anyone know how to avoid hundreds of setTimeout, I am trying to create a remindme system. I was actually going to use Cron, but you can't choose the number of iterations with node-cron. Because I think that having hundreds of setTimeout in progress is not incredible no?

#

I had seen Agenda but it only uses Mongodb I think and I use Mysql

rustic nova
#

how about one setTimeout that processes through a list instead? Perhaps adding a expire timeout along with the remindme entry

#

then that setTimeout executing every second

#

though theres also the cons about setTimeout, since your reminders will get lost on a restart. So a repeating setTimeout that goes through a list might also allow you to store the reminders in a database

thorn spruce
#

yes that's why i store them in my database to re-add them on restart (endDate-startDate)

rustic nova
#

yeah then load your reminders into a list and have the setTimeout iterate through the list and do the reminders etc

thorn spruce
#

The problem is that my reminders do not have the same expiration date

rustic nova
#

you might also be able to have other bot instances that are specifically for working through the reminders, might help with processing

rustic nova
#

thats at least how I would do it

thorn spruce
#

what do you mean by a repeating setTimeout Think

rustic nova
#

one single setTimeout that goes forever, that processes the reminders

sudden geyser
#

aka a setInterval

rustic nova
#

oh yeah forgot that exists too

#

you wont be able to reliably store reminders without some missing if your bot restarts if theres some that expire during the restart

sudden geyser
#

though it really sounds like you want some persistent queue

thorn spruce
opaque seal
lament rock
rustic nova
opaque seal
rustic nova
#

Yeah was about to say, judging from the code, yours are on the minute, hour, week etc

#

Only way to make a precise way is to have another instance of the bot deal with it

quartz kindle
# opaque seal There has to be a more precise system tho

the best system i can think of is store them in a database, then use an interval to check the database every 5-10 minutes for any timer that will expire in less than 5-10 minutes, and for each one found, create a timeout for it

opaque seal
#

Not seconds

#

Unless it's a short reminder

#

Which is generally fine I guess

rustic nova
#

So your border on a short and long reminder is seconds and minutes

quartz kindle
#

with the above method i mentioned, everything is millisecond precision

craggy pine
#

Anyone else getting a decent amount of "unknown intereaction" errors since the slash commands came back from being disabled temporarily? I'm getting one from just doing interaction.reply() which shouldn't throw that because it's the first thing it runs on that specific slash command ran

#

my buttons respond pretty slow too

solemn latch
#

Its probably api issues still

deft wolf
craggy pine
#

my errors seemed to have chilled out.

#

But for a good 30 minutes all I got were theses
https://scs.twilightgamez.net/5f5mb.png
Which 51 is

await interaction.reply({content: `Attempting to queue: \`${interaction.options.getString('song')}\``, ephemeral: true})
deft wolf
#

It must have been related to those api issues

craggy pine
#

yeah I just now had a realization that maybe I forgot to make 'song' required, but no, it is lol.

#

So ya api related likely.

sharp geyser
#

That or the interaction is non existent.

craggy pine
#

I mean, how would that happen?

sharp geyser
#

You could be completing the interaction already.

#

Well no, djs tells you if you deferred a reply or smth like that

craggy pine
#

ya it does.

wheat mesa
#

unknown interaction is likely from the API errors earlier

craggy pine
#

Ya it only started to happen after the slash commands came back so I was just curious if anyone else was experiencing the spam on unknown interactions on simple interaciton.replys but I haven't had one for almost an hr now so ya. Probably just api recovering from its stroke it had.

lament rock
#

@craggy pine Are you receiving interactions via http or over the gateway

#

because Discord can tell your client to resume and during that window, your interactions can expire

craggy pine
craggy pine
rigid maple
opaque seal
rigid maple
crystal wigeon
#

Has anyone worked with millions of rows in db?

#

It takes quite a bit of time to retrieve 500k data. Even with all the indexing

valid oak
#

500k data?*

#

like rows?

#

or

crystal wigeon
#

yeah

valid oak
#

lines

crystal wigeon
#

500k rows

#

from postgres

#

its also a select query select * from x where x.uid = xx

#

x.uid is indexed and stuff

#

still takes about 30sec

rustic nova
#

why are you trying to select every single data

#

consider optimizing your queries and moving over to a faster database system

lyric mountain
#

postgres is probably the fastest free option

lyric mountain
#

also is uid a primary key?

crystal wigeon
#

Nop

#

It’s like 1 uid can have multiple rows

#

One to many relationship

lyric mountain
#

what's the table used for?

#

also, there's no "one to many table"

#

1-N is a relationship, not a table structure

#

@crystal wigeon come back

crystal wigeon
#

brb

lyric mountain
#

ah ok

crystal wigeon
#

It’s mostly the pagination total count that’s costing time

#

Using count(id) to get total rows

lyric mountain
#

why dont u paginate through postgres directly?

crystal wigeon
#

I do

#

I’m using limit and offset

lyric mountain
#

do u need the total of posts?

crystal wigeon
#

yeah

lyric mountain
#

can posts be edited or deleted?

crystal wigeon
#

Yep both

lyric mountain
#

hm, are u getting the count together with the regular sql?

#

like SELECT *, COUNT(id) FROM ...

#

or in a separate query?

crystal wigeon
#

Yeah along with it

lyric mountain
#

btw, u can use COUNT(1) instead, it's faster sometimes

lyric mountain
#

reason being COUNT() will fetch all rows, so it might be fetching the other fields too which, if you have very large values, will affect execution time

crystal wigeon
#

I’m using count(id) actually

#

So you suggest making two db calls?

lyric mountain
#

yes

#

with count(1) not id

crystal wigeon
#

I’ll give that a try mmm

#

I see

#

Thanks I’ll give it a try

lyric mountain
#

also u dont need to do any join for the count

#

just count directly from the table, filtering by id

crystal wigeon
#

Yeah, there are no joins

#

I’ll check the performance on that mm

lyric mountain
#

what u could also do, is disallow editing/deleting posts older than X days

#

then make a periodic procedure that counts archived posts and save to an aux table

#

then u can just filter posts where age < X and count them, appending the saved count

#

this is actually why most forums archive posts after some time

crystal wigeon
lyric mountain
#

but if ur dealing with massive amounts of data you should consider something like that

crystal wigeon
crystal wigeon
lyric mountain
#

execute a PLAN EXPLAIN query and show the result please

#

redact the names if u must

crystal wigeon
#

Gotcha, I think the problem is I’m using row count

#

I’ll send the query in a few

rigid maple
#

I can't understand where I went wrong
the first buffer in the console is stereo, the second buffer is mono

#

When I convert the buffer to audio, I can listen to it, but when wit.ai converts it to text, it's empty.

crystal wigeon
#

this is for the user with more than 500k rows. its super fast for users with less data

lyric mountain
#

lemme format that first

#
EXPLAIN ANALYZE
SELECT x.*
FROM (
     SELECT *
          , row_number() OVER (ORDER BY rank_id DESC, id ASC) AS row
     FROM collections
     WHERE user_id = 1
       AND is_item = FALSE
) AS x
WHERE x.row = 1
#

much better

crystal wigeon
#

damn

#

how

#

to format

#

xd

lyric mountain
#

ctrl + alt + L on intellij

eternal osprey
#

how do i access this count(*) variable?

#

like i am using it like: result[0].(property here)

#

however result[0].COUNT(*) will behave like an actual function...

crystal wigeon
#

rename the object property,

eternal osprey
#

how? It's a pulled variable from sqlite

crystal wigeon
#

adding () is considered a method

#

what object is that?

eternal osprey
#

SELECT COUNT(*) FROM table;

crystal wigeon
#

or you can try result[0]["COUNT(()"]

lyric mountain
#

ok, now it's better yet

eternal osprey
#

okii will try thanks!

crystal wigeon
#

its not good practice tho

lyric mountain
#

ok so, first of all u never need = BOOLEAN since it's a boolean already

crystal wigeon
crystal wigeon
#

so it has to filter through rows that are false

lyric mountain
#

yes, u don't need that

crystal wigeon
#

otherwise row number gonna mess up

lyric mountain
#

AND NOT field

#

or AND field

crystal wigeon
#

aa

#

lemme see how that performs

lyric mountain
#

wont make a difference

#

it's just a tip for making stuff more readable

crystal wigeon
#

i see

lyric mountain
#

u also dont need to spam " everywhere, only for stuff using keywords as names

crystal wigeon
#

yeah its a knex debugger query log i copied it from

#

jsut to show as example here

lyric mountain
#

why do u need row_number?

crystal wigeon
#

so the rows have to be ordered and the user would choose something like the nth row

#

if you want to choose the 5th item

#

they type select 5

#

the order by is an addon for them to sort it by asc or desc

#

or based on a rank_id

lyric mountain
#
EXPLAIN ANALYZE
SELECT *
FROM collections
WHERE user_id = 1
  AND NOT is_item
ORDER BY rank_id DESC, id
OFFSET :row_n LIMIT 1
#

u dont need row_number for that, simply use offset

crystal wigeon
#

hmmm

#

let me try

lyric mountain
#

also try not to use *

#

pick only what u really need

crystal wigeon
#

yeah

lyric mountain
#

like, I dont think the user would need to see is_item column

#

so it's one less column in the resultset

crystal wigeon
#

mmm makes sense ye, but will need other columns i have

crystal wigeon
#

offset 1 would skip the first row

#

damnnn that was fast

#

20k ms to 50ms

crystal wigeon
#

noice

#

but for the count thing, need to show row number

lyric mountain
crystal wigeon
#

cause if they search for something with name, need to show on what row the item is on

#

yep

#

alr lemme solve 1 problem at a time

lyric mountain
#

for the row number u can use an extra column

#

to store line number

crystal wigeon
#

precomputed, but need to do this everytime collections are consumed etc

lyric mountain
#

use a trigger for that, leave the work to the database

crystal wigeon
#

mmmm

lyric mountain
#

like, when deleting, update all rows with number higher than the deleted row

crystal wigeon
#

it needs to like calculate the rows for each user data

#

mm

#

and when sorting

lyric mountain
#

u wont sort the actual data, you'll sort the resultset

crystal wigeon
#

I’ll brb

lyric mountain
#

while at that, having a row number column also speeds up count

crystal wigeon
#

Lemme do one at a time haha

#

I need to explain a bit more about the other one