#development

1 messages · Page 1609 of 1

near stratus
#

Check again

pale vessel
#

that's an API response

#

there' no way of telling

wicked crown
#
DICT_TYPE_CONVERT: Only dictionaries may be used in a DictType```
boreal iron
#

oh nvm there is... should've scrolled through all lines

#

lmao

near stratus
wicked crown
#

doesnt show the line

near stratus
boreal iron
#

alright ty anyway

quartz kindle
wicked crown
#

k

quartz kindle
#

because it bypasses a getter

boreal iron
#

hmm ok

quartz kindle
#

but thats pretty much useless microoptimization

wicked crown
#

so @near stratus whats the problem now

boreal iron
near stratus
near stratus
#
const { MessageEmbed } = require(`discord.js`)
const Discord = require("discord.js")

module.exports = {
    name: "ban",
    category: "moderation",
    description: "Bans a user",
    usage: ";ban [@user] [reason]",

    run: async (bot, message, args) => {

        if (!message.member.hasPermission("BAN_MEMBERS"))
        return message.channel.send(`:x: **|** You can´t use this command`)
    
        const user = message.mentions.users.first()
        if (!user)
        return message.channel.send("Please mention a user")
    
        const reason = (args [1])
        if(!reason)
        return message.channel.send("Please specify a reason") 
    
        const targetMember = message.guild.members.cache.get(user.id)
    
        
        const embed = new MessageEmbed()
        .setTitle(`Ban`)
        .setColor("RANDOM")
        .addField(`Banned User` , user)
        .addField(`Reason` , reason)
        .addField(`Banned By` , message.author)
        .setTimestamp()
       message.channel.send(embed).catch( (err) => {
            console.log("embed error");
        })
    
        targetMember.ban({
        reason: `${reason}`
    }).catch( (err) => {
        console.log("ban error");
    })

    }
}
opal plank
# quartz kindle technically, message.channel.guild.id would be "faster"

technically this would be faster

function getGuildIdByMessageObjectRecievedByTheApi(message) {
  let _message = message;
  if(!_message) return;
  if(!_message.hasOwnProperty('channel')) return;
  let channel = message.channel;
  if(!channel ) return;
  if(!channel.hasOwnProperty('guild')) return;
  let guild= channel.guild;
  if(!guild) return;
  if(!guild.hasOwnProperty('id')) return;
  let id = guild.id;
  if(!id) return;
  if(isNaN(id)) return;
  return id
}
near stratus
#

@wicked crown try this and tell me what the console says

opal plank
quartz kindle
#

you forgot something

opal plank
#

a semicolon?

#

to improve performance?

quartz kindle
#

if(isThirteen(message)) return

wicked crown
#

@near stratus now it worked tf

opal plank
#

ah, right

sage bobcat
#

One message removed from a suspended account.

near stratus
wicked crown
#

lol

opal plank
# quartz kindle `if(isThirteen(message)) return`
function Get_Guild_Id_By_Message_Object_Recieved_By_The_Api(message) {
  let _message = message;
  if(isUndefined(_message )) return;
  if(!_message) return;
  if(!_message.hasOwnProperty('channel')) return;
  let channel = message.channel;
  if(isUndefined(channel )) return;
  if(!channel ) return;
  if(!channel.hasOwnProperty('guild')) return;
  let guild= channel.guild;
  if(isUndefined(guild)) return;
  if(!guild) return;
  if(!guild.hasOwnProperty('id')) return;
  let id = guild.id;
  if(isUndefined(id)) return;
  if(!id) return;
  if(isNaN(id)) return;
  if(isThirteen(id)) return;
  if(isTen(id)) return;
  if(isUndefined(id)) return;
  return id;
}
wicked crown
#

thanks for your help @near stratus 🙂

small tangle
#

monkaS what am i looking at

near stratus
#

😳

pale vessel
#

Some good code

opal plank
#

the fastest way to get a guild id from the message

small tangle
#

and i made it wrong the whole time 🤦

#

brb improving code

near stratus
quartz kindle
#

xDDDDD

opal plank
#

lul

#

look, nobody said we were great at code, it just says notable member , it never states if its notable for good or bad code

small tangle
#

true that

misty sigil
opal plank
#

possibly lul

quartz kindle
#

notably bad member

#

:^)

opal plank
#

its notable member not notably good member

small tangle
#

but after this message it should be changed to Creator of Codeabomination

near stratus
opal plank
#

i should've used snake_case for that function name

#

actually, let me fix it

near stratus
small tangle
#

write it without blankspaces and linebreaks

opal plank
#

there we go

misty sigil
#
if (!!!!!message.guild) {
return
} else if (1 < 0) {
  // run this if the world is falling apart
} else if (2 < 1) {
  // run this if the world is falling apart
} else if (3 < 2) {
  // run this if the world is falling apart
} else {
// I dunno
}```
opal plank
#

we must make sure to add semicolons to decrease compile time

misty sigil
opal plank
#

indeed

#

i cna assure you getting your bucks worth with this code, super over the top

umbral zealot
#

you're not since ASI inserts them so it takes more time 😉

opal plank
#

code goes brrr

#

probably this level of code is needed for you to get yeeted off by your host's owner

small tangle
#

The only positive thing about the code is that it has a low level of nesting LULW

#

or probably the formatting

limpid heath
#

how to make a webhook server?

solemn latch
#

Just make an http server

limpid heath
#

?

misty sigil
#

Bro

opal plank
# small tangle or probably the formatting

i hear you like formatting

function Get_Guild_Id_By_Message_Object_Recieved_By_The_Api(message) {
  let _message = message;
  if(isUndefined(_message ))                 return;
  if(!_message)                              return;
  if(!_message.hasOwnProperty('channel'))    return;
  let channel = message.channel;
  if(isUndefined(channel ))                  return;
  if(!channel )                              return;
  if(!channel.hasOwnProperty('guild'))       return;
  let guild= channel.guild;
  if(isUndefined(guild))                     return;
  if(!guild)                                 return;
  if(!guild.hasOwnProperty('id'))            return;
  let id = guild.id;
  if(isUndefined(id))                        return;
  if(!id)                                    return;
  if(isNaN(id))                              return;
  if(isThirteen(id))                         return;
  if(isTen(id))                              return;
  if(isUndefined(id))                        return;
                                             return id;
}
limpid heath
#

