#development

1 messages · Page 2042 of 1

pearl verge
#

that is why i asked about if i give credits

#

anywhere possible on bot

quartz kindle
#

if it looks like an exact copy, its usually not allowed

#

so just change it enough that it doesnt look like an exact copy

#

even if just tweaking the bot's text responses

#

you can give credits anywhere you like, but thats not what reviewers usually look for

#

they just dont want multiple copies of the exact same bots on the website

pearl verge
#

oh ok

#

so credits dont matter?

manic basin
dry imp
#

okay thanks

radiant kraken
#

use flexboxes

spark flint
#

I ditched that

#

Because the Sonos api doesn’t accurately return duration

slender wagon
#
for (let i = 0; i < 4; i++){
        workers[i].shift = i
        console.log(workers[i].name + "'s shift for tomorrow:" + workers[i].shift)
    }

how do i pass the console log out of the for loop function

cinder patio
#

whut

onyx turtle
#

Hi, I was wondering if anyone knows the formatting of the website? I'm trying to make a good looking description 😄

onyx turtle
dry imp
onyx turtle
#

ah thanks ❤️

celest gate
#

does anyone know how to get mobile status in the bot

earnest phoenix
#

Requirements for uploading the bot in discord bot list?

celest gate
#

no

#

but i want to

split hazel
spark flint
#

lmao

earnest phoenix
spiral veldt
#

/nick new_nick:mezba

winter pasture
spiral veldt
split hazel
earnest phoenix
split hazel
#

not really

earnest phoenix
split hazel
#

yes

earnest phoenix
#

then tell me pls

split hazel
#

turkey

#

ok

tulip cradle
lyric mountain
#

not on the bot itself

timber fractal
#

So for example I would have 2 div elements, with a p element inside. One element's content is "Item 1" and the other one's content is "Item 11", but the second element is wider than the first one because it has a 2 digit number, instead of a 1 digit number. How could I make sure both elements have the same width?

lyric mountain
#

pad

#

or fixed width

#

or better yet, use an enclosing div to be the maximum width, and set them items to fit said div

#

that way the largest div will define the width of all items

unreal olive
#

i need chat bot api

winter pasture
unreal olive
#

k

vivid fulcrum
#

pov you have to implement localisation in your app

timber fractal
pearl verge
#

the code already has the credits

quartz kindle
pale vessel
#

imagine being able to fluently translate your native language to english

#

or i guess vice versa

feral aspen
#

I've installed Ubuntu on my laptop, and I have Ubuntu and Kali-Linux on my main (VM), what are some cool experiments to try on my laptop?

#

I remember reading how people would crack the password of their laptop administrator account or something, what else?

quartz kindle
#

go wardriving

feral aspen
#

Do I need a cantenna?

#

I remember I can like make a home-made one. 💀

#

But what else can I try on my laptop (to hack into it)? Laptop IS using Ubuntu so I guess I can crack the password with my main machine but need to figure out how to do so.

lyric mountain
lone mist
#

down the rabbit hole

#

How big is your npm directory already?

quartz kindle
ancient nova
#

if I'm making a warning system what's the best way of going about storing the warns?

#

I'm currently using better-sqlite3 and was wondering if I could also use that but not sure]

#

I was thinking about using a collection but it would be pointless once the bot is restarted

#

how do I actually structure something like this again?
I want to be able to get the warn by it's ID like so const warned = warns.find(ID) and then use it with warned.warnReason

sharp pine
#

hi all! I was wondering if it's possible to set a command that will assign a role to a poster when enough people react to a post with a certain emoji (kind of like a starboard, but for people, or like a reverse reaction role)

#

I couldn't find a bot that does this already, but if you know of one that works too

#

ex: I post a dumb meme. 4 people react to it with TheBest and that gives me a @fallen spear role

#

oh shoot sorry I did not expect that to be a name lol

hollow depot
#

why do i get this error even if i have this header?

headers: {
            'Access-Control-Allow-Origin':'*',
            'Content-Type': 'application/json',
          }```
#

sorry not familiar with web stuff

simple stump
#

I'm trying to display an image and then modify it with JS in the browser. However, if I just display the raw URL, I get an error in console saying it's forbidden. What's strange though is that when sending requests from Node, the image can be downloaded without issues. But since I'm attempting to bulk download images, it is more efficient to display the images on the web and then modify it using JSDOM rather than downloading the images and then displaying them. TLDR, how can I fix the issue of images being forbidden? Is there a way to bypass this without downloading the images first?

hollow depot
#

yup

sharp pine
#

oh excellent

#

can you help me figure out the command and/or refer me to the right documentation

simple stump
#
const express = require('express');
let port = 3000;

const cors = require('cors');
const app = express();

const corsOptions = {
    origin: '*',
    methods: ['POST', 'GET', 'PATCH', 'DELETE', 'OPTIONS'],
    allowedHeaders: ['Content-Type', 'Authorization']
};

app.use(cors(corsOptions));
app.use(function (req, res, next) {
    res.setHeader('Access-Control-Allow-Origin', your_host_like_localhost:3000);
    res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
    res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');
    res.setHeader('Access-Control-Allow-Credentials', true);
    next();
});

app.listen(port);

Try that

#

It's scuffed but works for me

#

Or wait

#

I misread the error

simple stump
hollow depot
quartz kindle
simple stump
#

Essentially the host you're sending requests to denies requests from outside sources. If you were to try this in Node for example it would probably work, but in the browser it doesn't. I myself am trying to bypass this but the best option is probably to send requests from the backend, then display it via Express.

quartz kindle
hollow depot
quartz kindle
#

so yes, you need to add a head route

#

what server are you using?

hollow depot
#

its an express server (if thats what ur asking lol)

quartz kindle
#

then add app.head(...)

#

along with your app.get(...)

hollow depot
#

ok, will try that now, thank you :))

quartz kindle
#

the head route does not need to send any content

#

only headers

sharp pine
#

i hate it when i forget to hit 'reply'

hollow depot
quartz kindle
#

show code

quartz kindle
hollow depot
quartz kindle
#

you need to send the response lol

sharp pine
hollow depot
sharp pine
#

(sorry, v new to discord bots)

hollow depot
quartz kindle
hollow depot
quartz kindle
#

if you want to listen to reactions on any message, better use the event

sharp pine
#

thanks

quartz kindle
#
app.all('/*', function(req, res, next) {
  res.header("Access-Control-Allow-Origin", "*");
  next();
});
#

note, this has to be placed before app.get(...)

hollow depot
#

kk, ill try now

#

nope, still the same

quartz kindle
#

show full code

#

and show full error again

#

the error might be slightly different, but look mostly the same

hollow depot
hollow depot
# quartz kindle show full code
const express = require('express');
const app = express();
const http = require('http');
const port = process.env.PORT || 8080;

var bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());

app.all('/*', function(req, res, next) {
    res.header("Access-Control-Allow-Origin", "*");
    next();
});
app.post('/', function(req, res) {
    stuff here
});

app.listen(port);
console.log('API server started on ' + port);
#

wait ill remove the stuff in app.post

wheat mesa
#

we love CORS

quartz kindle
#

the error is different, so that means the headers are working

#

you need to add res.header("Access-Control-Allow-Headers", "*");

hollow depot
#

in the request i already have that header

#

and also in the app.post()

quartz kindle
#

doesnt matter what you have in the request

#

and cors preflight requests are sent via OPTIONS, not GET nor POST

ancient nova
#

does anyone wanna read the code?

spark flint
#
const client = new Client({
    intents: intents, partials: ["MESSAGE", "REACTION"],
    allowedMentions: { parse: ["roles"] }
});```
#

