#development

1 messages · Page 2018 of 1

wooden ember
#

other than just removing the msg event altogether

cinder patio
#

they'll make it privileged

wooden ember
#

only affecting varified bots?

#

but even then if a bot already uses normal commands and cant function on /comands what will they do then?
cuz they cant humanly just go "lol sucks to suck"

eager yarrow
#

For the Web Dyno,

I can enable a web dyno with heroku ps:scale web=1 as I have a few available, but I need a web process type configured in my Procfile. I did have it as web: python bot.py, mimicing the worker process type I have for my bot. While the web dyno did spin up with no errors, once I sent a test vote request it crashed.

Do I need to configure flask or something to listen for the Post request on my bot, or do I need to build a Web solution in node to listen for the request?

cinder patio
#

you'll have to switch to slash command

#

they gave you a year and a half

wooden ember
#

yeah but non varified you can just activate the intent manually on non varifed

#

that sucks tbh

#

but then thats what hapens when you give literally any bot the ability to see every message in every channel in every server its in

#

kinda sad they didnt make it "secure" from the get go rather than having a rethink like half a decade later

#

personally i hope they come up with something better or just make /comands more usable cuz last time i tryed getting into that stuff it just felt like some redneck half-assed workaround bolted on the side

boreal iron
rocky dagger
#

so i got this code and i want to see if the dino varible is not inside the arr array but whatever i do everything passes or nothing does ```js
let ifBreed = [
{ "dinos": ["giga", "mosa", "pt"] },
{ "dinos": ["theri", "mana"] },
{ "dinos": ["rex", "tuso"] }
]

let dino = "h";

for (let x = 0; x < ifBreed.length; x++) {
for (let y = 0; y < ifBreed[x].dinos.length; y++) {
if (!ifBreed[x].dinos[y] === dino) return console.log(${dino} is not getting breed)
}
}```

sudden geyser
#

You should use !== instead of !... === ...

#

Though keep in mind that it'll immediately return if the current inner iteration passes, which I'm not sure is what you actually want.

rocky dagger
#

if its the dino variable is not in the array i dont want it to continue

rocky dagger
cinder patio
#

That's because both of your loops stop at the first wrong dyno name

#

so you don't want to return

#
function isDynoInArr(dino, ifBreed) {
for (let x = 0; x < ifBreed.length; x++) {
    for (let y = 0; y < ifBreed[x].dinos.length; y++) {
        if (ifBreed[x].dinos[y] === dino) return true;
    }
}
return false;
}
#

Then just use that function instead

#

or you could use a variable but in this case function's a lot better

lyric mountain
#

but when u do something !== ... you're checking equality (true if not equals, false otherwise)

rocky dagger
lyric mountain
#

also the way u structured it is quite inefficient

#

if all keys are the same, just use an array

#
let ifBreed = [
  ["giga", "mosa", "pt"],
  ["theri", "mana"],
  ["rex", "tuso"]
]
rocky dagger
#

it also has other information so i wanted to keep it basic

lyric mountain
#

shouldn't u be using objects then?

#

actual objects I mean, instead of anonymous (as in, classes)

rocky dagger
#

this is the whole thing json [{ "_id": { "$oid": "6248817a243b8d326c6d3eb2" }, "guildID": "494567290990493696", "userID": "330064750862139393", "dinos": ["giga", "mosa", "pt"] }, { "_id": { "$oid": "624881da243b8d326c6d3eb3" }, "guildID": "494567290990493696", "userID": "491298338784673817", "dinos": ["theri", "mana"] }, { "_id": { "$oid": "6248820f243b8d326c6d3eb4" }, "guildID": "494567290990493696", "userID": "811586423933108254", "dinos": ["rex", "tuso"] }, { "_id": { "$oid": "62489fd660e500b13afd2374" }, "guildID": "494567290990493696", "userID": "836670704120365087", "dinos": [], "__v": { "$numberInt": "0" } } ]

lyric mountain
#

ah, mongo

rocky dagger
#

yes

#

and its 4 different documents

lyric mountain
#

have u considered using sql? (since you're dealing with relational data on a non-relational database)

rocky dagger
#

havent looked at it

#

and i knew how to use mongo so i just used that

lyric mountain
#

for your current case, you can use includes to check if the dino is in array

#

obj.dinos.includes(otherDino)

rocky dagger
#

that worked, thank u very much

lyric mountain
#

yw

quasi dagger
#

What kind of discord bot payment integrations exist

woeful pike
#

preferably one where you redirect the user to a secure environment like a website run on a browser and not one where they enter their credit card number in dms

sudden geyser
#

what non-phishing bot is asking you to send your credit card information in dms

solemn latch
#

bad ones

lyric mountain
boreal iron
#

bcc is your black credit card right?

sudden geyser
#

can't imagine since I've never seen that

boreal iron
#

The one without limit I guess

sudden geyser
#

though I do see people emailing themselves regularly

lyric mountain
#

freerealestate I didn't mean email

#

actual paper mail

sudden geyser
#

oh

boreal iron
#

Huh paper still exists?

#

Weird times

sudden geyser
#

amazon forest isn't gone yet

lyric mountain
#

dates back to 1950

#

yes you're old

quartz kindle
#

this is a real company in 2022

#

you have to send them an email or a letter in the mail, with the above fields filled up

solemn latch
#

seems safe

sudden geyser
#

Card number: 0123 4567 8901 2345

#

immediately gets email from Discord

boreal iron
quartz kindle
#

dayum i just saw the april 30 deadline has been extended by 4 months

solemn latch
#

yeah

#

what is that, 14 months to prepare?

quartz kindle
#

idk

solemn latch
#

I still havent 👀

quartz kindle
#

i have more time to procrastinate now

#

:^)

solemn latch
#

yeah lmao

quartz kindle
#

i really need the date picker and variadic thing

#

i can do without, but it will be so much better with it

lyric mountain
#

and I need a way to set multiple signatures for a single command

quartz kindle
#

thats what subs and groups are for no?

#

but its kinda awkward to work with, i also need that

#

/a date time options
/a name time options
/a name date options
/a date date options
etc.... lol

lyric mountain
quartz kindle
#

it would be good to have for example "one of option1 option2 option3 is required"

lyric mountain
#

I'm more for "if A is supplied then B is required"

#

like /cmd [optA optB] optC

#

where [] is a param group

boreal iron
quartz kindle
#

didnt do the date picker yet

boreal iron
#

I wonder if discord even works on basic things like other field types or … hey hey where’s actually the promised sub command grouping?

#

Guess we will see more trash coming in the future instead of working on the basic features lot of people could use as they have to switch to application commands anyways

#

Being tired of repeating myself for one year now

quartz kindle
#

lel

split hazel
#

guys plz help

#

i am losing it

#

yeah os dev that doesnt know how to use the linux file system hahahahahahhaha shut up

#

anyways

#

this is supposed to print the phrase "hello w"

#

but it only prints "hello"

#

also tried printing the whole file

#

(my next step is interacting with the file in raw binary btw)

#

c++ btw

#

or c btw

split hazel
#

stupid design but wont judge

#

now im confused why opening a file in read and write mode clears the original contents

wheat mesa
#

