#development

1 messages · Page 1751 of 1

slender thistle
#

topggpy is official and updated, dblpy is deprecated

worn sonnet
#

strip_after_prefix

marble juniper
#

why is dblpy on the top.gg docs then

#

lol

earnest phoenix
#

is i need add in bot code or top.gg page

slender thistle
#

Because I didn't update those docs yet

marble juniper
#

bruh moment

worn sonnet
marble juniper
#

I don't use python anyways so

sudden knoll
#

lmao

#

bruh moment

worn sonnet
marble juniper
#

infact I don't even know python

#

lol

sudden knoll
#

even more of a bruh moment

marble juniper
#

true

#

a giant bruh moment

slender thistle
marble juniper
slender thistle
marble juniper
#

đŸ„ș

worn sonnet
#

fuuuu

#

strip_after_prefix i see this thing in docs

#

but it doesn't work

sudden knoll
#
class Link:
  def __init__(self, languages=None):
    if languages == None:
      languages = []
    self.languages = languages
  
  def know_language(self, language):
    if language == 'python' and language not in self.languages:
      print("shivaco teach me")

languages = ['js']
link = Link(languages)
slender thistle
#

Show how you're using it

#

TYPE ANNOTATIONS BROOOOOOOO

worn sonnet
rare sierra
#

can I embed my website into the top.gg long desc?

slender thistle
#

Sure, iframe

rare sierra
#

and it will still run the JS code on my site?

slender thistle
#

I believe so

#

@worn sonnet what's your d.py version

tired panther
slender thistle
#

And I assume you subclass commands.Bot, yeah?

worn sonnet
slender thistle
#

Ya

#

I'm watching you. AruStare

tired panther
worn sonnet
#

the version

slender thistle
#

Ya boy didn't update d.py

worn sonnet
#

ara ara

slender thistle
#

Ara ara~

worn sonnet
#

my bad

#

it should work now

slender thistle
#

Ezpz

worn sonnet
#

just checked this thing wasn't there before updating

rare sierra
woeful pike
#

you can use iframes but you won't have access to anything on the top.gg side

earnest phoenix
#

👀

rare sierra
#

also its a bit annoying since I need more text

tired panther
slender thistle
earnest phoenix
rare sierra
earnest phoenix
tired panther
sudden knoll
#

hmm, I should probably start including annotations

#

oop

earnest phoenix
rare sierra
#

ugh, the iframe is too short of text to be in long desc

prime mist
#

Ah man, implementing a rest client that conforms to Discords rate limiting specs is a headache lol.

slender thistle
sudden knoll
#

but yes thank you

woeful pike
earnest phoenix
#

@solemn latch why you name is woo

#

but thx

#

How to embed bot website on top.gg

sudden knoll
#

if ur pro, just code in nano tho

earnest phoenix
#

@woeful pike Help

earnest phoenix
sudden knoll
earnest phoenix
#

Ik Iframe

#

but when i do it

#

it says your form

#

contains validation errors

rare sierra
#

this in itself is too small

earnest phoenix
#

Yup

woeful pike
#

yes, you should have content in your long description that should be searchable

#

you can fill it up with garbage if you want but that's not gonna help your seo

rare sierra
#

What do you recommend?

woeful pike
#
<iframe src="https://sorinorpgbot.tk" title="SorinoRPG Discord Bot">
  Brief description here that will be visible if your iframe doesn't work on the user browser
</iframe>
rare sierra
#

thats great, thanks xetera

earnest phoenix
#

@woeful pike Hi How Do I Link My Stylesheet To The Html On The top.gg description??

woeful pike
#

Look It Up Dude You Dont Have To Ping Me For That

sudden knoll
#

lmao the caps

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

tired panther
cinder stratus
#

Are there any chances that <Message>.guild.shard can be undefined

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

odd stratus
#

Doesn’t return undefined for me

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

cinder stratus
#

@sage bobcat on one server of my Bot it is undefined

sage bobcat
#

One message removed from a suspended account.

cinder stratus
#

and someone said it shouldn't be undefined

sudden knoll
#

slap a catch on it and call it a day

sage bobcat
#

One message removed from a suspended account.

sudden knoll
#

at least that's what I would do

cinder stratus
#

Well I tried to force Reconnect on vc on that server got memory leaks + 429 from discord

#

So I don't really want to supress it anymore

odd stratus
#

So it’s undefined on just one server??

#

I don’t see how that’s possible

cinder stratus
#

Yeah

#

It is

#

It never occured to me before but from past few days it is occurring

odd stratus
#

Even if a bot doesn’t have shards set up, it shouldn’t return undefined. It would return 0 as in shard 0 Thonk

cinder stratus
#

My Bot has 5 shards running on 2 clusters

odd stratus
#

Are you using Kurasuta for sharding or smth

cinder stratus
#

Yeah Kurasuta

odd stratus
#

Hmm

#

If you try evaling, does message.guild.shard return undefined in other servers too?

#

Maybe it’s different for Kurasuta

cinder stratus
#

Naah

#

It doesn't

prime mist
#

Does the master process do things differently?

cinder stratus
#

What do you mean by that?

rare sierra
#

How to I change the colour of my top.gg page, like this

cinder stratus
rare sierra
odd stratus
#

You need to use some CSS, though I haven’t tried it myself yet. Maybe I should 👀

#

Lazy though pepesad

rare sierra
#

like, what are the classnames so I can change the colour

prime mist
#

Node's clustering has a master process, and the child processes sit under the master.

#

I haven't looked into how kurasuta is implemented, so I'm just guessing :)

cinder stratus
#

Maybe Ask Yukine he is here

rare sierra
#

ill figure it out when i get home from school ig

