#development

1 messages ¡ Page 38 of 1

ancient nova
#

1/10 chance for the embed to be named sus o meter

boreal iron
#

And we still love you Misty

sharp geyser
#

😔

#

Then help me

boreal iron
sharp geyser
#

;)

ancient nova
#

🤣

boreal iron
#

Then I would

sharp geyser
#

Well too bad

#

you shall never know

#

the awesome thing I am doing

boreal iron
#

:D

#

But but but I kindly ask

sharp geyser
#

But nah I am making a chat app to practice websocketing

#

and am having troubles displaying the messages to all clients in real time

#

as soon as they are sent

#

Doesn't help that the thing I am using to receive from the server uses a package I have 0 clue how to use right now

boreal iron
#

Don’t u just use some event system which emits an event being send to the client when a new message has been sent!

sharp geyser
#

Indeed

boreal iron
#

Isn’t that sort of the easiest way of doing it

sharp geyser
#

The client sends an event to the server that it receives and processes and sends smth back to the client

#

the smth back right now is the message and sender

#

but I have never used rxjs so whats being received in the client is turning into an Obeservable and I have 0 clue how to efficiently extract the data from an Observable without making spaghetti code

ancient nova
#

huh createdAt doesn't return ms

#

@boreal iron just tell me this and I can go to jail peacefully

sharp geyser
#

it returns a timestamp

ancient nova
#

huuuuh

#

how do I convert it to ms then

#

wth

boreal iron
#

Ok nothing I can help you with, too unfortunately
I made very simply System using only basic JS

sharp geyser
#

Yea I am using Angular

#

and Nestjs

#

and the only popular package I see for implementing a "easy" client implementation of client socketing is ngx-socket-io

#

but it turns everything into an Observable

#

and I have no idea how to use rxjs

#

and frankly I don't wanna learn

ancient nova
boreal iron
#

Hmm well never worked with em

ancient nova
#

if that's what it returns then how the hell does my whois command works?

#

I'm using the exact same thing and it somehow converts it to normal time

#

my timeAgo function takes in MS???

sudden geyser
sharp geyser
#

Teach me then

#

:)

#

right now I am fucking it up

sudden geyser
#

No OzenSmile

boreal iron
#

Guess you’re fucked then Misty

