#development

1 messages · Page 55 of 1

rustic nova
#

fix the output drakeNo
fix the actual object that the output uses drakeYea

spark flint
#

lol

boreal iron
#

number of servers 8, number of users 2 ... wut :P

rustic nova
#

probably did cached users

lament rock
#

15MB at 8 guilds is garbage >:(

eternal osprey
#

could anyone help me with this issue

#
char arr[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ' ', '!', ',', '.', '-'};
 bool matches_found = false;
 bool stop_counter = false;
 int counter = 0;
  char individual;
  while(!stop_counter){
     r++;
     counter = 0;
     input.close();
     input.open("test.txt");
    if(!input.eof()){
     
      matches_found = false;
     individual = input.get();
    
    a = ((individual >= 32 && individual < 128) ? (individual - 32 - (r % (128 - 32)) + (128 - 32)) % (128 - 32) + 32 : individual);
    cout << a;
        for(int i = 0; i < 56; i++){
    
    if(a == arr[i]){
    counter++;
if(counter == 30731){
   cout << "done";
   stop_counter = true;
}
   
    }```I basically want tto stop my loop when ALL characters in the file are in the array. However as of now it keeps looping infinitely.
#

It works for 1 character indivdiually, just not for > 1 chars

lyric mountain
#

you arr could be changed with a loop

#

or simply checking the numbers themselves

eternal osprey
#

but that wouldn't be a problem right?

lyric mountain
#

no, but it'd be the best approach

eternal osprey
#

I need to decrypt this. I already have the formula, just have one value missing which is value R. I need to calculate that

#

this is the formula

rustic nova
#

r is probably something appended on the secret you have there

lyric mountain
#

if(counter == 30731) you never, EVER do this

#

always use dead-end operators

rustic nova
#

KuuHaKu rage

lyric mountain
#

too many bit flips happened to me to allow something like that to exist

eternal osprey
eternal osprey
#

What's a dead-end operator?

lyric mountain
rustic nova
#

can tell why

#

skip a clock cycle

lyric mountain
rustic nova
#

boom your loop goes forever

eternal osprey
rustic nova
#

@lyric mountain can you technically define a number increment in a programming language a clock cycle?

#

ignoring the storing and stuff, just adding 1 to some number

#

well a clock tick*

lyric mountain
#

no idea, especially that most compilers will bake your code into something different

eternal osprey
#

wait i maybe got something really smart

#

so we have the first character of the encrypted text

eternal osprey
#

a = ((individual >= 32 && individual < 128) ? (individual - 32 - (r % (128 - 32)) + (128 - 32)) % (128 - 32) + 32 : individual);can't we reverse this formula

#

individual will be the first character.

lyric mountain
#

stop using ternaries please

rustic nova
eternal osprey
#

Can't we redefine this formula to get r = (formula)

rustic nova
#

honestly still think you should let another package/library handle it

#

people have been there

lyric mountain
eternal osprey
lyric mountain
#

it simply goes haywire and u don't know why

rustic nova
#

entirely raw done?

#

no packages at all?

eternal osprey
#

yup

rustic nova
#

shit thats kinda pain KEKW

eternal osprey
#

I had a formula to encrypt the text

#

and i can encrypt and decrypt successfully, however i now need to know fucking r lmao

rustic nova
#

make a general utilities class or file though, to avoid you doing repeated things

#

what encryption is that

eternal osprey
#

so idk what that is

rustic nova
#

also tbh that stuff seems too early for 5 weeks in

eternal osprey
#

i already got that

rustic nova
#

no clue about universities but

rustic nova
#

anyways what encryption is that?

eternal osprey
#

i really have no clue

#

it's a strange formulation tthat basically gets the character in a file, and then increemnts it's value with value r

rustic nova
#

then r should be mentioned somewhere

eternal osprey
#

imagine you have 'D', which is int 68. With r 2 you would get 70, so F

rustic nova
#

lmaoo

#

yeah r should def be mentioned somewhere

eternal osprey
rustic nova
#

pain

#

so essentially

#

you need to figure out r yourself

eternal osprey
#

” that contains a text file “secret.txt” that is encrypted with OTP using a secret initializing value R. It is your task to design and implement a program that decrypts this text file and uncover what value R has been used. The name of the decrypted text file must be “source.txt”. The only information known about the source text is that it is written in English.

rustic nova
#

oh so the secret is R

#

likely some string

#

OTP = One time pad

#

In cryptography, the one-time pad (OTP) is an encryption technique that cannot be cracked, but requires the use of a single-use pre-shared key that is not smaller than the message being sent. In this technique, a plaintext is paired with a random secret key (also referred to as a one-time pad). Then, each bit or character of the plaintext is enc...

#

this can help

#

somewhat

#

so according to OTP

The key must be random (uniformly distributed in the set of all possible keys and independent of the plaintext), entirely sampled from a non-algorithmic, chaotic source such as a hardware random number generator. It is not sufficient for OTP keys to pass statistical randomness tests as such tests cannot measure entropy, and the number of bits of entropy must be at least equal to the number of bits in the plaintext. For example, using cryptographic hashes or mathematical functions (such as logarithm or square root) to generate keys from fewer bits of entropy would break the uniform distribution requirement, and therefore would not provide perfect secrecy.
The key must never be reused in whole or in part.
The key must be kept completely secret by the communicating parties.

#

most importantly,

The key must be at least as long as the plaintext.

#

so you could essentially bruteforce the key perhaps? KEKW

lean knoll
#

Idk if its the right channel for this question but is there a variable with which you can display the servers votes in a vote webhook?

rustic nova
#

since what I'm guessing your goal is is essentially a cracker

eternal osprey
lyric mountain
#

webhooks aren't for getting total of anything

lean knoll
#

oh okay, thanks

eternal osprey
eternal osprey
rustic nova
#

alot of pain lol

#

wouldn't have any other clue then

lyric mountain
#

perhaps ur counter isn't incrementing properly

#

that said, u shouldn't use while for anything that has a boundary

#

aside from that, I can't really understand that code

eternal osprey
eternal osprey
lyric mountain
#

cant u just use an iterating for

#

idk if cpp has that tho

#

for (char c : chars)

wooden ember
wooden ember
lyric mountain
#

I mean, it does but not for this case

#

but cache is supposed to never reflect the total value anyway

wooden ember
#

used to or something there was a way of getting all users but it broke

lyric mountain
#

discord doesn't

#

discord.js does

#

different things

wooden ember
#

what ever all i know is that the code used to work but now it doesnt and i never fixed it

lyric mountain
#

it technically ain't broken

wooden ember
#

technically

lyric mountain
#

as long as u rely on cache for total count it'll show wrong values

#

cache is for holding recently used values

#

if u want user count u need to iterate over each guild and retrieve memberCount

#

not worth it imo, nobody cares abt user count anyway

wooden ember
#

i know and thats why it never go tfixed

#

lol

hidden gorge
#

i forgot how to code

#

my code is literally there lol but it broke

#

one sec let me grab it

#

Page 1 is Index Page 2 is the page it’s supposed to go to

earnest phoenix
#

You're literally sending a GET request to the / endpoint which you've declared to read the index.js file and send it back as the response, which is why you're seeing the code there

#

You're only redirecting when a GET request is made to the /discord endpoint

lament rock
#

let's also ignore the fact that you also have a handler for get / that sends hello world which is shadowed by the first get /

sharp geyser
#

@ancient nova where you at homie we miss your problems in development

earnest phoenix
#

Yeah homie, development have been too quiet lately

stiff dust
#

This is memberAchievementData[0] how can I check how many memberAchievementData[0] is true? and how many true or false?

boreal iron
#

You wanna explain your last two questions again?

#

You wanna check the object properties or…?

sharp geyser
#

Lets talk about the ENTIRE websocket protocol RFC

limber thicket
#

Hello

stiff dust
cinder patio
#

you should reeeeally use a bitfield here

#

also why not store the counts themselves instead of starsN, levelN, inServerN?

boreal iron
#

Add a strict check for the value to ignore other properties which aren’t booleans

#

if(<property> === true) + 1 your var

pale vessel
#

is that a non-monospace font I see there?

stiff dust
#

what is non-monospace font?

boreal iron
#

for(const property in object)

#

Make sure it actually is an object and not an instance of your database result

sharp geyser
earnest phoenix
#

gud morning

stiff dust
boreal iron
#

Could be the array which is true

#

Add a typeof check as condition

#

if(typeof archivmentData[key] === “boolean” && archivmentData[key]) ++

stiff dust
boreal iron
#

Why do you nest those statements?

stiff dust
#

wdym?

boreal iron
#

Also since you did a typeof check already there’s no need to do another strict check

#

That’s your entire statement:

#

if(typeof archivmentData[key] === “boolean” && archivmentData[key]) ++

stiff dust
#

yeah ...

#

wait

boreal iron
#

Then log the property instead to see which one is the one you don’t want to

#

if(typeof archivmentData[key] === “boolean” && archivmentData[key]) console.log(key);

stiff dust
#

okay wait

#

$isMongooseModelPrototype

boreal iron
#

Hmm a private property I guess idk mongoose

stiff dust
#

how can I ignore it?

#

memberAchivmentsData[0][key] !== $isMongooseModelPrototype
or
memberAchivmentsData[0][key] !== "$isMongooseModelPrototype"

boreal iron
#

If so the second one

stiff dust
#

nope didnt work

boreal iron
#

The key name is a string

stiff dust
#
if (typeof memberAchivmentsData[0][key] === "boolean" && memberAchivmentsData[0][key] !== "$isMongooseModelPrototype" && memberAchivmentsData[0][key]) unlocked++
boreal iron
#

key !== “ismongoose…”

stiff dust
#

BTW instead of that I can define unlocked -1 and with that isMongoose.... it will become truth number

boreal iron
#

I dunno if that private property is always there

stiff dust
stiff dust
#

finally XD

boreal iron
#

If it’s always there and is true

stiff dust
#

yup

fickle arch
#

how do I make bot shown how many server and user that each shards have ?

eternal osprey
#

hey guys i am still trying to find a way to decrypt this

#

the encryption process looks like this:

#

The function that gets called:c++ while (!infile.eof()) { initialise_pseudo_random(initial_value); initial_value = next_pseudo_random_number(); char individual = infile.get(); char encryptedchar = rotate_char(individual, initial_value, action); if (encryptedchar != EOF) { outfile << encryptedchar; } }
The encrypting function formula:```c++
if (action == Encrypt)
{
a = ((a >= 32 && a < 128) ? (a - 32 + (r % (128 - 32))) % (128 - 32) + 32 : a);

}```The next pseudo function: ```c++

const int SEED75 = seed * 75;
int next = (SEED75 & 65535) - (SEED75 >> 16);
if (next < 0)
next += 65537;
seed = next;

return next;```
#

So right now, the above image is encrypted with a mystery R. How would i find that r?

radiant kraken
#

@civic scroll your handwriting fits so well with my ide thanks

surreal sage
#

I need a email platform that I can easily make api calls to to read messages

wooden ember
#

how do i pass arguments to a node module? theres a module im using called node-microphone and idk how to set the options. up till now ive just exited the defaults in the module code

civic scroll
#

you urged me to improve my font

radiant kraken
eternal osprey
dry ocean
#

who may know what system should i do to get Presence Intent in verified bot?

wooden ember
#

how would i set the guild id as the name of a variable?

#

like this
let msg.guild.id = 'stuff'
but i know that wont work

#

the only other way i can think of is making an array somethging like

let stuff = {
  serverID: msg.guild.id
  otherinfo: 'things'
},```
but i have no idea how id get the `otherinfo` for each server without using a for each loop every time and that just doesn't seam right
rustic nova
#

you cant override it

wooden ember
#

?

rustic nova
#

aswell as it being a snowflake so you cant use an entirely different type for that

#

if you want to attach some info on a server, consider making a handler for that that allows you to fetch certain options for a guild

wooden ember
#

its only for a vc type thing

#

i gotta make a new audio stream for each thing and whildt i can create them i cant destroy them

#

i could do it withg the channel id

#

channel id would be better anyway

#

but i still have the same issue

rustic nova
#

you'll need to make a handler, for example having a static dictionary with the following:

  • a key that is the server id
    then a dictionary that has other things such as your audio instance

if you're trying to handle something on that audio instance, you can access that static list and then use the audio instance from there

if you no longer use it, you can just remove that entry from the dictionary

wooden ember
#

how on earth would i do that

#

the only handlers i've delt with ar command/event handlers

rustic nova
#

your general goal is trying to work with dictionary, look into how to work with dictionaries so you can store your audio instance

wooden ember
#

cool

#

well sounds like a project i guess will look into it later not got that sort of time at the minute but thx for the info

slender wagon
#

How do i learn C quickly

spark flint
slender wagon
#

No i am serious

wheat mesa
#

C is very simple in its essence

#

That's where the difficulty stems from; C is almost TOO simple sometimes

deep fern
#

429 hit on route /channels/1024369295238635571/messages
429 hit on route /channels/1024369295238635571/typing

rustic nova
#

tldr you are ratelimited

pale vessel
#

thanks

wheat mesa
#

tldr stop spamming the API

deft rock
#

butttt wafffflleeeeeee

earnest phoenix
#

@rose warren is this valid

spark flint
#

lol

#

make it scream scary things

rose warren
earnest phoenix
#

as in one will have commands that respond with the one exact sentence

#

and the other one will do other stuff

rose warren
#

I guess

earnest phoenix
hardy notch
#

cant get my bot to come online how to i make it ?

deft rock
#

English?

quartz kindle
#

do you know how to code?

deft rock
#

They asked how to make it so you tell me tim

hardy notch
#

Somewhat , not familar with discord server login thou

quartz kindle
#

is there any specific progamming language youre more comfortable with?

hardy notch
#

visual , some java and c

#

c+

quartz kindle
#

out of those 3 i believe java would be easier

#

there are a lot of discord libraries out there for every programming language

#

so look into discord libraries for java, like jda

#

and learn how they work, read their documentation

#

and thats pretty much all you need to create a functioning bot

hardy notch
#

ight , thank you 🙂

#

guess would be easyr to do through git hub huh?

#

😛

#

examples on git

quartz kindle
#

sure

hoary wing
#

Out of curiosity, for anyone that has a bot here and has a website for said bot, what do you use for screenshots of Discord? For example, I want to use discord screenshots on my website but using snipping tool is just giving me blurry images. Any suggestions on softwares would be much appreciated! Thanks everyone! :))

deft rock
#

Snipping tool, if it goes blurry I use Photoshop to sharpen it

hoary wing
#

Of course, not too big that the image takes long to download client side.

deft rock
#

Yeah, I mean it varys I suppose.

#

Just dont make it huge

hoary wing
deft rock
#

np

lyric mountain
#

as well as shrinking it

hoary wing
lyric mountain
#

just take a higher resolution screenshot

#

be it photoshop, gimp, corel or whatever, manipulating image size will always degrade quality exactly the same

#

that's because the computer has to "guess" what would be in the missing pixels

#

you can, however, make the image appear sharper or blurrier by using different interpolations like linear, cubic or lohalo

#

nonetheless it'll not reduce the quality loss

#

for example, if u enlarge an image to twice of its size, the loss will always be 50%

lament rock
#

run that bitch through waifu2x

lyric mountain
#

waifu2x doesn't help with texts

lament rock
#

it does actually

#

just the model is mainly for anime

lyric mountain
#

not really, it'll look like texts when u try to read something inside a dream

#

I use w2x daily

lament rock
#

Might come down to source used then

#

I never had problems

lyric mountain
#

w2x is a machine-learning upscaler, unless u build the source yourself and train it using text samples it'll do poorly for texts

#

it'd be better to simply write the text yourself in an image editor after upscaling it

lament rock
#

would be hard to do on materials with fine grain color gradations

lyric mountain
#

?

#

it's a discord print

#

simply upscale the image, delete the texts and write it again using whatever image editor u use

lament rock
#

gradients

#

gl refilling that

lyric mountain
#

what gradients?

#

also it aint hard, just sample the margins

lament rock
#

background gradients

#

if any

lyric mountain
#

just sample the borders

#

gradients are really easy to match

errant creek
#

ngl when top.gg switched to chakra-ui as their ui framework, i immediately recognized it and was like "woah"

sharp geyser
#

chakra-ui is mid

#

React components and hooks library with native dark theme support and focus on usability, accessibility and developer experience

errant creek
#

but still it was kinda weird to see it being used in production

errant creek
sharp geyser
#

shameless plug of my fav react framework

errant creek
#

framework?

sharp geyser
#

I have used both and mantine was a better experience

sharp geyser
rustic nova
#

fun fact, screw framework uis that obfuscate css classes

sharp geyser
#

I was thinking of a framework

#

my bad

rustic nova
#

especially if you're doing premid stuff

errant creek
sharp geyser
#

premid

#

do you mean premade?

errant creek
#

premid as in the discord rpc thing?

rustic nova
#

yeah

sharp geyser
#

premid

errant creek
#

why?

sharp geyser
#

never heard of it

errant creek
#

i only looked into the github repo like once to see how it worked

rustic nova
#

misty you never heard of anything lmao

sharp geyser
#

not true

#

i've heard of ur mom

#

ok on a serious note

#

I don't really fuck with discord stuff anymore other than gateway and oauth

#

so

errant creek
#

discord is kinda strange

sharp geyser
rustic nova
#

so is @sharp geyser

errant creek
#

what is your:

  1. preferred ui library (if any) or css preprocessor
  2. preferred web framework (or vanilla)
  3. favourite hosting platform
  4. favourite discord bot lib (if any)
sharp geyser
#

Just cause I do smth strange for a bit of change doesn't mean anything

sharp geyser
dry imp
sharp geyser
#

how do you think I found out about for/else

errant creek
dry imp
#

wtf thats such a nerd move

sharp geyser
#

daff

dry imp
#

cmon misty python is easy u dont need books

sharp geyser
#

this is why I learned something new that you didn't know despite using the language

sharp geyser
rustic nova
#

ignoring the pre-pc times

sharp geyser
#

Aurel uses free hosting

rustic nova
#

these were cringe

rustic nova
sharp geyser
#

Wait really?

rustic nova
#

ofc

#

what do you think @gilded plank runs on smug

sharp geyser
#

hey aurel do the -apply thing or whatever

dry imp
#

no way

rustic nova
#

-apply

#

see

sharp geyser
#

damnit

rustic nova
#

good uptime much

rustic nova
#

ofc

sharp geyser
#

false

rustic nova
#

well

errant creek
#

nvm it runs on aurel's brain

sharp geyser
#

it runs on lemon juice

rustic nova
#

technically smoke signals and someone pressing buttons when sees smoke

sharp geyser
#

which is why its upttime is amazing

rustic nova
sharp geyser
#

I wanna get it

errant creek
rustic nova
#

what do you think how discord bots work

sharp geyser
#

Aurel's brain connects to the satellites and downloads information

rustic nova
#

a bunch of monkeys on desks sending messages on their computer

dry imp
#

ahhh

errant creek
hidden gorge
#

my command isn’t working and i made the message.js event and the code is


module.exports = (Discord, client, message) => {
    const config = require("../../config.json");
    const prefix = config["main_config"].prefix;
    if(!message.content.startsWith(prefix) || message.author.bot) return;

    const args = message.content.slice(prefix.length).split(/ +/);
    const cmd = args.shift().toLowerCase();

    const command = client.commands.get(cmd) || client.commands.find(a => a.aliases && a.aliases.includes(cmd));

    if(command) command.execute(client, message, cmd, args, Discord);
})```
sharp geyser
#

Should I participate in the Halloween hackathon

dry imp
#

idk

sharp geyser
hidden gorge
sharp geyser
#

Thank you, now the next step

#

What is it doing instead, is the execution of the code stopping somewhere else?

hidden gorge
#

it’s just not running the command

sharp geyser
#

So it doesn't reach the command.execute

hidden gorge
#

yeah do you need my index?

sharp geyser
#

Have you tried logging command

hidden gorge
#

no

sharp geyser
#

it could be null/undefined

rustic nova
#

lol

sharp geyser
#

at least youre honest

#

try logging it

#

see what it is

hidden gorge
#

ok

#

i did it

#

nothing

sharp geyser
#

It logs nothing?

hidden gorge
#

yeah nothing

sharp geyser
#

try logging cmd and args see what the results of that is

#

It is probably not finding the command period

hidden gorge
#

ok

#

think i found it

#

nvm

hidden gorge
#

fixed

sharp geyser
#

@wheat mesa I need help with math

deft rock
sharp geyser
#

What?

#

Don't mini mod me

#

fuck outta here

deft rock
#

Don't be stupid then

sharp geyser
#

This is development related

deft rock
#

U never said that. So yeah.

sharp geyser
#

Okay but this is why community members don't mini mod

#

💀

deft rock
#

Don't tell me what to do

#

I'll do what I want.

sharp geyser
#

Anyway waffle math help :)

sharp geyser
# wheat mesa yes\

So I am trying to make a bot for the halloween hackathon but I wanna make it balanced. Essentially there will be items you can purchase that gives you a boost and obv each item will be more expensive. I am trying to figure out the best way to calculate the cost of the next item so it remains challenging but not insanely difficult

wheat mesa
#

uh

#

idk

#

exponential but really slow growth

sharp geyser
#

How do you determine the growth

#

I was also looking a an exp func but I forgot how they worked

wheat mesa
#

y = a(b)^x

#

a is the starting amount, like 2, b is the growth rate, like 2, and x is the thing you change each level

sudden geyser
#

how about quadratic

wheat mesa
#

it's the same idea

#

quadratic is a bit more annoying to control

sudden geyser
#

but it doesn't grow as fast

wheat mesa
#

Growth is relative

#

You can control the growth rate on both

sudden geyser
#

exponential implies that a variable is attached to an exponent

sharp geyser
#

So wait

#

x would be the thing i'd increment right?

#

so like y=2^x -> y = 2^2x

wheat mesa
sudden geyser
#

quadratic ≠ exponential

wheat mesa
#

Quadratic is baaaasically exponential

sudden geyser
#

exponential is not when line go up faster

wheat mesa
#

Exponential is easier to visualize in this situation though

sharp geyser
wheat mesa
#

not really, that'll change it but it's better to change b

sharp geyser
#

This doesn't seem steep enough

#

It'd be way too easy

prime mist
wheat mesa
#

Looks like e^x

prime mist
wheat mesa
#

Seems like e^x to me

prime mist
#

Oh nope, you are right

wheat mesa
#

Yeah

radiant kraken
wheat mesa
radiant kraken
wheat mesa
#

I was having a dumb moment

radiant kraken
#

smh

hidden gorge
#

YES FINALLY

errant creek
#

hm?

hidden gorge
#

the api works now

errant creek
#

what api

hidden gorge
#

the api for my website to show my status

errant creek
#

ah ok

earnest phoenix
#

lanyard takes 5 seconds to setup, join the server and get the image...

surreal sage
surreal sage
surreal sage
radiant kraken
#

Sayuri handwriting best font

#

especially for coding in a light theme IDE

#

🤌

delicate zephyr
#

Whats the discord subcommand option id for string input

#

because I cant find it on discord docs

#

they only show ROLE, CHANNEL, USER from what I can tell

delicate zephyr
#

danke

earnest phoenix
#

why i have x2?

#

what is this error

#
  • Would be nice to give code so others can start to help
  • Would be nice to have a better error than [object Object] so others know the actual error to help you
#

xd

#

so xd

#

Yeah use a pasting service maybe? So that it doesn't flood the entire chat

#

a ok

#

xd

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

why

#

it doesnt show nsfw content

#

so?

sage bobcat
earnest phoenix
#

compare

#

oh ok xd

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

earnest phoenix
#

not always.

#

already told themn

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

and it's fine for a react command

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

it doesnt show nsfw bruh

#

as that endpoint doesn't return nsfw

#

they don't use neko endpoint or whatsoever

#

so it's fine

#

const choices = ["hug", "kiss", "cuddle", "feed", "pat", "poke", "slap", "smug", "tickle", "wink"];

#

it doesnt show nsfw

#

my bot doesnt show any nsfw

#

as said, it's fine

#

and on the other side

earnest phoenix
#

xd

#

i alrd know it

earnest phoenix
#

@rose warren ping 1

rustic nova
surreal sage
#

Just wondering if this exists: true ? : 1

wheat mesa
#

In what language?

#

The way you used it in that example is invalid syntax, but the thing you’re looking for is called a ternary operator

#

It exists in basically every C-inspired language

earnest phoenix
#

@rose warren ping2

#

oh wait

#

this is development

rose warren
earnest phoenix
#

I want to learn dc bot coding in mobile phone any tutorial?

#

Is anyone here?

earnest phoenix
surreal sage
#

"" == null right? (js)

earnest phoenix
#

I should try trrmux instead

#

You can use terminal emulators such as Termux to write and host a Discord bot, or write it and host it on a VPS if you want to bot to stay up 24/7

surreal sage
#

"just root an android phone and put ubuntu server on it"

earnest phoenix
#

You don't necessarily have to write the code in Termux although, you can write it in any code editor, and move it inside Termux

earnest phoenix
#

You already know

#

I learned about hacking from you

#

Hmm 👀

earnest phoenix
surreal sage
earnest phoenix
#

It would be false, because even though they're both falsey values, their types are different

surreal sage
#

And if strict?

earnest phoenix
#

It would still be false if it's not true with the non-strict equality operator

surreal sage
#

hm

hidden gorge
#

I can’t figure this out

wicked mortar
#

What do you do next

quartz kindle
hidden gorge
quartz kindle
#

you cannot join a fixed string, since its already joined

hidden gorge
#

so what would i do then?

quartz kindle
#

or something in there is undefined, aka nonetype

#

show your on_ready event

hidden gorge
#

i fixed it nvm

#

nvm

#

broke again

#

@quartz kindle it’s in py

quartz kindle
#

yes i noticed

#

whats the error now?

hidden gorge
#

same error

quartz kindle
#

show your on_ready code

hidden gorge
#

wdym

quartz kindle
#

the code you have for the on_ready event

hidden gorge
#

this help?

quartz kindle
#

what is line 550?

hidden gorge
#

owners = “972502840247484527”.join(

#

and it continues to 551

#

and 552

quartz kindle
#

the problem is likely that self.bot_owner_ids is not defined

radiant kraken
wheat mesa
#

It is

#

Empty strings are falsey

#

Empty arrays are not though

#

That’s prob what you’re thinking of

sharp geyser
#

Hey waffle

radiant kraken
#

but people use for the .length property to check if a string is empty, not using the string itself

sharp geyser
#

no matter how much I play with the exponential function it just seems like at some point it'd get way too hard to continue playing

#

Unless I am just calculating it wrong

quartz kindle
#

you can also use equality to empty string

#

!str
str === ""
!str.length
str.length === 0

#

the compiler will likely optimize any of the above so it doesnt really matter which one you use

#

if you wanna be as semantically correct as possible, id go for either str === "" or str.length === 0

wheat mesa
#

!str might not be optimized the same since it would also check for null/undefined

quartz kindle
#

in case of engines like v8 it doesnt really matter

#

i believe all containers have basic props like isFalsey or stuff, so it will just check for that, regardless of the js type

earnest phoenix
#

HeadersTimeoutError: Headers Timeout Error
at Timeout.onParserTimeout [as _onTimeout] (/home/container/node_modules/erela.js/node_modules/undici/lib/client.js:1005:28)
at listOnTimeout (node:internal/timers:566:11)
at process.processTimers (node:internal/timers:507:7) What is the error. Ping me to answer pls

spark flint
earnest phoenix
#

ah ok xd

crystal furnace
#

client.on("ready", () => {
  client.users.fetch("485277325328384000").then((user) => {
    //channel
    //testChannel

    setInterval(() => {
      user.send("SOMETHINGHERE");
    }, 60000);
  });
});
client.on("message", (message) => {
  switch (message.content.toUpperCase()) {
    case "SOMETHINGHERE":
      resetBot(message.user);
      break;
  }
});

function resetBot(user) {
  user
    .send("Resetting...")
    .then((msg) => client.destroy())
    .then(() => client.login(process.env.DISCORD_TOKEN))
    .then(() => user.send("Đã reset bot thành công"));
}
#

why my code is not work

#

2022-10-11T11:15:50.912641+00:00 app[worker.1]: TypeError: Cannot read property 'send' of undefined
2022-10-11T11:15:50.912651+00:00 app[worker.1]: at resetBot (/app/index.js:155:6)
2022-10-11T11:15:50.912652+00:00 app[worker.1]: at CommandoClient.<anonymous> (/app/index.js:148:7)

earnest phoenix
#

It's <Message>.author not <Message>.user

crystal furnace
earnest phoenix
#

There's no need to change the parameter name of the resetBot() function to author, because <Message>.author is a user

crystal furnace
#

Thanks bro, you helped me so much

crystal furnace
#

your method is sent to the bot itself (not possible)

#

Hmm I will make some fix :)))

earnest phoenix
#

Nope

crystal furnace
#

Discord API error

#

Can't send message to this user (the bot itself)

#

or I wrong at somepoint?

earnest phoenix
#

<Message>.author is the author of the message, and not the bot; you're possibly not sending the message to the user, or their DMs are closed

crystal furnace
earnest phoenix
#

You should prevent the bot from reading bot messages, because the messageCreate event also listens to the bot's own messages

crystal furnace
#

to make auto reset function

earnest phoenix
#

Also what discord.js version are you using?

crystal furnace
#

like the bot will send the message to me then he send a signal to me that the process is happening

#

my idea is that

crystal furnace
#

This is a old bot but is my first bot so I want it to live :))

crystal furnace
#

(before fixing)

earnest phoenix
#

You should upgrade to v14, v12 is no longer supported and will most of the time crash due to it not being able to handle newer requests

crystal furnace
#

Now I just need to make the bot online 24/7 :))

#

I will do with my other bot

crystal furnace
earnest phoenix
#

You won't be able to make the bot run 24/7 with discord.js v12 because it'll keep crashing

crystal furnace
#

some shards of the bot is die before the main reset

earnest phoenix
#

If you want to keep the bot alive then upgrade, it's not even hard, in your case it's a few changes

crystal furnace
#

my other bot is discord.js v12 but in some magic way he is auto reset when have error

#

and can run 24/7 :))

#

only difference is that bot don't use discord.js-commando package

#

and this bot is not like that bot (not reset when have errors)

earnest phoenix
#

Auto resetting is not a solution, it can hit the 1,000 login limit and not be able to connect to the gateway again until another day

#

There's no reason to not update

crystal furnace
earnest phoenix
#

Then why not do the same to the other bot(s)?

#

It shouldn't take much time

crystal furnace
earnest phoenix
#

You don't need to entirely rewrite, you'll only be changing a few things and that's mostly it

#

You can refer to the official discord.js guide on what to change

crystal furnace
#

I am not a pro, honestly

#

My university tests / exams is more than code lines of my bot :))

#

But very thank you bro

#

You helped me so much, I feel better now

earnest phoenix
#

Alright, you're welcome

crystal furnace
#

In 2020, I reached that a time

earnest phoenix
crystal furnace
earnest phoenix
#

It mostly doesn't consider shards because bots could have a lot of them, so they would hit that ratelimit very quickly if it counted the shards as well

#

I think it's just the main instance that counts

#

Or it may count the shards as well, not sure

lyric mountain
quartz kindle
#

if you have 10 shards and a login limit of 1000, after starting your bot, your login limit is now 990

#

resumes dont count

crystal furnace
#

@quartz kindle if a bot have more than 1000 shards like MEE6?

#

How can they reconnect all the bot if they want?

lyric mountain
#

once you get a high amount of shards you can request a higher connection limit

quartz kindle
#

so when you get to 1000 shards, your login limit is like 5000-10000 or even more i dont know

#

you also get a bigger "max_concurrency" which lets you login multiple shards at the same time, so it doesnt take too long

#

heres the actual numbers from tje docs

#

The session start limit for these bots will also be increased from 1000 to max(2000, (guild_count / 1000) * 3) per day. You also receive an increased max_concurrency, the number of shards you can concurrently start.

neon leaf
#

idk why I dont check myself but is interaction.user.id a number or a string?

quartz kindle
#

in djs its always string

neon leaf
#

good

#

is there any easy way to migrate a mongodb database to mysql/mariadb?

quartz kindle
#

read all entries, for each entry write entry to new db

neon leaf
#

ig that makes most sense

#

thanks

lyric mountain
#

use mariadb if u must

#

or postgres if possible

neon leaf
#

i do

#

i dont

lyric mountain
#

mysql is just too much trouble to be worth it

neon leaf
#

im on maria, I dont think postgres will benefit me at all

lyric mountain
#

I mean, postgres has a much better support and scalability

neon leaf
#

but it doesnt use sql, correct? actually no, it has sql in the name, right?

lyric mountain
#

postgresql

neon leaf
#

well would my code for maria straight up work with it?

quartz kindle
#

90% of it probably yes

lyric mountain
#

if anything it'd be just minor adjusts to fit

neon leaf
#

what wouldnt? I dont think I use anything advanced, just write and mass reads

lyric mountain
#

for example, you don't declare collations on postgres

#

they don't even exist there

neon leaf
#

I dont even know what that is so, ... I think thats fine lol

lyric mountain
#

see, you'd be in trouble with mysql already lul

quartz kindle
#

lmao

lyric mountain
#

really, I don't know why the hell they thought it'd be a good idea to have something like that

quartz kindle
#

collate unicode mb4 ci black magic

neon leaf
#

would these still work on postgres?

exports.set = (userid, value) => new Promise(async ful => {
    const data = await db.query(`select * from usermoney where userid = ?;`, [userid])
    if (typeof data[0] === 'undefined') {
        await db.query(`insert into usermoney value (?, ?)`, [
            userid,
            value
        ]); return ful('Y-CREATE')
    } else {
        await db.query(`update usermoney set money = ? where userid = ?;`, [
            value,
            userid
        ]); return ful('Y-WRITE')
    }
})

// Add Function
exports.add = (userid, value) => new Promise(async ful => {
    const data = await db.query(`select * from usermoney where userid = ?;`, [userid])
    if (typeof data[0] === 'undefined') {
        await db.query(`insert into usermoney value (?, ?)`, [
            userid,
            value
        ]); return ful('Y-CREATE')
    } else {
        await db.query(`update usermoney set money = money + ? where userid = ?;`, [
            value,
            userid
        ]); return ful('Y-WRITE')
    }
})```
lyric mountain
#

pretty much

#

that's standard sql

quartz kindle
#

but youll need to check how your postgres library works in js

#

most differences are gonna be from differences between how the libraries chose to interface with the db

#

not the sql code itself

lyric mountain
#

btw I think it might error if u try to use query for inserts/updates

neon leaf
#

I dont have any errors

quartz kindle
#

btw you dont need to create a new promise there

lyric mountain
#

in postgres lib I mean

neon leaf
#

ah

lyric mountain
#

since they're non-returning operations

quartz kindle
#

just make it an async function

neon leaf
#

whats the most similar library for postgres in js to mariadb?

lyric mountain
#

usually you have something like execute or executeUpdate for insert/update/delete

quartz kindle
#

exports.add = async function(userid, value) { ... }

#

no need for new promise

lyric mountain
#

actually, it might be a literal fit for ur current code

#

($1::text is just CAST($1 AS TEXT) but shorthand)

neon leaf
#

this is my current:

const config = require('../../config.json')
const mariadb = require('mariadb');
const pool = mariadb.createPool({
    host: config.mariadb.oxbot.host, 
    database: config.mariadb.oxbot.database,
    user: config.mariadb.oxbot.username, 
    password: config.mariadb.oxbot.password,
    connectionLimit: 100
}); let db
pool.getConnection()
.then(botconn => { db = botconn })```
lyric mountain
#

the code u sent earlier I mean

neon leaf
#

ah

lyric mountain
#

also apparently, it allows using query for I/U/D too

#

anyway, that documentation I sent explains it pretty well how to use it

neon leaf
#

is this it?

const pool = new Pool({
  user: 'dbuser',
  host: 'database.server.com',
  database: 'mydb',
  password: 'secretpassword',
  port: 3211,
}); const client = new Client({
  user: 'dbuser',
  host: 'database.server.com',
  database: 'mydb',
  password: 'secretpassword',
  port: 3211,
})
client.connect()```
#

wait

#

I only need client I assume?

lyric mountain
#

pool is probably for creating a connection pool

#

which is better if u have high concurrency in ur database

#

otherwise client is fine

neon leaf
#

ig ill first worry about setting up the db

lyric mountain
#

Connection pool is basically many connections open at once so it can balance requests

#

Effectively the same as djs shard manager

neon leaf
#

ok so I have this;
const { Client } = require('pg')
but I am already using the Var Client bor djs, how do I get the pg one under a different name?

lyric mountain
#

I think u can use aliases in imports

#

Client as db

#

Or smth

neon leaf
#

that only works for actual imports

lyric mountain
#

Ah, require, just noticed

#

Check google if there's any way to solve that

earnest phoenix
#
const { Client: Foo } = require('bar');

For example

neon leaf
#

I think I got it

earnest phoenix
#

You can just use the : after the destructed value to give it a different name

neon leaf
#

yeah, ill do that

#

so I have this sql code, and it errors in postgres. why?
code:


module.exports = {
    data: {
        "name": migna
    },
    async migrate(db) {
        // Check if Migration has already occured
        let status
        try {
            status = await db.query(`select * from migrations where id = '${migid}%';`)
        } catch (e) {
            await db.query(`create table migrations (id int, name text)`)
            await db.query(`insert into migrations value (${migid}, ?)`, [migna])
            return true
        }; return false
    },
};```
error:
https://paste.rjansen.de/Jlb9owVsDd
#

ok so it created the table but couldnt write the data

#

nvm, I have to use values instead of value and $1, $2, ... instead of ?

lyric mountain
#

ah yes, it's usually enforced by libs to use either named or indexed parameters

quartz kindle
#

most libs should support both

#

bad lib if it doesnt :^)

lament rock
#

Ah yes. The pg lib will compile the statement to test it :)

lyric mountain
#

they started doing that after some incidents where param order wasn't in the expected positions

quartz kindle
#

lmao

wheat mesa
#
try {

} catch(e) {

}
``` is semantically correct, and causes no confusion with the compiler
slender wagon
#

clonning a github repo but getting these errors

wheat mesa
#

I think it's funny that you didn't use semicolons for the things that technically need them though lol

earnest phoenix
slender wagon
#

yeah i meant

#

i clonned it successfully

#

running it

#

but getting that shit error

#

my brain is too smooth

#

always stripe throwing such errors

earnest phoenix
#

Remove the node_modules directory and the package-lock.json file and run npm update --save, it should update the dependencies and get rid of the non-existent dependency

slender wagon
#

right

#

and there is none of that

earnest phoenix
#

Then just go ahead and run the command

slender wagon
#

maybe
@stripe/react-stripe-js@1.1.2
wants another version of react

earnest phoenix
#

It wants a non-existent version, which causes it to not be resolved

#

If running npm update --save doesn't fix it, you would have to run npm outdated and update the versions from the package.json file manually

slender wagon
#

Package subpath './lib/parser' is not defined by "exports"

#

errors love me

deft rock
#

Im drawing a blank.... how do I get my bot to show how many users are using the bot? (d.js V14.6.0) Ping or dm me thx

solemn latch
#

Using the bot?

in what way?
IE used a command ever? used a command in the last minute? currently listening to music?

Using can mean many things

deft rock
#

Love the name. But that aside I'd like it in my status. I have the server part down but the members I'm not getting atm

lyric mountain
#

so you want the total count of users that your bot can see (not necessarily that use your bot)?

deft rock
#

yes

lyric mountain
#

just iterate over each server and get memberCount

deft rock
#

I tried memberCount and it is undefined

#

id like it like
Watching over (users) members in (guilds) servers

hidden gorge
#

`const { SlashCommandBuilder } = require('@discordjs/builders')
const Discord = require('discord.js');
const { parse } = require('path');

module.exports = {
data: new SlashCommandBuilder()
.setName('sticky')
.setDescription('Create a sticky message')
.addStringOption(option =>
option.setName('input')
.setDescription('What do you want as your sticky message?')
.setRequired(true)),

async execute(interaction, exports) {

let maxStickMessageCount = 10
let messageCount = 0
let lastStickyMessage = ""
let stickyMessageContent = "";
let stickyMessageChannel = "";


if(!contentToStick) return interaction.reply("You must provide a valid string.")

if(interaction.member.roles.cache.has('877653550027636787')) {
    let getStickyMessage = interaction.options.getString('input');
    let contentToStick = interaction.options.getString('input');

    messageCount++

    if(messageCount > 10) {


    if(interaction.member.roles.cache.has('877653550027636787')) {
        try {
            stickyMessageChannel = interaction.channel.id;
            stickyMessageContent = contentToStick.slice(0).join(" ");
            lastStickyMessage = await interaction.channel.send(stickyMessageContent);
        } catch (error ) {
            console.error(error);
        }
    }
        }
    }
}

}`

deft rock
#
client.user.setActivity(`over ${memberCount} members in ${client.guilds.cache.size} servers`, { type: ActivityType.Watching });

This is my code

lyric mountain
#

memberCount what? bananas? apples? cars?

deft rock
#

ok, so what should i do?

lyric mountain
#

<guild>.memberCount over each guild

#

summing it to a total variable

deft rock
#

would I have to define guild tho?

lyric mountain
#

loop over client.guilds.cache

deft rock
#

ok let me try that brb

lyric mountain
deft rock
#

so either im stupid or did it wrong. its still undefined

lyric mountain
#

show how u did

boreal iron
#

Just show what u did

deft rock
#
 client.user.setActivity(`over ${client.guilds.cache.memberCount} members in ${client.guilds.cache.size} servers`, { type: ActivityType.Watching });
lyric mountain
#

sigh

boreal iron
deft rock
#

😅

boreal iron
#

He said iterate though it

lyric mountain
#

when I say "loop over it" I literally mean it

boreal iron
#

Where’s your loop

deft rock
#

im new to this activity stuff so idk how to loop it

lyric mountain
#

that's not an activity stuff

#

that's basic js

#

actually

#

that's basic programming

deft rock
#

I dont think ive looped before

boreal iron
#

for(const [id, guild] of client.guilds.cache) …

deft rock
#

that or ive used a different word than loop

boreal iron
#

Access memberCount inside on guild

deft rock
boreal iron
#

Add it to a var you created outside the loop

#

total_count = 0
loop->total count += guild member count
activity->show total count

#

That’s the order

deft rock
#

ok ill try that

lyric mountain
#

funny enough, that'd be valid in groovy (client.guilds.cache.memberCount.sum())

#

I love how many shortcuts are in groovy

quartz kindle
#

groooooooooveh

boreal iron
#

Sounds weird

#

Like goofy

sharp geyser
#

You’re goofy

neon leaf
#

how can I check if a user still exists in djs v14? aka if he deleted his account or not

#

actually, how do I just check if a user is in guild X

rustic nova
#

the second one is a little more difficult depending on if the user is cached or not

#

the first one is a little easier, deleted accounts often have same features: "deleted user", default avatar

#

they're never actually deleted

neon leaf
#

what about the second one though? I dont need the results to be 100% accurate

earnest phoenix
#

@neon leaf

  1. You can fetch the user using the <Client>.users.fetch() method to see if they exist, the method is likely to throw an error if the user no longer exists as the API will return Unknown User
  2. You can also fetch the user from the aforementioned guild using the <Guild>.members.fetch() method, if it doesn't exist an error will be thrown, otherwise the guild member will be returned
#

You don't have to worry much when fetching users/members (ratelimit reasons) because the cache is checked first before fetching, so if they already exist a new request won't be made

neon leaf
#

btw, is this inefficient?

#

it takes like 2 seconds to run

spark flint
#

Isn’t .map more effective

earnest phoenix
#

It absolutely is inefficient

  1. Just use a traditional for loop (for-i) and iterate through the next 10 elements as that's what you're looking for
  2. You should handle errors that can be thrown from the <Client>.users.fetch() method
  3. For string concatenation you can just use +=
  4. ${'`'} -> \`
prime mist
earnest phoenix
# spark flint Isn’t .map more effective

They're fetching a user inside each iteration, and since <Array>.map() doesn't wait for promises to be resolved, it'll return unresolved promises unless you use something like Promise.all()

spark flint
#

Ah ok

neon leaf
#

I only want to loop 10 times if 10 results match, so If the user selected local baltop it checks if the user in baltop is on the same server first

prime mist
#

You should probably add a limit to your query as well.

#

If you had 1000 users, it would get every single one. When you only want 10

neon leaf
#

I need all users though, else I cant be sure im getting all for a local server

neon leaf
#

man I cant think of anything to not need to fetch every user to check if they are still in the guild. Ig starting again may help, whats the best way to make a local baltop command?

slender wagon
#

how do i make the timer thingy on discord with unix time

neon leaf
#

<t:unixtime:R>

#

<t:1665550936:R>

slender wagon
#

how do i make it a countdown

#

i forgor

neon leaf
#

it is already one

slender wagon
#

1665650096

#

<t:1665650096:R>

#

ohoh

#

ty

quartz kindle
#

as for making sure the user is still in the guild, the only way is to use the member events, but for that you need the members intent

#

so on memberDelete you remove it from your database

#

if you dont have the members intent, then the only way is to fetch the member every time

neon leaf
#

oh my, how havent I thought about it that way, but how do I store all guilds a user is in?

quartz kindle
#

you can store it in an array

#

most databases do not support array columns directly tho

neon leaf
#

does postgres have array- ah

quartz kindle
#

some dbs suport json columns

#

i believe postgres does support arrays

neon leaf
quartz kindle
#

ye

neon leaf
#

whats the best way to assign all currently existing user their guilds?

rustic nova
#

I mean theres nothing stopping you from using one that doesnt, but placing the json data into a string based field

rustic nova
#

aswell as there being a possibility of users being in multiple guilds of your bot

quartz kindle
#

theres no real way to do that other than trying to fetch the same user id from every guild and ignore the ones that failed lol

#

unless you have the members intent

neon leaf
#

I think I have the members intent, im currently fetching and it works

rustic nova
#

then:

Loop through guilds, fetch members, add to array

quartz kindle
#

but can you fetch all members from a guild?

#

like guild.members.fetch() without any id

#

to cache everything

neon leaf
#

what is guild? interaction.guild?

quartz kindle
#

for example yes

neon leaf
#

but it didnt error either

rustic nova
#

depends on guild count and member count

neon leaf
#

like 40 members in the guild I executed the cmd in

rustic nova
#

yeah that shouldnt take that long

#

print out the length of the members you fetched

neon leaf
rustic nova
#

if its 0 or something below 40, you might not have the intent

#

is the Members intent on your code enabled too?

neon leaf
#

ig not

rustic nova
#

yeah missing an extra intent

neon leaf
#

GuildMembers?

rustic nova
#

also while you're at it, make sure that intent is also enabled on discords end

#

yes

neon leaf
#

yup, works

neon leaf
#

and would this be correct for the sql syntax?
select * from usermoney where $1 = ANY(guilds) order by money DESC

rustic nova
#

would fetch everything where guild id is any of your guilds, then order it by the money field descending

#

is guilds a list of ids?

#

aka the field with the ids?

severe lance
#

Does anyone know how to disable temp time limit?

neon leaf
#

yes

rustic nova
#

then should work, otherwise test-execute it

rustic nova
#

also @neon leaf even if it doesnt make much of a difference, consider defining the fields you'd want instead of *

#

could make your queries a tiny bit faster

#

unless literally all of it is what you need

neon leaf
#

I need every one though so ig not

rustic nova
#

lmao alright

neon leaf
#

there are only userid, guilds and money

rustic nova
#

fair fair

neon leaf
#

would this work?
```const rawvalues = await db.query(select * from usermoney where $1 = any(guilds) order by money DESC, [interaction.guild.id])
for (const element of rawvalues.rows) {
if (count >= 10) break

            let skip = false
            await interaction.guild.members.get(element.userid).catch((e) => skip = true)
            if (!skip) {
                count++
                let formattedcount = count
                if (count < 10) { formattedcount = '0' + count }
                embedDesc = embedDesc + `\`${formattedcount}.\` » <@${element.userid}> (**${element.money}€**)\n`
            }
        }```
rustic nova
#

thats something you gotta ask someone with js knowledge, @quartz kindle come back here

quartz kindle
#

order by money DESC LIMIT 10

#

.catch doesnt exist on .get()

neon leaf
#

do you know how to remove something from a psql array by content?

#

I currently got this far

quartz kindle
#

once you have all members cached, after you used guild.members.fetch(), you can loop over all members and add their guilds to your database

#

from there on, you can use the memberAdd and memberDelete events to manage them in your database

#

no need to always fetch them

neon leaf
#

yeah, but how exactly do I edit the array?

rustic nova
quartz kindle
neon leaf
#

this should be it for leaving then, right?

#

would this be it for adding?

quartz kindle
neon leaf
#

couldnt I just use $1 for both?

quartz kindle
#

$1 is guid id, $2 is user id

neon leaf
#

oh

#

forgor that lol

#

like this?

quartz kindle
#

do you plan to keep the members in your database even after they leave everywhere?

#

like if you have a user with 0 guilds remaining

neon leaf
#

yes

#

I dont care about 600bytes being wasted

quartz kindle
#

alright

#

so on the guildMemberAdd you need an upsert

#

add if it doesnt exists, update if it does

neon leaf
#

im currently confused by myself, so I have a file with money functions so I only have to edit them once, couldnt I just do the entire adding part in there if the guild isnt in the array when the bot wants to add / set money?

quartz kindle
#

something like this
INSERT INTO usermoney (userid, money, guilds[]) VALUES($1,0,{$2}) ON CONFLICT (userid) DO UPDATE SET guilds = array_append(guilds, $2)

#

where $1 is the userid and $2 the guild id

#

and you also need to prevent duplicates

#

although it should never happen, its possible you receive a guildMemberAdd for a user that is already in the guild in your db

swift path
#

Owo vote

quartz kindle
#

either due to discord bugs, or they joined/left when your bot was offline

swift path
#

OWo s 9999

#

Owo vote

rustic nova
#

we do not have owo here

swift path
#

Wvote

rustic nova
swift path
#

Owo vote

neon leaf
#

was able to migrate everything with this terrible code

        console.log(Guilds); for (const element of Guilds) {
            const guild = await client.guilds.fetch(element)
            const members = await guild.members.fetch()
            for (const element of members) {
                console.log(element)
                const data = await db.query(`select * from usermoney where userid = $1`, [element[0]])
                if (data.rowCount === 1) {
                    await db.query(`update usermoney set guilds = array_append(guilds, $1) where userid = $2`, [guild.id, element[0]])
                }
            }
        }```
crystal wigeon
#

hey has anyone used "google-spreadsheet" npm package?

#

how do i update a row with some condition

flat copper
#
var utterance = new window.SpeechSynthesisUtterance('Hello Treehouse');
    utterance.onstart = function(event) {
      alert('The utterance started to be spoken.')
    };
    window.speechSynthesis.speak(utterance);

    utterance.onerror = function(e) {
      alert(e)
    }

its is not working , in express js

radiant kraken
#

@solemn latch hi woo

solemn latch
#

@earnest phoenix no ads/self promotion please

neon leaf
#

is there any website that makes it easy to make a base with canvas?

#

because I want to make a level card

solemn latch
#

A base? as in the base layers?

You could make one in MS paint if you really wanted to.

neon leaf
#

so you can import images into canvas?

solemn latch
surreal sage
#

What does ... do in js?

#

Like [...new Set([])]

solemn latch
quartz kindle
#
[...x]
``` is pretty much the same as doing ```js
n = [];
for(const item of x) {
  n.push(item)
}
#

but there is also this ```js
function(...x) {}

#

its the same as ```js
function(a,b,c,d) {
const x = [a,b,c,d]
}

cursive musk
#
RangeError: Invalid count value
    at String.repeat (<anonymous>)
    at /home/container/src/commands/information/help.js:209:37
    at /home/container/node_modules/discord.js/node_modules/@discordjs/collection/dist/index.js:1:3113
    at Function.from (<anonymous>)
    at Map.map (/home/container/node_modules/discord.js/node_modules/@discordjs/collection/dist/index.js:1:3053)
    at module.exports.run (/home/container/src/commands/information/help.js:203:12)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async module.exports.runCommand (/home/container/src/events/message/messageCreate.js:302:5)
    at async module.exports.run (/home/container/src/events/message/messageCreate.js:276:9)
#

I am so confused as to why this is happening because of my help command.

wheat mesa
#

help.js line 209 column 37

#

That’s about all I can give you with what you posted

cursive musk
#
      return message.channel.sendCustom({ embeds: [embed] });
    } else if (
      (args && args[0].toLowerCase() == "config") ||
      (args && args[0].toLowerCase() == "configuration")
    ) {
      embed.setTitle(` ${emojis.config} - Config`);
      embed.setDescription(
        this.client.botCommands
          .filter((cmd) => cmd.category.toLowerCase() === "config")
          .map(
            (cmd) =>
              `${
                cmd.disabled || disabledCommands.includes(cmd.name || cmd)
                  ? red
                  : green
              } \`${cmd.name} ${" ".repeat(14 - Number(cmd.name.length))}:\` ${
                cmd.description
              }`
          )
          .join("\n")
      );

      embed.setFooter({
        text: `Requested by ${message.author.username}`,
        iconURL: message.author.displayAvatarURL({ dynamic: true }),
      });

      embed.setTimestamp();
      embed.addField(
        "\u200b",
        "**[Invite](https://universebot.xyz/invite) | " +
          "[Support Server](https://universebot.xyz/support) | " +
          "[Dashboard](https://universebot.xyz/dashboard)**"
      );
wheat mesa
#

repeat count must be non negative

#

14 - length is likely negative

cursive musk
#

Weird thing is that it's working on my testing bot

#

but not on my main

#

see

wheat mesa
#

Well cmd.name.length is greater than 14

cursive musk
wheat mesa
#

¯_(ツ)_/¯

#

I just know what’s wrong with the code you posted, that’s all I can speak for

quartz kindle
#

also, you can just use padding

#

you dont need to use repeat

#

cmd.name.padEnd(14, " ")

earnest phoenix
#

how was it to make the bot recognise caps and no caps? a regex? like I send !e and !E, bot will reply with same message

wheat mesa
#

.toLowerCase()

lament rock
#

alternatively, use slash commands

knotty quartz
#

Deploy-commands error

#

Its actually is getting on my nerves.

#

Fixed

neon leaf
#

what
TypeError: AttachmentBuilder is not a constructor