#development
1 messages · Page 2038 of 1
Wtf that is cool didn't know that
arg0 = args[0] 
how much faster?
It's used multiple times, so pointless to access the first element multiple times
That’s just micro optimizations
holy crap
does that work in c#?
The logical NOT operator (!) is generally meant for booleans only, as for the same concept in many statically typed programming languages, not for every value that exists to cast it to a boolean
Ir doesn’t make a noticeable difference between calling the var or array item
So basically it was meant to compare boolean values?
Optimization is optimization. 
Not much, but negligible to sat the least
True but as long as you’re just calling stuff which is already available in the memory defining another var for it seems pointless
It's mostly just meant to negate a boolean value to it's opposite bit, those operators aren't really supposed to be used on giant objects and classes and all kinds of other values to cast them into booleans forcefully, which can take a while depending on the type of the value
If you would for example use length a few times on the same array, in a loop, then creating a var once calling length would make sense
even i dont micro optimize THAT much
I'm THE optimizer, don't get in my way!
Or in the case and only then, when you’re calling a god damn long var nested in an object or deep array, creating a reference makes sense
lol
FakE we get it you don't like micro optimizations, now shut up before I micro optimize those bombs in your car

If they would only work I could do some holidays
shut up fake she doesnt say that
dont they carry a boolean valueOf-like all the time?
like stuff in js is either considered truthy or falsy, dont all data types have that already pre-defined?
Not really, they used to have an internal slot for that but it was removed due to it causing issues in edge cases, I don't remember what the edge cases were but they existed apparently
so what does it do instead? check if value is any of the truthy types?
an object cannot possibly be false, so what else does it need to check?
if typeof === object, automatically return true
It basically compares against a constant set of values, depending on the primitive type of the value, it returns the corresponding set to compare against, and if one matches, it negates it using the rule of the matched value, all of the values in the sets have their rules on how to cast a value to a boolean
In other words, if the value that has to be casted to a boolean matches the set of elements in it's own primitive type category, it picks the correct rule to cast the value to a boolean by
It's like a chamber of constant truthy and falsey values with categories assigned to them
where to implement this code ?
I’m missing the context a little bit but that code was part of an example of code you can use in the description of your bot on topgg
MessageEMbed decription must be a string
It does support html
You’re defining fields not a description
yeah yeah I forgot to change that
But using the wrong method for
by the way that code looks cleaner does it not?
that is how I usually write
not that mess I wrote earlier
now I'm getting MessageEmbed field values must be non-empty strings.
It's rather self-explanatory, either the content or the author property of the recentSnipe object is an empty string
Maybe try logging them and see
I don't think so, I would get an error
it does work when I send a message but not when I delete an image
but that's why I added that ternary operator
And you've got an error, try logging those properties when you use them and see what they really are
You wouldn’t get an error if they are null or u defined
you dont need to add async everywhere and use trycatch everywhere
If any property would be null or undefined you’re try catch clause wouldn’t error
I know I added that catch there for testing
Well just log your content, author, etc. and you will see the issue
That will actually cause a new error
If content is null or undefined a property length won’t exist
I mean it's not undefined, it was literally empty
in body tag ?
Then just do if(!sniper.content.trim()) // no content
You don’t need the html or body tags
You can simply use the style element as in my example
And put it in the description
(on top)
Before calling the classes
(if there is one to call in it, don’t remember the code anymore)
the trim() method is not a boolean.. I think?
at this point I'm more confused with JS than I am with batch
Wut?
okay
how does the trim() method work that makes it act like a boolean?
trim trims the content of any unnecessary white spaces
I thought it removed unnecessary space chars
precisely so it does nto act like a boolean
What does it need to?
I mean if you're using it in an if statement, yes?
If the content IS empty then !content is true
Just do content === '', god damn
I have lol
Nobody does that
also im pretty sure you cant ever receive a content from discord that only has whitespaces
Can’t even think of an uglier style
!content === '' moment
Maybe unicode space shit
if that bypasses discord it will also bypass trim()
That uglier style is yo- I'm advised to not continue further with this joke.
Hmm actually true but I’m not sure how trim gets rid of what exactly
FakE try to conform to micro optimizations challenge
Ah yeah nvm then
Well it actually wouldn’t matter then anyways
With or without it
I still don’t get why it has to return a boolean value just because I used it in the statement but okay
But he seems to be missing some fundamentals of JavaScript obviously
how hes scared for life, will never use !somethign again
.-.
at some point they will try using !Boolean(something)
and then eventually realize thats even slower
I don’t wanna sleep now after seeing that
Just do
content === '', god damn
That could cause a nightmare
do you guys have any idea for commands?
You shouldn’t complain about others when it comes to optimizations and benchmarking, Sir
you will have to get the permission first 
Ok, gib, now!
you need to be permission level 6 if I'm correct - Bot Moderator
I’m a level 99 dungeon master, Sir
Level 6 hahaha
Nitro makes everything possible
but... you don't have nitro
which I’m not paying for
interesting
sell your car and buy nitro
Not even the entire platform is worth the money I get from selling it
Doubt I will ever get a fan of discord
Oooo, optimizations scary ooo; I'm gonna make them your daily nightmare
Go back to general! 
Go back to driving your car
Ah, must've had a segmentation fault trying to understand simple optimization concept, how sad!
lol
Anyway jokes aside, NordVPN's CLI is the worst... it literally halts the entire terminal if one of it's processes are not finished, you can't even interrupt it