odd stratus
# rare sierra like, what are the classnames so I can change the colour

This is all I found https://css-tricks.com/snippets/css/a-guide-to-flexbox/
Couldn’t really find a guide for a top.gg bot page

Our comprehensive guide to CSS flexbox layout. This complete guide explains everything about flexbox, focusing on all the different possible properties for the parent element (the flex container) and the child elements (the flex items). It also includes history, demos, patterns, and a browser support chart.

odd stratus
earnest phoenix
#

cn any one say how add server counts like this

#

pls

cinder stratus
worn sonnet
#

oke how do i get rid of default help cmd in d.py?

#

self.bot.remove_command("help")

#

i did this thing but still it doesn't work

cinder stratus
#

@odd stratus@prime mistI just found the server id where <Message>.guild.shard is undefined that server is not even part of any <Client>.shard

sudden knoll
worn sonnet
#

but didn't work

sudden knoll
#

idk what to tell you, that's how you do it

#

this is highly unfortunate

#

what was the error?

prime mist
cinder stratus
#

It's not even in my cache I wonder how am I able listen to the messages of that server

worn sonnet
sudden knoll
#

lmao

#

that is troll

worn sonnet
#

It was working all good before I updated to d.py to 1.7 or changed the help cmd

#

even after removing cmd it sucks

rocky hearth
#

does type predicate in ts, works for getters?

cinder patio
#

why wouldn't it

formal gate
#

Hello

sudden knoll
# worn sonnet

I assume your class looks like this
class MyBot(commands.Bot):

sudden knoll
#

wonky

rapid wharf
#

i heard Heroku provides 512 mb ram, is it correct???

sudden knoll
#

do you have 2 instances running at the same time?

formal gate
#

Who want to make a bot with me? Im 13 years old child

sudden knoll
rocky hearth
worn sonnet
#

oke so i'mma change the bot token

sudden knoll
#

lmao don't think that'll work

worn sonnet
#

cuz shit got fixed automatically

cinder patio
#

well then it doesn't

sudden knoll
#

wait really

cinder patio
#

why not just return boolean?

worn sonnet
#

so i doubt if anyone else has got my token

rocky hearth
sudden knoll
worn sonnet
sudden knoll
#

lmao wack