fallen holly
#
            const Target1 = interaction.options.getMember("user") || interaction.member.user

 if (Target1.memberPermissions.has("KICK_MEMBERS")) {
                                          ^

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

I'm trying to make a user info cmd

boreal iron
sharp geyser
sharp geyser
#

no idea what that is

sudden geyser
boreal iron
ancient nova
#

what????

#

am I missing something??

boreal iron
#

No but guild members have

ancient nova
#

how does that work

#

my timeAgo function takes in MS

#

MS

sharp geyser
#

Cause stupid

#

its in ms

ancient nova
#

wot

sharp geyser
#

but djs probably does something when its called on its own and sent to a channel

#

and turns it into a readable format

#

same with if you try and send a member object without putting it in code blocks or whatever

#

iirc it just pings the user

ancient nova
#

then how come this returns false ? member.user.createdAt <= 6.912e+8

#

the account age is 6 days the amount of ms adds up to 8 days

sharp geyser
#

you are trying to compare a timestamp to a smaller number...

#

a timestamp will end up being a massive number in ms

#

do you think that massive number will be less than 6.912e+8ms?

ancient nova
#

no the createdAt adds up to 6 days, right? and the 6.912e+8ms is 8 days

#

so what's going on?

ancient nova
sharp geyser
#

wait one sec I think I might be doing math wrong

ancient nova
sharp geyser
#

you should be doing it correct yea

#

Unless createdAt is valued at more than 8 days

ancient nova
#

no it's definitely not

#

I tried 30 days timestamp

#

still returned false

#

what the actual hell..?

sharp geyser
#

@civic scroll hello qt

#

I have angular question from last night when u available

#

<3

boreal iron
#

Im continuously offline

sharp geyser
#

Once I get used to this rxjs bullshit

#

I will be able to make actual progress

boreal iron
#

Also where are all my messages I sent when I was offline?

fallen holly
boreal iron
#

Going into the void

#

Wtf is going on here

#

huh

#

time to delete my discord account I guess

ancient nova
#

dude what the hellll!!!

#

I can't get createdAt to return ms

boreal iron
#

Wut?

ancient nova
#

when I run it over my timeAgo function it returns 6 days ago

#

when I compare it to 8 days ms it returns false even though 8 days is larger than 6 dyas

#

WHY

#

WHAT IS GOING ON

boreal iron
#

What are you actually talking about?

sharp geyser
#

oh wait

#

I am dumb

#

forgot djs split shit

ancient nova
#

I just want to check whether an account is younger than a week

sharp geyser
#

createdAt is the actual date

#

createdTimestamp is what you want

ancient nova
#

but then how come my createdAt changes into MS????

sharp geyser
#

🤷‍♀️

#

dont question shit

ancient nova
#

my timeAgo function takes in MS and somehow when I do createdAt it turns it into regular time?

sharp geyser
#

just use createdTimestamp

#

ez

ancient nova
#

I am

#

I think we live in a simulation

#

that can't be real bruh

#

😭

#

how does that work

boreal iron
#

I feel like we should ask to see your function but no, that won’t happen

#

Not falling for it this time

ancient nova
#

somehow this turns createdAt weird shit into MS

sharp geyser
#

There you go

ancient nova
sharp geyser
#

you are taking a date and making it a new date

#

and subtracting by the current date

ancient nova
#

I'm such a dummy

sharp geyser
#

you don't even need new Date(date) iirc

#

since whatever date is will already be a Date object

boreal iron
#

Should have kept my mouth

ancient nova
#

I don't even know why I did that this way

#

I'm so confused with myself

boreal iron
#

Ur not the only one

quartz kindle
#

valueOf abuser smh

boreal iron
#

Don’t u like to be abused a little bit?

sharp geyser
#

ofc he does

#

he comes here every day

ancient nova
#

I'm going to bed

boreal iron
#

lmao

ancient nova
#

gn

boreal iron
#

Don’t have nightmares of your code

quartz kindle
#

so did they leave the content intent thingy paused half-way?

#

my bot doesnt respond to text commands on my server anymore, but its still responding to other servers in my logs lol

boreal iron
#

Just gets rolled out slowly

quartz kindle
#

people still insist on using text commands

boreal iron
#

Oh

quartz kindle
#

even though they are given a big ass warning on every text response

boreal iron
#

Is it sharded?

quartz kindle
#

yeah, not many tho

boreal iron
#

They said they re careful to not disconnect all shards at once especially for large bots

quartz kindle
#

yeah

#

this is my bot logs lmao

boreal iron
#

Enjoy your last moments I guess

quartz kindle
boreal iron
#

With so much variety Discord tries to archive I guess things will and can go wrong

#

Or not as planned

sharp geyser
#

v9 deprecation soon™️

sudden geyser
#

/command ... that's actually smart af

quartz kindle
#

wouldnt it be funny if after the intent enforcement there remained a few bots they forgot to apply the changes to

#

and they become the only bots in the world that can still read messages without the intent

quartz kindle
boreal iron
#

To be fair if discord would have released slash command mentions as part of the message formatting earlier it would have been easier to add them as examples to your user notifications screaming to use slash commands from now on

sudden geyser
#

wait @bot exists

#

less smart

lyric mountain
quartz kindle
#

exists yes

#

but im gonna shut down the whole process

#

my bot has 2 processes running rn, one for slash commands, another for websocket

#

both processes access the same command files lmao

boreal iron
#

Much efficient

#

Blocking files while reading? mmLol

quartz kindle
#

yeah except the slash command process has to load all the legacy crap from the other process to be able to use its commands

boreal iron
#

Please Tim

#

Don’t become the next Bae

#

Fix your code

quartz kindle
#

my bot is literally 2 cars hooked to the same battery rn

boreal iron
quartz kindle
#

even worse

sharp geyser
#

hey tim

#

ever use rxjs

quartz kindle
#

one car has the engine, the other car has no engine and instead has a bunch of gears that hook into the first cars engine to power its own wheels

quartz kindle
sharp geyser
#

Okay so can someone help me think something out real quick

#

Heres the current process of how I handle messages

#

User Types message -> They Press send and it gets sent over the socket to the server where it is saved to a db or whatever -> Server responds back with the message and the sender and any other relevant information -> How should the client display this message?

boreal iron
sharp geyser
#

I have a feeling I should be updating the div unordered list when I receive a message from the server instead of in the html file itself


<button (click)="this.sendMessage('Hello, World!')" >Send Message</button>

<div *ngIf="messages.length !== 0">
  <ul *ngFor="let message of this.messages">
    <li>{{ message.message }}</li>
  </ul>
</div>
wheat mesa
#

that looks like hell

sharp geyser
#

It is

#

Cause I have 0 fucking clue what I am doing

wheat mesa
#

good thing I have 0 clue what you're doing too

sharp geyser
#

rxjs makes everything an Observable so I am doing it in a weird way

wheat mesa
#

why javascript when rust exists

#

C:

sharp geyser
#
import { Injectable } from '@angular/core';
import {Socket} from "ngx-socket-io";
import {map} from "rxjs";

@Injectable({
  providedIn: 'root'
})
export class ChatService {

  constructor(private socket: Socket) {}

  sendMessage(msg: string) {
    this.socket.emit('message', msg)
  }

  getMessage() {
    return this.socket.fromEvent<{ message: string, sender: string }>('message').pipe(map(data => data))
  }

}

This is my ChatService that handles actually sending and receiving messages

#
import { Component, OnInit } from '@angular/core';
import {ChatService} from "./chat.service";

@Component({
  selector: 'app-chat',
  templateUrl: './chat.component.html',
  styleUrls: ['./chat.component.scss'],
})
export class ChatComponent implements OnInit {

  messages: Array<{ message: string, sender: string }> = []

  constructor(private chatService: ChatService) { }

  sendMessage(msg: string) {
    this.chatService.sendMessage(msg)
  }

  getMessages() {
    const message = this.chatService.getMessage()
    message.subscribe(data => {
      this.messages.push({ message: data.message, sender: data.sender })
    })
    return this.messages;
  }

  ngOnInit(): void {
  }

}

This is how I send the message to the service and how I get the message and add it to the this.messages array

#

but I realized I don't need to return this.messages anyway cause I can just access it

wheat mesa
#

yeah why have encapsulation when you can just make everything public C:

#

misty how do you like my plans for making a bytecode VM ```rs
/*

  • TODO:
    • Redo operations to allow more than 1 byte access to constants
    • Each op is still 1 byte, but can be followed by data greater than 1 byte
    • Use Cursor instead of BufReader
    • String format: LEN, BYTES
    • Store all floating points as u64, then use f64::from_bits to convert
  • BYTECODE FORMAT:
    • First 4 bytes: Number of constants in section - "C"
    • Second 4 bytes: Amount of bytes following the constants section - "N"
    • Bytes 9 to "C": Constants (Strings, numbers, etc)
    • Bytes "C" to "N": Opcodes and data following opcodes
      */
sharp geyser
#

at least when I tried I ran into issues

sharp geyser
#

I would if I did

#

and I am not confident in rust and am too scared to try

#

🥲

spark flint
#

Does interaction return a guildMember object?

sharp geyser
#

If its used in a guild I think so

boreal iron
#

As property yes

sharp geyser
#

I understand only half of that tho

wheat mesa
#

basically I have funny bytes in a file that represent different operations

#

and I'm thinking of a way to refine my current implementation to better support things

boreal iron
#

Waffle becoming the next Speedy-boy

#

soon to be banned lmao

spark flint
#

If I have an array of role IDs, how can I check if a user has any one of those roles?

wheat mesa
#

I just like low level

spark flint
#
const memberHasRole = serverConfig.modRoles.some(async (role) => {
    interaction.member.roles.cache.has(role)
});```
#

I got there but it doesn't work

wheat mesa
#

don't use async there

spark flint
#

ah

wheat mesa
#

But that would be the way to do it from what I can tell

#

ah you didn't return anything from that

spark flint
#

ah

wheat mesa
#

try js const memberHasRole = serverConfig.modRoles.some(role => { return interaction.member.roles.cache.has(role) }); or ```js
const memberHasRole = serverConfig.modRoles.some(role => interaction.member.roles.cache.has(role));

hidden gorge
#

elseif ($piece[0] !== basename(dirname($_SERVER[PHP_SELF]))) {
                                echo '<a href="'.$piece[1].'">'.$piece[0].'</a>';
                            }```
wheat mesa
#

@boreal iron your domain here

boreal iron
#

Use it as key (string) not as constant

#

$_SERVER['PHP_SELF']

hidden gorge
#

wdym

boreal iron
#

Compare what I wrote with yours

#

You’re using PHP_SELF as constant not as key to the global $_SERVER array

#

Ow yaay am I offline again?

hidden gorge
#

it works

boreal iron
#

Hmm just took like 20s to be send again

#

Idk

#

What’s going on today

hidden gorge
#

my wifi sucks

sharp geyser
sharp geyser
boreal iron
#

Nah I’m continuously being offline like every few minutes today

#

Maybe already reached my traffic limit

#

Idk

carmine summit
#

How do I call client deep in another file?

sharp geyser
#

Wdym

carmine summit
#

client is defined in index.js when it's ready, its going to call ./tools/tasks.js (init()) which is going to call ./update.js (update()) which needs to access client

sharp geyser
#

You can keep passing client down the chain

carmine summit
#

in the function parameters?

sharp geyser
#

Yea

boreal iron
#

Or export it and import it

carmine summit
#

wont that get messy af?

sharp geyser
#

Yes

#

Which is why no one does this

carmine summit
sharp geyser
#

That's the better option

#

Ig

boreal iron
#

Tbh I would create a class in your tasks.js and pass client in your index to it when initiating the class after importing tasks.js

quartz kindle
#

it lets you create a system where the bot cannot be invited until the person obtains special permission to invite it, for example some kind of registration system where the bot cannot be invited until the registration is complete

sharp geyser
#

So you can essentially make a private beta cool

sharp geyser
#

hi sayuri

#

I'm fixing to take a shower but I'll be back soon

civic scroll
#

> sayuri runtime init

quartz kindle
civic scroll
#

ok

quartz kindle
#

never export stuff from index.js

sharp geyser
#

Don't listen to Tim rebel!!!

quartz kindle
#

unless you know what you're doing

boreal iron
#

> sayuri pause

sharp geyser
#

Rebel against Tim

civic scroll
#

you export function callbacks

#

then you call it inside index

#

using event emitters

carmine summit
#

that also sounds messy af

civic scroll
#

nah

#

it's not

#

simple as shit

#

otherwise you have no way to access the client var

boreal iron
#

Define a class in your tasks file, export it, import it in your index and initiate the class, pass client to it

#

Easy

civic scroll
#

no

boreal iron
#

Yes

quartz kindle
#

the only safe way to export stuff from index.js is to import it inside functions and not in the root file

civic scroll
#

function callbacks are the most optimal

quartz kindle
#

otherwise you have circular deps

civic scroll
#

^

#

@quartz kindle still that variable access inside events?

quartz kindle
#

hmm?

civic scroll
#

what's the context that the client is accessed

carmine summit
#

it sends updates from an api

#

to a channel

quartz kindle
#

if you export it from index and import it elsewhere?

civic scroll
#

this is, similar stuffs to websocket and rxjs

civic scroll
#

something like a singleton container

boreal iron
#

He’s asking how to pass a var to another module and you’re recommending him to overengineer stuff

#

Poor dude

carmine summit
#

is there any guides to help me with this?

quartz kindle
#

hacker mode: ```js
// index.js
global.client = new Discord.Client(...)

// file.js
global.client.channels.cache.get(...).send(...)

civic scroll
boreal iron
#

Oh Tim

#

Or should I said Bae 2.0

civic scroll
#

so in index you define a client
and in that same file when a command occurs it calls the function from another file

#

is that right

carmine summit
#

literally this

civic scroll
#

and that another file tries to import the client

#

if that's the case with this solution, this man clearly never knew function binding

#

wait, where is it invoked

#

index?

carmine summit
#

yeah it defined in index

civic scroll
#

export the files as functions

#

inside index you bind the callback with the client

#

so that inside other file you can access it

#

here's an example
evt/interactionEvent.js

export function interactionEvent = (client, interaction) => console.log;

index.js

//... you set the client up and stuffs
const eventData = await import("evt/interactionEvent.js");
client.on("interactionCreate", event.bind(null, client);
#

check if it does console log the client

quartz kindle
#

await import on an es6 export? lmao

carmine summit
#

words cant define how confused i am

civic scroll
#

callbacks with events

boreal iron
#

Sayuri won the prize to be the number one “confuser“ trying to help somebody

carmine summit
#

I'm not using events

quartz kindle
#

can you show some code so we can see what exctly you're doing?

civic scroll
#

i just don't get you are trying to do

carmine summit
#
//index.js
client.once("ready", async () => {
  console.log("Ready!");
  require("./tools/tasks").init();
});
//tasks.js
const { getOrangeAppsUpdates } = require("./orangeapps");

async function init() {
  await getOrangeAppsUpdates().bind(null, client);
//somewhere in getOrangeAppsUpdates
client
boreal iron
civic scroll
#

IT IS

#

a

#

CALLBACK

#

SAY LESS FAKE

boreal iron
civic scroll
carmine summit
civic scroll
#

you.

#

you exports as functions to be used later

#

you pass the client into one of the consumer functions to be used it its body

#

not this circular import

#

this is gonna cause you errors later on

#

ever heard of circular depedency error?

carmine summit
#

no?

boreal iron
#

Imagine simply exporting a class in your tasks file you import and initiate in your index

#

I like people choosing the hard way

#

Instead

civic scroll
#

index import tools and execute itself
tools import index
index import tools
this will go on indefinitely

#

this man is stubborn af, hold lemme boot up the pc

quartz kindle
civic scroll
quartz kindle
#

init() suggests you are initializing something, not running the function

civic scroll
#

so why can't he export it as a function

quartz kindle
#

aka preparing the function for running it later

civic scroll
#

he should have exported it as a class

quartz kindle
#

so does getOrangeAppUpdates get initialized when you call it in init?

#

and then has a separate function to actually run ?

#

or is the getOrangeAppUpdates the actual function that is run on every event? in which case why is it being run on init?

boreal iron
civic scroll
#

🗿

carmine summit
#

yeah, there is a scheduler for it

#

I just added the .bind to see if itl work

civic scroll
quartz kindle
#

can you show how is it scheduled?

civic scroll
#

now.

carmine summit
#
async function init() {
  await getOrangeAppsUpdates().bind(null, client);

  //Busy school days
  schedule.scheduleJob("*/30 8-16 * * 1-5", function () {
    getOrangeAppsUpdates();
  });

  //Idle school days
  schedule.scheduleJob("0 0-7,17-23 * * 1-5", function () {
    getOrangeAppsUpdates();
  });

  //Weekends
  schedule.scheduleJob("0 * * * 0,6", function () {
    getOrangeAppsUpdates();
  });
}

quartz kindle
#

ah i see what you want

#

ok so do this

civic scroll
#

export as functions

#

there will be event registers
before listening to them

carmine summit
#

im using no events...

quartz kindle
#
//index.js
const tasks = require("./tools/tasks");
client.once("ready", async () => {
  console.log("Ready!");
  tasks.init(client);
});


//tasks.js
const { getOrangeAppsUpdates } = require("./orangeapps");
module.exports = function init(client) {
  const myOranges = getOrangeAppsUpdates.bind(null, client);
  schedule.scheduleJob(..., () => {
    myOranges()
  })
}
civic scroll
#

finally

#

thanks tim

quartz kindle
#

or simply this ```js
//tasks.js
const { getOrangeAppsUpdates } = require("./orangeapps");
module.exports = function init(client) {
schedule.scheduleJob(..., () => {
getOrangeAppsUpdates(client)
})
}

#

no real need to bind there

#

no need for async either

carmine summit
#

so just pass client as parameters?

quartz kindle
#

yeah

civic scroll
#

i told you

carmine summit
#

I was here to avoid that..

quartz kindle
#

no point in avoiding that

civic scroll
carmine summit
#

seems messy

quartz kindle
#

unless you want to use this

civic scroll
#

your implementation is way more messier

#

than this elegant arrow func callback

quartz kindle
#

you can do js const myOranges = getOrangeAppsUpdates.bind(client); schedule.scheduleJob(..., () => { myOranges() }) and then use this to access client inside the function

carmine summit
#

yeah, im just gonna pass client as parameters

civic scroll
#

i don't get it, why is it "messy"

carmine summit
#

i dont get it either

civic scroll
#

why you didn't get what you just said

quartz kindle
#

imagine it like this: how do you want to access the client inside the function?
if you want to access it via client -> pass as parameter
if you want to access it via this -> bind it
if you want to access it via this.client -> create a container class to hold the functions

carmine summit
#

yes ok fine, im just gonna pass it by parameters

quartz kindle
#

if you want to be cool -> access it using global.client

#

:^)

