#development
1 messages · Page 1501 of 1
so when you do instance.something() you're doing A.prototype.something.call(instance)
all class methods are stored inside the prototype, and all class instances share the same prototype
so the functions are all the same, but they are called with different this
and how the inheritance work?
there are 4 functions that override the this variable, .call() .bind() .apply() and function declaration
an extended class with new methods will create a new prototype that is a merge of both prototypes
Confusion for noobies
but the functions in the prototype are still references, not copies
hello Extreme
Hi
yea
js is very smart
its all coming together
sometimes too much smart
you think?
On today’s TimTalk?
Js is to smart
V8* is smart
js still flops in GC
what is this GC?
garbage collector
so y its bad in it?
imagine not failing bio
this is the reason why chromium eats so much memory, really bad garbage collection
mhm
you can manually sweep it
or thats just built in to V8
yea if you really want performance
or fork v8 and add manual memory management instead of gc
modern languages take away the pain of managing memory
that's a selling point for a lot of them
though c++ also has ways of making memory management easier... shared and unique pointers
f I announced my app name literally
having an automatic GC doesn't mean lesser performance though, it just needs to be done properly
for example .net5 has an insanely good GC, knowing when to dispose objects, when to spawn objects on the heap etc
at=error code=H14 desc="No web processes running" method=GET path="/" host=app.herokuapp.com request_id=dbc0b235-6844-44cc-93db-f894e7b9a1d3 fwd="37.69.201.69" dyno= connect= service= status=503 bytes= protocol=https
ok well, you do'nt have a web process running 👍
your app must have a web process
it has
what does your Procfile look like?
that's a worker process
And my index.js contains
server.all('/', (req, res) => {
res.send('Plubin is up');
});
server.all('/favicon.ico' , (req,res) => {
res.send('Not provided');
});
server.listen(PORT, () => {
console.log(`Server is up on port : ${PORT}`);
});
yeah
wait,
web and worker are different ?
yeah
This person just died
you'd have to split your server and bot into two processes
well
at least if you also got a bot running or something
I'll put both on cuz I'm using webhook too
k
yeah it runs
whats server.all vs server.use?
server.all is just for that route
server.use is for the route and every of its sub-routes
yea
@near stratus for a favicon you probably just wanna use server.get
i mean, no one's gonna try to make a delete request to your favicon
I might 
@mellow kelp thanks it works now