static char* readFile(const char* path) {
  FILE* file = fopen(path, "rb");

  fseek(file, 0L, SEEK_END);
  size_t fileSize = ftell(file);
  rewind(file);

  char* buffer = (char*)malloc(fileSize + 1);
  size_t bytesRead = fread(buffer, sizeof(char), fileSize, file);
  buffer[bytesRead] = '\0';

  fclose(file);
  return buffer;
}
``` might be useful to you
#

Didn’t write that btw, got it from a website

quartz kindle
split hazel
#

what is that cryptic text in the tree branches lmao

#

ah

#

i'll really be making use of binary mode

#

if i understand what it does correctly

#

nevermind i have no idea

lyric mountain
split hazel
#

now i know you can seek to positions

#

which is vital to my project

#

so im guessing i'd really just use r+ mode (read and write)

#

for random access and storage of data

#

not strings but bytes

#

ah binary mode is for non ascii data

ancient nova
#

does anyone

#

know

#

how to execute a function only once?

#

I want ChooseSound to be executed only once

marble juniper
#

make a boolean

ancient nova
#

but the Update method, is like a for loop

marble juniper
#

and when the method runs make it true

ancient nova
#

but I have 2 of them

marble juniper
#

make 2 booleans

ancient nova
#

what do I do if I wanna restart those booleans

marble juniper
#

wdym

ancient nova
#

both of those will constantly switch

#

from chase to idle

#

but the boolean trick will work only once

marble juniper
#

no idea then

ancient nova
#

ikr 😭 what do I do

marble juniper
#

tim probably knows

ancient nova
#

maybe, he's smart

marble juniper
#

indeed

quartz kindle
#

idle = false
if(idle) { chase; idle = false; }
if(!idle) { idle; idle = true; }

ancient nova
#

that'd actually work?

#

let me tryyyyyyyyyyyyyyyyyy

marble juniper
#

mind blowing

quartz kindle
#

as long as idle is outside of the update function

karmic delta
#

just wondering, i want to use buttons for polls and giveaways would this mean i have to store every button press in a DB? or is there a better way to do this?

quartz kindle
ancient nova
quartz kindle
karmic delta
marble juniper
#

then put it outside

ancient nova
#

then how do I make it play again if it's outside update

quartz kindle
quartz kindle
karmic delta
#

so reactions are still best for polls and giveaways if I dont want to store it in a DB 😢

ancient nova
#

is it actually impossible to do that?

quartz kindle
#

thats what i said will work

ancient nova
#

oh I thought you mean the first if statement

quartz kindle
#

i meant the bool variable

ancient nova
#

ah that makes more sense

#

let me try that out then

quartz kindle
#

also you dont need 2 identical ifs

#

why do you have this 2 times?

ancient nova
quartz kindle
#

ah

#

you can still make it better tho

ancient nova
#

how?

#

oof, this is an issue

#

Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement

#

this is definitely not good

wheat mesa
#

why are you doing idle;

#

or something like chase;

ancient nova
#

Tim did that

#

Update is called every second

#

it's basically a loop

wheat mesa
#

I think he was giving you pseudocode

quartz kindle
#
if(!playerInAttachRange && !isPlayingJumpscareAnim) {
  if(playerInSightRange) {
    ChasePlayer();
  } else {
    Patroling();
  }
  ChoseSound(idle ? SoundManager.playingIdle : SoundManager.playingChase);
  idle = !idle;
}
ancient nova
#

oh

#

well let me try this then!

wheat mesa
#

I want to do 2d unity but I'm too lazy to learn unity

#

I think my knowledge of C# is good enough to do it though

ancient nova
#

c# is fairly similar to javascript, if you know this language it won't take you long to learn it

wheat mesa
#

I already know C# pretty well

#

It’s not C# that’s the problem, it’s learning Unity/game dev and learning how to structure a game “properly”

ancient nova
#

ah, that took me quite a bit to learn properly

quartz kindle
#

gayme

ancient nova
#

maybe because I started off big, normally you'd supposed to make UI based games, then 2D games and lastly, 3D games

#

I went straight to 3D

wheat mesa
#

I tried to get into 2d game dev but I got bored of the low level stuff with C++ and SDL

ancient nova
#

@quartz kindle lol I suppose it works in switching between the statements but it still executes every time update is called

#

I'm saying it's impossible

#

physically cannot do this

ancient nova
#

just the plain interface is what makes it more enjoyable

quartz kindle
ancient nova
#

suppose you have a infinite function like so

setInterval(() => {
if (statement) {
//execute only once, then wait til you need to be executed again.
}
if (!statement) {
//execute only once, then wait til you need to be executed again.
}
}, 1);
#

it's simple to do it with one if statement

#

it's just one bool

#

but if you have to constantly switch between the if statements

quartz kindle
#

what defines when it will be needed again?

ancient nova
#

it's impossible

#

playerInSightRange = Physics.CheckSphere(transform.position, sightRange, whatIsPlayer);
playerInAttackRange = Physics.CheckSphere(transform.position, attackRange, whatIsPlayer);
this

#

both of those are bools

#

but if statement is true then it goes constantly

#

same with !statement

quartz kindle
#

i still dont get what you're trying to do

ancient nova
#

so this is my script

quartz kindle
#

you want ChoseSound to be called when?

ancient nova
#

the first time the if statement is called, the if statement will keep getting called, but ChooseSound only executes once

#

same with the second if statement

dry imp
#

damn, wanna try unity game dev again but my shitty mac cant even run unity properly

ancient nova
quartz kindle
#

so you want to call Patroling only if not already patrolling is that it?

ancient nova
#

only choosesounds is called once

dry imp
ancient nova
#

that's a little bit low

dry imp
#

tf do i supposed to test the movement

ancient nova
#

that's why I hate apple though

quartz kindle
#

so only call ChoseSound(idle) if not already playing idle

ancient nova
#

oh actually it might work now that I think about it

#

just give me a couple seconds to verifty

quartz kindle
#
if(!playerInAttachRange && !isPlayingJumpscareAnim) {
  play = false;
  if(playerInSightRange) {
    ChasePlayer();
    if(idle) {
      idle = false;
      play = true;
    }
  } else {
    Patroling();
    if(!idle) {
      idle = true;
      play = true;
    }
  }
  if(play) {
    ChoseSound(idle ? SoundManager.playingIdle : SoundManager.playingChase);
  }
}
ancient nova
#

you think this will work?

#

imagine this in a infinite interval

dry imp
ancient nova
#

choosesound will keep being executed

#

oh

quartz kindle
ancient nova
#

not sure

#

I'll test it

#

cause my brain is melting and I can't run the code in my head

ancient nova
quartz kindle
#

yes play can be inside update

ancient nova
#

this is so weird

#

can you maybe do this? @quartz kindle ```cs
// both of these if statements are called in Update() meaning they will constantly be called, as if it were an infinite loop.
//is called if everything is false
if (!playerInSightRange && !playerInAttackRange && !isPlayingJumpscareAnim) {
Patroling(); //<- will be called everytime the if statement is called
ChooseSound(SoundManager.playingIdle); //<- make this be called only once, until the second if statement is called.
}
//is called if everything is false, but playerInSightRange is true.
if (playerInSightRange && !playerInAttackRange && !isPlayingJumpscareAnim) {
ChasePlayer(); //<- will be called everytime the if statement is called
ChooseSound(SoundManager.playingChase); //<- make this be called only once, until the first if statement is called.
}

quartz kindle
#

thats exactly what i did

ancient nova
#

yeah but it doesn't seem to work

#

no sound is playing whatsoever

#

meaning nothing executes

earnest phoenix
#

Any idea why this is showing wrong?

quartz kindle
#

well, show the code you actually did

earnest phoenix
austere surge
#

it uses a different format

quartz kindle
earnest phoenix
#

oh my bad