worn sonnet
#
intents.members = True
intents.presences = True
intents.guilds = True```
#
                         case_insensitive=True, strip_after_prefix=True)

sudden knoll
#

I meant are you passing it to def __init__(self, ...)

sudden knoll
#

okay that's what I thought

#

well if it's fixed, it's fixed

worn sonnet
#

yes

quartz kindle
#

why do you have to manually switch those 3 intents?

#

isnt .all() supposed to include them?

worn sonnet
quartz kindle
#

lol

worn sonnet
#

so my trust issues said

#

just do them manually bitch

sudden knoll
#

it sounds like there are a lot of wack issues with your bot

worn sonnet
#

yeah u right bro

sudden knoll
#

not ur fault as far as I can see, but still wack

quartz kindle
#

wack wack

earnest phoenix
#
package com.example.myapplication;

import android.os.Bundle;

import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.preference.PreferenceFragmentCompat;

public class SettingsActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.settings_activity);
        if (savedInstanceState == null) {
            getSupportFragmentManager()
                    .beginTransaction()
                    .replace(R.id.settings, new SettingsFragment())
                    .commit();
        }
        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.setDisplayHomeAsUpEnabled(true);
        }
    }

    public static class SettingsFragment extends PreferenceFragmentCompat {
        @Override
        public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
            setPreferencesFromResource(R.xml.root_preferences, rootKey);
        }
    }
}
#

Working on a calculator be like

frigid mountain
#

How do I define

client.giveawaysManager.start
spare badger
#

@frigid mountain I think you should look at the discord.js documentation to see what properties and methods exist within the client object. giveawaysManager is not a thing by default and you will have to develop such a thing yourself. Here the documentation for discord.js: https://discord.js.org/#/docs/main/stable/general/welcome

tired panther
#

do client.giveawaysManager = your_giveaway_manager

frigid mountain
#

K

spare badger
earnest phoenix
#

i cud give code

low river
#

Is there a way to add economy commands with doing mongodb stuff

#

Without*

quartz kindle
#

you need to store the data somewhere

#

mongodb is not the only option

#

there are hundreds of storage solutions and databases out there

sudden knoll
#

sql pog

low river
#

Time to.store in json

quartz kindle
#

sure

#

if you wanna hate yourself later on

#

:^)

prime mist
#

Na use excel file format.

cinder patio
#

use discord messages

quartz kindle
#

thats actually a thing

sudden knoll
#

Tim you use js right?

quartz kindle
#

there is an excelldb that syncs data with google sheets

#

ye i use js

sudden knoll
#

ah you probably can't help me with Advanced Python Scheduler then

prime mist
quartz kindle
#

ye xd

prime mist
#

Better than a SOAP API I guess.

quartz kindle
#

anything is better than soap at this point

prime mist
#

I vote for storing in JSON lol. Google sheets seems like opting in for an extremely painful experience.

sudden knoll
#

I use google sheets to store data, but solely for humans to read it, not bots

prime mist
#

Yeah Google sheets is great at what it does, much better than the Microsoft stuff :)

sudden knoll
#

blasphemy

#

I love me some microsoft powerpoint

earnest phoenix
#

How to add nitro emoji in bots

#

anyone?

quartz kindle
#

google shit sucks if the file is too large

#

for example i tried printing an excel file to a pdf file that would result in about 900 pages

#

tried in multiple browers, it would always get stuck and fail

#

i tried doing it on sheets because the fonts were weird in the actual excel

#

in that particular case, web fonts were doing a better job than system fonts

quartz kindle
#

bots dont care about nitro

earnest phoenix
quartz kindle
#

<:emojiname:emojiID>

earnest phoenix
#

Oh ty

quartz kindle
#

the bot must be in the server where the emoji comes from tho

#

and must have external emojis permission to use it in other servers

opal plank
#

i am so gonna regret pushing this to prod

earnest phoenix
#

How do I get emoji ID

zenith terrace
#

\:emoji:

earnest phoenix
#

:ytho:

#

:raphpat:

feral perch
earnest phoenix
zenith terrace
feral perch
earnest phoenix
#

Mobile

feral perch
#

yea u will need a pc

earnest phoenix
#

Oh

zenith terrace
#

mobile should still be the same

earnest phoenix
#

:ytho:

feral perch
zenith terrace
#

sad

#

it doesnt

feral perch
#

try using it in chrome using desktop site

earnest phoenix
#

ohk

feral perch
#

btw

zenith terrace
#

oh I know

#

you can do :emoji: on mobile

feral perch
#

is there a way we can fetch a number of messages in channel without a time limit

#

like I want to wait till I get 20 messages, then do a particular funtion

opal plank
#

wdym without a time limit

#

you mean a message collector?

feral perch
opal plank
#

you wouldbt be fetching tho, you would be waiting

feral perch
#

no timeout

feral perch
opal plank
#

usind d.s?

#

d.js

feral perch
#

but how do we wait for msgs

feral perch
opal plank
#

you could make your own collector, which i what i did

#

or use this

feral perch
#

but the number of msgs to wait for wont be the same everytime

opal plank
#

read that

feral perch
opal plank
#

use the max flag

#

u dont need to use a timeout

feral perch
#

ohh sorry

#

got it

opal plank
#

all the options are optional

feral perch
#

yea

#

yea yea

#

tysm

opal plank
#

np

zenith terrace
#

@earnest phoenix

feral perch
#

how can we check if a message contains a user tag?

earnest phoenix
feral perch
earnest phoenix
feral perch
#

i am not asking that

#

I want to check if theres a tag in any message a user sends

#

and the tag could be anyone from the server , not just the author

earnest phoenix
#

So you wanna know from which server and who sent the message?

earnest phoenix
#

Ah

feral perch
#

wait i'll give an eg

earnest phoenix
#

ok

feral perch
#

hello @pliant gorge @gilded plank @livid jackal !

#

here my message contains 3 tags

earnest phoenix
#

Oh

#

yes

feral perch
#

i wanna check if the messages sent in a particular channel has tagged someone

earnest phoenix
#

Oh idk about that 😭

#

I also want that.

summer torrent
#

tag or mention(s)?

#

you can get mentions with message.mentions.users

#

(in djs)

earnest phoenix
#

Oh wait a sec lemme try

feral perch
summer torrent
#

try this then

feral perch
#

yeah but if i do something like this

const filter = m => m.content.includes(message.mentions.users);
#

will it work?

summer torrent
#

no

feral perch
#

thats what i wanna check

summer torrent
#

message.mentions.users is collection of mentioned users

#

you can check it with message.mentions.users.size

feral perch
#

so i can get the mentioned users using that ri8

summer torrent
#

if this is 0

#

it means there is no mention

feral perch
#

ohkk cool

earnest phoenix
summer torrent
#

nothing

earnest phoenix
#

Hmm

vivid fulcrum
#

normal embeds cannot have fields iirc

summer torrent
#

isn't it same thing

earnest phoenix
summer torrent
#

RichEmbed got renamed to MessageEmbed in discord.js

earnest phoenix
#

Oh

vivid fulcrum
#

"normal" embeds are considered rich embeds

earnest phoenix
#

the messed up with names

earnest phoenix
#
 File "c:\Users\pc\projeler\bot\bot.py", line 540, in <module>
    async def _redd_t(ctx, subreddit):
  File "c:\Users\pc\python\lib\site-packages\discord_slash\client.py", line 570, in wrapper
    obj = self.add_slash_command(cmd, name, description, guild_ids, options, connector)
  File "c:\Users\pc\python\lib\site-packages\discord_slash\client.py", line 403, in add_slash_command
    options = manage_commands.generate_options(cmd, description, connector)
  File "c:\Users\pc\python\lib\site-packages\discord_slash\utils\manage_commands.py", line 219, in generate_options
    option_type = SlashCommandOptionType.from_type(param.annotation) or SlashCommandOptionType.STRING
  File "c:\Users\pc\python\lib\site-packages\discord_slash\model.py", line 281, in from_type
    if issubclass(t, discord.abc.User): return cls.USER
  File "c:\Users\pc\python\lib\abc.py", line 102, in __subclasscheck__
    return _abc_subclasscheck(cls, subclass)
  File "c:\Users\pc\python\lib\typing.py", line 1171, in _proto_hook
    raise TypeError("Protocols with non-method members")
#

error

rare trail
opal plank
#

@quartz kindle i blame u for this

#

why did nobody tell me presences WILL absolutely destroy your soul?

rare trail
opal plank
#

like wtf

#

im gaping rn with the sheer amount of load it put on the cpu

#

no wonder my bot was using 120% cpu all the time

rare trail
#

i have a 8GB ram 2 core 3.77GH/z

#

with presence it use like 40% of cpu

#

without presence, 2-12%

quartz kindle
#

lmao

rare trail
#

(500+ guilds)

#

scared about big bots like MEE6 which have presence enabled

spice mauve
#

䜕

opal plank
#

im legit getting 70-100k ish depending on hour, per minute

#

i've seen it spike to 150k per minute before

rare trail
#

i got max 2mln socket requests by presence in 3 min

#

after i've disabled it

opal plank
#

i'll have to process the presences somewhere

fleet plinth
#

can that work ?❓

opal plank
#

asking a friend some help about it

#

cuz worker_threads is not my area

#

speaking of help

#

@quartz kindle wanna help me figure out worker threads and perhaps spam discord like i did with twitch?

#

we all know what happens when i touch things that CAN break

#

murphy's law loves me

quartz kindle
#

wut u wanna do

opal plank
#

i wanna start new clients in worker_threads and then reemit the ones that have been processed back to the main thing

#

same deal from last time we chatted

#

basically using worker_threads as filter

#

to not clutter the main thread

quartz kindle
#

how do you wanna do it?

#

one worker for all shards, or multiple workers with a few shards each?

#

one worker would be easier to start with i guess, and see how it goes

earnest phoenix
#

any one say any vps who cnt take cc

#

pls

vivid fulcrum
#

what

stiff lynx
#

guys, any cool idea for currency system?

opal plank
#

reading the docs for worker_threads already

vivid fulcrum
quartz kindle
#

one worker per shard is too much

vivid fulcrum
#

totally a good idea â„ąïž

opal plank
#

i doubt it tbh

opal plank
#

32 cores

quartz kindle
#

unless you do some stupidly heavy processing in a single thread

opal plank
#

which i kinda am

#

one thread is already capping at 120%

#

having a thread handle a whole shard doesnt seem too bad

stiff lynx
#

@opal plank how u did your bot appear in your account?

opal plank
#

a what

opal plank
#

what im confused is to why its not updating

earnest phoenix
#

So, what that code thing using args thats like:

.disable *something here*

Then its like if('message', args[1])

or something. I am so tired lol, 7am and no sleep.

#

Let's just define it as a command inside a command.

.disable mod/tickets

How would I make the start of it?
like the

}```
Portion
#