Already tried, doing that prevents the terminal from starting up at all lmao
lol but wtf
Cannot read properties of undefined (reading 'member')
guild.owner is not guaranteed to exist, and iirc it was even removed
besides that, owner.member is not even a thing, it doesnt make sense
I tried owner.user as well
I'm not aware of the API changes after discord.js 10 pretty sure
and it did exist
ownerId exists instead, but yeah it got removed
Which he can fetch
there is guild.fetchOwner()
Ow nvm then
Well then reading at least the guides about what had changed makes sense, a lot of sense
To prevent running into the same issues over and over again
I see thanks
how do you fetch the guilds region though?
I tried using message.guild.region but it returned undefined
regions were removed from guilds and put on voice channels
because each voice channel can be in a different region now
I see well that's a big surprise
can anyoen figure out why this regex doesn't work?
supposed to either use mention as a prefix or the preset prefix
it works with unicodes like ! or - but doesn't work with letters like 1 or d!
any idea why?
escape your custom prefix or it'll be treated as a regex
you do not want your code to be vulnerable against ReDoS
function escapeRegExp(text) {
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
}```
or simply use startsWith(), that's faster
Hello i have this but idk what to put on the /dblwebhook and tggpassword pls help xD
pls help me out
first line
and install https://www.npmjs.com/package/ffmpeg-static
should fix the problem

wait
there's no way I can set this to something, like JS?
Add pkgs.ffmpeg to replit.nix
You can enter the file by typing #replit.nix at the end of the url
you can cast client to something else
(client as any).commands = ...
(client as Record<string, any>).clients = ...
You need to override the types
You could do what Tim said or you could override it in a .d.ts file
I prefer the latter
or extend it ```js
class MyClient extends Discord.Client {
commands = new Discord.Collection()
}
const client = new MyClient()
like
create an types/common/discord.d.ts
with code:
declare module "discord.js" {
export interface Client {
commands: Collection<unknown, any>
}
}
??
i'll try Tim method
Yes
Something similar to that
until you install an x package that depends on y that depends on z
and the z package is malware 
im used to malware
node-ipc my beloved
having to re-compile the regex every use my beloved
I would assume the JavaScript engine will optimise that anyways
@earnest phoenix ?
most likely
I have this script that loops through all members and checks if their nick isn't [1000] <username>. However, the bot is now rate limited and can't loop through the last 100 members or so. Should I just wait? Is there a more efficient way to go about this?
await interaction.guild.members.fetch().then(async members => {
for(const member of members.values()) {
if (!member || member.id === "593882880854196228") {
return;
}
if (!member.displayName) {
console.log("Couldn't get " + member.id + "'s display name.");
return;
}
// Checks if their nick isn't [1000] SomeUsernameHere
if (member.displayName.includes("[") && !member.displayName.includes("1000")) {
let memberNick = member.displayName;
let splite = memberNick.split(" ");
console.log(member.displayName + " -> " + '[1000] ' + splite[1]);
await member.setNickname('[1000] ' + splite[1]);
}
}
console.log("Done.");
});
i can't install discord.js
happened to me a few times too
keep cancelling and trying until it works
also try using a different terminal
think it has something to do with bad Internet
Always for me 
npm works great for me all the time
but I do have gigabit internet and a decent cpu to process tars
how can i get the interaction user's voice channel with djs
probably interaction.member.voice.channel
yep that worked 
Optional chaining makes sense here
Member isn’t available for each interaction
interaction?.member…
Might also be the case for the voice property
When running it in a DM channel it will cause an error when trying to detect a voice channel
can anyone tell me why this reacts to ANY prefix? const prefix = message.content.startsWith(settings.prefix) ? settings.prefix : <@!${client.user.id}>;
settings.prefix is -
and it reacts to anything like ! d or even something like something something command
uh what exactly are you trying to do
probably easier this way
if someone does say -help I want it to work since that' the correct prefix, but instead if they did @mention help I want it still to work
yeah you did it completely wrong
just a sec
mentions are a bit more complicated since they differ on mobile and desktop
yeah probably, I just tested with 3 variations, I hear mobile uses regex while desktop uses a different method
do you know how I can fix that?
User mentions now have the following format <@USER_ID>
I tried that
the code you see in the screenshot is what I used and it somehow reacted to me doing i something something help
The split between profile names and nicknames was stupid anyways
That’s why discord got rid of it
How does that make sense?
I have no idea whatsoever you're welcome to join my testing server and see for yourself
If you haven’t found the prefix you automatically assume the mention has been used as prefix without checking for it
it doesn't react to !help or dhelp but it reacts to -help (the correct prefix) @mention help but also reacts to some weird anomalies sometimes, and i something something help appears to be one of them
Make sure to check either the prefix has been used OR the mention
I have
this kind of thing is complicated for a beginner (i assume anyways) so im just gonna give you the code and explain it to you
// Check if message either starts with prefix or "<mention> " (keep the space in mind).
if (!message.content.startsWith(settings.prefix)) && !message.content.startsWith(`<@${client.id}> `)) return;
// Create variables.
// Create arguments which will omit the command/prefix.
let args = message.content.split(" ");
let cmd;
// If settings prefix has been used.
if (message.content.startsWith(settings.prefix) {
// Remove the prefix from the first argument and set it as the command.
cmd = args[0].slice(settings.prefix.length);
args = args.slice(1);
} else {
// If mention has been used.
// Simply set the second argument as the command.
cmd = args[1];
args = args.slice(2);
}
// continue your processing
of course tune it to your use case
besides you should be using slash command realistically
that (!prefix) return; will never happen
I haven't accustomed myself to them yet
I just came back to bot development very recently
is the space in !message.content.startsWith(<@${client.id}> )) return; really needed?
seems like an error
you dont need it but i personally think a space between the @ and the actual command looks better
removing that would need a code refactor tho
those if statements at the end wouldnt really be needed anymore
Why does the mention need to have a white space?
I mean you could look at the code I showed in the screenshot and compare to what I'm trying to achieve
preference for me personally
Doesn’t make sense at this point since he later checks for arguments
If I only ping a bot without any argument I assume it will send me an help list how to use it
This mention does not include a white space
wait client.id?
so it's not client.user.id?????
??????
was that the error I made in my code???
no way
pretty sure both will work
Nah id doesn’t exist as property on the base client
so client.id is false?
so which one should I use?
I'm getting confused, what we're doing is essentially the same
in that case yeah its client.user.id instead of client.id
no waterproof phon?

