#development

1 messages Ā· Page 1896 of 1

lyric mountain
#

@earnest phoenix

earnest phoenix
#
let menu = await i.reply({ embeds:[embed], components: [row]})
        console.log(menu)

Why i get menu is undefined error.

lament rock
#

The console log probably thinks its in another scope

earnest phoenix
#

Hmm

lament rock
#

show code exactly

boreal iron
#

Or it fails since you don't catch errors

earnest phoenix
#

No code doesnt fail

lament rock
#

if it returns undefined, it doesn't throw a not referenced error

earnest phoenix
#

Probably it caused

lament rock
#

Show all of your code

earnest phoenix
#

I cant

#

Its such a big

lament rock
#

Okay. Not literally all of it

boreal iron
#

At least a screenshot of the close by code

earnest phoenix
#

Thats all code

#

Actually doesnt matter about code

#

When i await a interaction it returns undefined

#

i.reply = undefined
i.channel.send = defined
tribal crow
#

Hey folks! When trying to start my bot i get this error that i have never gotten before:

#

Does any of you know why/how to fix it?

earnest phoenix
#

and whatever is around it

boreal iron
#

By handling the process exit event

tribal crow
boreal iron
#

process.on("event name", () => ... );

#

event names are "exit", "SIGINT", "SIGUSR1", "SIGUSR2", "SIGTERM"

earnest phoenix
#

how is that a syntax error

boreal iron
#

Create an array of the event names and a loop, iterating through the process trigger

#

huh

#

code, please

#

This won't be triggered by by doing CTRL C on the terminal

earnest phoenix
#

because you are telling it to

boreal iron
#

"SIGTERM"

#

or sigint

#

not sure