roles aren't being pinged

feral aspen
#

Unless you're pinging the role, incorrectly?

spark flint
#

nope

feral aspen
#

Not sure.. but try seeing if you need any other partial required, otherwise, you may need to wait for another answer.

split hazel
#

in nodejs how do i check if a duplex stream has ended?

simple stump
#

How do you execute a script, then wait until it's finished? For example:

for (let i = 0; i < pages.length; i++) {
  axios.get("some_website").then(res => {
    // do some task and send lots of requests
  });
}
if (finished_requests) {
  return;
}

Basically, I want to send requests to a website. But since awaiting would take too long, sending a bunch of requests, then waiting for all of them to be finished is more efficient. But I'm not sure how to check if all the requests are done. Is there a better way to do do this?

ancient nova
#

uhhh what I used a function and somehow instead of executing it just pasted itself there?

#

like how does that even happen

simple stump
ancient nova
#

can anyone explain

feral aspen
simple stump
ancient nova
#

should I await it then?

#

didn't help

feral aspen
simple stump
ancient nova
#

other functions work fine what's going on

feral aspen
ancient nova
#

what do you mean I have

ancient nova
feral aspen
#

The warn ID is <code> and you sent me the code for the part before that, so.. ?

#

Can you send the full code?

ancient nova
#

do you want the function module's code because I sent all there is to the warn command

#

return message.channel.send(👍 Warned ${member.user.tag || "Unable to Fetch User"} for ${toProperCase(reason) || "No Reason Provided"} The Warn ID is ${generateID});

#

oh now I see what is wrong

feral aspen
#

You sent the code of the function, and not really called the function itself, I believe.

feral aspen
# ancient nova how do I actually structure something like this again? I want to be able to get ...

You don't really need to be over-complicating yourself, here's what's best you can do, which is something I personally did as well:
On your warnStructure variable, create three properties, content, serverID, and userID:

- For content, it will list an array of objects whereas each object will have two properties, the moderatorID which stores the moderator who's warning the user, and the reason on why the moderator is warning the user.
- For serverID, you will store where the warning took place.
- For the userID, you will store who's the user who's getting warned.

simple stump
#

If I were to use Promise.all, would each Promise be resolved in order? For example:

let a = new Promise(1);
let b = new Promise(2);
Promise.all([a, b]); // <- 1, 2; not 2 1

I’m probably not understanding Promises correctly, but hopefully this makes sense.

quartz kindle
#

no, it would not be in order

winter pasture
quartz kindle
#

but the execution/completion is not

winter pasture
#

Ah yeah, I may have misunderstood the question

quartz kindle
#

or i did

winter pasture
#

Who knows, they have all the information they need now KEKW

ancient nova
#

I even tried talking to the creator they just ignored me I'm fucking done

#

no matter what I do this shitty ass <enmap>.filter function returns just "{}" or straight up undefined

split hazel
#

the enmap owner 💀

#

they're so egotistical

ancient nova
#

it's not funny bro 😭

ancient nova
split hazel
#

she thinks she knows it all

#

no

#

the owner of enmap

#

evie

ancient nova
#

ong she kinda tried to help me, but then just straight up stopped responding

#

every single time I asked for an example or to show me how to do it she didn't do anything I even gave her the entire code for the command

quartz kindle
#

she doesnt like helping beginners

split hazel
#

she loves doing it then 💀

quartz kindle
split hazel
#

i find her to be very hostile a lot of the time

ancient nova
ancient nova
#

I've been at this for like 5 or 6 hours at this point I just wanna finish

quartz kindle
#

this is literally like a description of how the function works

#

the kind of stuff you see in documentations

#

not the actual code you should write

#

im pretty sure enmap's filter is exactly the same as collection's filter

ancient nova
#

I said that she doesn't like helping people and that her server lacks support and got banned

quartz kindle
#

i mean, she is not wrong

cinder patio
quartz kindle
#

free software does not include any kind of support, if you find an author that is willing to help you with using their software, then you're in luck

ancient nova
ancient nova
ancient nova
quartz kindle
#

i agree with that sentiment and i do my best to help people who use mine, but that doesnt mean everyone should do it as well

quartz kindle
solemn latch
#

cough cough cloudflare

#

zero support unless you pay 👀

ancient nova
quartz kindle
#

well support for big companies ofter comes from the communities that use them anyway

#

not directly from them

ancient nova
#

I spent 2 hours reading through the docs

#

went through them like 5 times

ancient nova
quartz kindle
ancient nova
#

let's see what it gives me

#

should I stringify?

quartz kindle
#

you could have also caught them at a bad moment

ancient nova
quartz kindle
#

but people are like that

ancient nova
#

as expected

#

doesn't work

quartz kindle
ancient nova
quartz kindle
#

yeah because thats not how Maps work

#

Maps use .set and .get

ancient nova
#

well the other method that uses .get works but .get is used for a single value and I want to fetch every single warn from a person

quartz kindle
#

then you're doing something wrong with how you store the data

ancient nova
#
    // Check whether to list variables or get a variable by ID.
    if (!member) {
        // Declare our embed.
        warningsEmbed = new MessageEmbed();
        
        // Get variable by ID.
        const filterResults = warnstorage.get(args[0]);
        if (!filterResults) return message.channel.send("This user does not have any warnings!");
        
        // Resolve our results
        const resolvedResults = filterResults; //JSON.stringify(filterResults);
        
        // Fetch warned user and the person who warned.
        const warnedUser = await message.guild.members.cache.get(resolvedResults[0]);
        const personWhoWarned = await message.guild.members.cache.get(resolvedResults[1]);
        
        // Return embed
        warningsEmbed.setTitle(`Z3RO Warn System (ID: ${args[0]})`);
        warningsEmbed.addField("Warned User", warnedUser.user.tag);
        warningsEmbed.addField("Reason", resolvedResults[2]);
        warningsEmbed.addField("Moderator", personWhoWarned.user.tag);
        
        return message.channel.send({embeds: [warningsEmbed] });
    } else {
        // Declare our embed.
        warningsEmbed = new MessageEmbed();
        
        // Get variable by ID.
        const filterResults = warnstorage.filter(value => value[0] === member.user.id);
        if (!filterResults) return message.channel.send("This user does not have any warnings!");
        
        // Resolve our results
        const resolvedResults = JSON.stringify(filterResults);
        
        // Try sending all warning IDs
        return message.channel.send("Fetched every warn ID: " + resolvedResults + "\nCount:" + resolvedResults.length);
    }
#

the first statement with the !member works

#

anything after else doesn't

#

do you want to see how I store the enmap data?

quartz kindle
#

how did you store the warnings?

