#development

1 messages · Page 1446 of 1

quartz kindle
#

he said he has other processes

drifting wedge
#

i do

#

but their all python

quartz kindle
#

and none are using pm2?

drifting wedge
#

they are

#

like pm2 is whats running it

quartz kindle
#

if you are using pm2 to manage multiple process, then yeah just get data from pm2

drifting wedge
#

but i can switch over

#

im only running python on pm2

#

so if theyres any python ones

#

but i need to be able to get the data

hollow sedge
#

"Advanced process manager for production Node.js applications." 🤔

drifting wedge
#

it works with python

hollow sedge
#

ig

drifting wedge
#

i mean the other one

#

forgot the name

#

like pm2 is commandline

#

no code needed

hollow sedge
#

code is easier than command line

drifting wedge
#

welp

weary ore
#

I implemented it but it doesn't work neither thow any errors

drifting wedge
#

can i get the proccess stats from it?

hollow sedge
#

you probably could but i mean you already got pm2 working

drifting wedge
#

but i dont get how i would parse pm2 data

#

or get it

quartz kindle
#

i just told you

drifting wedge
#

like how can i get the response?

hollow sedge
#

you execute commands

quartz kindle
#

exec pm2 jlist

drifting wedge
#

1 sec

#

it closes

#

the ssh

#

exec pm2 jlist

hollow sedge
#

how

quartz kindle
#
Parametric Thoughts

Python is a wonderful language for scripting and automating workflows and it is packed with useful tools out of the box with the Python Standard Library. A common thing to do, especially for a sysadmin, is to execute shell commands. But what usually will end up in a bash or batch file, can be also done in Python. You’ll learn here how to do just...

drifting wedge
#

idk

hollow sedge
#

wait

#

thats not valid python

#
import os
stream = os.popen('pm2 jlist')
output = stream.read()
print(output)
#

^

#

from the same thing that tim sent

drifting wedge
#

i run this?

#

wait

#

im confused

hollow sedge
#

yes

#

you run it like that

drifting wedge
#

i do subproccess

#

and i do subproccess.run whatever pm2 jlist

#

no?

quartz kindle
#

yes

drifting wedge
#

like id need the output

#

does it send?

quartz kindle
#

you read the stdout it returns

hollow sedge
#
import subprocess
process = subprocess.Popen(['pm2', 'jlist'],
                     stdout=subprocess.PIPE, 
                     stderr=subprocess.PIPE)
stdout, stderr = process.communicate()
stdout, stderr
#

from the same article that tim sent

#

lol

drifting wedge
#

ye

#

but id run this in the vps

#

popen

#

would just open it in the vps?

quartz kindle
#

you need to code that inside you python script

hollow sedge
#

yeah

quartz kindle
#

wherever you need to get that data

drifting wedge
#

and i would set it as a var

#

basucakky

quartz kindle
#

yes

drifting wedge
#

stdout and stderr

#

uhh why is it 2 dif tings?

hollow sedge
#

calling python variables vars 😭

drifting wedge
#

things*

drifting wedge
quartz kindle
#

errors go to stderr

drifting wedge
#

o ok

hollow sedge
#

what if we called them lets

#

so i would assign it to a let?

drifting wedge
#

thats fine with me

quartz kindle
#

does python have multiple variable types?

drifting wedge
#

no

hollow sedge
#

no

quartz kindle
#

lmao

#

then whats wrong with calling them vars

hollow sedge
#

ik

drifting wedge
#

tim and cloud, u 2 are fucking wizards

hollow sedge
#

its just weird tho

drifting wedge
#

thank u so much

hollow sedge
#

go away demon

quartz kindle
#

var is pretty much universal

hollow sedge
#

ik but whenever i see it

drifting wedge
hollow sedge
#

i just think of JS

drifting wedge
hollow sedge
#

because im uncultured

quartz kindle
#

xD

drifting wedge
#

what would u want me to call them?

#

Python VariablesTM?

hollow sedge
#

VARS IS FINE I TAKE IT BACK

quartz kindle
#

just call them "iable"

drifting wedge
#

alr

#

i have a iable problem

#

this iable called cloudfox is == "Dumbdumb" but it says its dummerdummer

quartz kindle
#

your iable is undefined

hollow sedge
#

ok im calling the mods and reporting you for cyberbullying

drifting wedge
#

aTmodS

quartz kindle
#

.js

drifting wedge
#

can i pull a specific var from a file?

hollow sedge
#

yes

#

you just have to import the file

#

and then you can use the var

drifting wedge
#

and how would i import it if the file is in a folder "Above" it

hollow sedge
#

so like

import file
print(file.var)
#

you could just use a . before the name of the file

#
import .file
print(file.var)
drifting wedge
#

ty

crystal wigeon
#

hey guys

#

so i found that if you disconnect your bot manually from vc it doesnt join back

#

any fixes?

split hazel
#

well it won't reconnect unless you tell it to

crystal wigeon
#

is there an event?

#

it says its still connected

#

so

high berry
#

My guess is ur using the wrong schema

split hazel
#

what library and what are you using to join the vc in the first place

crystal wigeon
#

vanilla

#

no libs

#

discordjs

split hazel
#

that is a library

crystal wigeon
#

ye just that basic no additional lib like discord-player

split hazel
#

yup the voice connection class has a disconnect event

quartz kindle
#

you will also receive a voiceStateUpdate event

split hazel
#

that also but it would probably be more predictable to do it the docs way

crystal wigeon
#

