#development
1 messages · Page 1609 of 1
DICT_TYPE_CONVERT: Only dictionaries may be used in a DictType```
received by .catch() ?
doesnt show the line
got it
alright ty anyway
technically, message.channel.guild.id would be "faster"
k
because it bypasses a getter
hmm ok
but thats pretty much useless microoptimization
so @near stratus whats the problem now
eris users:
yeah, just need to get into it a little bit... light version works fine so far
i read their documentation and it says dafaq
let's try one thing
lemme write the code
okay
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");
})
}
}
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
}
@wicked crown try this and tell me what the console says
xDDDDDDDDDDDDDDDDDDDDD

you forgot something
if(isThirteen(message)) return
@near stratus now it worked tf
ah, right
One message removed from a suspended account.
maybe it was the ban
the docs says
member.ban( {
reason: "ppppppp"
} );
lol
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;
}
thanks for your help @near stratus 🙂
what am i looking at
😳
Some good code
the fastest way to get a guild id from the message
some Notable members getting a guild
xDDDDD
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
true that
Wait I can write bad code and be notable for it?
possibly lul
its notable member not notably good member
but after this message it should be changed to Creator of Codeabomination
It's "notable" for naming the function
||Typos: "we don't exist"||
please don't
write it without blankspaces and linebreaks
there we go
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
}```
we must make sure to add semicolons to decrease compile time
maximise compile time
you're not since ASI inserts them so it takes more time 😉
code goes brrr
probably this level of code is needed for you to get yeeted off by your host's owner
The only positive thing about the code is that it has a low level of nesting 
or probably the formatting
how to make a webhook server?
Just make an http server
?
Bro
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;
}
i dont know lots about servers
Webhooks are just http requests designed for computers
or humans
how to make a https request
and i thought today is a day, where im not crying
There are cases which webhooks are used directly by users? 
👀
i may do that sometimes for top.gg votes
I mean technically you can make a http request
and technically you also make a response
uh totally don’t have a slave in my basement waiting for a http request to enter it into my database
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.

One request per guild per 5 minutes isn't that much
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.
are we supposed to spoonfed a whole webhook code ?
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
Ok so for example the bot caches messages from 80 guilds. Updating each document manually is fine in your opinion ?
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
?
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
Not if you keep ? When I'm answering other peoples question
Didn't they switch database recently?
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
Issue with installing or using sqlite?
Sqlite has a troubleshooting page on their docs/npmjs page
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.
cron
A scheduler would work aswell.
cron is kinda a scheduler
You said your having issues with installing?
We need the install error log, not the bot code
Also you probably missed some pretty clear detail on the install page: https://enmap.evie.dev/install#pre-requisites
help. me.
you forgot the is-is-odd
anyone can review py code?
What do u mean exactly by review
help slap spagetti code
I mean i guess i could take a look at it
^
even(num: int):
return (!odd(num))
K ill give It a look and dm you my thoughts
say someone redefines an odd number
you can do
you should just have 1 function
if odd(56):
and return inversions of that
what about multiply(2, 4)
@crimson vapor like this?
ill add it to my package if u want
no I mean like
idk py
Wait are you serious
idk how to add stuff to pip / pypi
def even(num: int):
return (!odd(num))
def odd(num: int):
return (num % 5 != 0)
idk if the syntax is right
U mean
oh yeah
Num %2
makes sense
Instead of 5
not 5
?
yes yes
Kek
LOL
but they could be separate
ye ye
say*
look into this?
ye i dont see the need for a function the check if its odd or nah
In Python you gotta use not rather than !
i think i made an insalenly good prime number finder
both work tho
on js you can actually do if (num % 2) return "odd";
yes because js good
js doesnt have range()
[...Array(<length>)].map((e, index) => index)