np
does anyone know how axios works? im trying to make a command that calls an external api but i keep getting this error
data[0] is undefined
wait it works if i just do res not res.data[] thanks
you probably have a syntax error right before that
@bot.command(name='botusers', help='only vissible to devs')
@commands.is_owner()
async def botusers(ctx):
await ctx.send(f'{len(bot.guilds)} server count')
await ctx.send (f'{sum([g.member_count for g in bot.guilds])} user count' )
await ctx.send([m.name for m in bot.guilds] )
await ctx.send ([g.name for g in bot.users] )
this gives me names of users form every guild
but is there a way to isolate and get the name list for a given guild name??
guys??
what in the living fuck
Create one big string and send it once instead of sending separate 4 messages
lol
Also what do you mean by that
they're probably going to exceed 2000 char limit with the last two messages
Names of members of a specific guild?
yea
Which guild specifically?
Could be avoided with a few tricks with string length checking :p
like if my bot is there in a server ; bot
i shold be able to get the names of botusers foronm that guild alone like
#botusers bot.. should bing me the names
keep in mind that multiple guilds can have the same name
you should use the guild id instead
hmm
so how do i write a code to get it with server id
await ctx.send ([g.name for g in bot.users] )
can you set more than one key in a map
client.react.set(msgid, { ///this saves the msgid in a map to prevent a fetch
guildid: guildid,
msgid: msgid,
reaction: emoji ,
roleid: roleid,
dm: dm
});
``` link mgsid + emoji as key
I want to delete the map entrie with msg id 01929 but with the emoji 🤑
is it possible, without a for loop
Anyone know of any way to embed the top.gg reviews section into another site without using iframes?
is it available via the api or something?
you seem to be only using the message id as the key unless im missing something?
I dont believe anything with reviews are available via the api.
you can use message id + emoji string as the key and then just delete the same thing
Pretty sure you'd have to scrape the reviews
yes msg id as the key
in two seperate strings?
in one
when I use a array?
what
I wonder if I could just fetch it using the URL the browser fetches from
uff
234703377999593472 + 😆 -> "234703377999593472😆"
the browser isn't only fetching reviews, it gets all the data from the site. And, if my understanding is correct, it probably even does server-side rendering anyway.
then I have to split them 😭
No, it fetches /js/reviews.js, which I also assume then fetches another external URI
I could be wrong though
no that`s javascript
why?
not data
eh the js is obfuscated anyway
Can confirm that's server-side data (straight from the source, so not rendered by JS)
bc when I want to have reaction roles , then I need the msg id
So scraping would be the only way
ah, that sucks
...so?
Well, this is going to be interesting
oh thx have a id
In JS, puppeteer can do that in a jiffy
tbh I could just cut out the reviews div and slap it in my page
the problem is cloudflare and encountering a captcha
yeah sure just grab .reviews_wrapper 😄
captcha? 
cloudflare will throw a captcha at you if your requests are sus
then do it entirely client side
I highly doubt that it'll captcha me
even if it does, I could just fallback to iframing it
It certainly won't if you do, say, a cache that refreshes only once an hour or twice a day or something
Well yeah, I just remembered CORS exists and might become a problem
so client-side might not be entirely viable
https://this-is-a-really.questionable.link/ZNJQX4 yeah CORS doesn't like that
freakin cors
F
How 2 code 4 dummies?
im sure the company that makes those books have one on programming.
hey, how do I get the code for this description in a good looking position?
Well, youd have to decide that.
set a div's position to absolute and do whatever you want
and also increase its z-index
Does anyone know how to check channel permissions for the bot on discord.js
client.guilds doesn't have a get method
you're probably looking for client.guilds.cache.fetch(id)
channel.permissionsFor(someUserOrMember)
No
oh wait
okay thanks ive been checking for the guilds p[ermission
yeah guilds are cached
<Collection>#fetch() isn't a thing
<Client>#guilds#cache returns a collection, use <Collection>#get() on it
did you login?
const channel1 = message.mentions.channels.first()
message.channel.send(channel1)``` how do you have the command include a mention?
command include a mention?
yes, but the bot can see if i actually mentioned a channel
how did you create client?
if you're using a command handler, you don't need to define client. put message infront of client to define it
just put it in an if statement to find out if any channels where mentioned.
what permissions does my bot need to send a message, is it just SEND_MESSAGES?
cause im getting a error saying missing permissions
It also needs permission to view the channel.
oh that too
as in, you can't send a message where you don't have rights to view that channel, that wouldn't make much sense ^_^
but if the bot cant view the channel how does it know the message was sent?
but it was missing EMBED_LINKS
thats wrong
still missing one permission but idk what it is
client doesnt exist in discord.js
Client exists
and Client is a class so you need to instantiate it but you probably already have an instance, so you shouldnt even be trying to instantiate it again
let id = document.getElementById("id2").value;``` the func accesses elements in the dom, it needs to be in the top or bottom of thr html?
in head or bottom of body?
always bottom of body
return reject(new DiscordAPIError(request.path, data, request.method, res.status));
^
DiscordAPIError: Missing Permissions
at RequestHandler.execute (D:\Bots\Ranger(V1.4.4)\node_modules\discord.js\src\rest\RequestHandler.js:170:25)
at processTicksAndRejections (node:internal/process/task_queues:93:5) {
method: 'post',
path: '/channels/691253619797786635/messages',
code: 50013,
httpStatus: 403
}```
is the error i get
you need to make sure everything loaded first
alr
like last time when someone asked you to use onload, you could have just put your code on the bottom and it would have worked
also, i made the func async but its really not updating
i updated the file in the webserver
again, check your console
function edit_bio() { < website
async function edit_bio() { < code
it does give errors
profile.js:4 Uncaught SyntaxError: await is only valid in async function
what are you sending?
it still does
it's not uploading correctly then
all it is is a message sending
but what are you sending
text? image? audio? link?
text
only text?
does it need permission to access channel id or anything
no
profile.js:4 Uncaught SyntaxError: await is only valid in async function
function edit_bio() { so its not updating
does fetch HAVE to be await?
@pale vessel
hgere is the full script
.cache.get
//////Modules//////
module.exports = {
name: 'setlogs',
execute(message, client, fs) {
//////Permissions//////
if (message.channel.permissionsFor(message.member).has("SEND_MESSAGES")){
if (message.channel.permissionsFor(message.member).has("VIEW_CHANNEL")){
//////Main-Code//////
let fullCommand = message.content.substr(9)
if (fullCommand == "false"){
message.channel.send("Logs have been Disabled")
client.Server ["Log" + message.guild.id] = {
logchannel: "false"
}
fs.writeFile ("./data/Server.json", JSON.stringify (client.Server, null, 4), err => {
if (err )throw err;
console.log("Server Data Updated "+message.guild.name);
});
}else{
client.Server ["Log" + message.guild.id] = {
logchannel: message.channel.id
}
fs.writeFile ("./data/Server.json", JSON.stringify (client.Server, null, 4), err => {
if (err )throw err;
console.log("Server Data Updated "+message.guild.name);
});
message.channel.send(`<#${message.channel.id}> Set as Log Channel`)
}
}}
}};```
No
You can use .then()
But that's not the problem
Your website isn't updating
check if the channel you're trying to send it has any permission overwrites
but since it checks the permissions shouldnt it show no errors
I’ve been trying all day to figure out why it’s not working ^ no it’s not my command handler
do you not have console
show your code now
weird choice to do Number() and not parseInt but okay
is there a difference?
not sure myself
Number parses floats as well
well actually here parseInt would be better
but realistically is there a difference?
No
you can't delete 3.5 messages so yeah parseInt is better in this case
So what’s the problem you guys see?
Lines? Lol
read
You don't check for if the amount is NaN or if the amount is < 1
^^
You also cannot pass a float. Number parses floats like Google mentioned
floats, round, nan and natural numbers
So
fix all those
(Number, args[0]);
What?
amazing
Lol..
@earnest phoenix Before you make a Discord Bot, you should have a good understanding of JavaScript. This means you should have a basic understanding of the following topics:
- proper syntax
- debuging code
- basic features (vars, arrays, objects, functions)
- read and understand docs
- nodejs module system
As much as we d like to assist everyone with making their bots, we rarely have the time and/or patience to handhold beginners through learning javascript. We highly recommend understanding the basics before trying to make bots, which use advanced programming concepts.
Here are good resources to learn both Javascript and NodeJS:
Javascriptinfo: https://javascript.info/
Codecademy: https://www.codecademy.com/learn/javascript
FreeCodeCamp: https://www.freecodecamp.org/
Udemy: https://www.udemy.com/javascript-essentials/
Eloquent JavaScript, free book: http://eloquentjavascript.net/
You-Dont-Know-JS: https://github.com/getify/You-Dont-Know-JS
NodeSchool: https://nodeschool.io/
CodeSchool: https://www.codeschool.com/courses/real-time-web-with-node-js
Evie s Accelerated JS: https://js.evie.dev/
Please take a couple of weeks/months to get acquainted with the language before trying to make bots!
That was fast
cuz my bot has handy tags
self bot!!!
imagine removing my bot from here when its basically replacement of r.danny 
Sigh...I come here for help but instead get the documents..
you welcome
You need to help yourself before we can help you.
we can't help you unless you show us logs
Alr
It'll help you in the long run to read documentation and actually gain knowledge of the language. You would not have asked this question if you knew effective logic and debugging procedures
Bruh
That doesn't provide the error. The actual error is at the top of the stack
MESSGAE_CREATE
Now? Happy
still nope
does your bot even have permission to send messages?
still not it
That's just the bottom of the stack where Discord.js checks for if stuff is cached
@lament rock tahts why I’m confused it’s now showing any error
give us the entire error already
thats all io could guess from half the error
it is
Let me try again
The error is there. Scroll up in the console
what you are trying to send is literally the error
LOL
it's all lowercase
@opal plank yea on iOS yes
just code in SQL, problem solved
@opal plank can it be used on iOS?
im gonna pretend i didnt read that
JUST 'code' IN 'sql'
iOS sandbox do be strong though
then you send an embed
message.send.(embed) right?
try it
tias
You have to define embed
Alr, lemme try
@opal plank lmao I love this meme
same
We keep trying...
ikr sad dev noises
Lol
I've just put my bot on github, and I want to be able to clone the repo on another device to work on it there. How should I handle the dependencies in node_modules? Should I upload them to the repo or is there some other preferred way?
always ignore node_modules
thats what lockfiles are for, to keep track of dependencies and stuff
All the node modules are listed in package.json. Push your package.json and IGNORE the node-modules folder
after you clone, do npm i to download all the modules
Yeah I've ignored them at the moment as I hadn't seen other repos with the folder
Oh yeah npm i
Thank you
We keep trying but always get the documents
you shouldn't have leaked your token
Can you not
This man is a madman
I’m sorry I didn’t
How... no I didn’t
what vps are you using?
I did but wtf
yes
Ye..
are you using .env
.env or config or string
Holy fuck man
did we just witnes someone logging onto his bot and tagging everyone on every server?
That gave me a shitty shock
it could've been worse
@opal plank yes holy fuck how..
is ur bot public?
No, holy wtf
token leak, as literally people pointed out
i've seen people fully atomic bomb tokens, delete and ban everyone in every guild lmfao
how tf
@earnest phoenix lmao right when I got pinged I check the coding
i meant delete all channels
The most weird part is I don’t have coding that can do that
h
you leaked your token
They don't need your code to use your token.
They just wrote their own code.
in your index:
^^
Then how can it be secure? @sterile lantern
require('dotenv').config();
client.login(process.env.token)```
bruh
do you not know what .env is
Yes, but if I do it how can it be like secure
.env will always be a private file
Yes @sterile lantern I got it
@earnest phoenix Read this: https://anidiots.guide/hosting/repl#adding-your-token-to-the-env-file-and-using-it
Let's take a look at how to host a bot on repl.it securely and correctly. And, for free!
so even if your project is public
they cannot access your token
if its in the .env file
I already done it @sterile lantern
alright
make sure to change your client.login function
to
client.login(process.env.token)
The weird part is I’ve already done it..
So I have no idea how they got my token
did you change your client.login function??
Hm, I don’t think
require('dotenv').config();
client.login(process.env.token)```
client.login(process.env.token)
So I put this in index?
Oh ok
where you do
maybe you gave it to someone
const discord = require('discord.js');
under that
put
require('dotenv').config();
while you were asking for help
And then in the env I do this
TOKEN=.....
why did you requrie it at the end
require*
in your code
index.js
on the top
where you require your packages
put the require dot env there
Oh my bad lol
javascript is case sensitive so you need to put TOKEN in both places or token in both places, you can't mix the cases
and then in .env make sure its
token=here
yeah lowercase if you do process.env.token
or uppercase if you do process.env.TOKEN
@weak parrot you have big brain smarts right
Depends
@sterile lantern you said top-
why do you have the require under all the code
i said at the very top
Ooh my bad LOL
where you require your packages..
Hey I'm transfering from quickdb to mongo and I'm wondering how I would do this
So I do item = args[0]
And thatll get me the first arguement:
I would just do:
```db.set(${reciever.id}${item}s, newrecieverinv);
db.set(${giver.id}${item}s, newgiverinv);```
How would I do this with mongo?
result = await userSchema.findOneAndUpdate({ userid : userID }, {item : value })
```but that doesnt work because it tries to set `item` to `value`
Do I have to make an if else statment for each item?
just the last two
Ok
i mean
no
the const discord
and reuqire one
require*
leave the client.login there
@weak parrot uhhh how do you see if a permission is in a set of permissions
No clue 
bitwise AND
Anyone here use mongo?
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
This at the end and those other at the top
i'm reading the docs
yes thats fine
you just have to use bitwise AND
if ((bitfield & permission) == permission) return true
else return false
uhhh don't think this is right
@sterile lantern so uh how is my file private? And yea it’s working,
Only I can view it? And also the other that are helping me code it?
Or only me
check what the keyword this is referring to. If you're nesting it somewhere this.client is defined, this might be referring to the arrow function
only the people that are in the project and have edit permissions
ready event is likely not a class
so if you didnt add anyone then only you
if it is my bad
quite frankly,
i think repl makes it so only project owner can see .env
regardless of collabs
sure that's one approach, just combine every value that has true in a bitmask with the values from the doc
a sample of that is also in the docs
i think
// this.permissions = BigInt
// guildPermissions[gp] = another BigInt
Boolean((this.permissions & BigInt(guildPermissions[gp])) == this.permissions) // false regardless
That statement wasn't meant for you, skull lmao
wh-
this was though #development message
i see but i still get false
they're parsing from API
They return a string which you can convert to a BigInt which is recommended
Help me someone
class PetalsPermissions<K extends keyof guildPermissionsType> {
permissions: bigint
constructor(perms: bigint|K[]) {
switch (typeof perms) {
case "bigint":
this.permissions = perms
break
case "object":
let n = 0
Object.keys(guildPermissions).map(p => n = n | guildPermissions[p])
this.permissions = BigInt(n)
break
}
}
// @ts-ignore
get toJSON() {
const d = {}
Object.keys(guildPermissions).forEach(gp => {
d[gp] = Boolean((this.permissions & BigInt(guildPermissions[gp])) == this.permissions)
})
return d
}
}
this is the entire class
not you
legit not getting post system messages
discord is high or something
my bot is reacting to the joined members but not getting system messages
lol
@sterile lantern thanks :)!
I do not believe you since the error states that this.client is undefined
log the value of this
or assign client to a variable which you can access without needing to access this
I just tested something similar and it works properly
& returns either 0 or 1
Help pleas
if it's 0 it should be false
& returns the bit you're checking for if it's in there. Not 0 or 1
0 if it is not in there
if it's one it should be true
Uh anyone?
What's the error
It’s saying there’s a bug for no reason @lament rock
still, Skullbite is comparing the result to this.permissions, they should just check if the result is 0 or not
np
is that a client.on function?
that message
or is it an error function?
like .catch or client.on(ready
someone explain how why and how
PLEASE HELP
oh wait
If the output doesn't have client as a property, then this.client is undefined like the error suggests and you should assign the client variable to something other than this since this is a funny JS key word which if nested, refers to the scope it's in. In this case, a function or the scope which is calling the function.
oh nevermind i guess it just ignores the * 1
wouldn't these be 0n if they were wrong...
yeah i got it, just needed to add some brackets
If the permission was not in the bitfield, the output would be 0n
If it was, & returns the permission
what is got?
Just a package for it
all my comparisons are getting bigger than 0
ive never heard of this
maybe you should stop copying code and start trying to understand how it works
probably some obscure http lib lol
Yea, it’s pretty unknown
What's the bitfield?
they're a help vampire lol they won't listen to anything you got to say
they've been told to go learn javascript and read useful articles more times than i have fingers on my body
hmm
Maybe you should stfu every time I see you here you’re just here to go after the newbie coders maybe you should stfu and stop saying stuff like that
@ mods
2147483647n @lament rock

How did you get this bitfield?
i'm popping off on you because you're a help vampire, i have no problems with new people at all, i'm glad to help them whenever i can and it's super nice being able to direct them at docs
you however, actively refuse to read any useful resource that's thrown at you and then complain "WHY THIS NO WORK????" when you found the code in a garbage can equivalent
@earnest phoenix
That is the biggest 32-bit integer
What you want? Want me to go use your codes in GitHub?

codes
lol
cringe
@trim saddle this bitfield has every permission
at this point we're the ones making his bot 
this tbh
hm.
@earnest phoenix I’m gonna be honest I don’t learn shit from documents I’ve read the documents but don’t understand em
because you don't read with understanding
I think this channel should be moderated more strictly and people like Partyman should get blacklisted
you just skim read it
and then complain how you don't understand it
the type of person who doesn't think while reading a book and then complains the book is shit and doesn't make sense
when all you had to do was actively think about what you're reading
No I read it carefully
How old are you @earnest phoenix ?

if you're interested why everyone hates what you're doing, read https://meta.stackexchange.com/questions/19665/the-help-vampire-problem
@cinder patio bruh what’s that kind of question?
case "object":
let n = 0
// perms: array with permission keys
Object.keys(perms).map(p => n = n | guildPermissions[p])
this.permissions = BigInt(n)
break
I’m 14
@lament rock maybe i'm parsing things wrong
Almost nearly I’m 13 rn but 14 in 21th February
wait...
they know about the 13+ limit so they're probably going to lie about their age
FUCK

Bruh seriously?
pain
what is it 👀 is it because you're mapping the keys
Ya fucking joking me? Ya telling me I’m under 13 just because I copy n paste codes 🤦♂️
i cannot explain how much cringe my body felt by reading this message
How?..
they cannot explain
@earnest phoenix in all honesty, you shouldn't be copying without understanding what they mean
Object.keys(ArrayLike) returns the Array indexes which would still technically be correct if you're accessing Array[key]
@trim saddle but tf is he saying that I’m underage?
notice how i said probably
Notice how I said ||stfu||
lol
i love script kiddies
they're amazing
wouldn't the Object.keys() for an array just be index numbers
I love fat asses that sit on their chair using their pc’s 24/7 @earnest phoenix
i feel insulted
They’re amazing at coding
Like amazing
i love fat asses too
i like it thick i like it fat yeah
well they're stringed so it would still return an undefined

Ofc you do
Oh yeah. I forget Object.keys returns Array<string>
finally

@earnest phoenix Alr I’ll try to learn send me all the important documents only the important ones
have fun cutie
it'll be hard but ok
also you can do n |=
@cinder patio any others?
@opal plank typescript is bullying me
Just give them rn, since now I’ll go hardcore on them
well, vsc theoretically
If you read all of that and grasp the concepts they teach you, you won't be asking questions like you just asked today
TS does like to bully
** Just give them rn, since now I’ll go hardcore on them**
it keeps screaming to configure my excludes but
I just gave toy
and the tsconfig is at the root of the project
control shift p => restart TS server
thats normal
Try closing and opening Vscode, this happened to me once
@cinder patio so those are the only one?
that's a good thing to do when TS is being dumb
Just restarting TS server is sufficient
seems to work
yea that works too
thank
Older versions require restarts more often, but I assume people spring for newer versions anyways
LOL
TS bundled with VSCode might be out of date so I just tell it to use npm installed binaries
hm
might be the reason why it broke
im running 4.1.3
but on an older project everything seems to be fine
I think that's latest 
Want me to nitro boost lol?
nobody gives a single shit go talk in general
nobody gives a shit about your exsictence please go sit on your fat ass
can you both be polite to one another
yeah, that was the problem, vsc seems to be running 4.1.2 in the bundle
this is not the place to argue, and general conversation should be in #general @earnest phoenix
@sinful belfry ima be honest his been after me since I came to this channel and I’m tired now
And that’s like 9 days ago or something
Yea I really am pissed now
im not asking what has happened, im telling you that general conversation should be in #general and you shouldnt be arguing here
so please stop
Alr
Oh okay. I see. Still kind of odd since newer versions like 4.1.2 should still be okay. I meant older in general terms like TS 3.x
It never hurts to tell VSC to use npm bundled, but it doesn't make you impervious to TS just being stupid
in python, how can i do like: if "joe" is in this list 3 times, do this
probably regex then count the results.
Party, as people said earlier. Please talk in #general if you're not asking or helping for development questions.
how should I access client on a class but if you were to log the class, client would not show up? js/ts
would private property work?
and how would I do that in js
pretty sure there is a private property on classes.
ik about that on ts but what about js?
JS doesn't have private properties. You could manage the reference in a variable in the root scope and use a getter to return the value. Getters do not show up in logs
and is private what I am looking for?
Class properties are public by default and can be examined or modified outside the class. There is however a stage 3 proposal to allow defining private class fields using a hash # prefix.
Since node 12 and on all recent browser that aren't, like, safari or some other archaic thing 😛
¯_(ツ)_/¯
Safari supports private class fields, but only in technology preview atm
var width = 400, height = 400, buffer = Buffer.alloc(width * height * 4);
for (var y = 0; y < height; y++) {
for (var x = 0; x < width; x++) {
var pos = (y * width + x) * 4;
buffer[pos] = 0;
buffer[pos + 1] = 10;
buffer[pos + 2] = 100;
buffer[pos + 3] = 255;
}
}
message.channel.send("loading", { files: [buffer] })
It sends the image, but its a jpg that doesnt display anything
for flask
do i use asyncio.sleep or time.sleep?
If you're in an async scope, use asyncio.sleep. If you're in a blocking scope, use time.sleep (which blocks)
so uh
is it possible to set a prototype property of a class as an different empty object for each instance?
i tried TheClass.prototype.obj = {} but that just passes the same object reference to every instance
@umbral zealot lmao I thought that said private ass fields LOL
uhh hey guys how do you fetch a channel of ur choice?
Yo guys
Can somebody help
Code part
Thats a translate command
I have error about results(const) empty
But why
What’s the error exactly
ok umm another question
how do i make it so the amount works look heres what happens
and here is the code:
yeah its big
look at the second args value
u mean the args[1]
yep
How to have a Range Developer?
Show the code's part where the error is
look this happens: this is code:
ik im sending wait
do you use visual studio code?
yes
read that
Does debugging work in a discord bot code?
of course
Oh right
uhh well here
is code anyways:
You are using args[0]
That takes the command
Looks very repetitive
fetching from the db a bunch of times and then never using it
or args[1] depending how you define args
Ya
He must fetch data from the db only if it's neccesary, i think.
stonks
you see that the variables are colored differently?
that gray-blue color means the variable is not being used anywhere
Only if you will use it, otherwise don't fetch that data.
(It's a suggestion)
hm
you have a CSP header that prevents using external urls as image sources
xd
are you still using args[0]?
Tim our savior
no i am using args[1]
ok
1 gets the "pokeball" string
what are you using for webserver?
Tim you are our savior lmao
annnnnnnnnnnd
Ubuntu as webserver software?
nginx reverse proxy?
Is that possible?
this is with args[2]
log your args
k
show your reverse proxy config
do you have set headers for content security policy?
How did you write your console.log()
i did console.log("test")
tho should i put the thing
So that means it never reached that part of the code
yeah
so you know it's something before that.
yep
Instead of asking for every time it doesn't work, you can play around wit the args[] and whatnot until it does.
why do you have both proxy_pass and proxy_redirect?
since you can use console.log() to log each step to figure out where it breaks
if(isNaN(args[1])) {
message.channel.send("specify a number.")
}
if(purchase === 'pokeball'){
let pball2 = args[1] * 250
if(amount < 250) return message.channel.send('You do not have enough money to buy this pack/item. Please try another one');
db.subtract(`money_${message.author.id}`, pball2);
db.add(`pokeball_${message.author.id}`, args[1]);
console.log("log1")
message.channel.send(`You just bought a pokeball pack!`)
}
this is the args[1] part
where are you logging it
for pokeball
🤔
thats in an if statement thats not running and doesnt contains args
in discord it sends isNaN
log it outside all if statements, and log the args variable
ok here wait
do you have Content Security Policy anywhere in your nginx configs? even outside of the proxy block?
just so we dont add duplcated stuff
if(isNaN(args[1])) {
message.channel.send("specify a number.")
}
console.log("log1")
``` this works
it logged
your args dont seem to be args
yeah ik
Also, you must use return(?
why would you name it args if its not args 🤔
he probably did console.log(args[1])
ag
Mm
I think you must use return to prevent executing the rest of the code and getting any error
true
Lol
XD
yes i did do that lol so what do i put bc my brain is still DYING
sad
when they asked you to log args, they meant console.log(args)
ooh
lmao
im brain ded
so they could see what the variable args looks like
because once you see how args looks like, then you also see which index is the correct one
see, so pokeball is index 0, and "1" is index 1
so '1' would bne index 1
ok
so args[1] is correct
ik
Lol
args[2] was wrong
Oh
in cases like this, you use console.log to see what the code is doing, that way you can simply do the right thing instead of guessing around and blindly trying things
Welcome to debugging
yes
Console.log() is your best friend
tim is savior of my buy cmd
lmao
and console.log() is indeed my best friend for code
What the hell means "of my buy cmd"?