ancient nova
# quartz kindle how did you store the warnings?
    // Prevent people from using the command for now.
    if (message.author.id !== process.env.OWNER) return message.channel.send("Command isn't finished yet");

    // Check for the valid permissions.
    if (message.author.id !== process.env.OWNER && !message.member.permissions.has("MANAGE_MESAGES")) return message.channel.send("You do not have enough permissions to warn.");

    // Fetch the warned user.
    const member = message.mentions.members.first() || message.guild.members.cache.get(args[0]) || message.guild.members.cache.find(r => r.user.username.toLowerCase() === args.join(' ').toLocaleLowerCase()) || message.guild.members.cache.find(r => r.displayName.toLowerCase() === args.join(' ').toLocaleLowerCase());
    if (!member) return message.channel.send("You have to mention a valid user to warn.");

    // Prevent people from warning themseleves
    if (member.user.id === message.author.id) return message.channel.send("You can't warn yourself.");

    // Fetch the reason.
    let reason = args.slice(1).join(" ");
    if (reason.length < 1) reason = "No Reason Provided";

    // Load the guilds settings.
    const settings = getSettings(member.guild);

    // Store the warn information
    const generateWarnedID = await generateID(5);
    warnstorage.set(generateWarnedID, [member.user.id, message.author.id, reason]);

    // Show confirmation
    return message.channel.send(`:thumbsup: Warned **${member.user.tag || "Unable to Fetch User"}** for **${toProperCase(reason) || "No Reason Provided"}** The Warn ID is **${generateWarnedID}**`);
#

the specific line is the one that uses warnstorage.set

quartz kindle
#

what does generateID return?

#

a string?

ancient nova
#

yeah 5 chars long string

#

example: f8aj3

quartz kindle
#

ok, so when you use warnstorage.get("f8aj3") you get an array of [user id, author id, reason]

ancient nova
#

yep

quartz kindle
#

so when you do warnstorage.filter(value => value[0] === user id) you get a sub-enmap of those entries

quartz kindle
#

like a filtered enmap

#

its still an enmap, but it has everything else removed

ancient nova
#

yeah I want to filter the enmap by user id

#

[user id, author id, reason]
^ by doing

quartz kindle
#

so you still need to get the values from it, as if it were a normal enmap

ancient nova
#

args[0]

ancient nova
#

wait

#

how would I write this?

quartz kindle
#

for example, if warnstorage is an enmap of 10 entries

#

and you do filtered = warnstorage.filter(...)

#

and you match 5 entries

#

then filtered is an enmap of 5 entries

#

its still an enmap

ancient nova
#

then how do I resolve it?

quartz kindle
#

you can use .map for example

ancient nova
#

omg okay give me a second

quartz kindle
#

which transforms it into something else

ancient nova
#

I literally love u if that works

ancient nova
quartz kindle
#

for example warnstorage.filter(...).map(value => value[2])

#

would give you an array of warning reasons

ancient nova
#

how would I get the key?

quartz kindle
#

evie's docs say that the function is identical to array.map

ancient nova
#

the thing I generate with the warn command?

quartz kindle
#

so the key would be the second param

#

(value, key) =>

ancient nova
#

I literally can't believe she just didn't say that I needed to do .map at the end. that could've saved me 4 hours

#

😭

ancient nova
#

doing key => key just returns all three params

ancient nova
#

actually scrap that, it works my syntax was just wrong

#

I'm trying to format it like

#

field0 = ID then field0 reason and who warned

quartz kindle
#

and both key and value return the full array?

ancient nova
#

nono it works, I was just hoping it would return an array where I can do array[0] for the key and array[1] for the value

quartz kindle
#

yeah, then just return [key, value[0]]

ancient nova
#

yeah but can I not make the value be an array too? I could double box it

#

[key, [value]]
then I would do value[1][int] to look through the value array

#

would that work?

quartz kindle
#

wut

ancient nova
#

okay okay let me explain

#

I have that map right

#

I want it to output an array with the key and then a second array with the 3 values, so 2 IDs and the reason

quartz kindle
#

ah then just do what you already have

#

=> [key, value]

ancient nova
#

they all appear mapped as if you used forEach but I just called the map function and it shows everything that is stored there

vivid fulcrum
#

eyy i got my CI/CD working

cinder patio
#

is that github?

vivid fulcrum
#

yup

#

gh actions

cinder patio
#

why does it look different

vivid fulcrum
#

using a different theme

ancient nova
quartz kindle
#

so if you return [key, value]

#

then the end result is gonna be [[key, value], [key, value], [key, value]]

ancient nova
#

I fixed that by doing 2 separate maps

ancient flint
#

Hey! Do you guys know if its currently possible for a discord bot to start a youtube together activity and start to play a video? Would be really cool for my bot but i cant find anything online. It might be possible using some kinda api request stuff. But idk

ancient nova
#

though I'm pretty sure they won't mind if you're aren't making the bot paid in any way

ancient flint
#

I mean using youtube together

#

Can a bot add a video to the waiting list

ancient nova
#

I'm not quite sure I only ever streamed music through the bot

ancient flint
#

I also cant find any like api references, i might try to use like chrome devtools to see if i can reverse engineer the endpoints it uses

ancient nova
ancient flint
#

Its not for a public bot its for a server, so i dont think its gonna be an issue

ancient nova
#

yeah if it's not public all good