yeah i saw the docs, but im confused as to where to use it. like can i use this in my music actions file? or should i do it globally?

#

something like

quartz kindle
#

wherever you create your connection

split hazel
crystal wigeon
#

ah

quartz kindle
#

for example ```js
connection.play("bla");
connection.on("disconnect", () => {
// handle disconnection procedures
})

crystal wigeon
#

got i! thanks a lot!

#

overthinking leads to lot of confusion lol

earnest phoenix
#
console.log(Util.parseEmoji(ax[0].trim()).id)
console.log(isUrl(ax[1].trim()))

if (Util.parseEmoji(ax[0].trim()).id != null && isUrl(ax[1].trim()) === true) { 
console.log("hi")
}
#

but it doesn't write hi to the console? What is the reason? I do not understand

crystal wigeon
#

ye didnt work

#

the connection still exists

#

even after i delete the whole queue obj

drifting wedge
#

if i have a list of dicts, how would i like use a key to find the response like to find the other part

#

like joe:mama

#

key = joe

crystal wigeon
#

yeah the event itself is not triggered if i manually dc it

#

discordjs ver 12.4.1

ancient thunder
#

would a change in boosts trigger a guildUpdate event?

drifting wedge
#

i have a json that is 2 dicts, how can i get like the dict from having one argument
like the dicts have for example: name:joe
so if i try to find name:joe
if gives me the entire dict

earnest phoenix
#

I wanna give up on making bots on my iPad..... I can nothing I’m a loser

drifting wedge
#

python

earnest phoenix
#

oof, wouldn't know in py

ancient thunder
#

well shit I was about to write one in js

drifting wedge
earnest phoenix
#

yeah i understand

drifting wedge
#

like basically i did pm2 jlist

#

which returns a json with the proccesses

#

and like they have a lot of things

#

but i have the na,e

ancient thunder
#

ill try to write a function for you brb

earnest phoenix
#

@drifting wedge if I had one

drifting wedge
#

uhhh

#

i mean ipad isnt too bad

#

testing is a pain prob

#

but like if u can run it

#

u should def try and continue

earnest phoenix
#

I can do nothing I can’t code I can nothing

#

I can just use prebuilt apps...

#

To make a bot

drifting wedge
#

not with that attitude!

#

just keep going

earnest phoenix
#

Hm, so how can I program in iPad?

drifting wedge
#

if u have a app to run it

earnest phoenix
#

It’s just a prebuilt one I learn nothing...

drifting wedge
#

watch yt lmao

earnest phoenix
#

I’ve tried lol

#

All Indians pop up, with fakes vids

#

LOL

drifting wedge
#

what lang?

earnest phoenix
#

Idk if it’s an Lang but it’s for me kinda BDFD

drifting wedge
#

uhhhh

#

dont

#

just dont

#

python is super ez

#

use python

earnest phoenix
#

I know that’s what I’m saying...

#

On mobile?! Tf

drifting wedge
#

ye

#

there are prob ids

earnest phoenix
#

WAIT REALLY?

drifting wedge
#

ide's

earnest phoenix
#

DM ME DM ME DME ME!

drifting wedge
#

pyto - python3

drifting wedge
#

one i found

earnest phoenix
#

Python 3?

#

Do I do it in safari?

drifting wedge
#

u can prob also use web ides

#

its an app

earnest phoenix
#

python wtf is an app?

drifting wedge
#

no

#

like its a python IDE

#

uhh how old r u?

#

like most 13+ yr olds have laptops

#

wait

earnest phoenix
#

Found it it has 1 rating ALol

drifting wedge
#

if ur under 13

#

just dont say anything

#

lmao

earnest phoenix
#

Nope I’m not lol

drifting wedge
#

o ok good

#

how old r u?

earnest phoenix
#

Turning 14 in February 21th

drifting wedge
#

u dont have a laptop?

earnest phoenix
#

My dad said I’ll get a computer

drifting wedge
#

or a pc?

#

like literally nothing?

earnest phoenix
#

Well a 20 year old if you want LOL

drifting wedge
#

it works ig

earnest phoenix
#

Ye..

drifting wedge
#

better than an ipad i rekon

earnest phoenix
#

MacBook

#

From 2005 or something LOL

drowsy raven
#

where to host my discord bot?

earnest phoenix
#

rent a cheap vps

drifting wedge
#

jay rizuri is typing

ancient thunder
earnest phoenix
#

@drifting wedge so this is what I see

#

@drifting wedge it says “hello world”

#

What do I do lol?

drifting wedge
#

what

#

send pic

#

uhh what is cs?

#

@ancient thunder

earnest phoenix
ancient thunder
#

oh oops I meant cd

drifting wedge
#

run it!

earnest phoenix
#

So I what do I do?

drifting wedge
#

run it

earnest phoenix
#

What do I write there?

drifting wedge
#

press the play button

#

run the print hello world

earnest phoenix
#

Says theme again

#

Says the*

drifting wedge
#

?

#

ik

#

check console

earnest phoenix
#

I’m in

#

Hello, world!

drifting wedge
#

NICEE!!!!!

#

alr u know any python?

earnest phoenix
#

Uh LOL

#

Hm, Idk

drowsy raven
#

where can I host my bot for free?

drifting wedge
#

ok lemme give u a rundown

drifting wedge
drowsy raven
#

ty

drifting wedge
#

bools, strings, integerns, and floats

#

integers*

#

bools are True or False

earnest phoenix
#

Remember the old days when Heruko had 24/7 free hosting time

drifting wedge
#

strings are text with "" so like "Hello World"

drifting wedge
earnest phoenix
#

Free?

drifting wedge
#

integers are numbers

#

no decimals

drifting wedge
earnest phoenix
#

Damn

drifting wedge
#

floats are numbers with decimals

#

u get it?

earnest phoenix
#

Uh, ye

drifting wedge
#

alr

#

print is to send in console

earnest phoenix
#

So, what would I use print for?

drifting wedge
#

to send it in console

#

send something

earnest phoenix
#

Hm alr.

high berry
earnest phoenix
#

Like copy n paste?

drifting wedge
#

look put this in

earnest phoenix
#

Alr.

drifting wedge
#
coolkid = "Joe" # string

print(coolkid)```
earnest phoenix
#

