#development
1 messages Β· Page 717 of 1
Use http headers
hm
i was gonna say websockets
I've never done real time stuff so I can't reall help there
You would have to update the message that displays the uptime
but not really
and probably let your bot poll the site a lot to see if the site is still online
or a websocket
Make an endpoint in your bots code and have your website query it every few seconds
You can run an offline timer and correct it once in a while, so you dont spam your endpoint
Like a heartbeat
-wrongserver @flat imp
@flat imp
This server is NOT the support server for ANY bot. You need to click on the "Support Server" button on the bot's page, not the "Join Discord" button at the top of DBL.
hey how do u fully restart a bot
ah
π© π
:xd:
oof
havent been on here in a long time
bro half of all my server that my bot is in is bot hell
Oh you wanna make it leave servers?
Using discord.js?
yup
A guild ID is better for that
ight
You can filter and loop over the guilds collection
I think you could put something like this in your ready event:
const guild = client.guilds.get('guildID')
guild.leave();
ah how would i get the id
If the names of the servers are unique for the ones you want to go leave you can just use the names
"It took too long to connect to Discord" // whatever other weird reason could be
api banned can make it say this too
@bot.command(hidden = True)
async def new(ctx, arg1, arg2):
with open('tag.json', 'r') as f:
l = json.load(f)
l[str(arg1)] = arg2
with open('tag.json', 'w') as f:
json.dump(l, f)
await ctx.send('Done')
```with this it will do {"<arg1>" : "<arg2>"}, how to ```py
{
"user_id" {
"arg1": "arg2"
}
}
```?
discord.py
So I got a question
How Would I Port A Variable From A HTML
Lets Say
The Variable is a time
So in the html, launched as a webpage, you can choose a time
then the bot can get that variable
Or in the case I'm using
<button onclick="window.alert('Reset Request Sent'); var tagBreach = true;" style="background: rgb(200, 0, 10); color: cornsilk; font-family: Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif;">Click to Request Link change, In Case Of Breach</button>
Then the JS file can read to see if tagBreach is true
@fallow quiver webhooks.
Or store it in the file, and have the bot check every x seconds. (Bad idea)
for a change
It's meant to be a password for the mod settings, it can be manually changed if it gets leaked
Thanks, I'll look into them
Do shards output to the main process?
any way to get out of this if statement hell? https://bruhh.wtf/Kv1cZHEgRL.png
From the looks of it you could probably throw a few &&s in there
or whatever your lang's 'and' is
@tranquil drum try throwing things into functions
it doesnt change the line count
but it makes it easier to read
Hey
You could do
if(event.getUser().isBot()) {
return;
}
if(event.isFromType(ChannelType.PRIVATE)) {
return;
}
...
or
if(event.getUser().isBot()) return;
if(event.isFromType(ChannelType.PRIVATE)) return;
...
you can also do things like if (xyz) return;
instead of nesting everything just break out of the function
oh, exactly what joakim said nvm
Those "early returns" are called guard clauses. You should definitely use them π
yeah yk you could just combine a simple logic gate like if(event.getUser().isBot() | event.isFromType(ChannelType.PRIVATE)) return;
hi
How I can play this on a voice channel using d.js? https://translate.google.com/translate_tts?ie=UTF-8&q=hi&tl=en&total=1&idx=0&textlen=2&tk=349084.260684&client=t&prev=input&ttsspeed=1
i am trying with .playStream but it doesn't play
if I try to make it say hello there it says only hello
the last words doesn't gets played
is it allowed that i make the bot not respond to a specific person?
yes
perfect
So long as it doesn't intervene with the review process if your bot is in the queue
nah i will only ignore the one and the only person who gave me a death wish (which backfired immensely) so i don't think it should intervene with the review prozess
Quick question, when my bot mentions somebody, (through ${msg.author} or similar methods), sometimes the mention is fine, as you'd expect, @solemn plank, however sometimes its just <@userid192938294>. Anyone know what causes this inconsistent behaviour and how one would fix it?
Your Discord cache
that doesnt make sense
assuming discord.js, the library automatically caches the message author before firing the message event
^It'll show as <@userid> to any user that doesn't have the mentioned user cached
It will still be a valid mention
but if the person was online at that moment, their discord will cache the user because it sees them sending the message
unless its someone who was offline and opened discord later
and the message is older than what discord preloads when you open it
and even then, discord should load user information the moment it loads a message
the only real reason i see for it happening is that the user who used the command left the guild
What's the best way of looking at JS class/objects sizes on core dumps
It looks like my bot slowly leaks memory, going from 5gb to around 14gb in 17 hours
how many guilds?
5.4k
It depends on his use case, it can be really annoying.
An example using one of my bots:
It's a recruitment thing for groups on the bot, but most mentions on it look like that because they aren't cached as it's a big server where most people won't be cached
All of those users are still in the server
I'm most likely going to switch to a different approach as it's very annoying especially for end users that have no idea what's going on when they see that
ah
But end users aren't always that smart to realise that
Yeh
usually done by trying to mention the other uncached user
I'm thinking about making it a thing where the one posting the recruitment would get a special role giving them access to send the recruitment message themselves
and then remove the role right after they posted
If it's their own message, people can just click the name and DM them from there
I'd just have less control over the format they use to post it

@split hazel thats way too much ram for only 5k, are you using js?
yyes
do you have zucc installed (a npm package)?
I think ram fills up faster from the users than from the servers its in
yes, but guilds are easier to use as a metric than users
nope we dont
how many users are cached when itas at 5g and when its at 17g?
at around 5g its at 500k cached for one of the shards
it may not be the users
its at 10g now and its 570k users cached for one of the shards now
how do i code to make a discord account for a bot or something
@split hazel the 10g is only that shard or all shards?
you might have a memory leak thats not related to discord
could be something in your own code
well, how about sweeping those caches?
i'm not exactly sure which object/class is using most memory is the thing
which is why i wanna figure out how to look at js objects in core dumps
@split hazel would this help?
https://www.valentinog.com/blog/memory-usage-node-js/
i wanna try do it inside the ubuntu server, using chrome and downloading the dump is my last resort
you can use remote debugging, but it requires free ram equal do the used ram
if you have like 40gb ram its doable
i should have enough, i'll try that
idk if this one is up to date, but its more or less like that
you will probably need an ssh tunnel as well
Lets assume i use Axios for web request, how could i make a request and pull a image from the website?
is the url of the image not known or dynamically generated?
if it isnt, just request the image directly
if it is, request the body, and extract the image url from it, then request the image
https://github.com/TheDrone7/disco-oauth could anyone recommend any improvements for this lib? Please don't say stuff like "Why are you doing x", "I don't like the way you handle x", specify what actually can be improved and how.
A library for easing the use of https://discordapp.com 's OAuth2 API - TheDrone7/disco-oauth
Thanks.
@quasi forge i would advise dropping request and using something like node-fetch or got
the reason is that request is nearly 5mb big
yes, but there are many alternatives to request
Node-fetch is kinda buggy
for example got is very good, and in many points better than request, and it only takes up 300kb
I was originally planning to use it
that lib is vulnerable to csrf attacks
Never heard of got tho
check it out on github
Yea
@earnest phoenix I would like to know how
you don't have a state parameter anywhere
meaning anyone can make a request to www.example.com/login?code=oauth code
to anyone's account
exposing the user's information
@earnest phoenix it's only a library for making the http request, not for making the website, the library user will have to make their own servers
@quartz kindle thank you, I will surely move it to got
as the library dev you should ensure your users are secure
forcing them to fiddle with your lib's internals to get lacking protection is a red flag
that's a common mistake in oauth implementation which is how idiots leak their email
I'll try adding the state as well then.
also you should probably handle ratelimits
Pretty sure the backend devs should be able to handle it but I could make slight modifications
to avoid users being api banned
Yea error handling is currently under development
I haven't pushed that to GitHub yet
Cuz I was having some issues but that's what I was working on currently.
Hey, would anyone using d.js know how to wait only to be logged in when you use Client#login, what I mean is only wait for client information and not for all guilds to be cached. Im on a very slow connection and doing UI stuff, so waiting for all guilds to be cached before being able to display appropriate information is a hassle.
The ready event in libraries is fired after the guilds have been cached. I think using partials might also modify this behaviour
@shadow dust you can do that by messing with the raw events
i messed around with it before, basically the readycheck in discord js compares if the guilds store size is equal to the total guilds
the ready event is not fired until all guilds are cached
but you can disable processing of guild packets via disabled events
and you can fill the store up with fake guilds
another way to speed things up is to set the large threshold to the minimum (50 i believe)
this will make discord only send you 50 users per guild, thus making the guild packets faster
the first ready packet gives you an array of unavailable guild objects
you can use those to fill up the guild store with guild partials and trigger the ready event
that still wont help you with shards tho, as discord only accepts one login every 5 seconds
hey i'm using process.memoryUsage().heapUsed to find my bot's ram usage and i'm converting it to MB
so if youre making an UI for a sharded bot, it will still take time before it can access all shards
and i wan tto make it so that if it's above 1000 then it get's divided by 1000
@cursive gale use rss, not heapUsed
heapUsed is the actual memory used by the js code
rss is the total memory used by the process
so process.rss?
I see
the memory usage that your operating system reports is similar to the rss
memoryUsage().rss
Thanks for the advices @quartz kindle
for example, heapUsage might tell you your bot is using 10mb ram
but the full node process its actually using 50-60mb
so using rss is more accurate
as for the divisions, divide by 1024, not 1000
if rss > 1024, divide by 1024 and append "KB", if its still bigger than 1024, divide again, and append "MB" instead
ok
thats the basic logic
you'll probably also want to use string.toFixed() to limit the number of decimals
yes i did that
@quartz kindle do you know how to get the the total number of users of my bot?
on what lib
@cursive gale to get an accurate number, you need to loop over all guilds and sum their memberCount
the best way to do that is to use guilds.reduce()
ok
its an embed
how
Color : 'RED'
you cant do it on a user account
You will
look into your librarys documentation
Β―_(γ)_/Β―
Title
That's An Embed
@wheat fern its not
stop giving misleading info
it's embed
embed != blockquote
how did you do it then
ik dis
on a user account
idk how red
you just cant
ok
a normal user account cant make embeds atm without breaking tos. bots can
and that is not an embed
One message removed from a suspended account.
One message removed from a suspended account.
if (command === 'help') {
const embed = new Discord.RichEmbed()
.setColor(config.defaultColor)
.setTitle("Current avaible commands")
.setDescription('**Prefix:**' + config.prefix + '\n__**Commands:**__\nhelp, leaderboard, daily, slots, work, dice, coinflip, transfer, balance')
message.channel.send(embed)
}
anyone knows why it returns TypeError: Cannot read property 'length' of undefined
doesnt look like you use length in that code snippet
well I changed prefix in the config maybe thats the error
yeah was the code at the start up
I didn't change it yet
ok problem solved
im so stupid sometimes
me too
bro my bot wont start up
is there a reason
just pm2 being a big no
but
ββββββ¬βββββββββββββββββββββ¬βββββββββββ¬βββββββ¬βββββββββββ¬βββββββββββ¬βββββββββββ
β id β name β mode β βΊ β status β cpu β memory β
ββββββΌβββββββββββββββββββββΌβββββββββββΌβββββββΌβββββββββββΌβββββββββββΌβββββββββββ€
β 1 β a β fork β 15 β errored β 0% β 0b β
β 0 β index β fork β 194 β online β 0% β 4.6mb β
ββββββ΄βββββββββββββββββββββ΄βββββββββββ΄βββββββ΄βββββββββββ΄βββββββββββ΄βββββββββββ
oof
that is a nice table ^^
ikr

i wonder if some low iq here actually ran that
F
again 
if you sudo it
everything gone
it doesn't
now pm2 is being bad boy and not starting up my f****ing bot
have you actually checked pm2 logs?
How i can copy any embed with eval??
usually in a library a message object will have an embeds collection/array
get the first item out of that, you'll have to copy it's properties over to a RichEmbed if using d.js
I can't ?
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
xd
One message removed from a suspended account.
Δ± am having trouble with this can anyone help me
remove msg.author.addRole(uye) and change to msg.member.addRole(uye)
ok 1 minute
thanks Δ± am having troΔ±uble with it about 1 hour and 30 minutes
whats your bot Δ± want to add it
π np (tΓΌrkΓΌm xd)
ΓΆnemli deΔil xd
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
Δ°nsteresting xd
@sage bobcat how are you reading/loading/running it?
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
how are you reading/loading/running it?
One message removed from a suspended account.
One message removed from a suspended account.
show it
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
nothing, or undefined?
One message removed from a suspended account.
One message removed from a suspended account.
does it even receive messages then?
One message removed from a suspended account.
console.log(prefix)
One message removed from a suspended account.
on the beginning
One message removed from a suspended account.
One message removed from a suspended account.
right after client.on("message")
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
i noticed it now
you have prefix = require("configuration")
so prefix is the entire configuration file
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
should probably be prefix = config.prefix
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
client.aliases = new Discord.Collection();
One message removed from a suspended account.
That's mine
Lmao
Lmao
const embed = new Discord.RichEmbed()
.setTitle(client.ping)
const Discord = require("discord.js")
module.exports.run = async (bot, message, args) => {
message.channel.send("Pinging...").then(m => {
let ping = m.createdTimestamp - message.createdTimestamp
let choices = ["Pong! :ping_pong:", "Pong! :ping_pong:"]
let response = choices[Math.floor(Math.random() * choices.length)]
m.edit(`${response}: Bot Latency: \`${ping} ms\`, API Latency: \`${Math.round(bot.ping)} ms\``)
})
}
module.exports.config = {
name: "ping",
description: "ok",
usage: "!ping",
accessableby: "Members",
aliases: ["latency"]
}
well
let choices = ["Pong! π", "Pong! π"]
ik
One message removed from a suspended account.
send code
One message removed from a suspended account.
you π didn't π define π it
command file isn't defined in that scope
anyone can help ? i get an eror
One message removed from a suspended account.
tricky one to find
oouh ok i find it
https://oliy.is-just-a.dev/5jq9xo_1908.png @sage bobcat
that is the kind of code they give you at a test during your study, they upper or lowercase 1 letter and ask what the bug is
thanks @amber fractal
define it before you use it
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
you define it after you use it
One message removed from a suspended account.
the first usage is commandfile.run(client, message, args);
he put that line there accidentally lol
show your new code then
he has to remove it, not define it
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
can you show the code you have now then?
One message removed from a suspended account.
does it log anything like ready before it goes unresponsive?
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
hey
One message removed from a suspended account.
i'm making a server info command
One message removed from a suspended account.
how do i get the creation date of a server?
One message removed from a suspended account.
that's props I'm guessing
One message removed from a suspended account.
ok
is that the only command you have at the moment? @sage bobcat
got it
One message removed from a suspended account.
actually why do you even have that line at all, if you deal with aliases two lines after it anyway
One message removed from a suspended account.
How do I make a bot message refresh every 60 seconds for python?
@sage bobcat .set() cannot be used with only one argument
you cant set anything without setting a value for it
and you're already doing the exact same thing two lines below
It defaults to undefined, it wouldn't cause an error I dont think
does it?
welp alright then
but it will take up more memory nonetheless
that line is still useless
how would I make a python bot loop and refresh message every 60 sec?
I don't know python, but you would want an interval of some kind
can't help you with the code around it because i don't know it
you want some kind of timer, but i also dont know anything about python
how?
finally running bot on google cloud
i get eror again
what error do you get?
that's the trace log, what does it say at the top of the error?
for up time robot
scroll up in your log and show us the first lines of the red text
I dont know anything about JS, so you will probably have to wait for someone who can help you with an unhandled promise rejection
oouh ok
or maybe google can help you
Those aren't the first lines
something through an exception inside an await
the unhandled promise rejections tells you exactly what an unhandled promise rejection is
You'll have to show what went wrong up above that
^
@brisk spruce just show the whole error
if you can't do that then why are you coding?
He's got point, why is it that hard to show the full error
have you thought about not using glitch // whatever free host that is
that is indeed glitch
glitch and heroku = shit
selfhost or buy vps using galaxygate (cheap)
how do i get guild emotes?
it's less reliable
welp...
lmao people who think selfhosting is genuinely better than a vps
it depends on your internet connection and you have to account for power outages
plus the cost of a server is too much for 99.9% of bot developers
uhm
physical*
yea i cant buy a vps lul
resberry pi is good for hosting
if anything like that happens at a hosting company they can switch to another server farm
while selfhosting you're fucked and you have to wait for the issue to be resolved
bro a vps is like $2/month
im pretty sure a decent physical server is like 5k or smth
dont take my word on this, but if a vps is $2 a month
where is it $2? @brisk spruce
i can find $5
where to place it lul
you could pay off for way longer than you'll be interested in hosting a bot
i can't find $2 vps anywhere @tranquil drum
if you want beefy storage go for digital ocean
@cursive gale https://buyvm.net/kvm-dedicated-server-slices/
though to be fair when will anyone ever need like 250gb of disk
general usage
what general usage do u have on a server
is it legit?
you can always use cloud storage if you need more
emm
SkySilk offers 50% off for 3 months on their VPS for new users
oh skysilk
bruh ss
that
yeah all my services are on it @cursive gale
it's your host?
i use them to host my projects
i host my file api on the same server as my discord bot lmao
ohh
remember it being free until it "oFfIciALLy reLeAsEd"
awesome $2 vps is not bad
i have 2, one for my projects and 1 for a database
not mine but im just hogging of someone else 
What's the issue with the "public release"?
You needy boi
oh yes
id rather invest in a stable vps company 
@tranquil drum for now i'm good with my 16GB Ram dedicated server
wait u have a dedi
not me
anyway
a kind man gave me
lol
lmao ok
nice lol
i wouldnt even know who it is if i really actually had to ask
can't find any place that sells 1TB RAM 2-4PB Storage nodes
plus the only thing i have to host is my discord bot which my friend is already doing
so
@cursive gale just use cloud storage
all tho internet is not very good
can someone tell me?
@tranquil drum do you know how to get the guild emotes?
use a guild emote with your bot?
Does anyone know how to get ws ping and client heartbeart (on d.js)
client.ping?
too many logins?
you only get 1000 identify's a day iirc
so how long is the ban?
just reset ur token
thanks
didn't seem to work though
the ban is 2 hours if im not mistaken
but are you sure thats a ban? can be rate limit due to concurrent logins
you can only login once every 5 seconds
if you're trying to login multiple shards at the same time, you'll get that too
wasn't it an hour?
could be, i dont remember