#
exports.run = async (client, message, args, level) => {
    // Prevent people from using the command for now.
    if (message.author.id !== process.env.OWNER) return message.channel.send("Command isn't finished yet");

    // Check for the valid permissions.
    if (message.author.id !== process.env.OWNER && !message.member.permissions.has("MANAGE_MESAGES")) return message.channel.send("You do not have enough permissions to warn.");
    
    // Get the ID of warn to remove.
    const warnToRemove = args[0];
    if (!args[0]) return message.channel.send("You have to give an ID for me to remove.");
    
    // Lets try removing the warn.
    // We are going to use try catch as there is no way to catch the error in case the ID is invalid.
    try {
        warnstorage.remove(warnToRemove);     
    } catch {
        return message.channel.send("That ID does not exist in our database.");
    }


    // Show confirmation
    return message.channel.send(`:thumbsup: Removed warn with the ID **${warnToRemove}**`);
}
``` I'm trying to write a command to delete the warns, I'm using `<enmap>.remove(ID);` for it but even though I've got no error it doesn't delete from the DB
west stag
#

For some reason I want to switch to rust, even tho I have no clue about rust, just because it sounds so speedy and memory efficient. The decades it would take tho KEKW

scenic kelp
#

unless you're needing the performance then you really shouldn't

#

by that logic you should switch to writing everything in asm because you can optimize stuff better

#

use the language you're most familiar with, chances are you'll be the most productive with it and write the best code with it

wheat mesa
#

I agree 100%

lyric mountain
#

Fun fact: the fastest language is the one you know the most

#

A good python code can easily win against a bad assembly code

quartz kindle
#

anything can win against bad assembly

#

just look at movfuscator

lyric mountain
#

Like, 99 out of 100 times u ain't gonna write better low level code than a compiler

#

A big mistake is trying to outsmart something made to otimize your code

quartz kindle
#

kurwa outsmarted

lyric mountain
#

Who kurwa?

wheat mesa
vivid fulcrum
#

i've been awake for almost 24 hours doing my final project

#

for school

#

that i have to turn in

#

otherwise i'll fail

#

and oh boy

#

i'm starting to hallucinate and i can't even code anymore

worn sonnet
#

How can I produce icons such as these ones
I'm using react-icons to get Icons and chakra-ui

#

or do I have to write custom CSS for this?

split hazel
#

I also see the support for compilation with use of different instruction sets for better performance is often limited

#

that's due to gccs mission to work on any platform

#

(ignoring architecture of course)

#

but yeah most of the time it's better code because it can't mess up like a human

#

god humans are such hopeless creatures

near stratus
worn sonnet
#

Those are kinda like outline

near stratus
worn sonnet
#

Oh those are FI

near stratus
#

yea

near stratus
worn sonnet
#

Thanks but unfortunately they don't have discord one I guess

#

what does fi and fa actually mean?

worn sonnet
#

Thanks just checked and there are many more to play with

raw nest
#

I use pycord and I want to delete a message after 5min. It all works but the problem is with persistent. Like when the bot restarts the buttons etc. don't work anymore (that's clear) and the message also doesn't get deleted after 5min.
I have this:

        await interaction.response.send_message(embed=embed, view=view)
        await asyncio.sleep(5) # Will be 300 in prod
        await interaction.delete_original_message()

How can I make a persistent delete or something similar?

split hazel
#

ignore my deleted messages

#

that's because when you sleep it's only present when the bot is running when you restart it it will be forgotten

split hazel
raw nest
#

Yes it will be up most of the time but f.e. when there‘s an update etc.

split hazel
#

how I see other bots do it is only restart when there's a small amount of active prompts or none at all

raw nest
#

aight👍

wraith gust
#

Join yuk

dry imp
#

ga ah

pale vessel
#

ngak

quiet scaffold
#

indo

split hazel
tulip ledge
#

I have this input which is supposed to be a equation eg. x^3 + 3x^2 - x + 3 now I want to make this into a function so I can further use it to find the zero point(s) and other stuff. How would I turn this string into the form:

function equation(x) {
  return (x^3 + 3x^2 - x + 3)
}
floral nexus
#

for game/economy bots, would it be better to use regular or slash commands

lunar palm
floral nexus
#

ty for the advice

earnest phoenix
cinder patio
#

keep in mind this is dangerous

earnest phoenix
#

If the input equation can be arbitrary entered by users then this is extremely unsafe, and I would recommend rather parsing the equation yourself and building the function string

tulip ledge
#

ah yeah parsing would be better

#

thanks

#

would also allow for easier factorisation

split hazel
fathom sonnet
#

hii guys, so i have simple message embed on my bot, and I want to make my bot edit specific part of the message every x time. example: every 24h.
Problem is that i dont exactly know how should I do that, here is part of the code i have:

#

i need to edit time part in the embed description

#

btw mintime is not important at all soo just skip it

split hazel
#

@earnest phoenix huh?

earnest phoenix
split hazel
#

yeah

#

just thought that go error is very unusual

earnest phoenix
#

It wouldn't be unusual if the library is somewhat written in Go, if something is wrong in the aforementioned library I suppose

split hazel
#

yeah im using smtp-parser

#

when receiving some emails the connection resets 💀

#

will file an issue (hope the github isnt dead)

stiff dust
#

Hi I want to change Channel Category but when I use setParent it will go to the top of the category how can I move it to the buttom?

split hazel
#

any tips on tracing where that error is coming from?

earnest phoenix
#

Well the stacktrace shows the files those errors are thrown from, and exactly where the deadlock occurs

#

Unless it's from somewhere else, which is not easy to track down whatsoever

split hazel
#

i see

#

just curious what is the best way to receive "string binary" and store it?

#

im doing this

#

but it feels illegal 💀

#

have a feeling the error is because of something else

earnest phoenix
#

Hmm, what exactly is the stream here? As in what type of stream is it?

proven lantern
#
const mailData = [];
...
mailData.push(data);
earnest phoenix
split hazel
#

it do be passing through

earnest phoenix
#

The love passing through your heart

split hazel
#

yea:(

#

i think i know why its timing out

#

(resetting)

#

i havent yet tested my database on receiving and sending large amounts of data

earnest phoenix
#

Hmm, that's probably the reason

split hazel
#

yeah its probably shitting itself for some reason 💀

#

should be a good test

#

hm thats working fine not sure what it is then

#

very fast too

#

it is worryingly fast

#

i think 1500000 bytes worth of uwus was a bit too much

#

bruh why did i set the max packet size to 1mb

#

thats goofy

quartz kindle
#

uwu

split hazel
#

i underestimated how much data my database can handle 💀

#

it is officially production ready time to deploy discord on it

#

just dont worry about the fact there arent any joins or advanced string queries

#

no one needs those anyways

#

finally my tcp handling code is robust

quartz kindle
#

xD

split hazel
#

right as i say that

#

this really isnt too different from osdev but instead of a segmentation fault you get random undefined behaviour

wheat mesa
#

@lyric mountain you went all out on that PR for misty damn

sharp geyser
lyric mountain
#

tbh, I had to write it twice cuz I mistakenly wrote git rm -rf . instead of git rm -rf --cached .

#

and I kinda learned something new from reading misty code

#

I didn't know %-20s was a thing

sharp geyser
#

what that I am an idiot

#

👀

#

Waffle told me bout that

lyric mountain
quartz kindle
#

you gave up on discord-js and started discord-java?

lyric mountain
#

since I had to reload .gitignore

sharp geyser
quartz kindle
#

lmao

sharp geyser
#

also I am still working on my ts lib just slowly

#

I got angry when channel cache was not working for guilds

#

😔

sharp geyser
wheat mesa
sharp geyser
#

Fuck swing waffle

wheat mesa
#

just puts the spaces on the right side of the string instead of the left

sharp geyser
#

the docs are confusing

#

:c

lyric mountain
#

so u dont need fancy libs or repeating the same thing many times

smoky sand
#

@rare mist

iron sinew
#

gi

#

hi

tired panther
#

I am currently building a website and do not want to use any express server..
How can I redirect https://website.com/invite to a given link?
(using Apache)

#
  • Does rewriteCond work for that?
spark flint
#

just be lazy like me

#

make a folder called invite

#

add a file called index.html

#

use HTML meta tag redirecting

#

that also allows you to use things like google analytics

split hazel
#

@quartz kindle right I want to add fragmentation prevention to my db now but don't know how

#

right now all I have is a file which stores each record and fixed size values, with strings being a pointer to a location in another file where the records aren't fixed size

#

a full out solution would be to every once a while, create 2 new files, copy over all records that aren't deleted and for strings create the entries as you go

#

I can add record reusing where inserting will overwrite a deleted record but that doesn't really solve the string problem

#

and it breaks the order of insertion

#

why haven't modern operating systems yet figured out a way to delete data in between files

boreal iron
#

Both work

delicate zephyr
#

better yet if you use cloudflare just use page rules rofl

vivid fulcrum
#

use the fetch api

#

iirc you post this object

#

i don't remember what key value pairs you're supposed to use

pine nova
#

💀

pallid phoenix
#

Hi, what lenguage I need to make a bot?

rare mist
rare mist
#

I'm not them but some easy languaged are JavaScript and Python, it all depends on your skill level or if you ever programmed

split hazel
pallid phoenix
split hazel
#

both

pallid phoenix
#

k

#

Discord Bot Maker is a powerful bot development tool for the #1 text and voice chat service for gamers: Discord. With this tool, you and your teammates can take your social experience to the next level!ExplanationOne of the most prominent features provided by Discord is the official support for bot accounts. In a matter of 20 seconds, anyone can...

Price

$9.99

Recommendations

2078

▶ Play video
rare mist
pallid phoenix
#

i can learn java script

rare mist
#

Neat

dry imp
#

wtf 10 dollar

pale vessel
#

sometimes being poor makes u learn things

#

i like being poor

#

(not really)

pallid phoenix
#

really?

#

i cant pay that

dry imp
pallid phoenix
#

jaja

#

same I go to learn xd I dont wanna pay that

boreal iron
dry imp
#

i aint that rich wasting money on nitro

pallid phoenix
#

k

#

you know where i can learn?

rare mist
split hazel
#

yt

#

if the person on youtube isnt an indian find another video

pallid phoenix
#

ah

rare mist
#

I can recommend a channel if you would like

pallid phoenix
#

k

pallid phoenix
pallid phoenix
#

no?

rare mist
pallid phoenix
#

XD ok

boreal iron
#

You would sell your soul to get it, I’m sure

shrewd shell
#

Hello there! discord bot makers, I have a question for you, how can I make some commands in my bot be used with top.gg voting obligation?

winter pasture
shrewd shell
#

thank you

winter pasture
shrewd shell
#

ok

turbid geyser
#

music bots get banned?

winter pasture
turbid geyser
#

k

winter pasture
#

Well correction to the message above, they dont verify music bots that use YouTube, Spotify, SoundCloud etc. Breach of their terms

winter pasture
# orchid otter Oh really 👀

I mean, it is against YouTube, Soundcloud and Spotify's terms of service by redistributing their content. So better not do it 🤷‍♂️

winter pasture
orchid otter
#

Yep, but i don't think so that yt Spotify and SoundCloud aren't allowed. I have seen many music bots with yt support and actually discord not matters about what sources we are using.

#

Discord just don't verify music bots because of intents. Many bots are using message content intent without any reason that's why. Slash Commands is a better option.

earnest phoenix
#

The intents have no play in this, Discord doesn't go out of their way to decline bot verification forms just for intents, Discord has started unverifying a few of the popular music bots and might continue doing it

orchid otter
earnest phoenix
#

Playing music directly from YouTube is against YouTube's ToS, although not against Spotify and SoundCloud's ToSs, as Spotify doesn't provide an endpoint or a way to directly retrieve streams of their songs and play it, SoundCloud probably does although not against their ToS

orchid otter
#

Then still hydra is playing with Spotify SoundCloud and Deezer.

pale vessel
#

rythm will be back

orchid otter
pale vessel
#

but probably unlike the old one

orchid otter
#

Lmao

earnest phoenix
#

But Discord now seems to be verifying music bots again, but they might take a U turn again

orchid otter
earnest phoenix
#

You may read the first part again, Discord doesn't really look at what sources your bot uses now; but be careful as YouTube might notice (ever in a lifetime probably)

orchid otter
#

Hmmm

#

But my bot is small so no worries

earnest phoenix
#

¯_(ツ)_/¯

oblique palm
#

I notice that I get this error with certain commands but still don't understand why it doesn't work while it worked before
Could someone tel me what im doing wrong?

"stack": "TypeError: Cannot read properties of undefined (reading 'id')
at /home/container/src/utils/utils.js:466:73
at new Promise (<anonymous>)
at getTopGGVoteFromAPI (/home/container/src/utils/utils.js:463:12)
at Object.checkTopGGVote (/home/container/src/utils/utils.js:446:16)
at WhoIsCommand.run (/home/container/src/commands/info/whois.js:91:70)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)"
TypeError: Cannot read properties of undefined (reading 'id')
at /home/container/src/utils/utils.js:466:73
at new Promise (<anonymous>)```
earnest phoenix
oblique palm
earnest phoenix
oblique palm
# earnest phoenix Try logging `config.apiKeys.topGG` and see what it logs
2022-05-26 14:49:26 - error [index.js]: Cannot read properties of undefined (reading 'token')
"stack": "TypeError: Cannot read properties of undefined (reading 'token')
at /home/container/src/utils/utils.js:470:60
at new Promise (<anonymous>)
at getTopGGVoteFromAPI (/home/container/src/utils/utils.js:463:12)
at Object.checkTopGGVote (/home/container/src/utils/utils.js:446:16)
at WhoIsCommand.run (/home/container/src/commands/info/whois.js:91:70)
at processTicksAndRejections (node:internal/process/task_queues:96:5)"
TypeError: Cannot read properties of undefined (reading 'token')
at /home/container/src/utils/utils.js:470:60
at new Promise (<anonymous>)
at getTopGGVoteFromAPI (/home/container/src/utils/utils.js:463:12)
at Object.checkTopGGVote (/home/container/src/utils/utils.js:446:16)
at WhoIsCommand.run (/home/container/src/commands/info/whois.js:91:70)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
level: 'error',
[Symbol(level)]: 'error'
earnest phoenix
#