Why am I starting to use grammar sometimes randomly?

drifting wedge
#

now send console

earnest phoenix
#

Hello, world!

Joe

drifting wedge
#

there we go

earnest phoenix
#

Uh ok LOL

#

Now let’s get to the serious talk @drifting wedge

#

Chad?

drifting wedge
#

?

earnest phoenix
#

Uh can ya help me?

#

@drifting wedge like with the coding

drifting wedge
#

with?

earnest phoenix
#

The coding

#

I’m new LOL

drifting wedge
#

uhh

#

watch a vid?

#

like wat u need help with?

earnest phoenix
#

Coding the bot......

drifting wedge
#

learn python before

#

uhhh

earnest phoenix
#

Uh

#

😐

#

I need some help...

drifting wedge
#

ye?

#

i mean honestly

earnest phoenix
#

With the bot coding

drifting wedge
#

not learning pythn before is like shootning urself in the foot

#

but thats how i started

#

so i cant complain

earnest phoenix
#

Okie um uh how do I learn python LOL

drifting wedge
#

figure out how to download livs

#

libs

earnest phoenix
#

Thanks babe

#

lol jk

#

Ok ok sorry lol ima start thanks

#

@drifting wedge delete it before SOMONE sees it

#

Someone

drifting wedge
#

delete what>

#

also dont emoji spam

earnest phoenix
#

The link

drifting wedge
#

why?

earnest phoenix
#

I don’t think it’s allowed

drifting wedge
#

it is

#

its fine

earnest phoenix
#

Alr, ima just start watching the vid and interrupt you if I need some help

#

His pc tf

#

@drifting wedge his pc man...

#

I can do nothing what his doing since I’m mobile...

drifting wedge
#

uhhhh

#

can u install libs?

earnest phoenix
#

How?

drifting wedge
#

pip install lib

crystal wigeon
#

no fixes ?

earnest phoenix
#

Lemme try

crystal wigeon
#

for the bot manual dc issue

earnest phoenix
#

Nope @drifting wedge is it a website?

drifting wedge
#

no

earnest phoenix
#

An app?

drifting wedge
#

i want to like get the dict using the key

#

so like if "name":"joe"

#

i use that dict

ancient thunder
#

ohhhh

earnest phoenix
#

lol term? @drifting wedge

#

Lib term*

cobalt anchor
#

does anyone know any promo codes for the bot by chance?

drifting wedge
#

liberary

crystal wigeon
#

someone help ;-;

earnest phoenix
#

@drifting wedge ;-; I’m confused

drifting wedge
#

u guys like this?

earnest phoenix
#

Idek what it is

cobalt anchor
#

yea same lmao

earnest phoenix
#

Lol

drifting wedge
#

its a website im making

cobalt anchor
#

SANTA CLAUS?

earnest phoenix
#

it's a bit inconsistent

cobalt anchor
#

can u give me good stuff for christmas

ancient thunder
#
def find_dict(list, key):
    cd = 0
    for d in list:
       cd = cd + 1
       break if d.name == "key"
       return cd
earnest phoenix
#

but other than that it looks good

#

i really love the color scheme

drifting wedge
#

i mean its a bot admin only page

crystal wigeon
#

i cri

drifting wedge
#

so its not that important

earnest phoenix
#

@drifting wedge uh what do I do? It’s all pc

#

stats has more attention than the title

drifting wedge
earnest phoenix
#

way better

crystal wigeon
#

can anyone help?

#

it says the connection is alive if the bot is dc manually

misty sigil
#

LMAO

crystal wigeon
#

and the "disconnect" event is not triggered

earnest phoenix
#

@drifting wedge can ya help?

#

No? Ok.....

drifting wedge
#

I'm busy man

sudden geyser
drifting wedge
#

Can anyone explain libs to this man

sudden geyser
drifting wedge
#

Oh

#

I mean it's for devs only

#

Like bot admins only

#

So not tooooooo important

#

But trying to make it not shit

sudden geyser
#

I don't mind the stats, but I feel name: value just looks boring. Like, it could also look like this:
Title
Text here

On paper, it doesn't look like much, but if you give it a background tint, Title as bold and the text a little bit intended, it could maybe look better. At the same time, it's preference (and may be me being picky) and name: value is not the end of the world.

cerulean ingot
#

how do i add an embed to my sites link

earnest phoenix
#

opengraph meta tags

#

and theme-color meta tag for embed color

obtuse jolt
#

cuck

#

63ms -> 1.7ms

quartz kindle
obtuse jolt
#

i wanna try

#

@quartz kindle give command

#

ok

#

then

quartz kindle
#

xD

#

wait

#

is your query sync?

#

that only works for sync code

obtuse jolt
#

i wouldnt know

#

i dont have your mental capacity sadly

quartz kindle
#

