#development
1 messages · Page 1807 of 1
i see now
i thoughbt you meant like
make 2 rows like i have there then
message.channel.send('Message', row, row2)
nah, its all part of the same message object]
i hate that format to be completely honest
Wait Erwin weren't you against message embed builders, now ur using button builders 😬
cuz they parse the emojis for me
🤔
lol
<a:name:id> => {animated:true, name: name, id:id}
lol
ah
I mean you can make a function which does this
could yeah, but the lib already has it
im willing to lose a few microseconds there for that extra parsing
the others are just there for consistency
so its not half builder half manual
also, feud, i think you were the one asking how i ported the reaction collector to buttons
thats how i did it lmao, you can literally see my old reactions in there as customId's
insanely easy port

payload.reaction.name => payload.interaction.customId
that was about it
Hello, i have disabled the PRESENCE intent for my discord.js bot. Now i randomly get these errors. Anybody knows how i can fix? I thought about disabling the INVITE intent too, although i thought about using it in the future.
can you provide the code
I think its because of the missing intent
which one?
not necessarily, it means you're trying to access id of an undefined variable
that stacktrace helps little since it's all internal calls
was it working before you disabled the PRESENCE intent?
yeah
Hm.
is that all of the thrown stacktrace?
what djs version are you using?
12
full version
run npm ls
did you disable the intent both on the dashboard AND the client builder?
do you do anything to your channels? delete them from the cache or something?
It seems to be happening here, but disabling that intent shouldn't affect this
so i put "12.5.3" in my dependencies?
just run npm install discord.js
npm i discord.js@12.5.3
maybe in dependencies it translates "12" to 12.0.x ?
ok so i will put '^12'
if you uninstall it and reinstall it, it does that by default
you can also do what cosmic said to install a specific version
npm i discord.js@latest or npm i discord.js@12.5.3 should work
isnt it better to put into the package.json?
does specifying 12.5.3 removes the ^ from package.json tho?
Probably, as you're installing a specific version
you can put it in the package.json, but that wont do anything by itself
you have to actually run npm install
also sometimes your package-lock will override it
so i did npm install before npm ls
I think its better for you to do a clean install, which means you gotta remove both of the package-lock.json file and the node_modules folder and run npm i
that sounds nice
i usually just do npm uninstall djs then npm install djs
That would work, I recommended that just in case if any of their other installed dependencies are outdated as well
run npm outdated
ok i will try that later, for now i have to let my bot run because users get pissed.
I guess i can excpect that updating will break other functionalities too?
possibly but most of it should be fine
djs is not known for doing breaking changes on non major versions
check the release docs
ok thank you very much so far. at the moment i have the shards starting up with the "disabled invites intent try", but later i will test it with the new update in any case.
👍
npm update is cool
too cool, but sometimes it could be overrided so it refuses to update to the latest versions
Clean installs 

