#development

1 messages ยท Page 92 of 1

neon leaf
#

oh

quartz kindle
#

deflate is compression

neon leaf
#

thats pretty unintuitive

quartz kindle
#

well

#

deflate makes it smaller

#

pushes the air out of it

#

inflate makes it bigger

neon leaf
#

ah

quartz kindle
#

fills it up with air

#

xD

wheat mesa
#

Me when enums exist:

neon leaf
#

why would I wanna use an enum for that, that just seems annoying

wheat mesa
#

Union types with strings are annoying

#

They both perform the same function in this case but if it were me Iโ€™d prefer an enum there

maiden gazelle
#

hello can somebody help me with the last step of my afk command i need to make it that when someone mentions a person who triggered the >afk command it sends a embed with "this person is afk, reason: reason here" but my exactly problem is that i dont know how what to put in a messageCreate event to react when somebody got mentioned

quartz kindle
#

the message object contains a mentions field

maiden gazelle
#

uhhh yes how can i make that

quartz kindle
maiden gazelle
#

okay thank you

agile field
#

where can i find my top.gg token

#

do i need to add my bot?

deft wolf
#

Yes

agile field
#

hmm

#

thx

real oriole
#

Yeah that's what I thought but I'm not getting that, I get everything else but that

quartz kindle
#

try testing it in a webhook tester website

#

and try changing your auth and saving again

#

to refresh the value

real oriole
# quartz kindle weird, works fine for me

this is what i get in the headers from the webhook
// "headers":{
// "accept":"application/json, text/plain, /",
// "content-type":"application/json",
// "user-agent":"Top.gg Webhook/1.0.0",
// "content-length":"101",
// "host":"*************",
// "connection":"close",
// "geoip-addr":"***********",
// "geoip-continent-code":"NA",
// "geoip-country-code":"US",
// "geoip-country-name":"United States"
// },

hushed robin
#

how would I check if a button is disabled in d.js?

spark flint
real oriole
quartz kindle
#

like nginx, or cloudflare

real oriole
#

need to talk to host maybe to see if they can allow it to pass through

#

be easier if they used X-Authorisation as a header key as this will get passed and not counted as a http auth request

#

like the same code works with patreon webhook they use x-patreon-signature and this passes through fine same as all other headers

solemn latch
#

๐Ÿ‘€ doesnt seem like a topgg issue though

#

sounds like a host issue

crystal wigeon
#

hey has anyone worked with pytube?

#

how do i download only 1 minute of a YT audio stream from a 10min video

rustic nova
#

Sus tos question

earnest phoenix
#
@client.command()
@client.has_permissions(administrator=True)
async def setprefix(ctx, *, newprefix: str):
    with open("prefixes.json", "r") as f:
       prefix = json.load(f)

    prefix[str(ctx.guild.id)] = newprefix

    with open("prefixes.json", "w") as f:
        json.dump(prefix, f, indent=4)

How can I make it so only Admins can use this command

I keep getting this error
AttributeError: 'Bot' object has no attribute 'has_permissions'

I just wanna know if it's even possible (Python)

jaunty basalt
#

Can someone tell me a way to replace all characters of string in English, if they are in some other language??

If there is any way so.

I want it for slash command string option. (I use javascript)

crystal wigeon
deft wolf
jaunty basalt
#

