#development
1 messages Β· Page 1537 of 1
How can i get bot developer role?
get a bot approved
Ok thanks
Help me plz ^^
you can't use relative paths for images
Image does not load
what cry said
Look at my 2 screens and my script
once again, read what cry sent
this
cry ?
does anyone know what the rate limit for fetching is
fetching what
what
so, fetching messages
ratelimits are dynamic
discord.js π¦
was wondering, anyway, thanks
almost all discord ratelimits are dynamic
an example of why not to hard code them is that a fuckton of bots got api banned when the ratelimit for changing channel names switched to a much more restrictive ratelimit
discord can change and adjust them anytime without notifying you
i think they even warn you not to hardcode it in the docs
they do iirc
104 105
Is it bad to use sqlite3 for a public discord bot in around 50,000 servers.
The sole purpose of the database is to allow for a simple economy, such as storing balance and bank balance?
this is top.gg support, try #development for dev help
this is #development
Lmao
@hallow grove what do you want?
yes it's bad
Why
sqlite is usable up until a 100 guilds
because it's a single file embedded database
it isn't powerful
Concurrency issues?
it isn't meant to handle so many connections
json is da best
simple and easy to use
thats true
Was just wondering since I read that a website will be fine when using SQLite if it has around 200k views per day, thatβs the threshold
and access time compared to a normal db is super slow
@hallow grove what do you want?
@opal plank
Why
basically if you're going large scale, use postgres
Nu
Mongo
π
ew
but sure whatever floats your boat
Whatβs bad about mongo eh? π
nosql is nasty to me
I keep getting an error tho
Saying topology is closed please reconnect
why you sending me friend requests? wanna talk to me or simply too impatient to wait for replies here?
what about me
I tend to be curious hmm
Dm ads most likely π
No
Yup
Yessir
Hmm
Don't be annoying now
Anyways imma dip, this Warzone game ainβt gonna play itself
Tyvm
you're using optional chaining in the wrong place
wdym?
wdym?
its logging all message delete? using ids it would not return if the author is the client
hello
i need help
I would like my bot to send a message to the channel of id 272764566411149314 when it joins a server
theres no need to ping random users.
@opal plank
please stop pinging people
can you not ping people?
so i ping developper
please dont
wtf
you are not entitled to help
Channel for chatting about (bot) development. If you have questions, ask the questions and wait for someone who can answer to help you. Do not ask to ask. Provide all possible information so people know what's up. Just saying "I get an error" doesn't give us enough information on your problem. Do not @mention people randomly.
ok sorry
if(message.author.bot) return; @fierce ether
Good evening, is someone available to help me?
?
I would like my bot to send a message to the channel of id 272764566411149314 when it joins a server
What lib
but I can not
How can you not
@odd stratus that rlly dosent help lol
const { Discord, MessageEmbed } = require('discord.js');
const joinEmbed = new Discord.MessageEmbed()
joinEmbed.title('Je viens de rejoindre un serveur !')
joinEmbed.description(`\`\`\`Nom du serveur : ${guild.name}\`\`\`\n\`\`\`ID du serveur : ${guild.id}\`\`\`\n\`\`\`PropriΓ©taire : ${guild.owners.tag}\`\`\``)
client.channels.cache.get("800523782673661953").send(joinEmbed);
});```
he don't work
how does discord determine the channel ID to assign to a channel?
the channel isn't in the cache probably
well I write it in the code
@odd stratus ik how to not log bots events, if you read the error you would not reply with if(message.author.bot) return;
just require the whole discord module
if the id is null explain how message.author is going to work without optimal chaining?
don't use destructuring
which module?
@compact olive It should not be like that
just use const Discord = require('discord.js')
i just told you
don't ping me
It's under a guildCreate event, and you put guild as a parameter
Try guild.channels.cache.get("channel ID");
you're destructuring discord.js
I don't know why its null? Send the code in a SourceBin here instead
its trying to fetch old messages, which would return no author
What's the question mark for though
aight ima head out
optimal chaining?
optional chaining
no message isnt always going to be defined tho? otherwise it wouldnt return null?
what?
message is returning null
you mean the message is null?
yea well deleted messages can't be fetched because they don't exist
u can fetch ids thats it
yeah the only thing you get is the message id
unless the message was in the cache, but that might not always be the case
So I'm barely learning how to code discord bots, and I had one up and running for a good amount of time (hosted off of my PC) and all of a sudden its not working anymore. The bot appears to be online in discord, but commands don't work. It shouldn't be online as I have closed the CMD prompt. But its online, with no responses to commands...
Any fixes?
did you close the terminal just a few moments ago?
It's been closed all day
regenerate the token 
I'll try that lol, thanks!
np
can someone explain this, It was fine yesterday but this is what is messing everything up
a package.json name needs to be lowercase
lmfaoo is that all it was?!
there are other rules but that one's the problem here
yea 
you probably wanna use something like philosophy-bot
would that stop the entire thing from working?
now its just not going online lmfaoo
Idk if something updated or what
but now I run it and nothing happens
no error just nothign
not that I see
np
Would a simple economy SQLITE3 database be fine for a private discord server with 5000 members?
Will just store balance and bank balance
Should be fine right?
Ping with response, ty
Yes it's fine
If you have a big bot with shards then sqlite probably isn't a good choice
But for private servers ye
it isn't fine on that big of a scale ποΈπποΈ
it's going to struggle
i mean
it depends on the amount of concurrent issues
but it's going to struggle
it will be more than fine
are you sure? i worked on a kind of a big guild and migrated their bot from sqlite to postgres because people started experiencing bigger delays than usual
disable synchroniztion, enable WAL mode
im getting average 0.3ms per query
sqlite can easily do 1k+ queries per second
so i'm using djs.
let time = args[1]```
i made sure that `time` endswith d, h, m, s. Then i want to multiply the number included but before that, i gotta take away d, h, m,s from the args
like 1d
then take away the d
and make it just 1
.slice(-1)
ok
I don't know why i'm getting undefined servers
lol
code?
well because it's undefined
bot.on('ready', () => {
console.log(`${bot.user.username} has started`);
bot.user.setActivity(`!help -- on ${bot.guilds.size} servers`, { type: "WATCHING" }); // Set Bot Status & Presence
});
.cache.size
uhh halp
reaction doesnt exist
wdym?
Alright, good, tyvm
the message does not have that reaction
you cannot get a property of undefined
I have a levels system in a partnered server with over 160k members and its pretty fast with sqlite
its like doing undefined.count
did you await it?
uhh await the reaction?
yes
Might include levels for that too then
await giveawayMsg.react('π')``` how about this?
okay
Make sure you have async 
make sure you have brains :^)



if (giveawayMsg.reactions.cache.get("π").count <= 1) {
return channel.send('**There is not enough people to end the giveaway! Cancelling...**')
}```
lol
show more code
ok
setTimeout(() => {
if (giveawayMsg.reactions.cache.get("π").count <= 1) {
return channel.send('**There is not enough people to end the giveaway! Cancelling...**')
}
else{
let winner = giveawayMsg.reactions.cache.get("π").users.cache.filter((u) => !u.bot).random();
channel.send(`**Congratulations ${winner.toString()}! You won ${prize}!**`)
}
}, time)```

how is time defined
time should be in ms
let time = args[1]```
@_@
multiple it by 1000
time.slice(-1)
if(time.endsWith('d')){
time = time*86400000
}
else if(time.endsWith('h')){
time = time*3600000
}
else if(time.endsWith('m')){
time = time*60000
}
else if(time.endsWith('s')){
time = time*1000
}```
I did
slice does not modify the original
also, you're checking if it ends with the letter, then multiplying it without removing the letter
so it becomes NaN
how do i fix that
wdym
you got a number
in once case you're slicing it
rather that multiplying/dividing it
and the second you're multplying
why ?
you know what slice does, right?
yeah
okay, so what is slice doing there?
"hello!".slice(-1) => "!"
to take away the letters at the end
hm
slice(0, thing.length - 1)
slice(0, -1)
does that work?
what does 0 mean?
ye
one of the improvements that slice made over substring and substr are negative indexes
they basically wrap around
time.slice(0, -1)``` what about this?
this
3fast5me
So, can i do js const time2 = time.slice(0, -1)
yes
k

