#development

1 messages · Page 1953 of 1

quartz kindle
#

create a new project

#

and use a nix template

#

instead of nodejs template

earnest phoenix
#

ohk?

quartz kindle
#

yes

earnest phoenix
#

ohk then?

quartz kindle
#

once its created, you will have a replit.nix file

earnest phoenix
#

yes

quartz kindle
#

change that file to this

{ pkgs }: {
    deps = [
    pkgs.nodejs-16_x
    ];

}
earnest phoenix
#

ok

#

done

#

now?

quartz kindle
#

and your .replit file must have this

#

run = "node index.js"

#

then you can copy your other files from your other project

earnest phoenix
#

ok

#

will it work then?

quartz kindle
#

yes

earnest phoenix
#

ok lemme check

earnest phoenix
#

thats an issue with your code

#

hmm

#

actually it isnt

#

you havent enabled the proper intents on your bot dev page

earnest phoenix
#

how to enable it

quartz kindle
#

show your index.js

earnest phoenix
#

ok

quartz kindle
#

what intents are you using?

earnest phoenix
quartz kindle
#

you are using GUILD_MEMBERS

earnest phoenix
#

hmm

quartz kindle
#

to use that, you need to enable it in your discord bot's page

#

in the discord developers website

earnest phoenix
#

ok

#

done

#

i enabled it

quartz kindle
#

now try again

earnest phoenix
#

yay

#

working

#

thanks @quartz kindle @earnest phoenix

quartz kindle
#

👍

earnest phoenix
#

heh

earnest phoenix
quartz kindle
#

no sorry

earnest phoenix
#

tim accept mine

earnest phoenix
spark flint
#

@solemn latch you're smart, should i go for block or object storage

#

i store image data in a database

#

as long as i can assign the image to an ID in the database i'm happy

#

and as long as its fast

solemn latch
#

Object is probably better for what you are doing.

spark flint
#

alrighty

solemn latch
#

Is it set to private?

spark flint
#

no

solemn latch
#

op i blured where it says private, meant to rectangle kek

spark flint
#

cleared cache ™️ and it worked

solemn latch
#

ah

#

always cache 👀

spark flint
#

@solemn latch is it possible to cname

#

with Backblaze

solemn latch
#

not sure tbh, never tried.

quartz kindle
#

it was explained quite well in the conversation that followed that message

#

what didnt you understand?

slender wagon
#

can you run the same bot from 2 servers with different functions

#

yes

#

huh

#

no no

#

not guilds

#

servers

#

like actual servers

#

aka host services

quartz kindle
#

yes you can

#

but you'll have all guilds in both

slender wagon
#

yes

#

ik

#

what i am trying to do is to handle some functions directly from the site and some others from another server

cinder patio
slender wagon
#

the bot will only be used on 1 server

#

so it will be ok

novel jetty
#

Is there something wrong with this bit of code? The bot chats with you in the DMs when you DM it

const fetch = require('node-fetch')
let b = await db.fetch(`chatbot_${message.guild?.id}`);
if(b !== undefined){
let channelName = message.guild?.channels.cache.get(b);
let mChannel = message.channel as any
if (mChannel?.name == channelName?.name) {
if (message.author.bot) return;
  message.channel?.sendTyping();
if (!message.content) return message.channel.send("Please say something.").catch((err) => console.log(err));
fetch(`https://api.affiliateplus.xyz/api/chatbot?message=${encodeURIComponent(message.content)}&botname=${client.user?.username}&ownername=Angel`)
    .then((res: any) => res.json())
    .then((data: any) => {
        message.reply({ content: `${data.message}`, allowedMentions: { repliedUser: false }}).catch((err) => console.log(err));
    });
      message.channel?.sendTyping();
}
}
sudden geyser
#

and what's happening

#

You implied something was wrong with it, so that's wrong with it?

slender wagon
#

ayo guys how can i run 2 nodejs projects at the same time

sudden geyser
#

depends on your work flow

#

If you're using VSCode, many people like to have separate windows for each project

#

Or use some built-in functionality to run projects at the same time

solemn latch
#

pm2 😄

#

or any other process manager

sudden geyser
#

If you're using Sublime Text it's a bit more difficult given the only good option is to run an external process

#

e.g. from a terminal

sudden geyser
#

For you guys building REST APIs, how do you like to handle error messages? I've been structuring them based on the incoming request, so, for example, a request to create a user with a blank string may return this:

// 400 Bad Request

{
  "body": {
    "name": ["must not be blank"]
  }
}

It's an array of reasons, but it's not very machine consumable. I've considered representing errors as bits, but don't know if it's a good idea given there could be a lot of reasons.

earnest phoenix
#

Mmm I might do it a bit weirdly but I just

{
  success: false,
  message: 'Name must not be blank'
}
sudden geyser
#

Hmm

#

I don't think success fields are that useful given the response code often indicates that (200 <= x <= 299)

earnest phoenix
#

Mmm, at that time i was using success as a way to tell if the request failed easier.

#

if(success){do something}

#

or smth

sudden geyser
#

Yeah, it is a bit easier, especially with chaining like with node-fetch

earnest phoenix
#

yea

sudden geyser
#

but status codes can usually tell more than a boolean

earnest phoenix
#

yea, I was just getting into making rest apis so I didn't really know the best way to handle error messages

#

I still use success fields sometimes though.

sudden geyser
#

I sometimes see it in the wild

#

like Hypixel's API

#

which ironically sometimes says true but still doesn't have a useful body

earnest phoenix
sudden geyser
#

but their api is a mess in general

#

there are like 13 ways to determine a user's rank (you have to use all of them to get accurate)

#

and it's just a mongodb document dump

earnest phoenix
#

lmao

#

What do you use to make rest apis?

#

like lang wise

sudden geyser
#

Currently Clojure

#

Which is like Java

earnest phoenix
#

icic

#

I have been using go

#

cause I didn't feel like learning elixir mmLol

sudden geyser
#

I've considered learning go in the past

#

but never felt like it lul

earnest phoenix
#

go isn't bad

#

I still dont fully understand it but its actually rather easy to understand some concepts

sudden geyser
#

I'm sure it's not "bad"

#