And you also have manual before token at line 470

#

The manual property is undefined, so correct it with what you logged and see what's the correct value

oblique palm
#

aha

#

it seems to be working right now

earnest phoenix
#

Awesome

oblique palm
earnest phoenix
fathom sonnet
#

guys, so i was making a welcome system with mongoDB, and i set everything correctly since my bot create DB when I launch it. But, problem is: when i "trigger" function, it only say that Aplication Did not Respond no errors in console, nothing. Here is code for setChannel file: ```js
const { SlashCommandBuilder } = require('@discordjs/builders')
const {Permissions, MessageEmbed } = require('discord.js')
const { Schema } = require('../database-schema/welcome_msg.js')

module.exports = {

/**
 *  @param {Client} client 
 *  @param {Message} client
 * 
 */

data: new SlashCommandBuilder()
    .setName('setwelcome')
    .setDescription('set channels for welcome messages')
    .addChannelOption(option =>
            option 
                .setName('channel')
                .setDescription('Set the channel where you want bot to send welcome messages')
                .setRequired(true)
        ),

async execute(interaction, client, message) {
    try {
        if(interaction.member.permissions.has('ADMINISTARTOR')) return 

        const channel = interaction.options.getChannel('channel')

        Schema.findOne({Guild: interaction.guild.id}, async(err, data) => {
            if(data) {
                data.Channel = channel.id
                data.save()
            } else {
                new  Schema({
                    Guild: interaction.guild.id,
                    Channel: interaction.channel.id
                }).save()
            }
            interaction.reply(`${channel} has been sent as the welcome channel!`)
        })
    }
    catch(err) {
        console.log(err)
    }
}

}

#

and here is code for schema ```js
const mongoose = require('mongoose')

const Schema = new mongoose.Schema({
Guild: String,
Channel: String,
})

module.exports = mongoose.model('welcome-channel', Schema)

fathom sonnet
#

how do you mean?

civic scroll
#

seems like you didn't and the discord client timed out

civic scroll
fathom sonnet
#

alright, lemme try

civic scroll
fathom sonnet
#

yes

