#development

1 messages · Page 2038 of 1

earnest phoenix
#

Using the strict equality operator (===) to compare them is faster than using the logical NOT operator (!) since it compares against multiple values rather than one constant value

sharp geyser
#

Wtf that is cool didn't know that

boreal iron
#

arg0 = args[0] freerealestate

dry imp
#

how much faster?

earnest phoenix
boreal iron
#

That’s just micro optimizations

ancient nova
earnest phoenix
# sharp geyser Wtf that is cool didn't know that

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

boreal iron
#

Ir doesn’t make a noticeable difference between calling the var or array item

sharp geyser
earnest phoenix
earnest phoenix
boreal iron
#

True but as long as you’re just calling stuff which is already available in the memory defining another var for it seems pointless

earnest phoenix
# sharp geyser So basically it was meant to compare boolean values?

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

boreal iron
#

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

quartz kindle
#

even i dont micro optimize THAT much

earnest phoenix
#

I'm THE optimizer, don't get in my way!

boreal iron
#

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

earnest phoenix
#

FakE we get it you don't like micro optimizations, now shut up before I micro optimize those bombs in your car

boreal iron
#

lmao

#

I like them but only until a certain point

#

which is what she says

earnest phoenix
boreal iron
dry imp
quartz kindle
#

like stuff in js is either considered truthy or falsy, dont all data types have that already pre-defined?

earnest phoenix
#

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

quartz kindle
#

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

earnest phoenix
#

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 ?

boreal iron
ancient nova
#

MessageEMbed decription must be a string

boreal iron
#

It does support html

ancient nova
#

it legit is though...

#

oh nevermind

boreal iron
#

You’re defining fields not a description

ancient nova
#

yeah yeah I forgot to change that

boreal iron
#

But using the wrong method for

ancient nova
#

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.

earnest phoenix
#

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

ancient nova
#

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

earnest phoenix
#

And you've got an error, try logging those properties when you use them and see what they really are

boreal iron
#

You wouldn’t get an error if they are null or u defined

quartz kindle
#

you dont need to add async everywhere and use trycatch everywhere

boreal iron
#

Not to say that the try catch is literally nonsense

#

lmao

ancient nova
#

instead of undefined it was literally empty

#

did not anticipate that

boreal iron
#

If any property would be null or undefined you’re try catch clause wouldn’t error

ancient nova
#

I know I added that catch there for testing

boreal iron
#

Well just log your content, author, etc. and you will see the issue

ancient nova
#

this should fix it

boreal iron
#

That will actually cause a new error

#

If content is null or undefined a property length won’t exist

ancient nova
ancient nova
boreal iron
#

Then just do if(!sniper.content.trim()) // no content

boreal iron
#

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)

ancient nova
#

at this point I'm more confused with JS than I am with batch

boreal iron
#

Wut?

earnest phoenix
ancient nova
#

how does the trim() method work that makes it act like a boolean?

boreal iron
#

trim trims the content of any unnecessary white spaces

ancient nova
#

I thought it removed unnecessary space chars

quartz kindle
#

trim() removes whitespaces from a string

#

for example "abc ".trim() = "abc"

ancient nova
#

precisely so it does nto act like a boolean

boreal iron
#

What does it need to?

ancient nova
#

I mean if you're using it in an if statement, yes?

quartz kindle
#

the reason for using it there is because " " is not false

#

but "" is

boreal iron
#

If the content IS empty then !content is true

ancient nova
#

I'm confused but okay

#

thanks

earnest phoenix
#

Just do content === '', god damn

boreal iron
#

Wtf

#

No

ancient nova
boreal iron
#

Nobody does that

quartz kindle
#

also im pretty sure you cant ever receive a content from discord that only has whitespaces

boreal iron
#

Can’t even think of an uglier style

ancient nova
#

!content === '' moment

quartz kindle
earnest phoenix
ancient nova
#

I am out

#

see ya

boreal iron
earnest phoenix
#

FakE try to conform to micro optimizations challenge

quartz kindle
#

it just matches specific utf8 codes

#

same as using replace with regex

boreal iron
#

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

quartz kindle
#

because he was influeced by all the voltrex micro optimization nonsense

#

:^)

boreal iron
#

True

#

That would confuse me, too