but I just haven't felt like putting in the effort to learn it

quartz kindle
sudden geyser
#

there is a friend of mine who always likes to talk about it

#

but my last experience with a lang in its domain is rust

#

and I didn't really like that

#

didn't have a use for it even though you can use it at a high level

earnest phoenix
#

I dont really like rust that much either

sudden geyser
#

If I had to use a low-level language though I'd consider C over Rust

earnest phoenix
#

people say go is the modern C

sudden geyser
#

V walks in

earnest phoenix
#

kekw

woeful pike
#

why would you create a new project in C in 2022 honestly

quartz kindle
sudden geyser
#

It looks simple

#

not much to it

earnest phoenix
sudden geyser
#

but I don't doubt it wouldn't be painful

earnest phoenix
#

its what people say

quartz kindle
#

pople do be dum

quartz kindle
woeful pike
#

coding in C is like trying to grow crops on a minefield ngl

earnest phoenix
#

I couldn't learn C it seems too annoying

woeful pike
#

I mean if youre not making something embedded

sudden geyser
#

living dangerously is what the cool kids do

woeful pike
#

have you heard of shellshock, stagefreight and friends

sudden geyser
#

which shellshock

woeful pike
#

yeriyikes super critical vulnerabilities introduced by some of the most experienced C developers in codebases audited by industry veterans

sudden geyser
#

Yeah I know C is much more vulnerable than a language like Rust

#

But it's something I'd consider learning regardless

woeful pike
#

oh sure nothing wrong with that

#

I was just commenting on the C over rust thing

sudden geyser
#

If I were building a long-term project sure I'd pick Rust

woeful pike
#

if you think you're more experienced than the entirety of the Android security team combined go ahead and make that new C project

quartz kindle
#

C is the most vulnerable lang because its also the most present lang everywhere

woeful pike
#

nah I don't agree with that, C just gives you way too much freedom

#

you can do absolutely anything you want including things you definitely do not want to do

quartz kindle
#

well, yeah, but its also been around for decades, and a large amount of vulnerabilities are due to old outdated code and outdated libraries

woeful pike
#

that's definitely a factor too

#

but we also keep finding critical vulnerabilities in C codebases not related to dependencies that've been audited by countless experts so it's not just a matter of numbers

modest maple
quartz kindle
#

i use js and i dont believe in dependencies

modest maple
#

yeah but thats because deep down your a C nerd

quartz kindle
#

i suck at C tho

#

i just know the basics

#

but in js yeah, most my libs are 0-dep

#

lmao

modest maple
#

how do you suck at c and just know the basic

#

C is like 12 instructions

quartz kindle
#

lmao

#

i guess that means that i know C but am very slow at coding it

#

because i constantly need to check docs and SO

modest maple
#

thats everyone dw

quartz kindle
#

and i get confused af when to use * and &

azure lark
#

how could i get a messages content and then replace every space with a -

sudden geyser
#

.content and .replace(...), but depends on your language

spark flint
#

what language

#

python = .replace(" ", "-")

azure lark
#

node

sudden geyser
#

If you want to get rid of all kinds of whitespace, sure.

azure lark
#

ok

quartz kindle
#

dont forget to also replace yellowspace and redspace

sudden geyser
#

what about purplespace

azure lark
#

how?

sudden geyser
#

it just really doesn't like spaces

azure lark
#

how could i use this:
octokit.request(`GET /repos/username/test-repo`, {})
to do actions if the repo was found and do other actions if it dose not exist

quartz kindle
#

what happens if it does not exist?

azure lark
#

404 error

quartz kindle
#

then you can catch it

azure lark
#

but how do i know if something has been found

quartz kindle
#

it will not error?

azure lark
#

so all i have to do is...
```octokit.request(GET /repos/username/test-repo, {}).catch(error => console.log("Not Found"))
console.log("Found")

quartz kindle
#

not exactly, but close

#

if you use .catch(), that will not stop the next lines from running, meaning if it was not found, both not found and found would be logged

#

so if you want to use the .then().catch() way, you need to do it like this:

octokit.request(...).then(result => {
  // code if found
}).catch(error => {
  // code if not found
});
// no code here
#

or if you want to do it the async/await way, its easier:

#
const result = await octokit.request(...).catch(() => null); // give null if error
if(result) {
  // code if found
} else {
  // code if not found
}
// code after found or not found
azure lark
#

ohhh okay

#

thanks!

quartz kindle
#

there is also another way

#

async/await with try/catch

#
try {
  const result = await octokit.request(...)
  // code if found
} catch(error) {
  // code if not found
}
// code after found or not found
hollow prawn
#

uh i hope this channel fits for this, but how tf do i increase the size of the terminal scrollbar in vs code its so SMALL i can't click on it bcs it thinks i'm trying resize vscode...

earnest phoenix
#

you could use your mouse to scrol

hollow prawn
#

its instant not as smooth as moving the scrollbar and it confused me makes it harder to focus

#

or if I can detach the terminal on a separate window like unity has with its game window/scene window and such

#

it'd be great

dapper jasper
#

help I am using discord.js v13.5 and i get error "Error [BAN_RESOLVE_ID]: Couldn't resolve the user id to unban." when i do interaction.guild.members.unban(<id>)

earnest phoenix
#

I hope you aren't actually doing .unban(<id>)

#

cause <id> is a placeholder for an id

dapper jasper
earnest phoenix
#

Make sure it is a valid user id

eternal osprey
#

hey, how would i create a function where 2 discord users can keep on writing numbers until someone writes pass?

supple oriole
#

wym pass?

supple oriole
eternal osprey
#

it would eventually all stack up basically.

#

So !bet (50) will add 50 to the pot, and in which the other user HAS to use !bet. However, he can also use !pass which would stop the function

supple oriole
#

You could do !bet @eternal osprey 100$ <- example

eternal osprey
#

I just don't quite know how to implement it

supple oriole
#

And then use a collector to find the command pass when being used.

#

And stop the cmd.

#

Idk much abt collectors.

#

May be wrong with that

#

But that's my idea.

supple oriole
eternal osprey
solemn latch
#

I always use a class for games that progress endlessly, call its own function until it ends

eternal osprey
#

it will be a long betting phase until someone passes

eternal osprey
supple oriole
#

So u don't know how to use class, is basically what your saying.

eternal osprey
#

basically yes

supple oriole
#

I rarely make games or economy for my bots.

eternal osprey
#

Instead of classes (which actually scares me just by looking at it), i would actually want to use functions if that's possible

#

It would do this:

wheat mesa
#

Classes are just functions and properties wrapped into an object

#

Will make your life a lot easier

eternal osprey
#
@user1 Please bet:
// user 1 bets
@user2 Please bet:
//user 2 bets
@user1 Please bet:
// user uses !pass
Function stops```
solemn latch
#