how would you use the result from that query?

obtuse jolt
#

in a function which i didnt add

quartz kindle
#

then its not sync

#

you need to put the timer inside the callback

obtuse jolt
#

ight

#

hold on

quartz kindle
#

does your eval support async?

obtuse jolt
#

most likely not

#

i didnt make it

#

@misty sigil did

quartz kindle
#

show data for proof

obtuse jolt
#

oh godf

#

this would be a lot easier if this eval command wasnt so shotty

cerulean ingot
#

tim ive seen ur bot

quartz kindle
#

cool

obtuse jolt
#

lmfao

#

how big is your users database

quartz kindle
obtuse jolt
#

what hardware does it have?

quartz kindle
#

1gb ram 1 core 15gb ssd

obtuse jolt
#

wtf

#

i feel cheated

#

you sort through 22,665 sets of data in 1.2ms

#

thats

#

wow

quartz kindle
#

its indexed

gilded olive
#

pro Tim

drifting wedge
ancient thunder
#

oh oops

#
def find_dict(list, key):
    cd = 0
    for d in list:
       cd = cd + 1
       break if d["name"] == "key"
       return cd
#

sorry I haven't used python in 2 years lol

crystal wigeon
#

hey guys

#

umm

#

when you dc the bot manually it doenst join back

#

the disconnect even isnt triggered

#

..

drifting wedge
drifting wedge
#

geez

crystal wigeon
#

yeah

drifting wedge
#

wat lib?

crystal wigeon
#

discordjs

drifting wedge
crystal wigeon
#

the "disconnect" event doesnt occur

drifting wedge
#

uhh

#

oh

solemn latch
#

disconnect event?

drifting wedge
#

im py

crystal wigeon
#

connection.on("disconnect")

drifting wedge
#

woo can help

#

i thnk

crystal wigeon
#

yes please

drifting wedge
#

wait it just returns 1

crystal wigeon
#
    const dispatcher = serverQueue.connection
      .play(ytdl(song.url))
      .on("finish", () => {
        if (serverQueue.loop) {
          serverQueue.songs.push(serverQueue.songs[0]);
          // serverQueue.songs.shift();
        }
        serverQueue.songs.shift();
        play(guild, serverQueue.songs[0], message);
      })
      .on("error", (err) => {
        console.log(err);
        logger.error(err.stack);
        return;
      })
      .on("disconnect", () => {
        queue.delete(guild);
        return;
      });```
drifting wedge
#

oh

crystal wigeon
#

here

drifting wedge
#

its the position?

crystal wigeon
#

the "disconnect" event doesnt ocur

#

when you dc manually

drifting wedge
#

if i have a dict pos, can i get whats in that position?

quartz kindle
#

.play() returns a dispatcher, so you cannot chain it

#

you are essentially doing dispatcher.on("disconnect")

#

instead of connection

crystal wigeon
#

ah

#

actually

#

its connection.play().on()

quartz kindle
#

exactly

crystal wigeon
#

ahhh

#

i should be doing connection.on("dc")

quartz kindle
#

ye

drifting wedge
#

tim

#

how are you still not working at google

#

ur like the fucking programmer god

quartz kindle
#
  1. i dont want to work at google
  2. you'd be surprised with just how good people who work at google are
drifting wedge
#

you're like the person the google employees go for help

quartz kindle
#

lmao

gilded olive
#

doc reading skills +100

quartz kindle
#

there are plenty of people much better than me, im not anything special, im just good at reading docs

ancient thunder
drifting wedge
#

and this returns "name":"joe:

#

for example?

quartz kindle
#

arent dictionaries non-sorted structures?

#

like js objects

ancient thunder
#

yes

drifting wedge
#

so u cant index the,

#

them

quartz kindle
#

then there should be no indexes

#

only keys

drifting wedge
#

like i have a json dict

ancient thunder
#

dict.values() puts the values into a list

drifting wedge
#

likt its 2 dicts

#

with []

ancient thunder
quartz kindle
#

yes, but the order is not guaranteed

#

every time you use .values() there is no guarantee that index X will be the same item again

drifting wedge
#

you can make a list

#

and then find them in the list

ancient thunder
drifting wedge
#

i have acheived orbit in KSP!

#

with my 4 stage spagetti rocket

#

it blew up 😦

#

@ancient thunder

#

wait tho

#

the "dict"

#

is like list1 = [{dict stuff},{otherdict}]

#

uhh also

#

the list is originaly has like false instead of False

#

so what can i do?

#

@quartz kindle if u r available

hollow sedge
#

what are you trying to do

ancient thunder
#

alright I somehow just added a python eval command to my js bot so I can test it

hollow sedge
#

what

#

how

earnest phoenix
#

lmao

ancient thunder
#

¯_(ツ)_/¯

#

it took a bit

earnest phoenix
#

Theres a ton of web apis for that type of stuff

#

also u could probably just use the python cmd to do it

hollow sedge
ancient thunder
#

i don't know

earnest phoenix
#

lmao

ancient thunder
#

I just felt like it

hollow sedge
#

ok have fun

quartz kindle
drifting wedge
#

ye

#

thats what i said above

#

one of my devs is helping me tho

sick sluice
#

is there anyway to use emoji inside code block?

#
😩 
#

woah it's possible

#

📻

#
📻 
#

it's different

sharp thicket
#

Hello,anyone know how to jcheck if a user is using a font anywhere in their username?

#

if you reply @ me if you may

earnest phoenix
#

you uh

#

might have a misconception

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

earnest phoenix
#

everything is the same font

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

clever vector
#

how to make streaming status?

trim saddle
#

@clever vector read library docs

outer zenith
#

@drifting wedge why are u trying to order a dict again

#

cause i had to do taht

drifting wedge
#

nah

slender thistle
#

Dicts aren't sorted

outer zenith
#

yes

#

but they can be sorted

hollow sedge
#

There is a collections.OrderedDict

slender thistle
#

Aye

earnest phoenix
#

@warm nova

#

@proper remnant

gilded olive
#

damn js got some nice logging

#

pog

hollow sedge
#

True

gilded olive
#

was messing around with svelte

#

cool framework I won't lie

lyric mountain
#

Every lang has good logging

...except C/C++, they can go to hell

gilded olive
#

python has 0 logging unless you either use the logging module or print statements

lyric mountain
#

C logger be like:

"You have an error in address 0x01728511"

drifting wedge
#

Print is great man

gilded olive
#

indeed

drifting wedge
#

Python imo is legit the best

#

Like it's easy to understand

#

Easy to learn

#

Similar to English

#

Makes sense

lyric mountain
#

Nah, java logger is hard to outmatch

drifting wedge
#

You can get really far

gilded olive
#

I love python but in some areas it's really just not suitable

drifting wedge
#

Ie?

lyric mountain
#

Like threading

drifting wedge
#

Front end web

gilded olive
#

Games

drifting wedge
#

^ main issue

#

Pygame

gilded olive
#

yes front end web

drifting wedge
#

C# is unity

gilded olive
#

making me learn js

#

for web dev

#

smh

drifting wedge
#

I'm doing py for everything I can

#

Like to show elements

#

Etc

gilded olive
#

you can use it as a backend

#

Flask or Django

#

Flask preferably >

slender thistle
#

Sanic

gilded olive
slender thistle
#

Goin' Fast @ 127.0.0.1

gilded olive
lyric mountain
#

Who else installed Ubuntu bash in windows?

drifting wedge
#

I Like flask

#

If anyone wants content

#

Highest budget video

gilded olive
drifting shell
gilded olive
#

i was gonna switch

#

then i learnt how many apps i would have to give up to switch

#

and just said no

lyric mountain
#

Yeah, that's the main issue

#

Linux bash is goddamn satisfying to use

#

Bash script is easy af to automate most stuff

#

Windows scripts are...well...anything but script

#

Its syntax is gross, coarse and way worse than assembly

gilded olive
#

yea....

lyric mountain
#

Like, what kind of lang doesn't allow c = a + b?

gilded olive
lyric mountain
#

In batch you gotta make a hella long command to add one variable to other

gilded olive
#
set FLASK_APP=file.py
will work
------------------------
set FLASK_APP= file.py
------------------------
error```
opal plank
#