not really
did u use sieve of eratosthenes?
someone pls review
i made my own
oh yeah prime number calculators
if u made ur own then i guarantee u theres a better algorithm out there
true
i made a really shitty prime number calculator back in like 6th grade
cant, ids are numbers
it would return only half of the ids
omg
is odd (id)
lol
u can only allow even id users to use your bot
oMG
imma do that
no, because for js anything is a boolean
"do you prefer 5 or 10?"
js: true
SOMEONEE
k so
parseInt the last of the id
million review code pls
what u did was basically skip even numbers, multiples of 5 and 10
thats not like
amazing
im in class gimme a min
yes it is
youre not amazing
:/
this @drifting wedge
give it a read to eratosthenes' sieve and fermat primality test
this is kinda dumb ngl
mine is better
bruh
i cut the nums / 2
so its like 80% less
using pretty much any method also cuts the numbers in / 2
i dont even know anymore if u r joking or not
same lmao
they just said...
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
i think
best
just straight up ignore him already
kek
lol
its basic
ill try
alr
it doesnt even print ol
@icy skiff
@icy skiff the other algorithms took like 18 days
lol
i know it doesnt
?
the fermat one
i googled ot
?
i mean py is slow too
ye ik
mhm
with this program
i tried to do the 100 million digit prime
thing
my vps ded
lol
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
try the integer limit
1 billion to 10 billion
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
not prime
9,223,372,036,854,775,807
not prime
program does it isnta
dont know how
well your ideal solution can check if a number is prime with O(sqrt(n)) time notation
9_223_372_036_854_775_807_000_000_000_000_000_000_000_000_000_000_000_000
no, they are 32 bit floats
no JS are bound to 32 bits
its why discord ids in JS must be strings
false
Python numbers are technically bounded
but the max number is generally greater than you have ram
0 is one of the checks
There's BigInt now though, so ids can be numbers
92233720385475807000000000000000000000000000000000007 is not prime
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
bitwise
mathematically speaking thats impossible
unless you manually compute all the primes upto a infinite amount of numbers
72560314765034785613048576130456240786134567324767348756304856038475384765314563948608601030314075013458173475613401876501837465038475613407856138765035673075613045613475613087456078677608760677666087436078341567053467034560734567135460067531406341508672343333333453463456457645642575467567867658567807809678567435624561362457645135624765028746507834651 not prime
had to change code a bit
but it gave it isntantly
not prime
Try 10007
false?
10,007 is a prime number, so that's wrong
Hey he just said it's fast not that it's right
sus
is_prime(10007)
True
so that's why such big numbers gave you instant results :0
*some
It is
Using switch and hard-coding all the numbers is O(1) 
Brb writing 124139857013013759817385418935713578913591 lines of code real quick
If there's a file with all prime numbers you could possibly write a script which automates that
10,007 is not prime accorind to my systen
It is tho
7256031476503478561304857613045624078613456732476734875630485603847538476531456394860860103031407501345817347561340187650183746503847561340785613876503567307561304561347561308745607867760876067766608743607834156705346703456073456713546006753140634150867234333333345346345645764564257546756786765856780780967856743562456136245764513562476502874650783465172560314765034785613048576130456240786134567324767348756304856038475384765314563948608601030314075013458173475613401876501837465038475613407856138765035673075613045613475613087456078677608760677666087436078341567053467034560734567135460067531406341508672343333333453463456457645642575467567867658567807809678567435624561362457645135624765028746507834651
not prime
big test: is 1 prime?
yes
no, it ain't
What is your code for this 
i made a bot for this prime stuff few weeks ago
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 
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
oh
thx ill do that
You don't mind the wrong output?
i mean we already established that it aint accurate
now we just gotta see how fast it is
yeah, 1000 times
is_prime(10007, False)
10007
2.3121229999999993 ms
has anyone here actually ever used a js BigUint64Array?
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
sus
for one iteration
@modest maple
try running it on ur pc
Btw
i]
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")```
doesn't python have any proper benchmarking tools?
idk man
comparing before and after timestamps isn't a proper benchmark
Is anyone else not able to load the developer page?
Dont do that
And at the end do print(time.time()-start)
use the perf counter
you can use timeit but it just does the same thing as that for loop
since mine cuts like 80% of numbers
your code is still O(n) and defo doesnt cut out 80% of the numbers lul
The site has been having some issues lately, just wait until it's online again
Ok. 🙂
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
it cuts, multiples of 5/10, cuts 1/2 of the numbrs + cuts even numbers
That is not 80% pretty sure
but thats less efficient than just squaring your iteration count every time
Bc there r ones so good we wont beat them
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
sus
Its not sus at all tho
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
decimal millis lul
Not really cuz the first iteration will check that
@modest maple ur code is shit
2**77232917)-1 isnt instsnt
code sucks
25 million digit number
U can start i from 3 and do i+=2 can't u
and ur dumb code cant even handle it
is_prime(2**77232917)
False``` works for me
Minus 1
Program for prime cheking??
I am a programmer but I know java
Tbh i dont see how this code is any better than 0Exe's tbh
...
^
see
i know youd come around
my code is best'
U r checking every single number between 2 and sqrt of n
Also no
lol
U need java program??
which is less than 0EXE
Yes it is
whatever dude
But u could cut It in half
i TRIED
0EXE cant even handle 2**77232917 - 1
because Python cant support a float that large
why dont we TOGETHER make a good one?
i cant seem to vote for bots rn and it says something about error 504
Make i start at 3 and i+=2
because mathematically my example is the fastest it can possibly be
Pretty sure that doesnt cover all cases
It does
On ur code, If I put 17, for example
Can anyone say do u need java program?
It Will test n%i for i = 2,3,4,5
In java I m champ
?
But u dont need to check the even numbers
^
and you dont need to check the 2nd half of the numbers
- you can skip multiples od 5
of*
ends with 5 or 0
Nothing can be divisible by 4 but not by 2, for example
I will tell u the logic
@drifting wedge bro I can help u
Just say what program u neee
No, he does that better than u do
?
Sqrt is better
Uf
and even numbers
cuts time in half +

The only easy thing that could improve @modest maple alg is making i+=2
Mmm yeah you could incr by 2
Bro I want to help u
Told ya
What's the program u need?
We don't need programs here
Then ?
^
Ye
helo make diskord hacked pls
basically
That would the the absolute fastest you can check if that number is prime or not though
Very very easy
xdddd
Dont think there is any other way to make it faster
Ok
then compare it with cf8's!
There is
big brain
Already told u
Theres no such thing as infinite list lol
if you had a infinite list your time would be infinite
would it be fast or hella slow?
lol
unless you sorted the list and had checked it's size
otherwise you're going to be infinitely searching the list
if u had a 9999999999999999999999999999999999999999999999**999999999999999999999 prime list
That's not infinite
ik
then searching that list would become the bottleneck
not really
hyperbole
if u had a long list
have fun wasting all of your resources on a prime number list 
cant u just array()?
i mean yeah you can use the array collection in python
Fermat primality test and sieve of eratosthenes are the fastest prime checkers i know of
wont stop it eating an insane amount of ram though compared to other versions
true
def prime(num)
for I=1 I<n
If n%i==0
f=f+1:
if I==1
return true
else
return false
I think It's the fastest there is
No
i mean it makes sense
Hope u r trolling
but would work
Is the Discord Developer Portal working for u guys?, im curious if its my problem 
wouldnt*

alr cya nerds
isnt sieve of eratosthenes for producing the numbers
ty for your opinions and stuff
Ye, u use memorization with it + fermat
True but after its set its literally the fastest out there
K bruh
your 'speed' would come from the fact you pre-computed the numbers
calculating new primes
Its the way people use on programming marathons
is just resource intensive
true
not "hard"
Pretty much
alr cya
Cya
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™️
all sudo >>>
What the hecc is spooderfy

can you guys log into your discord devs dashboard?
no
but you can use https://canary.discord.com/developers/applications
ref: <#discord-news message>
oh thanks!
@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
thats what i was on about, document db's might be better for your case #development message
though its 100% doable in postgres
fair enough lmao
Why is the mongodb server taking 150 mb of RAM
it has 0 connections
index's?
cuz its mongo
if you think 150MB is alot
then you are gonna enjoy as it get bigger 
makes sense
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;
}
station / Info is undefined
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
Your problem is that station (And then Info, cause Info = station) is undefined.
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
oh you again lul
that's because title is neither null nor undefined
it's a string with a blank space
Kek w
...
Yo😳
On js, does It work If u do
("" == false)
what can I do to fix all the possible errors
Today we are gonna end servers peace 
lol we shouldn’t do that
an empty string is falsy but does not equal false
yeah that will return true
use === to be safe
if (Info.title.trim())
lemme try
empty string, undefined, null, etc will all be false
Just like python then good to know
God my internet is sucking ass rn
yep
trim removes leading and trailing spaces
so " " becomes ""
which is false
for js everything is boolean
That makes sense tho
its a thing that JS took from python when it was made
no, not everything is a bolean
>>> True + True + True
3
>>> True + True + False
2
everything is truthy or falsy
? wut
Bools are technically built of the ints
my brain is weird or js is werid
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
tf is this ? python ?
psudocode
do if (Info.title?.trim())
its a trait in Python that was carried on in JS
both you can still do in the modern code bases
i mean the true-1 and false-0 makes sense
oh wait
as both languages build their bools off the integer base
Ye, its basically C but with Key words
actually do if (Info?.title.trim())
i just found a practical use for trigonometry in making games with canvas
this is pretty cool
the function we really need @mellow kelp https://million.is-a.computer/files/LKLD1JMXYHPammyK.png
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
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
this looks like a job for me
multiply(x, y)
so I am unsure how to stop it once it sends the message
// enviroment.d.ts
interface Boolean {
toTrue(): true;
}
// index.ts
Boolean.prototype.toTrue = function() {
return true;
}
yes
.then()
okay thanks
LOL
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
...
and added 4 for loops 
JS's forEach is basically python's map()
js has a .map too though
if (Info.title?.trim() && Info.headers?.trim())
you need to check if your payload is getting all the important stuff
No no I mean what you told me works
It s the error doesnt make senses ...
it's because you're getting an incomplete payload
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;
}
who can help me install enmap?
is anyone else having issues loading discord.com/developers?
npm i enmap
enmap has a support discrord, and an pre-requisities listed on the docs.
i kiw that but mucht errors
follow the docs 👀
alll
vs isnt what you need, you need build tools
is it possible to find a bots password?
https://www.npmjs.com/package/enmap - Just saying errors is not going to do anything/no hints to help you on
Uh?
what
Can u be more specific
no, I mean, the data you're receiving is missing some parts sometimes
you just need to check if it contains all the necessary fields
like a literal password
Password for what
Token or password?
password
Bro
or is there none
U r not helping
password as in your profiles password.
Bots dont have a pass
bot's don't have passwords
ok
It worked fine before I but in the if
then remove the if
don't use it if you know you'll be getting the correct data 100% the time
Does somebody already made this ?
Are there any Libary, which saves work for
canvas?
canvas but how can i do it with less work
Pillow for python
yes ik
don't be lazy
but i am lol i saw a library and it has -------------- code
how hard is it to draw two images and some text
less code is not equal to less work tho
but exact
do it for me lel, i never sued canvas
Ye no
xD
Give It a read to the docs
don't sue canvas
what should i use
canvas is awesome
Poor Canvas
he didn't get it...
Why do u sue canvas
Its a joke
damn
sure you'll need to do some math here and there, but it's not hard at all
are there any constructor like canvas-constructor
createCanvas(width, height)
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
but i want it xD
well good luck
rip xD
Why not read a tutorial or two about canvas?
i want a maseratti and 1 million dollars in pennies
Give me all ur bank balance and i code it for u
okay 1$ bank done xD
Stonks
you can't make this shit up
ik but see the video .I am using my one
ok
why is it half in english and harlf.... erm... turk? or whatever the fuck that is
That's pretty cool
@crimson vapor explain urself
turkish bottums
idk man
lmao
thats not me
why is this half in english
And Every Word Starts Uppercase Cuz Fuck Everything
ikr
but this looks very cool
cool yes
what the fuck
channelz
Erwin wanna give me feedback on my code again?
hell nah

gonna have to get to the market in 2 minutes
i'll take a look later after i finish work
ok
dude, nothing regarding coding is easy
you take the easy path and fall into a pit later on
can i do c o d e r e v i e w ?
yes
https://github.com/Million900o/terano-rose/tree/master/src
👏 code 👏 review
aight
i did not copy any code that is api everybody can use
time for 👏 code 👏 review
you can import json files without *
require ?
ts
that's what I call a siren path
it looks easy, beautiful and perfect, but behind its mask is a horrendous monster that'll drown you when you're least expecting it
and which path is it when i do it my self?
the right path
okay master
coding is a harsh task sometimes, but all the time you spend coding will be saved when debugging
yes I need to learn to debug
the problem is that is not my job, I busy with school and more
@crimson vapor you got a .then() in an async function kek
lel use await or promises
It look likes a ui for hippies ☮️
nor is mine
still valuable knowledge on the long way
bro ima go nap make sure you ping me so I see the messages when I get back
There is a way to get a bot statistics like how many server it is in without nodejs, there is an API ?
but discord.js is used with node js
think you mean runtime
but for my prject I can't use nodejs
then u can't use discord.js
yeah, that stuff
you are able to do that in 2 ways
ok...
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
ok but when click on the invite link of the bot i need to choose the server
well yeah
manually, at least
you might be able to request it directly for server count
check the oauth payload thats being sent
i'll try with the https://discord.com/api/v8/
hey
does anyone happen to have a solution for a lightweight command handler for JDA
honestly probably what i'm gonna end up doing all the ones i've used are super bloated
like, you need 1 superclass for the commands to extend (or implement) from and a manager to retrieve the classes from
for example
i sure hope its not reporting these stats
public interface Command {
void execute(Message message, User user);
}
then in ur command you implement it:
do you have a suggestion on approaching cooldowns? I was thinking making use of redis for it but idk
public class PingCommand implements Command {
...
@Override
public void execute(Message message, User user) {
//do stuff here
}
}
caches
unless ur cooldown is gonna be long
if it's just a 3-5 second cooldown redis is just a waste of processing
I only have a few commands I'd like 6+ hour cooldowns on, rest would be 60 seconds or less
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
I mean you can reflect it if you wish
return the command instance to whatever will use it
it's just that i saw something similar in a friend's repo
you still need to pass the parameters
so better let the caller pass them than passing arguments to handler then making an internal call
@floral plinth
i mean is there any reason to use this reflect thing over class instances
you can get it via oauth
ok thx by fetch ?
for one: less cluttering
fair enough
if you use annotations you'll barely need to do anything inside the handler
not even pass the class to the loader
yeah, a simple get request
I would personally opt for annotations
wait what
ok i'll try
aight, time to work
this is my handler