shit its py

eternal osprey
#

js

solemn latch
#

oh

#
class GameClass {
  constructor(user1, user2) {
    this.user1 = user1;
    this.user2 = user2;
    this.currentPlayer = 0;
    this.startup();
  }
  startup(){
    //start everything, create a collector for !pass that lasts until the end of the game
  }
  nextPlayer(){
    // create a collector for listening for !bet on the next player
  }
  endGame(){
    // end game
  }

eternal osprey
#

yeah my : is confusing lmao

wheat mesa
#

Basic classes aren’t too hard to implement

#

You’ll get used to it

#

They look scary at first but I promise you they’re not that bad, and it’ll save you writing a lot of code in most circumstances

eternal osprey
#

Alrighty, will have a look at classes then!

solemn latch
#

it really is just a set of functions, with all the data for the players contained inside itself

wheat mesa
#

Whenever you do module.exports = { blah blah } it’s similar to a class as well

eternal osprey
#

aha! Yeah it seems less scarier than i thought. Thanks Nala and Waffle!

wheat mesa
dapper jasper
earnest phoenix
#

that says its not

#

so

#

Actually

#

Are you sure the user is even banned

#

That could probably be another source to the error

eternal osprey
earnest phoenix
#

that is the only other way I can see it giving you that error unless the user id is invalid

dapper jasper
wheat mesa
#

Well that explains it

#

User objects can’t be banned

#

Member objects can be banned

#

If I’m understanding that correctly

#

Why would you even need .user anyways

spark flint
#

You need member object to unban

pale vessel
#

Or the GuildMemberManager

#

interaction.guild.members.unban(<id>)

solemn latch
#

if the member is uncached, you need the guildmembermanager then iirc

wheat mesa
#

interaction.guild.bans.create() seems like it would work as well

#

And interaction.guild.bans.remove()

#

I’m not entirely sure if that works but from looking at the docs it should

dapper jasper
solemn latch
wheat mesa
#

Seems like you need a user object as well. Probably easier to go with one of the other methods suggested by others

#

Never mind you don’t need the object

#

Something like that

dapper jasper
wheat mesa
#

What is your exact code

#

Show the line that you try to unban on

dapper jasper
# wheat mesa What is your exact code

well now it's: interaction.guild.bans.remove(interaction.options.getString('target').id,interaction.user.tag+': '+interaction.options.getString('reason'))

#

oh

#

i see

#

.id

eternal osprey
#

I have tried this, but it most definitely is wrong.

dapper jasper
eternal osprey
#

I am wandering through the docs, but this is a bit too hard for me tbh

#
class GameClass {
  constructor(user1, user2) {
    this.user1 = user1;
    this.user2 = user2;
    this.currentPlayer = 0;
    this.startup();
    this.message = message.content;
  }
  startup(){
   if(message.content.startsWith('!stack') && message.author == this.currentPlayer){
    const test1 = message.content.split("\n")
    .map((x) => x.split(/ +/));
    gamedatabase[rarko.id].betamount = Number(test1[0][1])
    console.log('Next player')
   }
  }
  nextPlayer(){
    // create a collector for listening for !bet on the next player
  }
  endGame(){
    // end game
  }
      }
    

      }```
earnest phoenix
wheat mesa
#

Your class doesn’t know what message is

#

You have to either pass that in as a parameter or pass that in the constructor as a property

wheat mesa
earnest phoenix
#

So it's not different from using .ban

wheat mesa
#

Not that I’m aware of

eternal osprey
#

I just still don't get how this will tell the bot to switch from users

wheat mesa
#

It’s up to you how to design it, so you can remove that function if you really want (though I don’t recommend it, since it’s less organized)

#

It might help to take a look at an OOP guide for js

eternal osprey
#

Wow didn't know that

eternal osprey
wheat mesa
#

I get that

#

Basically what you’re trying to do is create an infinite loop until someone passes

#

Right?

eternal osprey
#

yeah!

wheat mesa
#

You can do that a few ways

#

The first way is to have a while(true) loop and break on certain conditions that you specify

#

I’d recommend a message collector though since you probably want it to expire after a certain amount of time

eternal osprey
#

Not really. Just till someone passes.

wheat mesa
#

Oh

eternal osprey
#

They could be betting for hours (if their balance isn't lower than the actual bet amount)

earnest phoenix
#

Won't a while loop effect performance in the long run (asking cause performance is something I'm always confused about how to calculate)

wheat mesa
#

Probably not but it’s definitely not the cleanest solution for this

earnest phoenix
#

Icic

wheat mesa
#

I think a message collector is going to be your best friend here

#

My brain is kinda foggy atm so I can’t really think of a seamless solution, but using a message collector is probably the right way to go with this

eternal osprey
#

hmmm okay.

#

Yeah no problem waffle! You've helped me a lot!

wheat mesa
#

Anytime 👍

#

Gl with your game!

eternal osprey
#

Thank you 🙂

earnest phoenix
#

@quartz kindle

#

on use of a slash command with an optional argument, if nothing is specified for that specific option, does it return null?

quartz kindle
#

no idea

wheat mesa
#

I think (?) you can specify a default value for a slash command optional argument

#

Unless that’s just a detritus thing

quartz kindle
#

there is nothing about default value in the discord docs

#

and it says value is nullable

#

so the option should either have no value, or have null value

wheat mesa
#

you see this is why I use detritus

boreal iron
#

nvm

wheat mesa
#

the small things add up

boreal iron
#

That English didn’t make sense at all

sudden geyser
#

we speak dragons here

boreal iron
#

Well if Discord even sends the empty option with the event then it’s null or probably undefined - doesn’t actually matter

#

Or non existing at all - shouldn’t be hard to find out registering a guild command real quick

quartz kindle
#

adding extra stuff that the api doesnt have because people are lazy to do it themselves

boreal iron
sudden geyser
#

sounds like discord structures

#

"oh no dot doesn't work in my ide anymore! I can't stand using functions!"

wheat mesa
#

just looked apparently there's no default option

#

I remember something about default values to something though

boreal iron
#

No

#

There aren’t any

sudden geyser
#

I think I remember something about it in the past

quartz kindle
#

autocomplete is sexy tho

boreal iron
#

Only for option types like Boolean

sudden geyser
#

but computing the default value on your own is better anyway

#

more freedum

wheat mesa
#

ah this is what I was thinking of (message commands) ```ts
export default class BanCommand extends BaseCommand {
constructor(client: CommandClient) {
super(client, {
name: COMMAND_NAME,
permissionsClient: [Permissions.EMBED_LINKS, Permissions.BAN_MEMBERS],
permissions: [Permissions.BAN_MEMBERS],
disableDm: true,
args: [{ name: 'clean', default: 1, type: Number }],
metadata: {
description: 'Bans a specified user',
examples: [${COMMAND_NAME} @Waffle#9125],
type: 'moderation',
usage: '[Member: Mention, ID] <reason> (-clean: Number)',
},
type: Parameters.banPayload(),
label: 'context',
});
}
}

boreal iron
wheat mesa
#

I need to get into rust gui tooling with that new library because that looks sick

sudden geyser
#

which one

wheat mesa
sudden geyser
#

there's like a new gui framework every week on r/rust

wheat mesa
#

this one looks promising

boreal iron
#

You better learn PHP, best GUI builder on the market

wheat mesa
#

no >:C

boreal iron
#

Because no GUI language and support and always the best one

#

No shit to deal with

wheat mesa
#

nah java is the best gui language, base swing looks really modern

#

extremely modern

wheat mesa
#

No!

sudden geyser
#

just slap reactive and immutable on your library and stars will really start paying your rent

wheat mesa
#

I swear I only use it when I'm forced

#

though I like the pure OOP feel

sudden geyser
#

masochist

boreal iron
#

I can not trust you anymore

wheat mesa
#

I just like OOP

boreal iron
#

That sounded like you like Java and tried to recommend it

wheat mesa
#

no

#

I was making a joke about swing KEKW

#

intellij is written entirely in swing

#

the pain those devs must've felt

sudden geyser
#

so that's why it looks awful

wheat mesa
#

I think it looks pretty good

#

every setting just feels hidden from me though

sudden geyser
#

so many settings

#

spent hours trying to configure stuff

#

then realized I forgot how to revert some changes

#

I think IntelliJ has too much to be productive but that's just me

#

and a good ui is a good experience

#

I like sublime right now since it's minimal

wheat mesa
#

I like their ides for C++, Rust, Java, and that's about it

#

Visual Studio Community is a much better experience for C#, and Visual Studio Code is a much better experience for web dev/js/ts

#

I wouldn't lay a finger on python but if I did then I'd probably use PyCharm

boreal iron
#

Oh no that discussion again freerealestate

wheat mesa
#

But I'm not sure since I haven't used it

boreal iron
#

Notepad++ still for all hardcore coders

quartz kindle
round cove
#

I noticed for my 1server test bot that slash commands work fast. However, on my larger bot (1500 servers) when trying to handle interactions, discord.js claims that the interaction is unknown most of the time if I try running commands within a few seconds of each other. I did not have this issue with my test bot. Any reason?

If the first command sent fails, sending it again it works.

quartz kindle
#

but as you know it, im still procrastinating on my api :^)