quartz kindle
#

how hes scared for life, will never use !somethign again

boreal iron
#

.-.

quartz kindle
#

at some point they will try using !Boolean(something)

#

and then eventually realize thats even slower

boreal iron
#

I don’t wanna sleep now after seeing that

#

Just do content === '', god damn

#

That could cause a nightmare

ancient nova
#

do you guys have any idea for commands?

boreal iron
ancient nova
#

I'm out of ideas

#

here's all the commands I thought of by myself

boreal iron
#

I like reboot, will invite the bot and call that continuously

ancient nova
boreal iron
#

Ok, gib, now!

ancient nova
#

you need to be permission level 6 if I'm correct - Bot Moderator

ancient nova
boreal iron
#

I’m a level 99 dungeon master, Sir
Level 6 hahaha

ancient nova
#

impossible

#

the max level you can achieve is 10

boreal iron
#

Nitro makes everything possible

ancient nova
#

but... you don't have nitro

boreal iron
#

which I’m not paying for

ancient nova
#

interesting

dry imp
boreal iron
#

Not even the entire platform is worth the money I get from selling it

#

Doubt I will ever get a fan of discord

earnest phoenix
boreal iron
#

Go back to general! smirk

earnest phoenix
#

Go back to driving your car

boreal iron
#

Nah, fake is sleeping now

#

Recovering from you

earnest phoenix
#

Ah, must've had a segmentation fault trying to understand simple optimization concept, how sad!

boreal iron
#

lol

earnest phoenix
#

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

boreal iron
#

Just start it as separate session in screen

#

And tab out if it halts until it’s done

earnest phoenix
#

Already tried, doing that prevents the terminal from starting up at all lmao

boreal iron
#

lol but wtf

ancient nova
#

Cannot read properties of undefined (reading 'member')

quartz kindle
#

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

ancient nova
#

I tried owner.user as well

#

I'm not aware of the API changes after discord.js 10 pretty sure

#

and it did exist

quartz kindle
#

guild.owner was removed

#

owner.member never existed

#

owner is already a member

boreal iron
#

Which he can fetch

quartz kindle
#

there is guild.fetchOwner()

boreal iron
#

Ow nvm then

boreal iron
#

To prevent running into the same issues over and over again

ancient nova
#

how do you fetch the guilds region though?

#

I tried using message.guild.region but it returned undefined

quartz kindle
#

regions were removed from guilds and put on voice channels

#

because each voice channel can be in a different region now

ancient nova
#

I see well that's a big surprise

ancient nova
#

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?

pale vessel
#

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

robust crown
#

Hello i have this but idk what to put on the /dblwebhook and tggpassword pls help xD

dim solar
#

pls help me out

inland oracle
#
#

should fix the problem

sharp saddle
wooden gorge
sharp saddle
#

there's no way I can set this to something, like JS?

wooden gorge
#

You can enter the file by typing #replit.nix at the end of the url

sharp saddle
#

or show configs on that 3 dots

quartz kindle
#
(client as any).commands = ...
(client as Record<string, any>).clients = ...
wheat mesa
#

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

quartz kindle
#