welcome to py

#

where spaces and indentation matter

#

spits

lyric mountain
#

Not py, batch

opal plank
#

both

slender thistle
#

Python at least looks decent

opal plank
#

doubt intensifies

#

im not saying py isnt good

#

im saying py indentation is absolutely insane inducing and uncessary to be forced

slender thistle
#

Well

lyric mountain
#
@set a=3 
@set b=4 
@set /a "c=%a%+%b%" 
echo %c%
#

Like, man, look at this shit

slender thistle
#

I can read my nested loops so I'm good KEKW

lyric mountain
#

This is a simple sum in batch

opal plank
#

go for ts shiv

#

ts is the glory hole

lyric mountain
#

A sum of two variables

slender thistle
#

When my laptop doesn't die every 5 minutes

gilded olive
opal plank
slender thistle
#

What's that

gilded olive
#

lemme find it

opal plank
#

the dark side?

slender thistle
#

I can just import this

opal plank
#
import import from 'import'
slender thistle
#

I'll move there myself one day

gilded olive
#
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!``` @slender thistle
drifting shell
uneven monolith
#

im just gonna slip myself in here

drifting shell
#

uwu

uneven monolith
#

Im trying to make a sort of command that runs when someone says something specific, i got the running part but i cant figure out how to ban the message author. Any ideas, ive tried the traditional ban command but with message.author instead of message.mentions.first() and it did not seem to work. This is my code rn, its probably not right as it is just the code ive been trial and erroring on for the past hr.

const args = message.content.substring(config.prefix.length).split(" ");
let ar = args.slice(0).join(" ");
let ar2 = args[0] + ar;
var msg1 = ar2.toLowerCase();
const us = `<@${message.author.id}>`
const user = message.author;
const mem = message.guild.member(us)
if(msg1.includes('pineapples')){
    await user.send('Banned from LCSN.')
    await mem.ban({reason: `Saying: ${message}`})
}
```Discord.js
slender thistle
#

Flat is better [...]
Mhm

gilded olive
#

look at that mess

uneven monolith
#

this is some weird development

gilded olive
#

my god

uneven monolith
#

its my trial and error

#

yall python devs?

gilded olive
#

yea, well me

uneven monolith
#

my language is real amazing

gilded olive
#

i thought language beef is prohibited

uneven monolith
#

i was talking about how amazing js is

gilded olive
#

you are not slick

#

editing

uneven monolith
#

and im gone

gilded olive
#

👎

opal plank
# gilded olive ``` Beautiful is better than ugly. Explicit is better than implicit. Simple is b...

