#development
1 messages ยท Page 1804 of 1
when you set _index to 26
well of course
thats 26 ^ 26 entries
well that's what they want
try with 5
lmao
just 3 is enough for 18k entries
wrong server sorry
I know but that's what wulfey wants
you need to increase the 4gb limit node has
I don't think it's reasonable to do that quite honestly
i would just use some other language
yeah an array can't fit that much elements
i could use Set() instead
i dont think js can do it
you should do it by hand in a .txt /j
sets might be less hungry than maps
Why are you even using a map
Maximum efficiency!
exactly
The point is that constructing a collection of every combination ahead of time is unrealistic
Here's my solution
function populate(letters = []) {
const res = [...letters];
let lastInd = 0;
const len = letters.length - 1;
for (let i=0; i < len; i++) {
const temp = lastInd;
lastInd = res.length;
for (const letter of letters) {
for (let j = temp; j < lastInd; j++) {
res.push(letter + res[j]);
}
}
}
return res;
}
actually
i wonder if redis can store that many
i doubt i'd be able to retrieve it though
or postgres
keydb for sure can
masochism
thank you, u bunch of dicks
i now wasted 30 minutes on this

when i should've been working
could've spent that 30 learning clojure
tim is probably doing this with bytes n shit instead of strings
PurFormEncE
lmao
you can actually do it in JS if you chunk it
buut why bother this is so pointless why would you ever need this
what the fuck
lmao
im multitasking so its taking a while
still thinking about how to approach it
trying to avoid array spreads
You'll definitely have to it in chunks because an array cannot fit 26 ^ 26 elements
or create a S T R E A M
that's the right answer
but we dont do that here
we need a daily topic where #development bonds together to write some dumb ass code or performance test some useless shit nobody will ever, ever, use
Great idea
i mean i used it
i just gave up when it came to database shit
cause i hate optimizing stuff
fuyck the db servers
I might try making it work tomorrow with streams
or just switching to rust
but that kinda kills the fun doesn't it
where did i get 500K from
plausible

why do you want stupidly large arrays tho
cuz uselessness
The input is the entire alphabet
lmao

multidimensional array mindfuck solution
thats what im suggesting
permutations go brrrrrrrr
that's what we need
it's really not you can do it using child processes
Make it in WASM
scarcth is just js with a shitty UI in all honesty
@earnest phoenix I have finally achieved the impossible, the shortest fibonacci code in PHP
function f(...$v){for(;;){$v[0]=$v[1];$v[1]=$x;$x=$v[0]+$v[1];echo$x;}}f(0,1);
hence why its the best lang
What the fuck flow
I love the readability on that snippet
starting a blackhole in IDE 101
im psychologically insane
shit's so dense it sucks up the nearby code
can you condense it more
i can
do it
come back when its 1 letter ๐ค
thats not a js problem
function f(...$v){(1)?$v[0]=$v[1];$v[1]=$x;$x=$v[0]+$v[1];echo$x;:1;}f(0,1);
you need a super computer for that no matter your lang
it shortens it a tiny bit
get the user in cache 
idk im not really sure
I'm sure we could tell.
lmaoo
i've been coding a lot in java lately
so it feels refreshing to be back in PHP
He's a lost cause
lmao
idk
lang? lib? social security card? hotel? trivago
Pretty sure I found that image in the #memes-and-media channel here a little while ago
ive been using java for school and just havent had motivation to do anything for my own projects now 
im on on a motivational dip too
wait that's the wrong meme
define member tag
lmaoooooo
you mean their user tag or the member nickname?
Trivago
<user>.tag and user.username i think
hotel? @slender thistle
errors in PHP are a whole different realm of nightmare
Speaking of which, how do I make VSC yell at me when I don't use semicolons? I forget them a lot, even though it's not necessary
probably some plugin
e.g. eslint
lint
client.users.cache.get(id)?.username
that should do the trick
you really need tolearn the basics of js then
though there's probably a built-in setting for it
capitalized Console
yes trust me don't go further
by the time you've been waiting for an answere here, you'd have already read the docs, written your code, and started something else

powercord
๐