carmine summit
civic scroll
#

sorry for the tantrum, i just woke up to see this abomination

quartz kindle
#

if you want to be extra cool: export client and use require("../index.js") inside the function (not outside)

carmine summit
quartz kindle
#

yes

#

:^)

boreal iron
#

Poor Cwikks

#

You had the chance to escape

#

Rip

sharp geyser
#

@wheat mesa Is it a mistake to try and use rust for the backend of my chat app when I have 0 clue of what I am doing and where to start

#

researching a lot rn

civic scroll
#

use angular as backend

sharp geyser
#

I started from scratch my angular project

civic scroll
#

no

#

don't

#

use a dedicated backend with websockets

serene kelp
#

Any of y'all ever forget to add untracked files in git, and end up running into massive errors when you clone your repo down the line?

sharp geyser
sharp geyser
wheat mesa
#

rust has good backend capability but it also requires a little more advanced knowledge of rust since backends like that typically are multithreaded and/or share global state to some extent

#

which is difficult for a beginner to work with in rust

#

Rc<Refcell<State>> moments

serene kelp
civic scroll
#

so if there are untracked files, it will let me know

serene kelp
#

Now that I think about it, I have tons of random untracked files that I create when I stash changes I try.

#

It's probably just a me issue.

earnest phoenix
#