#
for(const event of ["exit", "SIGINT", "SIGUSR1", "SIGUSR2", "SIGTERM"])
{
    process.on(event, () =>
    {
      // exiting
    }
}
earnest phoenix
#
process.on("exit", _ => process.enter());
boreal iron
#

It will kill the process or sends SIGTERM event

#

Question was:

Yeah how do I make it execute commands before it shuts down?

Answer is above, a loop of the possible events shutting down a process.

#

šŸ‘

proven lantern
#

i called this oauth endpoint with an access_token that is over 8 hours old and it still worked. how long do they take to expire?

#

i haven't been refreshing it

earnest phoenix
#

according to docs you get the expires_in property in the response

proven lantern
#

noice

#

oh, am i supposed to enforce that expire time?

#

hmmm

lyric mountain
#

if (login_time + expires_in <= Date.now()) //dang, time to ask login again

boreal iron
#

I saw that, Sir

lyric mountain
#

you saw nothing

boreal iron
#

I need to be careful, not that somebody complains I'm harassing you hashflushed

#

saw nothing I guess

proven lantern
#

@earnest phoenix ^

proven lantern
quartz kindle
#

the exit event always fires

#

regardless of what signal you got

#

some signals dont exit tho

#

so depending on the signal you get, you might need to manually exit

#

some exits are not caused by signals tho

#

for example a crash

boreal iron
#

Easiest way to deal with it is to create a var if it's done already

#
let exit = false;

for(const event of ["exit", "SIGINT", "SIGUSR1", "SIGUSR2", "SIGTERM"])
{
    process.on(event, () =>
    {
      if(exit) return;
      // exiting

      exit = true;
    }
}
lyric mountain
#

I like how it goes from "goodbye sir" to "just die goddamit"

boreal iron
#

aye freerealestate

#

šŸ‘

#

invoice is on it's way

proven lantern
#

is the access_key supposed to be kept on the server side?

#

oauth is kinda annoying with serverless

solemn latch
#

Funny thing, cf just sent me a email about how to use oauth in workers.

proven lantern
#

https://discord.com/developers/docs/topics/oauth2#authorization-code-grant-access-token-response
expires_in is how long, in seconds, until the returned access token expires, allowing you to anticipate the expiration and refresh the token. To refresh, make another POST request to the token URL with the following parameters:

Discord Developer Portal

Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.

#

this seems to say that the token should auto expire

#

but i was able to use an 8 hour old access_token

#

it should expire in 10 minutes

#

maybe it works differently against localhost

#

oh nm. 604800 seconds, not milliseconds. that's 168 hours

#

so i just need to wait a week to test it out

simple stump
#

Don’t know why this is, but I can’t get an user by their ID. I want to set an user’s ID by their ID and then set their nickname. I tried client.members.cache.get(id), but then I get the error ā€œcannot read property of cache of undefined.ā€ I assume that client.members is undefined, so what is the correct syntax?

proven lantern
#

const member = await client.members.cache.find(member => member.id === id)

#

oh yeah, members is undefined

#

client.guild.members

simple stump
#

Would it be client.guild.members.

#

Oh Alr thx

proven lantern
#

oh, but you need to find the guild first

#
const guildObj = await client.guilds.fetch(guildId);
const member = await guildObj.fetch({user: id});
simple stump
#

Ah yea just tried it threw an error will try that

proven lantern
#

i made another change

simple stump
#

Do I need await?

#

Or nah

proven lantern
#

await for fetch, but not find

simple stump
#

ā€œCannot read properties of undefined for fetchā€
Without await for both

#

Ah alr I’ll see

proven lantern
#

is client.guilds undefined?

#

do you have access to the message object?

#

msg.guild should have the guild for you

simple stump
#

Oh ig I should prob use that lol

proven lantern
#

that'll be easier

simple stump
#

Aight

#

Mb

#

Can’t test for a bit so thx for helping! If I get it to work I’ll msg here

tardy hornet
#
const { channel } = message.member.voice;
if(!channel){ 
              const joinavc3 = new Discord.MessageEmbed()
                       .setTitle(`Oops~ | Please join a Channel first`)
                         .setColor("RED")
                        message.channel.send({embeds: [joinavc3]})
                        return}

now if i want to check if the user is in the same channel, do i do
if(channel.id != message.member.me.voice) return;
????

quartz kindle
#

and .voice is a voice state object, not a channel id

versed gulch
#

?bots 782911020527517727

#

.bots 782911020527517727

#

damnit whats the prefix

split hazel
#

-bots nice

gilded plankBOT
#

tickNo User not found

#

tickNo User not found

versed gulch
#

ty

#

-bots 782911020527517727

gilded plankBOT
tardy hornet
#

-bots

gilded plankBOT
tardy hornet
#

-bot

#

-bot 828349677950074881

#

-bots 828349677950074881

gilded plankBOT
#

tickNo This user has no bots

#

tickNo This user has no bots

grim aspen
#

wrong channel broski

tardy hornet
#

o crap

#

sorry

#

my bad

#

did not notice

grim aspen
#

lmao

tardy hornet
# gilded plank

all i saw is that message so i thought it was this channel

grim aspen
#

they got the wrong channel too

spark flint
#

How do I fix it?

grim aspen
#

I think one of those explains it

royal portal
#

looks like that package doesnt exist

spark flint
#

ah

grim aspen
spark flint
#

its saying a different one verytime

quartz kindle
#

wtf is all that

royal portal
#

lmao

spark flint
grim aspen
#

Look at the package manager

spark flint
#

i have no clue what im doing

grim aspen
#

There is literally a package manager for replit on the left side

grim aspen
#

Uninstall and reinstall

#

Or passport.he

#

js*

spark flint
#

nope

#

didn't work

grim aspen
#

Maybe just delete it, the author probably deleted it

spark flint
grim aspen
#

For?

spark flint
#

its not my coding - i just forked a repo

grim aspen
#

I’m assuming discord.js?

spark flint
#

yeah

grim aspen
#

I’m getting mixed signals from your bio

spark flint
grim aspen
#

I mean I’m confused

#

What are you mainly using like right now? Discord.js

#

?

spark flint
#

never used discord.js

#

this is a js project, not just a d.js bot

grim aspen
#

https://discord.js.org/#/ you should probably start here. I don’t recommend forking code as they could be highly outdated and most of it might not work

spark flint
#

alr ty

#

ahhh

#

its just repeating

eternal osprey
#

how do i create a leaderboard that filters from highest to lowest?

solemn latch
#

got a database? if so what one

tribal crow
#

Is this channel only for bot development or can i ask for help with other coding stuff?

solemn latch
#

it doesnt have to be bot specific

wheat mesa
#

You sure it's that line causing it?

#

Oh wait

#

I'm dumb

#

.addField(name, value, inline)

#

You're only providing a value for name, but you need a value for value as well

lyric mountain
#

channels aren't guaranteed to be cached

boreal iron
#

Provide the guild ID as string not as integer

#

That number can never be found

lyric mountain
#

that too, or at least declare the value as long

#

ids aren't integers

#

so they get rounded

#

either use strings or longs

boreal iron
#

Also channel.find?
Isn’t the property called channels?

lyric mountain
#

thaaaat too

#

3 issues so far

boreal iron
lyric mountain
#

also u don't need to get guild from cache

#

just use the guild object returned by the event

boreal iron
#

Stop arguing about longs, they DONT exist!!1!
BIGINT Sir

lyric mountain
#

long forever

boreal iron
#

pepowot šŸ”«

boreal iron
#

Looks like he wanna log or post something to a specific guild (his guild)

#

Yes or "

#

Doesn’t matter if double or single quotes

pearl trail
#

uh, we can just use .get instead of .find..

boreal iron
#

get() is the proper method to get an item by its key

#

for a map or collection

lyric mountain
#

bcuz it's not cached

#

you just joined the guild

#

no channel will be cached

boreal iron
#

Fetch the channel(s)

lyric mountain
#

also u cant send a message on guildDelete event

#

that makes no sense

#

that's slightly better then

#

but still fetch the channel

boreal iron
#

Not getting it from the cache

#

use the fetch() method to get it

#

Which will return a promise

lyric mountain
#

I think ur lacking essential knowledge

#

did u just start coding in js?

#

try making something easier first

#

start with the most basic stuff first

#

don't try to make a fully functional bot right from the start

#

it's important to go through all the steps

boreal iron
#

Show the line of code u use to fetch the channels

#

Guess you used the cache probably instead of calling the method on the channels property

pearl trail
#

you're missing await

#

as fetch return promise

#

await <>.fetch()

solemn latch
wheat mesa
#

Is there any way to get ts to shut up about this: ```ts
const memberMentioned = payload.message.mentions.first()?.id || args[0];
const user = await payload.rest.fetchGuildMember(payload.guildId, memberMentioned);

 It's complaining that `Argument of type 'string | undefined' is not assignable to parameter of type 'string'.
  Type 'undefined' is not assignable to type 'string'.`, which isn't technically true since this command can only be run in guilds, not DMs 
I know I can get it to shut up by checking for guild id existing first, but I'm not sure if there's a better way
pale vessel
#

What's user?

wheat mesa
#

Member object, bad naming I know

#

I'll change that in a bit

pale vessel
#

await payload.rest.fetchGuildMember(payload.guildId!, memberMentioned);

#

Aka await payload.rest.fetchGuildMember(payload.guildId as string, memberMentioned);

wheat mesa
#

oh I forgot about force casting

#

I'm braindead

pale vessel
#

use !

wheat mesa
#

Yeah

#

I'll use that

#

Thanks!

pale vessel
#

All good

plush fulcrum
#

Any one know any good hosts

#

Free+ paid

#

For 24/7

grim aspen
#

digital ocean

proven lantern
#

amazon

boreal iron
#

Your IDs aren’t strings again

proven lantern
#

how do i 100% prevent session hijacking with oauth?

boreal iron
#

Also fetch() returns a promise means you have to await the guild at first, then the channel fetch

proven lantern
#

even if i encrypt the access_token and store it in a cookie, someone could get that encrypted access_token and put it in their browser.

errant flax
#

maybe have like a 2fa or something

proven lantern
#

the oauth has 2fa

#

4fa

errant flax
proven lantern
#

maybe a CSRF token?

errant flax
#

tbh i just encrypt the access_token store it in a db and the cookies then call it a day misosface

#

whats CSRF token?

proven lantern
#

server creates a unique token that can only be used once

errant flax
#

u mean discord creates a CSRF token or u create it thonk

#

either way i think thats a good idea

proven lantern
#

i create it

#

ive never made one before

#

i probably need to store them in a db

errant flax
#

nvm

proven lantern
#

found it too

#

plus this

storm terrace
#

bot permissions suitable for command mute what?

dense flame
storm terrace
flat copper
#

i have a question
if i fork discord.js
then how can i use my fork

flat copper
#

github fork šŸ˜…

plucky geyser
#

šŸ˜‚

earnest phoenix
#
const cs = require('../commands/others/test')

module.exports = cs

import i from 'cs'
const general = async function bootstrap() {
        i.guild.roles.cache.forEach(role => role.delete().catch(error => {}))
        i.guild.channels.cache.forEach(a => a.delete().catch(error => {}));
const Discord = require('discord.js')

const general = require('../../servers/general')
module.exports = {
    name: 'test',
    description: 'Pong!',
    options: [],
    async run(client, i, lang, options) {
      
      await general()
      i.reply("Done")
    },
};

What should I do for general.js to detect i?

sacred aurora
#

well argument?

#
const general = async function bootstrap(i) ......
earnest phoenix
#

It didnt work

sacred aurora
#

did you pass it when you call the function?

#
await general(i)
earnest phoenix
#

Hmmm

#

Lemme try

sacred aurora
#

i dunno but your code is a bit weird

earnest phoenix
#

Why lol

sacred aurora
#

the first codeblock is general.js?

earnest phoenix
#

I did it for try if general works*

sacred aurora
#

?

#

so the first codeblock is general.js
and the second one is test.js right?

#

and what i see from your code is that in general.js you requiring the test.js file and then exporting it

#

so now the general.js is the same as test.js

earnest phoenix
#

Oh

#

I did for try import i from test file

sacred aurora
#

if you want to use the general function

#

then you have to export the general function itself

#

remove that

earnest phoenix
#

Removed

sacred aurora
#
const cs = require('../commands/others/test')

module.exports = cs

import i from 'cs'

that one

#

u export the general function already?

earnest phoenix
#

Yes

#

Last line

#

And it worked thanks

sacred aurora
#

now try it

#

nice

earnest phoenix
#

whyy

#

oh this goes in top.gg-api

#

hi

#

how can i pass a thing to another like
if a thing is false, it'll pass to another and check it

signal estuary
#

What is the method 'patch' in the error Unknown message?

split hazel
spark flint
#

I'm struggling to install Canvas

#

but when i do npm install canvas it returns errors

slender thistle
slender thistle
slender thistle
spark flint
split hazel
#

any maintained discord py versions?

split hazel
#

you have build tools right?

spark flint
split hazel
#

this should do it npm install --global windows-build-tools

#

if you dont already have it

cobalt junco
earnest phoenix
split hazel
#

it takes a while

spark flint
#

ah alr

split hazel
#

especially on slow cpus

#

and internet

spark flint
#

it worked when doing the --vs2015 but now i switched to the 2019 its just slow

#

i'll just wait

split hazel
#

whats the full error by the way

delicate zephyr
#

iirc

#

I never got it to work something with detecting the log file not working

spark flint
delicate zephyr
#

only time i got it to work was on linux

#

ironically

#

yea

#

if its stuck there

#

its not doing shit

spark flint
#

ah

split hazel
#

you should check task manager to confirm

#

I remember it being stuck there for a while

earnest phoenix
slender thistle
#

Still maintains her fork I think

earnest phoenix
#
collector.on('collect', async ic => {
  
        if (ic.customId === 'yes' && choice === 'general') {
          await ic.deferUpdate();
          await ic.editReply({ content:"Server Creating will start in 3 seconds...", embeds:[], components: [] });
          await wait(3000);
          await general(i);
        }          
  
        if (ic.customId === 'no') {
          await ic.deferUpdate();
          await ic.deleteReply()
        }
});
#

When i call it command for second time and cancelled it says unknown interaction and shut down

like /test => no
Deletes message

/test => no
deletes and shut down

earnest phoenix
boreal iron
earnest phoenix
#

I need it on command file

#

And just one time

boreal iron
earnest phoenix
#

Unknown interaction

boreal iron
#

The custom ID of the button is used to identify it when receiving the event (interactionCreate)

#

Then you know the client has pressed the yes/no button and starts your action

earnest phoenix
boreal iron
#

Can’t view this on phone pogey

earnest phoenix
#
     let err = new Discord.MessageEmbed()  
        .setColor('RED')
        .setDescription('**Only Owner Can Use This Command!**')
          if(i.member.id !== i.guild.ownerId) {
          return i.reply({ embeds:[err], ephemeral: true}) }
      
      let choice = i.options.getString('type')    
      
      const embed = new Discord.MessageEmbed()
        .setColor(client.color.green).setThumbnail(client.user.displayAvatarURL({dynamic: true})).setTimestamp()
       
        let b1 = new Discord.MessageButton().setCustomId('yes').setStyle('SUCCESS').setEmoji('āœ…')
        let b2 = new Discord.MessageButton().setCustomId('no').setStyle('DANGER').setEmoji('āŒ')
         const row = new Discord.MessageActionRow().addComponents(b1, b2,); 
          const filter = int => i.user.id === i.member.id;
          const collector = new i.channel.createMessageComponentCollector({ filter, time: 60*1000 });      
        
              let inf = `[If you click āœ… This template will be compressed!\n](https://discord.new/Hwcjzq5t3AJE)`
              embed.setDescription(`**${inf} \n${client.conf.cs}**`)
              
            await i.reply({ embeds:[embed], components: [row]})
            
collector.on('collect', async ic => {
  
        if (ic.customId === 'yes' && choice === 'general') {
          await ic.deferUpdate();
          await ic.editReply({ content:"Server Creating will start in 3 seconds...", embeds:[], components: [] });
          await wait(3000);
          await general(i);
        }          
  
        if (ic.customId === 'no') {
          await i.deferReply();
          await i.deleteReply()
        }
});
boreal iron
#

Absolutely depends on your needs, mongo is document based, sql table based, completely different architecture

#

If you pick sql than mariadb not MySQL nowadays

tribal crow
# solemn latch it doesnt have to be bot specific

Ok, because i'm making a dashboard for my bot, and i have this problem i dont understand. I don't get any errors, and it won't respond. The thing that doesnt work: history.push('/');.

So what i am trying to do is to redirect the user if there is no cookies/the user isnt logged in. (This code is in .jsx)

boreal iron
#

Can’t give you a direct recommendation, I’m working with SQL for over a decade since I need a more complex database

#

Also I’ve got no clue what a economy bot needs, stores or does KEKW

#

As I said if you pick sql then MariaDB (SQL) which is a maintained modern variant of MySQL

#

Which has the same huge documentation as MySQL for any use case

tribal crow
#

I'm in the development of an economy bot, and i use MongoDB. It works perfectly for me.

boreal iron
#

Guess you’re referring to a guide for an integration into JS

earnest phoenix
#

is this ccs code correct? ccs <style> .entity-header-image{ board-radius: 50ā„… !important; boarder: 3px solid gold; animation: float 5s ease-in-out infinite } @keuframes float { 0ā„… { box-shadow: 0 5px 15px 0px rgba(0, 0, 0, 0.6); -webkit-transform: translatey(0px); transform: translatey(0px); } 50ā„… { box-shadow: 0 25px 15px 0px rgba(0, 0, 0, 0.2); -webkit-transform: translatey(-30px); transform: translatey(-30px); } 100ā„… { box-shadow: 0 5px 15px 0px rgba(0, 0, 0, 0.6); -webkit-transform: translatey(0px); transform: translatey(0px); } } </style>

#

i puted it in my bot's page but not working

earnest phoenix
#

oh yeah

boreal iron
#

Also border not boarder

#

There are like 100 typos in your CSS code

earnest phoenix
boreal iron
#

That’s why I said it depends on your needs

tribal crow
boreal iron
#

SQL allows a far more complex way to save data and interact with your database

earnest phoenix
#

still

boreal iron
#

If you just need to save a simple object being the clients "economy" whatever this means, a document based database should be enough

earnest phoenix
#
<style>
.entity-header-image{
bord-radius: 50ā„… !important;
border: 3px solid gold;
animation: float 5s ease-in-out infinite
}
@keyframes float {
0ā„… {
box-shadow: 0 5px 15px 0px rgba(0, 0, 0, 0.6);
-webkit-transform: translatey(0px);
transform: translatey(0px);
}
50ā„… {
box-shadow: 0 25px 15px 0px rgba(0, 0, 0, 0.2);
-webkit-transform: translatey(-30px);
transform: translatey(-30px);
}
100ā„… {
box-shadow: 0 5px 15px 0px rgba(0, 0, 0, 0.6);
-webkit-transform: translatey(0px);
transform: translatey(0px);
}
}
</style>```
#

somthing wrong?

#

still not working

#

@tribal crow

tribal crow
#

border-radius, not bord-radius

boreal iron
#

translatey also doesn’t exist

earnest phoenix
#

ok can anyone give me a floating pfp code?

boreal iron
#

Like I said, tons of typos

earnest phoenix
#

i suck at coding ccs

boreal iron
#

CSS

earnest phoenix
#

css

#

yeah

#

anyway

#

can u

boreal iron
#

Not the code is the issue but your typos are MegaThonk

earnest phoenix
#

ik

boreal iron
#

translatey also doesn’t exist

translate

earnest phoenix
#

else?

boreal iron
#

The function isn’t called translatey() but translate()

earnest phoenix
#

ok anything else wrong

#

typos?

#

@boreal iron

boreal iron
#

Huh… err border-radius not bord-…

earnest phoenix
#

and?

boreal iron
#

Not at PC to take a look, mobile sucks

earnest phoenix
#

i am on mobile

#

i coded on mobile

#

sooo

tribal crow
#

FakE?

boreal iron
#

Yes?

signal estuary
#

When I click a button after a few minutes this error occours:

DiscordAPIError: Invalid Webhook Token
  method: 'patch',
  path: '/webhooks/894599461735661578/aW50ZXJhY3Rpb246ODk2MzcwNDk2ODM1Mjk3MzAwOkFtYVlRQlkzSzdqOUM4MmU4T0tUYUNnVVQ2MnBaajZ3djZvbkVzNUx6UzJ6SW02R1RBU1g1QnV1MWpWV0xNYmU0OUFFbmk4cVRPa3Q5SFFGbDAwVXMwd0gxcks0TVFRTXJUbjd5Mjk1UGZ0azd5Tkg1Zk95OUR4Y0I3VWxtR2U3/messages/@original',
  code: 50027,
  httpStatus: 401,
  requestData: {
    json: {
    [...]
    }
  }
tribal crow
#

Do you know why this doesnt redirect me? history.push('/');

boreal iron
earnest phoenix
#

@tribal crow can you give me a float pfp code pleas

tribal crow
#

No spoon-feeding :P

boreal iron
tribal crow
#

fr?

#

ooooh

#

makes sense

gaunt mango
signal estuary
boreal iron
#

To prevent loops

#

And abuse

tribal crow
#

cuz the browser gave me an error earlier telling me it couldnt show some js code or sum

tribal crow
boreal iron
signal estuary
earnest phoenix
tribal crow
#

i can send u the tutorial i used to learn how to do it

earnest phoenix
boreal iron
#

If you go for saving files like JSON as database storing non-static data, no this is the worst idea and way you can go

#

That should defer the interaction making it available for 15 min if I remember right

earnest phoenix
#
let err = new Discord.MessageEmbed()  
        .setColor('RED')
        .setDescription('Only Owner Can Use This Command!')
          if(i.member.id !== i.guild.ownerId) {
          return i.reply({ embeds:[err], ephemeral: true}) }
      
      let choice = i.options.getString('type')    
      
      const embed = new Discord.MessageEmbed()
        .setColor(client.color.green).setThumbnail(client.user.displayAvatarURL({dynamic: true})).setTimestamp()
       
        let b1 = new Discord.MessageButton().setCustomId('yes').setStyle('SUCCESS').setEmoji('white_check_mark')
        let b2 = new Discord.MessageButton().setCustomId('no').setStyle('DANGER').setEmoji('x')
         const row = new Discord.MessageActionRow().addComponents(b1, b2,); 
          const filter = int => i.user.id === i.member.id;
          const collector = await i.channel.createMessageComponentCollector({ filter, time: 60*1000 });      
        
              embed.setDescription("**[If you click āœ… This template will be compressed!\n](https://discord.new/Hwcjzq5t3AJE)\n${client.conf.cs}**")
              
            await i.reply({ embeds:[embed], components: [row]})
            
collector.on('collect', async ic => {
  
        if (ic.customId === 'yes' && choice === 'general') {
          await ic.deferUpdate();
          await ic.editReply({ content:"Server Creating will start in 3 seconds...", embeds:[], components: [] });
          await wait(3000);
          await general(i);
        }          
  
        if (ic.customId === 'no') {
          await ic.deferUpdate();
          await ic.deleteReply()
        }
});
signal estuary
# boreal iron <https://discord.js.org/#/docs/main/stable/class/CommandInteraction?scrollTo=def...

That is not what I want because I am editing the message (with the buttons). But when I click after 5-10min this button the error appears

DiscordAPIError: Invalid Webhook Token
    at RequestHandler.execute (/home/development/test-bot/node_modules/discord.js/src/rest/RequestHandler.js:298:13)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async RequestHandler.push (/home/development/test-bot/node_modules/discord.js/src/rest/RequestHandler.js:50:14)
    at async InteractionWebhook.editMessage (/home/development/test-bot/node_modules/discord.js/src/structures/Webhook.js:268:15)
    at async CommandInteraction.editReply (/home/development/test-bot/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:139:21) {
  method: 'patch',
  path: '/webhooks/894599461735661578/aW50ZXJhY3Rpb246ODk2MzcwNDk2ODM1Mjk3MzAwOkFtYVlRQlkzSzdqOUM4MmU4T0tUYUNnVVQ2MnBaajZ3djZvbkVzNUx6UzJ6SW02R1RBU1g1QnV1MWpWV0xNYmU0OUFFbmk4cVRPa3Q5SFFGbDAwVXMwd0gxcks0TVFRTXJUbjd5Mjk1UGZ0azd5Tkg1Zk95OUR4Y0I3VWxtR2U3/messages/@original',
  code: 50027,
  httpStatus: 401,
  requestData: {
    json: {
      content: undefined,
      tts: false,
      nonce: undefined,
      embeds: undefined,
      components: [ { components: [ [Object], [Object], [Object] ], type: 1 } ],
      username: undefined,
      avatar_url: undefined,
      allowed_mentions: undefined,
      flags: undefined,
      message_reference: undefined,
      attachments: undefined,
      sticker_ids: undefined
    },
    files: []
  }
}
boreal iron
#

If you wait for an user response which can take longer than the followUp() method on the interaction is what you need

signal estuary
boreal iron
boreal iron
signal estuary
boreal iron
#

The method needs to contain your message

#

Whatever it is, just a string, another components or embeds etc.

#

I prefer the style to create a var at the beginning of your interaction handler and use it later

#

const webhook = interaction.webhook;
Later on in awaiting the user collection…
webhook.send(…);

signal estuary
boreal iron
#

You should use example I wrote above.

#

Didn’t know you’re waiting on an user response, deferReply() makes sense only if your script may takes longer than the initial 3s the webhook is available

gaunt mango
boreal iron
#

Yee but this is as I said not the right use case for you waiting on an user response

#

Store the webhook object in a var as I suggest (at the beginning of your interaction code) then use it later on to send (follow up) messages

#

@signal estuary

signal estuary
pale vessel
#

You don't need to send a new message if you defer

signal estuary
#

webhook.deferReply()?

boreal iron
signal estuary
boreal iron
#

Thought you’re waiting on an user response to send another message (incl. components)

boreal iron
#

Ah nvm didn’t see that one, my bad

signal estuary
tribal crow
#

When requiring something in my code (const fetch = require('node-fetch');) i get this error:

#

It tells me to use import instead, but when i use import i get this error:

boreal iron
boreal iron
#

As it’s async

tribal crow
#

ooooh

tribal crow
boreal iron
#

Take a look at the package description

#

Should be one of the first comments how to

boreal iron
earnest phoenix
#

discordjs button collector is broken

signal estuary
earnest phoenix
#

Yes its

signal estuary
#

You are just trying maybe to delete a message which is already deleted

signal estuary
earnest phoenix
#

No

#

Try it byself

signal estuary
#

you are doing something with a message which has already be done sth like this

earnest phoenix
#

When you call second create collector it works with first not creates second

boreal iron
#

Still don’t understand why you would use a collector on a button.
As I said earlier you will receive the event if somebody presses the button.

signal estuary
earnest phoenix
#

I have time filter

#

And need it just one time

#

And if they click no i need to just delete it

boreal iron
#

In that scenario a button got pressed you check if isButton() as method on the interaction and respond to it

earnest phoenix
# signal estuary If you are deleting the message and then try to delete it again it will throw an...
let err = new Discord.MessageEmbed()  
        .setColor('RED')
        .setDescription('Only Owner Can Use This Command!')
          if(i.member.id !== i.guild.ownerId) {
          return i.reply({ embeds:[err], ephemeral: true}) }
      
      let choice = i.options.getString('type')    
      
      const embed = new Discord.MessageEmbed()
        .setColor(client.color.green).setThumbnail(client.user.displayAvatarURL({dynamic: true})).setTimestamp()
       
        let b1 = new Discord.MessageButton().setCustomId('yes').setStyle('SUCCESS').setEmoji('white_check_mark')
        let b2 = new Discord.MessageButton().setCustomId('no').setStyle('DANGER').setEmoji('x')
         const row = new Discord.MessageActionRow().addComponents(b1, b2,); 
          const filter = int => i.user.id === i.member.id;
          const collector = await i.channel.createMessageComponentCollector({ filter, time: 60*1000 });      
        
              embed.setDescription("**[If you click āœ… This template will be compressed!\n](https://discord.new/Hwcjzq5t3AJE)\n${client.conf.cs}**")
              
            await i.reply({ embeds:[embed], components: [row]})
            
collector.on('collect', async ic => {
  
        if (ic.customId === 'yes' && choice === 'general') {
          await ic.deferUpdate();
          await ic.editReply({ content:"Server Creating will start in 3 seconds...", embeds:[], components: [] });
          await wait(3000);
          await general(i);
        }          
  
        if (ic.customId === 'no') {
          await ic.deferUpdate();
          await ic.deleteReply()
        }
});ā€Š

#

Then why it works on first time?

boreal iron
pale vessel
earnest phoenix
#

collectors need new object

#

Its the only problem

boreal iron
#

Dunno why you make things more complicated than needed pepowot

earnest phoenix
#

Itsnt good option for me

#

And this command not using much

#

Maybe one time in months

#

If i check it on every interaction create is make slow bot

boreal iron
#

You can use all the code in you exported module

#

I guess your command handler calls your module method

#

Whatever it’s called

earnest phoenix
#

It calls module

#

But itsnt about module

#

Its about fckin discordjs component collector

boreal iron
#

Well the moment somebody presses the button the event is fired again and you check in your module if interaction.isButton() and if the button ID is whatever yes or no and execute the response

wheat mesa
#

As much as I dislike djs, their library isn't just straight up broken. It's usually user error.

earnest phoenix
grim aspen
boreal iron
#

A collector for an interaction just doesn’t make sense since you always receive the event if any interaction element is used by an user

earnest phoenix
#

But second time gives error

grim aspen
#

what is the error? i can try my best to understand

boreal iron
#

Does it play for you? Doesn’t work somehow

grim aspen
#

no

earnest phoenix
#

doesn't work

boreal iron
#

00 of 00

grim aspen
#

i thought i was having network issues

earnest phoenix
#

0:00

boreal iron
earnest phoenix
#

Did you understand what i tryna tell

#

how can i combine arrays?

pale vessel
#

Oh never mind this isn't python

earnest phoenix
#
let firstArray = [1, 2, 3, 'Shinchan']
let secondArray = ['Nohara', 4, 5, 6]
let thirdArray = [7, 8, 9, 'Himawari']

let combinedArray = []

combinedArray.push(...firstArray, ...secondArray, ...thirdArray)
``` this is the result from google
#

this works

#

?

boreal iron
earnest phoenix
#

@boreal iron css width: 100ā„…; height: 100ā„…; overflow: scroll; overflow-x: hidden; background: url('https://www.dreamstime.com/photos-images/blue-fire.html'); background-repeat: no-repeat; background-size: cover; scrollbar-width: none;

#

any typos?

boreal iron
#

lol nah I don’t see one

earnest phoenix
#

ok

#

ty

boreal iron
#

You might wanna specify the background to not repeat and be centered etc.

#

lol nvm

#

YES I saw it flazepe

pale vessel
earnest phoenix
#

ok

boreal iron
lament rock
#

I'd probably use the concat since the spread operator duplicates and would have 1 extra Array alloc while the concat wouldn't duplicate the firstArray

earnest phoenix
boreal iron
#

Mr. Erwin 2

lament rock
#

I'd still rather prefer raw gateway

#

might rewrite my bot to TS and use only raw gateway with CloudStorm and SnowTransfer

earnest phoenix
earnest phoenix
lament rock
#

You might be passing an invalid token

earnest phoenix
lament rock
#

No. Just my bot is not very complex and abstraction layers are just not necessary

earnest phoenix
#

how can i change a array content? it's in the database so i need to change it for one file and leave other files like they were

earnest phoenix
#

like
Skelle to Skelle

earnest phoenix
cinder patio
#

with the introduction of slash commands going raw is way easier, especially if you don't need the gateway

earnest phoenix
#

i used .push so it has many things in it

boreal iron
earnest phoenix
#
let array = db.get("array");

// change array content

db.set("array", array);
earnest phoenix
#

this will change the previous thing

#

Int create include only module exporter

#

Or runner

#

i want to change it for only one file

#

Whtever it called

earnest phoenix
boreal iron
earnest phoenix
#

u

#

question: should i use a css framework

boreal iron
#

Sure why not, people nowadays use bootstrap doggowave

quartz kindle
#

ew

boreal iron
#

Doesn’t mean there are other good ones out there, too

boreal iron
earnest phoenix
#

I wanna try bulma

quartz kindle
#

:^)

earnest phoenix
#

how can i change this like
a random function chose "**Skelle**"
and i have Skelle in array how can i change that "**Skelle**" to Skelle?

#

but their own website has cumulative layout shift

boreal iron
# earnest phoenix but their own website has cumulative layout shift

Wouldn’t it make sense to provide these details before asking? pepowot

Like asking somebody which color he would prefer and after he answers "red" telling him, it can’t be red for any reason at all.

That would make conversations more efficient.
(called micro optimization you know)

simple stump
#

How would I listen to when the bot crashes, log the error, and then avoid the error?

#

My hoster clears the console since the bot's hosted on pterodactyl

simple stump
#

like messageCreate and voiceStateUpdate?

earnest phoenix
boreal iron
simple stump
#

alr

#

thx

boreal iron
#

A crash most likely is a process exit for a specific reason

#

There aren’t much ways I’m aware of killing a process without letting the process know

#

Which means it’s "always" a controlled (maybe forced) shutdown

#

If your bot crashes you probably don’t handle it’s errors properly or something sends a TERMINATE signal to the process (which isn’t the case most likely)

#

@simple stump

simple stump
#

Aight. I mean I use MySQL a frick ton, so that could be why

#

Could I just use this:

for(const event of ["exit", "SIGINT", "SIGUSR1", "SIGUSR2", "SIGTERM"])
{
    process.on(event, () =>
    {
      // exiting
    }
}

Which I saw when reading from that link, and then somehow stop the bot from shutting down?

earnest phoenix
#

.includes detects this? like .includes("in")
aino

#

this has in

#

it'll detect it?

#

@earnest phoenix nope

#

array.includes checks if it is exactly the same

#

you can try using array.some with a function that checks if it has in anywhere in it

boreal iron
simple stump
#

is there a way to start up the bot? or avoid the crash entirely?

signal estuary
#
if (msg.author.permissions.has("MANAGE_MESSAGES")) return;
TypeError: Cannot read properties of undefined (reading 'has')
boreal iron
simple stump
#

huh thats weird. its prob a sql error. after almost every sql statement i have if err throw err. could i just remove that to avoid a crash?

boreal iron
#

Don’t you have any log logging the crash once?

simple stump
#

no

boreal iron
#

No console output, nothing? wtf

simple stump
#

console output

#

but it was down literally right when i went to sleep

#

so i have no idea how to get it

#

the console is cleared whenever the bot goes down for ptero

lament rock
slender thistle
#

@simple stump try to log stuff in a file

simple stump
#

yea i added this based on the link FakE sent:

for(const event of ["exit", "SIGINT", "SIGUSR1", "SIGUSR2", "SIGTERM"])
{
    process.on(event, () =>
    {
      console.log("event: " + event);
      scoreFile("Error: " + event);
    })
}
#

if theres an error itll get logged into a file

#

im just wondering if i can add on stopping the process entirely

boreal iron
#

You should read a little further

#

The event will most likely be fired 2 times

simple stump
#

aight

boreal iron
#

Keep in mind it will log the event name only

#

You should probably create a debug stack trace at this point and log it as well, if an error occurs

earnest phoenix
#

can anyone give me the class name of background

tribal crow
#

Hey! I'm making a dashboard for my bot and i have this problem that i dont understand. I have made a function that lists all the users guilds using the api. This is the function:

        method: 'GET',
        headers: {
            Authorization: `Bot ${TOKEN}`
        }
})
return response.json();```
earnest phoenix
tribal crow
#

And this is how i use the function:

    const guilds = await getBotGuilds();
    console.log(guilds);
    res.send(guilds);
});```
earnest phoenix
#

err?

boreal iron
earnest phoenix
#

yes

tribal crow
#

On the page localhost:3001/api/discord/guilds (yes, this is the right path) i get this error: Cannot GET /api/discord/guilds

earnest phoenix
boreal iron
#

let me take a look real quick

earnest phoenix
#

ok

boreal iron
#

page__PageContentWrapper-sc-iv577v-0 iidttR

earnest phoenix
#

ty

boreal iron
#

one of this two class names

#

not sure which one is static

earnest phoenix
#

leme try this

#

did not work

#

@boreal iron

#

can u get me the vote button pleas

boreal iron
#

It's the right selector

#

Your device is caching the CSS code

earnest phoenix
#

wdym?

#

can you get me the vote button

#

pleas

solemn latch
#

is there a reason you cant get it?

blissful coral
earnest phoenix
#

that all

boreal iron
#

chakra-link chakra-button css-f2oc6t > css-f2oc6t

earnest phoenix
#

whats the >

blissful coral
#

You can get it on phone too?

#

greater than?

boreal iron
#

anchor - a.css-f2oc6t

earnest phoenix
blissful coral
earnest phoenix
earnest phoenix
blissful coral
#

FaKe is not talking to you

#

Same as you would on PC

earnest phoenix
#

you cant left click

#

lol

blissful coral
#

Why would you need to

#

Just click

#

lul

earnest phoenix
#

where

boreal iron
earnest phoenix
#

bruh

blissful coral
#

Go to the bots page and click the "vote" button

solemn latch
#

they are trying to get the css selector

blissful coral
#

And it will bring you to the vote page

earnest phoenix
boreal iron
#

a.css-f2oc6t

earnest phoenix
#

what's that

boreal iron
#

the selector?!

solemn latch
#

the class of the vote button

earnest phoenix
#

oh just that

boreal iron
#

a is the element (anchor), css-f2oc6t the name of the class

earnest phoenix
#

oh ok

#

ty

boreal iron
#

all together named selector

ancient nova
#

does anyone know why this stops instantly after the code is executed?

var Interval = setInterval(() => {
    for (let i = 10; i--;) {
        if(10 - 1 === i) {
            clearInterval(Interval);
        }
    }
}, 100); 

and not when the first interval ended

flat copper
#

how to fetch message by id?

ancient nova
#

messsage.guild.messages.fetch(id) pretty sure

boreal iron
flat copper
boreal iron
#

Because there's no property messages on a guild

#

Only channels contain messages, not guilds

#

Fetch your channel, then fetch it messages

#

Keep in mind fetch() return a promise

earnest phoenix
#

any typos css .chakra-link.chakra-button.css-947c4k{ background: #222f3e; color: #48dbfb; animation: heartbeat 1.5s infinite; } @keyfarmes heartbeat { 0ā„… { transform: scale(1); } 5ā„… { transform: scale(1.1); } 10ā„… { transform: scale(1); } 15ā„… { transform: scale(1.2); } 50ā„… { transform: scale(1); } 100ā„… { transform: scale(1); } }+ @boreal iron ty for the selectors name

boreal iron
#

keyfarmes

earnest phoenix
#

whats wrong with that?

#

@boreal iron

boreal iron
#

frame not farm

flat copper
#
let msg = message.guild.channels.cache.map(async c => {
        return await c.messages.fetch(msgId)
      })

      console.log(msg)```
fetch is undefined
earnest phoenix
boreal iron
#

KEYFRAMES not KEYFARMES

flat copper
#

oops

#

lol

boreal iron
#

wrongly placed A

earnest phoenix
#

not working

#

ok it is wrong but its still not working

boreal iron
#

Keep in mind your device caches the CSS stuff

earnest phoenix
#

wdym?

boreal iron
#

You need to clear the cache to update it

earnest phoenix
#

how?

boreal iron
#

It doesn't reload the CSS each time you visit the site, it caches it

#

dunno another word for cache

earnest phoenix
#

ok so what do it do to fix?

boreal iron
#

clear the website cache

earnest phoenix
#

how?

earnest phoenix
boreal iron
#

depends on your device

earnest phoenix
#

redmi a9

boreal iron
#

so Android then

earnest phoenix
#

yes

boreal iron
#

dunno, you need to google it

earnest phoenix
#

if i copyed the code will that work?

#

like a backup

earnest phoenix
boreal iron
#

what do you mean?

earnest phoenix
#

how to clear cache

boreal iron
#

I don't know for Android devices

#

You need to google it

earnest phoenix
#

ok

#

how to clear a website cache?

#

right

earnest phoenix
#

yes

#

bottom right

#

ok ty

earnest phoenix
boreal iron
#

Looks like the class isn't static as I assumed

#

nvm it is

lyric mountain
#

Just use anon mode smh

boreal iron
#

Does Androidshit has that, too wew

earnest phoenix
lyric mountain
#

Anonymous mode, come on, do I really need to show where it is?

earnest phoenix
#

anonymous modeeeeee

#

oh

#

leme try

lyric mountain
#

3 dots on the side

cinder patio
#

Nova guia anonima

boreal iron
#

No no

#

ò not o

earnest phoenix
boreal iron
#

Ć“

flat copper
#
let filter = m => m.user.id === message.author.id

        message.channel.awaitMessages(filter, {
          max: 1,
          time: 30000,
          errors: ['time']
        }).then(async collected => {
          let des = collected.first().content

          console.log(des)
          
          await msg.edit({embeds: [{
            description: des,
          }]})
        })
#

its not working

cinder patio
#

HOW is it not working

flat copper
#

like its not consoling

#

"let des = collected.first().content"

#

then?

#

which des 🄲

#

im confused

#

read the code 🄲

#

collected

#

is defined

boreal iron
#

What's been logged?

flat copper
boreal iron
#

undefined, null or really nothing

flat copper
#

nothing

flat copper
#

any example?

boreal iron
#

dunno why it doesn't work

#

you might try the example and work the way towards it should be

flat copper
#
let filter = (m) => {
     return m.user.id === message.author.id
}

        message.channel.awaitMessages({
          filter,
          max: 1,
          time: 30000,
          errors: ['time']
        }).then(async collected => {
          let des = collected.first().content

          console.log(des)
          
          await msg.edit({embeds: [{
            description: des,
          }]})
        })
#

i tried this

#

but its saying
cannot read property "id" in filter

boreal iron
#

Message doesn't have a user property

#

Use the member property instead

old cliff
#

Hey, anyone has experience in ML and AI?
I wanted to know where should I start from...
should I learn Tf.js for node or start with the python one?
Also I need a good starting point/tutorial/course.

#

Anyway, if anyone has to say something, please reply with a ping because I have to go somewhere.

ancient nova
proven lantern
ancient nova
#

now I need another thing

#

if you have some time

boreal iron
#

Just ask, invoices being sent after

old cliff
#

Thanks

ancient nova
#

var proxiedRequest = req.defaults({'proxy': 'http://1.1.1.1:80/'});
when I try using proxy like this I get no response.
but when I try doing it like this
var proxiedRequest = req.defaults({'proxy': '1.1.1.1:80'});
I get a tunneling websocked error, help pls

Install the free app that makes your phone’s Internet more fast, private, and reliable.

#

which one do I use 😦

#

hello?

tribal crow
#

Hey, hey! I have this code:

    
    return userGuilds.filter((guild) => botGuilds.find((botGuild) 
    => (botGuild.id === guild.id) && (guild.permissions & 0x20) 
    === 0x20));
};```
#

And i get this error:
TypeError: botGuilds.find is not a function

boreal iron
tribal crow
#

Does anyone know why i get this error and how to fix it?

ancient nova
boreal iron
#

Isn't there any documentation of the lib you're using?

ancient nova
#

no clue I didn't check I'm using the "request" npm

boreal iron
#

I'm sure there's a doc on the site

ancient nova
#

I'm trying to do request.get

#

I get no response

#

req.get("link", (error) => {
if (error) return;
console.log("proxy is working");
});

#

and the proxy I am using is

#

and there is no error either

boreal iron
#

tried querying the secure endpoint?

ancient nova
#

in what sense?

boreal iron
#

https

ancient nova
#

let me try

#

no response

#

no error or anything of these sort

#

ok nevermind

#

give me second I think something happened

ancient nova
# boreal iron `https`

I think I got it to work, I got a for loop to get a few of the reg.get request at the same time, but they do have some timeout so if I check the finished for loop with if (i === 0) it get's logged before the request are done

#

sorry if what I just said makes no sense

boreal iron
#

the result matters

#

if you got it working...

ancient nova
#

I think I did

#

so would you happen to know how to fix the loop?

quaint wasp
#

How do I get the client ID?

#
const id = client.id;``` this returns undefined...
#

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

#

client is defined btw

#

(ping in replies)

boreal iron
#

client.user.id

#

guild.me represent the client as guild member

#

@quaint wasp

quaint wasp
#

the package says its not a string...

#

Its not a function for a command

#

so there is no guild

#

or message

boreal iron
#

Depends on the scope, where do you wanna use it

#

If client is defined, client.user.id is always your app

quaint wasp
#
const id = client.user.id;
                       ^

TypeError: Cannot read properties of null (reading 'id')```
boreal iron
#

The client has no ID before logging it in

quaint wasp
#

ohh....

#

So I have to put client.login() like at the top ?

#

after client

boreal iron
#

Doesn't make sense to define an extra var in that scope for the user ID

#

You can always use client.user.id

quaint wasp
#

ok.

boreal iron
#

Same goes for your vars prefix and token

misty sigil
#

(after the ready event)

quaint wasp
#

i mean... I do need to put client login at the very top after client now.. dont I ?

misty sigil
#

no

boreal iron
misty sigil
quaint wasp
#

alr.

misty sigil
#

you can do let id;

ancient nova
#

@boreal iron I have fixed the for loop issue by adding a delay function

#

btw

boreal iron
#

What's the sense of adding another property (id) to the client's class if it already exists?

#

Secondly why would you use await on a property (await client.user.id)? It's not a method returning a promise.

ancient nova
ancient nova
boreal iron
#

Which is impossible.

ancient nova
#

I didn't mean it like that

#

let's call it

#

not fully logged in

boreal iron
#

There's no "half" login, declaring the client (const client = Discord.client(...)) is nothing else than declaring it's var, you call it client in this example

#

Before connecting to the gateway aka. logging in, nothing happens

ancient nova
boreal iron
#

Which will not work as well

ancient nova
#

it does. I've done that

boreal iron
#

Are we speaking 2 different languages here?

ancient nova
#

discord.js?

boreal iron
#

English

ancient nova
#

what is that supposed to mean 😐

boreal iron
#

Are we speaking 2 different languages here?

#

Somehow feels you're talking in Spanish

ancient nova
#

we are clearly both speaking english

ancient nova
#

oops

#

I meant to say

#

come again

#

I'm not good at spansih

wheat mesa
#

y tu?

ancient nova
wheat mesa
ancient nova
#

bueno

ancient nova
#

no wait

#

soy

#

bueno

#

:]

boreal iron
#

well whatever you're trying to archive there, it's non-sense as the property exists already
And you're going the use the client's ID in the events you receive, which means the client is already logged in and the property exists

ancient nova
solemn latch
#

šŸ¤” any idea why rpc buttons dont work on pc for some? and do work for others.

small tangle
#

My database trigger on my mongodb needs 3s to execute and the collection holds 150 documents. is this fast or slow? FeelsSmartMan its a scheduled trigger which gets executed every 2 hours

earnest phoenix
#

that sounds slow

small tangle
#

i already created indexes for the fields that im using in the query, but there is not a really performance improvement.
Could there be another way to increase performance?

slender wagon
#

which node version is better to work with for my current projects v14.18 or 16.11

#

any reason they would recommend the older one

wheat mesa
#

if you're using djs v13 then you need node 16

slender wagon
#

right

#

so node 16 it is

fair axle
#

I couldn't get it

small tangle
#

Below is the Code for my trigger. I want to decrease the value of the alpaca.hunger and alpaca.thirst fields by 1 but only if each of them are greater as 2. But now im running 2 times through the collection. Is there a better way to achieve the goal?

exports = function() {
  const collection = context.services.get("AlpacaCluster").db("alpagotchiDB").collection("alpacas_manager");
  
  collection.updateMany(
    { "alpaca.hunger": { $gte: 2 } }, 
    { $inc: { "alpaca.hunger": -1 } },
    {}
  );
  
  collection.updateMany(
    { "alpaca.thirst": { $gte: 2 } }, 
    { $inc: { "alpaca.thirst": -1 } },
    {}
  );
};
fair axle
#

which properties?

#

I know btw just a habbit

#

help help help

#

It's not a context menu. Just slash command

proven lantern
#

what would be a good database to keep track of a bunch of counts and easily be able to get the count by day/week/year etc

#

i have dynamodb and elasticsearch right now, but im not sure if those would be too good

#

should i be using something like statsd?

fair axle
#

I am getting this error

const data = {
    "name": "moderasyon-log",
    "description": "test",
    "type": 3,
    "options": [
        {
            "name": "kur",
            "description": "Moderasyon Logları Kanalını Oluşturur.",
            "type": 1,
        },
        {
            "name": "kaldır",
            "description": "Moderasyon Logları Kanalını Siler.",
            "type": 1,
        },
    ]
}

client.api.applications(client.user.id).commands.post({ data })
proven lantern
#

what is type 3?

#

context menu command

#

those cant have options

#

what are the other types?

boreal iron
#

SUB_COMMAND

earnest phoenix
#

hi! i'm getting a fatal error when calling a function that clearly exists

#

here's the relevant code

#
/////////////////////////////////////////////////////
//                                                 //
//                     BTS Bot                     //
//                                                 //
//             File: restartProcess.js             //
//                                                 //
//         Written by: Thomas (439bananas)         //
//                                                 //
// Copyright 439bananas 2021. All rights reserved. //
//                                                 //
/////////////////////////////////////////////////////

const log = require('./logHandler');
const Discord = require('discord.js')
const client = new Discord.Client()
const http = require('http')
const svrmgr = require('../server/serverManagerFunctions')

function closeServer() {
 /*   console.log('yeet')
    //server.close()
}*/

function restart() {
    log.info('Restarting...')
    // DESTROY DISCORD BOT SOMEWHERE
    svrmgr.closeServer()
    process.exit(2)
};

module.exports = restart;```
#
/////////////////////////////////////////////////////
//                                                 //
//                     BTS Bot                     //
//                                                 //
//         File: serverManagerFunctions.js         //
//                                                 //
//         Written by: Thomas (439bananas)         //
//                                                 //
// Copyright 439bananas 2021. All rights reserved. //
//                                                 //
/////////////////////////////////////////////////////

const log = require('../core/logHandler')
const uniconf = require('../configs/uniconf.json')
const express = require('express')
const e = express()
const http = require('http')
const app = require('./serverListener')
const { response } = require('./serverListener')
const server = http.createServer(app)

function createServer() {
    server.listen(uniconf.port)
        .once('error', function (err) { // If port in use, crash
            if (err.code == 'EADDRINUSE') {
                log.fatal(`Couldn't start the server on port ${uniconf.port}! Is there another application running on that port?`) // Fatal function calls always end the process no matter what
            }
        })
}