round cove
#

I reply, deferring doesn't affect it because when deferring and still trying to post it claims the interaction just doesn't exist.

#

Maybe I should just try to defer everything but still.

boreal iron
#

It’s actually made for your use cases

sudden geyser
#

speaking of intents

#

are you supposed to pong after each interaction

#

I've just been responding

quartz kindle
# round cove Maybe I should just _try_ to defer everything but still.

well, you have 3 seconds to either reply or defer, so if your replies are slow, deferring everything will fix it, BUT, if your events are being slow or delayed for some reason, then you are also receiving interactions late, so your 3 second window can actually be less than 2 seconds, or even negative

quartz kindle
round cove
#

I see.

sudden geyser
#

ah

round cove
#

So instantly defer the interaction and force wait 3 seconds?

#

Xd

sudden geyser
#

I'd suggest letting it fail

round cove
#

It's jsut odd for it to fail every other time it does it.

#

Like it doesn't make fun exp

boreal iron
#

You also sometimes receive the event and respond immediately but it’s already expired

quartz kindle
#

follow up responses after deferring have 15 minute time window instead of 3 seconds

boreal iron
#

Not only a related issue to the latency at least what I could figure out yet

quartz kindle
#

yes, thats what i meant when i said the 3 second window can even be negative lul

#

discord dicksword measures 3 seconds from the time they send it, but until you receive it, all sorts of delays can happen

boreal iron
#

Yeah

#

Assuming more registered slash commands and API requests will exist in the future, that issue might happen more often, than rarely as it is right now

solemn latch
#

the sad part?
in my time reviewing its not uncommon for bots to have 3+ seconds response time

#

if they want to use slash commands they actually cannot.

round cove
#

I want to note that I instantly get a broken "unknown" interaction within miliseconds.

sudden geyser
#

@wheat mesa I just looked into Dioxus. It looks interesting given it's React inspired, but a bit scary since it's heavily macro-driven and makes use of categories that aren't relevant to Rust, like immutability. Is there a thing Dioxus is really good at that stands out?

boreal iron
wheat mesa
boreal iron
#

Does anyone know if there are more option types planned for slash commands like picking dates etc.?

#

I don’t actually follow the development

sudden geyser
#

There are attachments

#

But nothing else for types

boreal iron
#

Hmm I can imagine picking a time/date would be useful

sudden geyser
#

Yeah it would

boreal iron
#