klin
<Message id=862355849417719839 channel=<TextChannel id=272764566411149314 name='development' position=11 nsfw=False news=False category_id=355951029025636362> type=<MessageType.default: 0> author=<Member id=180112943612952577 name='Tim' discriminator='2373' bot=False nick=None guild=<Guild id=264445053596991498 name='Top.gg' shard_id=None chunked=False member_count=186793>> flags=<MessageFlags value=0>>
<Message id=862355855580332092 channel=<TextChannel id=272764566411149314 name='development' position=11 nsfw=False news=False category_id=355951029025636362> type=<MessageType.default: 0> author=<Member id=812465886098620476 name='mmmax' discriminator='0003' bot=False nick=None guild=<Guild id=264445053596991498 name='Top.gg' shard_id=None chunked=False member_count=186793>> flags=<MessageFlags value=0>>
<Message id=862355897871237160 channel=<TextChannel id=272764566411149314 name='development' position=11 nsfw=False news=False category_id=355951029025636362> type=<MessageType.default: 0> author=<Member id=812465886098620476 name='mmmax' discriminator='0003' bot=False nick=None guild=<Guild id=264445053596991498 name='Top.gg' shard_id=None chunked=False member_count=186793>> flags=<MessageFlags value=0>>
<Message id=862355909413044234 channel=<TextChannel id=272764566411149314 name='development' position=11 nsfw=False news=False category_id=355951029025636362> type=<MessageType.default: 0> author=<Member id=180112943612952577 name='Tim' discriminator='2373' bot=False nick=None guild=<Guild id=264445053596991498 name='Top.gg' shard_id=None chunked=False member_count=186793>> flags=<MessageFlags value=0>>
@rustic nova
<Message id=862355930044956712 channel=<TextChannel id=272764566411149314 name='development' position=11 nsfw=False news=False category_id=355951029025636362> type=<MessageType.default: 0> author=<Member id=180112943612952577 name='Tim' discriminator='2373' bot=False nick=None guild=<Guild id=264445053596991498 name='Top.gg' shard_id=None chunked=False member_count=186793>> flags=<MessageFlags value=0>>
LOL
lmao
<Message id=862355940207230986 channel=<TextChannel id=272764566411149314 name='development' position=11 nsfw=False news=False category_id=355951029025636362> type=<MessageType.default: 0> author=<Member id=812465886098620476 name='mmmax' discriminator='0003' bot=False nick=None guild=<Guild id=264445053596991498 name='Top.gg' shard_id=None chunked=False member_count=186793>> flags=<MessageFlags value=0>>
-b 812465886098620476 selfbotting
Banned mmmax#0003 (@sinful narwhal)
is that js?
Just for your info, disabling the GUILD_INVITES intent worked as for removing that error i posted further up. (Will still update the version soon)
the fuck is that
Does anyone knows a api, which creates transcripts in form of html as from Ticket messages?
👀 that seems very specific to something your doing.
true, I want to add a ticket system for my server...but the transcript are important
literally the dumbest way to get spotted
you could just generate html elements with the info u want
html is just text
hey
arnold
I'm getting this error: xl MongoError: MongoClient must be connected before calling MongoClient.prototype.db
yes yes
you can't access mongoclient before connecting it
Here's my code: ```js
require("dotenv").config({path: "path/to/.env"});
const uri = process.env.DBPASS;
const MongoClient = require("mongodb").MongoClient;
const mongo = new MongoClient(uri, {useNewUrlParser: true,useUnifiedTopology: true});
let bname = "Beyblade"
mongo.connect(err => {
console.log("MongoDB connected for Beyblade.js");
});
setInterval(() => {
mongo.db("main").collection("ids").updateOne({_id: bname}, {$set: {latest: datas[bname].latest}});
}, 600000);
const ids = mongo.db("main").collection("ids")
//const id = ids.find({});
class Beyblade {
constructor(name, type, image, firstOwner, id){
this.name = name;
this.type = type;
this.image = image;
this.firstOwner = firstOwner;
this.level = 1;
this.xp = 0;
this.specials = [];
this.passives = [];
this.aliases = [];
this.gen = 1;
bname = name || this.name;
if(id) this.id = id;
else {
if(this.name !== "Buddy Bey"){
}
}
}
async init(){
return true;
}
}
module.exports = Beyblade;
The commented part is where the errror lies
I believe it's already connected
no it's not
that's python ig,but kind of funny to see how it logs out message object
nani?
afaik database-related stuff aren't synchronous but async
so it doesn't necessarily wait for the database to connect before moving on
I see
how do i get it to wait for it to connect?
do you know callbacks work?
I've never really worked with them a ton
according to your code, mongo.connect takes a callback function
yes
do members in voice channels automatically get cached in discord.js?
like, on startup?
yes i believe so
you have an array of voice states on the initial guildCreates
not sure if they include full member/user data tho
ok thx
so I would have to place my code inside of the callback function?
that would be one option yes
why not?
well
i use javascript and promises with async await. thats one way how you can write more procedural code, if you dont like nesting functions.
alr
I have a question regarding infrastructure internally on a website that involves the back-end reading the HTML "skeleton" contents and replacing string values of {0} or etc. in the actual website application. Would this be a sound method? (Comments added in the code to explain what functions do.)
include_once __DIR__, "/vendor/autoload.php";
use App\Infrastructure\Internal\Skeletons\SkeletonController;
const SERVER_ADDR = "localhost";
# Class::__construct() asks for the HTTP route and page to read.
$webpage = new SkeletonController(SERVER_ADDR, "/index.html");
$tags = ["{0}" => "title"];
# Class::modify() is a basic str_replace() but for tags and formatting.
foreach($tags as $tag => $val) { $webpage->modify($tag, $val); }
echo $webpage->getContent(); # Class::getContent() is string return.
@green kestrel 🙏🏻 i ask for your master PHP guidance
because I know a lot of platforms use front-end and such ie. React, Express and etc. to handle this but I want to do it internally because with PHP scripting I can do this for things such as 1-page form checks, data tables being displayed, etc.
My discord bot is made of html,can someone help me?
What part do you need help with?
am I using it correctly?
async function connect(){
mongo.connect(err => {
console.log("MongoDB connected for Beyblade.js");
});
setInterval(() => {
mongo.db("main").collection("ids").updateOne({_id: bname}, {$set: {latest: datas[bname].latest}});
}, 600000);
const ids = mongo.db("main").collection("ids")
const id = ids.find({});
const datas = {};
Promise.all([id]).then(data => {
let beys = data[0];
beys.forEach(bey => {
datas[bey._id] = {
latest: bey.latest,
name: bey._id
}
});
console.log("Updated data!");
});
};
why not?
forEach has 0 advantages over normal for-each
but it does have some overhead since you're creating single-use anon functions
yeah I suppose this works but perhaps it's over engineered? PHP is a templating system as standard, you have the ability to switch in and out of markup as you please with near zero cost, frameworks like react aren't needed on PHP for this reason
I tend to keep my markup mostly in one file and code on the other and just pass vars between, basically model view controller
i see
I could use global variables instead and easily go in and out with <?= $_GLOBAL["value"] ?>
but it's a bit odd of an idea to me to do that
because there's certain elements i'd like to be able to dynamically control on based server events, esp. if i want something like an account system on my website
Someone know if sharding will fix that my bot takes 4min to ban one user on 250 servers?
const msg = client.channels.cache.get("836870311923417118").messages.fetch("862383984511418388")
console.log(msg)
Its giving me nothing
@rustic nova
it wont
the ids are correct?
ratelimits arent handled per shard, they are handled per token
help me
Oh damn, but it worked perfectly fine just yesterday and with 200 servers
read the message
You got any other idea that could fix it?
Sike
what message?
Cannot send an emty message, but the embed isn't empty
you cant send a message without content
it is
add a content or embed to it
you are DEF sending something empty
otherwise it wouldnt throw u that error
it might not even be coming from there
Suggestion: don't ban at once, ban them when they try to join
That works?
if they are in the server already, no
Oh yeah forgot about that
They aren’t yet
i assume you doing something like banning a user in all servers they are in
you gotta respect ratelimits or you'll be ratelimited, nothing that can be done there
maybe add helper bots
If they aren't present in a certain server, just ban them from that server once they attempt to join
but thats kinda stupid imo
Yeah ik
But can I set an automation for that?
they still gotta deal with the servers they are aready in, but yeah
for future proofing
add that person as blacklisted
and check every join
Cause that right there would mean that months of work and hundreds of dollars just got wasted
Yes, development and all isn’t cheap
I did
most bot devs are hobbists with less than 6 months of experience
Well competent for my budget
hundreads of dollars doesnt fit in the "idk how to handle bans"
but regardless
what SHOULD have been done is what hope said
Doesn’t mean I stent it all on him
ban the users in the servers they exist, and then add that user to a blacklist. on new member join, check if that user is on the database blacklisted, if so, ban them
no need to ban that users on all 250 servers your bot is in
im not seeing nothing empty in the embed, i did messege.channel.send(embed) so it has to send the embed
just gotta ban them on the 4 or 5 they are ACTUALLY in
Website, NDA’s, dev, staff, and so on
That’s possible? Just banning in servers the user is in?
of course
Oh
You are giving me hope
fetch if u dont
Got 750 mb ram
/guilds/guildId/members/id
then you dont wanna cache
thats too little to keep all users cached
Ok
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
i cannot believe i managed to load that website
So that helps with banning just in servers the user is in?
yes?
cuz you'd know if they are in the server or not
rather than banning them in a server they might not ever go to
ok i ran a debug, and then (i never used debugger before)?
read the rest
actually i have a pic up here somewhere
same error
a debugger wont magically fix code for you duude
it'll help you FIND the bug
hence the name, debugger
gotta love that d.js doesnt throw u where the request was made