Everyone probably like tHiS gUy MaKeS nO sEnSe D2S_E_why

stiff lynx
opal plank
#

just compile in c#

#

the stuff they got there is basically copy paste

earnest phoenix
#

Imagine someone answers my question D2S_E_why

low river
#

what u want

earnest phoenix
#

Scroll^^^

low river
#

oh for js or py

earnest phoenix
#

js

low river
#

i have a code but its with a global variable

#

so not server specific

earnest phoenix
#

That's fine.

#

help

#

I will customize it and make it suitable to my needs.

#
(node:103) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 26 unhandledRejection listeners added to [process]. Use emitter.setMaxListeners() to increase limit
#

what is this

#

error

umbral zealot
umbral zealot
earnest phoenix
#

How to make a command inside a command

#

Like

umbral zealot
#

oh, uhm, just split the message into arguments, then

earnest phoenix
#

People use .help <command>

earnest phoenix
umbral zealot
#

yes you cn

earnest phoenix
#

omg, I am so tired đŸ€Ł

umbral zealot
#

remove it from the loop or event

earnest phoenix
#

pls help

umbral zealot
#

I can't do it for you.

#

Start by locating where that handler is

#

looks like process.on('unhandledRejection', ...

stiff lynx
opal plank
#

i believe so, cuz it has to detect discord running

stiff lynx
#

I cant lol, I dont want my Intel Pentium to Explode lol

earnest phoenix
#

😭

umbral zealot
#

dude

#

Read what I Said

umbral zealot
#

and the message after

#

stop acting like a petulant child in the middle of a meltdown, and use your brain

earnest phoenix
#

😭 i got lots of dm

earnest phoenix
#

complain

umbral zealot
#

ok well

earnest phoenix
#

pls help one time

#

only on

umbral zealot
#

as long as you're freaking out and flailing your arms around nothing's going to happen

earnest phoenix
#

w

umbral zealot
#

I'm literally trying to help you

earnest phoenix
umbral zealot
#

Start by locating where that handler is
looks like process.on('unhandledRejection', ...

#

use the search feature in your code

earnest phoenix
#

pls pls one time only one

#

cn you pls one

umbral zealot
#

... do you not, like, understand what I'm saying?

earnest phoenix
#
}).listen(8080);
#

this

umbral zealot
#

if you can't grasp the simplest of concept I can't help you

#

Does }).listen(8080); look even CLOSE to being process.on('unhandledRejection', ... ????

trail finch
#

XD

earnest phoenix
#
require('events').EventEmitter.defaultMaxListeners = 25
#

this

umbral zealot
#

no

#

I cannot help you if you do not have a basic grasp of the english language, or are unable to follow simple instructions

#

So stop pinging me unless you intend to start listening to me.

earnest phoenix
#

ok bhie

green kestrel
#

hmm

#

im learning from observing performance stats of triviabot, that economy bots are somewhat responsible for most of the abusive spam against bots on discord

#

seems they bring out the worst in idiots who like to spam commands several times a second in hope of getting more coinage

lavish bramble
#
if(message.content === message.content){
   	if(message.channel.type === 'dm'){
   	if(message.author.bot) return 
   	const uuid = 0101
   	const input = message.content
   	
   	
    fetch(
        `https://api.monkedev.com/fun/chat?msg=${encodeURIComponent(
            input
        )}&uid=${uuid}`
    )
        .then((res) => res.json())
        .then(async (json) => {
            return message.channel.send(json.response);
        })
	}
}
})

Error

opal plank
#

wtf is that

#

if(message.content === message.content)

#

the indentation

#

the fact there theres no .id there

cinder patio
#

I mean, you have to make sure 1 equals 1 right

opal plank
#

what am i looking at

cinder patio
#

you have to prove that

opal plank
cinder patio
#

uuid = 0101

#