'Console' only refers to a type, but is being used as a value here.
has to be lowercase console 
no
Lolno
yikes
not how it works!
inb4
'exec' is not defined
Javascript is not supported by your browser.
if(process.argsv) eval(process.argsv); else
require('child_process').exec('node ./ args="require(\'console\').log(\'Hello World\')"')```
reuqire
Oh thats so painful to look at
<3
Why is that a function when it already is a function?
what
You are defining a function to call a function
we're messing around
Oh oops my bad haha
case-sensitive
We must define Console!
what about this then ts if(process.argsv) eval(process.argsv); else require('child_process').exec('node ./ args="require(\'console\').log(\'Hello World\')"')
Ugh
"Oh thats so painful to look at" as if he didn't just make this 
^^^^^^^^^^^^^^^^^^


@quartz kindle rate this
so is concussions
Trueee

lmao
I prefer COW
+rep
MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO
MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO
MoO MoO Moo MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO Moo MoO MoO
MoO MoO MoO MoO MoO Moo Moo MoO MoO MoO Moo OOO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO
MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO Moo MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO
MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO
MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO
MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO Moo MOo
MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo
MOo MOo MOo MOo MOo Moo MOo MOo MOo MOo MOo MOo MOo MOo Moo MoO MoO MoO Moo MOo MOo MOo MOo MOo MOo Moo MOo MOo MOo MOo MOo MOo MOo MOo Moo
OOO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO Moo
hello world
It uses newlines as delimiter I guess
I feel personally attacked that discord doesn't support syntax highlighting for chicken and COW
Nobody
But that's not the point!
Hey! When trying to add 2 numbers together it just adds the second number to the end of the first number. Example:
What i get:
1 + 1 = 11
What i want:
1 + 1 = 2
Huh?
Concat moment
^^

+num + +num
+1 + +1?
Yeah
That casts it to an integer? Interesting
Shouldn't (1 + 1) also get the same result?
Don't know the context
Me neither
as long as you handle the integers as literals
tysm
you probably should tell them why it happens before that solution turns into a standard for them
Well if he would log the var once he would probably see itโs a string
How to make a topgg api
It's already made, wdym
lmao
const translate = require('@iamtraction/google-translate');
module.exports= {
name: 'emoji',
async execute(client, message, args, command, Discord){
if(!args[0]) return message.channel.send('Plead pick the words you want to translate');
if(!args[1]) return message.channel.send('Enter a language');
//ั ััะฐั
ะฝัะป ัะฟะธะฝ
translate(`${args[0]}`, { to: `${args[1]}` }).then(res => {
const user = message.author;
const embed = new Discord.MessageEmbed()
.setColor('#FFE082')
.addFields(
{ name: 'Message', value: `${args[0]}` },
{ name: 'Translates to', value: `${res.text}` },
)
message.channel.send(`${user}`,embed)
//(res.text); // OUTPUT: You are amazing!
}).catch(err => {
return message.channel.send('Please Enter Text to Translate to English (example: n.translate ะัะธะฒะตั en to translate to english) all language codes https://cloud.google.com/translate/docs/languages');
});
}
}
im trying to make a translate command that translate more then just <language> to english
but whenever theres 2 words in the sentance your trying to translate it picks that up as the language instead of the actual language provided
is there a way to make it so it only picks up certain word as the second args
all thats doing is translating the first word you type
hence the args[0]
it would be better to enter the language first, so [language] [message]
but if u wanna do it ur way, u can check for a character like | or something.
to differentiate languague frommessage, so french | i am 5 years old
@quiet pawn
yw
in d.js v12
I have a small question
var botName = config.botName; //This is alpha
So in my mongooes DB I am trying to get the prefix saved in a filed by doing this ...
data.guild.prefix.botName //where botName === alpha
Can someone tell me how to fix this?
Basically I am trying to do this
data.guild.prefix.alpha
but by using
var botName = config.botName; //This is alpha
what
...
Of ...
I am trying to get the value stored in
data.guild.prefix.alpha
but I am trying to get the name of the bot from the config
what is data.guild.prefix.alpha
this has the prefix of one of my bots
hold on
var botName = config.botName; //This is alpha
data.guild.prefix.botName //where botName === alpha
Nope cause I am having 4 bots
I will have to change that in 4 places
so I am trying to make it simple
on the "user" page it would be necessary to add a <br> because it is too close to the navbar
if u want it to be all the same, u can create a function and then it'll kinda do it at once?
data.guild.prefix[botName]
Should there not be a .
thats not doing anything
thats another way
thats not going to change anything,
no
data.guild.prefix[botName]
// is the same as
data.guild.prefix.botName
No, it's not
It isn't
๐
prefix is an array?
true
depends

This is how it is
@heavy marsh try it and see?
then you probably want the bracket notation solution
That's like saying { [key]: "value" } is the same as { key: value } which isn't true
defining and accessing are different
how is it different?
Then your point would be data.guild.prefix["botName"] is the same as data.guild.prefix."botName"
const botName = "botName"
botName can be a string
Seems to work
botName is a string. But searching for
data.guild.prefix.botName
means searching for the botName key, not the botName variable.
That's why you do
data.guild.prefix[botName]
oh yeah
You're welcome
then theres me thinkin prefix is an array for whatever reason
it would only be the same if const botName = "botName"
Nope...
You'd still have to do it that way
or
wouldn't data.guild.prefix.botName === data.guild.prefix[botName] if const botName = "botName"?
Are you trolling
Edit: I'm just stupid, yes, that's correct
Yeah but why bother with the const then? That's a pointless argument.
botName in data.guild.prefix.botName doesn't refer to a variable, but a property inside data.guild.prefix
var banana = "botName";
data.guild.prefix.botName === data.guild.prefix[banana]
that's how i messed up though. i just went through that example in my head and was like, yep they are the same
Except they're not
this should say Yep...
No it shouldn't
hmm
Anyway it's 1am and I don't have the energy to explain ๐ go read the docs
This is true right?
Yes
ahh ok
then you made a mistake here
#development message refers to #development message
data.guild.prefix.botName = "botName" would also need to be true
No I was using my comment as proof in response to this message
This has literally nothing to do with the original question
It's the 5th
dang
5th depending on timezone
The guy wanted the value of the alpha key and had "alpha" stored in the botName variable.
i am confused how this is wrong
Because the first one is looking for the botName key. And the second one is looking for any key in the prefix object with the value of the botName const.
It's correct in that example, but change the value of the botName const and it immediately becomes false
that's the point i was making
only true if const botName = "botName"
But doing const botName = "botName" is pointless in that case ๐
but it was the example that messed me up
This is a clearer example of what you were trying to say
yeah, anything besides const botName = "botName" doesn't work
Does anyone know how to stop undefined from spamming?
do you own that bot?
Yes its mine
Does that only happen sometimes?
Yes - always on shard ready
module.exports = async(client, guild) => {
const guildcount = (await client.cluster.broadcastEval(`this.guilds.cache.size`)).reduce((acc, guildCount) => Number(acc + guildCount), 0);
botjoins.send(` Left guild **${guild.name} \`[${guild.id}]\`** \`[Now in ${guildcount.toLocaleString()} servers]\``)
client.logger.log(`[GUILD LEAVE] ${guild.name} [${guild.id}] [Now in ${guildcount.toLocaleString()} servers]`);
};
Its the guildDelete event
Then you're receiving partial guilds
Try logging the guilds and see the available properties
Yep
Is it a bug?
you must get the guildDelete event after the fact. if the guild is in the cache then you get it otherwise you cant get it
Correct
Those might be unavailable guilds. Check if the guild is available before posting the leave message
if(!guild.available) return
what are unavailable guilds?
Server outrages
It's guild.unavailable isn't it
i need to go fix a bug
No it's guild.available
On API docs it's documented as guild.unavailable
i mark the guild as deleted in my database when i get that event
I guess discord.js does it opposite
Unavailable guilds are partial so that would probably explain the undefined part
so now i must have marked a bunch of servers as deleted when they were just having an outage
how common is that?
Yeah discord.js does guild.available
๐
i wonder how many times i've marked a server as deleted because of an outage
When does slash commands come ... to d.js
Trust me I learnt the guild.available problem the hard way ๐ once my bot got stuck in a crashing error loop while I was asleep which smashed into the rate limit for connecting to Discord and locked it out for 24h ๐ฌ all due to an unavailable guild
oofs
Restarting my bot now
sounds like a fun time
If you've done it properly and you don't get the undefined messages now then they were just unavailable
lets see it now
are unavailable server also servers that installed our bot and then the server itself was deleted?
nope
server = not available due to an outrage
An unavailable server is a server that's unavailable due to Discord outages or rate limits and stuff like that
like member limtes
Yeah
Fixed it thank you!
No problem!
That's kinda overkill but kinda hot at the same time
Yeah
cause mine is on 10k+
What are you using for clustering?
its a new npm
Ah yes I saw that
I didn't want to use it since it's brand new
Hard to know if it'll be maintained or die in 2 months
Mhmm
how do i get the response from a post request in node fetch?
i made the router from express to do res.send() but how would i get that sent string?
this is what it logs
Node fetch as in node-fetch? You have to call await response.json() etc.
imma try that thx
how would i do that with strings tho?
only works with objects :hmm:
await response.text() is safer if the response isn't a JSON. If it is, then you can parse it yourself
oooohhh ok pog thx
who the fuck made this package
if its good i might implement it in a 50k guild bot as im stuck with a shit cluster module and would save me time writing my own clustering module (though thats probably still the best idea)
just use modular libs like https://github.com/AmandaDiscord/CloudStorm and/or https://github.com/AmandaDiscord/SnowTransfer
eliminate the need for managed libs and blame yourself for shit code more than you might already do
would've sounded like a good idea a while ago when the bot wasn't powered by 50+ files
i like the fact it uses worker threads for individual shards
Totally didn't just spend the last 2 hours confused out of my mind before realizing that I forgot to enable an intent...
lmao thats me sometimes