i dont know lots about servers

solemn latch
#

Webhooks are just http requests designed for computers

misty sigil
#

or humans

limpid heath
#

how to make a https request

small tangle
misty sigil
#

oh my

#

You do not make a http request

#

The http requests are sent to you

solemn latch
#

There are cases which webhooks are used directly by users? EYES

opal plank
#

i may do that sometimes for top.gg votes

modest maple
#

and technically you also make a response

misty sigil
#

uh totally don’t have a slave in my basement waiting for a http request to enter it into my database

earnest phoenix
#

Hello, I'm trying to create message statistics for servers. My idea is that the bot collects message count in servers and then every 5 minutes it updates all the statistic documents. But I'm not sure if i can give every document with a specific guild ID a specific key. Different server may have different amounts of messages. I'm trying to do this with a updateMany because i don't want to update each document manually, it will be a db torture. Using mongo.

solemn latch
#

One request per guild per 5 minutes isn't that much

earnest phoenix
#

Yes but the bot will collect those message amounts into cache. Also its not one guild. There are several and when the bot gets bigger it isn't fine at all. Because it will collect lots of messages from many guilds.

#

Updating docs one by one seems like a bad idea.

near stratus
solemn latch
#

Caching each count doesn't change if you write them per guild or not.
Many bots write per user per minute, its really not bad at all to do it per guild imo.

#

Especially since most guilds bots are in are not active 24/7 the vast majority of guilds won't need to be written at all

earnest phoenix
#

Ok so for example the bot caches messages from 80 guilds. Updating each document manually is fine in your opinion ?

solemn latch
#

From what I understand a properly setup mongodb server just updating the int it should be able to handle 10's of thousands of requests

earnest phoenix
#

?

solemn latch
#

For comparison top.gg afaik every time someone voted it just was written to the db

#

Which handled millions and millions of votes a month

earnest phoenix
#

?

#

can yu help?

solemn latch
#

Not if you keep ? When I'm answering other peoples question

earnest phoenix
#

Didn't they switch database recently?

solemn latch
#

Yeah after millions and millions of request became too much

#

Which isn't a concern for you I would expect

#

Since again, most guilds won't need to be written to

solemn latch
earnest phoenix
#

issue with installing

#

pls help

solemn latch
#

Sqlite has a troubleshooting page on their docs/npmjs page

earnest phoenix
#

Also i have another question. I would like to execute some code at 00:00. The bot may restart so i cannot just make it an interval. Also if somehow it started up after 00:00 i still wanna execute that code. Whats a gonna NPM module/way i could do that. Without worrying of the node app restarting.

solemn latch
#

A scheduler would work aswell.

lyric mountain
#

cron is kinda a scheduler

earnest phoenix
#

Thanks, ill try it.

solemn latch
#

You said your having issues with installing?

umbral zealot
#

We need the install error log, not the bot code

crimson vapor
#

you forgot the is-is-odd

drifting wedge
#

anyone can review py code?

icy skiff
#

What do u mean exactly by review

drifting wedge
drifting wedge
crimson vapor
#

I mean it works

#

should be more like

icy skiff
#

I mean i guess i could take a look at it

drifting wedge
#

^

crimson vapor
#

even(num: int):
return (!odd(num))

icy skiff
#

K ill give It a look and dm you my thoughts

drifting wedge
#

for my package

crimson vapor
#

say someone redefines an odd number

drifting wedge
#

you can do

crimson vapor
#

you should just have 1 function

drifting wedge
#

if odd(56):

crimson vapor
#

and return inversions of that

drifting wedge
#

true

#

true

#

like evenodd(num, "odd"/"even")

lyric mountain
#

what about multiply(2, 4)

drifting wedge
#

ill add it to my package if u want

crimson vapor
#

no I mean like

drifting wedge
#

or you can lol

#

just pr

crimson vapor
#

idk py

cinder patio
#

Wait are you serious

drifting wedge
#

idk how to add stuff to pip / pypi

crimson vapor
#
def even(num: int):
  return (!odd(num))

def odd(num: int):
  return (num % 5 != 0)
#

idk if the syntax is right

icy skiff
#

U mean

icy skiff
#

Num %2

drifting wedge
#

makes sense

crimson vapor
#

fuck shit

#

its 2

icy skiff
#

Instead of 5

crimson vapor
#

not 5

icy skiff
#

?

crimson vapor
#

yes yes

icy skiff
#

Kek

drifting wedge
#

whatever

#

makes sense

crimson vapor
#

LOL

drifting wedge
#

but they could be separate

crimson vapor
#

so they redefine odd numbers

#

ezpz

drifting wedge
#

ye ye

crimson vapor
#

say*

drifting wedge
#

make sense

#

but i dont think its worth it lol

#

its easier to code

crimson vapor
#

LOL

#

true

drifting wedge
#

like u can just do if num % 2 == 0

#

!=

drifting wedge
icy skiff
#

ye i dont see the need for a function the check if its odd or nah

dusky sundial
#

In Python you gotta use not rather than !

drifting wedge
#

i think i made an insalenly good prime number finder

icy skiff
drifting wedge
#

...

lyric mountain
#

on js you can actually do if (num % 2) return "odd";

crimson vapor
#

yes because js good

drifting wedge
#

js doesnt have range()

mellow kelp
#

[...Array(<length>)].map((e, index) => index)

drifting wedge
copper cradle
icy skiff
drifting wedge
drifting wedge
mellow kelp
#

oh yeah prime number calculators

drifting wedge
#

and i think its bettee than those

#

since i just skip 80% of numbers

icy skiff
#

if u made ur own then i guarantee u theres a better algorithm out there

drifting wedge
#

no

#

there isnt

#

i am best

icy skiff
#

true

mellow kelp
#

i made a really shitty prime number calculator back in like 6th grade

drifting wedge
#

just look into it

#

i made mine really well

opal plank
#

it would return only half of the ids

drifting wedge
#

omg

#

is odd (id)

#

lol

#

u can only allow even id users to use your bot

#

oMG

#

imma do that

lyric mountain
drifting wedge
#

or ids have to end with 5

#

or whatever

#

LOLLLLL

lyric mountain
#

"do you prefer 5 or 10?"
js: true

drifting wedge
icy skiff
#

k so

mellow kelp
#

you could add memoization

#

to cache the prime numbers

crimson vapor
drifting wedge
#