A string option and converting it to a timestamp might fail due user stupidity providing any valid date format

round cove
#

It's actually saying it's 7seconds before lol

#

God.

boreal iron
#

Welcome to the Discord API experience

round cove
#

But it works fine for my test bot, of course it would.

#

How is my fucking 1500 bot getting such late events. Doesn't make sense?

boreal iron
#

Hmm too many events it can process in time?

round cove
#

One event?

quartz kindle
#

especially when right now i use day/month/year strings to do it, and half of my users want to use month/day/year instead

#

lmao

#

fucking muricans

boreal iron
#

I absolutely know what you’re speaking about

round cove
#

Only 2 seconds but still?

boreal iron
#

My community control web panels always had yyyy-mm-dd and people from US to RU used it and there was one continent always having trouble with it freerealestate

quartz kindle
#

that would be one explanation

boreal iron
quartz kindle
#

any network fluctuation could also cause congestion to specific parts of the socket

round cove
#

Fair.

#

How can I help combat this?

quartz kindle
#

if, as you said, it doesnt happen on smaller sockets, with only a few guilds

#

one thing you could try is having more sockets with less guilds each

round cove
#

Sharding?

quartz kindle
#

yeah

#

another solution would be to switch to websocket interactions

solemn latch
#

imagine having the problem so many users use your bot that you have this issue. couldnt be me!(not /s)

boreal iron
#

Or completely using a different endpoint dealing with slash command events other than your actual bot

round cove
#

People do that too I guess

quartz kindle
#

i have never tested it in production, but im fairly certain webhook interactions are much more reliable than websocket interactions

#

at least in theory they should be

round cove
#

Hmm, an example?

quartz kindle
#

you will need an interaction server that complies with discord's security demands

#

meaning, you need a domain name with ssl

#

and need to verify each request's signature

#

and respond to random ping requests

round cove
#

Well I've got the domain at least via AWS.

boreal iron
quartz kindle
#

ye

#

i've made a lib for it

#

its part of my tiny-discord lib

boreal iron
#

Ah that’s the response option I saw in the table then

#

I was wondering what ping actually meant

boreal iron
#

(pings)

quartz kindle
#

this is basically my interaction server code

boreal iron
#

Oh custom headers

round cove
#

That's what I'd expect.

boreal iron
#

Guess I need to study the docs

quartz kindle
#

yeah, all messages are signed by ed25519

#

you have to return 401 on missing or invalid signature

#

and they do test that by randomly sending you invalid requests

boreal iron
#

Ah I see ping acknowledging requires to answer with the type omg

quartz kindle
#

ye

boreal iron
#

Not much complicated at all

quartz kindle
#

the only hard part was getting the signature to work

#

because discord gives you a raw key, and node.js doesnt support raw keys

#

so the typical solution is to just use libsodium

#

but i wanted to be 0 dep, so figured out how to convert the raw key to whateevr node.js wants

boreal iron
#

Haven’t even heard ed255… ever before

quartz kindle
#

which is just this, simple af, but was hard to figure out lmao

#
this._key = crypto.createPublicKey({
    key: Buffer.concat([Buffer.from("MCowBQYDK2VwAyEA", "base64"), Buffer.from(this.key, "hex")]),
    format: "der",
    type: "spki"
});
boreal iron
#

Hmm lol

#

Funny they don’t specify that in the docs

quartz kindle
#

they have this in their docs

boreal iron
#

I need to figure that out, too if I wanna step away from sockets

quartz kindle
#

the easy way is to just use libsodium or tweetnacl

boreal iron
#

Do the pings actually influence your app online status?

round cove
#

Well I guess I'll try sharding and pray.

quartz kindle
#

didnt test, but possibly

#

i mean, when i was testing this, there wasnt even an online status for non-bot apps

boreal iron
quartz kindle
#

php should have nacl or sodium

boreal iron
#

I thought they stated the app can be listed as being online (not only responding via websockets) without a client being shown in the member list

#

Huh wtf is that English

#

Just ignore what I wrote lol

quartz kindle
#

this should be the relevant function to verify the signature

boreal iron
#

Imagine Tim is sending FakE links to the PHP docs

#

The world is crazy

quartz kindle
#

xD

boreal iron
#

Even if that’s very helpful I doubt I can find that messages again when searching for them as there’s no option to save/favorite messages

#

That would actually be an useful feature

round cove
#

god have no idea how I'm going to handle sharding now lmao. Time to be smart and make a shard manager???

boreal iron
#

No no Tim is currently writing my php code as I can’t on mobile freerealestate

quartz kindle
#

lmao

#

im making my bot try to fetch 43k users to check if they are deleted accounts

sudden geyser
#

I give up with authentication

#

I'm sticking with sessions and cookies

round cove
quartz kindle
#

current speed is 10 per second

round cove
#

Nice

quartz kindle
#

so its gonna take about an hour and 20 min

round cove
#

I'm praying whatever the fuck I write for this sharding thing works as I've never done this

boreal iron
#

Tim’s sharing his requests on 1000 different test applications freerealestate

#

Aka bot net

quartz kindle
#

lmao nah

#

im doing this on prduction using eval command

boreal iron
#

You got taht one? KEKW

quartz kindle
#

xD

sudden geyser
#

alright I'm betting tim gets banned

round cove
#

lmfao

boreal iron
#

What’s even the purpose of finding out if they’re deleted or active?

round cove
#

probably clear his db

quartz kindle
#

ye

boreal iron
#

Oh oh… Tim may owns data from deleted accounts without their consent?

#

I’m calling the police now, I swear

quartz kindle
#

lmao

boreal iron
#

That privacy breach tho

quartz kindle
#

how am i supposed to know when they delete their accounts

#

theres no event for that xd

boreal iron
#

That’s not question!
You’re guilty. That’s it,

round cove
#

Xd

quartz kindle
boreal iron
#

That’s not question!

Yes, yes my English is on point today

boreal iron
boreal iron
#

Need to pass my utils, app and sql class to my eval cmd, too

#

Never thought about that before

#

Tim attached anything to the client oldEyes

quartz kindle
#

i dont have any fancy dashboard or database control panel, this eval is literally the only way to interact with the db, except something like an sqlite file editor

