#discord-bots

1 messages Β· Page 421 of 1

narrow hazel
#

so it resets the value when the bot resets

gritty inlet
#

Value of what

narrow hazel
#

the variables for the interactions I created

#

its determined on who presses the buttons and what channel they create

gritty inlet
#

Huh

narrow hazel
gritty inlet
#

Those are reinitiated on each interaction bru

narrow hazel
gritty inlet
#

Don't need a db

narrow hazel
#

doesnt the data get lost when the bot resets? without DB?

gritty inlet
#

uhh not sure you should use cog like that

gritty inlet
#

Persistent views* there's no such thing as a persistent button and that's some of the point

narrow hazel
#

yeah but the value is detemined by who presses it I cant just use like self.opener?

gritty inlet
#

There are dynamic items

gritty inlet
#

use the view = send a message with it

narrow hazel
#

I found this on github. Is this how it's supposed to be passing value to keep it?

gritty inlet
narrow hazel
#

nvm it's prefix

gritty inlet
#

?

#

Wdym

#

You got 2 options:

  1. Dynamic Items
    It's a component instance that is completely dynamic and does not "save" data, rather it gets the data from the component's custom id

  2. Persistent views:
    The view instance can "save" things for as long as it's active, allowing you to not have to use the custom id of its components for accessing the data

Persistent views are meant to be able to work after restarts but they depend on you giving the view instances the right data.

Dynamic items will always work as they depend on the custom id

narrow hazel
#

so is dynmaic items what im looking to do or does either work based on how im handling the class methods?

gritty inlet
narrow hazel
#

yeah but waht I wanna eventually achieve is getting the values back after the bot resets. Currently im just setting it to none and you said using cogs is a different method than whats normal

gritty inlet
#

Then you should probably use dynamic items

narrow hazel
#

ok thanks

gritty inlet
narrow hazel
#

Thanks i'll try it tomorrow. I spent too long coding today lol

gritty inlet
burnt quiver
#

it's optional, not nullable

gritty inlet
#

What does optional mean in this context

burnt quiver
#

i believe

data: dict[str, Any] = {}
data['key'] # Raises KeyError if optional else returns None if it is nullable
#

basically

#

!d typing.NotRequired

unkempt canyonBOT
#

typing.NotRequired```
Special typing construct to mark a [`TypedDict`](https://docs.python.org/3/library/typing.html#typing.TypedDict) key as potentially missing.

See [`TypedDict`](https://docs.python.org/3/library/typing.html#typing.TypedDict) and [**PEP 655**](https://peps.python.org/pep-0655/) for more details.

Added in version 3.11.
burnt quiver
#

i think?

burnt quiver
#

yes

gritty inlet
#

isnt that the definition of nullable...

#

ah i see so optional is something that might not even be there

#

got it

earnest cloud
#

how to use docstring correctly?
i tried everything but it's still showing "no description given" like this:

?timeout

Timeout a member

:param member: The member to timeout
:param minutes: The number of minutes to timeout
:param reason: The reason for the timeout (optional)

Arguments:
  member  No description given
  minutes No description given
  reason  No description given (default: no reason)
woeful hill
#

You would need to use numpy style i believe

tropic kelp
gritty inlet
#

Theres many styles

woeful hill
#
"""Short desc

Long desc

Parameters
----------
a : int
    desc for a
b : str, optional
    desc for b
"""
gritty inlet
#
class Application:
    """
    An application object to handle webhook events for. Used in `start_listening`.

    ---
    Args:
        url_path (str):
            The URL path to the webhook endpoint you have specified on *your application's Developer Portal page -> 'Webhooks'*.

            For example, if your endpoint is *`https://quackbots.xyz/webhook1`*, then `url_path` should be *`/webhook1`* (it depends on your server/file configuration).
        verify_key (str):
            Your application's public key, used to verify Discord's request signature.
            You can find this on *your application's Developer Portal page -> 'General Information'*.
    """```

Example
#

You're not forced to use a specific style

#

This is an option, and yes it works with intellisense or whatever you want to call it

earnest cloud
tropic kelp
gritty inlet
#

I know of 3 different styles

#

But there isn't a specific one that "everyone and their mother use"

earnest cloud
#

oh wait

compact chasm
#

Hello again chat I'm once again in need of help

tropic kelp
compact chasm
#

I'm getting the error "In guild_id: Value "[]" is not snowflake." HOWEVER there is not a single "guild_id" in my code so now I'm extremely confused

earnest cloud
tropic kelp
gritty inlet
#

youre probably passing a positional arg somewhere

tropic kelp
#

*full

compact chasm
#

Uh yeah probably should've sent that from the start 😭

#

Is it fine if i screen shot

tropic kelp
compact chasm
#

I mean when i read the thing it said to use the topical helps and i need help with my bot isn't this the right place

tropic kelp
#

for smaller questions and stuff, yes, but for long topics a seperate thread is usually better (so people can talk about discorsd stuff here, but yopur specific questions are in a thread)

compact chasm
#

Oh I see I see thanks

woeful hill
#

That could be why it failed to parse

quick gust
woeful hill
#

You can also change the desc of the param to a new line instead of being in the same line (the parser probably think thats where you specify the type, so it failed to parse)
Like this

"""
:param member:
    The member