A ban would most likely return something along the lines of forbidden access
A ban would most likely return something along the lines of forbidden access
no
the api ban behaves as a big ratelimit
429
So how can i correct tha ?
I don't know anything about NPM and JS, but it looks like something went wrong while downloading d.js
Maybe try the command again, something might have gone wrong while transmitting the data.
Else I also dont know
they probably fiddled with their package.json file manually
Nop.
hey
rn i'm using .rss to get the used memory for my bot
i wan to get the total memory usage of the bot on all shards combined how would i do that?
can anyone help me?
@cursive gale if you're running shards on separate processes, the only way is through ipc
discord.js's sharding manager has its own ipc you can use: broadcastEval
@ornate hawk you can an error in your package.json file
Which permission allows the bot to fetch invites?
await message.guild.ban(x.id)
});```
if i use this command bot will down :D?
what
Wut
why does it only is executed 3 seconds and than no more : ```js
const Discord = require('discord.js');
const client = new Discord.Client();
const fs = require('fs');
var date = new Date();
var timestamp1 = [ "[" + date.getDate() +"."+ date.getMonth() + "." + date.getFullYear() + "] " +date.getHours() + ':',date.getMinutes() + ' Uhr,',date.getSeconds() + 's,',date.getMilliseconds() + 'ms']
var timestamp = timestamp1.join('')
//console.log("bla",)
console.log2 = console.log;
console.log = function (msgparam){
console.log2(msgparam + " " + timestamp);
};
client.on('ready', () => {
console.log(Logged in as ${client.user.tag}! /**+ timestamp*/);
client.user.setStatus('idle')
});
client.on("message", message => {
if(!message.author.id == "406447103964086282") return;
if(message.content == "!move"){
let channelsall = Array.from(message.guild.channels);
};
});
other bots execute normaly
@quartz kindle hey sorry to bother you, you mentioned I could decrease the large threshold per guild Im wondering how I'd achieve such a thing with d.js
i tried but it didn't work can i get an example code it really helps @quartz kindle
@quiet topaz assuming that's your entire code, you never login.
@shadow dust you're probably talking about this https://discord.js.org/#/docs/main/stable/typedef/WebsocketOptions
It's a websocketOption that you add to your clientOptions
Yes thank you so much