When did I say it's not that bad

civic scroll
#

storing booleans as strings when you can just store the boolean itself

#

mmm

#

apparently a byte is more than a bit

earnest phoenix
#

String booleans are just the worst, not only are you wasting way more memory by allocating them for the strings, but you're also slowing down the comparisons and shit as you're comparing multiple characters instead of just a byte comparison

civic scroll
#

unless the interface explicitly only communicate via strings, don't ever store booleans as string

#

thank you

carmine summit
#

is there something like const messages = await webhook.fetchMessages({ limit: 100 });?

pale vessel
#

No

carmine summit
#

ok thanks!

sharp geyser
#

So I have a basic ws implementation going with axum

#

so I am psyched I got this far

earnest phoenix
#

The channel ID is provided in the webhook so it's pretty simple

sharp geyser
#

get outta my comfort zone

#

:p

inland vapor
#

:p jut da yr

#

!play jutt da yar

#

!play jutt da yar

sharp geyser
#

This no commands channel

carmine summit
inland vapor
#

!play jutt da yar

pale vessel
carmine summit
pale vessel
#

Fetch returns a promise

#

Await it first

earnest phoenix
sharp geyser
#
use axum::extract::WebSocketUpgrade;
use axum::extract::ws::{Message, WebSocket};
use axum::response::Response;
use axum::Router;
use axum::routing::get;
use serde::{Serialize,Deserialize};

#[derive(Debug, Deserialize, Serialize)]
pub struct MyMessage {
    pub message: String
}

#[tokio::main]
async fn main() {
    let app = Router::new()
        .route("/", get(|| async { "Hello, World!" }))
        .route("/ws", get(websocket_handler));

    axum::Server::bind(&"0.0.0.0:3000".parse().unwrap())
        .serve(app.into_make_service())
        .await
        .unwrap();
}

async fn websocket_handler(ws: WebSocketUpgrade) -> Response {
    ws.on_upgrade(handle_socket)
}

async fn handle_socket(mut socket: WebSocket) {
    while let Some(msg) = socket.recv().await {
        let msg = match msg {
            Ok(msg) => msg,
            // Client disconnected so just return
            Err(_) => return,
        };

        let parsed = match serde_json::from_slice::<MyMessage>(&msg.into_data()) {
            Ok(parsed) => {
                println!("{:#?}", parsed);
                parsed
            },
            Err(error) => {
                socket.close().await.unwrap();
                println!("{}\n", error);
                return;
            }
        };

        if socket.send(Message::Binary(serde_json::to_vec(&parsed).unwrap())).await.is_err() {
            return;
        }
    }
}
#

@wheat mesa rate

#

I had a lot of help from a cool guy

earnest phoenix
#

Hey Misty

sharp geyser
#

hru

#

get next Tuesday or nah?

tiny quartz
#

anyone use Koyeb? everything works great but it fails the health check after 15 minutes because the bot isn't listening on port 8080

boreal iron
#

Idk what’s going on the last days

earnest phoenix
#

It's probably because of Discord, they've been having some issues lately due to the gateway connection invalidation for many bots at the same time and stuff

boreal iron
#

Yesterday I sent an imagine together with some text and the text disappeared

earnest phoenix
#

They already had 2 incidents yesterday

boreal iron
#

Also had a short disconnect again

#

Also this happened yesterday

earnest phoenix
#

Woah Misty first person to chat in development!

boreal iron
earnest phoenix
#

Tim must be jealous

earnest phoenix
boreal iron
lament rock
#

I've been getting a lot of EAI_AGAIN DNS lookup errors

#

specifically for resuming

#

I'll have to cache lookup results

carmine summit
#

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

  let messages = await client.channels.fetch("943705642416373850").then((c) => c.messages.fetch({ limit: 100 }));

  if (!messages) return;

  for (const message of messages) {
    console.log(message);
    if (!ids.includes(message.content)) webhook.deleteMessage(message.id);
  }

rustic nova
#

message is undefined, thus causing id to not work

#

what does the console.log print

carmine summit
earnest phoenix
# carmine summit

You're iterating over a collection, which gives you both the keys and the values

#

You seem to only need the values so iterate over the values with messages.values()

boreal iron
#

Or for(const [id, message] of messages)

#

Will also do the job

carmine summit
#

is there a way to know if my webhook created the message?

boreal iron
#

Not faster, not slower but it will work, too

carmine summit
sharp geyser
boreal iron
#

If a message is a webhook djs should attach webhook as property

#

At least with the id as property

carmine summit
boreal iron
#

Huh what?

#

Can’t follow you anymore

carmine summit
#

I wanted to check if my webhook created that message so I can delete it if so

lament rock
eternal osprey
#

Hey guys

#

is it possible to actually make a message.reply ephemeral as well