ancient nova
#
if(!playerInAttackRange && !isPlayingJumpscareAnim) {
  play = false;
  if(playerInSightRange) {
    ChasePlayer();
    if(idle != false) {
      idle = false;
      play = true;
    }
  } else {
    Patroling();
    if(idle != true) {
      idle = true;
      play = true;
    }
  }
  if(play) {
    ChooseSound(idle ? SoundManager.playingIdle : SoundManager.playingChase);
  }
}```
#

left it almost exactly the same

quartz kindle
#

can you create variables in c# without defining them?

#

like dont you need something like bool play = false or var or whatever?

ancient nova
#

I do

#

private bool name = state;

#

I define them outside of the function

#

play = false overrides it

quartz kindle
#

show the entire class

ancient nova
#

do you want the entire code?

quartz kindle
#

yes

ancient nova
#

it's not really that long

#

okay give me a second

quartz kindle
#

it should work, the only problem i see is that patrolling will not play until you chase once, because idle is initialized as false

#

can you initialize a boolean as null or undefined/unset in c#?

#

are these sounds played in a loop?

#

or do they have a specific duration?

ancient nova
quartz kindle
#

if they have a specific duration, you need an additional variable to check if its currently playing something or not

ancient nova
#

there isn't anything specified as undefined, but null could work

#

if (!AmbientSounds.isPlaying)

#

this is how you'd check if the music is playing

quartz kindle
#

then you can get rid of the idle variable altogether

ancient nova
#

can you do it and send the code back?

wheat mesa
#

lol

earnest phoenix
wheat mesa
#

🥣

ancient nova
#

I feel like

wheat mesa
#

then take a break

#

just sayin

ancient nova
#

I have to finish my todo list for today

#

otherwise I can't sleep

quartz kindle
#
if(!playerInAttackRange && !isPlayingJumpscareAnim) {
  if(playerInSightRange) {
    ChasePlayer();
    if(!AmbientSounds.isPlaying) {
      ChooseSound(SoundManager.playingChase);
    }
  } else {
    Patroling();
    if(!AmbientSounds.isPlaying) {
      ChooseSound(SoundManager.playingIdle);
    }
  }
}
``` this is literally all you had to do since the beginning lol
wheat mesa
#

it's important to take breaks to fight burnout

quartz kindle
#

since you have a way to check if something is playing or not

ancient nova
#

wait but what if I want it to change abruptly

quartz kindle
#

can you check which one is playing?

ancient nova
#

I think so, let me check the docs real quick

quartz kindle
#

if(!AmbientSounds.isPlaying || AmbientSounds.clip != AmbientIdle) { hooseSound(SoundManager.playingIdle); }

ancient nova
#

actually no

#

wait

#

I'm at a dilema cause normally you'd use that to set a clip not check for it

quartz kindle
#

what type is AmbientIdle?

ancient nova
#

if(AudioSource.clip == clipToTest && AudioSource.isPlaying) { ... }

#

yeah so that's what I got from the docs

#

you can use it like this

ancient nova
quartz kindle
#

so yeah, just invert the if

#

you want to check if its not playing, or if its not playing the right clip

ancient nova
#

should I use &&?

quartz kindle
#

if(!AmbientSounds.isPlaying || AmbientSounds.clip != AmbientIdle)

ancient nova
# quartz kindle if(!AmbientSounds.isPlaying || AmbientSounds.clip != AmbientIdle)

gotcha

if(!playerInAttackRange && !isPlayingJumpscareAnim) {
  if(playerInSightRange) {
    ChasePlayer();
    if(!AmbientSounds.isPlaying || AmbientSounds.clip != AmbientIdle) {
      ChooseSound(SoundManager.playingChase);
    }
  } else {
    Patroling();
    if(!AmbientSounds.isPlaying || AmbientSounds.clip != AmbientChase) {
      ChooseSound(SoundManager.playingIdle);
    }
  }
}
#

let's hope this works

quartz kindle
#

the clips are wrong

#

if not chase, then play chase

#

if not idle, then play idle

ancient nova
#

my bad thought you set them like that on purpose so didn't change

#

@quartz kindle holy shit I think it actually worked

#

thanks

#

I couldn't have done this without you

#

it's awesome how you always manage to help me even if I use an entirely different language lmao

quartz kindle
#

most of the logic is the same in all langs

boreal iron
#

if hungry then eat else die

#

Yes it is!

ancient nova
lyric mountain
quartz kindle
#

you're hard to read

ancient nova
#

dang it now I'm stuck on this

#
            incrementValue += Time.deltaTime * 0.5f;
            float result = Mathf.Lerp(1,0,incrementValue);
            this.transform.position = Vector3.Lerp(initialValue, PlayerFace.transform.position + (1.5f * PlayerFace.transform.forward), result);
#

the player ends up going below the this object

lyric mountain
#

Wouldn't it be better to use double? Since you're dealing with position

wheat mesa
#

unity works more with floats iirc

simple stump
#

Using zlib and NodeJS, how would I extract the contents of a .7z, .tar, etc. archive to a folder?

lyric mountain
#

Can't u pass the file through tar command?

#

tar -xtract ze files

#

Now u never forget

lament rock
#

child processes

simple stump
#

Ah ic. Thank you I'll look into child processes and alternatives.

lyric mountain
#

Call tar from the main process

#

Idk abt node, but in java you can even wait for a result

lament rock
#

I don't think you can execute another process within the main process. It would have to be done with a child process

#

unless you mean spawn under main process as a child process of main

earnest phoenix
#

Any reason this error could be popping up?

I am trying to use mongoose to put store a document, but just keep getting this

austere surge
#

your connection is probably too slow

earnest phoenix
#

lemme try something rq

earnest phoenix
pine nova
# earnest phoenix Any reason this error could be popping up? I am trying to use mongoose to put s...
earnest phoenix
pine nova
#

💀

#

can u show the code where u connect to db?