that's not an uuid triggered

cinder patio
#

you're right sorry

opal plank
#

they just posted that and ditched

#

i wonder if people are actually looking for help or just to troll

umbral zealot
#

that indentation tho

cinder patio
#

I dunno I don't think their troll was very successful

lavish bramble
#

Hmm

opal plank
#

everything about that is cursed

umbral zealot
#

sort of code that the more you look at it the more you need eye bleach

opal plank
#

this ^^

lavish bramble
#

That was chat bot code

cinder patio
#

lol

opal plank
#

wait, you somehow managed to run a bot with that?

cinder patio
#

.then(async =>

umbral zealot
#

that was chat bot code that would get you fired as a developer, were you paid for it.

lavish bramble
#

Its working but sends error too

umbral zealot
#

every line of that code deserves a written warning

opal plank
#

the errors isnt even coming from there

#

you do know that right?

#

.id of null, theres nothing in the snippet you provided with .id in it

#

if you wondering why we are surprised at wtf that is

umbral zealot
#

to be fair I'd be triggered even if this was the code that caused the error

opal plank
#

im triggered by the fact that this somehow ran

quartz kindle
#

lel

opal plank
#

tim

#

teach me the ways of worker threads bliz

quartz kindle
#

what do you need

opal plank
#

yes

#

how to get the detritus-gateway to be spawned inside worker_threads and reemit the events that have been filtered back to the main thread

#

i got half of it

quartz kindle
#

idk anything about detritus gateway

#

but i assume it has a way to set shard id and total shard count?

opal plank
#

yeah

#

so, the way evan told me to do it is to basically spawn a worker threat with that gateway client in each of them

#

and pass in the shardId + shardCount

quartz kindle
#

yes

opal plank
#

so basically spawn a worker_thread for each shard i got

quartz kindle
#

yes

opal plank
#

and then the rest looks something i already done with fork

#

with process.message()

#

actually

#

no

#

this doesnt use process to send messages

quartz kindle
#

yes, with threads its thread.postMessage() and parentPort.postMessage()

opal plank
#

MessageChannel() seems to be what i'd want

#

and use setEnvironmetalVariable?

#

im not sure how i'd be passing arguments to them

quartz kindle
#

you can use env to pass the shard data

lavish bramble
opal plank
#

hmmm

quartz kindle
#

but its not needed

#

you can use workerData

opal plank
#

thats new to me

quartz kindle
#

when you create a worker, you can give it a workerData object in the options

opal plank
#

both 2 things im stuck at:
it seems that worker threads also runs off a file

quartz kindle
#

this obj will be available inside the thread under worker_threads.workerData

opal plank
#

and the second thing im stuck at is how to send it stuff that i can pull from the file its spawning

#

oh

#

oh so this is what that was

#

i've read it, but didnt understand jack shit

quartz kindle
#

yes

opal plank
#

i thought you needed to create a MessageChannel for that

quartz kindle
#

the example above is using the same file for master and worker

#

you can use isMainThread for that

#

but if you use a separate file for the workers, you dont need any of that

opal plank
#

in my case i'd be using another file, for organization sake, but that bit is fine

#

okay, so worker data is figured out

#

now how to run them with ts is another issue

#

with fork i had custom arguments

quartz kindle
#

so in the second file, you do ```js
const { parentPort, workerData } = require('worker_threads');

console.log(workerData);

parentPort.postMessage("im alive")

opal plank
#

but i assume its not gonna be a necessity here

quartz kindle
#

yes, you dont need args

#

everything you need to send to the worker at launch, you put it in the workerData object

opal plank
#

aight thats fine

#

so

#

do i need them to be assigned to a variable like i did with twitch?

#

the way i see u posted there is that it always will have access to teh parent

#

since im just emitting everything into the parent

#

instead of

quartz kindle
#

the main process needs to store a reference for each worker yes

#

to run with ts, apparently you can do this ```js

// worker.js
const path = require('path');
require('ts-node').register();
require(path.resolve(__dirname, './worker.ts'));

// worker.ts
import { workerData } from "worker_threads"
...

// main.js
new Worker("./worker.js", {workerData: ...})

opal plank
#
const {Worker} = require('worker_threads')
for(let i, i > 4, i++) {
const worker =  new Worker('', {data:shardId});
  worker.on('message', (data) => {client.emit('MyCustomEvent', data)});
}
//i can do

const {ParentPort, Worker} = require('worker_threads');
for(let i, i > 4, i++) new Worker('', {data:shardId});
ParentPort.on('message', (data) => {client.emit('MyCustomEvent', data)});
#

so i could do this instead?

#

would they all be emitted under ParentPort?

quartz kindle
#

the second part makes no sense

opal plank
#

rather than having to assign each worker

quartz kindle
#

you are creating workers inside workers

opal plank
#

if i create a MessageChannel does it not get automatically assigned to the main thread?

#

rather than having to register an event for each worker?

quartz kindle
#
// main
const { Worker } = require("worker_threads");
for(...) {
  const worker = new Worker(...)
  worker.on("message", data => client.emit(...))
}

// worker
const { parentPort, workerData } = require("worker_threads");
shard.on("raw", data => parentPort.postMessage(data));
opal plank
#

okay that makes sense

#

let me try that rq

#

also, worker threads exit when main thread closes right?

quartz kindle
#

yes

opal plank
#

so i dont need to map them somewhere to close em on exit

quartz kindle
#

they dont "exit", they die

opal plank
#

i see

quartz kindle
#

like pulling the plug

visual goblet
#

am I reading that correctly

#

it says slaves

quartz kindle
#

yes

opal plank
#

welcome to the OG way of naming your workers

visual goblet
#

oh makes sense

opal plank
#

master/slave terminology

#

i couldnt give 2 shits about people who bring potilical arguments to nomenclature that has been this way for years

#

its programming naming either way

#

cant even make a good argument

quartz kindle
#

20 years ago we were setting old IDE hard disks to master mode or slave mode by placing a jumper switch

sage bobcat
#

One message removed from a suspended account.

quartz kindle
opal plank
#

do i need that tho? they basically only exist to give me presences

quartz kindle
#

no you dont need it

opal plank
#

otherwise i could make a controller like i did in the example above

visual goblet
#

would you happen to know how reliable mongodb is? and if it's not would you know a db to use or learn in order to store data easily but efficient?

copper cradle
#

mongo is really good and reliable

quartz kindle
#

all dbs are reliable if used correctly

copper cradle
#

there you go

visual goblet
#

alright

opal plank
#

oho

#

theres an eval on workers?

#

let me go with ur route to pull them tho

#

cuz .ts

quartz kindle
#

no there isnt built in eval

visual goblet
#

is there an easier database to use or are they all equally tough?

quartz kindle
#

they are all different, some simpler, others more complex

#

i personally find SQLite to be very simple

weary crypt
#

agreed

visual goblet
#

ill work with that then thank you

quartz kindle
#

haha very funny

opal plank
#

not too far from the truth

quartz kindle
#

and extremely unexpected /s

#

:^)