implicity saves code and memory
simple doesnt do enough of the job, sometimes you need complex solutions for complex/simple problems
nested is better than flat
sparse is also worse than dense depending on the case, redability is sparse, efficiency is dense
readability only counts when someone needs to look at the code, as long as it does the job, its fine
special cases are enough to break some rules
errors can be logged silently, as long as you're aware of them and their purpose, specially when interacting with other peoples code

too lazy to refute the rest

gilded olive
#

....

opal plank
gilded olive
#

hold up lemme make that guys command in py

#
@bot.event
async def on_message(message):
  if message.author.bot:
    return None
  bad = ["pineapples"]
  if bad in message.content:
    await message.author.send("Banned from server")
    await message.author.ban(reason="Saying pineapples")
  else:
    return None```
#

done

#

oh .includes, assuming thats anywhere in the message

#

much better

young flame
#
let role2 = message.guild.roles.cache.find(role => role.name === `Ticket User`);
    if(!role2) message.guild.roles.create({ data: { name: 'Ticket User', color: ('RANDOM')} });
    let member = message.author;
    member.roles.add(role2);
gilded olive
young flame
#

it says cannot read property add of undefined

#

not sure whY

gilded olive
#

role id invalid?

#

that's what stack overflow is telling me

slender thistle
#

Isn't it supposed to be message.member

young flame
#

idk

#

probs

near stratus
young flame
#

me eval it

#

and it worked fine

#

like the whole command

slender thistle
#

message.member returned a Member version of the message author

young flame
#

i fixed it loLz

#

backto cooking smh

gilded olive
#

x

slender thistle
#

Exactly where you belong

young flame
#

wow

gilded olive
#

oh my

slender thistle
void vale
#

hi

young flame
#

okay with a bottle of sachi and mild depression

void vale
#

Who knows BASIC?

slender thistle
young flame
#

o

#

i dont have my phoone rip

#

igottafind it

#

i gotta find*

slender thistle
#

Use DMs or I'll send nukes upon you

young flame
#

nO

#

lemme eat first

earnest phoenix
#

Anyone know how to fix

bot.on('message', function(message){
    if (message.mention.user.first() === bot.user) (
        message.channel.send('Hello, do -help for more info.')
    )
})
#

Get a error when I mention the bot

slender thistle
#

What's the error?

earnest phoenix
#
/home/container/index.js:14
if (message.mention.user.first() === bot.user) (
TypeError: Cannot read property 'user' of undefined
at Client.<anonymous> (/home/container/index.js:14:25)
at Client.emit (events.js:326:22)
at MessageCreateHandler.handle (/home/container/node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js:9:34)
at WebSocketPacketManager.handle (/home/container/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:108:65)
at WebSocketConnection.onPacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:336:35)
at WebSocketConnection.onMessage (/home/container/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:299:17)
at WebSocket.onMessage (/home/container/node_modules/ws/lib/event-target.js:120:16)
at WebSocket.emit (events.js:314:20)
at Receiver.receiverOnMessage (/home/container/node_modules/ws/lib/websocket.js:789:20)
at Receiver.emit (events.js:314:20)
earnest phoenix
#

Isn't it mentions and users? I don't use d.js though

slender thistle
#

message.mentions.users

#

Plural

#

Because there can be multiple mentions, therefore multiple users

earnest phoenix
#

So what should I do?

earnest phoenix
#

No I am new to coding

#

@earnest phoenix

#

What you should do is not to use non-existing attributes I suppose.

#

I don't really know how js works though, I just assume if the attribute doesn't exist or have no value it'll return undefined

slender thistle
#

Is common sense not taught nowadays

slender thistle
#

And guess what you should replace in your snippet

earnest phoenix
#

the wgole thing

slender thistle
#

Not the whole thing

#

You definitely need your message event and the function you attach

#

You just need to look at your condition

#

And refer to my messages

earnest phoenix
#

How Do i make this a embed?

#
bot.on('message', function(message){
    if (message.mentions.users.first() === bot.user) (
        message.channel.send('Hello, do -help for more info.')
    )
})
lusty quest
#

the guide also contains other stuff that is helpfull

copper cradle
#

is how to use google not taught nowadays?

earnest phoenix
#

whats problem here ? div.footer{ position: fixed; left: 0; bottom: 0; width: 100%; background-color: #1b1b1b; color: white; text-align: center; z-index: -1; } <div clas="footer"> <p>Author: Hege Refsnes</p> </div>
Problem at https://tesladev.glitch.me/commands

#

pls ping me if you can help me

#

open website in desktop mode to see whats wrong

restive furnace
#

@earnest phoenix clas

earnest phoenix
#

someone already helped me.. anyways ty

pale vessel
#

Just use js const { key } = await fetch("https://hastebin.com/documents", { method: "POST", body: code }).then(x => x.json());and put the rest of your code outside

#

So you want to check for errors?```js
const res = await fetch("https://hastebin.com/documents", {
method: "POST",
body: code
});

if (!res.ok) return; // error embed

const { key } = await res.json();

// send URL```

#

You're making it complicated

#

Yeah

#

also, you don't need an else

#

If the code continues then it means that the response was OK

#

Never mind, I'm stupid

#

you need it for syntax highlighting ig

#

👌

hasty mulch
#

None

#

You can host the bot yourself up to 2.5K

#

That’s what I have been told by almost everyone

#

Well, if you want to get ahead of the curve, it really all depends on how fast your bot is growing

slender thistle
#

1000 is a generally recommended value

stark abyss
#

how to fix/ get help?

#

I want it to remove only based on the msg I sent

#

wdym

#

it's an object, time is what time I have to dm the user their msg. Id is just their user id

#

