#development
1 messages · Page 2068 of 1
what if u call it as a property?
It still does not exist.
did u try running even with the editor saying it's an error?
index.ts:4:12 - error TS2339: Property 'view' does not exist on type 'object'.
4 a.password.view()
class Password {
data: object;
constructor (data: object) {
this.data = data;
};
};
no, where u defined password (not Password)
time to return to v12 😔
too bad, u cant 
password: object
;-;
👏 typing matters 👏
Should it be password: Password?
yes
LOL.
object doesn't have call(), Password does
Also, this, right?
data: Student.
welcome to the wonderful world of ☀️ typed 🌈 languages ☀️
yes
every single class extends object, that's why it works, but u cant access class-specific methods
typescript is still more lenient than stronger typed languages
i beg to differ 💀
Java.
bro c only verifies if your syntaxes and types are ok and it continues with its day
It'll make sure it screams at you, your editor, and your terminal, too.
typescript users realizing using the any type defeats the purpose of the language
something: Object;
...
something.name; // undefined - PASS
Object something;
...
something.name; // Cannot resolve symbol 'name' - ERROR
ok I admit c would warn for some things that typescript would be like hold up
but functions in C.. u can't do that graceful dance that javascript has with the variables
in C an egg is an oblate spheroid, in JS an egg can be a car
like cmon who doesnt love pulling variables out of nowhere because of what waits on what and what variables get created along the way
c users calling functions named module1_subcategory_do_this_function() because there arent any namespaces or classes
it'll still be an egg but with wheels and __proto__ car
the car
where'd u find that 😂
lmao
What's the type for the array of classes?
this isn't your car right?
array
const students: something[] = [];
nah, idk who's car is that
found in google
what i like about c/c++ is the fact you can actually turn anything into a type that it isnt
Usually, for strings it's string[].
it really allows you to boost performance if you know what you're doing
well an array of chars is an array of ints but to say that statement.. PROE 🙏
Is it possible to delete my bot from top.gg?
I want to reapply with a different bot
there's a delete button on its page
Can't find it
are u logged in?
yw
so you're going to be using your other bot while still using the one you want to remove?
try array<Student>
I ask this weird question since if you no longer use the old bot..
u can simply change the image and have different code using the same token
Still errors.
I say THIS cuz ong the application takes forever
No so I restarted my bot. They are both the same. So same profile and everything. But I can't change the name of the bot on Top.gg
Unless you mean Array not array?
So I am deleting it and reappling
first google result
ah
is it verified?
if not, just change the name on applications page and press "Refresh data" on top.gg
I tried that but it didn't work for me
No not yet
I already deleted it 😞
creating a new bot just for changing name is a terrible option
yeah it wasn't the smartest but I didn't know how to get it to work otherwise
Oh wait
you could've 🌈 asked 🌈
No no I am using the same bot profile. So on Discord it is the same bot. Just with different name
But it wasn't updating on Top.gg
So I deleted the top.gg profile
and am re putting it
I believe that might get flagged as trending abuse tho
this wouldn't be an issue if the queue emptied in a day
What does that mean?
trending, not queue
but.. u might see it back in.. 3 months
re-adding the bot will put u in "Trending new bots" again if u have enough servers
wasted traffic
imagine calling the police for your missing dog 10 times
Oh lol my bot is not very popular. So it doesn't have that many servers
Ah okay
ah
I see the problem
I just googled how to see dms on discord.js v13 and apparently it wasn't a missing intent, it was a missing partial
I forgor d.js events depend on partials
do dms really need a partial
probably anything does
💀 doesnt that get sent along with the event
idk man i havent developed bots in a long time
by a long time i mean 2 years
I believe d.js uses the partials to retrieve full data before triggering events
must you really have new Client with intents
yea partials are events which dont have all the data necessary
must you have every event with some different class and a whole bible on each
imagine having enums
yes the devs of discord.js have their own tastes.. although discord api itself seems to have more standardised data.. im simply not going to build my own discord.js interface 😔
discordjs changed a lot
in JDA we just do (for intents for example) EnumSet.allOf(GatewayIntent.class)
i used to like it but not anymore
i remember a time discord.js was throwing errors when I was sending correct numbers for permissions simply because their function either takes their permission instances, a string or an array of strings
too convoluted and unknown apis
probably what happens when too many chefs in the kitchen
does jda have async await?
we don't need
i remember being confused about the fact you need to execute and queue promises
to be adding complication where it isn't needed 🔥
is everything blocking?
no, you see, I'm talking abt java
what if you want to retrieve data?
java handles differently async stuff
saw something similar for a repl database with classes and all of that but when reading the docs it was way more simple to interact with
<bot>.retrieveUserById("1234").complete()
is complete blocking?
there are 3 types: queue (full async), submit (can be both) and complete (full sync)
i assume theres some kind of thread pool in the background
like if you're doing .complete wont that block other events
in my case for example
I set the events to use 20 threads of the type WorkStealing
not exactly, but yeah (the thread is freed for other tasks once the current one finishes)
:troll: ```ts
enum Intents {
FIRST = 1 << 1,
SECOND = 1 << 2,
THIRD = 1 << 3
}
let newIntents: number = 0;
for(const intent of Object.values(Intents)) {
newIntents |= intent as number;
}
console.log(newIntents);
i like thread pools
just having threads on standby
because creating new threads can be costly
for sure it is
typescript users realizing enums arent actually enums and references to enums get replaced by the actual value defined by the enum
thats how every other language does it
programming language users when they realize that almost every language doesn't have a real enum
javascript users realizing objects arent enums and will incur performance penalties
Should I bother using redis for a bot that would use a database quite a bit, or just stick with my original idea of using postgresql + typeorm?
certainly depends on the traffic but for 99% of the time a local cache will be the best option
dont be tempted by redis
I've just heard redis is good, I haven't actually looked into it or anything
I've used postgres and typeorm together before, pretty good experience and it has a built in cache with optional timer
i havent used most of its features to understand why people would choose to use it but for regular caches its generally prob overkill
i guess if you have a lot of cache you could take advantage of the compression feature
postgres VERY rarely needs a cache layer
Why not? I know it's fast, but I don't really see a point to querying that much
oh yea thanks for reminding me
it will probably be a better option to raise the cache limit of the database instead
dont know about postgres but there are probably a shit ton of tunable settings
I could probably just wing it but I'm trying to minimize the amount of times I need to redesign things lol
the os also caches a bunch of shit for the database too
i made a database called BroDB and without caching it already does a good job
@cinder patio maybe u were right
you can bet on that
there's a config guide out there about what settings are good to change
the only server side database i ever dealt with is mariadb and mysql
i know if you have phpmyadmin you can easily tune them
hard to know what to tune tho
for postgres there's a config file
especially if you dont have a deep understanding of databases
postgres.conf iirc
if the config isnt json dont talk to me
hey guys, why is this only reading the [0]: js characters[args[0][1]].args[0][3]
it's not getting the args[0][3] as a whole
holy fuck what is that
speed
the thing is that instead of getting the whole args[0][3] (which is speed), it only gets the args[0]
console.log(characters) and console.log(args)
otherwise i have no idea what you're talking about
yeah this is gonna need a little more context with how many subscripts you have there
And that is which thing?
thats args?
yup
It's a 1d array
and what is characters?
{"Miauw":{"name":"Miauw","owner":"345138133429649408","speed":["50"]}}```
Oh I didn't even see the top one
you are doing characters["Miauw"].args
args does not exist inside the Miauw object
what you want is characters[args[0][1]][args[0][3]]
which is the equivalent of characters["Miauw"]["speed"]
no
characters[args[0][1]].args[0][3]
is equivalent to
characters["Miauw"]["args"][0][3]
the dot character represents a literal key
it cannot read variables
characters[args[0][1]] is the same as characters["Miauw"] because the [] reads the args as a variable
characters.args[0][1] is the same as characters["args"][0][1] because the dot reads the word args literally
multi dimensional arrays are fun
Wtf is this madness
machine learning is for you
when numbers get way too ridiculous
tf is a busy beaver?
and why is it a for-loop?
its a way of expressing a stupidly large number with a turing machine function
as far as i could understand it, its something akin to the number equal to the amount of operations needed to solve the beaver problem with N states, and the beaver problem is something not much different from bogosort or the game of life
these are all ridiculously ridiculous impossible to conceive numbers
rayo's number is the smallest number that is bigger than the biggest possible number you can represent with a googol amount of first order mathematical symbols
or something like that
Tim stop speaking enchantment table
These all feel like made up numbers
I just invented one, it’s called Waffle’s number: the biggest possible number
All they are is what you define it as
makes a netherite sword with sharpness level 32767
lmao
except that those are all mathematically and philosophically well defined numbers
ie they are made up, but they actually mean something
like an entire theory was created to back the number and why it should exist
there's an entire field of study of big numbers called googology lmao
This is a list of googolisms in ascending order. This list contains ill-defined large numbers, e.g. BEAF numbers beyond tetrational arrays, BIG FOOT, Little Bigeddon, Sasquatch, and large numbers whose well-definedness is not known, e.g. large numbers defined by Taranovsky's ordinal notation and Bashicu matrix number with respect to Bashicu matr...
I wonder if we'll ever be able to write the uncompressed formula of Graham's number
idk about the formula, but the actual number would take eons to write even if you wrote one character every plank time
some numbers have pretty fun names
Tethrathoth, got a new name for next D&D final boss
these are all unspeakable amounts of orders of magnitude bigger than grahams number
has to be with a name like that
there are many types of objects on js
if you want inheritance, the best way to represent it is through classes
you mean class as in lecture ?
class A {
constructor(arg) {
this.arg = arg;
}
getArg() {
return this.arg
}
};
class B extends A {
constructor(arg) {
super(arg);
}
getArg2() {
return this.getArg() + 2;
}
}
const obj = new B(10);
obj.getArg2() // 12
inheritance is like: "A dog is an animal, and an animal can move, thus dogs can move"
the constructor is the function that is run when you do new B()
is what creates the object and gives it its initial values and properties
class A {
constructor(arg) {
this.f = arg;
}
}
console.log(new A(10)) // A { f: 10 }
technically classes in JS are just an alternative/simpler sintax to plain objects with references and stuff
you could write the same with in other ways, without actually using classes
JS is a very hackable language
can you do this in JAVA?
java has classes as well, in fact everything in java is classes lmao
but java is probably not as hackable as js is
you probably cant tamper with stuff in java like you can in js
like in js you can access, modify and override prototypes, which essentially changes the class after its created
of course all this flexibility makes js less "safe" than other languages
Everything except primitives
oh ok
java is one of the best languages if u like working with classes
do you also know if java has interrupts ?
Like system interrupts..?
what is a system interrupt?
my professor told me computers have interrupts but he didnt explain it
interrupts are a very low level thing in systems languages
java is not a systems lang
My guess is the int keyword in assembly for example
To call kernel and stuff
is assembly a language?
But no Java is a higher level abstracted language
Yes
There’s tons of types of assembly
u can use JNI if u must call low-level interfaces
Yeah but at that point I don’t see the real benefit to using Java
oh so i should ignore it
Java isn’t meant to be super low level, it just has some capabilities for compatibility reasons
But you certainly CAN do it if you wish
depends what you actually want to study, programming is an extremely vast subject, with countless forms of specialization
there are languages for everything
and specializations for everything
Personally I usually prefer to work with low level APIs in their native language or something on an equivalent level (like C APIs in rust)
do you think i should also ignore ISR ?
What’s ISR
interrupt service register?
Sounds low level
you can ignore those if you dont want to work with systems and low level languages
my professor said i needed to write this until our next lecture
but your professor might want you to learn that regardless or he might fail you
it sounds like hes starting from low level languages and computer science things
all those things are useful to know, but not a requirement for knowing how to code
he's tim
Sounds like he might want you to learn things that are working towards learning assembly, what kind of class is it?
Just a general CS class?
hmm so basically software for machines and robots?
then yeah you'd need to know low level languages if you're going to work with hardware directly
he said this is a very hard course xD
you dont
logic gates are pure hardware
they are made with microscopic transistors and switches
thats how a processor is built
programming languages are a way yo use computers without having to know how they work
you can use those to build a redstone computer in minecraft
those symbols are actually circuit board symbols for drawing electrical diagrams in circuit boards
pages are units/blocks of memory
you know what RAM is?
like when you check how much ram your computer has
thats the memory
ohh i did hear
its what programs use to run
when you run a program, the program puts its code in memory, so the processor can read it very fast
u can replicate their behavior, but not physically make them
becasue hard disks are slow
Does somebody else use your account? I thought you said you made an OS earlier
I figure you’d need knowledge of this unless you were just trolling earlier
he also said he made a database
"BroDB"
His first message in here was today, it’s possible
Speedy has planned out the last 4 years simply for this moment
1 month
lmao so it was speedy after all
Speedy was doing some advanced trolling
the bro was the imposter
Rip speedy he’s gonna need a new personality for his new alt so he doesn’t get found out
imagine if the bro is not actually speedy
Nah def is
lmao rip
Lmaooo
He was talking earlier about the db thing
Then all of a sudden doesn’t know what an object is
xD
Just gave him the benefit of the doubt
well tbh i didnt even know he was banned in the first place
Same
He didn’t get banned until 30 mins ago
But he did get muted earlier today
Like 5 hours ago
so thebro joined immediatelly after he was banned? or was thebro already here all this time?
Joined right after
lmao
Had the “new here” sticker
Better watch out he’s gonna get that oracle server finally and raid top.gg lmao
anyone remember the good old times when someone would keep joining with a bunch of alts to insult dbl? and more specifically oliy and tonk
join > spam a bunch of fuck yous in all capitals > ban > repeat
Wdym? Are you trying to make valorant cheats lol
Pretty much impossible to get through their anticheat unless you’re a professional cheat developer
Why though
Valorant already has an RPC you can use
What you want to do here is going to be a little bit complex
You’re going to need an application that runs in the background as a windows service or something on startup like that, then listens for application open events via the windows api (I think?)
Probably, but not worth the effort you’ll be spending
Just use the normal RPC, this sounds like a really annoying project to make for something so small lol
And trust me, the windows API is absolute HELL
I've been here since before this place became top.gg, but my joined at date will say otherwise. Could probably find my oldest message and see how often I talked in the bot command 1 channel
Can remember the good old days
Now I shit on Discord.js
is requiring USE_EXTERNAL_EMOJIS for commands that use them allowed for bots submitted to DBL? i see plenty of permission denials and was curious whether it's okay for cosmetic features that could work without emotes, but wouldn't be as nice
u can request it, no prob
(as in request the bot?)
if you use it, yes
gotcha, thanks!
top.gg permission rules aren't about prohibiting features, it's about common sense and only asking what you really need
you can ask for all permissions (except admin) if you do use them
gotcha, wasn't sure if it was just an "if you use them" thing or if it was a "use as few permissions as possible" thing where if you could workaround a permission then you should
So, what's the point of using @sentry/node? Why bother with it instead of just using a normal error handler?
ok it's pretty cool
https://sourceb.in/pu8ZHHuru7, How do you exactly check two array objects in mongoose? Is this the right way on my shared link code?
theres https://sentrydiscord.dev too
by Ian
Alright I got it, but it doesn't seem to send me messages on the webhook when there's an error captured by sentry. I tested the webhook, works perfectly fine
Is there anything special I need to do?
py
It's an example exception you dumbo
the error I'm sending it gets logged in sentry, but not sent to the webhook
Interesting
Maybe see what requirements sentry has to send a webhook
Maybe there's an option you need to enable in sentry node
I'm enabling it right now. Turns out you need to set up integration alerts along with it
tfw your code is a gigantic mess, so you start everything from scratch and promise yourself its gonna be clean af this time, months go by and you watch your clean af code turn into a giant mess all over again
and you think its gonna be an easy rework
6 months later still not done
and your "clean af code" is already 59 files
i realized how much i hate large codebases and how much i love small code snippets
That's how I feel working with discords API and gateway
You try your best to make code that is readable and not messy and next thing you know you're doing black magic
what's the max amount of text that can be sent into a slash command?
https://sourceb.in/R7XDT34gig, how do I send a message using another lib.js? it throws in default as alwasy
Do you mean by options or?
each string field can only have so many characters. I think 100
But you can have multiple options of strings
for larger strings, I'd just use form submitting
Those have a maximum character count of either 2000 or 4000
I forget
nice, i might need to switch over to that
nvm found the answer
hey um, anyone know how to show server count on topgg website?
like in their website
when someone searches for bots
i see other bots have server count on display
https://top.gg/api/bots/:botid/stats
Im making a POST request to this route with Authorization: Bot {bot_token}
But its always returning unauthorized
aaa gotcha, is there an example?
do i send bearer token or basic
or "bot <api token>"
it looks like bearer token to me
anyway thanks i figured it out
nothing
just the token
yeah i figured it out, made the api call successfully
nvm thanks haha