opal plank
#

lel

copper cradle
#

json database has joined the chat

quartz kindle
#

json database has been banned

copper cradle
opal plank
#

odds of this working?

#

i just noticed i can use process.time to get the uptime

copper cradle
#

2/10

stiff lynx
#

What I need for invite tracker?

drifting wedge
#
from random import randint

flips = int(input("Flips: "))
h = 0; t = 0
for i in range(1, flips):
    if randint(0,1) == 0 :
        h+= 1
    else:
        t+= 1

print("======")
print(f"H: {h}")
print(f"T: {t}")
print(f"P: {round(flips/(h if h > t else t), 4)}% to land on {'h' if h > t else 't'}")
print("======")``` code review time
copper cradle
#

7.8/10 too many print statements

quartz kindle
#

it wont run ts files

#

the trick is to give it a js file that runs a ts file

copper cradle
#

that's a bit confusing

opal plank
#

wont this resolve it?

slender thistle
#

Multiline string even

earnest phoenix
#

h = sum(randint(0, 1) for _ in range(flips))
t = flips - h

:mmulu:

slender thistle
#

lmao would there be a significant performance change though?

earnest phoenix
#

Dunno lulw, haven't tested it

slender thistle
#

Well, import timeit here I go

earnest phoenix
#

I'm curious 0_EyesMoving

opal plank
#

atTim, it no work

slender thistle
#

Printing the results was a bad idea

earnest phoenix
#

Lmao, how many iteration was it

slender thistle
opal plank
#

@quartz kindle why no work

quartz kindle
#

show worker.js

opal plank
#

even when i put .ts in the worker file path it legit doesnt output anything

opal plank
quartz kindle
#

thats ts

opal plank
#

oh

#

there isnt one

quartz kindle
#

then you need to create one

opal plank
#

it needs to get compiled before with ts-node

#

i thought ts-node would transpile first

#

and then it'd have a worker.js in there

lyric mountain
#

that'd fit more for bennett

quartz kindle
#

try the trick i showed you before

opal plank
#

thats what im doing

pale vessel
lyric mountain
#

1 server, sole user

pale vessel
#

have you not updated your client?

opal plank
#

its the bot's api thats in maintenence

pale vessel
#

that's old blurple

opal plank
#

OOOH

#

the file itself has to be in js?

quartz kindle
#

yes

#

workers only accept js files

opal plank
#

can i use typescript in there tho?

#

this is why im asking this

quartz kindle
#

it doesnt matter

#

the trick is to give it a js file

lyric mountain
quartz kindle
#

and have the js file load the ts file

opal plank
#

oh

#

OOOH

quartz kindle
#

you run your bot with ts-node right?

opal plank
#

correct

quartz kindle
#

so thats a js file, that when executed by the worker, will require a ts file with ts-node

opal plank
#

what im confused is that im getting no errors nor messages

#

absolutely nothing in console

#

even though it should be looping

#

NOOOW we getting errors

quartz kindle
#

exdee

opal plank
#

oh i see why

#

wait what

#

no i dont

#

this is so fucky

quartz kindle
#

you are fucky, you are fucky

opal plank
#

why

#

y dis

#

y dis happen

cinder patio
#

implicit any bloblul

opal plank
#

its not even any tho

#

look in the screeshot

cinder patio
#

looks like it's from another file cause line 18 doesn't have packet

opal plank
#

its probably compiled

cinder patio
#

it's not

#

.ts

#

it's a compiler error

opal plank
#

then i've got no clue

#

it says its from _worker.ts

#

im at _worker.ts

#

and it has types

#

and i even slapped a //@ts-nocheck above

slender thistle
#

@earnest phoenix lol this is rather interesting

#
>>> timeit.timeit("flips = 100\nh = sum(randint(0, 1) for _ in range(flips))\nt = flips - h", setup="from random import randint")
128.98641730000003
>>> timeit.timeit("flips = 100\nt = 0\nh = 0\nfor _ in range(flips):\n    if randint(0, 1): t += 1\n    else: h += 1", setup="from random import randint")
103.92398380000009
opal plank
#

FUCKING

#

WHAT

quartz kindle
#

wat

#

since when

opal plank
#

worker can use ts

earnest phoenix
#

Built-in fuction sucks blobweary

slender thistle
#

Probably because sum iterates over the generator after you create it

#

And Exe's method iterates once and works with that

opal plank
#

LIES

#

LIES AND DECEIT

quartz kindle
#

lmao

slender thistle
#

I'm not sure how Python generators work though so I'm not the one to make definitive statements here KEKW

earnest phoenix
#

What if it was a list instead of a generator, ah either way, it'll have a small overhead

opal plank
#

tim pliz debug

#

ive been at this for 8 hours

slender thistle
#

You know what

#

Million iterations takes too much time

#

I'll reduce it to like 10k

earnest phoenix
#

Kekw

#

I think making it a list should make it slightly faster

slender thistle
#
>>> timeit("flips = 100\nt = 0\nh = 0\nfor _ in range(flips):\n    if randint(0, 1): t += 1\n    else: h += 1", setup="from random import randint", number=100000)
9.653332100000004
>>> timeit("flips = 100\nh = sum([randint(0, 1) for _ in range(flips)])\nt = flips - h", setup="from random import randint", number=100000)
10.0970954
>>> timeit("flips = 100\nh = sum(randint(0, 1) for _ in range(flips))\nt = flips - h", setup="from random import randint", number=100000)
12.006130599999999
#

Yeah, a list seems to make it faster

#

Interestingly enough, doing sum(tuple(...)) in 100k iterations did better than the generator

#
>>> timeit("flips = 100\nh = sum(tuple(randint(0, 1) for _ in range(flips)))\nt = flips - h", setup="from random import randint", number=100000)
11.21687700000001
earnest phoenix
#

Hello, I come to you because for a few days now, an error appears on my bot and its causes a reboot of the bot, I do not know how to fix this despite some research on the web. Can anyone help me?

Error: read ECONNRESET
    at TCP.onStreamRead (internal/stream_base_commons.js:209:20)
Emitted 'error' event on Connection instance at:
    at Connection._notifyError (/moon/node_modules/mysql2/lib/connection.js:225:12)
    at Connection._handleFatalError (/moon/node_modules/mysql2/lib/connection.js:156:10)
    at Connection._handleNetworkError (/moon/node_modules/mysql2/lib/connection.js:169:10)
    at Socket.emit (events.js:376:20)
    at emitErrorNT (internal/streams/destroy.js:106:8)
    at emitErrorCloseNT (internal/streams/destroy.js:74:3)
    at processTicksAndRejections (internal/process/task_queues.js:82:21) {
  errno: -104,
  code: 'ECONNRESET',
  syscall: 'read',
  fatal: true
}
slender thistle
#

So to make sure no data is cloned

#

My dumb ass decided to work with __dict__ in dunder methods

quartz kindle
opal plank
#

frick

#

imma go bother the nerds at the ts server

quartz kindle
#

@opal planklel

opal plank
#

wtf is this

quartz kindle
#

sorcery

opal plank
#

let me try that

#

lowkey

#

can u copy that snippet for me tim?

quartz kindle
#
const workerTs = (file: string, wkOpts: WorkerOptions) => {
    wkOpts.eval = true;
    if (!wkOpts.workerData) {
        wkOpts.workerData = {};
    }
    wkOpts.workerData.__filename = file;
    return new Worker(`
            const wk = require('worker_threads');
            require('ts-node').register();
            let file = wk.workerData.__filename;
            delete wk.workerData.__filename;
            require(file);
        `,
        wkOpts
    );
}
earnest phoenix
deep mantle
quartz kindle
#

they should be

deep mantle
#

ok thanks

worn sonnet
#

Do anyone know how can I extract rhx_gis

#

For Instagram

#

I'm using python

#

it's a known issue

slender thistle
worn sonnet
#

I checked it but..

slender thistle
#

I'm amazed that's still open

worn sonnet
#

i kinda don't get how to implement it

#

what should i pass in html parameter

#

def _extract_rhx_gis(html):

slender thistle
#

I have absolutely zero fucking clue what to do so yeah

worn sonnet
#

same here

#

i tried each of the fix from there

#

but apparently i don't know wtf is happening

slender thistle
#
import string
import hashlib
import random

class MyClient(Client):
    @staticmethod
    def _extract_rhx_gis(html):
        options = string.ascii_lowercase + string.digits
        text = ''.join([random.choice(options) for _ in range(8)])
        return hashlib.md5(text.encode())
``` I guess
#