yes

#

once i have sent them their msg I wanna remove that object from the array if that make sense thinkingLol

#

first I would have to use a setInterval

#

second that's not what I asked ;-;

near stratus
stark abyss
#

Yes

crystal wigeon
#

hey guys, so umm.. whem my bot is playing some music and then i send an embed with some chunk of data its lagging the music player

#

all the computatiosn are fast enough

#

but when multiple threads are running why does it interrupt ?

stark abyss
#
    for (var i=0; i < myArray.length; i++) {
      if (myArray[i].time <= Date.now()) {
       let user = await client.users.fetch(myArray[i].id)
        user.send(myArray[i].msg)
        myArray.splice(myArray.findIndex(arr => arr.msg == myArray[i].msg));
      }

now sending the user msg works, but I want to get rid of that object in the array

crystal wigeon
#

when multiple users are using my bot its lagging

#

but the computations on my server are fast

stark abyss
#

for attempt solution I don't have much to say

stark abyss
crystal wigeon
#

2cpu 8GB RAM, service is utilizing 5GB RAM on max

#

its actually a cloud service (gcp)

#

so i'd say its pretty fast?

#

it only happens while sending embeds

#

discordjs

#

vanilla music player no other music player libs like discord-player

#

ytdl

#

ye

#

yeah

#

to get the music

#

YTSearcher

#

ytdl-core

#

im filtering it to only audio

#

i see

#

but music apart if 5 6 people are using my bot the embed lags as well

#

what do you recommend?

#

haha never done that

near stratus
#

That's torture

crystal wigeon
#

ye could be an edge case scenario im not validating

earnest phoenix
lusty quest
#

expect this stuff. got someone DDosing my bot with an command that accesses an external API

#

he constructed a request that caused the API to return a few million results

crystal wigeon
#

i see

#

got it

lusty quest
#

the bot ended up with over 10 minutes of delay

crystal wigeon
#

so when there are many people using the bot at once

#

it lags

#

the embeds

lusty quest
#

yea bcs its busy downloading videos

crystal wigeon
near stratus
lusty quest
#

do what Alex recomended

crystal wigeon
#

got it, i'll take a look at lavalinkjs

#

got it got it

lusty quest
#

iirc lavalink also requires that you run a lavalink instance

crystal wigeon
#

it says optional

lusty quest
#

the js package is only a client iirc. you need something to handle the requests. and i dont think you will find many open instances you could use

crystal wigeon
#

can you elaborate?

#

could i run this instance on my gcp server itself tho?

#

i tried discord-player but it was dead

#

they deleted ytdl repo which was failing to npm install

#

im open to learning new stuff 😄

lusty quest
#

lavalink is a piece of software that is written in java that will handle the streaming of the yt stuff.
the NPM package Alex send in is a client to access the lavalink server you usually have to host yourself

crystal wigeon
#

so i basically need to host a lavalink server on my gcp?

lusty quest
#

its usually nothing hard to do on a proper VPS

crystal wigeon
#

i'll check out some tutorials

#

what about the embeds lagging when multiple users are using the bot

#

like thats a scalability issue but i have a good VM

lusty quest
#

the embeds lag bcs the bot is busy downloading stuff

honest perch
crystal wigeon
#

yep but those computations are logging very fast on the server

#

like i can see the data being loaded fast

lusty quest
#

did you run something async?

young flame
#
let chan = message.guild.channels.cache.find(channel => channel.name === `ticket-${message.author.username}`);
             chan.delete();
#

why does it keep coming back as undefined

crystal wigeon
#

while sending the embed?

lusty quest
#

in the command / event that sends the embed

young flame
#

unless i gotta like ```js
ticket- + message.author.username

crystal wigeon
#

yes

#

it uses async

lusty quest
#

async causes the bot to wait with the next step until the asnyc step is done

#

this can cause that some stuff is "laggy"

crystal wigeon
#

yep thats where the data is pulled from my db for the computations

#

but thats happening instantly

#

the sending in the embed is where it lags

lusty quest
#

did you render stuff for the embeds?

crystal wigeon
#

yes canvas

#

maybe i could try reducing the image dpi

lusty quest
#

this is what causes the "lags"

stark abyss
#
[{ time: x, msg: text, id: x },
  {
    time: '1607764119284',
    msg: "some other bunch of text okay",
    id: '298588307368050698'
  }]
    for (var i=0; i < myArray.length; i++) {
      if (myArray[i].time <= Date.now()) {
       let user = await client.users.fetch(myArray[i].id)
        user.send(myArray[i].msg)
        myArray.splice(myArray.findIndex(arr => arr.msg == myArray[i].msg));
      }
    }

This is removing the whole array, like absolutely deleting every object in the array. How can I get it so it only removes the object that has the message that I just send.

crystal wigeon
#

i seee

#

yes

#

even the canvas is async

lusty quest
#

running everything async can harm performance

#

since it awaits it

stark abyss
#

that looks like an array to me 🤔

lusty quest
#

thats an object.

stark abyss
#

inside an array 🤔

#

ok thx WeirdChamp

#

yeah it wouldn't work though I gotta findIndex that is same as the msg i send

lusty quest
#

use a map?

#

set the messageid as key

stark abyss
#

yeah I used a map ;-;

#

thats literally where I am asking for help

lusty quest
#

first you use an array, then a map?

stark abyss
#

but message id seems a good idea

lusty quest
#

?

#

timer are not persistent between restarts

stark abyss
#

^^

lusty quest
#

use Redis

stark abyss
#

what does that mean

lusty quest
#

you can set a TTL and it got a event that fires if a entry expires

stark abyss
#

TTL?

lusty quest
#

time to life

stark abyss
#

oh

lusty quest
#

you can get a free redis server too

stark abyss
#

wait what is this a database

#

lmao i don't know anything

lusty quest
#

its a database yes.

#

but it works different than normal DBs

stark abyss
#

i see, but I rather not move to it for one command

#

myArray.splice(myArray.findIndex(arr => arr.msg == myArray[i].msg)); can you spot some issue in this line?

lusty quest
#

you dont need to

#

its not a full blown database like MongoDB or Mysql. its more for persistent temporary stuff

stark abyss
#

i see

young flame
#

@lusty quest how do you delete a channel

#

what is message.content

#

uh

#

what version are you using

#

version

#

not lib

#

discord.js smh

#

discord.js v11 ect

#

v11 is the version

#

alr 1

#

message.createdAt should just be .setTimestamp()

fair scaffold
#

i have a bot system .._..

earnest phoenix
young flame
#

is it just message = ect

#

ifits discord.js like you said it should be

hasty mulch
young flame
#
message.channel
    .fetchMessages({
      limit: 100 \\fetches 100 messages
    })```
#

ect

#

and find a way to add message to it

#

message =looks like you defining message as that so you can have it filter messages ig

#

your code looks like a mix between djsv12 and v11

#

which is whyi asked

#

first

#

i dont think you coded it right

#

if quote is fetching messages why is everything else have quote on it

#

second msg should be message if its djs v12 and higher

#

you have inconsistencies in your code

#

which is why i said your going between djs v12 and v11

#

you dont need the .send({embed}); just .send(embed) ect

#

quote.createdAt shouldn't be there

#

actually most of the stuff with quote shouldn't be there

earnest phoenix
#

you asked the same thing yesterday, tinte

young flame
#

since quote is fetching messages

#

hi cry

earnest phoenix
#

helllouu

young flame
#

hruuu

earnest phoenix
#

tired, i have a meeting but im so exhausted

young flame
#

oof

#

i feel you

#

brb

earnest phoenix
#

@earnest phoenix y u still whitename u got no botum in q?

#

i dont do public bot deving anymore :p

#

pointless

#

@earnest phoenix I made h bot which is completely pointless so i can be greenname and flex on my friends

#

@earnest phoenix excuse me this.client.embed???

young flame
#

the coding is stupid af

stark abyss
#
[{ time: x, msg: text, id: x },
  {
    time: '1607764119284',
    msg: "some other bunch of text okay",
    id: '298588307368050698'
  }]
    for (var i=0; i < myArray.length; i++) {
      if (myArray[i].time <= Date.now()) {
       let user = await client.users.fetch(myArray[i].id)
        user.send(myArray[i].msg)
        myArray.splice(myArray.findIndex(arr => arr.msg == myArray[i].msg));
      }
    }

This is removing the whole array, like absolutely deleting every object in the array. How can I get it so it only removes the object that has the message that I just send or the one that triggered the if statement

earnest phoenix
#

If you want hosting I can I hosted my first customer bot

misty sigil
feral aspen
#

I have a question as I am new to MongoDB. If I want to create a new way into storing data, do I just make a whole other type of model with a different name?
Example I have a model called economy, for economy commands, do I make a whole other model for like social commands (example)?

quartz kindle
#

unless you set the time variable to future dates

stark abyss
#

it's a reminder command yeah

#

so any guesses on what's wrong?

feral aspen
# feral aspen I have a question as I am new to MongoDB. If I want to create a new way into sto...

Example.
This is my economy model schema.

// It is currently called data.js
const mongoose = require("mongoose");

const dataSchema = mongoose.Schema({
    name: String,
    userID: String,
    lb: String,
    money: Number,
    bank: Number,
    daily: Number,
    weekly: Number,
    beg: Number,
    work: Number,
})

module.exports = mongoose.model("Data", dataSchema);

If I want to do same for another category called social. Should it be like this?

// This will be called social.js
const mongoose = require("mongoose");

const socialSchema = mongoose.Schema({
    name: String,
    userID: String,
    bio: String,
})

module.exports = mongoose.model("Social", socialSchema);

Please do let me know if you have an answer, this is regarding MongoDB as well! 😉

stark abyss
#

I have been stuck on removing an object from array for hours how pathetic is that

quartz kindle
#

@stark abyss .splice(index, 1)

#

you forgot the second parameter

#

the number of items to remove

stark abyss
#

5:21 am CBPepecri

#

thx tim

gentle lynx
#

what should i replace password with?

misty sigil
#

a string that you put in the auth section

quartz kindle
#

whatever you put in your authorization in your top.gg edit page

gentle lynx
#

oh wait i thought its discord webhooks...

#

alright then

#

what should i put in the URL?

#

i'm confused, sorry

quartz kindle
#

where is your bot hosted?

snow urchin
quartz kindle
#

EAI_AGAIN is a DNS lookup timed out error, means it is a network connectivity error or proxy related error.

lusty quest
eternal osprey
#
 const filter = m => m.content.includes('+');
    const collector = message.channel.createMessageCollector(filter, { time: 15000 });```this message.channel is undefined. But i cannot really define channel as it is handled through dm?
lusty quest
#

does it error out with channel undefined?

eternal osprey
#

it errors cannot read createMessageCollector of undefined

young flame
#

but it said

#

delete of undefined

lusty quest
#

validate that the channel exist