million review code pls

icy skiff
#

what u did was basically skip even numbers, multiples of 5 and 10

#

thats not like

#

amazing

crimson vapor
#

im in class gimme a min

drifting wedge
#

youre not amazing

icy skiff
#

:/

mellow kelp
icy skiff
#

give it a read to eratosthenes' sieve and fermat primality test

drifting wedge
#

wdym?

#

shut

crimson vapor
#

this is kinda dumb ngl

drifting wedge
#

mine is better

mellow kelp
#

bruh

drifting wedge
#

cuz i made it

#

also

crimson vapor
#

grab the last number

#

and then

drifting wedge
#

i cut the nums / 2

crimson vapor
#

check if its prime

#

if it is

#

then do more math

#

if not don't

drifting wedge
#

so its like 80% less

mellow kelp
#

using pretty much any method also cuts the numbers in / 2

icy skiff
#

i dont even know anymore if u r joking or not

mellow kelp
#

same lmao

drifting wedge
#

lol

#

alr well how cani improve it?

lyric mountain
#

they just said...

icy skiff
#

the way u r doing theres nothing else to improve really, u r working with a number skipper of some sort

#

and u r skipping numbers in a pretty decent way

#

but

#

the fermat primality test just works differently

#

and better in every way

#

but dont get me wong urs works fine

drifting wedge
#

oh

#

ok

#

mine bes

icy skiff
#

i think

drifting wedge
#

best

mellow kelp
#

just straight up ignore him already

icy skiff
#

kek

drifting wedge
#

lol

icy skiff
#

try checking if (2^77,232,917)-1 is prime on ur algorithm

#

kek

drifting wedge
#

nah seriously

#

itd good? or stinky?

icy skiff
#

its basic

drifting wedge
#

ill try

#

alr

#

it doesnt even print ol

#

@icy skiff

#

@icy skiff the other algorithms took like 18 days

#

lol

icy skiff
#

i know it doesnt

drifting wedge
#

?

drifting wedge
#

i googled ot

icy skiff
#

?

drifting wedge
#

i mean py is slow too

icy skiff
#

that number i sent to u is the hghest known prime number

#

python cant take that

drifting wedge
#

ye ik

#

mhm

#

with this program

#

i tried to do the 100 million digit prime

#

thing

#

my vps ded

#

lol

icy skiff
#

lol

#

not a good idea definitely

drifting wedge
#

problem is just the hugeness of the number

#

it handles small numbers well

#

i tried all primes from 1, 1,000,000

#

and it worked well

icy skiff
#

yes yes i kniw

#

1M is relatively small for computers

drifting wedge
#

lol

#

what can i try?

#

that is POSSIBLE

icy skiff
#

try the integer limit

drifting wedge
#

1 billion - 10 billon

#

lemme tru

icy skiff
#

thats... negative

#

9,223,372,036,854,775,807 try that

drifting wedge
#

1 billion to 10 billion

modest maple
#

best thing about python is the unbound integers

#

your only limit is yer memory

#

9_223_372_036_854_775_807_000_000_000_000_000_000_000_000_000_000_000_000 is perfectly in bounds

drifting wedge
#

not prime

#

9,223,372,036,854,775,807

#

not prime

#

program does it isnta

#

dont know how

modest maple
#

well your ideal solution can check if a number is prime with O(sqrt(n)) time notation

drifting wedge
#

gimme a huge numbe

#

ill try it

modest maple
#

9_223_372_036_854_775_807_000_000_000_000_000_000_000_000_000_000_000_000

restive furnace
#

so is js' integers unbound

#

sad that c++ has limited into 128 bits

cinder patio
modest maple
#

its why discord ids in JS must be strings

drifting wedge
#

false

modest maple
#

Python numbers are technically bounded

drifting wedge
#

not prime

#

its due to the 0's

modest maple
#

but the max number is generally greater than you have ram

drifting wedge
#

0 is one of the checks

cinder patio
drifting wedge
#

92233720385475807000000000000000000000000000000000007 is not prime

modest maple
#

72560314765034785613048576130456240786134567324767348756304856038475384765314563948608601030314075013458173475613401876501837465038475613407856138765035673075613045613475613087456078677608760677666087436078341567053467034560734567135460067531406341508672343333333453463456457645642575467567867658567807809678567435624561362457645135624765028746507834651

#
def is_prime(n):
...     """
...     Assumes that n is a positive natural number
...     """
...     # We know 1 is not a prime number
...     if n == 1:
...         return False
... 
...     i = 2
...     # This will loop from 2 to int(sqrt(x))
...     while i*i <= n:
...         # Check if i divides x without leaving a remainder
...         if n % i == 0:
...             # This means that n has a factor in between 2 and sqrt(n)
...             # So it is not a prime number
...             return False
...         i += 1
...     # If we did not find any factor in the above loop,
...     # then n is a prime number
...     return True

Fast is_prime

drifting wedge
#

lemme try

#

i still think mine is faster

#

due to it cancelling a lot of numbers

earnest phoenix
#

bitwise

modest maple
#

mathematically speaking thats impossible

drifting wedge
#

false

#

its not

modest maple
#

unless you manually compute all the primes upto a infinite amount of numbers

drifting wedge
#

72560314765034785613048576130456240786134567324767348756304856038475384765314563948608601030314075013458173475613401876501837465038475613407856138765035673075613045613475613087456078677608760677666087436078341567053467034560734567135460067531406341508672343333333453463456457645642575467567867658567807809678567435624561362457645135624765028746507834651 not prime

#

had to change code a bit

#

but it gave it isntantly

#

not prime

modest maple
drifting wedge
#

try running mine

#

compaREE

cinder patio
drifting wedge
#

false?

cinder patio
#

10,007 is a prime number, so that's wrong

signal wagon
#

Hey he just said it's fast not that it's right

drifting wedge
#

sus

modest maple
#
is_prime(10007)
True
drifting wedge
#

wot

#

very sus

cinder patio
#

so that's why such big numbers gave you instant results :0

drifting wedge
#

73 gives true

#

like prime numbers work..

signal wagon
#

*some

modest maple
#

basically

#

your system is only fast

#

if you hardcode all the values

drifting wedge
#

10009 is prime

#

?

#

its not doe

#

im not sure

signal wagon
#

It is

cinder patio
#

Using switch and hard-coding all the numbers is O(1) pogey