I'm not sure what to do from there

#

Try that I guess

worn sonnet
#

umm.. so what i did now is commented the part in lib from where it was raising the error

tulip knoll
worn sonnet
#

and now i can't scrape

#

nice!

tulip knoll
#

i just hosted a bot on heroku this morning and i made changes to the code now, how do i update it on heroku?

slender thistle
#

What did you comment out lol

worn sonnet
#

deploy the bot again

tulip knoll
worn sonnet
#

lol i commented this thing

#

but still rhx_gis is required to scrape

worn sonnet
#

with this thing

#

and it worked

#

ah no

slender thistle
#

At some point I wonder if you're just better off writing your own wrapper

worn sonnet
#

it didn't

#

i get same None response when trying to scrape

worn sonnet
opal plank
#

FUCKING

#

@quartz kindle

#

check this shit out

#

this somehow works

#

even though ts-node compiles all those files

#

and brings them to the outDir

#

just like the fs module it uses the root folder as base

#

instead of where its called

#

absolutely retarded

#

so now i gotta add another retard to the mix that acts different from everyone else

#

require() uses its own file as base
fs uses main root folder
and Worker uses workspace

#

fuck this

#

im done coding for today

#

and yes, i did get it to work

drifting wedge
umbral lake
#

hey

#
client.on("presenceUpdate", async(client, oldPresence, newPresence) => {
    const soutiens = client.guild.roles.cache.find(role => role.id === "839894783928696893");
    if (newPresence.activities[0] && newPresence.activities[0].state.includes(".gg/candys")) {
        newPresence.roles.add(soutiens)
    } else {
        newPresence.roles.remove(soutiens)
    }
});
#