or extend it ```js
class MyClient extends Discord.Client {
commands = new Discord.Collection()
}

const client = new MyClient()

wheat mesa
#

(Unless djs doesn’t allow that somehow)

#

Yeah that too

sharp saddle
#

ok, i'll try

#

wait a second

sharp saddle
#

i'll try Tim method

celest gate
dry imp
#

js is actually pretty fun

#

more or less like py

vivid fulcrum
#

until you install an x package that depends on y that depends on z

#

and the z package is malware mmLol

dry imp
#

im used to malware

pale vessel
#

node-ipc my beloved

lament rock
split hazel
quartz kindle
#

most likely

simple stump
#

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.");
});
celest gate
#

i can't install discord.js

split hazel
#

keep cancelling and trying until it works

#

also try using a different terminal

#

think it has something to do with bad Internet

celest gate
#

it working now ig

quartz kindle
#

140627ms lol

#

npm is just shit sometimes

carmine magnet
#

Always for me pepsive

lament rock
#

npm works great for me all the time

#

but I do have gigabit internet and a decent cpu to process tars

spark flint
#

how can i get the interaction user's voice channel with djs

austere surge
#

probably interaction.member.voice.channel

spark flint
#

yep that worked yay

austere surge
#

might be thinking of something else

#

nice

boreal iron
#

Optional chaining makes sense here

#

Member isn’t available for each interaction

#

interaction?.member…

#

Might also be the case for the voice property

spark flint
#

its only for slash command interactions

#

my handler manages that

boreal iron
#

When running it in a DM channel it will cause an error when trying to detect a voice channel

ancient nova
#

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

split hazel
#

probably easier this way

ancient nova
split hazel
#

yeah you did it completely wrong

#

just a sec

#

mentions are a bit more complicated since they differ on mobile and desktop

ancient nova
#

do you know how I can fix that?

boreal iron
#

User mentions now have the following format <@USER_ID>

split hazel
#

is this standardised across all clients?

#

i saw some have <@! and some have just <@

boreal iron
#

@! was the structure for nicknames

#

That’s deprecated now

#

According to the docs

ancient nova
#

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

boreal iron
#

The split between profile names and nicknames was stupid anyways

#

That’s why discord got rid of it

ancient nova
boreal iron
#

If you haven’t found the prefix you automatically assume the mention has been used as prefix without checking for it

ancient nova
#

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

boreal iron
#

Make sure to check either the prefix has been used OR the mention

ancient nova
split hazel
#

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

boreal iron
#

that (!prefix) return; will never happen

ancient nova
#

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

split hazel
#

removing that would need a code refactor tho

#

those if statements at the end wouldnt really be needed anymore

boreal iron
ancient nova
#

I mean you could look at the code I showed in the screenshot and compare to what I'm trying to achieve

split hazel
boreal iron
#

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

ancient nova
#

??????

#

was that the error I made in my code???

#

no way

split hazel
#

pretty sure both will work

ancient nova
#

oh

#

that got my hopes up

#

well

boreal iron
#

Nah id doesn’t exist as property on the base client

boreal iron
#

It’s the user id

#

Well he just tries to give an idea how it should look like

ancient nova
#

so which one should I use?

ancient nova
boreal iron
#

Well you gotta be patient

#

Taking a shower now

#

Without smartphone freerealestate

split hazel
ancient nova
earnest phoenix
#

What is the average time to add robots?

ancient nova
#

@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

quartz kindle
#

show an example because idk what you mean

ancient nova
#

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

quartz kindle
#

either make a list yourself or you can use the Intl api

ancient nova
#

a list? you mean like every single number?

quartz kindle
#

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"

ancient nova
#

there an endswith function

#

I know there is a startsWith function

quartz kindle
#

yes there is

ancient nova
#

is this gonna work?

#

this is just an example I'm obviously not gonna make it look this bad

quartz kindle
#

if number is a string yes

#

since endswith and startswith are string methods

#

that end there is not valid js tho

ancient nova
#

now that I think about it it's not gonna work

#

it's not 11st but 11th

quartz kindle
#

11 and 12 are exceptions

#

so you need to make a separate rule for them

ancient nova
#

nesting more statements is gonna make it look slightly ugly

quartz kindle
#

nah

ancient nova
#

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

quartz kindle
#

heres an example of how someone else did it

craggy pine
#

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

ancient nova
#

well they're way smarted than me lol

quartz kindle
#

afaik 11 12 13 are the only exceptions

craggy pine
#

Think thats the function i use

quartz kindle
#

but they also apply to bigger numbers

ancient nova
#

how am I supposed to get an = with that weird / in the middle

quartz kindle
#

for examole 113 or 1013 also apply the 13 exception

quartz kindle
#

its just a !==

ancient nova
#

oh I see

twilit hawk
#

fonts like fira code have ligatures

ancient nova
#

does this look good?

ancient nova
#

too confusing

quartz kindle
#

try to be more descriptive

ancient nova
ancient nova
quartz kindle
#

i told you it only works on strings

#

did you not convert the number to string?

ancient nova
#

oh I thought that variable was automatically a string

ancient nova
ancient nova
quartz kindle
ancient nova
#

works great Thumbglass

ancient nova
quartz kindle
#

i personally dont like the key set way

ancient nova
#

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?

earnest phoenix
#

Show your code

spark flint
#

how can i send long strings in js

#
message.channel.send(`\`\`\`ansi\n
         ____  _            _    _ _     _            
        | __ )| | __ _  ___| | _| (_)___| |_ ___ _ __ 
        |  _ \| |/ _` |/ __| |/ / | / __| __/ _ \ '__|
        | |_) | | (_| | (__|   <| | \__ \ ||  __/ |   
        |____/|_|\__,_|\___|_|\_\_|_|___/\__\___|_|   
       \`\`\``)```
#

doesn't work

split hazel
#

you also need to make sure to backslash ` that are inside the string

#

and it's not 3 it's just 1

spark flint
#

yeah i'm doing it on purpose

#
thats how you do this```
split hazel
#

right in the middle

earnest phoenix
#

Declaring it as a constant outside of a hot path will mostly be a micro optimization

tribal crow
#

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?

earnest phoenix
#

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

split hazel
#

not good enough

boreal iron
#

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

earnest phoenix
#

The base command?

boreal iron
#

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

tardy wind
#

How to put emoji in the selection menu?? please someone help me 😭

#

I don't know anything about programming

worn anvil
tardy wind
worn anvil
#

Option icon accept emoji like this 😄
Or topggWink

#

To add custom emoji
Use this format: !topggWink

tardy wind
worn anvil
#

Oh you using a bot
I can't help then check their documentations

tardy wind
#

I'm Bot Slash

glossy oasis
# tardy wind

just make 2 different options, 1 for the role, one for the emoji.

#

You cant put a string inside the role option

ancient nova
#

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

pale vessel
#

did you await your promises inside the try block?

ancient nova
#

is member.send a promise?

quartz kindle
lament rock
#

callback hell time

ancient nova
#

how do I get the name of the owner? fetchOwner() didn't work either

earnest phoenix
ancient nova
earnest phoenix
#

I literally just said that the method returns a promise, you must resolve it first before accessing it's properties

lament rock
#

I Promise I don't suck at code

#

feel free to reject that

earnest phoenix
pale vessel
robust crown
#

Hello i have this but idk what to put on the /dblwebhook and tggpassword pls help xD

earnest phoenix
robust crown
#

oh

#

in here what?

earnest phoenix
#

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

robust crown
robust crown
earnest phoenix
robust crown
#

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

earnest phoenix
#

Yes

robust crown
#

Ok imma try Thank you VGsmile

lament rock
robust crown
earnest phoenix
#

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

robust crown
#

oh

earnest phoenix
#

.dbl_webhook("/dblwebhook", "Your webhook password goes here")

robust crown
#

but thats what i put here

quartz kindle
#

you have to pass it as a string, not as a variable

earnest phoenix
#

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"

robust crown
#

oops ye ye

#

my bad

robust crown
#

Not working not a single error msg

#

ive treid changing the ip still not

quartz kindle
robust crown
#

yes

#

current code

quartz kindle
#

where's bot.topgg_webhook.run()

robust crown
#

oh

quartz kindle
robust crown
#

kk sorry

robust crown
#

i mean its disabled

quartz kindle
#

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

robust crown
#

http://<ipv4>:3400/dblwebhook like this oh

quartz kindle
#

yes

robust crown
quartz kindle
#

lol the python-sdk for top.gg has completely different things in their github examples and their documentation examples

robust crown
#

ye

robust crown
quartz kindle
#

ye

robust crown
#

ye xD

quaint rampart
#

how can i install icons as an svg from fontawesome?

robust crown
quartz kindle
#

yeah try that

quartz kindle
quaint rampart
#

nvm i didnt realize there was a download button

quartz kindle
#

lel

robust crown
quartz kindle
#

👍

robust crown
quartz kindle
#

weird

robust crown
quartz kindle
#

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

robust crown
#

k

robust crown
#

works good thank you

marble juniper
#

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

sharp geyser
#

I honestly think it is just there to be there

marble juniper
#

Unless bot.fetch_user doesn't check the cache

#

Lol

sharp geyser
#

Probably doesnt

#

this is dpy right?

marble juniper
#

Yeah

sharp geyser
#

They dont prepare that much

marble juniper
#

I think so

sharp geyser
marble juniper
#

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

sharp geyser
#

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)
marble juniper
#

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

sharp geyser
#

Cause they don't prepare that far ahead

marble juniper
#

Why not

sharp geyser
#

Cause they are python devs

#

dont expect too much

marble juniper
#

lol

#

So ur telling me python devs aint smart

sharp geyser
#

We are meming but there is probably a valid reason why they haven't

sharp geyser
#

there are a handful that are

#

like daff and sky

#

they actually use their brains and not bang rocks against their heads

marble juniper
sharp geyser
#

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

marble juniper
compact briar
#

is there a way to allow line breaks inside of an interaction option as you can not space down with shift/enter?

sharp geyser
#

As far as I know there is no way to do so

marble juniper
#

No there isn't

compact briar
#

well that sucks. thanks for the answers

slender thistle
#

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)

slender thistle
#

Maybe \n could work, so that users would use that for a linebreak

marble juniper
#

true

#

Or just discord adds multi line support to string interaction options to desktop for once

slender thistle
#

It's Discord

#

I have no high hopes

marble juniper
#

Its already on mobile they are just being lazy

#

the inconsitencies never stop

slender thistle
#

No, they're consistent

#

Consistently inconsistent

compact briar
slender thistle
#

Yes

#

And you replace that with characters for newline so that it becomes a newline

compact briar
#

yeah theres no chance i can even get people to use \n correctly. i get multiple dms a week because someone couldnt read correctly.

slender thistle
#

Could always try

compact briar
#

if only we could have kept message commands. was a much more simple time lmao

slender thistle
#

Ikr

boreal iron
#

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

copper cradle
#

Zamn

deep prairie
#

how do i make my bot come online in my server?

boreal iron
#

You invite your bot, then start the application

deep prairie
#

i think i didnt do that

#

how do i invite my bot to my server then start the application

boreal iron
#

The developer portal of Discord has an URL generator

#

Select your app -> OAuth2 -> Select the scopes and permissions

deep prairie
#

do i click new application

boreal iron
#

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

deep prairie
#

what do i click

boreal iron
#

You select the scope of the application

#

For example bot and/or app.commands

vivid fulcrum
#

ah yes webpacked code noob code

deep prairie
#

which one should i select

boreal iron
#

depends on what you sort of app you wanna create

deep prairie
#

i invited my bot to my server

boreal iron
#

a bot connected to the gateway will require the bot scope

#

if you wanna create application commands, too, then both are required

deep prairie
#

so how do i create it

boreal iron
#

By coding it?!

deep prairie
#

how do i code it

boreal iron
#

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

deep prairie
#

how do i create the gateway

vivid fulcrum
#

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

boreal iron
#

huh cry still alive okeh

deep prairie
#

my bot is still offline

vivid fulcrum
#

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

deep prairie
#

what should i click

vivid fulcrum
#

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

vivid fulcrum
#

google the programming language you're most familiar with and add "discord library" to that

deep prairie
#

what should i type in google

deep prairie
#

what do i click after i open that link

boreal iron
#

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

deep prairie
#

what do i click

vivid fulcrum
#

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

deep prairie
#

can someone help me code my bot

spark flint
#

watch a youtube video or something, we're not going to spoonfeed code

deep prairie
#

can someone find me a video

boreal iron
#

You should try doing something on your own

deep prairie
#

like what

boreal iron
#

In that case finding a guide, video, tutorial whatever if you want to view/watch one

deep prairie
#

what can i type in google

spark flint
#

https://youtube.com and search "how to make a discord bot"

boreal iron
#

If there's no programming language you're familiar with you should not start with a bot

spark flint
#

^^^^^^^^^^^^^^^

vivid fulcrum
#

"can someone find me a video"

#

😭

#

newbies get more and more lazy every year i swear

boreal iron
hybrid cargo
#

Nice pong

boreal iron
#

you saw nothing

hybrid cargo
#

Who tf changed my name to visino

#

MACCC!!!

spark flint
#

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

deep prairie
#

i just coded my bot but it still wont come online

vivid fulcrum
#

this is actually starting to look good

#

but again

#

memory

#

god i hate electron

#

but making apps with web technology is so nice

boreal iron
#

yeah doesn't look bad tbh

deep prairie
#

did ya see my message

vivid fulcrum
#

i'm not happy with the memory usage at all

#

300mb and i don't do any background activity yet

boreal iron
#

yet

vivid fulcrum
#

yeah

#

i'm going to implement database polling

deep prairie
#

my bot wont come online after i have coded it

vivid fulcrum
#

you have to actually run your code

deep prairie
#

i did

boreal iron
#

Well

vivid fulcrum
#

learn js

#

this is what we've been telling you

boreal iron
#

Those red lines are indicating your issues

deep prairie
#

how do i fix it then

vivid fulcrum
#

you have to know at least the basics of your programming language before you make a discord bot

boreal iron
#

case sensitivity is important

quartz kindle
#

there is no such thing as Const with an uppercase C

#

thats not valid javascript

deep prairie
#

what should i do then

quartz kindle
#

dude

boreal iron
#

look at line 2

#

See the difference

deep prairie
#

ya

#

how do i fix it

quartz kindle
#

what part of "coding is case sensitive" you dont understand?

hybrid cargo
deep prairie
#

what should i type on google

quartz kindle
#

LOL

hybrid cargo
#

Bro at this point this just looks like you are trolling

quartz kindle
#

yeah im out

boreal iron
#

You google what you want find

deep prairie
#

how am i trolling

#

ok i give up then

boreal iron
#

I wonder he didn't ask how to get to google

quartz kindle
deep prairie
#

no

hybrid cargo
quartz kindle
#

"case" means uppercase or lowercase letters

#

for example "A" is uppercase, "a" is lowercase

deep prairie
#

kk

quartz kindle
#

case sensitive means that uppercase and lowercase letters have different meanings in code

deep prairie
#

oh

quartz kindle
#

you cannot freely use one or the other

deep prairie
#

what do i need to do

quartz kindle
#

as i explained, Const with an uppercase C is not valid code

deep prairie
#

should i make it lowercase

quartz kindle
#

yes

deep prairie
#

now it says Unexpected token

quartz kindle
#

and here, this is not the same word, these are two different words, so logically it will not work

boreal iron
#

Also remove the unnecessary spaces anywhere

quartz kindle
#

because the case is different

boreal iron
#

They aren't valid, too

deep prairie
boreal iron
#

L14

vivid fulcrum
#

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...

quartz kindle
#

and this is also invalid code

#

and this is also invalid code

boreal iron
#

Tim warming up

deep prairie
#

so should i delete it

spark flint
#

why does this happen

quartz kindle
#

yeah delete your entire file, and start from scratch, but this time learn some basics, follow guides, read documentations, etc

boreal iron
#

I'm sure that code block looks funny on mobile

deep prairie
#

but i follow what youtube says

quartz kindle
#

no you dont

#

i doubt youtube said to use those invalid codes

spark flint
#

yeah its fucked on mobile, but it looks nice on pc so

deep prairie
#

oh

quartz kindle
#

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

spark flint
#

idk why js is fucking it up

quartz kindle
#

second, pay attention to the video, you are not doing it like the video shows

deep prairie
#

yea i am

quartz kindle
#

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

deep prairie
#

ugh i give up then

quartz kindle
#

what video are you following?

deep prairie
#

unless someone can zoom me and i share my screen then someone can control my screen and show me

#

this

quartz kindle
#

your code

#

there are a lot of things you did wrong

#

thats why i said, pay attention

deep prairie
#

who has zoom

quartz kindle
#

the video is literally showing you, and you are copying it wrong lol

boreal iron
#

wut

deep prairie
#

can someone zoom me and show me

quartz kindle
#

no

deep prairie
#

why

quartz kindle
#

nobody is gonna do it for you

boreal iron
#

because you wont learn anything is somebody else is doing stuff for you

quartz kindle
#

unless you pay them

boreal iron
#

:P

deep prairie
#

i tried myself and idk how

boreal iron
#

and there we go, back to the capitalism

quartz kindle
#

you literally copied wrong lol

deep prairie
#

i just give up then

quartz kindle
#

just go back to the video, watch it again, and copy it right

#

what is so hard about that?

deep prairie
#

never mind then

quartz kindle
#

ok then

boreal iron
#

Try that

#

Even easier for you to copy and paste stuff without understanding what it does

still storm
#

Kek

slender thistle
dry imp
#

just use python problem solved

boreal iron
#

go on sir

slender thistle
#

No plz we don't claim such people

boreal iron
#

take your snakes with you

dry imp
#

ok php guy

slender thistle
#

ok driving while texting guy

boreal iron
#

sheeshh

slender thistle
#

sheeesh

quartz kindle
#

sheeeeeeeeeeesh

deep prairie
#

ok

royal portal
#

do you have to use next in an Express route for error handling?!?!1

split hazel
#

before he learns programming he needs to learn to copy first

royal portal
#

learn how to bing angeryBOYE

lament rock
#

duck duck go

royal portal
#

duck duck stop

vivid fulcrum
#

my brain is fried

wheat mesa
#

Lol

ancient nova
#

why does ownerName keeps giving me an error?

boreal iron
#

if you wanna do it that way, then it should be (await guild.fetchOwner()).user.tag

#

if I'm not wrong

ancient nova
#

at this point I'd rather not

wheat mesa
sick agate
earnest phoenix
sharp geyser
#

or you could do what fake said

earnest phoenix
#

Yep

sharp geyser
#

if you only need the owner name and nothing else then do what fake said

earnest phoenix
sharp geyser
#

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

earnest phoenix
#

Yea you are right

ancient nova
#

so can't do it any other way

sharp geyser
#

that is why you get the tag from the user

ancient nova
#

but you can't get the user unless u fetch the owner

#

bt the way @sharp geyser can you test my bot out pls

#

I need feedback

sharp geyser
#

no

ancient nova
#

why not

sharp geyser
#

Don't feel like it

ancient nova
#

you are heartless

sharp geyser
#

ik

ancient nova
#

it'll take you 5 min

sharp geyser
#

No means no stop pinging me for it

boreal iron
#

what's his issue actually?

sharp geyser
#

He can't get the owner's tag ig

#

even tho you told em how

boreal iron
#

huh

sharp geyser
#

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

earnest phoenix
earnest phoenix
sharp geyser
#

huh

earnest phoenix
stoic eagle
#

What should I use in place of interaction.user.hasPermission()

boreal iron
#

users don't have permissions

#

members have

stoic eagle
#

hmm

sharp geyser
#

interaction.member is a thing last I recall

stoic eagle
#

interaction.member.hasPermission()

#

What should I use in place of this

#

Coz its deprecated

boreal iron
#

ofc only if the command has been used in a guild

stoic eagle
#

Yep

boreal iron
#

member.permissions.has(...)

stoic eagle
#

What should I use in place of this

#

ok

sharp geyser
#

But then you can just check the channel type and ignore the permission thing

stoic eagle
#

But it doesn't worked

earnest phoenix
#

Then show your code maybe?

vivid fulcrum
#

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

#

😭

proven lantern
#

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.

fathom sonnet
#

hii guys, so i creating my bot from scratch with slash commands integrated, and i got this err. Can someone explain me why

hidden gorge
#

i can’t figure out how to fix this

fathom sonnet
split hazel
fathom sonnet
#

your sql version is outdated

split hazel
#

its caused by a sudden node.js update

hidden gorge
fathom sonnet
#

amm i would sugest you to try lower version of node

#

like 16.15.0

#

18.0 is not yet stable

split hazel
# hidden gorge

good advice above but if you cant you can try uninstalling then reinstalling forcefully
npm uninstall better-sqlite3
npm install better-sqlite3 --force

split hazel
fathom sonnet
#

idk

#

deleted it

#

but same

#

maybe i put that acidently

sharp geyser
#

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)

fathom sonnet
#

cant use await without async

sharp geyser
#

You can keep the async function there just put a semi on the console log

fathom sonnet
#

ok deleted await

sharp geyser
fathom sonnet
#

yea that dosent work

#

same error

sharp geyser
#
    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

quartz kindle
sharp geyser
#

I also thought of just returning a new Message(client, theDataFromThePost) but that didn't end up working either

quartz kindle
sharp geyser
#
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')
quartz kindle
#

how do you define this.guild?

sharp geyser
#

this.guild = this.client.guilds.get(this.guildId);

quartz kindle
#

and is this.client and this.guildId defined before that?

sharp geyser
#

Indeed it is

quartz kindle
#

did you console.log the data from the post and check if your Message class is compatible with it?

sharp geyser
#

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

fathom sonnet
quartz kindle
#

use the one you already have

quartz kindle
sharp geyser
quartz kindle
#

in your specific situation they are

sharp geyser
fathom sonnet
#

ok progress

#

slash commands are regfistered

#

bit no respon from bot

quartz kindle
fathom sonnet
#

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

ancient nova
#

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

fathom sonnet
#

you want to make that if nsfw command is executed in no nsfw channel it returns alert?

sharp geyser
ancient nova
#

how do I check if the place I'm executing the command from is a server

fathom sonnet
#

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

ancient nova
#

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

sharp geyser
#

Check the channel type

ancient nova
#

how?

sharp geyser
#

Text Channels and DM Channels have a different type attached to the channel object

ancient nova
#

I know that. I have no idea how to access that

#

I'm not at all famliar with the disscord API

sharp geyser
#

By reading the docs and realizing there is a type prop on the channel object

ancient nova
#

message.channel.type === "guild"

sharp geyser
#

no

ancient nova
#

then show me how to properly do it

sharp geyser
#

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

ancient nova
#

THAT TELS ME NOTHING

#

I need the code part to understand

sharp geyser
#

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

split hazel
#

💀

sharp geyser
#

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

ancient nova
#

bro I just want a fucking example wdym you sent me a fucking webpage will channel types

vivid fulcrum
ancient nova
#

wtf am I supposed to do with that if I don't know how to check for the channel in the first place

sharp geyser
#

He was cry but he expects people to just hand him the answer

vivid fulcrum
ancient nova
#

he said that was wrong

split hazel
vivid fulcrum
#

it is

sharp geyser
#

It is wrong, but you were on the right track

vivid fulcrum
#

and i said you were on the right track

sharp geyser
#

You would compare something but not a string

vivid fulcrum
#

yes you would? 😭

sharp geyser
vivid fulcrum
#

it can't use anything else

fathom sonnet
#

i think thats why

sharp geyser
#

Mmm, but the channel types are integers no?

vivid fulcrum
#

true enum type only exists in typescript

#

no idea i haven't used the api in a long time

sharp geyser
dusk steppe
#
  if (message.channel.type == 'DM') {
// code
} else
  if ((message.channel.type == 'GUILD_TEXT') && (message.channel.nsfw)) {
// code
  }
vivid fulcrum
#

from the link you provided 💀

sharp geyser
#

Wtf

#

But that makes no sense 😔

vivid fulcrum
#

it does

#

djs is not a low level library

#

it's obviously going to translate enums to their string counterparts

sharp geyser
#

Mmm ig

vivid fulcrum
#

they know their userbase is fucking stupid

ancient nova
#

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);
sharp geyser
#

But won't discord cry back saying that type isn't an integer

vivid fulcrum
#

why would discord complain

#

the comparison is done in your code

fathom sonnet
#

found problem...it was fetch version

vivid fulcrum
#

and even then, djs translates the enum again internally if used in an api request

sharp geyser
#

Ah, okay then that makes sense

#

I didn't know they did that

ancient nova
#

what's wrong with the code?

vivid fulcrum
#

you tell us, it's your code

ancient nova
#

if it's a guild then fetch all otherwise filter

sharp geyser
#

Whenever it says Cannot read properties of undefined (reading 'x'), it typically means that whatever is before 'x' is undefined

vivid fulcrum
#

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

sharp geyser
#

Mmm, I myself just use enums directly

vivid fulcrum
#

this allows you to use strings without bothering yourself with numbers

ChannelTypes["GUILD_TEXT"] // 0
#

yeah same

sharp geyser
#

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

sharp geyser
#

Then have you figured out which part is returning undefined?

ancient nova
#

I have

sharp geyser
#

Thats cool but you aren't being very informative so I can't help

#

:)

wheat mesa
#

container.commands is undefined. We have no context for what that means because we don’t actually know what you’re doing here

sharp geyser
#

^

wheat mesa
#

The code you posted has technically very little to do with the error

ancient nova
#

container is a collection

wheat mesa
#

Then container.commands is undefined, I don’t know what to tell you

ancient nova
#

I know, it was undefined and I fixed it

sharp geyser
#

So error resolved?

wheat mesa
#

Then your code is working is it not?