quartz kindle
#

ephemeral can only be used with interactions

#

not with normal messages

quartz kindle
#

my bot is still responding to text commands lol

#

in some shards

crystal furnace
#

If my bot auto reset like 5mins / time with this method

#

is it oke? is it touch the Discord Develop TOS?

rustic nova
#

why do you want to reset your bot?

pale vessel
#

You rlly shouldn't do that, especially at a large scale

solemn latch
#

it might not even be possible to do reasonably once sharded.

crystal furnace
#

@rustic nova@pale vessel I think I will use uptimerobot to wake up my bot if it offline

earnest phoenix
#

Just use a VPS, God damn

crystal furnace
earnest phoenix
#

I mean go ahead if you want but if you use a VPS you don't need to bother with things like UptimeRobot and stuff like that just to keep your bot running

ornate terrace
#

why wouldn't you use a vps, you can get some good ones for free

#

like oracle cloud free tier

rustic nova
#

good ones

ornate terrace
#

i use em to host 2 mc servers and 2 bots and sofar i've had no issues

earnest phoenix
#

Good VPSes aren't even expensive nowadays

#

You can get a pretty decent VPS up and running for a few bucks

lyric mountain
#

because how the heck did u manage with only 1gb ram?

ornate terrace
#

modded

ornate terrace
lyric mountain
#

...what free tier is that tf?

earnest phoenix
ornate terrace
#

i was gonna buy one but that seemed better than most and it was for free

dry imp
pale vessel
#

If you don't have a card skill issue

ornate terrace
#

btw, how long does an average bot take to get approved

dry imp
#

oracle support is just... god bless oracle

ornate terrace
#

their support sucks so much

#

i opened multiple support tickets for issues i had

#

all i got was "open a ticket with our technical team"

lyric mountain
#

I'm all in for java but...it doesn't deserve oracle

ornate terrace
#

lmao

#

thats why i plan on getting a paid one next month as im moving

rose lance
rustic nova
#

needs foreign keys to join

#

or what are the tables

sick agate
green kestrel
#

added two new commands to my bot for the next update

#

mods been needing them for a while

#

basically a way for staff to see if someone has premium, and what state its in, and one for them to move someones premium to another server for them

#

ive been having to move them by hand with sql commands, its a pain in the ass especially if im not at my pc

uneven heath
#

I am currently trying to parse a big JSON data using TypeScript

#

What's the best way to do it tbf, it's from Patreon and it's really messy

#

In all honestly, it sucks

#

Yes

#

It takes like

#

Forever if you want to validate their data

quartz kindle
#

theres nothing better than json.parse

uneven heath
#

Using TypeScript

quartz kindle
#

you can however isolate specific data instead of parsing everything

uneven heath
#

yeah, that's what I am going to do

quartz kindle
#

using string manipulation

uneven heath
#

Doesn't make it better

quartz kindle
#

it will make it faster

uneven heath
#

Yes, you have a point

#

Again, doesn't make it better 😂

quartz kindle
#

what kind of "better" are you looking for?

uneven heath
#

Less hell of implementing interface and type validation

#

I think even patreon-ts gave up because of now non-sensible their stuff is

quartz kindle
#

you dont really need to type the entire response do you? you can just type whatever you actually need

uneven heath
#

The structure is just messy overall

quartz kindle
#

i would just do something like const data = JSON.parse(body) as MyPartialDataType

#

and just implement the useful parts in the interface

uneven heath
#

Yes

#

It's funny

#

Because for whatever reason

#

They don't really try to group data and included as one

#

After all if you really need to get specific type you can just filter by type and the entire structure of the data are basically just attributes, id and type as necessary requirement

lyric mountain
#

the next step is finding out which of the 124706124 copies of the same data is the correct one

uneven heath
#

SHove it to a database and deal with it

#

kahfjksdkdf

#

It's also that

#

WHY DO THEY FEEL THE NEED TO HAVE data of every freaking key value

#

It doesn't make sense, it makes it really hard to parse in a clean way

uneven heath
#

I mean, I can still do type validation

#

IRONICALLY

#

But it DOESN'T MAKE IT ANY BETTER

earnest lantern
#

I'm uploading a large file with python using requests but I think what I'm looking for isn't limited to python. Is it possible to resume a download after interrupting a program?

mint mulch
# earnest lantern I'm uploading a large file with python using requests but I think what I'm looki...

that's up to the HTTP server serving the request, whether it supports range requests or not https://developer.mozilla.org/en-US/docs/Web/HTTP/Range_requests

An HTTP range request asks the server to send only a portion of an HTTP message back to a client. Range requests are useful for clients like media players that support random access, data tools that know they need only part of a large file, and download managers that let the user pause and resume the download.

earnest lantern
#

thank you

lyric mountain
#

so, let's say I'm using opencv to draw stuff, is using GpuMat better than Mat if it's just 2d stuff?

eternal osprey
#

if i edit a sent embed and add a ${role} ping

#

would it actually ping the role or only display the role?

lyric mountain
#

neither embeds nor edits will ping the user

eternal osprey
#

so when editing the content and embed, it won't ping?

lyric mountain
#

yes

#

pings only happen when the message is sent

uneven heath
#

Wait

#

I need some clarification

lyric mountain
#

like this @uneven heath

#

you see the yellow stripe, but u didn't get the ping notif

uneven heath
#

Good example

#

+10/10

#

Anyway

#

Is it possible for one user to have multiple tiers in Patreon?

#

I saw the API return entitied tier as an arrary

lyric mountain
#

I think only the highest counts

uneven heath
#

HUH

#

Then why does the API return the entitied tier as an array that doesn't make sense

lyric mountain
#

99% of the api payload doesn't make sense

#

iirc, patreon includes all available tiers into it for reference

uneven heath
#

Yeah, that's the thing

uneven heath
#

But the entry in relationships.currently_entitled_tiers are declared as an array

#

Which btw

#

Only show the highest entry

#

I don't understand why it is presented as an array

charred nest
#

How do I update my process.version for nodejs shyyDead Nvm says I’m already using v18.8, node -v shows 18.8, but I’m console logging my process version and it says 16.6 MikiSadThumbsUp

#

I’ve never had this issue updating before so I’m lost af

lyric mountain
#

your process is getting the node from the wrong path

ashen saffron
#

Hey all for what ever reason my bot's music modules would spam trackStart when someone loops the queue, however it would also spam the chat with "Starting to play songname here". Is there any solution for me to prevent that? (discord.js v13-lts, erela.js@2.2.3)

lyric mountain
#

where code

ashen saffron
#

for the issue reference

earnest phoenix
charred nest
#

v18.8.0

ashen saffron
# lyric mountain where code