@late hill oh, right, i overlookt it π
What does Error: Cannot find module β./config.json mean?
what do you think it means
I donβt know, Iβm pretty new to coding. Iβve made my bots file separate from my config.json.
I dont know js, but my guess is that it can not fine config.json
do i win?
nice
gratz I suppose XD
How do you overwrite permissions on a role?
lib?
node.js discord.js
Someone can help with an array Client.guilds?
I want to get the id list of all guilds, but I donβt understand how to do it
Already tried everything
use map
Ohh, thx you bro @earnest phoenix
Just finished writing my first github project
and?
ok i have feedback
mostly it's good practice to put event handler functions into their own files
especially the message event
second
// Your Twitch Username (optional)
const USERNAME = "";
this line is present in your code despite something about twitch also being present in your .env file
Putting event handlers into multiple files for such a small bot is a waste of time imo
putting event handlers into multiple files makes your bot not only easier to scale, it makes reading it easier
or you could be a chad and write a 4000 line index.js file since that's what it gets compiled into anyway
for?
actually I think i may have gotten it to work
Vysion that's the point. If your bot is large and has a lot, an event handler with different files is recommended. However, in my opinion, if your bot is only for a small function (like the one above) and doesn't have many lines, I'd say doing it within your index.js or app.js is fine too.
If it's going to be larger, sure. Just don't see it as a recommendation just because it's cleaner
even if it is a small bot i find it just as good practice
it is; I just don't find it necessary (recommendation wise) 
h m
the cooldown somewhat works
but it doesnβt send the message when the cooldown is done
discord-eco :omegalul:
you're returning regardless. Return if they are in the cooldown
why are u using discord-eco
Because.
if you want to make a rpg bot you should know how to use sqlite urself
I can use the packages I want to use, lol.
tis unnecessary
Thatβs your opinion.
You make your bot your way, I make my bot my way.
this is what happens when I remove return;
It sends both the cooldown and regular message.
How can I get that to not send the regular message when the user is set on cooldown?
like I said, return if they are in the cooldown. btw your phone's about to die
it will still run code below it
yeah i plugged it in
Hm...
How would I change it then?
Iβve been struggling with this command for an hour today lmao.
how wouldn't it
that's the same case for any ratelimit except stored ones (db)
and it might probably uh
take up more ram just having settimeout
idk
lmao
probably doesnt but eh
Im still confused. 
bruh
what the hell
for some reason
my commands work on my first server
but wonβt work on any other servers
can any one tell me where do i get this key???
https://cdn.discordapp.com/attachments/629663066035847178/637832061851271168/Capture.JPG
pretty sure that's just for you to come up with
Anyone know any simple image apis that are easy to use? Trying to make a "hug" command which would send a random pic of someone hugging
so you know dbl is sending the request
and you might wanna delete the webhook if that's the full id
Collier, have you tried Tenor's image API?
I have not looked into it, can you specify like tags on it?
samurai confused
yes
oh wow thats easy :p Well thanks anyways
can i remove this outline
with css or anything
nvm i got it
input:focus {
outline: none;
}