earnest phoenix
#
const connectToDb = async () => {
    await mongo().then(async (mongoose:any) => {
      try {
        console.log('Connected to DB')
     } finally {
        mongoose.connection.close()
      }
    })
  }

  await connectToDb()```
#

this worked, up until just recently
like, I was adding things to the db just fine about an hour ago

quartz kindle
#

why do you close the connection immediately?

earnest phoenix
#

shit

pine nova
#

lol

earnest phoenix
#

im stupid

#

thank you for pointing that out

#

forgot to remove it after testing smh

civic scroll
#

you imported discord while already imported discord

#

looks like copy-paste codes

#

overview

#

that's what hit my eyes first

#

the 1st line of async run

#

you could just Discord.MessageEmbed

#

why not most of the time?

quartz kindle
#

names are case sensitive

#

if you named it Discord, then its Discord.MessageEmbed, not discord.MessageEmbed

split hazel
#

does anyone happen to know databases like sqlite work under the hood?

#

like how do stored records get physically represented in a file

#

because im interested in how they deal with fragmentation because of deleting records

bright hornet
tulip cradle
#

js { label: "Channel Updates", description: `${client.emoji.THEME} | ` + "Set the channel for logging channel updates", value: "channel_logs", },

boreal iron
#

iirc descriptions only support text and numbers and no special chars or emojis

#

But the select menu option can have an emoji

earnest phoenix
#

heelo there

quartz kindle
split hazel
#

I'm just thinking of a strategy on approaching this issue

#

since you can't just delete bytes

#

unfortunately

#

so will they be replaced or

#

is there an index of deleted blocks

#

so they can be replaced

quartz kindle
#

yeah there are many strategies for this

#

all of them have drawbacks

#

there isnt a single best solution

snow vector
#

i made it

lyric mountain
#

holy that's some high level necromancy there

#

so, how did it go?

snow vector
#

good

#

im gonna touch up the css so it looks better but

lyric mountain
snow vector
#

raw web sockets

lyric mountain
#

good

#

well, you're pretty much set up then, now it's just working on the front end

snow vector
lyric mountain
#

did u find it hard or pretty straightforward?

snow vector
#

in between i had never made anything in phpMyAdmin and the layout confused me but other then that it went pretty smoot

lyric mountain
#

oh, phpmyadmin

#

use pgadmin4

#

php<something>admin is generally used as a fallback alternative to manage the database

#

I asked regarding the websocket itself

snow vector
#

thats just what i can use on my hosting

lyric mountain
#

ah, mysql, I misread postgres

#

well then phpmyadmin is the best option

snow vector
#

yeah lol

lyric mountain
#

is it the only database available?

snow vector
#

on my hosting?

#

yes

haughty scaffold
#

Can anyone help me with my topggpy? I wrote this but it did not work. I tried asking in #topgg-api but no one answered so I wanna ask here 😭

import discord
from discord.ext import commands, tasks
import topgg
from config import *

class TopGG(commands.Cog):
    def __init__(self, bot):
        self.client = bot
        self.token = DBL_TOKEN # set this to your DBL token
        self.dblpy = topgg.DBLClient(self.client, self.token, autopost=True, post_shard_count=False)


    @commands.Cog.listener()
    async def on_dbl_vote(self, data):
        print(data)

def setup(bot):
    bot.add_cog(TopGG(bot))
haughty scaffold
#

What is route?

solemn latch
#

It's the part that goes at the end of your webhook url

http://serverip:port/dbl for example

haughty scaffold
solemn latch
#

If you want, but its often faster asking here or in #topgg-api.
Others often catch things I don't ^_^

haughty scaffold
solemn latch
#

You probably shouldn't share your webhook url with me either.

haughty scaffold
#

Help me please 😭

solemn latch
#

did you fill in your url and auth on your bots edit page in the webhook section?

solemn latch
#

and you didnt use a discord webhook url correct?

haughty scaffold
solemn latch
#

topgg webhooks dont work with discord webhooks

haughty scaffold
solemn latch
#

ah

solemn latch
haughty scaffold
solemn latch
#

topgg only allows one webhook at a time, as far as I know you cannot use two on any site.

haughty scaffold
#

Like links that I can get the routes one

earnest phoenix
#

hello

solemn latch
solemn latch
#

your url would be
http://VPSIPHERE:PORTHERE/ROUTE

haughty scaffold
#

Oh

haughty scaffold
solemn latch
#

how else do you expect to receive the events?
webhooks are pretty standard for receiving data.

haughty scaffold
solemn latch
#

yeah, webhooks are the easiest and most performant way of doing that.

haughty scaffold
solemn latch
#

well, its incomplete

#

webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000
is missing

solemn latch
#

it can be any standard characters

#

kiandkiasndkd

#

would be a valid path

#

you're the server, you get to decide those things

haughty scaffold
#

But the VPS only hosts the bot tho-

solemn latch
#

most vps providers allow web requests

haughty scaffold
#

@solemn latch So the stucture is <IPAdress>:<PORT>/<anything here>?

solemn latch
#

yeah, as long as <anything here> is the same on topgg and webhook_path='/<anything here>'

haughty scaffold
#

Ohh

#

I got it, let me try

solemn latch
#

the auth you decide, as long as its standard characters
a-z A-Z 0-9 and a few others are allowed

haughty scaffold
#

cool

#

@solemn latch Bro can we get the url in Vote tracker bot?

solemn latch
#

you can use vote tracker or your own webhook.
not both

solemn latch
#

seems they provided it.

#

your code wont function if you use that though

haughty scaffold
#

O

#

sadge

#

However- can we do the track without webhook?

solemn latch
#

we only provide webhooks.

haughty scaffold
solemn latch
solemn latch
#

deleted for privacy reasons

haughty scaffold
#

ah

#

it's fine

solemn latch
#

the webhook url cannot be visited in a browser, its only for server to server communication(otherwise it would be called a website)

haughty scaffold
#

O

#

Nvm I will try it tmr

#

gtg

atomic kindle
#

Should I finally give in and use bcrypt or continue hashing passwords using SHA?

wheat mesa
#

BCrypt and salting

atomic kindle
#

Doesn't bcrypt require salts by default?

wheat mesa
#

I don’t think so

#

But they might, can’t remember

sudden geyser
#

there's argon as well

split hazel
#

anyone know a good tool to look inside a programs memory (including heap) and search the contents?

#

i tried cheat engine but it doesnt support regex text searching

lyric mountain
#

I'd be more amazed if it did support

#

heap is most of the time huge

split hazel
#

or at least one that can monitor page reads

#

that should probably be easier

woeful pike
#

SHA is relatively fast because it's general purpose. Password hashes are specifically meant to be slower to make brute force even harder so you should probably switch

wheat mesa
boreal iron
#

Bcrypt does generate its own cryptographic safe salt key

#

(by default)

#

But you shouldn’t set the generation cost to a too low value

simple stump
#

How would I use ES modules in a commonjs file? Ex.

import someModule from someModule;

// But I want:
const someModule = require("someModule");

Reasons for this is that I don't want to have to go through every single file and change require to import. Most of the modules I use are not ES modules anyways, so changing such things for just one module would break a lot of things.

pale vessel
#

you'd have to use const someModule = await import("someModule");. there's no other way besides migrating to ESM and using search & replace function of your editor

fallen holly
#

HI i'm making a website with nodejs first time on web dev how do i fix this

pale vessel
#

require() is only in node

fallen holly
#

huh

pale vessel
#

browser JavaScript is not node

#

if you're making a website in node.js, chances are the backend is in node.js

fallen holly
#

How do i change the backend

pale vessel
#

i'm not sure what you're trying to do

#

what part of your code has require() in it and what is it for?

crimson vapor
#

oh shit flaze is talking again

#

hi

fallen holly
#

making an url shortener so i'm using bitly api and i'm requiring node-fetch

pale vessel
#

why are u running the code in the browser console?

fallen holly
#

i'm not

pale vessel
#

ah if u want fetch, simply use fetch()

#

it's built in

fallen holly
wheat mesa
#

then you can't POST to that url

earnest phoenix
#

For some reason I am getting a permission error even though the bot has permissions and intents to ban (which is what I am trying to do)

wheat mesa
#

show the error and the code associated with it

earnest phoenix
#

Any reason that this could be happening?

Here is the error:

wheat mesa
#

check your bot's permissions again

earnest phoenix
wheat mesa
#

because the likely reason is that you didn't check the right perms

earnest phoenix
#

it has admin

#

lemme try just ticking ban rq

solemn latch
earnest phoenix
#

Found the issue.. It's because of the fact that bot was below the role that the user had..

Is there a way to catch this and just return an error in Discord saying to make sure the bot role is above the person you're trying to ban?

solemn latch
#

its called manageable

earnest phoenix
#

gotchhhaaaaa

#

thank you veryyy much

rocky hearth
#

how do I uninstall all global packages, with yarn?

bright hornet
#

is there any way to delete the timeout using d.js?

rocky hearth
bright hornet
earnest phoenix
#

Hey there...

I am using MongoDB as a database and am trying to check if a certain value within a document equals something.

What I am trying to do is check if the user wants to display the ban publicly and does not have a channel configured using this code:

if (isPublic && dbdata.publicChannel == "none") {

      interaction.reply({
        content: 'there we go'
      })
      
    }```

the `publicChannel` is set to `"none"` when a bot is added to the server and then is updated using a command.

Anyways.. When I run my code, all I get is an error saying the application didn't respond or whatever with no error in the console.

Any reason this could be happening?
Thanks in advance
#

isPublic is a boolean the user provides
dbdata is the findById that I have set up

#

And everything works fine when I remove this if statement..
And I would just remove it, but it is needed

lament rock
neat current
earnest phoenix
#

What here could not allow my bot to reply to interactions?

neat current
earnest phoenix
neat current
lament rock
neat current
#

I thought you have problem with reply 😄

earnest phoenix
earnest phoenix
lament rock
#

because your logic is flawed or dead-ending