whispers softly in ears : variables can be reassigned
damn i want js to add pattern matching expressions asap
this is a perfect use case for them
not that
Thanks @quartz kindle @opal plank , it worked! 
new thing in php ```php
$result = match(a) {
"h" => time * 3600000,
"m" => time * 60000,
"s" => time * 1000
}
no preblomo
it exists in rust, scala and F#
And java
and java
there is a proposal for c++
and a very early one for js with ugly af syntax
which i hope it doesnt pass
Lul
im not keeping up with upcoming changes tbh
nor proposals
though what i am trying to keep uo with is sharding
Although it'd be be better than some chained ifs I see here
but im probably gonna cry with it
me neither, but i looked into php8 and saw that and though it was cool af
im gonna have to somehow prevent racing against other shards
You could use queues
thought about it, but they are REALLY slow
like, signigicantly
grammar is hard sometimes
thats an option, but i need to first check if its a necessity first
php lol
what are you racing against?
shards presences
why not to literally like mine or all other libs and just reemit everything into a single client?
but no, lets have them have their own instances
cuz fuck you
I think mutex will be the only way to do it without sacrificing speed
what is the issue?
ah
and them running simultaniously might trigger events twice in a race
in some VERY rare cases
i have checks
but my concern is that they run before the variable is set
and locks it
never tested that, but im pretty sure it would happen also with internal sharding
where are you setting the variable?
well, i got user object(not d.js's)
which has 2 keys
well, improtant to this matter at least
reminded and playing
reminded is a bool
if user is playing x game, it runs a reminder function and then sets that reminded as true
though, if they are run in pararell, shit might happen
and the reminder is ran twice before the reminded is set to true
so the variable is set in memory in process?
correct
y not a db
cuz that'd add even more latency and allow for even more stuff to pass by
await shouldnt stop the thread, and possibly add even more gap for another race promise to fulfill
are you using worker threads or child processes?
currently, neither
im still thinking of the logic behind it
wondering if i should use d.js sharder
or not
or make my own, for that matter
you can use worker threads with a sharedArrayBuffer and implement it as a circular buffer
did not understand half of what you said
worker threads
i know those
sharedArrayBuffer
sharedArrayBuffer and circular buffer
Let's say I have guild A on shard 1 and guild B on shard 2, both shards on separate VPSs.
Can I retrieve guild A inside shard 2?
sharedArrayBuffer = ArrayBuffer that is shared across worker threads
okay that makes sense
aka thread 1 changes first byte to 1, thread 2 reads first byte and sees 1
all writes on sharedArrayBuffer are atomic
sharedArrayBuffer has a constraint that its limited to a fixed size
you cannot resize it once you create it
this seems like a major block for me
so a circular buffer is a way to implement a sort of an infinite data stream
since there are thousands of users
you write until the end of the buffer, then you continue writing from the beginnign again
and they are added removed dynamically
and you use two pointers to control boundaries
that sounds more complicated than doing my own sharder to be completely honest
specially when i already have my twitch framework
well, your only other option is a db, redis, or lockfile or mutex
or a central process with ipc
wouldnt a db or redis still imply the same issue and allow race between calls?
no because they are atomic
hmmmm deadlocks might trigger though
well, the process thats accessing the db would need to queue it to ensure atomicity
so that would be a problem
hmmm, this is all theorical btw, i havent ACTUALLY tested if i'll be getting double output
for simplicity sake i might run with queue
I need to know if I'll need to rework my matchmaking system
the database needs to have a conditional write operation
and see how that performs
Like, I'm still at 1k servers, but I'm near a total rework of the code
Just waiting discord's menus
you can fetch the guild from the rest api
and you can send requests to the api
soon enough i'll have to worry about sharding, its growing faster by the day
but for now i got a lot of lee way
Maximum I'd need to do is retrieve channel and send message
you dont need the guild to get a channel
in fact if you have the channel id, you dont even need to retrieve the channel
POST
you can just post directly to it and handle the error
channel_id/messages iirc
Nice
client.api.channels(id).messages().post({uvuvwevwevwe})
actually sending messages is PUT no?
I was afraid because I rely on message mirroring
let me check docs
wut
dont use ts then
ah
Integrate your service with Discord β whether it's a bot or a game or whatever your wildest imagination can come up with.
throw salt and lemon in eyes, gotcha
the sharedArrayBuffer method would offer the best possible performance
the second best performance would be to have one of your worker processes keep the data, and have the other workers send messages to it
the only reason why im bringing up that is because its presence realted
like
its a LOT
ye
that comes to show how much more data you receieve with presnces
in 7 days uptime
234 mil presences parsed
nice
IPC i assume?
yes
ipc between worker processes is very efficient
and can send js objects without stringifying
how does that fix the issue though?
and functions and classes and shit
cuz i already have a bool
i'd still need to queue it, no?
cuz the object containing the reminded bool is also the same thing, correct?
yes, but you queue it in one process
i just dont see how the worker solves the issue
they both try to change the bool, the issue is when they race it
and run while the bool is set
they both change -> both send to worker -> worker changes 1, ignores the other, and returns responses -> worker who gets the successful response runs the function, the other does nothing
thats not the issue though
actually
hmmm
lemme get my head straight
okay, yeah, no, i think im right on this one
so, the issue comes with whats happening WHILE the bool hasnt been set and its waiting
for example
actually, why am i giving example?
let me just dump code
see that for loop or await add new user?
those are my issues
while that await is running, user.playing might pass
twice before its been updated
its this code but ran twice
if everything is inside the same process, this is not hard to solve
but if you have multiple process, then you literally cant solve it. you have to send everything to a single process to be executed synchronously and sequentially
after presence is found i could just yoink into the queue, thats 100% a solution as it would, at the very least, massively reduce the queue, since it'd only be passed with that
rather than queuing every presence, i could run that check to find a specific presence(which i should be running by game id, not by name) and queue it
that MIGHT not prove too impactful
this is how i would solve something like this:
it boils down a lot to try and error, im not even sure a race would occur here at all, this is all assumptions
// shard 1 and shard 2
client.on("presenceUpdate", bla => {
let(a of bla.activities) {
if(a.name === "yes") {
worker.postMessage(bla)
return;
}
}
});
// worker
let users = {};
process.on("message", async etc => {
if(!users[etc.user.id]) {
await addNewUser(...)
}
})
wouldnt runnig it async completely fuck ti up though?
nope
hmmm it seems i dont quite understand how js async works internally
sometimes i get the idea that it doesnt halt the code, but sometimes it does
the rest keeps on going, which is kinda odd
js is 100% synchronous, everything is blocking
that specific script halts while the await is runing until its fullfilled
even if you make an async function, the code is still sync
javascript is confusing and stupid at times
well yeah, thats where the confusion comes
that allows for other scripts to be ran meanwhile
which could be annoying when they are touching the same things
like this where it might create a rare race condition
what it does is that if you make a function async, you "prepare" it for a possible async operation
and the code only stops being sync then the actual async operation begins
the actual async operation begins the moment there is no more sync code to execute
for example a callback
or an I/O request
so if i run a 2 functions
one async and one sync
when the async one hits an await
the sync one (pararell) should still be going, no?
until the await finishes
then it continues on the one that was halted(awaited)
did i get it right?
if the sync one starts after the async one, the sync one only starts when the async one hits an async code
await does not guarantee its actual async code
because you can still await sync stuff for some reason
also
in the case of a promise though
when you await an async function, like a promise
actually i might be able to try this real time
its still sync code until the code inside the promise hits something it cant continue
async function bla() {
// sync
return new Promise(r => {
// still sync
doSomething(() => {
// async starts here, js cannot execute this without waiting
r(10)
});
// this is still sync
console.log(20)
})
}
console.log(await bla()) // 20, 10
async function a() {
console.log('start')
console.log(await db.get('something'));
console.log('end')
}
function b() {
for(let i, i < 1000, i++) console.log(i);
}
My probably flunked logic states that, if ran simultaneously, the async functions will run first with start, then function b will spam console log, i'll get the returned value of the await and end, and then the rest of the console log i's will end
am i correct to say that?
correct
but if db.get() has a console.log inside it before the actual db call, that console.log is executed before function b
so its kinda like blocking? where it'll run async until it hits a block, then i'll run the rest until the promise is fullfiled, which then it gets back to the async, and once it finishes, comes back to the sync code?
interesting
when the js code hits an await, it sets a timer and continues the rest of the code
default is 15 or 30 seconds to auto reject promise, no?
the only difference is that the timer is based on signalling instead of time counting
maybe thats axios i think
promises dont auto reject
i thought promises had a maximum life ebfore they were rejected
not afaik
in the case of the worker receiving messages, or any event emitter
js cannot ever handle two messages or two events simultaneously, it will always process them sequentially
so before the second message has a chance to be processed, the first message already checks if the user exists in the object, and if it doesnt exist, it creates it, before proceeding with the async call
so while the async call is waiting, and the second message comes, the user is already in the object so it does not proceed anymore (which i actually forgot to add in the previous examples)
let users = {};
process.on("message", async etc => {
if(!users[etc.user.id]) {
users[etc.user.id] = true
await addNewUser(...)
}
})
well, in a single process, sure, but what happens when we add sharding onto the mix?
thats the idea behind using the worker process
where we have two processes handling two events simultaniously(and likely echoed)
have all shards redirect the events to the same worker to be processed sequentially
like a funnel
which is what i began whining about
well
its more efficient than a database and more efficient than a lock file
just less efficient than sharedArrayBuffer
this
you dont need to emit everything, only that specific thing
you have to queue it in the same process
hmmm, IPC it is then
another option is using a database that can do conditional updates
something like db.setIfNotExists
does d.js spawner allow me to bind each shard ?
i would assume its all used by process.send()
if you're using djs, just use broadcastEval
but yes you can use process.send() if you set it to worker mode

oh
how would broadcastEval be used here? that would just eval something on all shards, no?
process.send() with the sharding manager in worker mode will basically send a message to the sharding manager
well yeah, i was actually thinking about something else, idk why i said broadcastEval
using an emitter would be the proper way no? that way i dont have to run setInterval
cuz otherwise i risk losing positions
hmmmm
djs has client.shard.send()
and i assume i can easily access sharding manager and re-emit that to my main code no?
shard => process.send('presence', presence)
manager.on('presence') => client.emit('event', presence)
client.on('event', presence => stuff and things)
that SHOULD work i assume?
while the client part isnt teoretically necessary, i like to keep client related stuff binded there
its just for consistency, shouldnt add to much strain to just re-emit it
or a pseudo client
im not sure
like i said, i ahvent even started with sharding
so im not sure how it works
the sharding manager doesnt have a client
i'd probably need a pseudo then
actually
ACTUALLY
can i not do the same that i did with my library then?

and just do EXACTLY what i did but with EVERY incoming event?
and emit it to the manager, and re-emit to client?
that would literally require no update on the code whatsoever, no? just adding the sharder
//shard 1
client.on('message', process.send('message', (message)));
//shard 2
client.on('message', process.send('message', (message)));
//index
manager.on('message', message => client.emit('message', message));
client.on('message', (message) => {/*actual code here*/})
for every event?
i mean
thats literally what i did to my twitch lib, but i needed the manager because there were custom events there that were internal and shouldnt be exposed to the end user, like Promises between the IPC pipes for connections and sync events, so only the events that the client originally had were re-emitted
you're sending all events to the manager
correct
then process them with a client in the manager?
but the client in the shard cant login?
nothing, just weird
i wouldnt do it like that tho, at least not without some basic filtering
//shard 1
const Discord = new require('Discord').Client(require('./config.json').token);
client.login();
client.on('message', process.send('message', (message)));
//shard 2
const Discord = new require('Discord').Client(require('./config.json').token);
client.login();
client.on('message', process.send('message', (message)));
//index
const Discord = new require('Discord').Client(require('./config.json').token);
client.login();
manager.on('message', message => client.emit('message', message));
client.on('message', (message) => {/*actual code here*/})
Is this not valid?
no because 1: the client in the manager will error with sharding required
2: the client in the manager will basically spawn duplicated shards
hmmm manager uses its own client i assume?
you have 2k guilds, shard 1 has 1k, shard 2 has another 1k
what would the manager have?
or, rather, manager IS the client?
the manager is not a client
the manager is just a process spawner
and ipc bridge
hmmm so you are suggesting the manager doesnt exclude the initial client?

i would assume you could pass the client to the manager and it would shard it
im suggesting that if you are gonna redirect all events to the manager, you are gonna have to process them with your own code, without a discord.js client
but i need to login in order to recieve events no?
im confused, how are they being recieved in the shards then?
how to you access events inside the shard?
then if you send all events to a different process
this different process has no client
HMMMMM
that would give a ton of troubles for me though
specially with caching]
d.'js cache, for that matter
my main client wouldnt have all guilds cache
in the shards or in the manager?
the other cache is fine
manager would be best to have everything cetralized, the idea was to simply spawn shards to basically be event slaves
where they would recieve and re-emit to main
anyone here using datadog
the moment you redirect the event to another process, discord.js no longer has control over it
yes but it can be really wonky
every 30 seconds i would run an eval on every slave and return all cache
im not using message or anything of the sort
thats basically gonna double your ram
hmmm, theres that too
i mean
wait
im pretty sure those uber big bots with millions of servers do that
a farm of slave shards
actually
but then again, they dont use discod.js
what if i do it cacheless?
thats even better
out of context this is weird lmao
lmao
each shard is cacheless, on recieving events i'd mimic the same that would happen when discord.js recieves an even nateively directly from discord, where it constructs the message, the guilds, all that
pass it to main and construct it there. Cache in the main client
yes
can i not mimic a sent even from the slave to my main client as it was coming from discord directly, so it handles the cache as normal?
okays thats at least a lot of options, but lets hear your best one, since im worried about performance
all those are DOABLE but probably shit
what do you have in mind?
if i were to make a giant bot
it probably do something like this
lets say 1 million guilds
Uhh so i made a drop command, but i need the bot to know when the first user adds a reaction
how do i do that?
10 processes, in a 10 core vps
each process has 100 shards, using a raw websocket lib
each process receives raw events from 100 shards, and filters them based on some predefined criteria, like commands, prefixes, etc
once an event passes the criteria, it can be sent via IPC to a master process
the master process then does caching, handling, database, etc, and responds directly to the discord rest api
....
this is roughly the idea i had with the slaves i sent above
yes
let the spawner deal with the sharding by itself, it should be fine, but then re-emit everything into master, where the main client is, and simply have the client handle it like it would normally
like, for example
you can trick discord.js into doing what you want
anybody?

i could construct it and save it as new Message() no? there are constructors
though i could simply just attach it to the corresponding maps d.js has
shard.on("message", (event, ...data) => {
client.ws.emit(event, ...data)
})
i dont think i can access a websocket connection to mess with that
thats the idea i was going for
use the websocket in a 3 way
you will need to listen to the raw event in the shards
and use the data recieved from the shard and emit into d.js's main client as a websocket event
and forward the raw data
then emit it in the websocketManager to trick discord into thinking it received it from ws
the thing is
that seems, to me at least, the most efficient and less tricky solution, as it would mean i dont need to update my old code at all
if the slaves dont do anything other than reemit
then you will have a stupidly huge influx of events in a single process
thats why the shards need to do some basic filtering
and hopefully drop at least 90% of irrelevant events
someone help me here 
code
yes
reactionadd/remove/presences/memberupdates/messages, the rest i dont hink i perticurlaly need
so voice stuff
const embed = new Discord.MessageEmbed()
.setTitle('π DROP')
.setDescription(`**Instructions:**\nBe the first to react!\n\n**Host:**\n${message.author.tag}\n\n**Prize:**\n${dropPrize}`)
.setColor('BLUE')
let dropMsg = channel.send(embed)
dropMsg.react('π') ```
and all that garbage could be voided
for example
ignore all precences that do not include genshin
and if you need to listen for when a user stops playing it
keep a small cache of presences in the shards
containing only the ones currently playing
those are the ones i need
which im fairly certain i could just remove intents for the ones i dont need
you need to await channel.send()
else you're reacting to nothing
ok
how do you have the bot say something when a user reacts
this also would mow down a TON of stuff
if you're waiting for a single reaction, like an answer to a question, use message.awaitReactions()
if you're waiting for several users to reach for a period of time, use message.awaitReactions()
if you're waiting for users to react and want to do something for each reaction while waiting, use message.createReactionCollector()
if you want to do something everytime someone reacts, use messageReactionAdd event
its 3am
chats like these are usualkly said in DAPI, its quite hard to find people here who can keep up with what discord does internally
i need sleep
its 3am and same
ty a ton for the insight
i'll make sure to bother you tomorrow, so wait for my wake up call