signal wagon
#

Brb writing 124139857013013759817385418935713578913591 lines of code real quick

cinder patio
#

If there's a file with all prime numbers you could possibly write a script which automates that

drifting wedge
#

10,007 is not prime accorind to my systen

signal wagon
#

It is tho

wise pendant
#

7256031476503478561304857613045624078613456732476734875630485603847538476531456394860860103031407501345817347561340187650183746503847561340785613876503567307561304561347561308745607867760876067766608743607834156705346703456073456713546006753140634150867234333333345346345645764564257546756786765856780780967856743562456136245764513562476502874650783465172560314765034785613048576130456240786134567324767348756304856038475384765314563948608601030314075013458173475613401876501837465038475613407856138765035673075613045613475613087456078677608760677666087436078341567053467034560734567135460067531406341508672343333333453463456457645642575467567867658567807809678567435624561362457645135624765028746507834651
not prime

drifting wedge
#

199 is prime

#

very cool]

#

19999*

#

1999*

cinder patio
#

Is 5147 prime?

#

according to your algorithm

lyric mountain
#

big test: is 1 prime?

drifting wedge
#

yes

lyric mountain
#

no, it ain't

drifting wedge
#

1 is not

#

the 5147 is

modest maple
#

What is your code for this pithink

drifting wedge
#

i posted it

#

github

#

0exe/prime

cinder patio
wise pendant
#

i made a bot for this prime stuff few weeks ago

modest maple
#
from time import perf_counter
start = perf_counter()
for _ in range(1000):
    is_prime(10007)
stop = perf_counter() - start

print(stop * 1000, "ms")```
call your function is_prime and run this ![mmLol](https://cdn.discordapp.com/emojis/356831697385422848.webp?size=128 "mmLol")
drifting wedge
#

how?

#

like at the same time?

#

?

modest maple
#

pithink Bro im litterally saying just add your code to that calling it is_prime add that code to the bottom and run it

#

and send it's output time

drifting wedge
#

oh

wise pendant
#

thx ill do that

cinder patio
#

You don't mind the wrong output?

modest maple
#

i mean we already established that it aint accurate

#

now we just gotta see how fast it is

drifting wedge
#

sus

#

it spammed 10007

lyric mountain
#

yeah, 1000 times

modest maple
#

dont print anything other than the time

cinder patio
#

is_prime(10007, False)

drifting wedge
#

10007
2.3121229999999993 ms

hallow shell
#

has anyone here actually ever used a js BigUint64Array?

modest maple
#

So my code is actually accurate and faster mmLol

#

6ms for 10k iterations lul

drifting wedge
#

sus

#

something is wrong eith my code doe

modest maple
#

i mean idk what you're tryna do with ur code

#

the solution itself isnt any faster than sqrt(n)

#

technically its O(n) just trying to cut out some stuff

drifting wedge
#

nah it works

#

it works

#

10007 is prime

cinder patio
#

sus

drifting wedge
#
True
1.0440969999999938 ms```
#

10007

autumn latch
#

DO I need to say more?

drifting wedge
#

@modest maple

#

try running it on ur pc

icy skiff
#

Btw

autumn latch
#

i]

drifting wedge
#
def prime(num:int, show:bool = True, sf:bool = True):
    if num == 2:
        print(num)
        if not sf:
            return True
    elif num % 2 == 0:
        return False
    elif num == 5:
        print(num)
        if not sf:
            return True
    elif num%10 == 5 or num%10 == 0:
        return False
    else:
        counter = 0 
        for i in range(1, round(num/2)):
            if num % i == 0:
                counter += 1
                if counter > 1:
                    return False
                else:
                    if show and i != 1:
                        print(i)
        if counter == 1:
            print(num)
            return True
        else:
            return False

from time import perf_counter
start = perf_counter()
for _ in range(1000):
    prime(10007)
stop = perf_counter() - start

print(stop * 1000, "ms")```
icy skiff
#

U Just need to check if the number is divisible from 3 to its Square root

#

In that for

earnest phoenix
#

doesn't python have any proper benchmarking tools?

drifting wedge
#

idk man

icy skiff
#

It does

#

Just import time

#

Do start = time.time() before It begins

earnest phoenix
#

comparing before and after timestamps isn't a proper benchmark

fossil tapir
#

Is anyone else not able to load the developer page?

modest maple
icy skiff
#

And at the end do print(time.time()-start)

modest maple
#

use the perf counter

drifting wedge
#

@modest maple how does ur code work?

#

and how is it faster than mine>

modest maple
drifting wedge
#

since mine cuts like 80% of numbers

modest maple
#

your code is still O(n) and defo doesnt cut out 80% of the numbers lul

dusky sundial
modest maple
#
from time import perf_counter
old = 0
start = perf_counter()
for i in range(10_000):
    new = i * i
    prime(new + old)
    old = new
stop = perf_counter() - start

print(stop * 1000, "ms")``` Run that and see just how slow your code gets
#

vs my example which did it in 42ms

drifting wedge
icy skiff
#

That is not 80% pretty sure

modest maple
#

but thats less efficient than just squaring your iteration count every time

drifting wedge
#

i think it is

#

why dont we just make a super prime finder?

#

big brain time

icy skiff
#

Bc there r ones so good we wont beat them

modest maple
#

You're trying to cuz down on size via hard coding values then brute forcing rather than trying to cut down on numbers based of their pattern

#

you wont be O(sqrt(n))

#
def is_prime(n):

    """
    Assumes that n is a positive natural number
    """
    # We know 1 is not a prime number
    if n == 1:
        return False
    i = 2
    # This will loop from 2 to int(sqrt(x))
    while i*i <= n:
        # Check if i divides x without leaving a remainder
        if n % i == 0:
            # This means that n has a factor in between 2 and sqrt(n)
            # So it is not a prime number
            return False
        i += 1
    # If we did not find any factor in the above loop,
    # then n is a prime number
    return True```
is about as fast as you can be
#

your code took 140304.6681 ms vs 42 ms

drifting wedge
#

sus

icy skiff
#

Its not sus at all tho

cinder patio
#

Theoretically, wouldn't checking if the number is even (but not 2) before starting the loop be faster in cases where an even number is provided?

#

That does add a bit of overhead when the number is not even

lyric mountain
#

decimal millis lul

modest maple
drifting wedge
#

@modest maple ur code is shit

2**77232917)-1 isnt instsnt

#

code sucks

#

25 million digit number

icy skiff
drifting wedge
#

and ur dumb code cant even handle it

modest maple
#
is_prime(2**77232917)
False``` works for me
icy skiff
#