earnest phoenix
#

but it's just a command that says "hello world" Cry

lament rock
#

Show your code so we can help better

earnest phoenix
#
import { ICommand } from 'wokcommands'

export default {
  category: 'ban',
  description: 'Bans the user, for the reason given. Will also display the ban in the configured channel',

  slash: true,
  testOnly: true,
  guildOnly: true,

  permissions: ['BAN_MEMBERS'],

  options: [
    {
      type: 'USER',
      name: 'user',
      description: 'The user you want to ban',
      required: true
    },
    {
      type: 'BOOLEAN',
      name: 'public',
      description: 'If "true", the log will be sent to the configured public channel. If "false", it will not.',
      required: true
    },
    {
      type: 'STRING',
      name: 'reason',
      description: 'The reason you are banning this member.',
      required: false
    }
  ],

  callback: async ({ interaction, guild }) => {

    const configSchema = require('../schemas/config-schema')

    const user = interaction.options.getUser('user')
    const buser = guild?.members.cache.get(`${user?.id}`)
    const isPublic = interaction.options.getBoolean('public')
    const reason = interaction.options.getString('reason')

    const dbdata = await configSchema.findById(`${interaction?.guildId}`)

    function isReason () {

      if (reason) {
        return reason
      } else {
        return 'No reason provided.'
      }

    }

    
    const logChannel = guild?.channels.cache.get(`${dbdata.publicChannel}`)
    if (logChannel?.type === 'GUILD_TEXT') logChannel.type === 'GUILD_TEXT'
    else return

    const publicEmbed = {
      author: {
        name: `${user?.username}#${user?.discriminator} was banned!`,
        icon_url: `${user?.displayAvatarURL()}`
      },
      description: `
• **User:** ${user} (${user?.username}#${user?.discriminator})
• **Moderator:** ${interaction.user} (${interaction.user?.username}#${interaction.user?.discriminator})`,
      fields: [
        {
          name: 'Reason they were banned',
          value: `${isReason()}`
        }
      ],
      color: 0xff0028,
      footer: {
        text: `Bannin' Bonnie | User ID: ${user?.id} | Moderator ID: ${interaction.user?.id}`
      }
    }

    const succEmbed = {
      description: `![anicheck](https://cdn.discordapp.com/emojis/960755807937499166.webp?size=128 "anicheck") **${user?.username}#${user?.discriminator}** has been banned!`,
      color: 0x3cb371
    }

   interaction.reply({
     content: 'hello'
   })

    /*if (!buser?.manageable) {

      const errEmbed = {
        description: `![anix](https://cdn.discordapp.com/emojis/961040332697501747.webp?size=128 "anix") This user is not manageable!\nPlease make sure that the bot role is above the person you are trying to ban!`,
        color: 0xff0028
      }

      interaction.reply({
        embeds: [errEmbed]
      })

      return 

    }*/ 

  }
} as ICommand```
#

I have the one part commented out for troubleshooting

lament rock
#

How interactions works as compared to message command handling is that you HAVE to respond. Simply returning without telling the user anything does not help the user or you

earnest phoenix
lament rock
#

yup

#

it's just something in general as well

earnest phoenix
#

So even though the command that sets the channel makes sure it is a GUILD_TEXT channel, I should also make sure it is here in the ban command?

#

And then, if it isn't for who knows what reason, return an error embed or something alike?

#

And that helped

THANK YOU @lament rock

lament rock
#

always sanity check yourself because unintended logic will always occur if you allow room for it to

earnest phoenix
#

yea

#

i was about to go insane, I've been on this for 2 hours ahhhhhhhh

lament rock
#

If something so simple got me stuck, I would go insane too. Something did happen yesterday where I was working on a Discord gateway lib I maintain where if Discord asked my client to reconnect, it would connect to the gateway, but it wouldn't receive the HELLO packet (which Discord always sends). Turns out that I removed all listeners from the ws implementation which was a relic of old design. Needless to say I shouted plenty of obscenities at myself after 4 hours of console logging and debugging

earnest phoenix
#

Been there done that

#

Not that exact situation, but some like it

neat current
#

Discord token and refresh. one time, I had no error on console everything was perfect I was getting the response from discord api but I can't send the request. Slash command auto complete was showing nothing even if I send data back. I have a friend who is newbie on programming he told me that dude refresh the token maybe it expired. afterwards, I refreshed the token and it worked 😄

earnest phoenix
#

oml Peepo_Joy

#

speaking of newbies

lament rock
#

its the little things. I'm at the point of js mastery, but I'm still dumb as fuck

earnest phoenix
#

what permissions do you need to send to other channels?
Just the send messages permission, correct?

neat current
#

I think Send Message is covering for that ?

lament rock
#

VIEW_CHANNEL and SEND_MESSAGES

neat current
lament rock
#

That area doesn't matter since guilds and channels are what takes precedence

earnest phoenix
lament rock
#

users with MANAGE_ROLES can change the permissions anyways

pine nova
#

💀

lament rock
#

Welp. Those are the permissions, so check again

earnest phoenix
lament rock
#

like I said, that page does not matter whatsoever

#

the channel overrides are what matters

earnest phoenix
#

okay

#

now

#

how would I check if the bot has permission?

#

to send messages to that channel

lament rock
earnest phoenix
bright hornet
#

how can i add canva image on embed?

pale vessel
#

upload the image as an attachment first and use the url

empty moth
#

Would someone know a way to remove a role automatically when another role is granted ? I have a visitor role, but once people are granted "member" role, I want visitor to be removed. Member role is granted through a bot (easy applications).

earnest phoenix
civic scroll
empty moth
civic scroll
empty moth
#

none I believe ? I just use a few bots and that's it.

rocky dagger
#

i got a map of userIds from a queue i made and want to turn it into user tags instead, ik i can use client.users.cache.get for ids if they are in a string but it doesnt look like it works in a map js const stringArray = queue.map(obj => `${obj.queue.userID}`); console.log(stringArray); const joinedString = stringArray.join('\n'); console.log(client.users.cache.get(joinedString));

#

or if it much easier just tag the user but i preferably wouldnt

rocky hearth
#

can I access a global variable inside a js function?

#

coz, I hv a local variable with same name, in that funciton

lament rock
#

If queue is an Array, that returns an Array<User>. If it's a Collection, that would return Collection<string, User>

lament rock
#

global is a constant

#

if it's webjs, you'd use window

rocky hearth
#

doesnt fetch works in nodejs?

lyric mountain
rocky dagger
#

yes

lyric mountain
#

just replace the very first line in ur code with```js
const stringArray = queue.map(obj => <@${obj.queue.userID}>);

#

no need to get anything, discord will parse that into a mention