lmao
whats your wake up call
jk, but for real, ty for the info
rise and shine
a rooster
hehe
my intro with extra bass
What are features noobie devs come looking to make
ask
i can prob help
tim literally just said he went to sleep
,
manager.broadcastEval(
`this.users.fetch('188242504670380033').send('Thanks for voting')`,
0
);
why this is not working
TypeError: this.users.fetch(...).send is not a function
you need to await the fetch
(await this.users.fetch('188242504670380033')).send('Thanks for voting') this not working too
whats erroring
UnhandledPromiseRejectionWarning: SyntaxError: Unexpected token 'this'
needs to be an async func.
don't get your point
...
can you give me more details
manager.broadcastEval(
`async () => {
const userInfo = await this.users.fetch('188242504670380033');
userInfo.send('Thanks for voting')
}()`,
0
);
like this ?
i think that'll work
yeah it working
thanks you
Can I mix discord.js-light and discord.js together
Init client with discord.js-light
and using other remain discord.js
So how can I switch from using discord.js into discord.js-light completely in fastest way
most shit is the same really
if you have MessageEmbed, Collection, etc.
thats the same
const { ShardingManager } = require('discord.js');
like this I have to change all require('discord.js') -> require('discord.js-light')
right ?
yep.
and all .cache.get will move into using .fetch
and in .fetch(id,cache) there always option cache
So I want to make cache fetch on default without pass param is it possible
manager.broadcastEval(
`(async () => {
const userInfo = await this.users.fetch('188242504670380033');
userInfo.send('Thanks for voting')
})()`,
0
);
why this emit shardCreate event and it have no shards.is but it value is
{
_eval: '(async () => {\n' +
"\t\t\tconst userInfo = await this.users.fetch('188242504670380033');\n" +
"\t\t\tuserInfo.send('Thanks for voting')\n" +
'\t\t})()'
}
please dont
you should just use client.users.cache.get('id')
^ that
actually, ur should be using client.users.fetch('id')
there's absolutely no point using fetch, since it checks cache BEFORE requesting
Pros do const user =new Discord.User(client, {id: "id"}) if you need the user object only for sending a message to them
I mean, you're just creating a fake user object that the library gets .id of
Help
Iβm trying to make a bot that counts from a !start command to a !stop command?
ok so quick question, since i've sharded and the guilds get split, what if i have a setTimeout func that executes are a function finishes, something like refilling 8 mana every 3 mins, but because of shards it doubles the refill time refilling 9 mana every 3 mins.. im sure if i use shard.ids[0] === 0 it'll only work for the first shard and wont work for the second shard
@umbral zealot
hey if u still need that command i have a solution but im not sure if its your package https://sourceb.in/3yKjP4n2yC wait i will dm it since much people are gonna type over this message
function isThisPossible(a, b = a) {
return a + b;
}
isThisPossible(2, 8); // 10
isThisPossible(2); // 4
I want to hv the 2nd parameter defaults to the value of first parameter. Is it even possible?
yes it is
bruh the code CuriousBesant sent is correct
there's nothing wrong with it
then why..
If that is correct, then I wont check for b to be undefined. That is already good and clean
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='https', port=443): Max retries exceeded with url: //top.gg/api/bots/697463492457922571/stats (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x0000017FB7E6AC40>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))```
Getting this error
That is in python, I guess?
Show your code
I saw mee6/arcane ... bot and they have a custom avatar and custom status for servers which have premium. After my knowledge they create a second shard for the guild and then they can change the status. But how do they spawn the shard that should contain the premium guild?
.includes
if(client.shard.ids.includes(0)) return console.log("hello");
will it not start executing multiple times?
no when its shard 0 then yes
tf?
if i have a timeout func which does something it should be doubling that
includes(0) will execute this twice if there is shard 0 and shard 1
no just on shard 0
so what will shards.ids[0] === 0 do?
same thing right
if shard is 0
only then
but what about the guilds in shard 1? it wont even work for that?
anyone using akairo here ?
@tired panther
depends on your question
alright so
if i go to my server in top,gg there are all my server but the deleted ones stays aswell how can i get that deleted?
because its to many now
idk about that, maybe wait a while or something
yes
hmm, all my shards are at 82% capacity, time to add more soon ig
flex
use auto mode on shard manager
my shards take 1 minute to start π
u use a another libary?
adding more shards means restarting all the clusters
and i dont do that without manual intervention
disrupting that many servers would piss them off π
oh, u have a bigger bot more than 25k?
65.6
is this the trivia bot?
lol sharding isn't that simple
yeah
no its easy, use discord.js-light
not light enough for me thanks
does discord-js light have cluster?
do you know how to fix dbm
discord.js-light just removes the caching mechanism of discord.js, nothing more
fix it? why, is it broken @dreamy trout ?
if your mindset is just to use a library for everything good luck maintaining a big bot lol
and where do u host your idea? , my hosting is ending π and i do not have any money more. 4k bot bruh
I type command and it's not working
their bot isn't written in javascript
i host at ovh on a dedicated server, bare metal
ik
@dreamy trout unfortunately you cant really troubleshoot, DBM does everything for you, to the point of having no facilities to debug it. if you want to figure out whats going off, you need to learn to code your own bot really
@cinder patio i could turn off caching on aegis, and each cluster would use like 10mb... im actually tempted, but it would mean a ton more db queries
no I mean dbm does everything for me I power on bot but when it's online commands doesn't work either
Brain, what do you cache? I'd imagine you don't need to cache a ton of stuff for a trivia bot
users, guilds, roles and role memberships, channels
most of it is then written to sql for dashboard use when a user issues a command or successfully answers a question
if i turned off caching i'd have to write that data for dashboard use at the point where i see it, which means a HUGE number of INSERT INTO ON DUPLICATE KEY UPDATE for roles when a cluster boots
like literally millions
booting a cluster would go from 20 secs to minutes
the cache is small enough that i'd sooner sacrifice a bit of ram for the cache, than to do that and hammer mysql to death
each cluster is an independent native compiled process that manages 4 shards
now it works but why it doesn't send any emojis
you need the ID of the custom emoji
oh how to get it
thx
this is for u okay
not the bot
oof
I think I need to login from discord bot client
nah
can u get a emoji from the bot cache?
i never do that
so i don't know exactly how
noice
now it does send emojis
I am using akairo and want to using all framework function
Example:
?cf h 3000
?cf 3000 h
my currently args
js args: [ { id: 'face', type: 'string', }, { id: 'betMoney', type: 'number', }, ],
it's working in case one but in second it swap position make anything messy so I there anyway we can do it working in both way without check it in exec() Anyone can help me?
sorry I can't help u I'm not using akiro
it ok
I have a problem. I don't know how to say it but I'll try.
I am making a twitch stream notification system for my bot on discord.js. I have problem about thumbnails. The question isn't about twitch. I am sending an embed with stream thumbnail image. But the original image and embed's image is different.
For example. this is an embed and when I click open original
images are different but same link
!b invite
When I make it .setThumbnail the problem solves but I want it to be .setImage