i believe the error happens at:

    .on("trackStart", (player, track) => {
    console.log("trackStart announced.")
    client.channels.cache.get(player.textChannel).send(`Started playing **${track.title}** (**${format(player.queue.current.duration).split(" | ")[0]}**).`);
    })```
earnest phoenix
# charred nest v18.8.0

I'm not talking about the version, the which command outputs where the binary of the provided command is

ashen saffron
lyric mountain
#

yes but, in your code

#

where is it inside?

ashen saffron
#

it's inside my lavalink/manager.js file

lyric mountain
ashen saffron
earnest phoenix
charred nest
#

Logging it when my bot tries to go up

#

So basically

tight mortar
#

Who use bdfd here

lyric mountain
#

you're creating one listener every time you add a song

ashen saffron
# lyric mountain do you create a manager for every song?

here is the loop code:

  if (!player) return msg.reply(':error: There wasn\'t any video to repeat.');
    if (player.queueRepeat) {
      player.setQueueRepeat(false);
      msg.reply(":success: Player no longer repeating.");
    } else {
      player.setQueueRepeat(true);
      msg.reply(":success: Player now repeating.");
    }
charred nest
#

I'm running into "Object.hasOwn is not a function", which is only available after 16.9, but I updated and still can't put it online

lyric mountain
earnest phoenix
charred nest
#

PM2

earnest phoenix
#

I think PM2 is using the older Node.js binary from the different path

charred nest
#

Ah rats

earnest phoenix
#

I would recommend uninstalling the older Node.js version

ashen saffron
# lyric mountain no, show where u create a player

it should be: @lyric mountain (update: added the player creation)

              const player = client.manager.create({
        guild: message.guild.id,
        voiceChannel: message.member.voice.channel.id,
        textChannel: message.channel.id,
      });
player.connect()
player.queue.add(res.tracks[0]);
message.channel.send(`Enqueued track **${res.tracks[0].title}** (**${format(player.queue.current.duration).split(" | ")[0]}**) at position ${position}.`);
      if (!player.playing && !player.paused && !player.queue.size) player.play();
charred nest
#

Will do, thank you so much

earnest phoenix
#

You can run nvm install --lts to install the latest LTS release

charred nest
lyric mountain
ashen saffron
lyric mountain
#

well, idk then, but that's the only reasonable explanation

wheat mesa
#

I'm seeing a distinct lack of await for things that look like they're async

ashen saffron
lyric mountain
#

I never used erela, but multiple listeners is the only thing that could explain the notification spam

earnest phoenix
ashen saffron
earnest phoenix
#

You can check if the player is set to loop so you can return from sending the track playing message repeatedly

lyric mountain
#

ah, just noticed it isn't a listener issue, but a 1-second song

#

then yes, that's a logic issue not code

#

u could check what's the last sent message by the bot, if it's the same as the one about to be sent, return

ashen saffron
lyric mountain
#

or check if song == nextSong

#

at last, managed to draw a rounded rectangle topggLikeThis

#

low-level drawing is awful

#

and I just noticed the corners have the wrong thickness

ashen saffron
#

I did try with if (player.queueRepeat) return; but that didn't work so idk

earnest phoenix
#

Basically

let prevSongId = null;

...

.on('trackStart', async (_, track) => {
  if (track.id === prevSongId) return;

  prevSongId = track.id;

  await channel.send(/* Track playing message */);
});
ashen saffron
earnest phoenix
#

Yeah

ashen saffron
earnest phoenix
#

Both code?

ashen saffron
earnest phoenix
ashen saffron
#
let prevSongId = null;
              const player = client.manager.create({
        guild: message.guild.id,
        voiceChannel: message.member.voice.channel.id,
        textChannel: message.channel.id,
      });
player.connect()
player.queue.add(res.tracks[0]);
      console.log(prevSongId)
      prevSongId = player.queue.id;
message.channel.send(`Enqueued track **${res.tracks[0].title}** (**${format(player.queue.current.duration).split(" | ")[0]}**) at position ${position}.`);
      if (!player.playing && !player.paused && !player.queue.size) player.play();
earnest phoenix
ashen saffron
# earnest phoenix And what do you have in the `trackStart` event listener?
    .on("trackStart", (player, track) => {
    console.log("trackStart announced.")
    let prevSongId = null;
    if (track.id === prevSongId) return;
    console.log(prevSongId)
client.channels.cache.get(player.textChannel).send(`Started playing **${track.title}** (**${format(player.queue.current.duration).split(" | ")[0]}**).`);
    })```
earnest phoenix
#

You aren't supposed to initialize the prevSongId variable in the event listener, you're supposed to use the one you initialized before creating the player.

ashen saffron
#

but it would be undefined then

earnest phoenix
#

It wouldn't be if it's defined in the same file

ashen saffron
#

manager.js and the play command isn't in the same file path

earnest phoenix
#

Although what I meant by giving the songs an ID is to assign them to the track, literally, but I suppose that's not needed as the ID is from the player

#

So you can do this:

let prevSongId = null;

...

.on('trackStart', async (player, track) => {
  if (player.queue.id === prevSongId) return;

  prevSongId = player.queue.id;

  await channel.send(/* Track playing message */);
});
ashen saffron
#

the only things you can do with the player.queue property

earnest phoenix
#

And that was the concern, you should assign them manually if it doesn't exist

ashen saffron
#

uh someone said that i should try to check for the previous song and if it were the same song then try not to send it again

#

but i don't know how erela.js does that

lyric mountain
#

not the previous, the next

#

erela has a queue, u can simply compare current against the next

earnest phoenix
#

Well they would technically have to compare the current one against the previous song to check if it's the same song to not send it, if they check for the next one they would have to use a variable to acknowledge it the next time

lyric mountain
#

ah true, I forgot the event happens after changing songs

#

tbh, u can compare the current against the last song

#

since the previous will be sent to the end of the queue

ashen saffron
#

and how to do that exactly

lyric mountain
#

curr.id == queue[queue.size - 1].id

#

if that's how u get the id

earnest phoenix
#

Yeah, I don't know what information the tracks contain in ErelaJS but @ashen saffron you can do something like this:

.on('trackStart', async (player, track) => {
  if (track.name === player.queue.at(-1).name) return;
});
lyric mountain
#

damn js and its negative indexes KEKW

ashen saffron
topaz bloom
#

Can anyone make me a logo?

lyric mountain
#

no

lyric mountain
earnest phoenix
lyric mountain
#

ik, it's just weird to pass negative values for array access

ashen saffron
#

yeah it's title

earnest phoenix
#

Or just track.title since you just have access to the current track there directly

ashen saffron
#

so uh

lyric mountain
#

use the identifier since it's guaranteed to be unique

ashen saffron
#

right?

lyric mountain
#

no

earnest phoenix
#

Also yeah better to use the identifier

earnest phoenix
ashen saffron
earnest phoenix
#

I guess ErelaJS removes the current song from the queue list so there wouldn't be any songs in there if only a single song was queued?

ashen saffron
#

track.identifier works

earnest phoenix
#