unkempt cloak
#
[Error_Handling] :: Uncaught Exception/Catch (MONITOR)
TypeError: client.voice.onVoiceStateUpdate is not a function
    at VoiceStateUpdate.handle (/home/container/node_modules/discord.js/src/client/actions/VoiceStateUpdate.js:29:22)
    at Object.module.exports [as VOICE_STATE_UPDATE] (/home/container/node_modules/discord.js/src/client/websocket/handlers/VOICE_STATE_UPDATE.js:4:35)
    at WebSocketManager.handlePacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:351:31)
    at WebSocketShard.onPacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
    at WebSocketShard.onMessage (/home/container/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
    at WebSocket.onMessage (/home/container/node_modules/ws/lib/event-target.js:199:18)
    at WebSocket.emit (node:events:526:28)
    at Receiver.receiverOnMessage (/home/container/node_modules/ws/lib/websocket.js:1137:20)
    at Receiver.emit (node:events:526:28)
    at Receiver.dataMessage (/home/container/node_modules/ws/lib/receiver.js:513:14) uncaughtException
 [Error_Handling] :: Uncaught Exception/Catch```

anyone know how to fix it ?
lyric mountain
#

TypeError: client.voice.onVoiceStateUpdate is not a function

rocky dagger
lyric mountain
#

?

#

like, if u want the username u do need to get the user object

#

that's why I asked "with 'tag' do you mean <@mention>?"

rocky dagger
#

thats why i said or if it much easier just tag the user but i preferably wouldnt

rocky hearth
#

how does axios works in both browser and nodejs?

rocky dagger
lyric mountain
#

obviously

#

console wont parse the mention

rocky dagger
#

i also replied in discord

lyric mountain
#

because you don't share a guild with that user

#

what's that command for?

rocky dagger
#

to list a queue from a database

lyric mountain
#

no, I mean, is it public or dev-only?

rocky dagger
#

currently me only but i will make it public

lyric mountain
#

if ur going to show members of other servers then yes, you need to grab the username

rocky dagger
#

im not

lyric mountain
#

then using a mention is fine

#

since members of the same guild will always show as a valid mention

#

just put the mentions inside an embed or disable mentioning users so they don't get pinged

rocky dagger
#

well, it didnt ping me

lyric mountain
#

is it inside an embed?

rocky dagger
#

no

lyric mountain
#

then it should be disabled globally, else it'd have pinged

rocky dagger
#

weird

#

nvm it works now

jovial parcel
#

i found a bug in my bot that will take awhile to fix. if i delete it from top.gg will i be able to readd it again later (assuming with review)?

quartz kindle
#

yeah, but why would you want to remove it? just leave it there, nobody cares lol

jovial parcel
#

cause first impressions, ya know?

proven cloak
#

Here You see that Emoji ? i wanna know how to do that in discordjs

earnest phoenix
# proven cloak Here You see that Emoji ? i wanna know how to do that in discordjs

You can use the setEmoji() method on the MessageButton class instance to do so
https://discord.js.org/#/docs/discord.js/stable/class/MessageButton?scrollTo=setEmoji

dry imp
#

amogus github

earnest phoenix
slender wagon
#

can i use fs on vanilla js

#

or something similar idk

pale vessel
#

erm, no

#

that would be a huge security vulnerability

slender wagon
#

oh shit you are right

#

what iff i encode it real hard

#

Also this is a project i am not taking really seriously

#

@pale vessel come here heheh

#

does encoding work

#

like would it make it safer somehow

vast cedar
#

when i map all my guilds, some guild id, guild name and icon are undefined, someone know why?

pale vessel
#

what are u mapping it to?

quartz kindle
slender wagon
#

but i did use something similar to fs on a vanilla project earlier

vast cedar
quartz kindle
#

there is the browser FileSystem api which can access temp files and such https://developer.mozilla.org/en-US/docs/Web/API/FileSystem

The File and Directory Entries API interface FileSystem is used to represent a file system. These objects can be obtained from the filesystem property on any file system entry. Some browsers offer additional APIs to create and manage file systems, such as Chrome's requestFileSystem() method.

pale vessel
slender wagon
slender wagon
#

like it has more info than stackoverflow

#

the answers are there lmao

quartz kindle
#

it has a huge community maintaining it

slender wagon
#

ohhh that's why

vast cedar
# pale vessel show ur code
const guildData = await data.guilds.cache.sort((a, b) => b.memberCount - a.memberCount).map(guild => {
            return `Name: ${guild.name} ID: ${guild.id}`
}); 
slender wagon
#

i've been always wondering

vast cedar
#

I dont see anything wrong with the code

#

But some guild return undefined as id or server name

quartz kindle
#

you dont need await

#

also what is data?

vast cedar
#

data is the client

quartz kindle
#

is the client logged in?

vast cedar
#

yes he is

#

sometimes i get the id and the name is undefined

slender wagon
#

u have to fetch the members first

quartz kindle
#

do you have sharding? do you use guilds.fetch(id) anywhere?

#

do you use guilds.cache.set() anywhere?

vast cedar
#

No i dont have anything this is just a 10 line script where i map all guilds

 '957844928900247612' => <ref *62> Guild {
    id: '957844928900247612',
    name: undefined,
    icon: undefined,
    features: undefined,
    //... 
slender wagon
#

uhh what?

quartz kindle
#

not only in this script

#

show how you define data

vast cedar
#
const bots = new Collection()

bots.set(guild.id, new Client({ intents: 32767 }))

const data = bots.get(guild.id);

await data.login(token)

// and the map after this
quartz kindle
#

what

earnest phoenix
quartz kindle
#

what even is that

#

that doesnt make any sense

slender wagon
vast cedar
#

Yes

slender wagon
#

don't just copy and paste code please

quartz kindle
#

why are you creating multiple clients

vast cedar
#

I need a different bot for each guild

quartz kindle
#

why?

vast cedar
quartz kindle
#

thats not how it works

vast cedar
slender wagon
#

u are hosting all of them on 1 vps?

quartz kindle
#

you have different tokens for each guild as well?

vast cedar
#

Yes

earnest phoenix
#

botghost hosting concept

quartz kindle
#

i mean

#

you have to keep in mind that each client will not have only that guild, and that if two bots share the same base guild one of them will be overwritten

#

also, awaiting the login is not enough to receive all guild data

#

that is why you are seeing undefined

#

guild data is only guaranteed to exist after the ready event

vast cedar
#

but it work when i map all guilds with eval, so this is weird

slender wagon
#

that's prolly cuz the ready event has done it's job?

#

Damn a custom bot for a "Claim your nitro" server Ooof

quartz kindle
slender wagon
#

just what i said hehe

vast cedar
#

okay thanks

slender wagon
#

if .onReady is finished you are good to go

#

that's it

vast cedar
#

yes it work now, thanks you :)

bright thorn
#

message.channel.messages.fetch();

am getting ratelimits on fetch so what i have to do

#

any optional idea?

wheat mesa
#

What are you fetching the messages for?

#

The simplest solution is don’t fetch that many messages™️

near stratus
quartz kindle
#

lmao

#

yes, lets fetch every single message we receive, that sounds like a good idea

boreal iron
#

Aye... if we're not allowed to receive the content anymore, just take down the API with spam as protest

rocky dagger
#

so i just added a new bot i made to a server and i am getting this error here DiscordAPIError[20012]: You are not authorized to perform this action on this application at SequentialHandler.runRequest (D:\programering\Coding\MyBots\discord.js\DJS v13\ark helper\node_modules\@discordjs\rest\dist\lib\handlers\SequentialHandler.js:198:23) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async SequentialHandler.queueRequest (D:\programering\Coding\MyBots\discord.js\DJS v13\ark helper\node_modules\@discordjs\rest\dist\lib\handlers\SequentialHandler.js:99:20) at async D:\programering\Coding\MyBots\discord.js\DJS v13\ark helper\src\functions\handleCommands.js:31:17 { rawError: { message: 'You are not authorized to perform this action on this application', code: 20012 }, code: 20012, status: 403, method: 'put', url: 'https://discord.com/api/v9/applications/811586423933108254/guilds/494567290990493696/commands' }

sick agate
#

perm issues

#

or scope

#

scope

wheat mesa
#

Make sure you invited it with the right scope

#

(applications/commands)

boreal iron
#
  • application.commands
wheat mesa
#

Same thing

#

You know the saying, PHP, potato, same thing!

boreal iron
#

quiet! texan boy

wheat mesa
quaint wasp
#

hey.. So umm, I sort of started hosting a website like a month ago

#

and completly forgot about it

#

and now I forgot its hosts name 😅

#

any of you know a host thats litilary named Git? I tried searching for it but all I got was the Git (not a host) and Github

#

ping in replies

green kestrel
#

just spent some time seeing how small we could get our compiled bots. we agreed on something like this

#include <dpp/dpp.h>
int main() { dpp::cluster bot("token"); bot.start(false); }

someone said 'oh in rust i can get a similar bot compiled and stripped symbols and it is 5mb'... so i did the same and...

brain@neuron:~$ g++ -std=c++17 -o testsize2 test2.cpp -ldpp -Os
brain@neuron:~$ strip testsize2
brain@neuron:~$ ls -alh testsize2
-rwxr-xr-x 1 brain brain 6.7K Apr  6 19:35 testsize2

kekeke

sick agate
green kestrel
#

i did the same and stripped symbols off triviabot... heres what happened

#
brain@neuron:~/triviabot/build$ ls -alh bot *.so
-rwxr-xr-x 1 brain brain 630K Apr  6 19:46 bot
-rwxr-xr-x 1 brain brain  24K Apr  6 19:46 module_bandwidth.so
-rwxr-xr-x 1 brain brain  89K Apr  6 19:46 module_diagnostics.so
-rwxr-xr-x 1 brain brain  32K Apr  6 19:46 module_presence.so
-rwxr-xr-x 1 brain brain 1.1M Apr  6 19:46 module_trivia.so
sick agate
#

nice

lyric mountain
#

@wheat mesa I hate bnf

#

first time trying to write a custom language compiler for intellij and I hate bnf

cinder patio
#

what is bnf

wheat mesa
#

What is bnf

#

Just use regular expression form instead (whatever it’s called)

#

This thing

lyric mountain
wheat mesa
#

Ah okay I see

lyric mountain
#

for example <test:any:R> is a parameter called "test", with type "any" and is required

wheat mesa
#

I haven’t done stuff like that

#

Much better than writing it by hand to be fair

lyric mountain
#

but that FEELS like regex, but isn't regex and I hate that

wheat mesa
#

With a parser and everything

lyric mountain
#

also it's fun that you could theoretically make a theme where all colors are random

#

just supply (int) (0xFFFFFF * Math.random()) when passing highlight color

#

it'll change everytime you do something

wheat mesa
#

Lol

#

Just randomly make valid code look like an error

lyric mountain
#

bruh, I spent 1 hour trying to find why this is capturing [] too

wheat mesa
#

Lol

lyric mountain
#

guess why?

#

damn unicode

#

now why understand why people use [A-Za-z] instead of [A-z]

solemn latch
#

lmao

boreal iron
#

yeah you should be careful if you don't wanna match ascii chars, too

#

If you don't care about the case sensitivity then simply add the i flag

#

[A-Z] or [a-z] will then both match the right chars but no ascii chars

lyric mountain
#

yay it works

polar sapphire
#

My bot was public and random people added it to their servers. How can i make my bot leave these servers like how premium bots leave servers? when you add them without premium subscription?

split hazel
#

if so it's as easy as guild.leave()

polar sapphire
#

Js, Thank you all, my friend helped me,

atomic kindle
#

I don't have much experience with sharding Discord bots. So, if I have messages that need to be fetched every time the bot is restarted, what would be the most efficient way of doing so?

solemn latch
#

broadcast eval fetch it

sterile lantern
#

How do we go about fetching users in discordjs v13? is it still client.users.fetch?

#

Ah wait nevermind it has to do with my intents

sterile lantern
#

how can i delete the embed that was sent

#

in this case, q1

#

like after it checks everything ofc

boreal iron
#

You edit the message and let it’s content as it is but pass an empty array for the embeds options

#

iirc message.edit({ embeds: [] }); will not affect the content

#

If there’s no content this will cause an error as a message can’t be empty

quartz kindle
#

one does not simply edit an embed :^)

boreal iron
#

One?

dim valley
#

hi

quartz kindle
#

meaning "a person cannot simply walk into X"

#

its impossible or too hard

boreal iron
#

Ffs

#

Please try to argue so that monkeys like I can understand you

simple stump
#

I'm trying to import an ES6 module in commonjs, but client keeps returning undefined.

let client;
import('es6-module-thing').then((_) => {
    client = new _.default();
});
module.exports.client = client;
quartz kindle
#

you cant do that

simple stump
#

Is there any way then I can import an ES6 module into commonjs without having to change all my require statements to import and modifying my package.json?

quartz kindle
#

treat it as an async function like it is

#

the closest you can do to that is this:

#
module.exports = function() {
  return import('es6-module-thing').then(_ => new _.default());
}

// file
const createClient = require("yourmodule.js");
// inside some async code
const client = await createClient();
simple stump
#

Okay tysm!

#

And I assume yourmodule.js is the file that contains the module.exports statement?

quartz kindle
#

ye

#

but you might as well just use the import line directly

#

its a 1 liner anyway, not much use putting it in a separate file

#

const client = await import('es6-module-thing').then(_ => new _.default());

simple stump
#

ah ic okay. tysm this is super helpful

slender thistle
#

await?

quartz kindle
#

is that a question, or...?

woeful pike
#

obviously there are exceptions to that like all rule of thumbs but it's a helpful way of thinking about managing when you need things and when they're available

quartz kindle
#

yeah but you cant import esm from cjs like that

woeful pike
#

ye I recognize there's a more important underlying issue here in specific

civic scroll
proven cloak
#

How to do Mention a Button, and a SelectMenu in SlashCmds ??

glacial yoke
#

hey, i was wondering how i would make it so when i say !help it sends the normal help cmd (which i already have) but then using buttons below you could click stuff like moderation, utility, etc and it will edit the message to show that. I've already got that but my issue is when i click something like moderation it edits the message but removes the buttons. how do i do that and still keep the embeds so it removes the moderation button and adds a "help" one and keeps every other one

#
import nextcord
from nextcord.ui import Button, View
from nextcord.ext import commands

class Help(commands.Cog):
     
     def __init__(self, client):
          self.client = client

     @commands.command()
     async def help(self, ctx):
          mod = Button(label="Moderation", style=nextcord.ButtonStyle.green)
          uti = Button(label="Utility", style=nextcord.ButtonStyle.green)
          
          ambed=nextcord.Embed(timestamp=ctx.message.created_at,colour=0x2986cc)
          ambed.set_author(name="Heroku Moderation", icon_url="https://media.discordapp.net/attachments/961439698750943243/961465912886697994/Hemi.png")
          
          async def button_callback(interaction):
               await interaction.response.edit_message(embed=ambed, view=None)
               
          mod.callback = button_callback
  
          wmbed=nextcord.Embed(timestamp=ctx.message.created_at,colour=0x2986cc)
          wmbed.set_author(name="Heroku Utility", icon_url="https://media.discordapp.net/attachments/961439698750943243/961465912886697994/Hemi.png")
  
          async def button_callback(interaction):
               await interaction.response.edit_message(embed=wmbed, view=None)
               
          uti.callback = button_callback
          
          embed=nextcord.Embed(timestamp=ctx.message.created_at,description="Heroku is a mainly Moderation & Utility bot, our goal is to make Heroku as simple and\neasy to use. Heroku is always in development and being worked on / getting huge updates, if you want to help out with Heroku dm `herq#4281`\nwith command idea's, or to become a developer for Heroku (If we are looking)",colour=0x2986cc)
          embed.set_author(name="Heroku", icon_url="https://media.discordapp.net/attachments/961439698750943243/961465912886697994/Hemi.png")
          
          view = View()
          view.add_item(mod)
          view.add_item(uti)
          await ctx.send(embed=embed, view=view)
#
def setup(client):
     client.add_cog(Help(client))
#

if you could help or if i don't make sense pls ping me

wheat mesa
earnest phoenix
#

whats the problem?

#

ping me please 😄

winter pasture
steep ivy
# glacial yoke ```py import nextcord from nextcord.ui import Button, View from nextcord.ext imp...

you should add an extra button with one of the button callbacks and in that same callback, disable a different button (I don't think it's possible to delete one entirely from the message):
i.e.

async def button_callback(interaction):
  new_button = discord.ui.Button(label=f"Play Amogus", style=discord.ButtonStyle.green, emoji=":video_game:")
  original_button.disabled = True
  # Or smth like that

I hope that helps

pulsar bone
#

they are asking me for verification but whenevr i upload my documents they say its invalid
i am uploading my adhaar card as my identity proof
can someone help me in it .

winter pasture
#

And what about my second question, what intents are you passing in currently? It is a required field

pale vessel
#

maybe they meant node 17

earnest phoenix
winter pasture
#

Yeah that is not relevant atm tho 😂
What is the answer for my other two questions lol. Kinda hard to help when you avoid them KEKW

winter pasture
winter pasture
pulsar bone
pulsar bone
winter pasture
#

I am guessing a PAN card is a aadhar card?

#

Humm... reading from the other server people mentioned a "aadhar card" worked. Are you 16 years or older?

#

Maybe try taking a clearer image in a brighter room?

pulsar bone
lyric mountain
#

check if there isn't a lib for that, making your own pagination handler can be quite hard to explain

twin bridge
#

Lol

neat ingot
#

so.. what you think would be the best way for me to, within my app, show how many users are currently using the app?

#

I'm thinking of, within the app, pinging some api with some random unique id that gets regenerated when the app reboots, and then on my api i can just count how many unique id's within like, the past 5 minutes

#

but idk

neat ingot
#

but then each active app would have a constant connection to my server, and that doesnt scale as nice as an occasional ping for a counter to be returned

lyric mountain
neat ingot
#

yea, but games would mostly already have an active socket for sending data

lyric mountain
#

wouldn't it be the same for your app? it's a 1-N relation

cinder patio
#

You could use UDP instead of websockets

sage bobcat
#

One message removed from a suspended account.

cinder patio
#

hmmm or you could just go with your solution

sage bobcat
#

One message removed from a suspended account.

neat ingot
#

I mean, my app doesnt need to be sending any other data though. using a socket just to check how many recent users seems kinda overkill 😄

#

but having some api that just gets pinged seems messy somehow

lyric mountain
#

well, either way you do need to set a connection between client <> server

#

websockets don't necessarily mean it'll be a bidi connection

neat ingot
#

yea, but lets take scale into account too. you can only have like 1000 sockets connected to any single endpoint iirc

#

for something thats sending a ping to get a counter once every 5-10 minutes, that seems like an unnessicary obstacle

slender wagon
#
let day1 = 2
let day2 = 2
let day3 = 1

//Let's check for the best combination and refuse the bad combinations

if (day1 === 1 && day2 === 2 && day3 === 3) {
    console.log(`Perfect :)`)
} else if (day1 === 2 && day2 === 1 || day1 === 3 && day2 === 1 || day1 === 3 && day2 === 2 || day2 === 2 && day3 === 1 || day2 === 3 && day3 === 1 || day2 === 3 && day3 === 2){
    console.log(`balls too`)
}else{
    console.log(`balls`)
}
#

look guys javascript

neat ingot
#

so i'd either have to implement some kind of load balanacing with multiple servers ready to spin up to record a counter, or just use an endpoint, and count how many uuid's in the past x time

earnest phoenix
slender wagon
#

yeah ik

#

what i wanna do is when day1 is bigger than day2 console log shit

slender wagon
#

same thing for day2 with day3

#

wait i am stupid

neat ingot
#

oh, apparently nginx has a hard limit of 65,535 concurrent connections 😄

cinder patio
#

64K for TCP

neat ingot
#

wth, why am i over here thinking 1k 😂

#

but still, keeping a connection open constantly vs a ping every x minutes, is it really better to socket it?

#

rather than just connect then close each time with a regular request

cinder patio
#

UDP sockets are cheap and there's no constant connection

#

just an open socket

neat ingot
#

I guess then it would really depend on how often im actually going to be polling the api

#

if i want users within 5 minutes, or an hour, or 24 hours, or whatever

#

like, if im doing it every 5 minutes maybe a socket would be better, but i think anything over one per 30 minutes would likely be better to just ping an endpoint

#

or i could just add google analytics to my app and get the data there 😂

#

but ~ eww, google. (sorry mr feud)

slender wagon
#
if (day1 < day2 && day2 < day3 || day1 === day2 && day2 < day3 ||day1 < day2 && day2 === day3 || day1 === day2 && day2 === day3) {
    console.log('Gucci')
}else{
    console.log('No good!')
}

which one? lmk if u got a better solution

cinder patio
neat ingot
#

😂

#

yea im likely going to set it up with udp as i think i do wanna be sending updates fairly frequently

quartz kindle
#

if you're pinging every 5 minutes you dont need sockets

#

sockets are meant for connections that update many times per second, if you're only doing it once every 5 minutes, you will end up wasting most of it to some kind of keepalive heartbeating

neat ingot
#

that was kind of my initial thinking in using just a basic ping type request. like, just having unrequired connections alive seems like a pointless waste of resources.

#

and its literally just to send some data like uuid and app version 😄

#

and to get a number returned

cinder patio
#

UDP is connectionless

#

one socket sends data other receives it, a connection is not required

#

with HTTP you're basically starting a connection and then closing it once you receive your data. So theoretically there's more overhead using HTTP than using UDP

lyric mountain
slender wagon
#

I forgor about that too

#

😂 💀

lyric mountain
slender wagon
#

I gotta keep a js operators list printed somewhwre

#

Somewhere

#

💀

lyric mountain
#

finally

#

dealing with autocompletion in intellij is annoying af

#

but at last my syntax checker is done

#

java

slender wagon
#

Thats ok too but the one Kuhaku did is good

slender wagon
#

I wanna learn java

lyric mountain
slender wagon
#

Thats the only lang i can get a job with in my country

#

Otherwise i would have to do frontend which i hate

#

I do know c# a bit

lyric mountain
#

learn either lang and you automatically learn the other

slender wagon
#

Used it for unity

lyric mountain
slender wagon
#

Is it gonna be hard to move from js to java

#

I've literally never touched java

lyric mountain
#

well, code migration is difficult when going from a dynamic lang to a static one

#

HOWEVER, to ease ur migration I'd recommend groovy

sudden geyser
lyric mountain
#

since it has a syntax VERY similar to js, but is technically java

#

and it's also dynamic

sudden geyser
#

js and java are incomparable imo

slender wagon
#

Hmm

lyric mountain
#

that's true, that's why I suggested groovy

slender wagon
#

The thing is i shall learn it just cuz thats what companies use here

#

Nodejs is almost unknown

#

Its either php or java

#

I dont wanna make a step back and learn php

sudden geyser
#

unknown where you are? I hear lots of jobs involve node.js

sudden geyser
#

makes sense

slender wagon
#

Yes

#

Its not africa

#

Its just fucked

#

No

#

Shut up init

#

Drugs

sudden geyser
#

one is a country and one isn't

slender wagon
#

Aaaaaa

#

Java

sudden geyser
#

If you plan on learning Java I recommend you check out Hyperskill

#

Taught me a lot of it

slender wagon
#

But the thing is if i find a company that uses nodejs i can get paid good

#

Since there is not many nodejs devs out here

#

Giv me sum $$$ and good advertsment

sudden geyser
lyric mountain
#

s!eval ```groovy
def getOr(var a, var b) {
return a ?: b
}

getOr(null, "abc") // prints abc
getOr(5, "abc") // prints 5

this see the similarity with js?
lyric mountain
slender wagon
#

Shushhh

lyric mountain