yes
see server > settings > webhook
gotcha, thanks!
i dont see this anywhere, the webhook for server says its just to post to a channel from external source
my question was, if on topgg someone votes for a server, is there a webhook that would give me the info like how there is one for bots
nvm i found it lol
thanks lol
same for bots and servers
ye ye, my dumbass was looking in the discord app server settings 😂
........
Well people could just edit the invitation url doesn't it?
check permission before doing stuff
yea they can
i hate when people do that to spam my fkin console
I am though 😭
I tested each and every command it doesn't pop up in the console from them
it pops up randomly
the intervals can be from 30s to 1h and there is no stack trace other than the channel the error came from
Might be channel overrides then
try this
Log channel id before you do stuff
like
console.log(interaction.channel.id)
interaction.channel.delete()
Then you can see which channel causing problem
after that you can fetch channel info and find the problem
how would you stop a setinterval loop in js?
im asuming if i just add something like if stop == true then the loop will still run but just return everytime
or do i have to use a while loop or somthing?
but idk how to add a pause or sleep in there without doing somthing wacky
with clearInterval
const myInterval = setInterval(function, milliseconds);
Then you can to stop the execution by calling``` clearInterval()
clearInterval(myInterval);```
oh yea that's a good thing
actually no nevermind that's not it
Hey, i've got a simple button that triggers a function, but i sometimes get a critical error from the discord api saying "unknown interaction" when trying to reply to the button, which causes my bot to crash. I've tried adding the answer in a try catch loop to get more informations and avoir the bot from completely crashing, but it sadly didn't work :/
Does anyone have this issue ? And have anyone got a solution for it ?
that's why I hate buttons
I'm sure it's not related at all but what you could try is replying to each interaction
yeah i do too, but it's way easier than having a reaction listener :/
I agree 100%
wdym ?
do interaction.reply(...) to it and it shouldn't fail anymore
that is what i do
that solved my problem
maybe don't try catching that and instead follow up?
I've got a function from someone here I could send it to you
data: index.js:41181 - throw new DiscordAPIError(data, res.status, request);
data: index.js:41181 - ^
data: index.js:41181 - DiscordAPIError: Unknown interaction```
have you made a collector?
i've recently added the try catch to try avoiding the complete crash
the message is just a confirmation that everything else worked well, but there are anyway other informations saying that everything is okay
so if the message is not sent it's not much of an error, but just stop it from crashing 🥲
yep
I have no idea honestly, you're not even using a collector so you prolly need an event to reply to them?
try using interactionCreate event
I've never used that event but it seems fine to me
but i don't even know if that comes from djs or discord api
and would you have a solution to suggest just to avoid the complete crash of the process ?
add something like this in the interactionCreate event
try {
// all of the code
} catch (e) {
if (interaction.replied)
interaction.followUp("Follow up" + e)
else
if (interaction.deferred)
interaction.editReply("Edit" + e)
else
interaction.reply("Reply" + e);
}};
and see which error pops up
I did that when trying to figure out my error, then I added whatever the error that came up with to my collector and it started working
cursed javascript
const backingArray = new Uint8ClampedArray(sharedArrayBuffer);
const pointer = wasm.paint(
width,
viewportHeight,
aspectRatio,
focalLength,
new Float32Array([x, y, z])
);
const raw = new Uint8ClampedArray(wasm.sharedMemory().buffer, pointer.offset(), pointer.size());
for (let i = 0; i < raw.length; i++) {
backingArray[i] = raw[i];
}
return sharedArrayBuffer;
Have no idea what I'm looking at
ray tracer in web assembly, reaches into wasm memory to copy data onto a SharedArrayBuffer
isn't that array for drawing images?
typed arrays can be used for pretty much anything
yeah but it's mainly for drawing
it's going over 200k pixels every frame and painting some kind of color on the screen depending on intersections and stuff. Fun project, I don't think you could make it work this smoothly in js directly
why not try doing the same but with webgl?
you can do it with javascript alone
well I'm learning ray tracing so
if you did that in js it would probably be slow
although maybe not even by much
with webgl you could get it working prolly way faster and with js only
and glsl 
anyways the point isn't "put 2 spheres on the screen" so it's irrelevant regardless
ah yea forgot about shaders
then what's the point lol?
I just said it lol, learning new stuff
ah
did you use three.js for the project from the recording above?
it kinda looks like threejs
DYOR on doggy
whoa that's impressive
so essentially you ACTUALLY managed to write your very own ray tracing engine
I wanna implement looking around with my mouse but I first need to solve other problems
which are?
hard to figure out what it's doing tbh
btw are you going to publish it as a web game once you finish?
I wouldn't know I never tried writing my own ray tracing 
but it kinda looks as if you have a memory leak
I'll turn it into an interactive thing but not a game
it's not a memory leak on my end. Something is wrong with vite
hm I see
I think I need to switch to webpack oops
that's cool
send it to me once you finish ples 
you wrote all of https://raytracing.github.io/books/RayTracingInOneWeekend.html by yourself?
that's some extensive writing
no lmaoo I'm reading it
oh 💀
I suck at math I'm following through with it
ah that's cool
hello, someone use sequelize with mysql here please?
Just ask your question
do you guys have any command ideas?
can you get guild property from channel?
<GuildChannel>.guild
Careful though, if it's a DMChannel then the guild property won't exist
Use the raw api
wtf
the field title is not even documented
so... modals are an initial response and the interaction can't be deferred (before)?!
nvm
They are
ERROR Unhandled rejection: DiscordAPIError: Missing Permissions
why
I added an permission check
in
literally
every
script
why
check channel not role
what do you mean??
check bot's permissions at channel level, not member level
like, do not check the bot's permissions directly, check channel permissions for the bot
i AM...
if (message.guild && !message.channel.permissionsFor(message.guild.me).has(
[
Permissions.FLAGS.VIEW_CHANNEL,
Permissions.FLAGS.SEND_MESSAGES,
Permissions.FLAGS.EMBED_LINKS
]
)) return;
that's what I'm doing
or is there anything I'm missing that could be causing the DiscordAPIError: Missing Permissions pop up every 30 seconds
then u missing some perm
which 1???
how would I know?
I wish I fucking knew but it's not telling me
I don't even know which channel it keeps popping up from cause it's not any of the guilds I'm in
would help if u post at least the stacktrace
oh sorry I thought I posted it
DiscordAPIError: Missing Permissions
at RequestHandler.execute (/home/container/node_modules/discord.js/src/rest/RequestHandler.js:350:13)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (/home/container/node_modules/discord.js/src/rest/RequestHandler.js:51:14)
at async TextChannel.send (/home/container/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:176:15) {
method: 'post',
path: '/channels/124622509881425920/messages',
code: 50013,
httpStatus: 403,
requestData: {
json: {
content: undefined,
tts: false,
nonce: undefined,
embeds: [Array],
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: undefined,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined
},
files: []
}
}
that's the entire thing
most of the time it's the same channel
do you know what command is it?
no idea, it doesn't even happen when I execute a command. it just happens at seemingly random intervals
once rebooted I noticed it happens once every around 30 seconds to 5 minutes
don't u keep a log of commands used?
I do, but it's got nothing to do with the commands
are you 100% sure?
I bet you have an unauthorized permission
we know
Just saying
is it always that channel?
most of the time, but today it's been happening really often in the same channel and it's bothering me so bad
Anyone of you experiencing ModalSubmitInteraction being sent multiple times?
nope I don't use interactions very much
put a catch in all sendMessages in your guild listener
print something you can use to quickly locate where it happened
then wait for it to happen
guild listener? do you mean my logging handler?
wherever you handle guild messages
does messageCreate include DMs?
yes, but I've got that handled, there is specific commands for guilds and DMS
no no, you see, I'm not talking about commands
you might be trying to send a message to an user it can't
ah no, that's definitely not it
it only responds on mention
and anything that sends messages to users has a permission check
back to guild then, do this
I don't think I'm following, you want me to put that on the entire event or ?
cause sendMessages is only done in the commands itself
and the error happens randomly
...BOY
so you want me to put a catch on the logs? how will that help?
if you're 100% SURE it has nothing to do with commands how tf is it happening in a command then?
ok, back to the start, you keep a log of commands right?
it's not.. it randomly happens perhaps you misunderstood what I meant
yes, it's only in the console and they are kept until I restart the bot
that's...not a log of commands
when I say log I mean a history of all commands used
oh no, I don't have that sort of thing
both for safety and debugging purposes
put the log above run
already do
ok, now just wait for it to happen again
yeah my logger class handles all that
okay one ssec
can I ping you when it happens?
yes
oh it happened
what command was it?
failed to send a message pog
then that ain't happening inside command handlers
do you have ANY sendMessage before run?
yes
put a catch in it
but I check for SEND_MESSAGE permissions before any of them are sent
doesn't matter, put a catch on it
if (message.guild && !message.channel.permissionsFor(message.guild.me).has(
[
Permissions.FLAGS.VIEW_CHANNEL,
Permissions.FLAGS.SEND_MESSAGES,
Permissions.FLAGS.EMBED_LINKS
]
)) return;
ok
are there any others or just that?
Every send has to be checked
just that, there is also moderation logs but that's in the different events than messageCreate
you don't understand.
inside that catch make it log to console something u can easily locate
this is in almost any event before executing
I think I do understand based on the error. POST /channels/:channel_id/messages can only do one thing
we're trying to find out what permission he's missing
I'm aware but I don't post to anywhere without a reason, and each message.send I do is being checked for permissions
did you add it?
keep an eye if it pops in the console
if it does, the error is happening there
if it doesn't, that's not the only sendMessage there
so far so good
around 1 minute after rebooting
though I have no idea how possibly that could happen...
2 minutes we good
wow did that actually fix it lol
I should check if anything had stopped working
that's not a fix, we're trying to see if the issue is there
Permission checks don't guarantee a message will be sent, because of latency or caching issues or whatever.
They only reduce the amount of bad requests you can make to prevent bans
oh I see
no.. I just did .catch(); without anything in it.. was I supposed to log it lol
^
I'm going to edit the commands rq then
give a sec
though I think it actually fixed it
:Z
that's not a fix, that's a mat sweep
I understand
did it appear?
yes
then there's you error
it happened when I ran command -urban
show what you're doing there
Might want to console.log(new Error().stack) stuff so you can see code execution
yeah but it's not a problem anymore it seems
I've done the catch in every message.send I got in the messageCreate event and it still popped up
you shouldn't use the very same message in all catches
how will we know which one is it now?
That's why I said printing a new Error().stack
create the new Error().stack outside of the catch because it will include previous frames of the event loop
cause I know which message it origianted from cause I executed it
but that's not the issue
either do what papi said or make the debug messages different
You can only go so far back in stack frames and Discord libraries usually don't remove the garbage frames from their request handler
.catch(console.log(new Error().stack));?
const s = new Error().stack;
msg.channel.send(...).catch(() => console.log(s))
none of that is necessary if you use await instead
good catch, didn't notice the missing awaits
where?
in both places
you want me to await both of these message.send?
also
at module.exports (/home/container/events/messageCreate.js:88:32)
at Client.emit (node:events:390:28)
at MessageCreateAction.handle (/home/container/node_modules/discord.js/src/client/actions/MessageCreate.js:26:14)
at Object.module.exports [as MESSAGE_CREATE] (/home/container/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:346:31)
at WebSocketShard.onPacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketShard.js:478:22)
at WebSocketShard.onMessage (/home/container/node_modules/discord.js/src/client/websocket/WebSocketShard.js:317:10)
at WebSocket.onMessage (/home/container/node_modules/ws/lib/event-target.js:199:18)
at WebSocket.emit (node:events:390:28)
at Receiver.receiverOnMessage (/home/container/node_modules/ws/lib/websocket.js:1169:20)```
it happens when I execute -urban
and the -urban has the nsfw if statement
You don't do checks there from the code you sent
what's wrong?
try doing what tim said, put await on those sendMessage
how will that help ?I don't have any try catch statement there
are you checking if you can send messages before that part of the code?
yes I am
I sent you that piece of code 3 times
but is it before?
this is in every event that I can put it in (eg. has a message property or a way to get message property)
yes it's before everything
well, then I'm out of ideas, but at least now you know where it's happening
I don't
it happened even after I added the catches
catch doesn't magically fix the issue
you can put a mute catch there, or u can investigate what other perms you'd need to send a message
but it did happen there too, else it wouldn't show the catch message
What even is the issue anymore
discordapierror: missing fucking permissions
mysterious missing permission error
for literally no reason
What are you trying to do
happens at very weird intervals
it can happen immidietaly after startup or not at all
for example it didn't do it right now somehow
nvm it just did
seconds after I send the image
[2022-07-06 19:38:55]: CMD Bot Owner ItsOkayBae#1172 (392035788004524043) ran command stats
[2022-07-06 19:40:04]: ERROR Unhandled rejection: DiscordAPIError: Missing Permissions
DiscordAPIError: Missing Permissions
at RequestHandler.execute (/home/container/node_modules/discord.js/src/rest/RequestHandler.js:350:13)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (/home/container/node_modules/discord.js/src/rest/RequestHandler.js:51:14)
at async TextChannel.send (/home/container/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:176:15) {
method: 'post',
path: '/channels/124622509881425920/messages',
code: 50013,
httpStatus: 403,
requestData: {
json: {
content: undefined,
tts: false,
nonce: undefined,
embeds: [Array],
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: undefined,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined
},
files: []
}
}
and nobody exeucted another command
so WHY
WHY
???
Calm yo self man
Well it's obviously an issue with posting to a channel
It gives you the channel ID
so what am I supposed to do with it?
Figure out what channel
I'm not in that channel
Is this bot public?
yes
Well then it's likely an issue of you sending a message on ready/message create or some other even that gets fired when bit starts up
bot*
I put the permission check code in almost every event
the only events that I didn't put it in are because I can't get the channel property
to check channel permissions
Iirc it could also be a dm
But I don't remember if missing permission is what discord returns when a bot can't dm a user
🤷♂️
but I doubt anyone would be dming it anyways
why
it's only got 50 fucking servers
there is a catch on literlaly every channel I try sending to
You say you know it's not but you've been wrong on other occasions before so I doubt your judgement
for example this is message delete
I cought it, I don't log anything either
so why would it pop up
That's not exactly safe error handling but whatever
and besides I've got
if (message.guild && !message.channel.permissionsFor(message.guild.me).has(
[
Permissions.FLAGS.VIEW_CHANNEL,
Permissions.FLAGS.SEND_MESSAGES,
Permissions.FLAGS.EMBED_LINKS
]
)) return;
``` right above it
Is there a faster way I don't think of to create and check for an existing object property?
if(object.prop) object.prop.test = value; else object.prop = { test: value };
I can't remember if in is a thing in js
If so you can check if it's in the object
But I don't see what's wrong with doing object.prop and then setting it no?
Isn't there something like ??= ?
I doubt it, it works
Ah yes forgot about that mf
in any server even if no permissions
Well my guy it's literally an issue with posting to a channel

Stat command would respond with a message
But I don't see ??= is helping me
If it can't send it will error
If left hand null assign the right to the left isn't that what you want?
Permission flags will change in v14 to djs' loved camel case
https://discord-api-types.dev/api/discord-api-types-payloads/common#PermissionFlagsBits
just to say
The enum name even changes doesnt it?
@sharp geyser
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
I found which channel
Why ping me
Seems like it doesn't have permission to send in that channel
Gj finding out what the channel is
Gtg
hmm i don't think so, need to check if the first prop exists before I can check/create another nested prop inside
Where's Tim or Voltrex when you need them

jesus christ v14 is going to suck
I don't think I wanna update
wait v14 is already released?
It's a master version iirc
Errors in the console are fine btw
I'm not updating
It hasn't been pushed to stable I don't think
i dont think so, but when deciding to do create something new, go with the latest changes
don't build something that will be deprecated in a few weeks again
object.prop = object.prop || {}; object.prop.test = value;
well... that's literally the same
or no wait. I have one better
Isn't that essentially the same as using ??=
just without the statement at all
object.prop = Object.assign(object.prop || {}, { test: value });
ok I updated every event with that method
now I shall never see that error again
thank god
thanks for help
no because I need to check the first prop at first before accessing another property inside it
hmm ok I see that's not really more effient than what I did
NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
ERROR Unhandled rejection: TypeError: channel.permissionsFor is not a function
what
permissionsFor doesn't exist on DM channels
Dms don’t use permissions
I fucking accidentally replaced my messageCreate event with another
and didn't save
time to fucking rewrite
🤮
God thanks somebody invented CTRL + Z
ik
problem is I wasn't using any text editor 😭
Most ridiculous thing is they don't start with a small letter as camel case would do
my lib wont even have permission strings, if you wanna deal with permissions, learn bitwise
true, but still ridiculous
how will they work in v14?
what?
permissions
That won't help you with API errors caused by Discord
Best example:
ChangeNickname, PermissionsBitField { bitfield: 1071661829185n }, true
// interaction.appPermissions?.has(permission) -> true
Obiviously ChangeNickname is part of the bitfield
When executing the god damn action, look at the response:
rawError: { message: 'Missing Permissions', code: 50013 },
code: 50013,
status: 403,
method: 'PATCH',
url: 'https://discord.com/api/v10/guilds/768526426412417045/members/972714450564026408',
requestBody: {
files: undefined,
json: { nick: 'test bot', communication_disabled_until: undefined }
}
How does bitwise help with Discord API issues, hmm?

appPermissions is a new field respresenting your, guess, app permissions in any situtation
I'm definitely not updating now
I've got no words...
permissions are fucked up so many times, I can't count this anymore
lmao
honestly most of the time its not even worth handling them
except if your bot is huge
but for small medium bots its much easier to just let it error
I can't fucking fix this API issue
Not even reinviting helps
I'm still missing the permissions to change the nickname while the appPermissions telling me, I'm allowed to do so
💀
Also inconsistency anywhere in the lib, my gosh
well, kicking and reinviting doesn't work as well
nothing fixes the api permission issue
great
Either it’s the v10 gateway or my guild is fucked up
When using Cloudflare Workers, your app won't be able to access non-ephemeral CDN media. For example, trying to fetch an image like https://cdn.discordapp.com/attachments/1234/56789/my_image.png would result in a 403 error. Cloudflare Workers are still able to access ephemeral CDN media.
is there any other way to access things such as user avatars, guild icons, etc w cloudfare workers
😔 another discord.js issue
the second line 10 seconds later says undefined but that means that I did try to login and my bot simply never gets ready
I also tried bot.login(...).then(console.log).catch(console.log) but there's absolutely nothing
using a timeout is not the right way to wait for the bot to be ready
you need to use the ready event bot.on("ready", () => {})
I know
I did this..
after I realised my bot simply isnt loading
to see the bot's connection status you can use the debug event
bot.on("debug", console.log)
will try
meh i think this is pretty much not possible
unless using a different image server, but i dont think any other image server has all discord avatars + guild icons
why the fuck cant cf workers access discord stuff?
There’s a client method isReady() you can await as well
🤷♂️
it was just me trying to find the problem.. it's not an error of me happening before the bot attempts to log in.. it tries but then.. yea gonna on("debug")
huh
id assume it has to do with some sort of security problem but i dont think there would be any security issues