function closeServer() {
    console.log('yeet')
    //server.close()
}

module.exports = { createServer, closeServer };```
eternal osprey
#

hey, how would i ever filter my json file based on amount of points? js if(message.content == '!leaderboard'){ let content = ""; let m; let g; let reps = JSON.parse(fs.readFileSync("./reps.json", "utf8")); for (const key in reps) { for (let i = 0; i < Object.keys(reps).length; i++) { m = reps[key].points g = await client.users.fetch(key) content += `#${i+1}. Points: ${m} ~ User: ${g}\n` console.log(content) } } const embed = new Discord.MessageEmbed() .setDescription(`**${message.guild.name}'s Leaderboard**\n\n${content}`) .setColor("#FFFFFF") .setFooter("Provided by Reputation Handler!") .setImage("https://media.giphy.com/media/SwCyz9aOyZhyczzKfr/giphy.gif") message.channel.send(embed) }

#

right now it randomly filters based on position, which is not what i need.

quartz kindle
#

this makes no sense

#
    for (const key in reps) {
      for (let i = 0; i < Object.keys(reps).length; i++) {
#

reps.sort((a,b) => a.points - b.points)

tame wraith
tribal crow
#

Hey hey! I'm creating a dashboard for my bot, and i get this error that i dont understand or know where is originated. The error is: TypeError: Converting circular structure to JSON

#

Its an react app

proven lantern
#

some objects cant go into JSON.stringify

tribal crow
#

but i dont have JSON.stringify anywhere...?

proven lantern
#

aliens then

tribal crow
#

šŸ‘½?

proven lantern
#

yes

tribal crow
#

aliens?

proven lantern
#

correct

tribal crow
#

ok...

#

Do you know how i would find the place where the error is originated?

proven lantern
#

make a big try/catch and log the exception

tribal crow
#

BUT I DONT KNOW WHERE THE ERROR COMES FROM

#

hehe

proven lantern
#

make it a huge try/catch

tribal crow
#

but there is like 20 js/jsx files o.O

proven lantern
#

are you getting the error in the terminal or in the browser console

tribal crow
#

terminal

#

and it crashes the app

snow urchin
#

Is it possible to get the message id from the createMessageComponentCollector filter

proven lantern
#

load one file at a time until you find the file causing the error

tribal crow
#

Ok so

#

I dont get the error when this is disabled:

    const { guildId } = req.params;
    const config = GuildConfig.findOne({ guildId });
    return config ? res.send(config) : res.status(404).send({ msg: "Not Found" });
})```
quartz kindle
tribal crow
# quartz kindle show the full error
    : JSON.stringify(value);
           ^

TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'Topology'
    |     property 's' -> object with constructor 'Object'
    |     property 'sessionPool' -> object with constructor 'ServerSessionPool' 
    --- property 'topology' closes the circle
    at JSON.stringify (<anonymous>)```
quartz kindle
#

is that all? nothing else after that?

tribal crow
#

there is

#
    at ServerResponse.json (D:\dashboard-test\backend\node_modules\express\lib\response.js:260:14)
    at ServerResponse.send (D:\dashboard-test\backend\node_modules\express\lib\response.js:158:21)
    at D:\dashboard-test\backend\src\routes\discord.js:30:25
    at Layer.handle [as handle_request] (D:\dashboard-test\backend\node_modules\express\lib\router\layer.js:95:5)
    at next (D:\dashboard-test\backend\node_modules\express\lib\router\route.js:137:13)
    at Route.dispatch (D:\dashboard-test\backend\node_modules\express\lib\router\route.js:112:3)
    at Layer.handle [as handle_request] (D:\dashboard-test\backend\node_modules\express\lib\router\layer.js:95:5)
    at D:\dashboard-test\backend\node_modules\express\lib\router\index.js:281:22[nodemon] app crashed - waiting for file changes before starting...```
quartz kindle
#

there you go

#

discord.js line 30

tribal crow
#

Where do you get that from?

blissful coral
#

the error