Try checking for the size of the queue first then

#
if (
  player.queue.size !== 0 &&
  track.identifier === player.queue.at(-1).identifier
)
  return;
earnest phoenix
ashen saffron
#

and the code is:

    .on("trackStart", (player, track) => {
    console.log("debug: trackStart announced.")
    console.log(`track identifier: ${track.identifier}`)
    console.log(`queue size: ${player.queue.size}`)
    if (player.queue.size !== 0 && track.identifier === player.queue.at(-1).identifier) return;
    client.channels.cache.get(player.textChannel).send(`Started playing **${track.title}** (**${format(player.queue.current.duration).split(" | ")[0]}**).`);
    })```
earnest phoenix
#

Weird, can you try logging both track and player.queue?

ashen saffron
digital swan
#

just started to randomly get this error

earnest phoenix
# ashen saffron hm

Oh nevermind, I know what the issue is, the current way will only work if there are multiple songs in the queue, to make this work for single songs you would have to check if the player is being looped

#

Does the player give you a property to see whether it's being looped?

ashen saffron
earnest phoenix
#

Unless the 0 0 2 in your logs are something else

ashen saffron
earnest phoenix
#

@ashen saffron alright looking through the documentation, I found a sold solution to this

let prevSongId = null;

...

.on('trackStart', async (player, track) => {
  if (track.identifier === prevSongId) return;

  prevSongId = track.identifier;

  await channel.send(/* Track playing message */);
});
#

The solution is the one I proposed at first, just with the identifier property

ashen saffron
ashen saffron
earnest phoenix
#

Just to the track start one

ashen saffron
#

oh okay

ashen saffron
earnest phoenix
ashen saffron
# earnest phoenix Show code
    .on("trackStart", (player, track) => {
    let prevSongId = null;
    console.log("debug: trackStart announced.")
    if (track.identifier === prevSongId) return;
    prevSongId = track.identifier;
    console.log(`prevSongId value: ${prevSongId}`)
    client.channels.cache.get(player.textChannel).send(`Started playing **${track.title}** (**${format(player.queue.current.duration).split(" | ")[0]}**).`);
    })```
earnest phoenix
lyric mountain
lyric mountain
#

lmao

lyric mountain
#

Anyone here experienced with opencv?

#

If so, how can I draw an image on top of another?

sharp geyser
lament rock
#

I feel like a fucking genius

#

infer is so goddamn powerful

#

The shit I do for accurate type narrowing

#

mapped union types are so painful if you don't want them inside an object

earnest phoenix
#

hi uhmm i wanted to ask if someone can send a code in python to make so when someone votes to send a messasge

lament rock
#

good luck getting people to write code for you here

earnest phoenix
#

no i dont want you to write them

lament rock
#

I think it would be better to refer to the docs for the top gg api library you're using and then check google if someone else has a solution

earnest phoenix
#

if you have already to sent me but if you dont have the code its okay

lament rock
#

what you need to know is how to listen for votes and how to send a message to a specific channel. If you know that, you know how to solve your own problem

lyric mountain
#

we don't "send code for X", but we can help if you have something already going

earnest phoenix
#

ok thanks

rustic nova
#

did github die?

#

nvm just takes ages

lyric mountain
#

it dies everyday

rustic nova
#

ye fuck its down

#

based github

sharp geyser
#

its fine for me

rustic nova
#

works again

#

the japanese users on twitter were mad too

civic scroll
sharp geyser
civic scroll
lyric mountain
#

rounded

wheat mesa
sharp geyser
#

Waffle

#

just in time

#

I have a question

#
              match parsed {
                    WebMessage::MessageCreate(message) => message_create(message),
                    WebMessage::MessageDelete(message) => message_delete(message),
                }

I am matching an enum, and I have one question about it so far

#

Do I really have to do WebMessage::MessageCreate()

#

Why can't I just do MessageCreate(message)

sharp geyser
wheat mesa
#

multiple threads

lyric mountain
#

waffle waffle, thou who delve deep into low level languages, have u ever used opencv?

wheat mesa
#

hold on ill help in a sec

sharp geyser
#

ok ty

wheat mesa
sharp geyser
#

Oh?

#

So it forces you to use the enum name to get the one you wanna match against?

wheat mesa
#