Minus 1

drifting wedge
#

its wrong then

#

-1

#

ye

#

u need -1

next storm
#

Program for prime cheking??

drifting wedge
#

ye

#

we're messigng with that stuff

next storm
#

I am a programmer but I know java

icy skiff
drifting wedge
#

...

drifting wedge
#

see

#

i know youd come around

#

my code is best'

icy skiff
#

U r checking every single number between 2 and sqrt of n

icy skiff
drifting wedge
#

lol

next storm
#

U need java program??

modest maple
#

which is less than 0EXE

icy skiff
#

Yes it is

drifting wedge
#

whatever dude

icy skiff
#

But u could cut It in half

drifting wedge
#

i TRIED

modest maple
#

0EXE cant even handle 2**77232917 - 1

#

because Python cant support a float that large

drifting wedge
#

why dont we TOGETHER make a good one?

warm mulch
#

i cant seem to vote for bots rn and it says something about error 504

drifting wedge
#

like an instant one?

#

lol

icy skiff
#

Make i start at 3 and i+=2

drifting wedge
#

we COULD

#

i mean we're pretty big brain

modest maple
#

because mathematically my example is the fastest it can possibly be

drifting wedge
#

we could just google it

#

use pupettee

modest maple
drifting wedge
#

and see if number is prime

#

pupeteer

icy skiff
#

On ur code, If I put 17, for example

next storm
#

Can anyone say do u need java program?

icy skiff
#

It Will test n%i for i = 2,3,4,5

next storm
#

In java I m champ

drifting wedge
#

?

icy skiff
#

But u dont need to check the even numbers

drifting wedge
#

and you dont need to check the 2nd half of the numbers

#
  • you can skip multiples od 5
#

of*

next storm
#

What program u want

#

Just say

drifting wedge
#

ends with 5 or 0

icy skiff
#

Nothing can be divisible by 4 but not by 2, for example

next storm
#

I will tell u the logic

#

@drifting wedge bro I can help u

#

Just say what program u neee

icy skiff
drifting wedge
#

?

icy skiff
#

He checks upto Square root of n

#

U check upto half of n

drifting wedge
#

oh

#

thats smart

icy skiff
#

Sqrt is better

drifting wedge
#

alr

#

well u can not check multiples of 5

next storm
#

Uf

drifting wedge
#

and even numbers

next storm
#

I could help u

#

But no reply

drifting wedge
#

cuts time in half +

next storm
icy skiff
#

The only easy thing that could improve @modest maple alg is making i+=2

next storm
#

No one is replying

#

Wtf

icy skiff
#

Sorry bro

#

What do u need?

modest maple
#

Mmm yeah you could incr by 2

next storm
#

Bro I want to help u

icy skiff
#

Told ya

next storm
#

I am a programmer

icy skiff
#

Oh

#

We r all

next storm
#

What's the program u need?

icy skiff
#

We don't need programs here

next storm
#

Then ?

icy skiff
#

We r Just debating about prime checkers

#

Lol

drifting wedge
#

^

next storm
#

Prime checking of a number??

#

It's very easy

icy skiff
#

Ye

earnest phoenix
#

helo make diskord hacked pls

drifting wedge
#

basically

modest maple
#

That would the the absolute fastest you can check if that number is prime or not though

next storm
#

Very very easy

icy skiff
drifting wedge
#

@next storm you make one

#

alr

modest maple
#

Dont think there is any other way to make it faster

next storm
#

Ok

drifting wedge
#

then compare it with cf8's!

drifting wedge
#

well ofc

#

u can check if number is in a list of prime numbers

icy skiff
#

No

#

Not hardcoded

drifting wedge
#

big brain

icy skiff
#

Already told u

drifting wedge
#

wouldnt it work?

#

if u have an infinitelist

#

of all the primes

icy skiff
#

Theres no such thing as infinite list lol

modest maple
#

if you had a infinite list your time would be infinite

drifting wedge
#

would it be fast or hella slow?

wise pendant
#

lol

icy skiff
#

It would be O(1)

#

If It was possible

modest maple
#

unless you sorted the list and had checked it's size

#

otherwise you're going to be infinitely searching the list

drifting wedge
#

if u had a 9999999999999999999999999999999999999999999999**999999999999999999999 prime list

icy skiff
#

That's not infinite

drifting wedge
#

ik

signal wagon
#

then searching that list would become the bottleneck

modest maple
drifting wedge
#

hyperbole

modest maple
#

assuming it's sorted you can use an array

#

which would be O(1)

drifting wedge
#

if u had a long list

earnest phoenix
#

have fun wasting all of your resources on a prime number list mmLol

drifting wedge
#

IMMA MAKE A PRIME LIST1

#

ez

icy skiff
#

Gl

#

But @modest maple

drifting wedge
#

cant u just array()?

modest maple
#

i mean yeah you can use the array collection in python

icy skiff
#

Fermat primality test and sieve of eratosthenes are the fastest prime checkers i know of

modest maple
#

wont stop it eating an insane amount of ram though compared to other versions

drifting wedge
#

true

next storm
#

def prime(num)
for I=1 I<n
If n%i==0
f=f+1:
if I==1
return true
else
return false

icy skiff
#

I think It's the fastest there is

next storm
#

Why

drifting wedge
#

i mean it makes sense

icy skiff
#

Hope u r trolling

drifting wedge
#

but would work

small tangle
#

Is the Discord Developer Portal working for u guys?, im curious if its my problem ASpeek

next storm
#

Bro I know only java

#

That's why

drifting wedge
#

wouldnt*

next storm
drifting wedge
#

alr cya nerds

modest maple
#

isnt sieve of eratosthenes for producing the numbers

drifting wedge
#

ty for your opinions and stuff

next storm
#

@icy skiff bruh I know only java programming

icy skiff
#

Ye, u use memorization with it + fermat

modest maple
#

ehh ig

#

but the pre-processing isnt faster

icy skiff
#

True but after its set its literally the fastest out there

modest maple
#

your 'speed' would come from the fact you pre-computed the numbers

drifting wedge
#

calculating new primes