oki
Hey, so for those of you who do JS stuff, What's the difference between new Function(code)() and eval()
they're basically the same
however
eval() evaluates a string as a JavaScript expression within the current execution scope and can access local variables.
new Function() parses the JavaScript code stored in a string into a function object, which can then be called. It cannot access local variables because the code runs in a separate scope.
https://stackoverflow.com/questions/4599857/are-eval-and-new-function-the-same-thing
basically with new Function() you can't access locally declared variables outside new function()
i want to make a profile command but i sorta dont know how
@valid frigate thank you
use lavalink/lavaplayer :P and a good host
Is lavalink an npm module?
its a java api
Hw about on js
that you need a client library to connect to
discord.js-lavalink
is the lib for js
hey
i have a logging system which logs user stuff in a channel
i started to make shards for my bot
now it gives me errors that it can't find the channel as that shard is not on the server
can someone help me?
i tried this: ```js
bot.shard.broadcastEval(`
const channel = this.channels.has('${636625617382801418}');
if (channel) {
channel.send('test this works');
}
`)```
but it just dosen't send anymore it's a test code BTW
no errors on the console
@cursive gale ${636625617382801418}
how do you think that'd work
drop the template literals
ok
also i want a shard to send me dms when they start/restart how would i do that? @sick cloud
look at the docs and work out the events
ok
it depends if you're using internal sharding or the sharding manager though
i'm using d.js sharding manager
then just use the ready/disconnect events
ok
has returns a boolean, yet you then try to send to it
you shouldn't
that's spamming 20 log in requests every time
you'll just reset your token
ohh
at most 1 or 2
ik 4?
*ok
my friend taunted me and said spawn 50 then so i did does that mean...
ohh no
you'll probably just have 50 less launches
yeah and those bots get double the launches
discord gives you 1000 launches, bots over 100,000 servers get 2000
ohh that's why
what if a bot is in 1mil severs?
discord will give more launches then?
@sick cloud hey i got a new error
err doesn't exist anywhere in the function
and if you hit that far discord gets more lenient
ok
your token is invalid
check your email for a token reset email or just reset the token and use the new one
ok sry i somehow got this habit of mentionning people
Invalid or Unexpected token = some }{ (; is missing
Im not sure + you could use webhooks instead bot client spamming in the channel. @cursive gale
idk how to use weebhooks
lemme send u tutorial
ok :))
https://anidiots.guide/discord-webhooks (start with webhooks part 1 if u never used them.)
ok ty :))
np
how do i get webhook id?
By creating it
go to the channel
then go to webhooks
and then press create new
and then u get the id
is it the /api/webhoks/number?
ok ty
nono its token, you can check the id by going it
and then copy the "id": "number" @cursive gale
How can i make an Prefix like: bot help
wdym
set your prefix to bot
oh u mean like botmention help?
just put <@urbotid> as prefix, that should work.
@sick cloud well but the space is the big problem
@restive furnace nah elsr i would say @botmention
Code your own bot so that'll you understand how the splitting up between command & args works
how is it a problem
And there shouldn't be a problem
@fallow spire it isnt actually a probelm just put prefix as prefix (space) <<<-- theres space after it.
yes
that should work
also you should use .env file for storing data instead of a json in my opinion .env is better @fallow spire
lmao tony
@cursive gale well how do i point to that file
ok
ur eris @Vysion#3272
dont be like me
meh
i just would use @botname as another prefix and space.
omg you serious @valid frigate you use that?
i am very gay
i just use startsWith
but most of the time you dont need to use spaced prefixes
nothing crazy
@sick cloud Your Eris aswell
lol thaaaaaat can be written in 1 line kinda
i too use startsWith hehe
@restive furnace well show xd
i use a command handler
same @cursive gale
me too who wouldnt?
ikr
@fallow spire what
anyone who want main file being 1gb, maybe?
wdym
@restive furnace Sureeee
august looks at me with a funny face
i use d.js
i use d.js
i use both
@restive furnace same
go eris
i'm d.js too
@sick cloud Thats pretty gay
well to be fair
lol
i wrote a cluster library in eris
eris = harder ver of d.js?
Yep
eris has less utilities
if you want performance then eris
djs is beginner friendly
WELL, HOW CAN I MAKE THAT NOW
calm down
an eris rewrite doesnt take too long
i use my own library sometimes but it's not done
no like
i have to travel 12 hrs in car in an hr
awesome sounds cool
where can i signup? @sick cloud
ok
it's free real estate
(node:3849) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 ready listeners added. Use emitter.setMaxListeners() to increase limit
Where i put .setMaxListeners()
event within event i bet
tf's that
i will rewrite to eris when i added basic cmds first.
you attached 11 ready event listeners
OMG
how what tf
teach me @fallow spire
i laughed
tf 10 ready listeners who need em?
gucci gang
I only have 2 xD
psst uber
?
just use 1
it's just opinion wise
Well But WHERE TF ARE THESE 10 READY 'S
i like eris but if you do it right djs works just as well
nothing is better
nothing is better
it's just what people prefer
lol
well thats a heated debate, djs is honestly better if you take advantage of all the QOA and stuff it provides, but if you dont absolutely need it, eris is pretty much just djs with some useless stuff removed leading to less overhead
my library doesn't cache anything so, it > *
so its sorta specific usecase
miles is making us a really cool custom library though
for them hyper performance
and automatic scalability
whaaaa anything
(remove caching when)
who needs caching
what is thiss