celest gate
#
DiscordAPIError: Invalid Form Body
components[0].components[0].emoji.id: Invalid emoji
components[0].components[1].emoji.id: Invalid emoji
components[0].components[2].emoji.id: Invalid emoji
components[0].components[3].emoji.id: Invalid emoji
components[0].components[4].emoji.id: Invalid emoji
components[1].components[0].emoji.id: Invalid emoji
    at RequestHandler.execute (/home/container/node_modules/discord.js/src/rest/RequestHandler.js:350:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async RequestHandler.push (/home/container/node_modules/discord.js/src/rest/RequestHandler.js:51:14)
    at async TextChannel.send (/home/container/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:176:15)
    at async module.exports (/home/container/events/player/trackStart.js:87:22) {
  method: 'post',
  path: '/channels/978735567967764546/messages',
  code: 50035,
  httpStatus: 400,
  requestData: {
    json: {
      content: undefined,
      tts: false,
      nonce: undefined,
      embeds: [Array],
      components: [Array],
      username: undefined,
      avatar_url: undefined,
      allowed_mentions: undefined,
      flags: undefined,
      message_reference: undefined,
      attachments: undefined,
      sticker_ids: undefined
    },
    files: []
  }
}
fathom sonnet
earnest phoenix
earnest phoenix
celest gate
#

ohk

fathom sonnet
#

yea, still same, aplication dod not respon & no errors in console & bot remains online

earnest phoenix
#

You've got a typo

wheat mesa
simple stump
#

I'm using PDFKit to create a PDF with a bunch of images in a folder (see image). However, when looping through the directory, the script loops out of order. For example:

Adding for 0.png
Adding for 1.png
Adding for 10.png
Adding for 11.png
Adding for 12.png
Adding for 13.png
Adding for 14.png
Adding for 3.png
Adding for 4.png
Adding for 5.png
Adding for 6.png
Adding for 7.png
Adding for 8.png
Adding for 9.png

Is there a way to fix this?
Code: https://sourceb.in/1xFiRvv2o3

quartz kindle
#

but alphabetical, not numeric

#

if you want numeric, you need to extract the numbers from the file name and re-sort them

simple stump
simple stump
simple stump
sharp verge
#

Hi, so im trying to setup a webwook when voting for the bot and would like to continue with voting rewards. I used this code from the topgg documentation but am unsure what to replace the content with in the last line (the "dblwebook" and "password")

import topgg

# This example uses topggpy's webhook system.
bot.topgg_webhook = topgg.WebhookManager(bot).dbl_webhook("/dblwebhook", "password")
quartz kindle
lyric mountain
sharp verge
#

thank you minecraftheart

split hazel
#

no please no more please I beg you

quartz kindle
#

theres a new react framework every 3 months

#

:^)

spark flint
#

does anyone here have experience with Puppeteer proxying? I kinda don't want to expose my servers IP when people screenshot things

simple stump
#

Weird question. I'm sending requests to a website. I'm just curious whether this bit of code would get me IP banned or not.

for (let i = 0; i < links.length; i++) {
  let link = links[i];
  let request = new Promise((resolve, reject) => {
    this.wait(this.throttle ? this.throttle : 50).then(() => {
      this.downloadFile(link, join(__dirname, "./" + title + "/" + chapter + "/" + page + ".png")).then(() => {
        resolve();
      });
    });
  });
  promises.push(request);
}
await Promise.all(promises);

This this.wait is pretty useless, but I'm just wondering if there's a way to not get blocked if I were to send requests this way.

celest gate
lyric mountain
#

something.value
/\ this is null

quartz kindle
simple stump
#

hm interesting. is there a better way to go abt this without having to wait an extremely long time for js to download images?

quartz kindle
#

execute them sequentially

#

one at a time

#

if that takes too long, you can try executing a few at a time

#

with formdata

#
const fd = new FormData();
fd.append("file", file);
$.ajax({
  type: "POST",
  url: "upload.php",
  data: fd,
  success: success
});
upper current
#

the only thing i see here is you have let filetype = file.type, but file isn't defined anywhere. (not in that snipet anyway)

#

when you use showFile() are you passing anything through?

#

showFile(file) maybe?

lyric mountain
#

hey @quartz kindle are u a cpp guy?

quartz kindle
lyric mountain
#

nhe

boreal iron
#

Isn’t cry speaking cpp?

#

Or c#

#

I don’t remember anymore

#

I’m old

#

That’s sad

quartz kindle
#

do you need help with cpp? or with ccp?

lyric mountain
#

just trying to disable alt key (but not alt combos)

quartz kindle
simple stump
lyric mountain
#

like, the company I work to uses alt as the "Function" key, and we're rewriting one of the programs in flutter

#

but windows is stupid and doesn't let me press alt without focusing the titlebar menu

boreal iron
lyric mountain
#

I managed to remap alt to ctrl, but I also need to allow alt combos

#

idk how to detect if multiple keys are pressed in cpp

#

tbh I'd not even be touching cpp if fckin dart had a way to disable keyboard keys

quartz kindle
#

thats not even a cpp issue, is more like a windows api hell issue

split hazel
#

c++? why would you touch that garbage unsafe crippled mess of a language

#

become a rustacean today

lyric mountain
#

like, I don't need to touch the cpp files, but I must

#

fuck it, I'll use a boolean switch

#

...except I cant cuz alt is pressed first

split hazel
#

🤮 🤮 🤮 🤮

#

we dont speak about that dead language

boreal iron
split hazel
#