icy skiff
#

Its the way people use on programming marathons

drifting wedge
#

is just resource intensive

modest maple
drifting wedge
#

not "hard"

icy skiff
#

Pretty much

drifting wedge
#

alr cya

icy skiff
#

Cya

modest maple
#

dont you love it when your forget docker is running as sudo so makes all the files with sudo perms

#

well ig my settings file is now sudo protected™️

icy skiff
#

all sudo >>>

lyric mountain
#

you just appended that text to a file

#

now your system32 is gonna get delete

modest maple
#

and now we wait

#

broom broom

cinder patio
#

What the hecc is spooderfy

modest maple
hidden lynx
#

can you guys log into your discord devs dashboard?

umbral zealot
#

no

hidden lynx
#

oh thanks!

cinder patio
#

@opal plank I'm just gonna say that I am going to switch to mongdb because I don't think the data I'm storing works for a relational database, or it's too hard to get it to work with one

#

And also because I have to finish the app in around 2 weeks

#

Some question types have extra options which are a pain to store in a relational db

opal plank
#

thats what i was on about, document db's might be better for your case #development message
though its 100% doable in postgres

cinder patio
#

yeah it definitely can be done

#

I just can't be bothered lol

opal plank
#

fair enough lmao

cinder patio
#

Why is the mongodb server taking 150 mb of RAM thonkku it has 0 connections

solemn latch
#

index's?

modest maple
#

if you think 150MB is alot

#

then you are gonna enjoy as it get bigger mmLol

cinder patio
#

makes sense

heavy marsh
#

so on d.js v 12.5.1 I get an error saying TypeError: Cannot read property 'title' of undefined

Why wont this fix the problem

          let Info = station;
        let np_s_s;
        let np_s_a;
        
    if(Info.title !== null || Info.tittle !== undefined) {
        const StationInfo_Raw = Info.title.split(" - ")[1].split('" ').map(x => { let s = x.split('="'); return {[s[0]]: s[1]} });
        let StationInfo = StationInfo_Raw.reduce(((r, c) => Object.assign(r, c)), {});
        let NP_Station = `${StationInfo.text || `Unknown Station`} \`[${StationInfo.song_spot || `UNKNOWN`}]\` | ${StationInfo.length || `00:00:00`}` || ` `;
        let NP_StationIcon = (!StationInfo.amgArtworkURL || StationInfo.amgArtworkURL === "null") ? "https://cdn.discordapp.com/attachments/701169235526680696/811104671527600128/Unknown_Stream.png" : StationInfo.amgArtworkURL;
        
        np_s_s = NP_Station;
        np_s_a = NP_StationIcon;
    }
cinder patio
#

station / Info is undefined