Thank you so much for the help, gonna talk with my team about that.
aight, gl
anyone know what this is?
an error
an error /s


ik but do you know what it wants me to do
I guess currently not xD
currently not what?
bot.users.cache.size
add a .cache. between every users and size
How would I leave servers that are below 50 members? (discord.js)
client.guilds.cache.forEach((v,k,m)=>{
if(v.memberCount<50) {
v.leave();
};
})
don't forget to Implement cooldowns
alr thx
side note: that's a bad practice that'll put your bot's reputation in mud over time
You could Implement uncaching for small guilds
he's probably not verified yet for resorting to such measures
Someone made servers just to mess up my bots verification
someone made like 40 servers with no members
to bring me to 100 server limit
lol
thats some next level trolling
just get the guy's id and leave all guilds where the owner matches his id
I also wanted to leave more space for actual people using the bot
^
if people add your bot, they expect to have it stay there
even if it's only 1 time
doing that is bad for your reputation
i would rather leave Bot Servers
they like to collect for no reason a stupid amount of bots
yeah definitely leave bot farms
i would rather leave Bot Servers
Yeah and it’s easy to do
Just check if the server name contains specific words (like bot etc.)
Additional checks like bot member count > member count makes sense, too
actually, check if count > member * 2
I've met legit servers of people who didn't have a clue what bot they wanted and added a shitton of them
later on they did remove unnecessary bots
Does anyone have any bot feature ideas? Im too retarded to think of them.
I'm asking for a friend, is a globalban command against discord tos? Banning someone in 250+ guilds that aren't owned by the bot owner
If banning everyone thats a BIG i mean HUGE no no
Unless OWNERS permission
Let's say I had a bot in 250 servers, if I wanted to ban you from all of them I would jsut run a command, with the owner knowing nothing
no'
That is a major TOS violation
You need the permission from ALL the owners
how do I apply to get my bot veridied
can you help me find this in tos?
#support Check the pins
Dude, thats a no no
Even with the consent from all the owners?
ik that, can you help me find it he wont shut up to me about it
yes
The more you know i guess
doing something too much in a short timeframe is against tos
yk what they say, good ideas are priceless
I doubt someone will give 'em openhanded
god dammit
Can you send a screenshot of where it says it?
Jesus christ
No, go find it yourself @odd sapphire If your too lazy to do it then just get banned
It's not me I'm asking for someone
Then tell your friend to find it
how hard did you want it?
@odd sapphire https://discord.com/developers/docs/topics/rate-limits#:~:text=All bots can make up,per second during normal operations. Read it
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
idc
then i cant help you, bcs it could be to much
What would be too much
using AI to do stuff like Voice Recognition
That would take WAYYYYYYYYYYYYYYYYYYY too much precious RAM
nah
Its plausible https://www.npmjs.com/package/react-speech-recognition
last time ive used tensorflow js it used like 50-80mb
i know its possible, but you sort of want to do stuff with the voice recognition
What API did you use?
lol API
IDK
I have 0 clue how to write an AI
this is why ive asked how hard you want the suggestion
cough Skynet cough
Skynet would be AWESOME
besides from the death part
was funny enough the Working name for the bot
nah, the bot is already dead
Thank you good sir for the idea, i am going to implement it once i make money.
people try too much to have new ideas instead of thinking what people need
business rule #1 is: your product must fulfill someone's necessity
I have.
I need fun features. That is why im asking the general population to get ideas people WANT or NEED
That's a question better solved yourself.
I cant possibly solve it im not the users, im the owner.
The services many people use today are derived from others' work (inspiration) or original ideas by a single person or small group. The idea wasn't crowdsourced.
hey
While you think you can't answer it since you're the owner, users won't know what they want.
So it's up to you to figure it out.
i actually forgot how to create an exe file for my js script.
is there any documentation or tutorial online?
JavaScript is an interpreted programming language.
You don't build an executable off of it.
Unless you're wack
woopsie
i guess it would be easier for people who didn't have any programming experience
If you're using Node.js, for example, you run a file with node ./file.js
to just boot up an exe instead of debugging and starting it etc.
yeah that is also possible
It really depends.
research
just like big business do
There are advantages in categories like interpreters, transpilers, compilers, and virtual machines.
The big advantage of projects compiled to machine code is the user needs less of the software, but it may also be larger, harder to port, etc.
make a market research, see what has too much offer and what has too much search
For the most part, it depends on who's running the software. If it's just you, using any on the list is fine since you're the only one paying the price. If it's on a user's computer, you should consider what you want from your users.
how can i catch a certain error, such as: bla bla bla is not iterable, and instead of that, actually logging something else too.
Like how can i detect a certain error
try {
// try doing something
} catch (error) {
// handle error here
}
You'd catch the abstract error and try to validate it. However, JavaScript errors are generally not made for machines to interpret, so users choose to do something on any generic error (Kuu's example) over trying to parse the error and see what it's about.
Yeah i am already catching the error, but can i like check whether a certain error occurs and then start an event
would that just require an if statement after i caught it
catching an specific error might be hard since js is non-typed
aha okay
But the best programs are those that don't require try/catch logic
got em, won't do it then. Thanks guys!
Yeah i figured so.
Curiously, how do you handle errors in Javascript?
I just check the state
You wouldn't just pass a user's first argument to fetch by ID. You'd parse the ID and see if it failed
Not sure if I follow...
What would you do if this fails:
const user = await fetchUser(id);
basically you need to guess what error will pop inside the scope
BTW I don't use try / catch either, but curious to see what others do.
try-catch in js is quite rare given almost everything is async
Well, async / await kinda changes that.
and stuff a try-catch might grab are obvious errors
await <Promise>.catch(err => handle here)
You will still need to put a conditional on the result if you wanted to short circuit the flow.
Which is the same as a catch block really.
But I think using .catch would make the code read better.
it's more streamlined and you'll be dealing with each promise individually
also helps locating where the error happened
I would treat it as a generic error and say the user couldn't be fetched. Let's think of args[0]. Maybe you have an isSnowflake function that returns true/false if it's a snowflake.
The genericness comes from the error returned from await fetchUser(id). Did Discord fail? Did the user exist? Was the ID rejected regardless of my isSnowflake function? The goal is to avoid making assumptions.
I don't like try/catch/finally since it interrupts the flow of the program imo. It's very bulky, verbose, and allows for multiple errors of different types to be caught. Some languages make it easier to tell the source of it (e.g. a Rust enum)
But as I was saying, you would still need if statements or something:
const result = await fetchResult().catch(console.error);
if (!result) return;
try/catch, not quite as nice IMO:
let result: Result;
try {
result = await fetchResult();
catch (err) {
console.error(err);
return;
}
Or you rethrow the error with a more useful message.
Well, whether you use Promise#catch or try/catch or whatever isn't relevant to what your saying.
But I agree, that errors should be as specific as possible.
Im very retarded right now
Im trying to add a variable im outputting from a for loop to another variable, how do i add them to one another over and over so the output of ALL the for loops is added up?
so in my discord lib im going from current version 1, to the next release being version 9.
this is because im changing my major version to always match the version of the discord library the lib is using.
this means that when the next release comes out with threads support, officially the discord api version will be 9 so the next version of D++ is 9.0.0. the minor and patch version numbers are based on the features we add and fixes we make still.
anyone think this may be confusing to users, seeing us jump from 1.0.3 to 9.0.0? i think its going to take some explaining in the readme and in the release announcement?
i ask because no other discord libs are using this version numbering scheme and i think it makes some sense to
theirs was based on a year though, wasnt it, or something? or a language standard version?
does c++ have a package manager? the only reason for sticking with proper semver is because most package managers will never auto-update major versions due to breaking changes. If you put breaking changes on a minor version and then your package manager autoupdates it, it will crash your process
C++ as a language does not, no
theres a non-standardised mish mash of platform specific package systems such as vcpkg, chocolatey etc
whatcha think
all with different versioning policies
it think its fine for the most part
Written in Node
just be very clear whenever you push a breaking change
ye
but sometimes there could be a breaking library change
if an idea comes up, if a change of direction happens
etc
I think you should manage your tabs better.
wdym>
It's current based on their release schedule (every few months). Every few months, they'd release a new version of the language as 1.x.y, then decided to just use x.y.z.
this will be fun.... new caching controls in D++, lets see how low i can get a triviabot cluster to run at
/* Set cache policy for D++ library
* --------------------------------
* User caching: none
* Emoji caching: none
* Role caching: aggressive
*/
dpp::cache_policy_t cp = { dpp::cp_none, dpp::cp_none, dpp::cp_aggressive };
/* Construct cluster */
dpp::cluster bot(token, intents, dev ? 1 : from_string<uint32_t>(Bot::GetConfig("shardcount"), std::dec), clusterid, maxclusters, true, cp);
yes
do you use a pool allocator or something like an malloc replacement for allocating thousands of small things?
or just the regular malloc/new?
wait if i changed my js file to ts wouldn't that work 
Huh
such a dumb idea but if i rename the file and replace .js to .ts wouldn't that work 
idk why i thought such of a dumb thing
I mean... it depends?
Without strict mode it should work.
what is strict mode?
i hate working on other people's code
a client on fiverr asked me to fix a bug in a js bot
and uh
this entire code is one big bug

wut this
I think without any configuration set, it is turned off to start with.
this shouldn't be hard right i mean ts is just js
anyways time to make a new app
Yeah this is a case, but it will give you lots of warning messages potentially.
But it will error if it spots a bug in your code.
inb4 runs node index.ts
ye lol just realized

oh ok ts gave me an error which i didnt noticed 
Oh btw, you're 18 now (a month ago) right?
yupp
nice, 142mb for a 10k guild cluster and a million users, thats one hell of an improvement 😄
let m
client.channels.cache.get("836870311923417118").messages.fetch("862383984511418388").then(msg => m = msg).then(() => {
setInterval(() => {
m.edit(embedG(client))
}, 5000)
})
}
async function embedG(client){
const embed = new MessageEmbed()
.setTitle("**Bot Status**!")
.addField("**Guilds**:", client.guilds.cache.size)
.addField("**Users**:", client.users.cache.size)
.setColor("RANDOM")
return embed
}```
Error: cannot send empty message
Use m.edit({ embed: embedG(client) })
Then
Error: embed[0].description is required
Are you using the master branch?
how are the users being cached? On disk? I highly doubt 1m is within the residential set
Anyone know good alternative aside from jikan api? sometime I feel it slow as tortoise
Official MAL API
I personally use Jikan as it offers more info and I never had problems with it
Also, check out AniList GraphQL API. It's also really great and faster than Jikan
reading anilist documentation is a little daunting for me, like jikan doc more straight forward, but thanks for reply
Which version you on btw? @pale vessel I meant the jikan api version
v3
hmmm, on v4 right now, maybe I should downgrade to v3 
its not, not any more. this is with only caching of: guilds, channels, roles
i need to retain caching of those three to do permissions checks
ive changed the settings to not cache users, with users and emojis cached it takes about 320mb

how would i start typing my css code?
like do i need to do
// my desc
<style>
.class name {
...
}
</style>
yeah, that works
aight thanks
is it possible to make particles?
cuz i dont think we can make html elements
could u link me a docs to that?
<style>
body {
background: url("https://imgur.com/BVJsaGq.jpg");
background-size: cover;
background-attachment: fixed;
opacity: 1;
}
.modal-background {
background: none;
}
.entity-content, .centered {
border-radius: 5px;
background: rgba(0, 0, 0, 0.724);
}
.site-nav {
background: rgba(0, 0, 0, 0.764);
}
code {
color: #fff;
font-weight: 600;
font-family: Overpass,-apple-system,BlinkMacSystemFont,Segoe
UI,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;
}
</style>
for some reason when i added these 2 lines border-radius: 5px; , .centered the site does not update my css, it overwrites it
oh wait nvm
i dont know why but there was a # in the url
Can I do like if any command is executed then bot reacts to his own message?
That's possible
How?
are these links a discord feature or is it automatic
It's been out for few months? now
ok yea but is it automatic; or do I have to tell it to link or smthn
You need to provide it link etc
docs?
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
ty
Discord.js-light
http://join.nuggys-thigh-highs-club.pictures/n7vZZHj7
Normal Discord.js v12
http://join.nuggys-thigh-highs-club.pictures/fLJm9QX4
damn
the difference
from djs to djs light
lol
you should have shown it at like 10 hours of uptime tbh
at 10 hours it on normal is like 700 -800 ram
usuage
members and messages
ill do an update with djs light when i get around 10 hours
who darethn pongeth me
ik but still
@opal plank
if u care that much use detritusjs instead
replying to myself is so hard
avdertising
well i dont that much but i like the small difference and all i had to do was add -light and
const client = new Discord.Client({
cacheGuilds: true,
cacheChannels: false,
cacheOverwrites: false,
cacheRoles: false,
cacheEmojis: false,
cachePresences: false,
cacheMembers: true
});

watching anime
well im using light now i onl didnt before because statrcord
only supports offical libs
but i stopped using statcord
detritus IS an official lib btw
and you can see it in discord.gg/discord-api
ayway, bye
we're in #development btw
¯_(ツ)_/¯
everyone does it
bd?
fl0w uses better discord?
@latent heron confirm
djs/master they remove user.presence i wonder why
When you mod your client to make it look uglier
I'm getting this error: xl TypeError: Cannot read property 'run' of undefined
I'm not sure why. Here's my code -
index.js:js if(testForNumber == 0) { let spwn = client.spawns.get(spawn); spwn.run(message, prefix, db, available, client); }
spawnsystem.js:js module.exports.run = async (message, prefix, db, available, client) => { console.log("hi"); }
Of course, there is more, and if you have questions I'll answer it to the best of my abilities. Any help I'm grateful for and is welcomed.
but what if....
client.on('dmMessage', message => {
if(message.content.hasLinkOrURL) {
await message.author.reply('Fuckoff with yer ads');
await message.author.block()
}
})```
message.content.toLowerCase().has("detritus")