Hey someone suggest me fun commands for my bot plz! I'm out of ideas.
(Not so advanced because I'm still learning)

lament rock
#

save yourself the trouble and dont make a bot

#

or at least dont make a public bot

#

I've been doing this shit for 5-6 years and I should have stopped while I was ahead because had I known the day of reckoning for music bots was upon us, I would have stopped.

earnest phoenix
#

Help json
code of check if user has premium

def check_if_user_has_premium(ctx):
    with open("premium_users.json") as f:
        premium_users_list = json.load(f)
        if ctx.author.id not in premium_users_list:
            return False

    return True

file premium_users.json

{"908097297177526323"}
#

error

#
  File "/home/container/.local/lib/python3.10/site-packages/discord/ext/commands/bot.py", line 1394, in on_message
    await self.process_commands(message)
  File "/home/container/.local/lib/python3.10/site-packages/discord/ext/commands/bot.py", line 1391, in process_commands
    await self.invoke(ctx)  # type: ignore
  File "/home/container/.local/lib/python3.10/site-packages/discord/ext/commands/bot.py", line 1349, in invoke
    await ctx.command.invoke(ctx)
  File "/home/container/.local/lib/python3.10/site-packages/discord/ext/commands/core.py", line 1015, in invoke
    await self.prepare(ctx)
  File "/home/container/.local/lib/python3.10/site-packages/discord/ext/commands/core.py", line 919, in prepare
    if not await self.can_run(ctx):
  File "/home/container/.local/lib/python3.10/site-packages/discord/ext/commands/core.py", line 1280, in can_run
    return await discord.utils.async_all(predicate(ctx) for predicate in predicates)
  File "/home/container/.local/lib/python3.10/site-packages/discord/utils.py", line 672, in async_all
    for elem in gen:
  File "/home/container/.local/lib/python3.10/site-packages/discord/ext/commands/core.py", line 1280, in <genexpr>
    return await discord.utils.async_all(predicate(ctx) for predicate in predicates)
  File "/home/container/bot.py", line 35, in check_if_user_has_premium
    premium_users_list = json.load(f)
  File "/usr/local/lib/python3.10/json/__init__.py", line 293, in load
    return loads(fp.read(),
  File "/usr/local/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.10/json/decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
deft wolf
rustic nova
#

if you wanna compare a list, do

"premium_users": [
  "user1",
  "user2"
]

or

[
  "user1",
  "user2"
]
#

dont think the second one is correct either

#

but the first one is for sure

earnest phoenix
rustic nova
#

add debug lines lol

earnest phoenix
rustic nova
#

remember that you're still trying to compare a integer with a list of strings

rustic nova
fierce bloom
#

hello guys how to start

deft wolf
#

Start what exactly?

eternal osprey
#

how come that even after all these setbackground colors it is still white: java frame.setBackground(our_black); panel.setBackground(our_black); label.setBackground(our_black);

#

our_black is a valid color, i assured that

lyric mountain
#

still using the wrong casing I see

#

but anyway, show the rest of the code

bright thorn
#

Guys I think there is no more scope on discord

#

No more future on discord for bots

#

Discord implementing the bot ideas in discord

#

Which is killing the bots future in discord slowly slowly

earnest phoenix
deft wolf
#

Maybe he means /ban and /kick commands although I'm not entirely sure what it could be about

spark flint
#

nah

#

/ban and /kick have existed since slash commands first introduced

#

theyre not new at all

deft wolf
#

Maybe he had a predictive dream in which he saw the end of discord bots

lyric mountain
gleaming bolt
#

I'm using fastify/middie but it's giving an error: "TypeError: reply.send is not a function"

#
(async () => 
    const app = fastify();

    await app.register(require('@fastify/middie'));

    app.use(bodyParser.urlencoded({ extended: false }));
    app.use(bodyParser.json());

    app.use('/', (request, reply) => {
        reply.send("teste")
    })

    app.listen({ port: process.env.API_PORT })
})()
grim aspen
gleaming bolt
grim aspen
#

looks like it. never used it

gleaming bolt
#

hm...

#

I still get the same error because I'm on version v^4.12.0

bright thorn
#

Pain this message

#

It will be coming soon

rustic nova
#

Nah it wont

#

Unless discord wants to implement this one specific carding game into their UI and allow users to earn money on their platform and be able to generate images using their own UI and allow built-in musicbots

#

See

#

They will implement easier use of some non-specific features such as moderation into their site

#

But they wont add 95% of your remaining multi-purpose features of your bot into it

#

Because

#

Its actually unnecessary

tepid flax
#

if anyone knows py-cord dm me i have a quick paid job (one command)

rustic nova
#

depends

#

but this isnt fiverr or freelancer

#

just state what you need here

neon leaf
#

how can I pass an external function my class context in a object ({ context: this, otherstuff: 'yes' })? nodejs

sudden geyser
#

that's how it should work

#

then just give the object as an argument

neon leaf
#

well for some reason it doesnt, this is considered any when passing, probably because this is now referring to the object

sudden geyser
#

can you show more of your code

neon leaf
sudden geyser
#

what does hovering over this say

neon leaf
#

fixed it, worked when defining the key manually; context: this - not just this

sudden geyser
#

ah

#

then it was using this: this

#

so was just a naming problem

craggy pine
#

@drowsy crag

rustic nova
#

smh why ping again

craggy pine
#

Was going to say the same.

#

Because people might not want to be pinged unless its for a good reason. My ping was for a reason that has since been delt with.

drowsy crag
#

@covert gale

agile field
#

hello

#

i need to access to the apis

#

for educational purposes

lyric mountain
#

well, that's not how it works

deft wolf
#

You have to wait until they accept your bot

agile field
#

i've just sent my useless bot for the review

#

i don't want to scrape the website

#

it is for my master's thesis

deft wolf
#

Now wait and hope they accept it

lyric mountain
#

topgg only opens the api to approved bots, no other way around

#

if you stop to think, the api wouldn't even work since your bot would never receive votes

agile field
#

there are a lot of bots that are useless in top.gg list

lyric mountain
#

useless is a matter of view

agile field
#

how did they get accepted

deft wolf
#

Normally, they meet the requirements

agile field
#

they've scraped

lyric mountain
#

this wouldn't work nowadays since the site includes bot protection

#

also, even with the api you'd not be able to achieve that

agile field
#

ok let me ask you something

#

do you have access to the api

lyric mountain
#

yes?

agile field
#

can you retrieve the bots attributes with searching their category?

lyric mountain
agile field
#

/bots?search=gaming

#

for example

#

limit 500

lyric mountain
#

this site includes everything u can search for

#

read it

agile field
#

i already

#

did

#

there is an example there but it searches with the bot's name

lyric mountain
#

if it doesn't mention seaching for specific tags, then u cant

agile field
#

ok

#

thx

#

can you try it for me?

rustic nova
#

check the "search" field

#

you are able to provide a list of tags iirc

agile field
#

yeah i saw it that's why i asked here

#

alright then

#

i need to have that access to the apis

#

i hope they accept

sudden geyser
rustic nova
#

poor mudae mao

candid spire
#

How to create a vote required command?

solemn latch
#

You'll ideally use webhooks and store the votes in a database

thick turtle
#

Or lazily make an api call on the command (don't recommend)
https://top.gg/api/bots/:bot_id/check

solemn latch
#

Ratelimits will get you very quick with that.

thick turtle
#

Yup ๐Ÿ˜‚

#

Periodically call the api for the get all votes endpoint and save it ๐Ÿ‘

#

And take advantage of the webhook to get when people vote to then keep your saved version updated

livid sequoia
#

Good day everyone

#

Uhm. Would like to develop a discord bot

#

Where can I start reading, im zero knowledge

#

Or any developer for partnership on my idea. DM me

#

Just asking guys...

earnest phoenix
# livid sequoia Where can I start reading, im zero knowledge

Start by learning the basics of a programming language, I recommend Python personally. JavaScript is also a good choice I believe.
Once you've got the basics of the language covered you can look at libraries such as discord.py. These make the process of creating a bot as well as commands etc much easier.

wheat mesa
#

I recommend neither python nor javascript as a first language (but if you insist on one of the two, javascript is the way to go), but something more like Java

#

Then move to a language like javascript after you understand types and such, then you can learn to make bots

lyric mountain
#

Python is a sugary trap for beginners

onyx wind
#

Javascript > Python if you just starting

livid sequoia
#

You can make bots in java,,?

onyx wind
lyric mountain
#

You can make bots in pretty much any lang

livid sequoia
#

How bout dbase

#

Or discord will take care of dbase users

lyric mountain
#

You need to handle it yourself

onyx wind
#

You should join discord api. Literally all the goodies are there

livid sequoia
#

Ah oki

#

Oh you can monetize your api if you develop it

#

?

lyric mountain
#

Kinda, but nobody will pay

#

Not when huge popular libs already exist

solemn latch
#

Some bots get fair amounts of patreon supporters, but thats rare and after you gain good growth.

wheat mesa
#

Can someone explain how the actual FUCK this produces 395 ```java
int va = 99;
va = 3 + 3 * --va+va++;
System.out.println(va);

#

this was a competition question I had

#

(java)

#

the bytecode breaks all of the precedence order???????????

#

the fuck???

sudden geyser
#

3 * --va gets evaluated first

wheat mesa
#

In theory the order should be
va++,
--va
3 * (result of --va)
3 + (result of 3 * --va)
(result of the above) + (result of va++)

sudden geyser
#

va produces 98

wheat mesa
#

But that's wrong

sudden geyser
#

then the rest is evaluated left to right

wheat mesa
#

I understand what the bytecode means, but the precedence does not follow the order it should

#

this is the order it should follow

#

The post increment should be first, then pre decrement, then basic pemdas

sudden geyser
#

the order would only matter for --va

#

va++ wouldn't change the value of va

wheat mesa
#

Yes it would

sudden geyser
#

no it wouldn't

wheat mesa
#

va++ changes the value of va but returns the un-incremented value of va

sudden geyser
#

yeah

#

and that's the last thing that reads va

wheat mesa
#

No

#

That should be the first one to be evaluated

#

Which is why I'm so confused

#

post increment has the highest precedence in that entire expression

#

then pre decrement, then multiplication, then addition

sudden geyser
#

their precedence is clearly the same in the diagram

wheat mesa
sudden geyser
#

oh there are two places

wheat mesa
#

this is bizarre behavior

#

surely there's a reason but still it's so weird

#

yeah it's definitely not a compiler bug, js has the same behavior

sudden geyser
#

new theory

wheat mesa
#

js AND java are broken ๐Ÿ˜‰

#

nope C# same thing

sudden geyser
#

my idea is it has to do with semantics, as you can't use pre and post ++/-- in the same expression (i.e. you can't do --n++)

#

which means it goes back to left-right evaluation with the other orders

#

hence what I said before

wheat mesa
#

that would be super weird and not make much sense

sudden geyser
#

it may just be a niche only for specification, but I don't know

#

me personally, I think order of operations / precedence is a bad system that shouldn't exist in any language

wheat mesa
sudden geyser
#

try it and see

#

I couldn't get it to compile

wheat mesa
#

I meant my version of it

#

You can't do --n++ because n++ evaluates to a number and not a reference-able variable

#

But you can do --n+n++ because n++ evaluates to a number which is allowed in a binary expression obviously

sudden geyser
#

yes

wheat mesa
#

even so it makes no sense as to why they would disallow precedence to be used like that

#

I'll ask my CS teacher tomorrow

#

Maybe it's some obscure dogshit left in compilers for some tiny optimization reason of some sort

earnest phoenix
# wheat mesa Can someone explain how the actual FUCK this produces 395 ```java int va...

Precedence is actually put aside here because --va + va++ is unsequenced [1], in which the behavior is undefined [3] and it is unknown which of the operations will first take place as they have side effects [2]

[1] What are sequence points?
At certain specified points in the execution sequence called sequence points, all side effects of previous evaluations shall be complete and no side effects of subsequent evaluations shall have taken place

For example, at the end of the evaluation of full expressions (a full expression is an expression that is not a subexpression of another expression):

int foo = 5; // ; is a sequence point

In other words:
Sequence point is a point in time at which the dust has settled and all side effects which have been seen so far are guaranteed to be complete

[2] What are side effects?
Evaluation of an expression produces something and if in addition there is a change in the state of the execution environment it is said that the expression (its evaluation) has some side effect(s)

For example:

int foo = bar++; // where `bar` is also an int

In addition to the initialization operation, the value bar gets changed due to the side effects of the post-increment operator (++)

[3] What is undefined behavior?
Behaviors that may arise upon use of erroneous program constructs or erroneous data, in which the standards impose no requirements for the implementers, so they can decide the behavior

Between the previous and next sequence point a scalar object shall have its stored value modified at most once by the evaluation of an expression, what this means is that between two sequence points a variable must not be modified more than once

Here are examples of undefined behavior caused by unsequenced points:

i++ * ++i; // UB, `i` is modified more than once between two sequence points
i = ++i; // UB, same as above
i = ++i + 1; // UB, same as above
#

Here's a simplified explanation:

int va = 99;
va = --va + va++; // You'll get `196` because `--va` is evaluated first due to unsequenced points, because of undefined behavior

int va_ = 99;
// Going by our own perception of operator precedence, which is basically like this:

// Unary post-increment/decrement operators have higher precedence (temporary variable to store the original value because of the post-increment operator)
int temp = va_++;

// Unary pre-increment/decrement operators have lower precedence
--va_;

va_ = va_ + temp; // We'll get `198` because we did the operations with our own perception of operator precedence, as we're not affected by unsequenced points
#

holy shit

#

Compilers are smart enough to tell you about that behavior I just explained, for example, doing exactly what you're doing in C++ (compiling with Clang++), you'll get a warning as what you're doing is unsequenced

#

literal ๐Ÿค“

#

Yes, I love being a nerd mmLol

quartz kindle
#

very interesting read

#

also found another nice explanation specifically for js, but may also be applicable to other langs

lyric mountain
#

Which allows u to do some whacky stuff

ripe epoch
#
client = commands.Bot(command_prefix='!', intents=intents)
statusChange = True
guilds = str(len(client.guilds))

@client.event  # Code to run on bot start
async def on_ready():
    print('ModzBott is running!')  
    print('----------------------------------')
    await asyncio.sleep(0.5)
    print('Loading cogs:')
    while statusChange == True:
        await asyncio.sleep(5)
        await client.change_presence(activity=nextcord.Game(name=f'/help | {guilds} servers!'))
        await asyncio.sleep(5)
        await client.change_presence(activity=nextcord.Game(name=f'/invite | {guilds} servers!'))```
I am rather confused as to why this code snippet is not working on my bot, the bot is in 20 servers however the bot status states 0. The bot token is correct and it is also connected to the correct bot. Any ideas as to why it is not showing the actual server count?
deft wolf
#

Where did you get this code from?

ripe epoch
#

This is my own

ripe epoch
rustic nova
#

I'm referring to your code

ripe epoch
#
 intents = discord.Intents.default()```
rustic nova
#

Specifically include the members intent

#

Check the docs

deft wolf
ripe epoch
rocky hearth
#

For a monorepo, should I put the licence field in packagejson to the root file or in all of my apps?

surreal sage
#

How to make Nginx listen to any port?
Like, I want the ipv6 and ipv4 listen ports to be anything as long it's from server_name

surreal sage
rigid maple
#

can i make different backgrounds that change from user to user

quartz kindle
#

why would you even want that

surreal sage
#

Reverse proxy with one of my VPS' and my home server

quartz kindle
#

but why all ports lol, there are many ports that are system reserved and stuff like that

surreal sage
#

right

quartz kindle
#

you can set a range of ports like this listen 9000-9999

surreal sage
#

ah thanks

quartz kindle
#

but dont make it 0-64k lol

surreal sage
#

lmfao

quartz kindle
#

also

surreal sage
#

How do I make UDP reverse proxies work?
the stream { server { aint work for me

quartz kindle
#

here's another arguably better way of doing it

quartz kindle
sudden geyser
#

!!!

rigid maple
#

When I add a class to an element using js, does it only change for the user entering from that computer or is everyone affected?

rustic nova
#

?

#

are you referring to like, changing elements within the site the user is viewing?

rigid maple
#

no i want to show the same <div> as red to one user and green to another

#

i get this color from localStorage

#

I will change the color of the div according to the data from localstorage with js

rustic nova
#

localStorages are linked to a website domain so yes, it would change the color for any user logged into that specific browser where the localStorage is set

#

that data of course stays after creating new browser sessions

lyric mountain
rustic nova
#

still dont get the thought-process behind it

#

the default port for http (80) is good enough

carmine summit
#

Can I read messages sent to my bot in direct messages?

#

messageCreate event doesnt seem to trigger when its a direct message

rustic nova
#

ensure you have the correct intents

carmine summit
#

It triggers fine on the server

#

Is there any special intents for direct messages?

verbal meteor
#

Hello, I submitted the bot 2 weeks back. I haven't heard anything back from top.gg
How can I check the status?

nimble talon
#

im trying to make my bot connect to a VC channel, its saying TypeError: Client.__init__() missing 1 required keyword-only argument: 'intents' not sure what it means by this, heres the code:

import random

client = discord.Client()

@Client.event
async def on_ready():
    #information
    print('Logged in as')
    print(client.user.name)
    print(client.user.id)
    print('------')

    channel = Client.get_channel('1066410957074616433')
    await Client.join_voice_channel(channel)
    print('Bot joined the channel.')

client.run('removed token to post here')```
dusty whale
#

I'm struggling to get my bot to work in bigger servers (100k+ members), but it's working in smaller servers. The bot is possible to add, but command is not working in bigger servers. What could I be doing wrong? My bot is https://memix.lol

Thank you so much!

Discord

Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.

lyric mountain
#

What exactly isn't working?

craggy pine
#

That's kinda advertising no?

lyric mountain
#

Hi miyu

craggy pine
dusty whale
#

No, not advertising, sorry

#

didn't mean it to be at least

#

I'm not sure why it's not working

#

that's my problem

#

It works in "smaller" servers, but it's non-working in bigger servers for some reason

#

could it be something with permissions?

#

do you need more permissions in bigger servers that has more advanced roles, etc?

lyric mountain
#

You need to specify what "not working" means

dusty whale
#

The command is not working

#

the bot is there

#

added

lyric mountain
#

WHAT command?

dusty whale
#

but the command doesn't work

#

/memix

#

the bot command

lyric mountain
#

Ok, we're advancing

#

What does that command do?

craggy pine
#

Wrap the command in a try catch and print the error catch throws assuming it's attempting to run

lyric mountain
#

What does it do?

dusty whale
#

the command generates a meme that you can change the text of

#

here's a gif

#

of how it works basically

lyric mountain
#

Mind sharing the code here?

dusty whale
lyric mountain
#

Only code relevant to the command btw

deft wolf
#

How it works on the server is one thing, but how it works from the code level is a completely different thing

dusty whale
#

ah ok

lyric mountain
#

Yes, that

dusty whale
#

thank you so much for this guys btw

#

really helpful, although I'm still kinda lost lol

#

but thank you for real

lyric mountain
#

Don't worry, but to help you we'll need to see the code

#

Else it'll be just guessing

#

The possible issues could be lack of embed permission, unable to talk in channel, faulty api or getting user through cache

foggy yoke
#

yeah

#

you should check the error as well, if any

dusty whale
#

how can I check that :/

#

thank you!!

lyric mountain
#

Yes, the console will usually show what happenwd

dusty whale
#

oh

lyric mountain
#

Or is the bot hosted in stuff like pterodactyl?

dusty whale
#

i dont see anything in own API logs

lyric mountain
#

The screen u use to start the bot, does it show any error?

dusty whale
#

no, nothing there either

#

also it confirms auth and adds properly through the bot page as well

#

just big servers that's affected

#

it becomes non-working

craggy pine
#

Then it kind of goes back to the first thing Kuu asked for which was, can you share the code so we can help debug it.

dusty whale
#

the command

#

but it still shows the previous working commands sends

#

because SOMETIMES it works

dusty whale
#

but then stops working

#

yeah will do

#

thanks guys!!

foggy yoke
#

i think you should check the error

#

it will tell you EXACTLY wht went wrong

craggy pine
foggy yoke
#

sorry then

#

my bad

#

code it is

dusty whale
#

which part of the code would be most helpful?

#

any specific?

foggy yoke
#

the command

craggy pine
#

the more related to the command probably the better.

hazy jewel
#

i need help with my discord bot

deft wolf
#

With what exactly?

hazy jewel
#

i cant launch it

deft wolf
#

And what language do you use?

hazy jewel
#

JavaScript

deft wolf
#

So what exactly is not going your way? Bot won't log in or what?

hazy jewel
#

it cant launch

#

this is code fragment
if (msg.content.startsWith('/ban')) {

#

there is missing ","

deft wolf
#

But the bot is active, it just doesn't respond to commands, right?

#

Active I mean it's online

hazy jewel
#

its offline

#

it doesnt launch

wheat mesa
#

You havenโ€™t given us an error or anything to work with. The information you have provided is extremely vague and weโ€™re basically just guessing what your problem is. Please be more specific

hazy jewel
#

',' expected.

#

this is error

wheat mesa
#

That has nothing to do with the code you posted

hazy jewel
#

in problems in VSCode there is this error

wheat mesa
#

That is somehow more vague than all of the other info you gave us

hazy jewel
#

i can send you full code and node.js errors that appear when starting bot

deft wolf
#

Then send it on this channel

#

But don't send the bot token by accident

hazy jewel
deft wolf
#

For some reason you have "{" in front of "client.on()"

solemn latch
#

๐Ÿ‘€ your code editor should give warnings for that

deft wolf
#

It gave him a warning, but I don't think he knows how to read it

hazy jewel
#

these are node.js errors
Uncaught SyntaxError E:\bot.js:74
}
^

SyntaxError: missing ) after argument list
at internalCompileFunction (internal/vm:73:18)
at wrapSafe (internal/modules/cjs/loader:1149:20)
at Module._compile (internal/modules/cjs/loader:1190:27)
at Module._extensions..js (internal/modules/cjs/loader:1280:10)
at Module.load (internal/modules/cjs/loader:1089:32)
at Module._load (internal/modules/cjs/loader:930:12)
at executeUserEntryPoint (internal/modules/run_main:81:12)
at <anonymous> (internal/main/run_main_module:23:47)

craggy pine
deft wolf
quartz kindle
#

dont teach them bad habits lol

hazy jewel
#

please send me corrected version beacuse when i removed { it created more problems in VSCode

deft wolf
#

Because the whole part responsible for the ban command is completely outside the messageCreate event

quartz kindle
deft wolf
#

Also, I'm not entirely sure what the for(let index) part is supposed to do, which apparently doesn't do anything in this file

#

@hazy jewel

lyric mountain
#

they changed the formatting, again

#

added padding and round corners

hazy jewel
#

this is the error
Uncaught Error Error: Cannot find module 'request'
Require stack:

  • C:\Users\User\Downloads\message.js
    at Module._resolveFilename (internal/modules/cjs/loader:1047:15)
    at Module._load (internal/modules/cjs/loader:893:27)
    at Module.require (internal/modules/cjs/loader:1113:19)
    at require (internal/modules/cjs/helpers:103:18)
    at <anonymous> (c:\Users\Igor\Downloads\message.js:2:17)
    at Module._compile (internal/modules/cjs/loader:1226:14)
    at Module._extensions..js (internal/modules/cjs/loader:1280:10)
    at Module.load (internal/modules/cjs/loader:1089:32)
    at Module._load (internal/modules/cjs/loader:930:12)
    at executeUserEntryPoint (internal/modules/run_main:81:12)
    at <anonymous> (internal/main/run_main_module:23:47)
deft wolf
#

You don't have request installed

rustic nova
#

reverses change

hazy jewel
#

this is another error
Uncaught DiscordjsError TypeError [ClientMissingIntents]: Valid intents must be provided for the Client.
at _validateOptions (c:\Users\User\node_modules\discord.js\src\client\Client.js:489:13)
at Client (c:\Users\User\node_modules\discord.js\src\client\Client.js:78:10)
at <anonymous> (c:\Users\Igor\Downloads\message.js:3:16)
at Module._compile (internal/modules/cjs/loader:1226:14)
at Module._extensions..js (internal/modules/cjs/loader:1280:10)
at Module.load (internal/modules/cjs/loader:1089:32)
at Module._load (internal/modules/cjs/loader:930:12)
at executeUserEntryPoint (internal/modules/run_main:81:12)
at <anonymous> (internal/main/run_main_module:23:47)

deft wolf
#

You have no intents listed in your client

#

It's explained very nicely here

#

Also if you are using discord.js v14 then you will need to change event message to messageCreate

hazy jewel
#

there is TypeError [ClientMissingIntents]

deft wolf
#

You click "Applications", select your application that you use, go to the "Bot" tab and scroll down a bit

#

I can't, but you should be able to use those toggles normally

hazy jewel
#

i enabled everythiiiing and the error iiis the same

deft wolf
#

Okay, what intents did you add to the client?

#

I mean what you added to your new Discord.Client()

wheat mesa
#

Please learn your programming language before you make a discord bot

rustic nova
#

lmao

lyric mountain
#

given the code is being ran by a single file named message.js inside Downloads folder, I BET it's a "no code required" badge unlocker

#

also fuck, discord utterly destroyed the image viewer

hushed robin
#

well you canโ€™t get the badge from prefix commands

lyric mountain
#

that's true too, but I don't think they're the one writing the bot at least

hushed robin
#

probably just copied and pasted code and assumed it would work ๐Ÿ˜

deft wolf
#

A year ago it might have worked

hazy jewel
#

GUILD_CREATE and MESSAGE_CREATE

deft wolf
#

I mean what you have in this part of the code, because GUILD_CREATE and MESSAGE_CREATE are not really intents

#

You need the Guilds and Guild Messages intent to receive messages from the servers

#

When you go to this website, it contains a list of intents and events that are subject to this intent

compact briar
#

im creating a dashboard for my bot and need to ensure the user has manage_guild before allowing them to make changes to the guild settings. Am i going to need to apply for the GUILD_MEMBERS intent?

quartz kindle
#

you only need it if you want to list all members in your dashboard

#

you dont need it to get information about a single guild member

compact briar
lyric mountain
#

All u need to do is fetch that specific member

#

And fetch works independently of cache

eternal osprey
#

Hey does anyone know why my gif is not playing in the frame using java swing?

#
  closeWindow(registerFrame);
        Color our_orange = Color.decode("#ff8c00");
        URL imgUrl2 = this.getClass().getResource("cool-loading-animation-gif-4.gif");
        Icon icon = new ImageIcon(imgUrl2);
        JLabel label = new JLabel(icon);
        JFrame f = new JFrame("Animation");
        f.getContentPane().add(label);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.pack();
        f.setLocationRelativeTo(null);
        f.setVisible(true);
        loadingFrame = f;```
#

I only get a white frame instead of an actual gif playing

surreal sage
#

How can you run a bash command outside a Node process?
My goal is to fire a shell script
Wait one second
And run a command (which would restart the node process)

#

I don't want node to attach to that shell script
No awaiting responses or anything

lyric mountain
eternal osprey
lyric mountain
#

google

#

java technically supports gif, but it moshes it all together when converting to bufferedimage

neon leaf
#

whats a regex to match if the first and last letter of a string are for example b?

lyric mountain
#

so you need not to convert to bufferedimage

eternal osprey
lyric mountain
#

"how to play gif in label java"

eternal osprey
#

i already searched up java swing not showing gif

neon leaf
eternal osprey
#
 Icon icon = new ImageIcon("cool-loading-animation-gif-4.gif");
        JLabel label = new JLabel(icon);
        JFrame f = new JFrame("Animation");

        f.getContentPane().add(label);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.pack();
        f.setLocationRelativeTo(null);
        f.setVisible(true);


        f.setSize(800,600);
        loadingFrame = f;```okay so i have searched how to display a gif
#

only thing showing up is a black screen with nothing

lyric mountain
#

dont do JFrame.getContentPane().add()

#

just add it directly

#

also u need to set that frame as the window's content pane

compact briar
deft wolf
#

I'm not too familiar with AOuth, but isn't it that when user log in, you can check what servers this person is on and read their permissions?

earnest phoenix
lofty cipher
eternal osprey
#

omg i swear sometimes the gif loads in, other times it just doesn't

wheat mesa
#

Welcome to swing ๐ŸงŒ

eternal osprey
#
 public void guiLoader() {
        closeWindow(registerFrame);

        URL img = this.getClass().getResource("ezgif.com-resize.gif");
//Make it to an Icon
        Icon icon = new ImageIcon(img);
//Make a new JLabel that shows "icon"
        JLabel Gif = new JLabel(icon);

//Make a new Window
        JFrame main = new JFrame("Zorgzaam | Planning & Administratie");
        loadingFrame = main;
//adds the JLabel to the Window
        main.getContentPane().add(Gif);
//Shows where and how big the Window is
        main.setBounds(800,800, 800, 800);
//set the Default Close Operation to Exit everything on Close
        main.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Open the Window
        main.setVisible(true);
```like honestly what the fuck am i doing wrong
#

i questioned myself so i copied a random guy's code from stackoverflow to test, i resized the gif, i downscaled the gif, i format it

#

brev tf

earnest phoenix
# surreal sage How can you run a bash command outside a Node process? My goal is to fire a shel...

You can do that within Node.js itself, no need for additional shell scripts:

// Import the `spawn()` method to spawn a child process which'll be the Node.js process in this case
import { spawn } from 'node:child_process';
import { setTimeout as setPromisedTimeout } from 'node:timers/promises';

async function restartProcess() {
  // Check if the process is restarting, note that we're setting the `PROCESS_RESTARTING` environment variable ourselves 
  if (process.env.PROCESS_RESTARTING === '1') {
    process.env.PROCESS_RESTARTING = '0';

    // Give 1 second for the previous process to fully shut down and exit just in case
    await setPromisedTimeout(1_000);
  }

  // Spawn a child process with the command line arguments of the current process
  spawn(process.argv[0], process.argv.slice(1), {
    // Set the environment variables 
    env: { ...process.env, PROCESS_RESTARTING: '1' },
    // Prepare the child process to run independently of it's parent process
    detached: true,
    // Inherit the current standard input/output
    stdio: 'inherit'
  })
    // Unreference the child process from the parent process so the parent process doesn't wait for the said child process to exit
    .unref();

  // Exit the process
  process.exit(0);
}
#

But I would recommend using a process manager for this use case instead

eternal osprey
#

aha found the issue

#

thread.sleep

lyric mountain
eternal osprey
#

So my gif is actually being interrupted from loading by my thread.sleep

#

would there be any way to make sure that gif is loaded? I was thinking about wrapping it in a new thread

earnest phoenix
# lofty cipher Does this look good? https://pastes.dev/MDixxpzF6f
  1. Use a formatter like Prettier
  2. Use a database to store cooldowns and such, because otherwise they'll be reset upon restart
  3. Avoid setting properties to the global object to be used globally, as this can cause unexpected issues or cause libraries to fail, and since libraries can also access this property, this can be a security vulnerability as well, instead, export the value and import it where you want to use it
  4. Instead of using the rjutils-collection library to get a random number between ranges, use the built-in randomInt() method from the node:crypto module, for example: randomInt(30, 50)
lofty cipher
#

Ok thanks

valid talon
#

Hey

maiden gazelle
#

hi im keep getting this error and i dont know what to do with it i tried so much im trying to make a help command with buttons i already handled it in my index so that cant be the problem ig

const Discord = require("discord.js");

exports.run = async (bot, message) => {
    
    const hp = new Discord.ActionRowBuilder()
    .addComponents(
        new Discord.ButtonBuilder()
        .setCustomId(`mo-${message.id}`)
        .setLabel('moderation')
        .setStyle(Discord.ButtonStyle.Primary);
        
        new Discord.ButtonBuilder()
        .setCustomId(`fun-${message.id}`)
        .setLabel('fun')
        .setStyle(Discord.ButtonStyle.Primary);
    
    new Discord.ButtonBuilder()
        .setCustomId(`fun-${message.id}`)
        .setLabel('logging')
        .setStyle(Discord.ButtonStyle.Primary)
    
    new Discord.ButtonBuilder()
        .setCustomId(`wandl-${message.id}`)
        .setLabel('wandl')
        .setStyle(Discord.ButtonStyle.Primary)
    )
    
let embed = new Discord.EmbedBuilder()
        .setDescription(`**SHARK Help Menu**

press the buttons to control the help menu

[**SUPPORT SERVER**](https://discord.gg/fytWuaA2bH)
`)
        embed.setColor("#B468FF")
        message.reply({ embeds: [embed], components: [hp] });

    }

exports.help = {
    name: 'help', 
    aliases: []
    }
earnest phoenix
# maiden gazelle hi im keep getting this error and i dont know what to do with it i tried so much...

You're putting semicolons in expressions, you're passing arguments to a function there, and to pass other arguments you need to use colons to separate them

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions

Functions are one of the fundamental building blocks in JavaScript. A function in JavaScript is similar to a procedureโ€”a set of statements that performs a task or calculates a value, but for a procedure to qualify as a function, it should take some input and return an output where there is some obvious relationship between the input and the outp...

#

Learn JavaScript fundamentals

#

These are where the colons are supposed to go (remove the semicolons that I'm pointing out here as well)

sharp saddle
#

guys, how can i use Environment Variables with LUA?

eternal osprey
#
 long startTime = System.currentTimeMillis();
        long elapsed = System.currentTimeMillis()-startTime;
        while(elapsed<10000) {
            elapsed = System.currentTimeMillis()-startTime;
        }```this still stops my fucking gif
rustic nova
#

you're doing a while loop

#

which halts your whole thread, including your gif one

#

either do it in a thread or dont even use while at all

sharp saddle
#

@earnest phoenix Thank you

earnest phoenix
#

You're welcome

lyric mountain
#

This is where the java is separared from the script

#
CompletableFuture.runAsync(() -> {
    // Async code here
    ...
});
hushed robin
#

what would be the most efficient approach to wrap text with canvas

lyric mountain
#

Calculate text offset

#

"how?"

#

y + text.height * line

#

"how do I get line?"

#

Calculate text width, when it pass given boundary, do line++

wheat mesa
#

damn kuuhaku looking into the future

hushed robin
#

managed to get something working bloblul

cinder stratus
#

Hello, I am facing some issues with redis, our redis setup is clusterized.

Redis version: 7.x
Client: ioredis (nodejs)
Setup: 3 master redis and 3 slaves
Error log: https://hastebin.com/share/umumujunoj.bash

lyric mountain
#

redis...clusterized?

#

redis?

#

like, it's supposed to be used as a cache layer, not as an actual database

#

it can be one, but it'll be subpar compared to dedicate databases

cinder stratus
#

Well we are using it for cache, we have postgre for db

lyric mountain
#

why is it clusterized then?

cinder stratus
#

Its microservice, every cache is on redis.

lyric mountain
#

Not sure if I understand, but anyway

#

I think ur getting that due to a deadlock

#

Like, many processes trying to get the file's lock

cinder stratus
#

I kinda get the error now it's like redis is loading all the data and before it finished processing that you just made bunch of requests to redis do "things"

lyric mountain
#

Can't u wait it?

cloud agate
#

does anyone know if changing status (client.change_presence) with the AutoShardedBot on discord.py carries over to all shards?

cinder stratus
lyric mountain
#

Nono, just prevent the runtime from advancing before it finished loading

#

It'll delay the startup a bit, but it'll guarantee u don't have cache mismatch

cinder stratus
#

I see.

tame linden
#

Hello everyone, I try to create a bot for play music on youtube and hosting on Heroku. It's works well on my computer but too lag on the host. What should I do zd1cnv

deft wolf
#

Buy a VPS

#

Free hosting sites are not suitable for hosting music bots

#

Music bots require a lot more resources than a regular text command bot

tame linden
tame linden
deft wolf
#

From what I see, for $5 on Heroku you get 512mb of ram

#

It's probably not enough for a music bot, unfortunately

neon leaf
tame linden
deft wolf
#

I mean, I'm just writing that for this price you would probably get a VPS twice, if not 3 times better

#

I checked the prices on OVH and for less than $7 you get 1 vCore and 2GB of ram

#

I personally have 4GB of ram and 2 vCore which is enough for me for less than $7 but I buy servers on Polish hosting so these prices will never be comparable

tame linden
#

adore How do you feel about their VPS

deft wolf
#

It should be good especially since it has a free trial period so you can decide if you want to stay with it or go back to Heroku

eternal osprey
#

btw thanks to everyone helping me out with understanding java and its scopes. Thanks to yall i got a 91% on my assignment!

rapid canopy
#

i can't logged

deft wolf
#

I hope this token doesn't work

#

And besides, you need to define in your client what intents it should use

#

This should help you

rapid canopy
tame linden
rustic nova
#

running a bot on aws

#

thats new to me

tame linden
#

I think my code have problem. It's still lag on aws

deft wolf
#

Is your code from the internet or did you write it yourself?

#

I'm curious because if it was from the Internet, I could try to run it on my VPS and check if it's the fault of the code or AWS

tame linden
quartz kindle
tame linden
quartz kindle
#

ah

#

whats your instance specs?

rustic nova
#

its a free trial

#

so probably not good

quartz kindle
#

audio takes a lot of resources, especially if you're transcoding in real time

#

the free trial one might not be strong enough

tame linden
craggy pine
#

very low for audio

tame linden
tame linden
rustic nova
#

probably no trial / free thing is gonna be sufficient for it

tame linden
#

I dont know how much are enough

rustic nova
#

I do not, I run multiple private applications that have something to do with audio though

craggy pine
#

I use a minimum of 4gbs of ram to run a bot that only does music and other smaller tasks.

tame linden
#

Too many differnt cpu selection

craggy pine
#

I actually run a 1 core Intel cpu w/o any lagging.

tame linden
#

Thank you everyone for the help

lyric mountain
eternal osprey
#

Is this a correct logical circuit of xnor?

#

I just thought about implementing the principles of the xor and then complementing it

lyric mountain
#

Write the XNOR truth table

eternal osprey
#

I mean i know it would be true, but rather the implementation of the components of logical circuits

lyric mountain
#

Yes, write the truth table

#

When implementing a gate u need a truth table

#

Makes it much easier to write the code later

#

That said, java already has xnor anyway

eternal osprey
#

I see thank you! I had created a truth table already and it was correct just was a bit insecure about whether the logical circuit was valid.

#

Yeah, this is not for the Java course but processors ๐Ÿ™‚

lyric mountain
#

Ah yes

wheat mesa
#

I have a similar course that we get to actually build the circuits in, 10/10 would recommend trying it sometime if you haven't

eternal osprey
wheat mesa
#

Damn

eternal osprey
#

It would help a lot but we only got 7 weeks for the course ๐Ÿ˜ฆ

wheat mesa
#

It's much more intuitive when you get to actually breadboard them

eternal osprey
#

Yeah indeed i am a bit of a visual learner so i find it pretty hard without being practical indee

#

I honestly almost understand the whole lecture so far, but one thing that fucked my mind was this:

#

I honestly have no fucking clue what this means. I have looked at wikipedia etc but i can't find anything about ALU flags. Like, where do i look? Must i compare the MOST left bits of 2 bitstrings (this is about bit additions)

wheat mesa
#

This is something you generally look at when you're programming in assembly

eternal osprey
#

ooowh

#

so we must actually look at ALL the bits of the bitstrings that we are adding?

#

not only the MSB

tame linden
wheat mesa
#

The overflow bit is important for checking for errors

#

The carry out bit flag is something I don't know about, I've heard the term but I haven't actually looked into it

#

ah okay that's pretty simple

eternal osprey
#

The thing is, what do they mean with "result"

wheat mesa
#

Adding two numbers

eternal osprey
#

Must you look at each bit and compare them? Must you look at the resulted bitstring after adding them?

eternal osprey
wheat mesa
#

Well, it's not as simple as just ORing the bits together

#

The logic gates used for it are more complex than that, but I'm assuming the ZERO flag is a fast way to compare two numbers since it only requires 1 gate operation per bit of the two numbers you're adding

#

yeah it's just a quick way to compare two numbers essentially

eternal osprey
#

so if i understand it correctly, a zero flag is when all bits are 0 in the result?

wheat mesa
#

Essentially yes

#

I'm not quite sure if that's a perfect explanation of it, as I'm not an expert on the topic

#

but I would assume that's basically how it works

eternal osprey
#

i see, and eventually last question (honestly sorry for my dumbness) if we have overflow we also have carry right?

wheat mesa
#

so in this example, BEQ would likely be checking the ZERO flag on the CPU instead of worrying about the result

eternal osprey
#

I mean, a bit is a mod 2 calculation, so if it's for example 1+1 = 2 = 0 and 1 gets carried away

wheat mesa
eternal osprey
#

Okay, thank you very much for all the help waffle!

wheat mesa
#

np C:

#

Btw @eternal osprey if you want to get better at logic gates and such, there's a game on steam called Turing Complete. It's great for creating low level circuit simulations and it's quite fun to progress through the levels

eternal osprey
#

Owhh really? That's really cool. I will definitely have a look at it

#

The flags are pretty clear to me thanks to you, thanks bro!

#

Would these flags be the same when working with two-cmplement? @wheat mesa

#

two complement binary system*

wheat mesa
#

I'm not entirely sure of the low level implementation details surrounding two's compliment

#

I just know how to convert to and from it lol

#

As the abstraction gets higher level, the low level logic starts to become incredibly complex

eternal osprey
#

Owh my bad i indeed serached it up, if the msb is 1 it accounts for negative

#

else its positive

wheat mesa
#

I see

slender wagon
#

is the userId from discord an integer or string

rustic nova
#

depends on library

#

generally the string variant is used

slender wagon
#

discord.js

rustic nova
#

though you can just cast it to/from a string

slender wagon
#

i am getting it from an interaction

rustic nova
#

yeah the discord.js one is string based

coarse yoke
#

@pliant owl

#

welp

rustic nova
#

thats a bot of yours

#

bots dont get added here

coarse yoke
#

they did

#

not anymore

#

ig

#

i remember testing him here

rustic nova
#

iirc kicked back in like, 2017-18

#

nevermind your bot was deleted before so it wouldnt have been here to begin with

coarse yoke
winged linden
#

yo question

#

guild.members.forEach(async (member) => {})

this is possible to do?

rustic nova
#

do something with the members of each guild?

#

if your bot has that intent, yeah

winged linden
rustic nova
#

also ratelimits ofc

winged linden
winged linden
#

nvm

#

          const members = await guild.members.fetch();```
#

fixed it like that

#

and used members.forEach()

rustic nova
#

yeah just have to remember that .fetch() fetches all the members

#

which can cause ratelimits and/or cause delays processing things on your end

#

since that fetch actively requests the members from discord

lyric mountain
winged linden
#

what should i do then if i have to loop over the users every 2 min

keep in note, its just 1 server ๐Ÿ™‚

winged linden
lofty cipher
lyric mountain
#

uhh...but why fetch?

#

like, don't u already have a database?

winged linden
winged linden
winged linden
lyric mountain
#

idk

lyric mountain
#

or whatever ur doing

#

you should refrain from doing api operations whenever possible

winged linden
#
      verifyservers.find().then(async function (b) {
        for (const server of b) {
          const address_to_track = server.track_address;
          const guildid = server.server_id;
          const roles = server.roles;

          const guild = client.guilds.cache.get(guildid);

          const members = await guild.members.fetch();

          members.forEach(async (member) => {
            const account = await profiles.find({ discord_id: member.id });
            let count = 0;
            if (account.length > 0) {
              //check linked wallets, if they hold any nfts give role if not do nothing
            } else {
              //remove related roles cuz he didnt have his wallets linked yet
            }
          });
        }
      });
    };```
#

@lyric mountain

lyric mountain
#

u ping a lot dont u

winged linden
#

anyways, its all good lol, 2 requests every 2 mins wont hurt much

winged linden
#

twice just noticed lmao

craggy pine
#

replying pings aswell ๐Ÿ˜›

lyric mountain
#

instead of guild members

winged linden
winged linden
#

also, i can have a timeout every time it gives a role, that way i am not going over the limit

lyric mountain
#

update user status when events happen

#

like joining guild, role add, message, etc

neon leaf
#

this isnt necessarily about programming but does anyone know how to fix this? Lets say 3 players join my Minecraft Server; the first two have a normal ping and the other one always, always a bad one. Once a fourth player joins he just gets kicked because his connection reset. what? I have full access to the vps so help me here, I already searched for resets in tshark (wireshark) and found this:

winged linden
# lyric mountain update user status when events happen

its currently only 1 server so ig that should do the work now, once i have a more servers using that feature i can have a timeout between each server
like that
await new Promise(resolve => setTimeout(resolve, 1000));

the problem is updating user database wont be an option on the long run, it will probably cause more problems

winged linden
#

whats your specs anyways?

neon leaf
#

it isnt im quite certain

lyric mountain
#

it only makes harder to fix later on

winged linden
winged linden
#

for now its just 1 server, later on its gonna be much more

#

having timeouts wont hurt

lyric mountain
#

I told u to update their status when events happen

#

having timeouts WILL hurt

#

if you settle at "good enough" it'll create the bad habit of leaving technical debts unpaid

winged linden
winged linden
lyric mountain
#

and they'll end up forcing u to rewrite the entire thing again

winged linden
#

yeah ik it happened to me before lol thats why i am trying to have the best option right now

but really man, i cant just update their status on events

lyric mountain
#

why not?

#

it's 1000x better to call your database often than call the api often

winged linden
# lyric mountain why not?

1)i can 100% update once they link wallets, but what if they sold the nft, what if they bought more and need a higher role
2)i can add a database of users, but this database could be huge and could cause problems on the long run lets say i had to shut down the server for 5mins and like 500 users joined servers and i dont have them in my database
3)tracking real time data for my scenario is better cause as i said it depends if they hold nfts or not

winged linden
lyric mountain
#

uh, it will

#

with 2 servers that's 4-10 requests

winged linden
#

i will have the interval set to the number of servers i have +30 s

lyric mountain
#

I wont argue because 99% of the time they end up ignoring

#

but the way ur doing it, expect to be contantly hitting the ratelimit

winged linden
lyric mountain
#

it's the worst option

#

like, really

#

databases are made for huge amounts of transactions per second

#

and by huge I mean millions

#

while apis expect low amount of calls

#

the way ur doing it will require rewriting very soon

winged linden
# lyric mountain it's the worst option

suggest another way to make it automated, i cant track member joins of all the servers i got, it will be a hard and adding all the current members could hit rate limit

#

why would i hit the rate limit if i am sure its a max of 2-5 requests per second

lyric mountain
#

already did

lyric mountain
#

so you'll never hit ratelimit for listening to events

#

the only thing that can happen is crashing ur bot if u create too many listeners

lyric mountain
#

also, there's another little detail

#

fetching all members WILL crash your bot due to OOM

winged linden
# lyric mountain also, events do not hit the api

ah great then but again, what if my bot went offline for 5mins and those 5 users that joined i didnt add to the database

they will be left stranded (i know they wont be holding any nfts and they are useless but they could be given the role by a mod and i will not be able to remove it cause sometimes roles in this space are given just to test stuff)

lyric mountain
#

there are way too many events u can use for tracking it

#

if a member never talks u might as well not worry abt them

winged linden
lyric mountain
#

no server is strong enough

rustic nova
#

you could even use a join channel and check for joins that happened during your bots downtime

#

if the server provides one that is

winged linden
lyric mountain
#

listeners are global, not server-specific

#

but yes, u can listen to all events if u want

#

discord wont complain

winged linden
#

ah thats nice, i could do that. i will check what i could do and let you know ๐Ÿค

#

thanks alot ๐Ÿ˜„

lyric mountain
#

just make sure whatever u do, consider as if u were working with 1000 guilds

#

that way u ensure it'll grow smoothly over time

winged linden
#

now i make it in chunks as functions , if something is wrong i just fix the function / rewrite it

lament rock
#

Another way to ensure messages reach you is to separate your Discord gateway connection to another process and then send dispatch events to an aqmp instance and have your main bot or cache worker listen to amqp. The messages stay in a queue until they're consumed

hallow shell
#

how do i update my bot's profile pic on top.gg

sharp geyser
#

So say I had a camera and I wanted to view it on my pc/phone. How would I stream what the camera is viewing to my device of choice

#

I'd assume I would need smth to process these video streams of some sort to actually display it

lament rock
sharp geyser
#

I see

#

Is there any difference in efficiency in these encodings

oblique sky
#

Yes, h.264 is also known as .mp4
Some people use avi or other encodings, their size and speed is difference, you can search online for comparison between those encodings

carmine summit
#

Can I read messages sent to my bot in direct messages?
messageCreate event doesnt seem to trigger when its a direct message
It triggers fine on the server
Is there any special intents for direct messages?

deft wolf
#

Yes

#

You're specifically interested in one, "DIRECT_MESSAGES", unless you want to receive reactions as well

tame linden
# deft wolf Yes

I'm actually recognized the problem of laggy in my discord bot. As you know, I have tried to host on Heroku and AWS and the problem still there. But today, I have tried to host on Google Cloud and the suprise is it no more lags when playback. The specs on AWS: 2vCPU - 8 GB Ram ( I have try on differences specs, this is the maximum) and Google Cloud is: 1vCPU, 1GB Ram. So, seem like google are limiting the traffic from AWS to their server (?). I dont know

viral badge
#

one of my bots get really high ping "out of nowhere" sometimes (it suddenly starts being slow), this is /ping command using message listener method
(too slow for interaction)
Gets fixed by a bot restart
(the lower ping one is another one of my bots on the same machine so yall know its not some internet issue)
Ram usage: 0.3 GB

rustic nova
#

Either sudden spikes by your host

#

Or performance issues caused by overloading/not enough power

#

Keep an eye on both your server traffic nonetheless, aswell as your bots cache size and ram usage

viral spade
#

Hello, im using discord.js v14.7 on a bot with close to 100 shards.

Suddenly the bots started to go offline in some servers seemingly random. Other servers on the same shard are working just fine, and the shard, where the affected server is on, is still showing as online with uptime of multiple days.

Any ideas why the bot shows as offline and is not responding on some servers?

eternal osprey
#

Hey guys, i have created a multiplexor, how can i output 1 if there's parity?

quartz kindle
#

in any case you can try restarting that specific shard and see if the guild works again

#

if it still doesnt work even after restarting then its a discord issue most likely

feral aspen
#

I'm attempting to host an Umami application, and I was able to setup everything correctly. However, when it comes to logging in, the moment I click 'login', I get the following error of:

Segmentation fault (core dumped)
error Command failed with exit code 139.

I'm not sure, however, what's causing this issue. I've setup everything right, and the application starts, oh well. Although, it's the logging in that is the issue.

lament rock
#

segmentation fault commonly occurs when referencing a null pointer, so the code is at fault (no pun intended)

feral aspen
#

I mean the code is from the GitHub the documentation lead me to download, so I'm not sure.

lament rock
#

like I said, its an issue with the code

feral aspen
#

Great. ;-; (no analytics, then)

#

Though it'd be funny if I debugged it myself.

lament rock
#

Use something like StatsD if you need application analytics

#

or figure out graphana

feral aspen
#

I heard Umami was a good one, that's why I decided to use it.

#

Are they paid? If so, that's the great thing about Umami, it's free.

neon leaf
#

so I let users make reverse proxies with nginx and also upload ssl certs (!)
if they are invalid in most cases I tell the user but I cant detect everything and in worst case scenario nginx wont reload because its invalid; how can I make nginx ignore all ssl cert errors and just use a default one if it fails?

wheat mesa
#

So thatโ€™s uhโ€ฆ good luck

wheat mesa
#

Wait this is written in js

wheat mesa
#

How the hell did they fuck up so badly they got a segfault

#

In js

#

I would understand causing a segfault if it were written in C, C++, C#, or rust, but javascript??

quartz kindle
#

probably a native dependency for some reason

jaunty basalt
#

Hey anyone know how to change an image to circular using canvacord npm package

I'mma trying to do with an avatar url (discord)

Plz tell

viral spade
#

hi, i am using discord.js v14 and trying to restart a shard.

I am receiving the ids of the shards that are queued for a restart from my db into my shardingmanager process. There i will search for the shard and trigger its respawn function.

const shard = manager.shards.find(shard => shard.id == shardId);
if (shard) await shard.respawn();

however, it seems like the shard is not properly shut down, the shard process seems to run multiple times, for each respawn i did. All the shard's cronjobs run multiple times and when triggering a command i get "Interaction has already been acknowleged" multiple times.

Any idea why the shard is not shutting down properly and restarting, so only one instance of it is running at all times?

quartz kindle
viral spade
quartz kindle
#

eval command?

viral spade
quartz kindle
quartz kindle
#

after it restarted

viral spade
#

just not doing it now before its working

jaunty basalt
# quartz kindle

Will this work??

const { Canvas } = require('canvacord');

// slash command code...

let user = interaction.options.getUser('user');

let circlePfp = await Canvas.circle(user.displayAvatarURL({ format: 'png' }));

let a = new AttachmentBuilder(circlePfp, { name: 'circle.png' });

await interaction.reply({ files: [a] });```


I don't have my pc rn so I'm confused
quartz kindle
#

in bot.js

#

'SIGTERM' and 'SIGINT' have default handlers on non-Windows platforms that reset the terminal mode before exiting with code 128 + signal number. If one of these signals has a listener installed, its default behavior will be removed (Node.js will no longer exit).

#

The subprocess.kill() method sends a signal to the child process. If no argument is given, the process will be sent the 'SIGTERM' signal.

viral spade
#

thank you so much

quartz kindle
sterile brook
#

why this filter doesnt work

const filter = (interaction) => interaction.user.id === message.author.id && !interaction.user.bot
const tradeCollector = tradeRequestMsg.createMessageComponentCollector({filter, time: 90000 })
lyric mountain
#

define "doesn't work"

sterile brook
#

other user that is not message author can interact

#

freely

lyric mountain
#

the second part u can freely remove btw

#

interaction user will never be a bot

#

regarding the first part, anyone BUT the author can interact?

#

if so, did u try logging what each part is returning?

sterile brook
#

everyone can interact

#

author and any user

#

that's why i am asking

lyric mountain
#

then the issue can't be in that code u sent

quartz kindle
#

more specifically, show how you define message

neon leaf
#

how can I disable the update available message for pnpm? This doesnt work
pnpm install --fix-lockfile --registry=https://registry.npmjs.cf --update-notifier=false "${args[@]}"

sterile brook
quartz kindle
#

yes

sterile brook
# quartz kindle yes

i am just taking message from messageCreate event
and pass it to command.run() method

#

nothing more

#

problem not in message cuz it works in other commands

quartz kindle
#

on which message are the buttons you are waiting for?

sterile brook
#

here filter doesnt work

#

but here for example works fine

quartz kindle
#

hmm strange, i dont see anything wrong

gilded venture
#

Hopefully someone can help me here.
My bot in the last 2 days has randomly gone offline around the same time. It's in around 200 servers. Errors do not show anything crazy, but today I did see a few disnake errors around "Interaction took more than 3 seconds to be responded to.". I assume these happened just before it started to die.

When I try to rerun to start it up it just hangs and shows nothing... yesterday after a few attempts 20mins it starts working again. I have nothing to work with here and its frustrating.

Any ideas?

sudden geyser
#

Try seeing if anything you're using supports debugging (e.g. an env var DEBUG=true or logging levels)

deft wolf
#

Have you tried deferring interactions?

#

Depending on what your code is doing it can take more than 3 seconds to respond and deferring the interaction allows you to edit the response later

quartz kindle
gilded venture
gilded venture
quartz kindle
gilded venture
#

no, happened yesterday and today around 10pm

#

which could just be a popular time

quartz kindle
#

When I try to rerun to start it up it just hangs and shows nothing... yesterday after a few attempts 20mins it starts working again.

#

this gives me the impression that either your network had issues or discord had an outage

#

where is your bot hosted?

gilded venture
#

aws us-east-1

#

i looked on discord status that was my first thought but no outage

quartz kindle
#

could be an issue with aws

gilded venture
#

i do currently have no internet and tethering off my mobile but im not sure how that could interferee with anything, im ssh to my instance and trying from there

quartz kindle
#

do you have any info about cpu/memory usage on the machine?

gilded venture
#

yea its been the usual, just 1-2% lmao

#

i have 2 bots on 1 instance, the other is compltely fine and has the same code

#

only difference between the main one actually is that i have the top.gg api posting bot stats so i can see how many servers my bot is in

#

i added that in 4-5 days ago... thats the only difference between the too, apart from one being in 200 servers, and the only only in 2

quartz kindle
#

do you have the presences intent?

gilded venture
#

i dont actually, only server and message

#

wasnt approved for presense

#

dont think i needed it

quartz kindle
#

hmm, im mostly guessing here, but i can only think of aws network issues

gilded venture
#

do i need the presence intent for the top.gg api stats thing?

quartz kindle
#

no

#

i just asked because the presences intent causes a huge influx of data from discord

#

its almost like discord is ddosing you, thats how horrible presences are

gilded venture
quartz kindle
gilded venture
#

cant check my grafana dashboard cuz ive had no internet last 2 days

#

would be on there

#

fml

#
MemTotal:        1984212 kB
MemFree:          301820 kB
MemAvailable:    1135176 kB
rustic nova
#

Lol

gilded venture
#

i forget the difference between Free and Available

gilded venture
lyric mountain
gilded venture
#

im running a few things on there tbh

lyric mountain
#

ah ok, so that aint you bot's mem usage

gilded venture
#

no thats the whole server

#

running promethus + grafana dashboard

quartz kindle
gilded venture
quartz kindle
#

MemTotal: total usable RAM
MemFree: free RAM, the memory which is not used for anything at all
MemAvailable: available RAM, the amount of memory available for allocation to any process

#

anyway those look like normal values, nothing wrong there

#

for your issue it would be more helpful to get the memory used by the bot process

#

what does your bot run on?

gilded venture
#

disnake

#

if thats what you mean

#

python

#

and running in a docker container

quartz kindle
#

are both bots in the same container or in separate containers?

gilded venture
#

separate

#

using my phones 4g is messing with something - i just shut down my test bot thats on an entirely different server in another region, tried to spin it back up and nothing...

#

same with the clone bot on the main server

quartz kindle
#

hmm

gilded venture
#

Frustrating

#

No idea whatโ€™s causing it and no real internet connection to fix

lyric mountain
#

Crashes often appear on the log, no way ur getting nothing on it

topaz terrace
#

how do read a specific txt file and then find a string in that file and then remove the completely?

lyric mountain
topaz terrace
lyric mountain
#

Just save it

topaz terrace
lyric mountain
#

Because ur not saving the file

#

Ur just replacing the word

topaz terrace
#

do i just liek await allWords.save();

lyric mountain
#

Also, replace doesn't mutate the string

#

Strings are immutable

topaz terrace
#

oh ok

lyric mountain
topaz terrace
#

oh

topaz terrace
lyric mountain
#

Save the output of replace

topaz terrace
#

this is what it look like in the txt file.

lyric mountain
#

Idk how ur planning to use that dictionary, but you'll need some way to cache or index it

topaz terrace
#

hmm, how do i cache it

lyric mountain
#

That's a question for another day

topaz terrace
topaz terrace
lyric mountain
#

let string = string.replace(...)

topaz terrace
#

oh ok

#

how to save it?

lyric mountain
#

Just google it, should pop as tge first result

topaz terrace
lyric mountain
#

Yep

topaz terrace
#

so i would just to fs.writeFileSync("path/to/file", newString)?

lyric mountain
#

Yep

topaz terrace
#

oh

lyric mountain
#

Just remember that'll overwrite the file content

topaz terrace
lyric mountain
#

Yes

topaz terrace
#

how would i only replace a certain word

#

and not the entire thing

lyric mountain
#

Just replace the entire thing

#

By "entire thing" I mean you'll overwrite the previous content with the new content

#

The new content being the string minus the word u removed

topaz terrace
#

oh

#

i still dont get it

#

what

lyric mountain
#

let text = readfile

Lorem ipsum sit amet dolor

text = text.replace("sit", "")

Lorem ipsum amet dolor

writefile

topaz terrace
#

oh

wheat mesa
#

Does anyone know how to get a c++ project to compile to a standalone exe file in CLion? Can't seem to get it to work

lyric mountain
#

The hardest part is actually making c++ compile