heavy marsh
#
     internetradio.getStationInfo(Stream, function(error, station) {
          let Info = station;
        let np_s_s;
        let np_s_a;
        
    if(Info.title !== null || Info.title !== undefined) {
        const StationInfo_Raw = Info.title.split(" - ")[1].split('" ').map(x => { let s = x.split('="'); return {[s[0]]: s[1]} });
        let StationInfo = StationInfo_Raw.reduce(((r, c) => Object.assign(r, c)), {});
        let NP_Station = `${StationInfo.text || `Unknown Station`} \`[${StationInfo.song_spot || `UNKNOWN`}]\` | ${StationInfo.length || `00:00:00`}` || ` `;
        let NP_StationIcon = (!StationInfo.amgArtworkURL || StationInfo.amgArtworkURL === "null") ? "https://cdn.discordapp.com/attachments/701169235526680696/811104671527600128/Unknown_Stream.png" : StationInfo.amgArtworkURL;
        
        np_s_s = NP_Station;
        np_s_a = NP_StationIcon;
    }
        let Station_Name = Info.headers['icy-name'] || `Unknown Station`
#

I mean Info gets the info

#

but I want to do is when info.title is not defined ignore it but if its defined do that

cinder patio
#

Your problem is that station (And then Info, cause Info = station) is undefined.

heavy marsh
#

I did console.log to Info

#
{
  title: " ",
  fetchsource: 'STREAM',
  headers: {
    'content-type': 'audio/mpeg',
    'icy-br': '192',
    'icy-description': 'IPR is an independent online radio based in Guadalajara, curated by local and international DJs, musicians and visual artists.',
    'icy-genre': 'Eclectic',
    'icy-name': 'Internet Public Radio',
    'icy-pub': '0',
    'icy-metaint': '16000'
  }
}
#

So want I trying to do is

#

if the tittle information then do this one

        const StationInfo_Raw = Info.title.split(" - ")[1].split('" ').map(x => { let s = x.split('="'); return {[s[0]]: s[1]} });
        let StationInfo = StationInfo_Raw.reduce(((r, c) => Object.assign(r, c)), {});
        let NP_Station = `${StationInfo.text || `Unknown Station`} \`[${StationInfo.song_spot || `UNKNOWN`}]\` | ${StationInfo.length || `00:00:00`}` || ` `;
        let NP_StationIcon = (!StationInfo.amgArtworkURL || StationInfo.amgArtworkURL === "null") ? "https://cdn.discordapp.com/attachments/701169235526680696/811104671527600128/Unknown_Stream.png" : StationInfo.amgArtworkURL;
#

if not then ignore this part

#

So ... why wont this work

if(Info.title !== null || Info.title !== undefined) {

Or am I doing it wrongly

lyric mountain
#

oh you again lul

lyric mountain
#

it's a string with a blank space

icy skiff
#

Kek w

heavy marsh
limber flume
#

Yo😳

icy skiff
#

On js, does It work If u do
("" == false)

heavy marsh
earnest phoenix
#

Today we are gonna end servers peace kek

limber flume
#

lol we shouldn’t do that

crimson vapor
near stratus
near stratus
lyric mountain
near stratus
lyric mountain
#

empty string, undefined, null, etc will all be false

icy skiff
#

So it does or ir doesn't

#

Lol 2 different answers

icy skiff
#

God my internet is sucking ass rn

near stratus
lyric mountain
#

yep

#

trim removes leading and trailing spaces

#

so " " becomes ""

#

which is false

near stratus
#

yea

#

welcome to js lol

lyric mountain
#

for js everything is boolean

icy skiff
modest maple
#

its a thing that JS took from python when it was made

ornate otter
#

So i fixed my top.gg colours and now they are broken again

modest maple
#

that everything can be compared

#

it also took the whole bools being ints system

crimson vapor
#

no, not everything is a bolean

modest maple
#
>>> True + True + True 
3
>>> True + True + False 
2
crimson vapor
#

everything is truthy or falsy

modest maple
#

Bools are technically built of the ints

earnest phoenix
#

my brain is weird or js is werid

heavy marsh
# lyric mountain `if (Info.title.trim())`

Ok so I did this

    if(Info.title.trim()) {
        console.log(Info.title)
        const StationInfo_Raw = Info.title.split(" - ")[1].split('" ').map(x => { let s = x.split('="'); return {[s[0]]: s[1]} });

Console log is

But I still get the error

TypeError: Cannot read property 'title' of undefined
near stratus
crimson vapor
lyric mountain
modest maple
#

its a trait in Python that was carried on in JS

#

both you can still do in the modern code bases

mellow kelp
#

i mean the true-1 and false-0 makes sense

lyric mountain
#

oh wait

modest maple
#

as both languages build their bools off the integer base

mellow kelp
#

that's what booleans are basically

#

1s and 0s

icy skiff
#

Ye, its basically C but with Key words

lyric mountain
#

actually do if (Info?.title.trim())

mellow kelp
#

i just found a practical use for trigonometry in making games with canvas

#

this is pretty cool

crimson vapor
modest maple
#

Alot of JS' basic runtime fundamentals were taken from Python, they were lucky to be able to take the good bits of Python's implementation, remove the features that made python hard to sandbox and got the ability to add performance

stark abyss
#
distube.on("addSong", (message, queue, song) => return message.channel.send(`Added ${song.name} - ${song.formattedDuration} to the queue by ${song.user}`));

for some reason "addSong" even is triggered more then once so its sending the message more then once, but it won't let me add return

crimson vapor
#
Boolean.prototype.toTrue = () => true```
#

ezpz

lyric mountain
stark abyss
#

so I am unsure how to stop it once it sends the message

mellow kelp
#
// enviroment.d.ts
interface Boolean {
    toTrue(): true;
}

// index.ts
Boolean.prototype.toTrue = function() {
    return true;
}
#

yes

stark abyss
#

whatHaveIdone okay thanks

heavy marsh
# lyric mountain do `if (Info.title?.trim())`
     internetradio.getStationInfo(Stream, async function(error, station) {
          let Info = await station;
        console.log(Info.headers)
        let Station_Name = await Info.headers['icy-name'] || `Unknown Station`

Cosole.log ==

{
  'content-type': 'audio/mpeg',
  'icy-br': '192',
  'icy-description': 'IPR is an independent online radio based in Guadalajara, curated by local and international DJs, musicians and visual artists.',
  'icy-genre': 'Eclectic',
  'icy-name': 'Internet Public Radio',
  'icy-pub': '0',
  'icy-metaint': '16000'
}

Error

TypeError: Cannot read property 'headers' of undefined

...

modest maple
#

JS's forEach is basically python's map()

placid iron
#

js has a .map too though

lyric mountain
#

you need to check if your payload is getting all the important stuff

modest maple
#

Man was dumb and forgot to update the players

heavy marsh
#

It s the error doesnt make senses ...

lyric mountain
#

it's because you're getting an incomplete payload

heavy marsh
#
     internetradio.getStationInfo(Stream, async function(error, station) {
          let Info = await station;
        console.log(Info.headers)
        let Station_Name = await Info.headers['icy-name'] || `Unknown Station`;
        let np_s_s;
        let np_s_a;
        
    if(Info?.title.trim()) {
        const StationInfo_Raw = Info.title.split(" - ")[1].split('" ').map(x => { let s = x.split('="'); return {[s[0]]: s[1]} });
        let StationInfo = StationInfo_Raw.reduce(((r, c) => Object.assign(r, c)), {});
        let NP_Station = `${StationInfo.text || `Unknown Station`} \`[${StationInfo.song_spot || `UNKNOWN`}]\` | ${StationInfo.length || `00:00:00`}` || ` `;
        let NP_StationIcon = (!StationInfo.amgArtworkURL || StationInfo.amgArtworkURL === "null") ? "https://cdn.discordapp.com/attachments/701169235526680696/811104671527600128/Unknown_Stream.png" : StationInfo.amgArtworkURL;
        
        np_s_s = NP_Station;
        np_s_a = NP_StationIcon;
    }
earnest phoenix
#

who can help me install enmap?

fossil tapir
heavy marsh
solemn latch
#

enmap has a support discrord, and an pre-requisities listed on the docs.

earnest phoenix
earnest phoenix
#

VS

solemn latch
#

follow the docs 👀

earnest phoenix
#

alll

solemn latch
#

vs isnt what you need, you need build tools

earnest phoenix
#

is it possible to find a bots password?

heavy marsh
earnest phoenix
#

what

icy skiff
#

Can u be more specific

lyric mountain
#

you just need to check if it contains all the necessary fields

earnest phoenix
icy skiff
#

Password for what

heavy marsh
earnest phoenix
#

password

icy skiff
#

Bro

earnest phoenix
#

or is there none

icy skiff
#

U r not helping

earnest phoenix
#

password as in your profiles password.

heavy marsh
#

Bots dont have a pass

mellow kelp
#

bot's don't have passwords

icy skiff
#

Bots dont have password

#

U use ur account

earnest phoenix
#

ok

heavy marsh
lyric mountain
#

then remove the if

#

don't use it if you know you'll be getting the correct data 100% the time

heavy marsh
#

I mean somethings I dont get the ... Nerve mind

#

I will see for a solution

earnest phoenix
#

Does somebody already made this ?
Are there any Libary, which saves work for

mellow kelp
#

canvas?

lyric mountain
#

yeah, 100% canvas

#

or Graphics2D if you're a javacoder

earnest phoenix
#

canvas but how can i do it with less work

icy skiff
#

Pillow for python

earnest phoenix
lyric mountain
earnest phoenix
mellow kelp
#

how hard is it to draw two images and some text

lyric mountain
#

less code is not equal to less work tho

earnest phoenix
#

but exact

icy skiff
#

Just set the bg and the avatar and add some text

#

That's like pretty easy

earnest phoenix
icy skiff
#

Ye no

earnest phoenix
#

xD

icy skiff
#

Give It a read to the docs

lyric mountain
#

don't sue canvas

earnest phoenix
mellow kelp
#

canvas is awesome

icy skiff
#

Poor Canvas

lyric mountain
#

he didn't get it...

icy skiff
#

Why do u sue canvas

icy skiff
lyric mountain
#

anyway, canvas is the most straightforward path

#

it's already abstracted af

copper cradle
#

damn

lyric mountain
#

sure you'll need to do some math here and there, but it's not hard at all

earnest phoenix
mellow kelp
#

createCanvas(width, height)

icy skiff
#

Then code urself

#

Like

#

Why r u stealing code

#

That code was not made for u prob

lyric mountain
#

dude

#

stop looking for wet water

#

just code it urself

#

you'll NOT find an exact example of what you're trying to do

#

github is NOT a self-service buffet

earnest phoenix
mellow kelp
#

well good luck

earnest phoenix
cinder patio
#

Why not read a tutorial or two about canvas?

lyric mountain
mellow kelp
icy skiff
#

Give me all ur bank balance and i code it for u

earnest phoenix
icy skiff
#

Stonks

copper cradle
#

you can't make this shit up

crimson vapor
#

that code is shit

earnest phoenix
crimson vapor
#

ok

opal plank
#

why is it half in english and harlf.... erm... turk? or whatever the fuck that is

icy skiff
#

That's pretty cool

opal plank
#

@crimson vapor explain urself

mellow kelp
#

turkish bottums

crimson vapor
#

huh?

#

what

#

im american

opal plank
crimson vapor
#

idk man

opal plank
#

lmao

crimson vapor
#

thats not me

opal plank
#

why is this half in english

crimson vapor
#

thats why I called it shit

#

read the code

#

using PascalCase for variables

opal plank
#

And Every Word Starts Uppercase Cuz Fuck Everything

crimson vapor
#

ikr

earnest phoenix
#

but this looks very cool

crimson vapor
#

cool yes

opal plank
#

Channelz

#

cool kids intesify

crimson vapor
#

what the fuck

mellow kelp
#

channelz

crimson vapor
#

Erwin wanna give me feedback on my code again?

opal plank
#

hell nah

crimson vapor
opal plank
#

gonna have to get to the market in 2 minutes

crimson vapor
#

ah

#

nice

opal plank
#

i'll take a look later after i finish work

crimson vapor
#

ok

lyric mountain
#

you take the easy path and fall into a pit later on

mellow kelp
crimson vapor
#

yes

mellow kelp
#

aight

earnest phoenix
mellow kelp
#

time for 👏 code 👏 review

crimson vapor
#

I don't copy code either

#

I make it myself

mellow kelp
#

you can import json files without *

earnest phoenix
#

require ?

crimson vapor
#

ts

lyric mountain
earnest phoenix
lyric mountain
#

the right path

earnest phoenix
#

okay master

lyric mountain
#

coding is a harsh task sometimes, but all the time you spend coding will be saved when debugging

crimson vapor
#

yes I need to learn to debug

earnest phoenix
mellow kelp
#

@crimson vapor you got a .then() in an async function kek

earnest phoenix
tired panther
lyric mountain
#

still valuable knowledge on the long way

crimson vapor
#

bro ima go nap make sure you ping me so I see the messages when I get back

floral plinth
#

There is a way to get a bot statistics like how many server it is in without nodejs, there is an API ?

lyric mountain
#

node.js is a js framework

#

did u mean discord.js?

floral plinth
#

but discord.js is used with node js

modest maple
floral plinth
#

but for my prject I can't use nodejs

lyric mountain
#

then u can't use discord.js

lyric mountain
opal plank
floral plinth
#

ok...

opal plank
#

once is that it give you the server count via the auth

#

second is via the gateway directly

#

but the second one you need to use your token iirc

#

and identify on the gateway

#

though that number isnt completely accurate, it updates slowly

#

this is the live server count

#

as you can see, theres a bit of delay

floral plinth
#

ok but when click on the invite link of the bot i need to choose the server

opal plank
#

well yeah

#

manually, at least

#

you might be able to request it directly for server count

#

check the oauth payload thats being sent

floral plinth
eternal osprey
#

hey

near plover
#

does anyone happen to have a solution for a lightweight command handler for JDA

lyric mountain
#

create one urself

#

it's not hard at all, you just need 2 classes

near plover
#

honestly probably what i'm gonna end up doing all the ones i've used are super bloated

opal plank
#

wew

#

this is a lot more than i expected

lyric mountain
#

like, you need 1 superclass for the commands to extend (or implement) from and a manager to retrieve the classes from

#

for example

opal plank
#

i sure hope its not reporting these stats

lyric mountain
#
public interface Command {
  void execute(Message message, User user);
}
#

then in ur command you implement it:

near plover
#

do you have a suggestion on approaching cooldowns? I was thinking making use of redis for it but idk

lyric mountain
#
public class PingCommand implements Command {
  ...

  @Override
  public void execute(Message message, User user) {
    //do stuff here
  }
}
lyric mountain
#

unless ur cooldown is gonna be long

#

if it's just a 3-5 second cooldown redis is just a waste of processing

near plover
#

I only have a few commands I'd like 6+ hour cooldowns on, rest would be 60 seconds or less

mellow kelp
#

should i use java reflect to load commands into the manager?

class CommandHandler {
  public <T extends Command> void load(Class<T> clazz) throws SomeExceptions {
    const constructor = clazz.getConstructor();
    const command = constructor.newInstance();
  }
}
#

or should i just directly pass the command instance

near plover
#

I mean you can reflect it if you wish

lyric mountain
#

return the command instance to whatever will use it

mellow kelp
#

it's just that i saw something similar in a friend's repo

lyric mountain
#

you still need to pass the parameters

#

so better let the caller pass them than passing arguments to handler then making an internal call

opal plank
#

@floral plinth

mellow kelp
#

i mean is there any reason to use this reflect thing over class instances

opal plank
#

you can get it via oauth

floral plinth
#

ok thx by fetch ?

lyric mountain
mellow kelp
#

fair enough

lyric mountain
#

if you use annotations you'll barely need to do anything inside the handler

#

not even pass the class to the loader

opal plank
near plover
#

I would personally opt for annotations

mellow kelp
floral plinth
#

ok i'll try

opal plank
#

aight, time to work

lyric mountain