poor Erwin
I have two run different modules with "run", does this change anything? Or did I do something incorrectly
changed run to execute. it's not the issue
Cmd handler 
when you say -help then the bot will say "This command doesn't exist"
how do u do dat
Module:
module.exports = {
cross: "<a862535909550587925>",
tick: "<a862537918130946059>",
music: ""
}
Index:
client.emojis = require("./utils/emojis")
Command:
Module.exports = {
//data
run(){
message.channel.send(client.emojis.tick)
}
}
Error : its giving me undefined
you shouldnt do that
commands that dont exist should not reply
otherwise anything you'd do - for will reply with that
no, its just a dumb thing to do
ohh
read this
How do i stop console saying errors
check if a command exists first
ok
When i type an invalid command I'm having errors on console. i need to stoo that cuz my bot restarts for some reason.
Example when misspelled
just return it
we dont magically know what you're doing
you either post ur code or figure out urself
<rejected> TypeError: Cannot read property 'catch' of undefined
at Object.run (/src/user/app/commands/disconnect.js:21:24)
at module.exports (/src/user/app/events/message.js:36:13)
at Client.emit (events.js:375:28)
at MessageCreateAction.handle (/src/user/app/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (/src/user/app/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/src/user/app/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31)
at WebSocketShard.onPacket (/src/user/app/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
at WebSocketShard.onMessage (/src/user/app/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
at WebSocket.onMessage (/src/user/app/node_modules/discord.js/node_modules/ws/lib/event-target.js:132:16)
at WebSocket.emit (events.js:375:28)```
one error comes
but i solve that probleam
still it come
Show the code.
Is it possible to update the codes without closing the bot?
Yes
How ?
Dunno

hot reloading
detritus for example handles that
<Client>.clear();
<Client>.addMultipleIn();```
is an example of how you reload ur commands with new code
update the files and run that in a command
it'll re-import all the command files
So is this valid for the whole node application or just for discord.js?
That's only valid if you're using detritus
Oh alright
actually, i think cake might have added <client>.reloadCommands()
@eternal elbow but the point stands, just re-require ur files
man i wanna contribute some shit to detritus
gib repo
I dunno I use slash commands anyways 
console.time("how long erwin takes to gib detritus repo")
same
i use both tho
buit he added that onto slashCOmmands as well
Also what are these new emotes 
I can do something that will reload the commands but I have no idea how to do the newly added "requires"
just scan the folder again...?
You can help with the docs
give examples to methods
you better ask cake before doing anything tho
All right, I only have one question, how do I reinstall the express api?
still waiting for repo link
the what
wait, u actually want it?
thought u were meme'in
yeah
well, like i said, i thought u were mem'ing
what repo?
good luck
voiceChannel.join().then(voice => {
const receiver = voice.receiver;
voice.on('speaking', (user, speaking) => {
if (speaking) {
console.log(`${user.username} started speaking`);
const audioStream = receiver.createStream(user, { mode: 'pcm' });
audioStream.on('end', () => {
console.log(`${user.username} stopped speaking`);
voice.play(audioStream, { type: 'opus' });
});
}
});
dont
just
dont
Why?
event listener under that?
you gonna get maxEventListener reached
like real fucking soon
Hiw i can fix it
or use once
use whatever command that is 22 time or more
you should get node screaming at you for having a possible emmory leak
client.on("message", async message => {
if (!message.guild && message.member.bot) return;
let args = message.content.split(" "),
cmd = args[0];
if (cmd === "join") {
//Get channel bye Name
let channelName = args[1].toLowerCase();
const voiceChannel = message.guild.channels.cache.filter(c => c.type === "voice" || c.type === "stage").find(channel => channel.name.toLowerCase() === channelName);
//if there is no voice channel at all or the channel is not voice or stage
if (!voiceChannel || (voiceChannel.type !== 'voice' && voiceChannel.type !== 'stage')) return message.reply(`The channel #${channelName} doesn't exist or isn't a voice channel.`);
//Join channel
voiceChannel.join().then(voice => {
const receiver = voice.receiver;
voice.on('speaking', (user, speaking) => {
if (speaking) {
console.log(`${user.username} started speaking`);
const audioStream = receiver.createStream(user, { mode: 'pcm' });
audioStream.on('end', () => {
console.log(`${user.username} stopped speaking`);
voice.play(audioStream, { type: 'opus' });
});
}
});
}).catch(err => { throw err; });
}
})
This is all the code
I just want to record a voice
And play back
How i can do this?
My English not good i don't know what actually you say
imma slap them with the thing
😅
learn first
I wonder how they said their question perfectly in english but cant read english
I have a translator
and how to fix it
ok bye
Ok
ill leave you to help them
@solemn jolt https://nodejs.org/api/events.html#events_events
im out too, i gotta talk shit to million
I need to lern this?
Does constantly writing and deleting files with fs decrease performance?
yes
How can I distinguish between a method and a function?
Do you want to do it inside the said function or outside?
there's no real way to check because in JS there is no difference between a method and a function
at least inside V8
Inside a module, it can become property too
const fetch = require('node-fetch')
const client = require('../index')
client.on('ready', () => {
const automemeSchema = require("../models/automeme")
automemeSchema.findOne({ guild: message.guild.id }, async (err, data) => {
setInterval(() => {
if (!data) return;
if (err) throw err
const channell = data.channel
fetch('https://api.nuggetdev.com/api/meme')
.then(res => res.json())
.then(async json => {
const memeEmbed = new Discord.MessageEmbed()
.setTitle(json.title)
.setImage(json.url)
.setFooter(`Link: ${json.postLink} | Subreddit: ${json.subreddit}`)
.setColor('#FF0000');
channell.send(memeEmbed)
});
}, 30000);
});
})```
Message not defined
i dont want it in the message event
line 5
either hardcode the guild id instead of message.guild.id, or store it in a database
you cant access a message on ready event
How can I make it so whenever I add a new field to a data model, it automatically adds the new fields to all of the existing data?
new Promise((res) => res(1))
Will this return a promise or 1?
How could I make a command that has a 1 in 8 chance of sending?
It returns a promise, it'll return 1 after being resolved
so is there a way to resolve it without awaiting?
Promise.resolve(), Promise.prototype.then() or just wrap it in an async function (async () => { ... })() and await it
okay
I may be just overlooking something in the Discord API docs, but is it possible to get a user's voice state in a guild without having to rely on cache from gateway events?
nope
@thorn flower
made my slash command handler much more tidier and simpler 
my bot itself got much more simpler since i switched to slashcommands
ye much more usable
easy access*
the thing i like about slash commands r the options
and for the user its a much better experience with tab completion and all
AND with ephemeral message
so the channel wont get flooded with a chunk of embed/msg
oo same
Components are kinda a mess tho
to configure?
ye i agree with u
just to work with them
would be nice to be able to define a vaild number range
wdym?
i wonder what discord would add next with interactions 
and looking forward to threads which i dont have access to cuz im on mobile
i can define a range like 0-5 and when an user enter 6 discord tells him that the valid range is 0-5
i dont understand what u mean there
I want them to add countdowns, would be very useful for a lot of stuff
oke i have a buy cmd which is like /buy item amount and amount should be max. 5 e.g.
cant u do that but manually?
and at slashcommands my IDE screams at me everytime i should nullcheck the values of the command params and im just like "i required them
"
like u just check if amount is greater or less than to something
yeah thats what im doing rn

but with the range im not having to do it
args r kinda more easy to access with my slash cmd handler
so i dont have to do
args[0]...
now i can do
args.option1
im not happy with the able/disable options rn of slashcommands
do u mean the application.commands scope?
because its only guildwise
e.g. i should be the only person to execute the shutdown command, fine i disable the command globally and whitelist myself, but that whitelisting applies only to one guild
in another im not allowed to use that command too
i would just leave it there out in the open but only requires the member id to mine
I only add admin commands to the bot's guild
fun thing with a custom bot that u wont have to make slash commands globally and wait for 1h
i just upload it to the guild im using the bot for

wonder if people will still use reactions if buttons r open for most of discord's api wrappers
button are way nicer imo, i use them for like approve/decline something
sad that they limited the colors tho
Buttons are also less spammy
im looking forward to let us devs choose the hexcolor for the button
and maybe animated buttons? 
can't you put animated emojis in buttons right now?\
You can, since it supports partial emojis
it's more efficient on rate limit to send a button, a reaction role is a message plus each reaction
haven't tried it
yes you can freud
but still custom button colors will be sick tho
they won't do that, the button colours match the apps theme
hmm sad 
i wonder if they add more variety of colors
Heyo.
${bot.users.cache.get(res[i].userID).username || res[i].username}
I have this code...
Returns an error.. cannot read property .username of undefined I said, ok, let's do this.
i have an apple
${bot.users.cache.get(res[i].userID)?.username ?? res[i].username}
Puts undefined, WHY
can't u just do ```js
let usr = bot.users.cache.get(res[i].userID);
let name = "";
if (usr) name = usr.username;
else name = res[i].username;
a bit more verbose? yes but it saves a lot of time finding where the issue is
What's res[i]?
but you can debug that easier
it's a loop using descending method.
Are you sure the properties aren't undefined? Debug
Wait..
You need to know what you're working with
bot.users.cache.get(res[i].userID)?.username, I found out that this user id is sometimes not in the cache.
.. so instead, I want to show res[i].username
But if res[i].username exists why not just use that?
Because it's stored in a database.
So is res[i].userID
Let's consider res[i] as an id, right?
I mean the object
Goodness.
It's like the document for MongoDB.
In this document, i saved two things, .username (username of the guy) and .userID (user id of the guy)
I did
${bot.users.cache.get(res[i].userID).username || res[i].username}
Why grab from cache?
🤷♂️
...
Fetch?
You already store the username in the database
Can't you just do the or operator before getting the username
Well.. it's not updated.. which is the problem.
Then only store the ID and use fetch
Yes.
Let me try.
bot.users.fetch() right?
yes
${bot.users.fetch(res[i].userID).username || res[i].username}```
Imma try this.
Do I add ?.
You don't need to use the username from database if you already have the user object
Yes.
But that'd raise an error, no?
If it doesn't exist it shouldn't be inside the DB imo
I'm trying to fetch the updated username, if errored or undefined, then I would use the one inside the database.
Let me try
Well.. uh, it returned all undefined.
${bot.users.fetch(res[i].userID)?.username ?? res[i].username}
I used this.. returned undefined.
WAIT
One moment.
Bru, dot moment
^
How do I set the voting webhook?
There's a lot of them, Don't know if any are good
Hi everyone, does anyone know what caused this errors? its been happening for the last 1.5-2 weeks out of no where.. no changes done to the bot to cause it
this one happens frequently recently
discord.errors.ConnectionClosed: Shard ID None WebSocket closed with 1000
and the
aiohttp.client_exceptions.ClientOSError: [Errno 32] Broken pipe
error happened a lot last week, and returned today and it kind of breaks the bot, the bot keep restarting after that
which lang?
do you have bad internet connection?
are you sure you're not on an outdated dpy version
Hi asking here again for that #topgg-api message
nope, i host the bot on heroku
yes ^^
and your endpoint is?
hmm not sure what exactly you mean by that
is the webhook == your herkou domain
Any reason axios would get a 503 error for a url, but when I put it into my browser it works just fine
https://adonis.itsbounce.net:8443/api/song/joel-corry/bed/auth/AutoDJ
code is literally just axios('https://adonis.itsbounce.net:8443/api/song/joel-corry/bed/a/AutoDJ')
?
How many shards do you all suggest for a 10k+ bot?
10
The suggestion is leaving each shard with about 1.8-2k guilds. 6 should do the trick, unless u dont care about future proofing
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
make a call to this endpoint and let discord decide
Remember that 2.5k is the limit per shard
Sorry to jump on to this, but what is a shard?
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
ok thanks
Damn cry's faster than me tday
?
setInterval(() => {
client.channels.cache
.get('836870311923417118')
.messages.fetch('862383984511418388').then(msg => {
console.log(msg)
msg.edit(loads[result], {embed: createEmbed(client)}).catch((e) => {
console.log(e)
})
})
}, 60000)```
Why message is not editing?
there's cloudflare bot checking bruh
its not cf
it is cf lol
is there any java users here?
i need some help for school project
ping me if u know java
god typescript needs macros NOW!!!! There isn't a good macro implementation for TS yet and it's been like 8 years now
function macros to be specific
What do you need macros for
?
instead of asking "does someone know java" you could state your issue
-ask2ask
Don't ask to ask.
Just ask your question, it wastes time if you say "i need help" or "can someone help me?" instead of just saying what the problem is. Save your time and other people's time and just ask the question.
Please read https://dontasktoask.com/ for an explanation on why this is an issue.
Is there any discord.js-redis libary ,which isn't outdated?
Why not just use Redis directly?
I want to use redis as cache instead with discord.js-light
All the library does is listen for events and modify the Redis cache.
@opal plank will detritus work on deno since it is ts?
Does someone know a decent sharding manager?
I think code said something about a converter to replace nodes internals do deno. Worth a try. However ive been told against using redis ir third party caching, that it'd br useless
Erwin, right now im going to tell you. Please dont respond to my question with detritus
Detritus
for. the. love. of. christ
disc.js has a manager
A shit one
i want to see if there is a better one
Yes
Dont. You. Dare. Say. It
But seriously, do you know a goodone?
Detritus
I CANT USE THAT
Learn it
MY BOT IS TOO BIG
Like ebryone else
Do you know a decent one for JAVASCRIPT that is compatible with DISCORD.JS

But in all honesty, do you know a good one?
Ive been looking for the perfect one
No luck
the issue is djs in itself tbf
it treats shards like completely separate processes
or something
thats why im looking for something else
I was looking at that right now
👎
Don't you dare insult detritus!
detritus is ass, along with discord.js
It's a great lib, the docs just aren't very detailed quite yet
actually it should work ,which node internal does detritus use?
Have you tried using Detritus in the first place?
Yes a little bit, im going to make a bot for a friend
I dont like it too much
its **O K **
You have only used it a little bit
use internal sharding
I've only used Detritus for a little bit, and I already like it far more than djs
The docs are lacking, but the library itself is amazing
What makes it better
It's far more optimized
I'm sure @opal plank could give you a lot more reasons why Detritus is better as well
oh, believe me, he already has
@rapid prawn
Hey erwin, i need some detritus examples
Absolutely no clue. Try running it tbh
See if i can figure it out :)
Or try the converted beforehand
well, the fact Detritus is updated to new features much faster than djs is nice.
the issue with djs is everyone uses random third party libraries for new features for months till djs updates.
so youll have people asking questions for a library only 2000 people use and there is no support for.
I legit sent u my repo like 5 times, but lets go
Read the text
got it
any in js?