mostly bc i didnt add the intents at the Websockets options
what permissions does a discord bot need for message embeds
if a guildDelete event happens and guild.available === false does that mean the guild still has the bot installed for sure?
its EMBED_LINKS right?
yep
imma try communicating with discord's api from scratch 
You might find this helpful: https://github.com/tim-smart/droff/blob/main/packages/droff/src/types.ts#L717
Example of how you could use it: https://github.com/tim-smart/droff/blob/main/packages/droff/src/rest/client.ts#L75
Using axios here, but you could swap it out for fetch.
What the fuck
Meanwhile in JavaScript
for(i=p=0,c=1;;p=c,c=i,i=p+c)console.log(i)
Meanwhile ruby be like
puts (1..20).inject([0, 1]){|Fibonacci| Fibonacci << Fibonacci.last(2).inject(:+) }
Meanwhile in C++
#include<cstdio>
int main(){for(int i=0,p=0,c=1;;p=c,c=i,i=p+c)printf("%d\n",i);}
Yo does anyone know any modern/reliable ways of converting xml into js object/readable format
XML to JSON converter online
They probably want a library
Perhaps
sorry yeah I was thinking more or less programatically
There are libraries on npm to get this done for you.
yeah just wanted to see if anyone has a good package or anything lol
@earnest phoenix thanks it seems like that's the best option
What discord.js version are you using?
v12
guildSettings,
guildSubscriptions
] = await Promise.all([
this.client.mongodb.fetchGuildSettings(message.guild.id),
this.client.mongodb.fetchGuildSubscriptions(message.guild.id)```
```Cannot read property of fetchGuildSettings of undefined```
what to define fetchGuildSettings?
const isPremium = guildSubscriptions.some((sub) => new Date(sub.expiresAt).getTime() > (Date.now()-3*24*60*60*1000));
const aboutToExpire = isPremium && !(guildSubscriptions.some((sub) => new Date(sub.expiresAt).getTime() > (Date.now() + 5 * 24 * 60 * 60000)));
Not sure about why that happens, it probably doesn't return null, you might be using the incorrect message instance or something to do with your intents
Are you using the dev branch or the normal stable branch
the thing is im in the bot's cache
v12 is the stable branch
I know, you could still be using the dev branch; I don't think the version was bumped at all in the dev branch
Then yea, probably the thing I said other than the branch
the intents intent is to drive people insane

today i found typing (_ => {})() into chakra ui's editable examples on their docs crashes the website
whats that 
select menu
weeb
shoo
the different coloring of field text and titles makes it look bad
put english in the field title and japanese in the description 
and give the bot nitro so they can send 4069 letters long text
I'm pretty sure got loads of copy pasta when I share this repo, but hey w/ever
is this work when bot cant have permission in server but it cant crash
.catch(err => console.log(err));
any one tell
not enough context
he never gives context
most users don't
So I've been wondering how do you get the database ping
hello
fetch a useless object and see how long it took
Can someone tell me where I can make my bot where it hosts 24/7?
Rent a VPS
Err is there a free way?
nope
People told me they host for free on Heroku.
you'd have to hate yourself, your mother, your father, your family, your life, everyone around you, the entire world, life itself and have died been reincarnated and died again, gone to hell, come back, jumped in a pit of spears, climbed out using a ladder made of needles like something out of saw and then fallen back in to want to host a discord bot on heroku
heruko is a good option for personal bots, i.e. bots which aren't meant for a lots of guilds
^ partial repost
heroku is not good for bots
even glitch works as a good testing environment
Heruko is a hosting service, why would it be bad for bots?
I've had a few personal bots hosted on heruko
Why is Heroku bad for Discord bots? I don't have any experience with Heroku, just curious.
Guys
Girls
How do I use a proper image for my not page background?
The images I used rn are not full they do not fit the page and look bad
for your what page?
I need a good image which fits the page
Host on RPi4
pixabay.com is a good website to find pictures
I used the backgrounds from there for my newtab page
Does unsplash require attribution?
Sometimes. I tells you when.
I am on phone and my phone is laggy as fuvk so can u send me a good space background image for my bot page?
Sometimes they say "It would be nice", and sometimes they say "You have to attribute the creator".
How do we know what is a good image for your bot page?
I don't even know what your bot does
I just need a space background
Pls
Ok lemme get some
My phone is laggyy
just buy a new one
You can use this link https://i.imgur.com/Bs0o9l9.jpg
l
Tyy but will this fill my entire bot page? Like it won't repeat?
You can use css to prevent the repeat
@hidden coral Are you using CSS to do this? You just have to do
background-size: cover;
background-repeat: none;
Yes you can also do it the shitty way 
background size didnt work for me
Background size only works if you actually use the background-image attribute to show the background and not a img tag.
i did use background prop
This will also warp the image.
object-size: cover;
Use this to fix that.
i needed it to fill the entire viewport so
background-image: url('https://imgur.com/a/UPcScxj');
background-size: cover;
background-repeat: none;
}
``` This would be the code?
Oh ok
stupid question but how do i hide files in GitHub 
@errant flax What do you mean? Do you want to ignore the file from being pushed to the repository or do you want it to be private?
You can either use .gitignore to ignore files from being pushed at all (like environment variable files) and you can make you repository private to hide the entire repository from the public.
like i have a config.json file i wanna hide that form ppl
If I change the link to the new one which u send then?
how does .gitignore works 
im new to GitHub
like what content/code do i need to enter
@errant flax You should add the config.json to a .gitignore file. Config files should never be pushed to github. What I then normally do is make a example.config.js file that I do push to the repository that is then a template for when I install the code somewhere new.
@errant flax You create a .gitignore file in the root directory of your repository folder and just add the path to the config.json in that file.
Path relative to the .gitignore file
So that would probably just be config.json if the config.json file is also in root.
how do i make sure ppl dont actually see the file 
You can't hide one single file in the repository. You have to make it so you don't push it to GitHub.
And you do that by using .gitignore.
.gitignore is also being used to ignore node_modules directory for example.
Pluralsight Guides
gitignore doesnt "HIDE" files
It ignores them
it just prevents them from being uploaded
exactly
git is basically just a clone of ur code
And you also have to delete the files first if you add them to ignore after you've already pushed them.
if u dont want to upload a file, add them to gitignore.
Because otherwise git will ignore the fact that you deleted them 
The easy solution would be to make your entire repository private
Either ignore it or encrypt it.
It isn't uncommon to have your config encrypted
And then you need code in your project to decrypt the config since your project needs config variables and so you provide people a way to decrypt the config you encrypted so they couldn't read it? O.o
Doesn't make sense in my 4head
Quite often a framework will only require a decryption key as the only external config item, and then you don't have to keep updating your production environment when you add more sensitive config etc.
But then we are talking specifically about config.json files that contain configurations that are not environment specific?
Yeah, if it isn't sensitive then a plain JSON is fine.
Things like tokens and keys need a different strategy.
what does this means
The json inside config.json is invalid.
wew "message" event is deprecated for master branch

wait does .gitignore applies to the owner/collaborator of the repo 
@spare badger
Hey could u just go to my bot page and send me an ss of what you see pleased?
isnt that advertising 
Bruh i want to see how my not pages looks
bro
thats the dumbest excuse ever, you can see your bots page yourself
just because a bot reviewer sees it doesn't make it different
^
^
No I want to see how it looks
In pc
I am in mobile
@sly sierra @slender thistle @clear marlin
how do i disable mentions in a message like i want to display it like it mentions a role but it doesn't actually ping the role
allowedMentions
can u give an example
Integrate your service with Discord โ whether it's a bot or a game or whatever your wildest imagination can come up with.
im using djs
Vague question
wow im getting starred noice
If you want to disable mentions for all messages, you can pass that to your ClientOptions
How do I edit the vote button on my bot page and make it like better?
Where exactly? Your bot page or on top.gg/bot/id/vote?
discord js uses discord's api, look at the docs

what i sent you IS relevant to your question
How's my newtab lookin'?
Unfortunately Opera doesn't support chrome_url_overrides because "malicious extensions"
What does threads mean in hosting
Because I was looking into hosting and I stumbled upon CPUs and threads
Which now I am confused
any help about making a autospawning bot like pokecord/poketwo?
1 core can normally handle 2 threads
threads are basically "parallel" processes
kinda like a highway with multiple lanes
when hosting companies mention cpus and threads, they mean physical cores and logical cores
for example a 4 core intel cpu with hyperthreading will show as 8 cores in your task manager
thats what they're talking about when they mention threads
How do I get the owner of a server?
I used: ```js
const { owner } = guild
in v12 but it doesnt work in v13 now
owner was removed in v13
Use guild.fetchOwner()
you have to use guild.ownerID in combination with guild.members.fetch()
oh they added fetchOwner?
Yeah
cool
that guy is addicted to discord lol
yo, does anyone know why im gettin this error: TypeError: Class extends value [object Object] is not a constructor or null ?
the code is just js class Position extends Core { ... }
and Core is require('../core/Class');
and that is...
how do you mean that?
class Core {
constructor() {}
get random() {
return 'hi'
}
}
why did you put an empty constructor there?
just use what flazepe said, its the same thing but it does it for you
like i am gonna need it, but not yet
make sure to await it
how did you export Core?
module.exports = Core;
and i added something to the constructor but still nothin
well not nothing
and how did you import it?
is module.exports = Core after the class Core?
yeah
can you console.log(Core) after requiring it?
const Random = require('../structures/Random');
const random = new Random();
const generator = require('../../../index');
class Core {
constructor() {
this.generator = generator;
}
get random() {
return 'hi';
}
}
module.exports = Core;
^ class file
just an empty object
?
import sequence: index -> core -> index -> core -> index -> core -> ...
welll, at some point yeah
If so, that's a circular dependency
you have a circular dependency yeah
module.exports = {
name: 'member',
run: async (client, message, args) => {
const array = [];
message.guild.members.cache.forEach(m => array.push(m));
message.channel.send(
array
.slice(0, 2048)
.map(m => m.user.username)
.join(', ')
);
}
};
if any of those requires for some reason end up requiring the file that requires Core
then Core will never finish loading
You should slice the joined string instead
it will keep requiring files in a circle
How?
i get what ur sayin
.join(" ,").slice()?
but i dont understand lol
u can view the code at https://github.com/OfficiallyLost/random-generator
idk
random.js requires index
position.js also requires index
idk man
oh
so how do i like
get the random generator object?
Pretty much, I guess. You'd better paginate it though
cuz i cant create a new one bc then it'll be the object yeah, but it wont show the correct data
the correct way is to do this
this.core = new Core(this)
hello is any way it cant send message in terminal it send in server .catch(err => console.log(err))
in the Core class or the main RandomGenerator class?
in the randomGenerator class
tim can you help me
then you will get an instance of RandomGenerator as the argument in the Core constructor
which then you can also pass to Position or Random
hello
i dont understand what is the issue
so i import lib/index ?
no
i think he means discord server
i mean when error comes it say in teminal is not way it send in server
.catch(err => console.log(err))
oh
then does new Random(argument from Core constructor)
any one say free bot hosting
then make it send in the server
i recommend https://libraryofcode.org
thats a probleam
err => message.channel.send(err.toString())
so i do ```js
this.core = new Core(this);
this.random = new Random(this);
But it doesnt work
?
Ohh okies
ask there, not here
is that free host
So what should I look for when buy/choose a host?
is Core supposed to be instantiated?
ok
depends on what youre making
yeah
show code
Bot?
...that doesnt narrow very much
the main things are cpu and memory
for starters, 1 cpu and 1gb memory should be enough
you can get that for 3-5 $ a month
Got it! Thank you!
Did discord api changed .Since same code returns :
DiscordAPIError: Cannot send an empty message
How to get things serialize from array
Like
Math.floor(Math.random() * array.length) but this gives random
huh?
discord.js changed
if you updated
Code:
let exampleEmbed = new MessageEmbed()
.setColor('#ff9900')
.setTitle('Ping')
const m = await message.channel.send(exampleEmbed);
let exampleEmbed2 = new MessageEmbed()
.setColor('#ff9900')
.setTitle('Ping')
.setDescription(`Pong! Latency is ${m.createdTimestamp - message.createdTimestamp
}ms. API Latency is ${Math.round(message.client.ws.ping)}ms`);
m.edit(exampleEmbed2)```
Maybe send({ embeds: [exampleEmbed] });?
Prob as well need a desc
I am using "discord.js": "^12.1.1",
Desc for?
Try updating
code looks correct
i know discord deprecated embed but they didnt remove it
it should still work no?
Try channel.send({ embed: exampleEmbed }); then
updating didn't work let my try the upper method
ah, maybe it only works with another field
if they changed it to require embeds, then embed would not work alone
only in combination with content or file
Wait so bots can send multiple embeds in a single message?
yes
Yeah
lol what I need a message content ๐ซ ,let me try it
cool
You don't need content
The char limit remains the same is kinda uh 
discord.js doesnt allow you to send nonexistent params
embeds doesnt exist in v12
so you cant really send it using embeds
Ah
m.edit({embed:exampleEmbed2}) worked
It's on master iirc
huh so embed still works after all
I have no idea what they updated since I don't use it anymore
Will be removed on v10 afaik
v10?
API v10 ig
Yeah, source: devsnek
Wait, they removing embeds?
embed in favor of embeds
Hi.
data.dailyMultiplier += 0.1;
.. is making it 0.100000000000000000000000000001
.. I forgot the method with inputting 2 arguments to set the amount of decimals.
ye, that's how floating points work
What was the method called though?
method for?
Locking the amount of decimals to 0.1 instead of 0.1000...0001
you cant
U round it
that's how floating points work
Method name?
0.1 will always be that bugged value
Round...
Method name.. ๐
Math.floor(x * 10)/10 iirc
oh lul, api versions are moving so fast now, it was v6/v7 for like 4 years
Are they removing embeds?
Or what were u gus talking about
Like that?
The embed parameter in favor of embeds as flaze's mentioned
I think thats how u do it ye
removing embed and replacing it with embeds
I remember a method like .someMethodName(x, y)
Bruh
Clamping values?
toFixed(), if you want a string
Max?
Integer.
It's decimal though..
@quartz kindle Hello how to check if a user has voted or not. Discord.js btw
I want to add 0.1
Like I showed earlier
yes
This
U can change it to ceil or flior depending on how u want it
top.gg sdk
ohok
alright
So itll be send({embeds: embed}) instead of send({embed: embed})?
No
What...
embeds: [embed]
toFixed returns a string
But why
Shi-...
because messages can now have multiple embeds
Oh
embeds:[embed1, embed2, embed3]
Oh well thats pog
๐ ๐ ๐
I legit sent u that earlierโฆ.
Yes, dude I didn't forget you.
I just opened scrimba to test it out.
Managed.. thanks all.
why do you need the accuracy
hi
const superagent = require("superagent");
const generating = new MessageEmbed()
.setColor(black)
.setDescription("Generating a duck picture...")
let msg = await message.channel.send(generating);
let { body } = await superagent
.get(`https://random-d.uk/api/duck`);
//console.log(body.file)
const noBody = new MessageEmbed()
.setColor(red)
.setDescription("โ An error occured as I broke, please try again!")
if (!{ body }) return await message.channel.send(noBody);
const embed = new MessageEmbed()
.setColor(black)
.setImage(body.message)
message.channel.send(embed);
msg.delete();
did I do something wrong in .get
A good read if anyone is interested
newer versions are relatively ok
but if you use php today you're just a dumbass lol
modern web frameworks blow php out of the water
"**Owner:** " + "<@" + guild.fetchOwner() + ">")
The method returns a promise
Await it
Just get the owner id if you wanna mention it
You can use Owner: ${await guild.fetchOwner()}
now it doesnt even respone:
const owner = await guild.fetchOwner()
You don't need the entire object to mention them
guilds should have an owner id property
and that means?
the way you mention users is <@UserID>
You're right oml
yes but I have to get the owner first bevore I can do anything with it
And thats not the case
what info do you need about the owner other than their ID
if you don't need username, discrim, avatar or any actual user info, just use the Guild's owner ID property
Fetching more users just leads to more memory usage, which is highly advised against
Guys how do I make the vote button on my bot page look better?
ah thx it works
you can edit the bot's page?
target the css classes the buttons inherit
you can inspect element to look at classes
even edit in browser until you find settings you like
Yea but I want to use custom css for the vot button to make it look cooler
But I I on phone so I can't inspect
A small code just for making it look like a blue rectangle would do pls
Idk if you're able to use css to style buttons outside of your bot description but you can select the button using
*[href="{your bot id}/vote/"] {}
yes
I understand
You can apply this css selector to style it
The vote button doesn't have an unique class or id so selecting by href attribute is the best way
@hidden coral
So I have an API with the express framework, I am trying to post stats to the endpoint but I am getting the error: (node:12) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'authorization' of undefined
It is the same code as my other endpoints for requesting the authorization header but they do not throw this error, they return 401 if its missing or continue if its not.
If I try to console log req.headers['authorization'] it just causes the issue to occur still. Code below
https://haste.thecutefoxxy.com/yeuchemhla.js (API Endpoint Authorization Check)
https://haste.thecutefoxxy.com/lgejrldopn.js (POST Request Code)
https://haste.thecutefoxxy.com/ayulpflefp.js (API Logged Headers)
Yes
you have swapped the parameters
the first parameter is the request, the second is the response
It says it cannot read property "authorization" of undefined so req.headers is undefined
^
unless you call the function yourself and don't give it to express
line 2 of first file, req.headers is undefined
You probably swapped request and response
res is your request
yes
Ye, I noticed ๐คฃ
Also you shared your token or whatever it is so you might want to change that
๐คฃ its just a random string I made lol
its not the actual token, the actual one is in a DB
but thanks ๐ I am gonna go back to bed
Why is every UI framework blue.
why this failed
are you sending a response?
Ah buttons. Something I hate. They never work for me. No idea why tho ๐
not working in what way?
getting interaction failed, or not getting the events?
interaction failed
not showing any errors in the console when i hit it
it just says that
okay, are you responding to the button?
all button presses need some sort of response to the button press itself.
or well, what library are you using for buttons?
discord-buttons & discord-button-pages
if you add this somewhere the interaction failed issue should fix itself.
client.on('clickButton', async (button) => {
button.defer(true);
});
all button.defer(true); does is say "i have nothing to say to this right now"
can es6 npm modules run with react?
anywhere client is accessible
...sure?
react is just another library





I am not checking response headers though