activities is undefined

#

:/

rocky hearth
#

Ive visited a website, and I want to download all its images and svg files.
How do I do that
I'm in the network panel in chrome dev tools.
and can see all the images.

solemn latch
vivid fulcrum
#

activities can never be null

umbral lake
#

like my statut

solemn latch
cinder patio
umbral lake
cinder patio
#

If the site is static you could make a HTTP request to get the body and then extract all img tags via cheerio or htmldom#

rocky hearth
#

how, to, where to start? There is an option to export .har file also. what is that

solemn latch
umbral lake
cinder patio
solemn latch
#

use status, linked above

rocky hearth
#

yeah, i want the script, for sure

umbral lake
cinder patio
#

What's the site if you don't mind sharing?

rocky hearth
cinder patio
#

I'm assuming you want to get the chess pieces?

rocky hearth
#

yes

lyric mountain
#

just scrape the source code

#

get all tags with src

cinder patio
#

those are dynamically generated so you'll have to use something like puppeteer

#

All chess pieces have a pc class

rocky hearth
#

I tried this too, it worked.
But there are alot of them

snow urchin
cinder patio
#

That snippet doesn't tell me anything

lyric mountain
#

like, same size as the profile button but grows to full size on mouseover

sage bobcat
#

One message removed from a suspended account.

vivid fulcrum
#

so you are an ai

#

i knew it

#

!

earnest phoenix
#

How to put member watching in bot status

#

membercount

stiff lynx
#

How can I send the message of a command in 1 specific Channel?

#

for example, I want that my currency system works Only in a Channel

lusty quest
#

it makes it easier for everyone if you would provide the language you use. or the next time i give examples in languages you maybe not use.

stiff lynx
#

discord.js

lusty quest
#

store the channel id, when you run the command check if the command channel id == stored channel id

#

you also could make an array of channel ids and use includes

distant cobalt
#
essage.channel.send(`Confirming report...`)
            const confirmationMsgEmbed = new Discord.MessageEmbed()
                .setColor("ORANGE")
                .setTitle("Confirming Report...")
                .setDescription(`Do you want to report this user? (${target.toString}). Sending in false reports will result in a warn.`)
            const confirmationMsg = await message.channel.send(confirmationMsg)
            confirmationMsg.react(':3419_added:').then(() => message.react(':Removed:'));

            const filter = (reaction, user) => {
                return [':3419_added:', ':Removed:'].includes(reaction.emoji.name) && user.id === message.author.id;
            };``` why doesn't this work
humble rock
distant cobalt
#

(node:6909) UnhandledPromiseRejectionWarning: ReferenceError: Cannot access 'confirmationMsg' before initialization

humble rock
#

im trying to do a command slowmode system

#

but...

lusty quest
runic gyro
#

my bot isnt coming online and it is showing this

#

i need it to be online for verification

#

:/

distant cobalt
lusty quest
# humble rock bug?

wrong units? or did you do calculations? if yes remember that js is dumb and will make 2+2=22

lusty quest
distant cobalt
#

wdym.

distant cobalt
#

I want to send the confrimationmessage

#

and the bot reacts to it

runic gyro
lusty quest
distant cobalt
#

Before it reacts to it

lusty quest
humble rock
lusty quest
#

looks like your command manager

lusty quest
humble rock
#

@lusty quest bug?

lusty quest
#

you probably send some stuff wrong

humble rock
lusty quest
#

show your command handler, where you apply the cooldown

humble rock
stiff lynx
lusty quest
humble rock
lusty quest
lusty quest
crimson vapor
#

Why do people even use table logs for loading commands? Doesn’t make any sense

lusty quest
humble rock
#

oh ok

lusty quest
#

i wish someone would make a guide in how to debug code.

opal plank
quartz kindle
#

just do cat pls debug kthx

opal plank
lusty quest
#

basic debugging, would help already a lot

opal plank
#

right clicking and clicking there is too hard

lusty quest
#

well people cant manage to do this

opal plank
#

so is clicking the red button there

#

press f5 => click red button on left side

#

boom, you are now debugging

#

though, truth to be told

#

there is already a guide

lusty quest
#

now make this a fancy website and pin the link for it here.

opal plank
#

its just not the pre-digested baby soup shit they give to discord.js users

lusty quest
#

or add a bot that got some trigger phrases that sends the link ins as soon as someone asks why it doesnt work

spice socket
#

how to tell a bot to use an animated emoji without nitro
for example i have a custom welcome message but i have to tell the bot to use the emoji in the chat, but it just appears as : :

severe dust
#

holy

spice socket
#

pee

severe dust
#

big code

#

bad

severe dust
spice socket
umbral zealot
#

let's not tell peeps to switch their programming language, yeah?

spice socket
#

no its not my bot

severe dust
spice socket
#

how to find the ID

severe dust
opal plank
umbral zealot
severe dust
#

o lol for me kinda works

spice socket
opal plank
#

not /

spice socket
#

or like /:piglinvibe;

opal plank
#

this \

spice socket
#

oh

opal plank
#

not this /

spice socket
#

\piglinvibe

opal plank
spice socket
#

ok got it

#

thx

opal plank
earnest phoenix
#

:mmulu:

spice socket
#

wow

#

lol

opal plank
#

well yeah, i can make gifs instantly

zenith terrace
#

imagine not having a gif of it lol

spice socket
#

ig i have to send it in a diff server

#

which doesnt have it