say you have ```rs
enum MyOption<T> {
Some(T)
None
}

#

that could cause issues with implicitly imported types like the default Option<T>

sharp geyser
#

Mmm thats fair

sharp geyser
#

It makes more sense now why I was getting that error earlier

#

I looked through stack overflow and got my answer even tho it wasn't to the question I was asking kek

#

My websocket stuff is one step closer to being completed.

#

Now I just have to fully implement everything now that I got a method to the madness

wheat mesa
#

enjoy fighting the borrow checker later

#

😉

sharp geyser
#

Also, I have a qualm against just outright closing the socket if they provide false data

#

Like say the event name is right, but they misspelled one of the data properties

#

or they accidentally leave one out

wheat mesa
#

sounds like a bad idea to allow websocket connections to send false data

sharp geyser
#

Mmmm true

#

But I need to at least provide a reason why

#

right now it just closes without a reason

#

but idk how to send the reason with the close

wheat mesa
#

that would be annoying for both ends, you'd have to handle it and then the lib dev would need to figure out why their thing is still working despite not sending correct data

sharp geyser
#

Fair point

#

but so far the reason for the close is literally nothing

#

so its even harder to tell why something happened

lyric mountain
wheat mesa
#

just let them suffer like C devs whenever they get a segfault with no other info

sharp geyser
#

but I dont see a way to provide a reason with axum's websocket implementation

sharp geyser
#

I was making big oopsie and was not properly typing my helper functions

#

I was trying to move it into there and use it other places

#

Now I need to implement a database connection

#

😔

lyric mountain
#

Worse than big errors are errors that don't make sense or no errors at all

sudden geyser
#

well java error messages do look awful

lyric mountain
#

At least they do point at the error

sudden geyser
#

except when they don't wah

bright thorn
#

interaction is working fine

#

but stil i got This interaction failed

#

why?

#

and what are the solutions

sudden geyser
#

Try debugging your program more (e.g. logs) since we can't tell anything with that

lament rock
#

interactions expire after 15min
Most commonly, buttons that are older than that will always fail on the user's end. The INTERACTION_CREATE is still sent, so you can ignore those errors.
Trying to respond to the interactions via rest will return a 404 Unknown Webhook

#

Not responding in time will also expire the interaction and cause it to fail

#

If you're using the gateway for interactions, most of the overhead comes from decoding gateway messages especially at scales with a large volume of inbound messages. Only really lightweight ws solutions can keep up and even then, It'd be advised to put your sockets on a separate thread (not all on separate threads unless you have a load balancing technique that round-robins between all or divides them roughly equally)

#

Another solution on the gateway end is to only use intents you really need. I've migrated to slash commands pretty much entirely and I do not miss all of the message creates I used to get

sharp geyser
#

@wheat mesa fighting the borrow checker damn you for already knowing

#

😔

wheat mesa
#

told you C:

sharp geyser
#

I am also sure what I am doing to solve it is not recommended at all

wheat mesa
#

what are you struggling with

sharp geyser
#

Well heres where it started

#
pub fn message_delete(message: MessageDelete, socket: &WebSocket) {
    // This here will handle everything related to deleting a message, e.g removing the message to the database and then responding back to the
    // client with the appropriate data

    socket.send(Message::Binary(serde_json::to_vec(&message).unwrap()));

    println!("Message ID: {}\n", message.message_id)
}

So I have this bit of code, and it is crying cause of the socket.send usage
Cannot borrow immutable local variable `socket` as mutable
so I made socket: &WebSocket -> socket: &mut WebSocket

#

and now

#
            Ok(parsed) => {
                match parsed {
                    WebMessage::MessageCreate(message) => message_create(message, &socket),
                    WebMessage::MessageDelete(message) => message_delete(message, &socket),
                }
            },

this is crying cause message_delete(message, &socket) is not &mut WebSocket

#

so I did message_delete(message, &mut socket)

#

Is this the proper way to handle this?

wheat mesa
#

Yes

sharp geyser
#

Okay next question

#

What does it mean by Cannot borrow immutable local variable `socket` as mutable

#

How is it considered mutable?

wheat mesa
#

Which line was that occurring on?

#

The socket.send line?

sharp geyser
#

yea

wheat mesa
#

socket.send is likely a function that requires a mutable borrow of the socket, aka the internal impl probably looks something like fn send(&mut self, otherstuff)

sharp geyser
#

Ah

wheat mesa
#

So to use a mutable function on the socket you need a mutable borrow of it

sharp geyser
#

you're right it does

#

this is a lot more fun than I thought it'd be

#

I thought I would be pulling my hair out doing this in rust

wheat mesa
#

me out here manually debugging my bytecode

sharp geyser
#

👀

#

yea

wheat mesa
#

like 90% sure that's wrong

sharp geyser
#

you have fun with that bud

#

Ima stick with my less complicated stuff

wheat mesa
#

YOOOOOOOO IT WORKS

#

successfully decoded from that file

sharp geyser
#

yes I know what this all means

wheat mesa
#

basically I have bytes that signify things in the beginning and now it's successfully using that information to decode the rest of the file

sharp geyser
#

yea

#

ok

wheat mesa
#

strings work too

sharp geyser
#

cool

earnest phoenix
#

Hello, when I type member.guild.id in the guildMemberAdd event, I cannot get the server's id, how should I do this?

sharp geyser
#

Do you get any errors?

earnest phoenix
sharp geyser
#

member.guild is undefined

#

show code

earnest phoenix
# sharp geyser member.guild is undefined
const data = require("../models/Guild")
module.exports = {
    name: 'guildMemberAdd',
    async run(member) {
        const config = await data.findOne({GuildID: member.guild.id})
        if(config.Autorole.active === false) return;
        if(member.user.bot) return
        if(config.Autorole.active === true) {
            let role = config.Autorole.role
            member.roles.add(role)
        }
    }
}
sharp geyser
#

How are you loading these events

earnest phoenix
# sharp geyser How are you loading these events

module.exports = (client) => {
  const events = fs.readdirSync("./events/").filter(f => f.split(".").pop() === "js");
    events.forEach(f => {
    var event = require(`../events/${f}`);
    var client = global.client
    client.on(event.name, (...args) => event.run(client, ...args));
    console.log(`${f}`)
  });
};

this is my eventLoader file

sharp geyser
#

there's your issue

earnest phoenix
sharp geyser
#

your run function in the guildMemberAdd event is expecting the first param to be client

earnest phoenix
#

How can I fix?

sharp geyser
#

I don't even know if your event loader works, but you can try async run(client, member)

#

in your event

earnest phoenix
#

I did ty

sharp geyser
#

@wheat mesa getting linker errors in cargo install mmLol

graceful trench
sharp geyser
#

What

#

that literally doesn't matter

graceful trench
#

No client

sharp geyser
#

The thing is that what he thinks is member is actually client

#

so 👀

graceful trench
#

You mean

#

client.member

#

Oh

#

Let me check it

#

@sharp geyser another thing...

graceful trench
#

Like

#

There's no args

sharp geyser
#

Huh

#

ofc there is...?

#

whatever you get from the event e.g guildMemberAdd returns a member object of the user who joined

#

so ...args if that's even the correct way to do it would be a member object

graceful trench
#

Oh

#

I usually use (eventName, event.bind(null, client)

sharp geyser
#

thats the typical way

graceful trench
#

I know

#

So it catch what your using or it changes to client or null

#

I think that he need to try that

#

Idk

#

Well, byee

uneven heath
#

So I have a many-to-many relationship table store in my database (Patreon and Tiers)

#

Currently I am setting up in a way where an User can have many Tier and a Tier can have many User

The question now is that when the user update their tier option, how would I deal with purging the junction table

#

^ Yes, it's a many to many because gods know why Patreon decided like that

sharp geyser
#

I mean its not bad for it to be a many to many

uneven heath
#

Yeah, but I am thinking on how I would deal with the junction table

#

Let just say I can obtain a list of user tiers through their payload

sharp geyser
#

You can cascade delete and add the user to a new tier when they wanna join another

uneven heath
#

So completely delete all of previous entry and add the new one?

sharp geyser
#

Essentially yea

#

It should delete them from the tier table and then in turn delete the tier from the user

#

so you can just add a new one

uneven heath
#

Oh yeah, that's a way.
I essentially wired up to some hooky shit lol

uneven heath
#

lol

sharp geyser
#

or that

uneven heath
#

Since my database saves both former_patron and active_patron anyway

uneven heath
#

I assume it should not

sharp geyser
#

🤔

#

idk never had to do that before

uneven heath
#

Well, let's hope there is no edge case...

#

That would be scary

#

I gonna just do this then

#

Add all entry from Patreon API

#

After then check if there is any entries that doesn't exist in the Patreon API (If the user change tier, the new tier in the database doesn't reflect that in the payload)

#

It is confusing but I think this is the correct way to do it?

inland vapor
#

;;play no love shubh

#

Yr bot kasy add krty ha

#

Boat

earnest phoenix
sharp geyser
#

What would be the best datatype to use in my postgres table for storing a user id, in my rust structs all my ids are u64's but idk what datatype would be suitable for postgres

#

should I just use NUMERIC ?

earnest phoenix
#

If PostgreSQL supports storing long integers such as user IDs then yes, if not then strings would be more suitable

#

As you can just convert the strings to the numbers whenever needed I guess

sharp geyser
#

From what I was reading they don't support long integers like that

#

so saving em as strings are probably the best bet

#

they also state that using NUMERIC is rather slow