boreal iron
#

Well I mean most likely you don’t even that

quartz kindle
#

yes i dont even that

#

:^)

boreal iron
#

Omg

#

Fuck my phone for real

#

Damn auto correction stealing all my words

#

:D

sudden geyser
#

dashboards are overrated anyway

quartz kindle
#

ill need to make a dashboard eventually

#

my premium stuff is way too complicated to set up

#

people have to paypal or patreon me, then i have to send them a json and they have to edit the values and send it back to me, then i add the json configuration to their accounts

round cove
#

Bruh lmao

quartz kindle
#

yeah

#

because its colors and graphics stuff

#

cant really use commands for that

#

i mean i could, but it would be complicated

#

a dashboard would be much better

#

with color pickers for example

boreal iron
#

Why don’t you use the PayPal flow?

#

Did write one flow in the past already

#

You provide additional informations to the request to PayPal, like a Discord user ID after a login, and will get it back from PayPal within its requests and the info about the payment status

#

Storing the payment in a database and if it’s successful you promote the Discord user ID with whatever you want

quartz kindle
#

yeah

#

but my issue is that my premium features are not easily activatable

#

i currently have to manually define the features the person wants after they explain to me what they want

round cove
#

Oh man this is already not fun.

quartz kindle
#

the amount of possible customization doesnt fit in 2000 chars

boreal iron
#

Built and used that flow a few years ago for a gaming community requiring the Steam login then pushing the Steam ID through the process and storing it together with the payment info in the database

#

To grant VIP access to server shit

quartz kindle
#

i know people get frustrated after they donate because they expect something that i just turn on and they have access to a bunch of new features and commands

#

but my stuff is too complicated for that

boreal iron
quartz kindle
#

well, these "items" have a huge ass json of customization

#

my premium feature is basically customizing the colors in the chart

round cove
#

Yo test bot worked

boreal iron
#

Omg

boreal iron
#

“[red_bars,yellow_x,blue_y]”

#

And whatever

#

As items they purchase via PayPal being listed when buying that stuff

#

Item “red_bars” with description XYZ

#

For 1$

quartz kindle
#

lmao

#

this is a custom theme:

boreal iron
quartz kindle
boreal iron
#

OKAY you’re not compatible to my suggestions

quartz kindle
#

lmao

boreal iron
#

Dunno how many items you can sell but yeah

quartz kindle
#

im thinking of making a dashboard with interctive color pickers and shit

#

and have it be a subscription feature

boreal iron
#

One last idea is to use a generator on your site, generating BITFLAGS (I hate) for the unique customization you save in your database

#

Yeah I see

#

Same idea

#

Might require to restrict to the colors

quartz kindle
#

i have an even worse customization hell idea planned, but not for this bot, for a webapp im planning

#

but its essentially the same thing, but not limited to colors

boreal iron
#

Tbh I don’t actually see a big issue

#

I explain how

#

You website > generator (color picker etc.) > if done, customization saved in database > redirection to payment flow with unique payment ID (saved in database as well associated with the customization) > if payment success proceed > if fail delete customization from database

#

Actually damn easy

#

And for donations without that a big hint “you wanna donate without customization etc”

quartz kindle
#

hmm its a good idea

#

but im still not sure if im gonna go that way

#

im thinking subscription might be easier, but will probably make much less money

#

i can try implementing both sub and theme purchase

boreal iron
#

Yee but generally storing the customization in a database or cookie/session together with a unique payment ID seems like an easy way
Also in terms of auto removing this if a payment never happens or fails

quartz kindle
#

for the theme purchase idea i had thought in another way

#

give them 24 hours of access to the dashboard, where they can tweak and test in discord as well

#

and once the 24 hours are done, whatever they did gets permanently saved in their account

#

but your idea might be better

boreal iron
#

The association with an unique ID and the user ID in your database allows the donator to edit his customization at any time

quartz kindle
#

yeah but i was planning on only allowing that for subs

#

for single purchases, further edits should not be accessible

#

otherwise they would never need to pay again

#

they would just edit it every time they want a new theme

boreal iron
#

Yes absolutely what I did too for reoccurring payments, the payment info in the database also contains the payment type

#

I dealt with different payment types too

#

Single and subs

#

To grant specific access to specific things for the Steam ID associated with the payment in my database

quartz kindle
#

what do people prefer?

#

i have a feeling most people are against subbing

#

they just want to pay once and never again

#

or maybe thats my bias because i am like that too lmao

boreal iron
#

Reoccurring payments in our case as that grants special access to game server items and virtual shit, single payments just could access to other stuff like quick connect even if the slots are full etc.

quartz kindle
#

hmm

#

i have another feature planned besides the themes thing

#

for subs

boreal iron
#

Can’t remember 100% but I still have the payment code and database structure and screenshots somewhere

quartz kindle
#

a button chart navigator

boreal iron
#

Tim that actually doesn’t matter that’s up to you how you promote it

quartz kindle
#

idk i suck at making money

#

i feel much more at ease and relaxed when theres no money involved and everything is free

#

thats why i like working with open source

#

but thats also why im poor lmao

boreal iron
#

You just use the payment type as your point to access features or not for the associated user IDs or add a few more columns to the database for example, is_sub etc. to categorize your users and their features

boreal iron
#

That shit is actually scalable and extendable with features (as items if needed) you store in a database you deal with in the payment

#

You send anything you want to PayPal in your payment flow, they will list it for the customer when checking out and that’s it

quartz kindle
#

i have a lot of freedom in my db so thats not an issue

boreal iron
#

And this all works for donations

quartz kindle
#

its just deciding what costs what and in what payment format

boreal iron
#

As we weren’t selling stuff too

quartz kindle
#

how much does your sub cost?

boreal iron
#

If I’m back to my PC tomorrow I show you how the usual payment infos look like

#

You can basically provide anything to the PayPal flow which will be processed and/or stored if a payment succeeds or not

boreal iron
#

Per month

#

And the community had more than 400 active subscribers oldEyes

quartz kindle
#

dayum

round cove
#

starts sharding
mongo claims things have already been executed

Bro I'm going to lose it

#

time to convert all my mongo shit to postgres