yeah:(

#

shouldve written my database in rust

#

but then i dont think my schools exam board project allowed languages allows rust

#

too new of a language

lyric mountain
#

speedy's worst enemy

split hazel
#

can you explain the joke

lyric mountain
#

because it removes rust

split hazel
#

ah

#

ive only coded in rust for 1 hour in total so far tho

boreal iron
#

It doesn’t really remove rust but who cares

quartz kindle
#

that link doesnt work

fathom sonnet
#

ok guys, so about my problem with welcome message from today, it was because i missed (!) in permissions so thats why bot didnt answer, but now, when i call interaction, i got error: findOne() is not defined:

simple stump
#

Using ElectronJS, how can I create an “overlay” in a sense? Ex. A window that is semi-transparent that doesnt go away if you are in full screen. One example includes Discord’s overlay that you can enable in settings.

manic basin
# pallid phoenix you know where i can learn?

U first want to pick the programming language that ur bot is going to be written in. It could be any, from C++ to JS to Python. Make sure that u are comfortable with the programming u want to program in. Then find a lib to use. U could use this site (https://libs.advaith.io/) to see which one works out for u. once u have chosen, go ahead and read the docs and guides

dry imp
#

you probably wanna code them in julia

vivid fulcrum
#

unfortunately people like that aren't willing to and will never learn

manic basin
#

The programming language doesn't really matter. Plus Julia's discord lib is on API v6, which has been deprecated for a long time now

vivid fulcrum
#

most of the time they resort to copypasting from youtube

dry imp
#

use python for everything stareswag

lyric mountain
#

also u need to make it ignore pointer events

radiant kraken
dry imp
#

i use it for everything

radiant kraken
#

it depends on what field of programming you're interested on

dry imp
#

use python when you can, use other lang when you must stareswag

radiant kraken
#

tbh just use whatever the fuck you want iara_sunglasses_cool

dry imp
#

yes but you probably want python troll

radiant kraken
#

i used to be a python dev 2 years ago so i can't disagree with that

dry imp
#

should've been for your whole life, im disappointed in you null

radiant kraken
manic basin
pallid phoenix
#

xd

#

k

vivid fulcrum
#

it's cpp

sharp geyser
#

Interesting to know cry

#

I didn't know that

lyric mountain
#

cry do u know if it's possible to disable alt key default function?

#

like, the one that focuses the titlebar's menu

vivid fulcrum
#

to have a true overlay you need to have a directx/opengl hook that intercepts the game rendering pipeline, wait for the game frame to render, hook into the render, flush your buffer into it and then send it to the gpu/cpu to render

vivid fulcrum
#

my electron apps are frameless

#

then in the frontend i create a custom frame

lyric mountain
#

pressing alt still send focus to titlebar

vivid fulcrum
#

oh flutter

#

i have absolutely 0 experience with it

#

sorry

#

been wanting to try it out though

#

im currently expanding my stack by using all kinds of UI app frameworks

lyric mountain
#

I can write in the cpp files used for windows

#

that's why I asked since ur a cpp shaman

pale vessel
#

isn't he a c# shaman

fathom sonnet
# wheat mesa Show `setChannel.js`

here it is: ```js
const { SlashCommandBuilder } = require('@discordjs/builders')
const {Permissions, MessageEmbed } = require('discord.js')
const { Schema } = require('../database-schema/welcome_msg.js')

module.exports = {
/*
/**
* @param {Client} client
* @param {Message} client
*
*/

data: new SlashCommandBuilder()
    .setName('setwelcome')
    .setDescription('set channels for welcome messages')
    .addChannelOption(option =>
            option 
                .setName('channel')
                .setDescription('Set the channel where you want bot to send welcome messages')
                .setRequired(true)
        ),

async execute(interaction, client, message) {
    try {
        
        if(!interaction.member.permissions.has('ADMINISTRATOR')) return interaction.reply('You are not allowed to use this command')
        const channel = interaction.options.getChannel('channel')

        Schema.findOne({Guild: interaction.guild.id}, async(err, data) => {
            if(data) {
                data.Channel = channel.id
                data.save()
            } else {
                new  Schema({
                    Guild: interaction.guild.id,
                    Channel: interaction.channel.id
                }).save()
            }
        })
        interaction.deferReply({ ephemeral: true })
        interaction.reply(`${channel} has been set as welcome channel`)
        .then(console.log)
        .catch(console.error)

       
    }
    catch(err) {
        console.log(err)
    }
}

}

#

const { Schema } = require('../database-schema/welcome_msg.js') is just schema

pine nova
#

why are u importing it like that

#

just do

const WelcomeSchema = require('../database-schema/welcome_msg.js')
WelcomeSchema.findOne({}).then().catch()

if its a mongoose schema 💀

copper cradle
#

well that does look like a mongoose schema

pine nova
#

then yea

fathom sonnet
pine nova
split hazel
#

use speedb instead

#

no memory leaks whatsoever

#

not even one byte

pine nova
#

never heard of it fr

split hazel
#

ah

#

its mongodb but better

#

its very fast too

pine nova
#

dem gonna try it then

boreal iron
split hazel
#

good stuff

boreal iron
#

Not sure if an exorcism would help you anymore

#

Probably not at this point

split hazel
#

🤡🤡🤡🤡🤡

#

you rn

spark flint
#

known issue

#

also wrong channel to report stuf

#

but nothing we can do as you've already reported there

tribal crow
#

Hello there

#

I need some help :)

#

I have an array of different events and when these events take place. I want to find the next event, but not the closest event. I've searched for a long time, but didn't find anything helpful. Are any of you able to help? Thanks :)

civic scroll
#

apparently, this code executes, but the value of isPortrait is not updated after call

civic scroll
#

you said you knew react

winter pasture
civic scroll
#

but the thhing is

#

the call to setIsPortrait didn't update the value of isPortrait at all

#

here is the variable defs

winter pasture
#

And the console.log in there did fire?

civic scroll
#

yeah

winter pasture
#

Wth

civic scroll
#

enourmous amount of times

#

but value didn't change

#

if you look at the code prior to this

vivid fulcrum
#

what does your entire useEffect look like

civic scroll
#

it's irrelevant

#

all you need to know is that

vivid fulcrum
#

it's relevant

civic scroll
#

i did define that

#

the useEffect has 0 deps

#

and did return a cleanup func

winter pasture
#

It should have the setIsPortrait func as a dep I think

#

At least our linting rules force us to do that at work

In case the function is redefined

civic scroll
#

i don't want the whole thing to rerender

vivid fulcrum
#

it will because of the state change

civic scroll
#

it's only defined once since the component won't rerender no matter what state changes

vivid fulcrum
#

also

civic scroll
#

it won't

vivid fulcrum
#

the resize event fires a bunch of times, you might consider adding a debounce

#

150ms or so should work fine

civic scroll
#

bruh

#

it only fires when the viewport changes from landscape to portrait

#

but that's not the stuff i need

#

the problem is the dispatch call didn't update the state for some reasons

#

and idk what's preventing it

#

the func call did hit

vivid fulcrum
#

i am not talking about the effect firing

civic scroll
#

not the effect

#

the update function

vivid fulcrum
#

i just noted that the resize event will fire a bunch of times during resizing, log it in the console and see for yourself

#

adding a debounce will improve performance significantly

civic scroll
#

i returned immediately

#

so what's the point of debounce

#

and you are deviating away from the main problem

vivid fulcrum
#

oh good point, i thought you were doing something else in the event as well

#

have you tried running in strictmode?

civic scroll
#

it's strictmode by default wym

#

💀

vivid fulcrum
#

im just asking, strictmode is used for useful debugging info

#

stop being passive aggressive lol

civic scroll
#

i'm frustrated because you are providing me unrelated trivial stuffs

#

all i ask is what might have prevented the value from updating

earnest phoenix
#

According to the React documentation, the setState() method (setIsPortrait() in your case) is not guaranteed to change the state immediately, with the existing value staying until some of the checks behind the scenes are done, it also states that the state won't be changed if something is blocking it, such as a bottleneck

vivid fulcrum
#

because you're giving us way less information than you know on your code, you cannot get mad at people for trying to pinpoint a problem with little information

civic scroll
#

there's nothing else touching those state vars i mentioned

#

and therefore they are deemed to be reduntdant

#

get to the point already

solid tide
vivid fulcrum
#

something also just popped into my mind, you're going to benefit from denouncing regardless

your user can keep resizing even after the landscape check passed

civic scroll
vivid fulcrum
civic scroll
#

in 1 second, resizing within the bound of portrait

civic scroll
#

since window api is outside of react

vivid fulcrum
#

oh

#

i think i figured it out

civic scroll
raw nest
#

Is there a way to somehow write a function to count all lines of code in a repo/organization? The api doesn't give you this data shrug

civic scroll
tribal crow
# quartz kindle please elaborate

Ok, so i have an array of all the Formula 1 races this year, containing their date and place. I want to sort them and return the next race, so that when a user uses a command, it replies with all the info about it.

vivid fulcrum
#

the value possibly lags back in setting the state, instead pass it an arrow function, the argument of the arrow func is granted to have the current value of the state, just invert it since it's a bool

raw nest
civic scroll
#

so you mean

#

define an arrow function instead of using the state variable directly in cb

vivid fulcrum
#

yes, sec ill try to find a doc for it

solid tide
civic scroll
#

document.addEventListener ?

solid tide
civic scroll
#

get current date as unix and use binary search to find the nearest one

#

assuming the data is a tuple

quartz kindle
#

(assuming js)

civic scroll
#

looks like

vivid fulcrum
civic scroll
#

the thing is

#

wait lemme read stack overflow

#

also

#

debouncing won't help

vivid fulcrum
#

yes it will

#

you're overloading react by updating the state so many times

#

not even useTransition would help

vivid fulcrum
#

do you really think this is not an issue

civic scroll
#

didn't i mention it wouldn't rerender no matter what

#

the useEffect has explicitly 0 dependency

vivid fulcrum
#

a component re-renders when its state changes

civic scroll
#

no

#

that's if you call useEffect and omit the 2nd parameter

vivid fulcrum
#

you have some serious misconceptions

#

effects are functions that run whenever a change is challenged in the component ergo effects

#

your component will re-render but the hook won't re-run

civic scroll
#

but the thing is

#

that state value doesn't change the component's output html

#

so on change it shouldn't rerender

vivid fulcrum
#

doesn't matter

civic scroll
#

2nd argument is, didn't you already see the condition to trigger a state change and a possibly a rerender like you said?

vivid fulcrum
#

react defaults to re-rendering behaviour when a components state is changed

civic scroll
#

how can someone resize between landscape and portrait 300+ times a second

solid tide
vivid fulcrum
#

oh my

#

god

civic scroll
#

you didn't get the problem

solid tide
wheat mesa
#

💀

solid tide
civic scroll
#

btw @vivid fulcrum

#

callback didn't solve the issue

vivid fulcrum
#

your state change will run anytime the portrait check passes, although react won't re-render if the current state value is equal to the value of the argument, you're still calling the setstate and putting pressure on react

#

im out of ideas right now, just try debouncing as a last resort

#

if that doesn't work, no idea

solid tide
#

The val does change

civic scroll
iron gale
# civic scroll

Why you are not waiting for resize end? You can do it by setTimeout and clearTimeout but im not too sure about performance

vivid fulcrum
#

i would approach this by debouncing the resize event listener and putting isPortrait as an effect dependency

civic scroll
#

perhaps i can try adding the portrait as a dep

vivid fulcrum
#

isPortrait? worth a shot

civic scroll
vivid fulcrum
#

it's most definitely a performance concern but alright

#

whatever floats your boat

civic scroll
#

bruh

quartz kindle
#

i dont know react, but i found this in SO, idk if its of any use, if not just ignore

civic scroll
#

there's no one that can be bored to even

#

resize the page

vivid fulcrum
solid tide
#

Ie after changing state

civic scroll
#

good news: dependency worked

#

bad news: refactor

vivid fulcrum
#

now debounce it!!!!!!!!! :(

civic scroll
#

since the component is entire page

#

now the intro sequence plays again

solid tide
civic scroll
#

💀 ]\

#

i will just suffer in vc

#

thanks and sorry for the troubles

solid tide
civic scroll
solid tide
vivid fulcrum
#

it's a bit rude but i get where they're coming from, you're trying to help someone whose skill level is above yours

solid tide
#

Js for a month

wheat mesa
#

Definitely not your area of expertise then for that :p

earnest phoenix
#
if(!msg.author.roles.has('979751338831396884'))return;```
#

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

#

what is the problem ?

wheat mesa
#

author is a User object, which does not have roles associated with it. Use msg.member instead

earnest phoenix
#

oh ok let me try

earnest phoenix
#

i use discord.js v12

wheat mesa
#
  1. Update to v13
  2. Read the docs for member objects, I’ll send it here
earnest phoenix
#

i don't need v13 now

wheat mesa
#

Yes, you do

#

Staying on v12 will give you a massive headache later

earnest phoenix
#

ik

wheat mesa
#

msg.member.roles.cache.has()

earnest phoenix
#

oh ok

wheat mesa
#

I personally love discord.js’s documentation, make sure to reference that whenever you’re having issues with it

lament rock
#

Discord.js documentation and pretty much every other doc page assumes you understand data types and have an editor that supports it

wheat mesa
#

If you don’t already know about data types then that is definitely something you need to know about

lament rock
#

I mean. It's stupid to not have an editor that has intellisense

wheat mesa
#

Well, a lot of people use replit that “has” intellisense, but it’s so slow that it doesn’t show up 90% of the time

#

So I understand why it can be difficult sometimes

earnest phoenix
#

a shop server bot .-.

wheat mesa
#

Regardless of what you use though, knowing how to navigate and use the documentation is a very essential and useful tool to developing a discord bot

wheat mesa
#

Gl!

civic scroll
#

additional help needed

#

this involves framer-motion library for react

solid tide
boreal iron
floral zephyr
#

Selamunaleyküm

boreal iron
#

It’s some pure hardcore experience

dull dragon
#

How do i see which servers added my bot?

simple stump
#

Using ElectronJS, how can I create an overlay similar to this? The overlay is able to stay on top even when an application is in full-screen, yet when I'm playing a videogame, win.setAlwaysOnTop doesn't always work (the window doesn't appear). Is there a way to achieve this?

winter pasture
lyric mountain
dull dragon
dull dragon
winter pasture
fathom sonnet
#

I got an queatuon, maybe it is Stupid but hey...

So i got and idea on to make d.js bot which will use image detection to detect specific objects on the image. So i just Wonder if that is posible

winter pasture
fathom sonnet
#

I would use it to "protect" Server from NSFW content...

proven lantern
fathom sonnet
fathom sonnet
quartz kindle
#

this is true for most games as well

#

the only way for an overlay to work in true fullscreen is if that overlay injects itself into directX/openGL or whatever graphics engine the game uses

simple stump
quartz kindle
#

if it works with any other window, then it should work on mc too, it basically always brings the window to the front of other windows

#

fullscreen doesnt use windows at all, the game takes full control over the screen and the desktop ceases to exist while the game is running

#

as for how to do that, i dont know either

delicate zephyr
upper current
#

random question: a friend wants to put gifs (from Tenor) in his embeds. Discord parses those gifs and displays them fine in text, but when embedding them, the embeds don't like it without the .gif and just simply adding that to the end of the links breaks them. Any idears on what we could try to just to play around with it?

quartz kindle
upper current
#

typical

quartz kindle
#

when pasting them as a website, discord looks up the website's opengraph tags to decide what to display

#

for example

#

these are the links discord actually displays

upper current
#

so it would be better to just access the Tenor API and pull from there rather than trying to parse it out on his own?

quartz kindle
#

so you have to do the same, fetch the tenor link and look for the direct link in the opengraph tags

upper current
#

they do, just not one i've ever done anything with.

#

used one, used 'em all, rite?

#

||jk, biggest lie i've said all year||

#

ty tho

quartz kindle
#

try it

boreal iron
#

anybody else having trouble with the v10 gateway and the client presence?

#

discord somehow doesn't show the client's presence for some reason

#

it has been set correctly and the client has the right presence

upper current
tacit citrus
upper current
#

it's possible to catch who's message was deleted, but without accessing the audit logs, you can't tell who deleted it.

tacit citrus
#

my bot has acces to audit logs but i should fetch it from audit logs?

slender thistle
quartz kindle
upper current