"""
timber dragon
#

discord.py's ext.commands only supports the numpy style fwiw

And app_commands support google, numpy and sphinx

woeful hill
#

My initial thought was that it only support numpy, now i know it also support more in app_commands

severe field
#

i believe you can even add types to your params like this:

"""Class to hold the parameters for fetching content from the API.

    :param list[str] | None tags: List of tags to filter posts 
    :param FileType | None file_type: File type filter 
    :param SortOrder | None sort_order: Sort order for posts 
    """
narrow hazel
#

I finally figured out how to find the number inside the count and add the value to the int

#

I was overthinking it the whole time

fast osprey
#

this will give you false positives on substrings

narrow hazel
#

its counting

#

My only goal is the match the int inside the message content so people could produce messages

fast osprey
#

target number is 3, I type 8532165 and your code will say it counts

narrow hazel
#

well I asked for help earlier and got insulted so im not gonna try anymore

fast osprey
#

suit yourself, odd to post code here with the explicit intent of not getting help on it though

young dagger
fast osprey
#

Depends if you want to allow for the number being between words. Regex would be the approach if you did

timber dragon
#

Also are you reading and writing to json on every message πŸ’€

fast osprey
#

I mean they've said they don't want help

timber dragon
#

I don't see where they got insulted
Unless asking for help and not getting the solution or people calling your current code bad is a personal insult to them

#

But it looks like they left the server, so, welp.

fast osprey
#

Rip

proper slate
#

Has anyone else made an animated discord bot? I want to see what others look like and how they managed it. Id like to compare notes and see what we did differently.

burnt quiver
#

what is an animated discord bot

proper slate
#

A discord bot with animated responses

#

I used GIFs that I render custom for commands and then cache. GIF counts as one message even if its 60 frames, so if you keep it under 8 mb you can send animations

#

@burnt quiver im not the best at always checking discord w/o notifications. Im happy to talk but you'll get my attention better if you tag me

burnt quiver
#

uh

#

not sure tbh

timber dragon
#

proceeds to not tag

static shale
#

Hello, I am a new coder and I want to program discord bots. I would appreciate tips and resources. Thank you.

dry kelp
#

Hellou

dry kelp
#

especially since you caching them, at a high usage if it's caching onto bot's memory that's bad, especially if tons of gifs.

dry kelp
#

@timber dragon I moved that panel onto URL operations for images, they work much more smooth than uploading.

timber dragon
#

Neat

proper slate
# dry kelp Do you have a proper TTL system?

It decays and then the eviction zone is the bottom of particle space. Eviction exists but everything is memmapped with OS paging and the physics state is saved so its gradual. This is a more prefetch and prebuild oriented approach. Instead of getting a LEGO brick 1 at a time, id rather get the whole set with instructions and bags and pieces organized.

#

Oh hold on. Let me link it

proper slate
#

Sorry I got a little confused what I was answering because its related

compact chasm
#

Hey so I had a question but I'm not sure if it deserves a thread so I'll ask it here

tropic kelp
#

ok, go ahead

compact chasm
#

Is it possible to attach a button to an embed that when clicked brings up a modal that sends another embed with the data provided, while also having a button that's identical to the previous embed

compact chasm
#

Yes

tropic kelp
#

iirc yes, idk how exactly you'd do that though, ask in #1035199133436354600 if you want to get a more specific answer than that though

compact chasm
#

I see alright

fast osprey
#

You don't attach buttons to embeds

#

Buttons can either be on the bottom of messages or in containers

compact chasm
proper slate
#

They're right tho

compact chasm
proper slate
#

Buttons under

fast osprey
#

The terminology matters because those two things are accomplished in different ways

proper slate
# compact chasm Would you mind sharing 😭

I have a view with a nav bar underneath and buttons under thst. I send an embed with an animated GIF and pressing the paging button underneath edits the message to have a different animated gif. It ends up looking like a loading screen and then a blinking cursor terminal interface like fallout.

#

Gets around discord rate limits for animations as well. Counts as one message even though its 60 frames

#

Just need to stay under 8 mb

compact chasm
#

That's cool but editing isn't exactly what I was going for

compact chasm
fast osprey
#

Underneath messages uses the "v1" components. You can have up to 5 rows of 5 buttons each

proper slate
#

Thats what I said

#

Dang. Dismissive

fast osprey
#

"V2" allows you to put buttons within a message using a more flexible layout. These can use containers, which look like embeds but are very importantly distinct from them. Containers can have arbitrary text, mediagalleries, and components (like buttons)

proper slate
#

Yeah i specifically said 5 buttons.

#

Thats wild. Good luck

compact chasm
fast osprey
#

Yes you can use either

compact chasm
#

Both?

fast osprey
#

You can't use both at the same time

compact chasm
#

No I meant as in both methods

fast osprey
#

Yeah both methods could be used to accomplish what you described

compact chasm
#

I have been just sending the view with my send_message which I'm assuming is the v1 here so I'm confused how I can use that

fast osprey
#

What have you tried and where are you stuck

compact chasm
#

So like I said I first made the modal which takes the info, then the view and the button, so now I just have no idea how to make the new embed sent by the modal have the same button to keep the chain going

fast osprey
#

It doesn't need the exact same button object

#

You can just send another view with a button that does whatever you want (even if that's the same thing)

compact chasm
#

...

#

Now that I think about it

#

You are absolutely right and I'm dumb as hell

#

I appreciate it 😭

dry kelp
#

they're so fun

dry kelp
#

@fast osprey there u go, since u said it's slow, it was due to the upload method of the images inside of the containers, which im now doing thru a public github repo, using url instead.

fast osprey
#

It's by definition going to be slower than the integration panel

#
  • user -> discord -> user
    vs
  • user -> discord -> your bot -> discord -> user
gritty inlet
#

I believe the integration menu is just easier to use

burnt quiver
#

The idea/code is there, but what solstice said is true, so I think you could implement this same idea but somewhere else where it's not possible or as easy through discord

dry kelp
fast osprey
#

the only people saying that are the people who hate change for no reason

#

it's a perfectly fine implementation

dry kelp
#

Yeah bro, u gotta follow the market tho man

#

it ain't like we can do anything about it

#

i ain't gonna make a public bot, with this insane structure, that only me and 2 friends use

#

u get me?

#

And i can assure people would rather use BOT'S SETTINGS rather than "discord integrations"

#

i've already discussed this yesterday, about interaction / prefix commands, discord been trying for years to remove prefix commands, can u guess why they won't remove them?

#

cause nobody finna use discord anymore, that's the truth man

fast osprey
#

...discord can't "remove" prefix commands

dry kelp
#

and neither try

fast osprey
#

they're messages. Discord isn't going to remove messages

gritty inlet
#

You don't gotta be anti innovation just because "you're following the market"

dry kelp
#

with they're "interaction commands"

dry kelp
#

We can't, and im not gonna sit here teaching people how to properly use discord.

#

in milions and milions of servers

gritty inlet
#

I will say though - many people don't know of these Discord implementations

dry kelp
#

i ain't making no info/knowledge bot

fast osprey
#

I'm taking it you're exclusively in brainrot roblox children servers who cannot understand extremely basic client functionality

dry kelp
#

Bot has it, built in, works easily.

fast osprey
#

because I do not see that behavior where I go

gritty inlet
dry kelp
#

And people i also dev for, different custom bots.

#

made 400$ early month

#

all these servers have over 200k members

#

and that's my target server, not a dev server composed by 50 bots and 30 actives, sorry.

fast osprey
#

It is your decision to design for the lowest common denominator and make it worse for everyone involved

gritty inlet
#

I think bot devs should refrain from still developing these things
Don't care about old bots. But if you're making a new bot, why stick to old things

dry kelp
#

But i ain't doing it.

gritty inlet
dry kelp
#

Containers are new, fully component setup, and whole bot will remain coded as component based.

dry kelp
#

Im remaking all of these features, also remastered, that's the key

#

with my own salt, if u know what i mean

fast osprey
#

Just because a person wants something that doesn't automatically mean a) it's good for them or b) you are absolved from any responsibility for providing it

#

incredibly small minded viewpoint

dry kelp
#

but once again, i ain't gonna make a bot to teach people how to use cord, and neither tell me this, and shit that u can make thru discord integrations, cause respectfully, idgaf 🀣

gritty inlet
dry kelp
#

Neither Me, neither YOU have the right to decide for them, if they want it, they use it, they dont want it, they dont use it.

gritty inlet
#

πŸ’€

west escarp
#

!mute 404264989147529217

unkempt canyonBOT
#

failmail :ok_hand: applied timeout to @dry kelp until <t:1761422958:f> (1 hour).

fast osprey
#

was waiting for the personal attack to come out

west escarp
#

!unmute 404264989147529217

unkempt canyonBOT
#

failmail :ok_hand: pardoned infraction timeout for @dry kelp.

west escarp
#

No personal attacks, thanks.

west escarp
#

There are good reasons to use either application commands or text parsing

#

No need to flamewar over it

dry kelp
fast osprey
#

They have a history of personally attacking me

#

if you want to look through their message history

dry kelp
west escarp
#

Then don't engage with them

fast osprey
#

They do it in response to my answers to other people

west escarp
#

Okay, I'll be more explicit

#

@dry kelp please stop engaging with someone who clearly doesn't want to engage with you

dry kelp
west escarp
#

@fast osprey just because someone's not behaving well doesn't give you an excuse to do the same

#

Ping mods instead

dry kelp
#

You'll understand.

fast osprey
#

I fully recognize that, and I have endeavored to be cordial minus the one out-of-pocket comment you called out

fast osprey
#

which I apologize for

west escarp
#

Alright. This wasn't particularly bad so all I expect is change moving forwards

fast osprey
west escarp
dry kelp
west escarp
#

Consider it a competition on providing clear help. People will gravitate to helpful, easy to grasp answers. We don't limit problems to one answer or one interaction

#

Provide your point, and if they don't bite, they don't bite

dry kelp
#

@west escarp I never wanted to engage with this person, till the moment happened 2 days ago, randomly commenting of my code, poiniting it as being "bad" saying that there are no "reasons" why i should modify python pkgutil, which i proved him a reason of why we're doing this.

#

All visible reading chat history of this channel.

west escarp
#

Yes, and frankly that's just another instance of todays behavior. Neither of you look good there. "just let rottens rot" isn't something that would catch grace, and neither is "it's not a good reason I'm sure"

#

Both of you are overly abrasive and aggressive

dry kelp
#

That’s absolutely true, not saying that what i said its alright, but it was all after these replies coming from this person.

#

Which clearly wanted to engage with me, having 0 experience in the topic related.

west escarp
#

Then I expect both of you to cease needling the other, and if it resumes then I will start escalating

gritty inlet
#

Just acknowledge, now assuming they have no experience isn't a good thing to do

#

Anyway yurp have a good day

fast osprey
#

I would prefer to interact cordially, which involves not having my experience underminded or having slurs thrown at me

#

barring that I'm fine not interacting at all and people can choose which answers they prefer

dry kelp
#

Its not meant to be rude, its just that our brain is not AI, and we cant access that much data at once :)

fast osprey
#

and you are doubling down on undermining my experience

dry kelp
#

He shouldnt of had engaged saying what im doing is terrible from a docstring inside of an image. But i will respect the moderator decision, and fully ignore this person since its just not worth my time.

#

I already proved my points :)

leaden helm
#

does anyone know any service that solves hcaptcha? it seems like 2captcha or solvecaptcha.com no longer supports it

gleaming inlet
#

!rule illegal to help bypass captchas

unkempt canyonBOT
#

5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.

dry kelp
#

This channel is so dead

timber dragon
#

Good

vocal plover
# dry kelp This channel is so dead

It's not really supposed to be an active community channel, it's here mostly for getting help with Discord bots, and sometimes people don't need help.

faint basin
#
@commands.has_permissions(ban_members=True)
@commands.bot_has_permissions(ban_members=True)
async def ban (ctx, member: discord.Member, *, reason: str = ": Not specified "):
    try:
        if member.guild_permissions.administrator:
            a = discord.Embed(description="User has administrator permissions. ", color=0x0001)
            await ctx.send(embed=a)
        else:
                a1 = discord.Embed(description=f"**{member}** was banned by **{ctx.author}**!", color=0x0001)
                a1.add_field(name="Reason: ", value=reason, inline=False)
                a1.set_footer(text=f"ID: {member.id} : ")
                try:
                    await member.send(f"You were banned by {ctx.author} from **{ctx.guild.name}**!", embed=a1)
                except:
                    pass
                
        await member.ban(reason=reason)
        await ctx.send(embed=a1)
    except Exception as e:
        await ctx.send(f"An error occured: {e} ") ```
#

rate my code

woeful hill
#

Worse than built in

burnt quiver
#

No role hierarchy check πŸ˜”

faint basin
#

πŸ˜…

faint basin
# burnt quiver No role hierarchy check πŸ˜”
@commands.has_permissions(ban_members=True)
@commands.bot_has_permissions(ban_members=True)
async def ban (ctx, member: discord.Member, *, reason: str = ": Not specified"):
    try:
            if member.top_role >= ctx.guild.me.top_role:
                await ctx.send("An error occurred while trying to ban the user. Make sure my role is above the role of the user you want to ban.")
                return
                
            elif member == ctx.guild.owner:
                await ctx.send("you cannot ban the server owner!")
                return
        
            elif member == ctx.author:
                await ctx.send("you cannot ban yourself! ")
                return
            
            elif ctx.author.top_role <= member.top_role:
                await ctx.send("you cannot ban someone with a higher or equal role!")
                return
            
            elif member.guild_permissions.administrator:
                a = discord.Embed(description="User has administrator permissions.", color=0x0001)
                await ctx.send(embed=a)
                return
                
            else:
                a1 = discord.Embed(description=f"**{member}** was banned by **{ctx.author}**!", color=0x0001)
                a1.add_field(name="Reason: ", value=reason, inline=True)
                a1.set_footer(text=f"ID: {member.id} : ")
                try:
                    await member.send(f"You were banned by {ctx.author} from **{ctx.guild.name}**!", embed=a1)
                except:
                    pass
                
                await member.ban(reason=reason)
                await ctx.send(embed=a1)
    
    except Exception as e:
        await ctx.send(f"An error occurred: {e} ") ```
woeful hill
faint basin
woeful hill
#

By using the built in system

faint basin
#

🏝️

timber dragon
#

Why is everything wrapped into a try-except

#

Why are you checking for admin perms specifically

#

The role check takes care of that

finite salmon
dry kelp
#

With no experience they cant make a good prompt

dry kelp
faint basin
#

idk

dry kelp
#

How are you doing something you dont know ducky_concerned

faint basin
#

we can name variables anything we want

dry kelp
#

then why dont we all name our variables pickle1 = 1

#

pickle2 = 2

faint basin
#

i couldn't think of a name so named it a,a1

dry kelp
#

its not wrong, but when you code you expect common sense

faint basin
dry kelp
#

i think thats what most people do

faint basin
#

yes

dry kelp
#

But i can also see lies, and because AI doesn’t inform you properly, that variable is assigned under a function, you can assign same variable under a different function.

#

And i do believe you tough u needed different variable names everywhere into your file

faint basin
#

o

dry kelp
#

I can also see you are building prefix commands, most people modify the baseclass of bot using a updated ctx

#

building ctx.error / warning / approve

faint basin
#

ty twin i didn't coded that much like I saw a yt video and tried making a bot

dry kelp
#

already built in embeds

#

you might wanna try doing that

faint basin
#

alr

dry kelp
#

so u only create in your code the final response embed

#

and that administrator check can be counted as a validation, just by checking if target has administrator permission

finite salmon
#

Why would you need admin perm to ban

fast osprey
finite salmon
#

Real

dry kelp
finite salmon
dry kelp
#

That's his code, not mine πŸ€·β€β™‚οΈ

#

Maybe he's building a private bot, and not a public bot.

#

And he wants to prevent admins from being banned thru bot, that's his choice.

faint basin
#

where can I learn this all

dry kelp
#

Oh man... firstly, i suggest you digging into learning python features.

faint basin
#

yes

dry kelp
#

Then learning how to properly setup your workshop.

#

Then you wanna look into different packages for your settings, i recommend Dynaconf

#

Then you wanna learn how to setup poetry, which is an amazing tool, loads all packages inside of a venv directly.

#

Can also hold different typing rules...

faint basin
#

oh

dry kelp
#

Then you wanna learn how to use docker, which is a most common tool across developers

dry kelp
#

Then you wanna dig into how to establish a connection with database (avoid using raw SQL), use a ORM (sqlalchemy)

#

Avoid using files such as config.py or any .json files for bot's settings, focus on using .toml files for settings, and an actual proper .env for configuration, e.g bot token, database credentials etc.

#

Once you have knowledge in those, your workshop will eventually look better.

faint basin
#

oh

#

tysm for the advice

dry kelp
#

No problem man, there are also other packages you could use, im just saying these because it's what i work with, and they're absolutely amazing.

fast osprey
#

There's absolutely nothing wrong with raw sql

#

And in fact it can be more performant than ORMs in many cases

dry kelp
#

Didn't that admin say to stop engaging with me? Perhaps i never said it's bad, i said avoid, since they're a begginer, it has a better performance than ORM, but imagine besides all mentioned above, he starts learning sql too, something that can be avoided.

fast osprey
#

Not engaging you doesn't mean you get to express an opinion in response to someone else first and I am forced to let misleading statements stand. This isn't a race to comment

dry kelp
#

Bro i swear to god, ill start again, and i wont feel bad

dry kelp
#

in a fucking discord bot

fast osprey
#

I gave my opinion and you gave yours, they can make their decision and that's it

dry kelp
#

tell me

#

validate your point

#

he is building a discord bot not a fucking nasa rocket

finite salmon
dry kelp
#

Before you trying to engage a conversation with me, look at the messages said, keyword "Avoid using raw SQL", you acted like i said raw sql is bad, when orms will do just fine, even when his bot is in 100k guilds, that traffic will still be handled.

dry kelp
#

Using an ORM is just fine for learning, and understanding code logic.

dry kelp
woeful hill
#

Read the last line

dry kelp
#

brave more specifically, cause i hate ads πŸ˜‚

woeful hill
#

And do you read, not like there are no opinions and everyone agree to something one sided

dry kelp
dry kelp
#

Are you even reading what i've told the man? Or you genuely blind, i can understand it from solstice, but you?

woeful hill
#

So i cant have my opinion on things

dry kelp
#

You can, but he was engaging with me, we all know ORM will work better for a beginner πŸ€·β€β™‚οΈ

#

And performance comment is true, but uneccesary, since it will handle traffic over 100k guilds.

#

and to achieve 100k guilds up-to-day you need some crazy shit to be able to compete with current market πŸ€·β€β™‚οΈ

woeful hill
#

Then let the man decide, there are no downside of trying viable approach

dry kelp
woeful hill
#

Yes

dry kelp
#

🀣 🀣 🀣 🀣

#

you funny

woeful hill
#

I havent learned to use orm once in my life

I started by making raw sql and it just more fascinating to see how each keyword works

dry kelp
#

Then you cannot even engage in this conversation, if you don't have experience in both.

#

Since you're trying to evaluate 2 things, while only having experience in 1, it doesn't work like that.

woeful hill
#

you are not a president so you cant vote for president

dry kelp
#

To make an evaluation you must know both arguments cons / pros.

#

That's the truth, how would you compare 2 arguments while having experience in 1, do you even think?

#

Ohhh, i get it, you're like these AI rats, that all they're information comes from AI!

#

Trying to compare something you have 0 experience in, thats just crazy

#

πŸ˜‚πŸ˜‚πŸ˜‚πŸ˜‚

woeful hill
#

Have i used any comparision about sql and orm

dry kelp
#

try an orm your own, then we can resume this discussion , until then i wish you best luck into your things

woeful hill
#

πŸ€” because i think not

dry kelp
#

Once you can validate your own points, based on your own experience, thats when we will resume this topic.

woeful hill
#

Where is the part that i point out it is better

#

I said they are "viable" approaches

dry kelp
#

its not my business to buy you glasses to see your messages and ours in order to understand this topic discussion.

proper slate
#

Can someone please respectfully explain the debate going on here to me?

burnt quiver
#

Kinda Raw SQL vs ORM ig

gritty inlet
#

I preferred an ORM solely because I find it easier to use objects and functions in a traditional Python way

scarlet tiger
dry kelp
dry kelp
burnt quiver
#

Yes that makes sense 100%, but you told them to avoid using raw SQL, which might make them think it's bad which it isn't

so the wording here might have caused this confusion and all

dry kelp
#

Avoid doesn't mean it's bad, it's just so they would focus on an ORM usage for now, since it might suit them a lot better.

burnt quiver
#

i meaaannn

#

when someone tells me to avoid doing something, I would have a mindset that it's bad, but ig it's subjective

scarlet tiger
burnt quiver
# dry kelp

im not gonna play this word definition thingy, i just said to me it seems like something is bad if someone tells u to avoid it, and i already said it's subjective

dry kelp
fast osprey
gritty inlet
#

Personally I'd say "I recommend using y" instead of "avoid using x"

dry kelp
#

Partially right there

gritty inlet
#

ORMs isn't what you should be looking for if you want to truly understand how databases work, yes

dry kelp
#

But full control logic is out of context.

dry kelp
#

@scarlet tiger

scarlet tiger
# dry kelp Do not rely on AI for your answers, you didn't have to say you have "experience"...

For a beginner, starting with an ORM isn’t really recommended β€” they should learn SQL first. That was my point, ORMs are great (as long as you understand how SQL works), but as I said before, for someone still learning SQL... they’re not really recommended yet...
Using an ORM or not is personal, but if you want to really help new developers, don’t just give them the β€œeasy path.” ducky_concerned

dry kelp
gritty inlet
#

I don't exactly get that point; Would you also say it's better to first do raw http requests with the Discord API before using a library?
Maybe I'm wrong but Idk much about databases, so I can't tell what are the cons of not learning raw sql first

scarlet tiger
dry kelp
fast osprey
#

You're writing well they're just trying to undermine you

dry kelp
#

only AI could spew bullshit like that

gritty inlet
#

Eh

proper slate
burnt quiver
#

so using a lib can be easier

dry kelp
#

"it gives full control" Something ANY mature ORM does already, Prisma, SQLalchemy

#

i don't want to engage with people that use AI for they're responses.

proper slate
# dry kelp have you read this?

Yes. I have. Which is why i am disagreeing with you. Have you read it? Because you can. Now you write something in Spanish we all can read please

scarlet tiger
dry kelp
gritty inlet
burnt quiver
#

i mean yeah? but because you're not 'wrapping' the same thing, you can't really compare it like that

dry kelp
burnt quiver
#

not*

gritty inlet
#

Yeah hey I'm not calling anything "better", sorry if it sounds like that

proper slate
#

Im gonna leave i dont like getting heated and sormtimes i misunderstand. Your English is good man @scarlet tiger

gritty inlet
#

Have a good one

proper slate
#

Keep it up

dry kelp
#

@gritty inlet You doing good, some people think discord bots are nasa rockets, and they want operations to fly out like pigs.

gritty inlet
#

Don't take me under your wing though

#

Anyway meh each person should use what they prefer

scarlet tiger
#

Seriously, should someone just learning use an ORM without understanding SQL directly? That was my point.

dry kelp
#

You have 0 experience from the moment you said that bullshit with ai

scarlet tiger
#

Lol

dry kelp
#

"RAW SQL GIVES YOU FULL CONTROL"

#

something ANY mature ORM does already

scarlet tiger
velvet compass
#

@dry kelp if you cannot engage politely, do not engage. We expect people to help others without putting them down or assuming things about them.

#

Also, for ORMs, #databases is likely a more appropriate channel

dry kelp
velvet compass
#

Good, then the conversation can stop

dry kelp
#

i replied to his response, which makes 0 sense.

velvet compass
dry kelp
#

It's tiring repeating same thing 100 times

scarlet tiger
tight obsidian
#

let's drop it please

dry kelp
#

dude what? are you saying???

tight obsidian
#

(if anyone wants to politely discuss the tradeoffs involved in using or not using an ORM, let's move to #databases)

dry kelp
#

@scarlet tiger Stop misleading people, mature ORMs will give you full control same as Raw SQL, e.g SQLalchemy, Prisma.

vocal plover
# dry kelp It's tiring repeating same thing 100 times

My advice, genuinely you'll be much happier if you take time to realise that you don't need to take on the world and get involved with every conversation you disagree with. Sometimes people have vastly different views on how stuff should work, you're welcome to give input on ways you think would also work, but 9 times out of 10 in a space like this it doesn't benefit anyone to start arguing about them. People will figure out things over time, and if someone is giving really bad advice you can always take to @novel apex and the mods will figure it out, they're more likely to be listened to and don't have a personal attachment so they're not going to be making anyone upset

dry kelp
scarlet tiger
#

I'm still learning English and writing with proper spelling (as my teacher taught me), so am I an AI? Help. oldsalute

dry kelp
#

And he thinks this is english related, oh my god

vocal plover
#

I don't care if it's AI and I don't want to debate you nor anyone else on this, I want to say that if you drop it in cases like this you'll be happier, as will everyone else involved

tight obsidian
#

!mute @dry kelp You were told multiple times to drop this behaviour

unkempt canyonBOT
#

failmail :ok_hand: applied timeout to @dry kelp until <t:1761578899:f> (1 hour).

compact chasm
#

Okay so quick question how can I actually handle errors in a modal?

#

I tried using a good old try... except but that doesn't return anything while the modal still says "Something went wrong".

timber dragon
#

you need to actually respond to the interaction

#

but errors raised in the callback should be handled by overriding the on_error method in the class

compact chasm
compact chasm
#

So I'm a little confused about the syntax of Modal.on_error. How do I implement that 😭?

fast osprey
#

You'd implement the on_error method within your modal class. It accepts (self, interaction, error)

compact chasm
#

I opted not to make modals with the class because when I did that it just didn't work

#

I mean with the class as in you know class modal(yada yada)

fast osprey
#

You should, that's the recommended way

#

It's not that bad and I'm sure the troubles you were having can be pretty quickly resolved

compact chasm
#

I mean of course they can be resolved but like I just DON'T understand classes

#

Which leads to more problems elsewhere

fast osprey
#

That's something I'd strongly recommend you target given you are using an object oriented library in an object oriented language

compact chasm
#

😭

#

Hard to argue with that

fast osprey
#

Without the use of classes you'll find you have much worse problems with variable scoping and the like

toxic notch
#

how do i install discord.py in visual studio code? i already have python i only need the library

fast osprey
#

You install libraries into your python installation (or virtual environment) not vsc. The simplest way is to use your command line with <your python exe> -m pip install discord.py

#

On windows that should ideally be the py launcher

toxic notch
#

on command promt rigth?

gritty inlet
#

pip install discord.py stonks

#

Hey why the skull PensivePeach

toxic notch
#

im new to windows and vs code

#

i mostly code on my phone using google collabs

gritty inlet
#

What I'd do is add Python to PATH; Add Python to system variables; Then you can just do pip install x

toxic notch
#

how do u add py in sys?

gritty inlet
# toxic notch

Do the whole command at once, e.g. python3.14 -m pip install discord.py or whatever

gritty inlet
#

(Click on Path -> Click on edit)

toxic notch
gritty inlet
#

Then you're gonna want to make a New -> and add these 2:

  1. Your Python folder path, e.g. C:\Users\User\AppData\Local\Programs\Python\Python314\
  2. Your Python scripts path, e.g. C:\Users\User\AppData\Local\Programs\Python\Python314\Scripts\
gritty inlet
#

Btw all of this is considering you're not using a VENV. Cuz I got no idea how to manage Python in a Windows VENV.

fast osprey
gritty inlet
fast osprey
#

Or could just use py which was exactly created for this purpose to reduce confusion

gritty inlet
#

Whatever the user finds convenient. I'm just used to using the main name so I made it accordingly

toxic notch
#

yeah my laptop cooked

gritty inlet
#

I only use a VENV on my RPI

dry kelp
#

creates the venv for them, they can also mention desired python version.

#

@toxic notch look into poetry tool for python

#

and then in your IDE just select to use the venv created, which should appear as recommended

gritty inlet
#

I doubt they should mess around with allat before knowing how to even install it

#

Not to mention all commands including VENV ones are very simple, dunno why you need a helper.
But hey I never tried it so what do I know. Just sharing my point of view.

dry kelp
#

actually

#

its easier than installing all deps manually πŸ˜‚πŸ˜‚

#

and you can js set whatever python version u want

#

so i would say this is apart on how to setup workshop properly, thats something they could do

gritty inlet
#

I doubt it's much more than little help.

But hey I never tried it so what do I know. Just sharing my point of view.

dry kelp
#

@toxic notch look into poetry, will save your workshop

#

no debs will be installed locally on your computer, its all venv

#

so they wont conflict across projects

gritty inlet
#

Considering that's what they want..

#

I use a VENV on my RPI because I'm pretty much forced to

dry kelp
#

look how pretty it even is

gritty inlet
#

Overwork in its prime

dry kelp
#

How is it overwork tho?

toxic notch
#

I use vs code

dry kelp
#

it's so much easier

gritty inlet
#

xD

dry kelp
#

the overwork was the ruling part of the project, which is half visible

fast osprey
#

Venvs and dependency managers are well and good, they're not required though and folks should probably understand what they are and make an informed decision

toxic notch
#

Ama continue tmr

gritty inlet
dry kelp
#

https://python-poetry.org/docs/pyproject/ @toxic notch Save this, this is your start.

gritty inlet
#

etcetc

dry kelp
#

the overwork is worth it, cause i know my shit runs smooth as fuck

gritty inlet
dry kelp
#

bot is not chunked either, has my own TTL cache logic, which goes to redis cluster and pulled from redis

#

i can't rely on library chunking due to milion users, it would take bot minutes to connect after a restart

gritty inlet
#

So don't chunk at all

dry kelp
#

i am not chunking

gritty inlet
#

Exactly

dry kelp
#

i did mention, i have my own TTL

gritty inlet
#

Whatever makes yer happy

dry kelp
#

it makes me absolutely happy

gritty inlet
#

Holy moly I had to turn my strict typechecker off

dry kelp
gritty inlet
#

xD

dry kelp
#

__slots__ is also an amazing python feature

gritty inlet
#

I'll prob only turn strict on when I'm working on an actual lib, it's just annoying when doing personal code

burnt quiver
#

fr

dry kelp
#

my ruling is so strict

#

but 0 warnings looks hot for me

gritty inlet
#

I have 0 warnings on standard type checker

dry kelp
#

i use ruff smirkey

#

pylance too

gritty inlet
#

This block turned out to work very well

#

That's how it be when you're too lazy to migrate some buttons to a better system

dry kelp
#

πŸ’€

gritty inlet
#

ikr

#

(ill keep that)

#

shortest file i got lol

dry kelp
#

πŸ’€

gritty inlet
#

Ok THATS overwork brudda

dry kelp
gritty inlet
#

(:

#

In my personal codes I don't be putting effort into typing and docs.. But I cant shame those who do

dry kelp
#

πŸ’€

gritty inlet
#

brah

dry kelp
gritty inlet
#

Cmon Discord I know you can document these already..........

#

But this is the dumbest shit I've seen so far

#

Like ok? Dont add it then xd

gritty inlet
#

For example these 3 events are all the same payload xD

#

But then here it's different. Consistency doesn't exist in this stuff

dry kelp
#

can't lie, entitlements are so ass to manage

gritty inlet
#

glad i dont gotta do that

dry kelp
#

but yeh man, dont think the shit i do is overwork, is what i need since i cannot handle milions of users thru library chunking.

gritty inlet
#

Millions?

dry kelp
#

Yes

stark ingot
gritty inlet
dry kelp
#

We've discontinued 3 months back, coming with a new v2 version much more improved.

#

lost only 20 guilds meanwhile, people have faith in spookylito

#

but what we building cannot be done overnight, takes time

gritty inlet
dry kelp
#

Did you ping me?

gritty inlet
#

O yea
When you say millions, sure you don't mean something as "bot.users"? Which doesn't really count

compact chasm
#

πŸ’€

dry kelp
#

If you are familiar with what happens when a bot is chunked.

#

It sends you all guilds and users data (to keep this short i said data), Doesn't matter if users interacted or not with the bot.

gritty inlet
#

Yeah you can't realy count that as your user base xD

dry kelp
#

Once you stop chunking, you receive NOTHING, you need to make your OWN fetch operations.

gritty inlet
#

I know

dry kelp
#

doesn't matter if they interacted or NOT

#

It's still data your bot receives towards library, and yes there are milion users across all guilds spooky is in, reason why you see my "overwork"

gritty inlet
#

Exactly why you'd usually not need to chunk

dry kelp
#

reason why SPOOKY is NOT chunked

#

When you chunk such a huge amount, your bot can so long to start up.

#

It's bad practice to have all that across bot's memory

gritty inlet
#

And no, high amount of users that a bot can "see" doesn't mean much, sorry

dry kelp
#

imagine your bot's memory, receiving all that load of cache

gritty inlet
#

It's about who interacts

gritty inlet
#

It only does if you chunk them

dry kelp
#

Dude are you, braindead?

#

When you chunk, you receive all users and guidls data

gritty inlet
#

Why would it matter if you don't chunk or cache them

dry kelp
#

BECAUSE we DONT cache them on fucking bot's memory

gritty inlet
#

But you said you don't chunk

dry kelp
#

BECAUSE we DONT cache them on fucking bot's memory

#

And there is a TTL to hold a MAXIMUM amount

gritty inlet
dry kelp
#

which we limited to 5000

#

and it doesn't go to bot's memory, it uses REDIS

#

so bot's memory will always be low

gritty inlet
#

Eh yeah the memory of the bot's process specifically

dry kelp
#

not fucking chunking milion users across guilds, since it chunks people that NEVER interacted with bot, holy

gritty inlet
#

-_-

#

You don't got to keep calling people that word

dry kelp
#

Cause you're talking information you have 0 clue of

#

Chunking WILL get onto your bots memory all users and guilds

#

all my memory goes to redis, and NOT bot's memory

celest pelican
#

!tempban 404264989147529217 1d Take a break. If you return, re-read our #code-of-conduct thoroughly before.

unkempt canyonBOT
#

failmail :ok_hand: applied ban to @dry kelp until <t:1761677078:f> (1 day).

gritty inlet
#

Not cheering on one's downfall but yeah no need to repeat such word again and again

#

You can't make me look dumb and only at the end explain what kind of cache it is...

proper slate
#

Yikes.

#

I was going to talk about MY cache system

#

Ill be civil I promise if anyone wants to talk

gritty inlet
#

All good vro

proper slate
#

Does anyone use like. A theme across their content?

#

Like I studied physics

gritty inlet
#

Ngl I just let my library handle the cache

proper slate
#

Everything i do is pretty physics related

#

I made an emergent lesrning cache system and so far its buggy a little but has promising data

#

Using particle physics to model access patterns

gritty inlet
#

You lost me there PeepoGGERS2

proper slate
#

Uh. Its like. Here's an analogy.

Most systems grab one piece at a time and have it delivered.

I use physics forces to act like access patterns. Different patterns apply different forces and related content clusters.

Instead of ordering and waiting, I drive to the store, find what I want, and grab the box, all its pieces, the instructions, and a couple other boxes that were buy 1 get one free. Then I go home. I do extra work.

But everyone else waits for pieces

I have like 3 open boxes with the instructions.

gritty inlet
proper slate
#

Its like a box of LEGO

#

Grab everything at once so you dont have to go back

compact chasm
#

I'm lurking in chat trying to see if I'll hear anything interesting until I realized I don't understand a single thing being said πŸ—£οΈ

gritty inlet
#

Real talk

proper slate
#

Ok. Its like. Caches are little particles. They are hot or cold and time cools them down. Stuff being dependent makes it cluster together and accessing something heats it up. Over time related stuff clusters because it gets hot and the interactions get stronger. So it like. Learns by just literally making an entry hotter and seeing what happens

They end up grouping by stuff being accessed together. Then when you grab the group, everything is related

gritty inlet
#

Very useful thing I made πŸ₯€

#

Jokes ofc

proper slate
#

Hahaha. Cool color

gritty inlet
#

Ngl it's just hard to make non useless stuff

compact chasm
#

First both I made just pulled from a list of random insults I liked and called someone a random insult

proper slate
#

I just make what I need and build it from what I know. I know physics so even caches end up as metadata particles πŸ™„

gritty inlet
#

But I got one bot with like 50 completely random commands xDD

#

This one's fun tho

#

Prototype that I never did anything with

#

Was cool to make

velvet compass
#

!unmute 865986856268333056

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: pardoned infraction timeout for @shy talon.

velvet compass
#

Hey, you can't send that many emojis. Maybe a screenshot would be fine

shy talon
#

ok, thanks. sorry, i did not know that

#

hi, i'm trying to make a minesweeper game(just send a 10x10 grid of emojis 1️⃣ - 8️⃣, each behind a spoiler). The generated grid looks like this:

||:blue_square:||||:one:||||:bomb:||||:bomb:||||:one:||||:blue_square:||||:one:||||:two:||||:two:||||:one:||
||:blue_square:||||:one:||||:two:||||:two:||||:one:||||:blue_square:||||:one:||||:bomb:||||:bomb:||||:one:||
||:one:||||:one:||||:one:||||:one:||||:one:||||:blue_square:||||:one:||||:two:||||:two:||||:one:||
||:bomb:||||:one:||||:one:||||:bomb:||||:one:||||:blue_square:||||:blue_square:||||:blue_square:||||:blue_square:||||:blue_square:||
||:one:||||:one:||||:one:||||:one:||||:one:||||:one:||||:one:||||:two:||||:two:||||:two:||
||:blue_square:||||:blue_square:||||:blue_square:||||:blue_square:||||:blue_square:||||:one:||||:bomb:||||:two:||||:bomb:||||:bomb:||
||:one:||||:one:||||:one:||||:blue_square:||||:blue_square:||||:one:||||:one:||||:two:||||:two:||||:two:||
||:one:||||:bomb:||||:one:||||:blue_square:||||:blue_square:||||:blue_square:||||:blue_square:||||:blue_square:||||:blue_square:||||:blue_square:||
||:one:||||:one:||||:one:||||:blue_square:||||:blue_square:||||:blue_square:||||:blue_square:||||:blue_square:||||:blue_square:||||:blue_square:||
||:blue_square:||||:blue_square:||||:blue_square:||||:blue_square:||||:blue_square:||||:blue_square:||||:blue_square:||||:blue_square:||||:blue_square:||||:blue_square:||

I have checked, this is 10x10, even the last line, however for some reason, discord only shows 9 squares on the last line

#

this is how it looks for me. i asked a friend too, it is the same for them

#

oh, it's even worse for 15x10. it instead shows 15x7, with 6 squares missing on the last row. does anybody know what causes this and how to fix it?

proper slate
#

Are you accounting for borders or page breaks? Are you using visual width vs len() and keeping track of both?

proper slate
#

Wcwidth handles visual width really well

shy talon
#

it also can't be that a row is too wide, because the emojis are missing entirely

#
import random

emojis = {
    0: "||:blue_square:||",
    1: "||:one:||",
    2: "||:two:||",
    3: "||:three:||",
    4: "||:four:||",
    5: "||:five:||",
    6: "||:six:||",
    7: "||:seven:||",
    8: "||:eight:||",
    "bomb": "||:bomb:||",
}



def gen_grid(width, height, mines):
    if mines >= width * height:
        raise ValueError("too many mines!")
    grid = [False] * (width * height)
    mine_positions = random.sample(range(width * height), k=mines)
    for mine in mine_positions:
        grid[mine] = True
    res = []
    for y in range(height):
        for x in range(width):
            if grid[x + width * y] == True:
                res.append(emojis["bomb"])
            else:
                surrounding = 0
                for mx in range(x - 1, x + 2):
                    for my in range(y - 1, y + 2):
                        if (
                            (mx < 0 or my < 0)
                            or (mx >= width or my >= height)
                            or (mx == x and my == y)
                        ):
                            continue
                        if grid[mx + my * width] == True:
                            surrounding += 1
                res.append(emojis[surrounding])
        res.append("\n")

    return "".join(res)

this is my current prototype to generate the game

proper slate
#

Do you have the emoji font?

shy talon
#

? what emoji font?

gritty inlet
#

Suggestion: Use the emoji unicode and not the Discord format

#

But also, what's the point of this if you can just cheat by clicking on the spoilers xD
Feels like playing TicTacToe against yourself

shy talon
gritty inlet
#

No I'm just saying. Never said it'll solve anything.

shy talon
gritty inlet
#

You're right πŸ˜„

proper slate
shy talon
# proper slate Most fonts need an emoji font installed too.

I'm pretty sure the problem isn't fonts. it also happens when i use normal digits and X for bombs like this:

||`X`||||`2`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||
||`X`||||`2`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||
||`2`||||`2`||||`1`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||
||`2`||||`X`||||`2`||||`1`||||`1`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||
||`X`||||`2`||||`3`||||`X`||||`2`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||||`1`||||`1`||
||`1`||||`1`||||`2`||||`X`||||`3`||||`1`||||`1`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||||`2`||||`X`||
||`0`||||`0`||||`1`||||`1`||||`2`||||`X`||||`1`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||||`2`||||`X`||
||`0`||||`0`||||`0`||||`0`||||`1`||||`1`||||`1`||||`0`||||`0`||||`0`||||`0`||||`1`||||`1`||||`2`||||`1`||
||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||||`1`||||`X`||||`1`||||`0`||
||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||||`0`||||`1`||||`1`||||`1`||||`0`||
solar venture
#

hi guys who

faint basin
#

hi

solar venture
faint basin
#

me

#

yes

solar venture
#

Thank you, Ace, for joining us.

burnt quiver
#

this isn't really the place

#

no

quick gust
#

You're essentially just advertising

solar venture
#

if its not allowed i will delete all messages about it

celest pelican
solar venture
#

ok

solar venture
proper slate
#

Has anyone tried animation?

gritty inlet
#

As in?

stark ingot
gritty inlet
#

discord.py; interaction_check.
I want to have a check that if false, respond to user with x.
I currently do that in my check, implemented in the item's interaction_check:
I am also wondering why would it be a problem to respond in the check, not library wise but why does it fail sometimes? Unless the failure is something else

async def is_original_user(interaction: discord.Interaction) -> bool:
    if interaction.message and interaction.message.interaction_metadata:
        if interaction.user.id != interaction.message.interaction_metadata.user.id:
            await interaction.response.send_message(f"This belongs to <@{interaction.message.interaction_metadata.user.id}>.", ephemeral=True)
            return False
    return True```
Today there was a time where I clicked someone else's button and the interaction just failed to respond. I can't figure out what caused it to fail, there was no exception raised anywhere either (at least I don't see one in my logs)
I restarted the bot and tried again and it responded.

Is this purely a latency thing 😭
proper slate
#

Its 100% possible

gritty inlet
proper slate
#

I was just wondering if anyone else had tried?

gritty inlet
#

Idk what u mean by animating a dbot

proper slate
#

Like giving responses custom animations. Instead of using embeds, use animations in the embed

#

I know there is sprite swapping already but thats a low frame rate

gritty inlet
proper slate
#

Sorry. Not my intent

#

I render GIFs on demand and that deals with the FPS/rate limits problem

fast osprey
#

Not sure what other answer you're expecting. Discord is a message service, it's not youtube

#

You can upload a gif or a video or link to a host that has either

next mirage
#

hi guys

#

how do i start?

#

with making these dc bots ??????????????????

fast osprey
#

Learn a programming language, find a discord library for that language, follow that library's official getting started guide

timber dragon
#

Can I do -1 instead

proper slate
fast osprey
#

Tried sending gifs or videos? Yes

gritty inlet
#

Yeah I think you need to rephrase all of this because you're talking about simply "sending an animation" in a response.

proper slate
#

Nevermind

grave sandal
#

@proper slate I think I've seen a bot send a gif in an embed with a slot machine and the result of gambling or something.

fast osprey
#

Containers support mediagallery items, embeds do not

gritty inlet
#

What that has to do with what they said πŸ˜…

sick birch
timber dragon
#

Or you're not handling a specific situation

gritty inlet
fast osprey
#

Worth doing some debugging to see what is or isn't being executed. You wouldn't get a latency issue without an error (or you're swallowing errors)

gritty inlet
#

I'm not too surprised about the latency though, the more far away you are from Discord's servers the worse it gets

#

And I'm far enough

young dagger
#

Didn't they fix the discord caching issue with mentions?

gritty inlet
#

Not a cache issue, but yeah they made them resolve always but reverted that change the day after

young dagger
#

Sometimes they show up as "unknown user"

gritty inlet
gritty inlet
gritty inlet
#

Don't remember, I think someone quoted it here

young dagger
gritty inlet
#

No and that wouldn't make sense with what I said

#

They can fix it and they did temporarily

#

.

#

That's why I said it sounds dumb, because this doesn't make sense

young dagger
#

What is your theory?

burnt quiver
#

Users that are not in the server won't be rendered

young dagger
burnt quiver
#

I've never seen that happen before unless you're talking about in embeds

young dagger
burnt quiver
#

in embeds there's some weird caching issue so yeah

timber dragon
#

Every mention will be rendered if they roll out the thing again iirc

#

It was mainly reverted for performance issues

burnt quiver
#

advaith said there was some performance issue

#

yeah

gritty inlet
#

In that case, I can see why they didn't want it

burnt quiver
#

no, in embeds or not, users not in the server won't be rendered

Issue being users are not rendered properly in embeds even if they are in the server

gritty inlet
#

Wasn't talking about this

#

Was talking about that time they made them resolve everywhere

timber dragon
#

It would send all the resolved objects with the message

gritty inlet
#

πŸ€”

timber dragon
#

I guess? I don't manage a big ass codebase like discord

woeful hill
#

I mean if it does that every time then it would worsen the performance than just rely on user's client cache
If it is cached it is cached, if it isnt it isnt

gritty inlet
#

Yup

timber dragon
#

"If it isn't it isn't"

woeful hill
#

Wise words

faint basin
#
@commands.has_permissions(administrator=True)
async def removerole (ctx, member: discord.Member, *, role: discord.Role):
    try:
        if role is None or member is None:
            embed = discord.Embed(description="You missed the ``member`` argument. do it like: `^removerole <member> <role>`")
            await ctx.send(embed=embed, delete_after(3))
            return
            
        elif not ctx.author.guild_permissions.administrator:
            embed = discord.Embed(description="You must have Administrator permissions.")
            await ctx.send(embed=embed, delete_after(5))
            return
            
        elif ctx.author.top_role <= ctx.guild.me.top_role and ctx.author != ctx.guild.owner:
            embed = discord.Embed(description="Your top role should be above my top role.")
            await ctx.send(embed=embed, delete_after(5))
            return
            
        else:
            await member.remove_role(role)
    except discord.Forbidden:
                embed = discord.Embed(description="I don't have permissions to *Remove Role*")
                await ctx.send(embed=embed, delete_after(5))  ```
#
@commands.has_permissions(administrator=True)
async def addrole (ctx, role: discord.Role, *, member : discord.Member):
    try:
        if ctx.author.top_role <= ctx.guild.me.top_role and ctx.author != ctx.guild.owner:
            embed = discord.Embed(description="Your top role should be above my top role.")
            await ctx.send(embed=embed)
            return
            
        elif role => ctx.guild.top_role:
            embed = discord.Embed(description="This role is higher than my role, move it to the top!")
            await ctx.send(embed=embed, delete_after(5))
            return
            
        elif not ctx.author.guild_permissions.administrator:
            embed = discord.Embed(description="You must have Administrator permissions.")
            await ctx.send(embed=embed)
            return
            
        elif role is None or member is None:
            embed(description="You missed the ``member`` argument. do it like: `^role <role> <member> `")
            await ctx.send(embed=embed, delete_after(4))
            return
        
        else:
            await member.add_roles(role)
            await ctx.message.add_reaction("πŸ€Ήβ€β™‚οΈ")
            ```
sick birch
#

is there some context for this i'm missing?

gritty inlet
#

Prefix commands in 2025 notstonks

scarlet tiger
gritty inlet
#

More difficult - no
More feature rich - yes

stark ingot
#

What specifically is harder about slash commands? It should be approximately the same number of key strokes

scarlet tiger
#

As a developer, I have to adapt to my users’ needs and preferences. If they like and use prefix commands more, then I have to go with that.

#

Although whenever I make a prefix command, I also create its slash version, since there are also some users who prefer those (even if they’re few) πŸ˜…

gritty inlet
#

There is no real difference to the response or send speed
Preference is fine although as I said slash commands have way more features.

#

Without slash commands you have to make a help command describing each command, as well

scarlet tiger
gritty inlet
#

Honestly don't see why people want those so bad

fast osprey
#

Making both is the worst option

faint basin
#

hi

vivid plover
fast osprey
#

That would be even worse with prefix commands

#

If anything that's even more reason to use slash commands

gritty inlet
#

When you do !help you don't know which of these 17 bots will respond

#

It's much less of a mess when you have a command list

celest pelican
#

The one where ! is the prefix?

gritty inlet
celest pelican
#

Yeah, I can see how it would get confusing if you have several bots with the same prefix

gritty inlet
#

Which necessarily happens

fast osprey
#

When you remove the need for a help command (and superfluous commands that are just reimplemented native behavior), from my experience there aren't many overlaps

celest pelican
gritty inlet
#

Yeah see you gotta configure them now

#

It's just less convenient, not a disaster

#

Also with slash commands you can have user installed commands

quick gust
#

It's much easier to type /command and pick the bot you intended to use, instead of memorizing the prefixes

woeful hill
#

dont even need to remember the command name

#

type / and then everything you can execute is shown

burnt quiver
#

I like to use prefix commands cuz I know them and it's undoubtedly faster since u know the arguments and this is like a private bot

But for 'production'/public bots, slash commands are definitely better in almost every aspect

finite salmon
#

The thing is, people hate change regardless if its for the better or worse

#

There are people who really hate change since they are so used to prefix commands

vocal plover
burnt quiver
#

Yes but that’s only if know the command well, someone who’s new to the bot won’t know and slash commands are much more friendly

vocal plover
#

Yeah not arguing with that, just that there are uses for prefix commands in 'real' bots beyond not liking change

fast osprey
#

Depending on what the moderation action is, if it's doing something more sophisticated than the native operations and it's super time sensitive

vocal plover
#

Yeah I should clarify that if you're running a server with like 1000 people then you almost certainly have no reason to need the extra speed of prefix commands, my case is somewhat more unique kekw because I frequently need to ban people sending scams/gore/etc in a server with around 600k people, so the impact of leaving it in chat longer is a lot bigger and more immediate

#

(and also sometimes includes multiple users in one command, where are variadic args Discord? we've been asking for 4 years)

fast osprey
#

Agreed that is a huge gap on slash commands blobpain

vocal plover
#

it's such a shame because I really like slash commands generally, but a bunch of stuff I do needs variadic args

#

so I'm blocked from properly using them, I mean I can just dump IDs into a text field but if I'm not getting the benefits of the slash ui anyway at that stage why bother using it

#

that said, advaith is now employed on the apps team and we're getting stuff added to modals for example, so maybe soon we'll get the stuff we've been asking for for years

fast osprey
#

In theory you could have a multi user select. It's one extra step but might be more ergonomic

vocal plover
#

how many lines of yaml is too many lines of yaml?

#

an unfortunate consequence of being a large server is we get hit by new stuff first, so although we have a frankly insane amount of automod stuff we still get a bunch of stuff that we need to react to (and then filter when we've seen a pattern)

gritty inlet
#

Just don't let new members send links or media

vocal plover
# gritty inlet Just don't let new members send links or media

Wow why didn't I think of this! (It's not that simple, firstly because people send messages without links that guide people into scams, and also because we don't want the community to be hyper restrictive. Also, we do, but people aren't new forever, and people who are existing members get compromised)

gritty inlet
#

I mean it can work alright with a leveling system if you have one

#

But yeah I never said you can 100% avoid this

fast osprey
#

The latter scenario is pretty common

gritty inlet
#

Yup

#

That's one reason why you should require moderators to have 2fa

#

In general, not talking about your case

celest pelican
#

Isn't the typical case of compromise token theft (where 2FA doesn't help)?

vocal plover
gritty inlet
#

Matter of fact it's very good practice

celest pelican
gritty inlet
#

Yea ik

#

2FA helps with e.g. fake login pages

fast osprey
#

In theory a moderator should be more educated than the average discord user and know not to "test my game pls"

vocal plover
#

Also just to point it out, I specifically mean regular members being compromised rather than mods, since there's a fuckton of people in GTAO with a high enough level to post media, and we can't enforce 2FA on them

fast osprey
#

Yeah I think those two cases got mixed up here

vocal plover
#

I certainly am kekw

gritty inlet
#

I just troll scammers when they dm me lol

fast osprey
#

Sadly not many of them are particularly fun when you screw around with them from my experience

vocal plover
#

I'm involved in too many anti-abuse organisations and projects so I don't get them anymore. Literally the scam software skids use for it has me and a few other IDs blacklisted because they've worked out that it will result in instant termination lmao

#

It's nice to know that I'm that much of a problem for their operation lol

gritty inlet
#

The ones that find me are
And funny enough there's a code word for some of them

#

Tested that

faint basin
#

try, except or @cmdname.error

faint basin
#

πŸ€Ήβ€β™‚οΈπŸ€Ήβ€β™‚οΈ

burnt quiver
#

honestly depends

#

Ig if you want more specific error handling, try except is better?

cuz if there's two places in your code that raises the same error and are similar, you might not be able to tell where this error came from

faint basin
#

which one would be better if I wanna make a public bot

livid fiber
#

Can we get perms for voice txt

timber dragon
#

same perms as a text channel

timber dragon
faint basin
#

hmm

serene plank
#

!e import discord

unkempt canyonBOT
# serene plank !e import discord

:x: Your 3.14 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 1, in <module>
003 |     import discord
004 | ModuleNotFoundError: No module named 'discord'
serene plank
#

!e import pandas as pd

unkempt canyonBOT
serene plank
#

!e print("Hi gais")

unkempt canyonBOT
foggy kraken
#

.

gritty inlet
#

Finally

#

Seems to only be applied in profiles lol

young dagger
#

@gritty inlet What DB are you using for your bots?

#

Btw what do you guys think about MongoDB vs asqlite?

gritty inlet
young dagger
gritty inlet
#

Nah it has an async engine option

#

:D

grave sandal
#

I love sqlalchemy but I kind of wish there was something faster to use just to prototype with. Feels like a lot of boiler plate to get anything useful.

sick birch
young dagger
sick birch
fast osprey
upper falcon
#

what's the raw api for creating a server invite?

burnt quiver
#

raw api meaning?

upper falcon
timber dragon
upper falcon
#

thank you

#

let me try it rq

#

like this

#
        channel_list = httpx.get(f"https://discord.com/api/guilds/{guildid}/channels", headers = {"Authorization": f"Bot {token}"})
        channel_ids = []
        for x in channel_list.json():
            channel_ids.append(x["id"])
            print(channel_ids[0])
            threading.Thread(target=wrapper.waifu.create_invite, args=[channel_ids[0]]).start()
gritty inlet
#

If it works then it works...

#

Nice another person that uses httpx

fast osprey
#

Why are you looking over all channels and making invites to all of them

gritty inlet
#

That's a great point actually

#

Though this code is, obviously, for testing so Idk

upper falcon
gritty inlet
#

Please tell me you're not using synchronous operations in production though

upper falcon
#
threading.Thread(target=wrapper.waifu.create_invite, args=[random.choice(wrapper.waifu.get_all_channel_ids(guildid))]).start()
gritty inlet
#

Why...

#

You know HTTPX has async right?

upper falcon
#

i know

gritty inlet
#

Then why use threading + asynchronous

upper falcon
#

for it to be faster

fast osprey
#

What is the purpose of making an invite on a random channel

upper falcon
gritty inlet
fast osprey
#

No I didn't I asked you why

gritty inlet
#

Threading is really not more fast or more effective than using async operations

upper falcon
#

i just need a random channel invite

gritty inlet
#

This is what I do:

client = httpx.AsyncClient(headers=...)

async def x():
  response = await client.get(...)
  ...
upper falcon
#

i know httpx is async

gritty inlet
#

Been using that for almost 2 years and it works great

upper falcon
#

but i'm using it sync

gritty inlet
fast osprey
#

Why do you need a random channel invite

#

Who is getting this invite and why would it be random

gritty inlet
#

Just create an invite for the guild directly

#

Why channel bound

upper falcon
#

because i already have a function in my class for getting all channel ids

#

it's some moderator bot i'm making

#

i just need a invite function

fast osprey
#

To invite who

upper falcon
#

idk bruh anyone

gritty inlet
#

That doesn't mean you should do it.......... theres no point in creating invite for all channels, not to mentions that's hella sketchy

#

So create invite for the guild, not for a channel of it

upper falcon
gritty inlet
#

Dude why are you always picking the obviously worse option 😭

#

But have fun if that's what you believe is good

upper falcon
#

thanks

fast osprey
#

9 times out of 10, code like this is malicious and used to back door into servers

#

People can use the native invite feature. This adds nothing

upper falcon
gritty inlet
#

πŸ₯€

#

But yeah bots shouldn't create invites for guilds

#

Just do it yourself

fast osprey
#

There are a few cases where you might want that. But manually creating an invite to a random channel screams "I want a back door into this server"

solid prairie
#

for heavy io

#

ur just bloating up your app with additional threading

timber dragon
#

But ChatGPT said it's faster :(

vocal plover
finite salmon
# solid prairie for heavy io

Threads are meant for CPU intensive tasks and async for I/O intensive task. You need to explicitly use threads separately if you want it to. It doesn't use it on its own

solid prairie
#

i see

upper falcon
#

see i told y'all my code was good smh

gritty inlet
#

Did anyone say it's good

#

I assure you api calls are not intensive in any way, but they do block, not in a way that would make it better to use threading

#

The best practice is to use async

verbal island
#

I have a working bot that sends a message to a channel with a hardcodded user's ID in the code. I was wondering if there is a better way to see when that user gone offline or online. And when the user gone offline, i want it to show how long the user had gone offline when user gets online.

Sounds confusing :c

#

Like a timer? (Not live, ofc)

#

Ping me if anyone have an idea. Because i'm going to take a shower!

finite salmon
cloud dawn
#

!d discord.on_presence_update

unkempt canyonBOT
#

discord.on_presence_update(before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Member) updates their presence.

This is called when one or more of the following things change...
dim kettle
#

How i can do a discord bot

#

i have a level very very smart

fast osprey
#

Very carefully

verbal island
cloud dawn
#

!d datetime.datetime

unkempt canyonBOT
#

class datetime.datetime(year, month, day, hour=0, minute=0, second=0, microsecond=0, tzinfo=None, *, fold=0)```
The *year*, *month* and *day* arguments are required. *tzinfo* may be `None`, or an instance of a [`tzinfo`](https://docs.python.org/3/library/datetime.html#datetime.tzinfo) subclass. The remaining arguments must be integers in the following ranges...
#

class datetime.timedelta(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0)```
All arguments are optional and default to 0. Arguments may be integers or floats, and may be positive or negative.

Only *days*, *seconds* and *microseconds* are stored internally. Arguments are converted to those units...
finite salmon
#

!e

import datetime
import time

offline_snap = datetime.datetime.now()
# Capture the datetime of when the user went offline

time.sleep(1)  # Simulate user was offline for 1 second

online_snap = datetime.datetime.now()
# Capture the dateimte of when the user came back online

time_elapsed = online_snap - offline_snap  # You get a datetime.timedelta object

print(f"Seconds elapsed while user was offline: {time_elapsed.seconds}")
unkempt canyonBOT
verbal island
#

Thank you! I understand now

timber dragon
#

!d discord.utils.utcnow

unkempt canyonBOT
#

discord.utils.utcnow()```
A helper function to return an aware UTC datetime representing the current time.

This should be preferred to [`datetime.datetime.utcnow()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow) since it is an aware datetime, compared to the naive datetime in the standard library.

New in version 2.0.
timber dragon
#

You should use that for time comparisons in a library like discord.py

Everything else works the same way

cloud dawn
#

Result will be the same, this will only really be an issue when sharding.

timber dragon
#

It'll actually error out

#

Since you can't compare a timezone unaware (?) with one that is

burnt quiver
#

!e

import datetime

print(datetime.datetime.now() > datetime.datetime.now(datetime.timezone.utc))
unkempt canyonBOT
# burnt quiver !e ```py import datetime print(datetime.datetime.now() > datetime.datetime.now(...

:x: Your 3.14 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 3, in <module>
003 |     print(datetime.datetime.now() > datetime.datetime.now(datetime.timezone.utc))
004 |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
005 | TypeError: can't compare offset-naive and offset-aware datetimes
burnt quiver
#

surprised I typed that right first try

timber dragon
burnt quiver
#

tyty

mellow charm
#

@mighty briar

dry kelp
timber dragon
#

Welcome back

dry kelp
#

i managed to implement openai free moderation api

#

which apparently still requires billing ducky_concerned

#

added the minimum 5 usd