boreal iron
# quartz kindle dayum

Yeah until the owner has ruined the project because he used all the cashed for private usage, didn’t pay the game servers, his developers and pissed anybody off

#

That way the sad end of more than 2000 invested hours

quartz kindle
#

rip

#

he went full corporate

boreal iron
#

Work for an huge community panel, Framework, backend tech, automation systems, payment systems etc etc etc

boreal iron
quartz kindle
#

this gonna take a while

#

xD

boreal iron
quartz kindle
#

40k more to go

round cove
#

0

#

Jesus

#

What does the bot do?

boreal iron
#

I’m gonna hammer the report profile button for API abuse now!

quartz kindle
#

lmao

#

im respecting the rate limits!

#

2 reqs/sec

boreal iron
#

Ya ya… you’re spying on 40k accounts

quartz kindle
#

lmao

#

how is it spying if i want to delete them

earnest phoenix
#

tim what the heck are you doing

quartz kindle
#

checking for deleted discord accounts so i can remove them from my db

earnest phoenix
#

Oh

#

Pog

boreal iron
earnest phoenix
#

and I heard you have 40k?

quartz kindle
#

yeah

earnest phoenix
#

"Gently"

#

"Hey uwu can I stwore your dwata"

quartz kindle
#

their id is literally the only thing i store that is not their bot settings lmao

earnest phoenix
#

why do you need their id

#

and only their id

boreal iron
#

Why the fuck do you need to clear your database then?

quartz kindle
#

how else would i make per user settings? lmao

boreal iron
#

Is it already 932GB large?

earnest phoenix
#

oh I thought you literally only stored their id

quartz kindle
#

"that is not their bot settings"

#

.>

earnest phoenix
#

shut up im tired

quartz kindle
#

excuses

#

lmao

earnest phoenix
#

smh

#

So I spent 4-5h trying to figure out why sapphire's new slash command implementation wasn't working

boreal iron
#

I’m close to my disk limits of 1TB but still don’t think about cleaning the database, so shut up Tim with your 20 MB database

earnest phoenix
#

turns out ts-node was the issue

quartz kindle
earnest phoenix
#

damn people dying?

quartz kindle
#

as far as discord is concerned i guess

#

lmao

earnest phoenix
#

you wouldn't have no problems if you had no data

#

ezpz

boreal iron
#

Oh fuck the time… my gosh

quartz kindle
#

damn, the time must be sexy

earnest phoenix
#

its only 8pm for me :p

#

tho im still tired

boreal iron
#

Ok need to sleep, need to fucking finish building my roof today before the next snow is coming

quartz kindle
#

o

earnest phoenix
#

Do you live in a place with no roof

#

tf

#

homie got the stars in view all night

boreal iron
#

Not for my house lol

earnest phoenix
#

oh

#

Think about it, a house without a roof is still camping

boreal iron
#

There you go

earnest phoenix
#

Looks like wood

boreal iron
#

Genius freerealestate

earnest phoenix
boreal iron
#

And steel

earnest phoenix
#

Is sheet metal steel?

boreal iron
#

No but the steel is steel

quartz kindle
#

looks nice

earnest phoenix
#

I have bad memories with sheet metal

#

Cut my eye open 3 times in roughly the same place on sheet metal

earnest phoenix
# boreal iron

house without a roof not a roof without a house angery

boreal iron
earnest phoenix
#

inb4 it falls apart

boreal iron
#

Shut up it doesn’t

earnest phoenix
#

inb4 15 feet of snow

#

if you are somewhere with 15 feet of snow

#

every mountain ever

#

you literally shouldn't be living there

round cove
#

and with one single mongoose error I'm changing to a rdms

boreal iron
earnest phoenix
boreal iron
#

That thing is more solid than Trumps fucking wall

round cove
#

Resigned.

earnest phoenix
#

WHAT

#

But u were like

#

the only cool mod

round cove
#

Nah all the mods are cool.

earnest phoenix
#

nah

round cove
#

Respect the homies.

earnest phoenix
#

they are smelly

round cove
#

They work hard.

earnest phoenix
#

which is why they smell

#

working up sweat

round cove
#

gg

earnest phoenix
#

mongodb sucks btw

#

kthxbai

boreal iron
round cove
#

lmfao

earnest phoenix
#

nah dylan the homie

round cove
earnest phoenix
#

I helped him solve one of his problems

earnest phoenix
boreal iron
#

You can now be the deadass we know you are

round cove
#

now help me solve this one 😏

earnest phoenix
#

like I aint saying no

#

but i aint saying yes either

quartz kindle
#

werent you guys going to sleep? why are you still here

#

lmao

earnest phoenix
#

I never said I was

#

I said I should

#

big difference

round cove
quartz kindle
#

if there is postgres, why isnt there pregres?

sudden geyser
#

because we can't devolve further

quartz kindle
#

what about progres and congres

#

and regres

sudden geyser
#

progres
we haven't made progress

congres
do you want to get the freedom treatment

regres
that actually sounds nice

round cove
#

smh

slender thistle
#

gres.

quartz kindle
#

gross

round cove
#

Found this looking up postgress UUID

quartz kindle
#

lmao

round cove
#

Oh should I check out typeorm?

earnest phoenix
#

Yes

#

If you don't wanna painstakingly make your own SQL queries

round cove
#

Do you use the postgres package I shared above of does typeorm help witht hat?

earnest phoenix
#

I use this one

round cove
#

Are there big differences besides how the data is retrieved and how queries are done?

earnest phoenix
#

I'm not sure it matters which it uses typeorm just suggests this one

earnest phoenix
#

It gives you methods and such to make tables and query data easier

round cove
#

Right.

#

Appreciated.

earnest phoenix
#

You don't have to use an Orm but it's honestly really nice

#

Also typeorm is a really nice typescript Orm that works with more than just postgres

round cove
#

okay this is exactly what I want

earnest phoenix
#

Kekw

round cove
#

So you essentially only use typeorm and don't interface with pg at all right?

earnest phoenix
#

It's a support package

#

You never have to require it

round cove
#

Poggers

#

Really appreciated.

earnest phoenix
#

Typeorm uses it in the background

#

No problem

#