What is the average time to add robots?
@boreal iron if i have a number
how do I detect whether it's a 1st 2nd 3rd quantity? I want to add that to my welcome message thing
show an example because idk what you mean
if say var num = 1;
and I request the var using console.log(num) it's gonna output 1
how do I output 1st, same with 2 being 2nd and 3 being 3rd
same with bigger numbers such as 21st
either make a list yourself or you can use the Intl api
a list? you mean like every single number?
you dont need every single number, just follow the ordinal rules
ex if number ends with 1, add "st"
if number ends with 2, add "nd"
yes there is
is this gonna work?
this is just an example I'm obviously not gonna make it look this bad
if number is a string yes
since endswith and startswith are string methods
that end there is not valid js tho
nesting more statements is gonna make it look slightly ugly
nah
it is though :/
and I'm gonna have to make them be upfront as well
so it's gonna be 11, 12, 1, 2, 3
are there any more such exceptions
heres an example of how someone else did it
function getNumberWithOrdinal(n) {
var s = ["th", "st", "nd", "rd"],
v = n % 100;
return n + (s[(v - 20) % 10] || s[v] || s[0]);
}
Mobile code blocks doodoo
well they're way smarted than me lol
afaik 11 12 13 are the only exceptions
Think thats the function i use
but they also apply to bigger numbers
how am I supposed to get an = with that weird / in the middle
for examole 113 or 1013 also apply the 13 exception
thats just their text editor's theme
its just a !==
oh I see
font ligatures
fonts like fira code have ligatures
does this look good?
looks like a bot whose owner doesnt know english very well
try to be more descriptive
how descriptive?
oh I thought that variable was automatically a string
of course I do
either way could you elaborate on this?
for example even this looks better ```
prefix: -
log channel: channel
mod role: role
...
works great 
that's what I had before, it didn't look quite decent enough that's why I went with Key Set
i personally dont like the key set way
I see I'll try doing it your way once more to see how well that looks
@quartz kindle yeah I don't think it looks better
why doesn't client.user.avatarURL() not work?
Show your code
how can i send long strings in js
message.channel.send(`\`\`\`ansi\n
[0;31m ____ _ _ _ _ _
| __ )| | __ _ ___| | _| (_)___| |_ ___ _ __
| _ \| |/ _` |/ __| |/ / | / __| __/ _ \ '__|
| |_) | | (_| | (__| <| | \__ \ || __/ |
|____/|_|\__,_|\___|_|\_\_|_|___/\__\___|_|
\`\`\``)```
doesn't work
are you backslahing the ` at the beginning and end on purpose?
you also need to make sure to backslash ` that are inside the string
and it's not 3 it's just 1
that should work you're just missing a backslash on a ` inside
right in the middle
It does optimize it, although everytime it's encountered, it's matched against the set of saved regexps to see which one it is
Declaring it as a constant outside of a hot path will mostly be a micro optimization
I have a quick question
in djs v13
does messages count as interactions?
like can i use the "interactionCreate" event for messages or do i need a separate event for that?
Messages and interactions aren't the same, in discord.js, you would have to use the messageCreate event for messages and the interactionCreate event for interactions
not good enough
Is there actually a way to enforce to use a sub command instead of just using the base command?
Or would I need to use choices?
Sub commands can not have required as option
The base command?
hold on I think my guild commands are fucked up
lemme clear them real quick
I registered a command with two sub commands and the client actually shows 3
The base, and the the base with the two sub commands
wtf
my gosh I can't delete the guild command
🤦♂️
probably a caching issue as there's no API error
How to put emoji in the selection menu?? please someone help me 😭
I don't know anything about programming
Are you able to send a menu first?
Using Bot commands, yes
Option icon accept emoji like this 😄
Or 
To add custom emoji
Use this format: !topggWink
Oh you using a bot
I can't help then check their documentations
I'm Bot Slash
just make 2 different options, 1 for the role, one for the emoji.
You cant put a string inside the role option
DiscordAPIError: Cannot send messages to this user when mentioning a bot? Also this code is in a try catch method so I'm not sure why it stills throws an error
did you await your promises inside the try block?
is member.send a promise?
yes, everything that involves talking to discord is a promise
callback hell time
how do I get the name of the owner? fetchOwner() didn't work either
The <Guild>.fetchOwner() method returns a promise, resolve and access it's properties
should I do <Guild>.fetchOwner().user.tag or <Guild>.fetchOwner().tag cause the latter returned undefined
I literally just said that the method returns a promise, you must resolve it first before accessing it's properties
Nah, I would Promise.resolve(papiOphCodePromise)

i accept your resolve
Hello i have this but idk what to put on the /dblwebhook and tggpassword pls help xD
The /dblwebhook is just a placeholder indicating the endpoint you've put on the webhook field on your bot's Top.gg page, for example if you've put http://<IP address>:<port>/voted, it should be /voted, but you can put anything you want, such as the /dblwebhook as shown
Yeah the webhook URL as I mentioned goes in the Webhook URL field, and the password of the webhook (tggpassword as you were asking about) goes in the Authorization field
Although it's better to ask about that in #topgg-api instead
oh so in the webhook url is also
/dblwebhook or with the ip sorry
yes sorry not many people just go there
The one that goes in the Webhook URL field must contain the whole URL, not just the endpoint
oh now i get it then in the code its just the endpoint
since i use Digital ocean the port is normally 22 right and ip is the ipv4
Yes
Ok imma try Thank you 
Um
You're supposed to pass whatever you entered in the Authorization field to the second parameter, as it seems you have't declared it with a variables so just pass it in
oh
.dbl_webhook("/dblwebhook", "Your webhook password goes here")
but thats what i put here
you have to pass it as a string, not as a variable
You're using it as a variable, not as a string, just tggpassword is an identifier and will try to lookup a variable
Bascially "tggpassword"
what is not working? the vote event?
where's bot.topgg_webhook.run()
oh
kk sorry
pick a random non-protected port, for example 3000
and add it to the url field in your top.gg edit page
http://YOURIP:3000/dblwebhook
http://<ipv4>:3400/dblwebhook like this oh
yes
oops
lol the python-sdk for top.gg has completely different things in their github examples and their documentation examples
ye
i think the port should also be inside xD
ye xD
how can i install icons as an svg from fontawesome?
yeah try that
explain what you're trying to do
lel
Works fine now thanks 
👍
it works fine in the test webhook but not in actual vote xD
weird

im assuming bot.get_user does not fetch from discord and only gets from cache
and the user id you're getting is not cached
regardless you dont need to use await there
you might be looking for bot.fetch_user instead, which does fetch the user from discord if not cached, and does require await
k
works good thank you
Random but why would anyone use bot.get_user then instead of bot.fetch_user if bot.fetch_user does the same thing just with a promise and a fetch of the user if its not cached
Doing bot.get_user and checking if its None and then fetching the user would just be doing bot.fetch_user with an extra step
I honestly think it is just there to be there
Yeah
They dont prepare that much
I think so

In djs the fetch method checks cache first lol
but since djs Caches everything you sometimes don't need any fetch functions unless you know they are not gonna be cached
Such as a user that is not in a server the bot is in
It literally just fetches from the api
so ye
async def fetch_user(self, user_id: int, /) -> User:
"""|coro|
Retrieves a :class:`~discord.User` based on their ID.
You do not have to share any guilds with the user to get this information,
however many operations do require that you do.
.. note::
This method is an API call. If you have :attr:`discord.Intents.members` and member cache enabled, consider :meth:`get_user` instead.
.. versionchanged:: 2.0
``user_id`` parameter is now positional-only.
Parameters
-----------
user_id: :class:`int`
The user's ID to fetch from.
Raises
-------
NotFound
A user with this ID does not exist.
HTTPException
Fetching the user failed.
Returns
--------
:class:`~discord.User`
The user you requested.
"""
data = await self.http.get_user(user_id)
return User(state=self._connection, data=data)
Ig tim should have said then
use get_user first and then check if its None
And if it is then use fetch_user
Wonder why dpy just doesn't remove the extra step and checks cache in the fetch function
Cause they don't prepare that far ahead
Why not
We are meming but there is probably a valid reason why they haven't
majority of em no
there are a handful that are
like daff and sky
they actually use their brains and not bang rocks against their heads
Maybe they can't or they just didn't think about it
It is likely they can't do it in a way that isn't a headache but 🤷♀️
I dont know python well enough to determine
same
is there a way to allow line breaks inside of an interaction option as you can not space down with shift/enter?
As far as I know there is no way to do so
No there isn't
well that sucks. thanks for the answers
Because it's pointless and goes against the idea of fetching from API
It's up to you to handle. Cache can be out of date in rare cases and that's why you'd want to fetch data from the API directly
get_user(id) or await fetch_user(id)
There's the option of having users type something as a separator
Maybe \n could work, so that users would use that for a linebreak
true
Or just discord adds multi line support to string interaction options to desktop for once
\n doesnt work as it just sees it as part of the string
Yes
And you replace that with characters for newline so that it becomes a newline
yeah theres no chance i can even get people to use \n correctly. i get multiple dms a week because someone couldnt read correctly.
Could always try
if only we could have kept message commands. was a much more simple time lmao
Ikr
Modals support text fields and text areas which support multi line text input
An easy example how to use it, is to execute slash command with all options you need to have, then when sending the command return a modal with a text field or text area to collect whatever you need.
Once the user is confirming that modal, take all options together and modal to do whatever you wanna do with that command
Zamn
how do i make my bot come online in my server?
You invite your bot, then start the application
i think i didnt do that
how do i invite my bot to my server then start the application
The developer portal of Discord has an URL generator
Select your app -> OAuth2 -> Select the scopes and permissions
do i click new application
Well if you haven't did so yet, you don't have an application
If you dont have a car you can't drive "your" car
ah yes webpacked code noob code
which one should i select
depends on what you sort of app you wanna create
i invited my bot to my server
a bot connected to the gateway will require the bot scope
if you wanna create application commands, too, then both are required
so how do i create it
By coding it?!
how do i code it
Choose a language you like and you're familiar with, then decide if you wanna use a library or create the gateway connections and rest API calls yourself
how do i create the gateway
you should probably consider using a library
and even before that, you should consider getting yourself familiar with the programming language you're going to use
huh cry still alive 
my bot is still offline
you have to use a programming language and a library for discord that corresponds to your programming language
this requires prior knowledge in computer science basics
nothing
a discord bot is not a magic thing that comes on by itself
it's just an interface
for you to use it, you have to pick up a programming language and a discord library for it
where can i find it
google the programming language you're most familiar with and add "discord library" to that
what should i type in google
^
what do i click after i open that link
Dude, choose a library in a language you like and prefer, then look out for the library guidelines how to use it
Then begin using it and take a look at their docs how to work with it
read this
How do I make a Discord bot?
Since code is required to run a bot, we very strongly recommend that you have some programming experience before making your own. Note that code is executed and a bot is the product of that code; a bot is not something into which code is loaded, and a bot will not automatically do anything unless you program it accordingly. With some programming knowledge, the first step to developing a bot is to create a new application at https://discordapp.com/developers/applications/me. You should then read the documentation regarding the Discord API on the same site. Following that, you may want to pick a community-supported API library in a programming language of your choice. Each library will have its own set of documentation and instructions for developing applications, which you should read and follow before writing your bot code.
i.e. you should probably familiarize yourself with computer science basics and a programming language before continuing with a discord bot
a great introduction is cs50 by harvard
can someone help me code my bot
watch a youtube video or something, we're not going to spoonfeed code
can someone find me a video
You should try doing something on your own
like what
In that case finding a guide, video, tutorial whatever if you want to view/watch one
what can i type in google
https://youtube.com and search "how to make a discord bot"
If there's no programming language you're familiar with you should not start with a bot
^^^^^^^^^^^^^^^
"can someone find me a video"
😭
newbies get more and more lazy every year i swear

Nice pong
how do i use utf8 symbols in my code
nano doesn't like it
so whenever i try to add it, it fails
just transferred from my PC
i just coded my bot but it still wont come online
this is actually starting to look good
but again
memory
god i hate electron
but making apps with web technology is so nice
yeah doesn't look bad tbh
did ya see my message
you know what does?
i'm not happy with the memory usage at all
300mb and i don't do any background activity yet
my bot wont come online after i have coded it
you have to actually run your code
Well
Those red lines are indicating your issues
how do i fix it then
you have to know at least the basics of your programming language before you make a discord bot
case sensitivity is important
what should i do then
dude
what part of "coding is case sensitive" you dont understand?
Learn. Go to google, there are so many resources. Try to learn the language
what should i type on google
LOL
Bro at this point this just looks like you are trolling
yeah im out
I wonder he didn't ask how to get to google
do you know what "case sensitive" means?
no
Tim
"case" means uppercase or lowercase letters
for example "A" is uppercase, "a" is lowercase
kk
case sensitive means that uppercase and lowercase letters have different meanings in code
oh
you cannot freely use one or the other
what do i need to do
as i explained, Const with an uppercase C is not valid code
should i make it lowercase
yes
now it says Unexpected token
and here, this is not the same word, these are two different words, so logically it will not work
Also remove the unnecessary spaces anywhere
because the case is different
They aren't valid, too
which number
L14
we can't help you with every syntactic error you have, you have to familiarize yourself with js -> https://developer.mozilla.org/en-US/docs/Web/JavaScript
JavaScript (JS) is a lightweight, interpreted, or just-in-time compiled programming language with first-class functions. While it is most well-known as the scripting language for Web pages, many non-browser environments also use it, such as Node.js, Apache CouchDB and Adobe Acrobat. JavaScript is a prototype-based, multi-paradigm, single-threade...
Tim warming up
so should i delete it
why does this happen
yeah delete your entire file, and start from scratch, but this time learn some basics, follow guides, read documentations, etc
I'm sure that code block looks funny on mobile
but i follow what youtube says
yeah its fucked on mobile, but it looks nice on pc so
oh
if you're following a youtube video, first make sure its updated, things change very fast with discord.js
if your video is not made for version 13 of discord.js, then its outdated and you should not follow it
https://capy-cdn.xyz/AbZ5yjfmqxwJ.png thats what its meant to look like
idk why js is fucking it up
second, pay attention to the video, you are not doing it like the video shows
yea i am
if you were, you wouldnt be writing invalid code
i dobut the video is showing you invalid code, i know youtube videos are garbage but even that cant be that garbage
ugh i give up then
what video are you following?
unless someone can zoom me and i share my screen then someone can control my screen and show me
this
your code
there are a lot of things you did wrong
thats why i said, pay attention
who has zoom
the video is literally showing you, and you are copying it wrong lol
wut
can someone zoom me and show me
no
why
nobody is gonna do it for you
because you wont learn anything is somebody else is doing stuff for you
unless you pay them
:P
i tried myself and idk how
and there we go, back to the capitalism
you literally copied wrong lol
i just give up then
just go back to the video, watch it again, and copy it right
what is so hard about that?
never mind then
ok then
Try that
Even easier for you to copy and paste stuff without understanding what it does

Kek
Maybe take it slow and learn the basics of programming first, then getting into JS (or basics of it, rather)
just use python problem solved
go on sir
No plz we don't claim such people
take your snakes with you
ok
ok php guy
ok driving while texting guy
sheeshh
sheeesh
sheeeeeeeeeeesh
ok
do you have to use next in an Express route for error handling?!?!1
before he learns programming he needs to learn to copy first
learn how to bing 
duck duck go
duck duck stop
my brain is fried
Lol
why does ownerName keeps giving me an error?
if you wanna do it that way, then it should be (await guild.fetchOwner()).user.tag
if I'm not wrong
at this point I'd rather not
You’re right
\ s
const owner = await guild.fetchOwner() then use owner.user.tag or something
Yep
if you only need the owner name and nothing else then do what fake said
But I think it's easier this way
It leads you to making a useless variable tbh
If all you need is the owners name why bother putting the entire owner object into a variable
Yea you are right
they removed guild.owner.name
so can't do it any other way
that is why you get the tag from the user
but you can't get the user unless u fetch the owner
bt the way @sharp geyser can you test my bot out 
I need feedback
no
Don't feel like it
ik
No means no stop pinging me for it
what's his issue actually?
huh
Idrk what the issue is at this point but going from his original problem he was trying to get the owner's name and couldnt
also you are pulling not only the server owner tag also the id
Then use this way get guild owner as a object
huh
What should I use in place of interaction.user.hasPermission()
hmm
interaction.member is a thing last I recall
interaction.member.hasPermission()
What should I use in place of this
Coz its deprecated
ofc only if the command has been used in a guild
Yep
member.permissions.has(...)
But then you can just check the channel type and ignore the permission thing
But it doesn't worked
Then show your code maybe?
a plus for making your app with electron is that you can use its BrowserWindow for puppeteer
so you don't bloat your app with extra 200mb for the puppeteer browser
everything else? a minus
😭
i have a record command that updates 2 elo ratings. one is a combined elo rating and one is a distinct elo rating.
so if you play a 1v1 match you'll have a 1v1s rating and a 1s rating. if you play another match, but this time it's 1v1v1 then you have a new 1v1v1s rating and update the 1s rating.
my question is what would be the best way to handle undoing a recording? for instance if someone tried to undo the first 1v1 match before undoing the second 1v1v1 match it would mess up the combined elo rating, but the distinct would be correct. should I force the user to undo in order or let them undo out of order with a warning? or maybe force them to choose which type of rating they want to use, but that'll probably be too confusing.
hii guys, so i creating my bot from scratch with slash commands integrated, and i got this err. Can someone explain me why
you know you've fucked up big time when js tells you console.log is not a function
your sql version is outdated
yea ik
amm i would sugest you to try lower version of node
like 16.15.0
18.0 is not yet stable
good advice above but if you cant you can try uninstalling then reinstalling forcefully
npm uninstall better-sqlite3
npm install better-sqlite3 --force
by the way what is the point of that (async() => ())
If you deleted the async function it should work
The problem likely was you didn't have a semi after the console log so it thought the below was it's function call (or that is what I think is happening as it's happened in the past to me)
You can keep the async function there just put a semi on the console log
ok deleted await
public async send(data: MessageSendData): Promise<Message> {
return await this.client.rest.post(`/channels/${this.id}/messages`, data);
}
Alright so this is supposed to return a message object right? Well the thing is when I go to use .then when using the send method the type of the data returned is an object (rightfully so), so I am wondering what would be the most logical way to convert the data sent to a Message, I already made a parse method like tim suggested on the Message class but I am still unsure of how I should actually do this logically
message.channel.send({ content: 'Hello World!' }).then((msg) => {
setTimeout(() => {
console.log(typeof msg);
console.log('Done');
// msg.edit({ content: 'Fuck off' });
}, 5000);
});
As in this example below
msg is a object and not the Message instance it should be
did you add a ; at the end of console.log? show your current code
I also thought of just returning a new Message(client, theDataFromThePost) but that didn't end up working either
thats exaclty what you have to do, why didnt it work?
C:\Users\dyeaa\Documents\github\misty\strife\src\client\rest\structures\Message.ts:47
this.channel = this.guild.channels.get(this.channelId) as GuildTextChannel;
^
TypeError: Cannot read properties of undefined (reading 'channels')
how do you define this.guild?
this.guild = this.client.guilds.get(this.guildId);
and is this.client and this.guildId defined before that?
Indeed it is
did you console.log the data from the post and check if your Message class is compatible with it?
Ah this doesn't have a guild_id
that makes sense
{
id: '975504454960951336',
type: 0,
content: 'Hello World!',
channel_id: '972975386549968936',
author: {
id: '961018771261231104',
username: 'Teamer',
avatar: null,
avatar_decoration: null,
discriminator: '1564',
public_flags: 0,
bot: true
},
attachments: [],
embeds: [],
mentions: [],
mention_roles: [],
pinned: false,
mention_everyone: false,
tts: false,
timestamp: '2022-05-15T21:06:26.059000+00:00',
edited_timestamp: null,
flags: 0,
components: [],
referenced_message: null
}
- For MESSAGE_CREATE and MESSAGE_UPDATE events, the message object may not contain a guild_id or member field since the events are sent directly to the receiving user and the bot who sent the message, rather than being sent through the guild like non-ephemeral messages.
I see
So I wont always get the guild_id
If there isn't always a guild_id then that means I have ot think of another way to get the guild when it isn't there
ah i think thats not problem ; are not problem in js
use the one you already have
yes they are
They are when using anonymous async functions (or whatever they are called)
in your specific situation they are
Mmm do you mean to use the one from the GuildTextChannel?
send() {
const response = await this.client.rest.post(...);
response.guild_id = this.guildId;
return new Message(this.client, response);
}
Thank you
ok ok, its going good...but: I got this, idk why it give me this, but im sure that i can use require instead of import
I'm trying to figure out how to make this if statement work only if it's executed in a guild
message.guild seems to always return true
you want to make that if nsfw command is executed in no nsfw channel it returns alert?
Mmm, seems like you are using something other then cjs (at least that is what the error states)
something like that. I just need to figure out how to make the guild check work
how do I check if the place I'm executing the command from is a server
you can: ```js
if(!message.channel.nsfw) {
message.reply('You can use this command only in NSFW tagged channels !!')
return
}
to check if channel have nsfw on
no I don't want that. I want to check if I'm executing this message in a server, cause I want this command to be able to be used in dms too
Check the channel type
how?
Text Channels and DM Channels have a different type attached to the channel object
I know that. I have no idea how to access that
I'm not at all famliar with the disscord API
By reading the docs and realizing there is a type prop on the channel object
message.channel.type === "guild"
no
then show me how to properly do it
type is a enum (which evaluates to a number in the end)
https://discord.js.org/#/docs/discord.js/stable/typedef/ChannelType
All I will give you is this, use one of these to check it
ChannelType is something you can import from discord.js btw
I am not going to fucking spoonfeed you every step of the way like everyone else has
You need to learn some stuff on your own
💀
I gave you the resources you will need, if you know basic js you should know how to fucking compare two things with each other
bro I just want a fucking example wdym you sent me a fucking webpage will channel types
you were on the right track with this
wtf am I supposed to do with that if I don't know how to check for the channel in the first place
He was cry but he expects people to just hand him the answer
this
he said that was wrong
the link tells you the types - you are on the right tracks just not with the guild part
it is
It is wrong, but you were on the right track
and i said you were on the right track
You would compare something but not a string
yes you would? 😭
Does djs use them as strings?
ah yea, i use REST
it can't use anything else
i think thats why
Mmm, but the channel types are integers no?
true enum type only exists in typescript
no idea i haven't used the api in a long time
well yes, but the docs state type is a integer why would it be a string
if (message.channel.type == 'DM') {
// code
} else
if ((message.channel.type == 'GUILD_TEXT') && (message.channel.nsfw)) {
// code
}
from the link you provided 💀
it does
djs is not a low level library
it's obviously going to translate enums to their string counterparts
Mmm ig
they know their userbase is fucking stupid
TypeError: Cannot read properties of undefined (reading 'filter')
const myCommands = message.guild ? container.commands.forEach(c=>c) : container.commands.filter(cmd => container.levelCache[cmd.conf.permLevel] <= level && cmd.conf.guildOnly !== true);
But won't discord cry back saying that type isn't an integer
found problem...it was fetch version
and even then, djs translates the enum again internally if used in an api request
what's wrong with the code?
you tell us, it's your code
if it's a guild then fetch all otherwise filter
Whenever it says Cannot read properties of undefined (reading 'x'), it typically means that whatever is before 'x' is undefined
@sharp geyser here's how they do it if you're interested https://github.com/discordjs/discord.js/blob/v13/src/util/Constants.js#L537-L552
basically they input an array of strings that they're going to use as enums and spit back out an object that automatically translates string values to their corresponding int
Mmm, I myself just use enums directly
this allows you to use strings without bothering yourself with numbers
ChannelTypes["GUILD_TEXT"] // 0
yeah same
I get the idea of using strings but personally I just find it cleaner to use enums directly
but that is the benefit of using ts :p
I know
Then have you figured out which part is returning undefined?
I have
container.commands is undefined. We have no context for what that means because we don’t actually know what you’re doing here
^
The code you posted has technically very little to do with the error
container is a collection
Then container.commands is undefined, I don’t know what to tell you
I know, it was undefined and I fixed it
So error resolved?
Then your code is working is it not?