If you need an example of how to setup typeorm I can make one

#

Also any entities you create I suggest extending BaseEntity

round cove
#

I was thinking of just having a directory for all my entity's and then maybe some "service" class that handles all the entities and I can do basic calls through that?

#

What does Baseentity add?

earnest phoenix
#

Essentially you don't have to use the insert methods and such

round cove
#

Ah

earnest phoenix
#

You can just do
const user = new User()
user.id = blah
await user.save()

#

On phone so it's not in code blocks sorry

round cove
#

Ah that makes sense.

#

Also JS const correctness is so stupid. Xd

earnest phoenix
#

Also makes it nice cause you don't have to use getRepository

round cove
#

Oooh that is nice.

earnest phoenix
#

Yea

#

You can just call the table and use find one on it

#

I will make a typeorm example

#

Basically just how I implement it

round cove
#

😮

#

oh yeah now we're gaming

earnest phoenix
#

ah right

#

you have to use id!: string

round cove
#

God no

#

I will find a real solution

earnest phoenix
#

That is the real solution

#

lmfao

#

You literally have to

#

unless its optional

round cove
#

man i hate that

earnest phoenix
#

id?: string

round cove
#

"strictPropertyInitialization": false is also a solution

#

But I don't wanna do that just for typeorm

#

Damn

earnest phoenix
#

Its not a big deal

#

It is basically just like "Yes this can never be null"

#

It makes it nice cause if you are missing that from your creation it will yell at you

#

say id is required and you do

const user = new User()
user.name = balh
#

it will yell

round cove
#

Right but I'd rather the TS interpreter to catch that because it becomes a runtime issue.

#

Cause I can do ! anywhere and make TS shutup.

#

But yeah until they come out with a better solution I guess I gotta do that

earnest phoenix
#

Mmm, but it markes it as a required field

round cove
#

I wish they made the entity's return Partials instead.

#

Right that's true.

earnest phoenix
#

You could always do a partial of a entity ig

#

but using Partial is not always good

round cove
#

Or add (required) as a param for the decorators 😉

earnest phoenix
#

Anyway using ! marks it as a required field so

#

Imo I rather it be how it is now

#

It is a lot easier to type

round cove
#

Hmm

earnest phoenix
#

I will make an example of a table relation as well to show you how i works

#

:p

round cove
wheat mesa
#

I have big news guys

#

Js is C# now

earnest phoenix
round cove
#

ty

wheat mesa
earnest phoenix
#

Hopefully it helps at all until I can make a better example

round cove
#

Thanks, lemmie check it out.

earnest phoenix
#

I basically just covered how to connect to a database, how to make entites and how to make a table realtion (Many-To-One/One-To-Many) and how to query one and save one

round cove
#

Ooh the one to many helps.

earnest phoenix
#

Ah also

round cove
#

Also the unique decorator, ty ty

earnest phoenix
#

I forgot something

round cove
#

👀

earnest phoenix
#

When creating the connection use syncronize: true in dev

#

when you push to production remove it

round cove
#

Honestly, why have a _id and id

earnest phoenix
#

_id is the random id

#

id was like discord id

round cove
#

Which is great !

earnest phoenix
#

I was modeling it around a discord bot

round cove
#

Ah I see.

#

Since it is a user that makes sense.

earnest phoenix
#

ye

round cove
#

I just need randomly gen'd Ids for tracking things.

#

But thanks fort he explanation

earnest phoenix
#

No problem

#

Also table relations are rather useful

#

One example is an inventory system.

#

Which is basically what I was modeling after in the example mmLol

round cove
#

I know I could google this, but is there a way to limit length of arrays?

earnest phoenix
#

It is nice because once you make a table relation especially a Many-To-One table relation you don't really need to touch the table that has the Many-To-One decorator unless you are creating an instance of it

round cove
#

Besides hard coding checks.

earnest phoenix
#

I think you can use length prop on the Column decorator

#

though don't quote me on it

round cove
#

Cool, and how about foreign keys?

#

So I can nuke some rows if deleting things Xd

earnest phoenix
#

as for foreign keys i haven't messed with them that much

#

So even I am unsure mmLol

round cove
#

I'll google, thanks again 🙂

earnest phoenix
#

might be what you need

#

Not entirely sure though

#

Also I think RelationId decorator might be close to what you need as well (not entirely sure tho eek)

round cove
#

Yeah trying to read up on it before I start putting random stuff down ;p

rose warren
#

@cedar plover check the pins for help on how to make a bot and ask for help here. Good luck! dog_Happy

earnest phoenix
round cove
earnest phoenix
#

Mmmm

#

You don't really need that tho

round cove
#

Guide.

earnest phoenix
#

yea

round cove
#

Might be all I need then?

earnest phoenix
#

Mmm, I would assume so it seems ot be what you'd want

#

Assuming you wanna make a One-To-One relation

round cove
#

ManyToOne

#

But should be the same?

earnest phoenix
#

You don't need JoinColumn for a ManyToOne relation

round cove
#

Oh?

earnest phoenix
#

Yea

round cove
earnest phoenix
#

You just use OneToMany on the cattegory

#

or wait

#

I think I might have it mixed up one sec

round cove
#

In this case, the category doesn't need to contain reactroles

#

But the reactrole can be apart of a category.

earnest phoenix
#

you are righjt

#

That should work

round cove
#

Pog

earnest phoenix
#

a OneToMany relation can't exist without ManyToOne but the other way around is not necessary

round cove
#

I'm sure I'll have plenty of testing to do

earnest phoenix
#

I hope you enjoy typeorm

round cove
#

I will :)))

earnest phoenix
#

also never touch mikro-orm

#

its absolute aids

round cove
#

?

earnest phoenix
round cove
#

Lmfao

earnest phoenix
#

typeorm so far is supreme out of every orm i've tested

round cove
#

I honestly expected sharding to be harder earlier

#

but it worked out

earnest phoenix
#

Also Dylan if you wanna contribute to the typeorm-example with your experience with it later on feel free too

round cove
#

discord.js wise

earnest phoenix
#

I plan on leaving it there for others

#

I was going to make a example using typeorm for the longest time I just never got around to it

round cove
#

not it is helping others