#discord-bots

1 messages ยท Page 420 of 1

fast osprey
#

So you think calling someone slow is a compliment?

dry kelp
#

Must aswell file a complaint of me calling you slow too.

dry kelp
#

you are here giving out "advices" and you cannot understand yourself simple common names.

#

I had expectations from a developer like you to understand the concept of a PRODUCTION branch

fast osprey
#

You keep saying I don't understand this and you're refusing to identify what it is you think I don't understand

dry kelp
#

Cause you are not understanding ๐Ÿ˜‚

fast osprey
#

I told you I know what production means and you're insisting I don't

dry kelp
fast osprey
#

Me saying I don't care what you call your branches is not the same as me saying I don't understand this word you're using

stark ingot
#

And automatic syncing effects this how?

gritty inlet
#

It's not related

dry kelp
gritty inlet
#

I know
But y'all started a new convo completely out of that context

#

What can I say..

stark ingot
#

I still don't see why it is not good practice.

#

This question still stands

gritty inlet
#

What if a user, on production or not, does many adjustments to a certain thing they're working on, and every few changes they restart the bot? Now you got the bot sending the PUT /commands request way too often - even if it doesn't actually hit the rate limit, you just spam an endpoint.
And personally I don't even think this is an edge case.

grave sandal
#

I'm actually working on something myself to write automated acceptance tests against discord bots/slash commands. Generally I don't think any better is possible in discord bot development publicly without manual testing, so it's not like other types of testing people can reasonably do but just ignore.

dry kelp
stark ingot
dry kelp
#

Proved since he wasn't able to understand his own words.

#

Holy production, production is production, not a pickle

#

๐Ÿฅ’

gritty inlet
dry kelp
#

Getting offended that badly upon being called slow, based on they're saying, it's just crazier.

stark ingot
gritty inlet
#

You never mentioned that ๐Ÿ’€

#

That changes my view of it, of course

fast osprey
#

Okay dude

dry kelp
grave sandal
# dry kelp Sounds amazing, curious how that turns out.

It's going fine so far. I'm between a bunch of things at the moment. I got serious about it when I saw someone else already did similar (not including slash commands) with this https://github.com/CraftSpider/dpytest and when I tried it it no longer worked. But I've gone over the code used pieces of it. The basic idea of both is just to take the discord client instance, replace the HTTP client (it has one with very specific methods that aren't specific to http) with a custom one, and to inject messages into where it processes them from. So it'll build a backend in memory of guilds, add messages when http calls go out, and pass the json data for them to where it would normally be parsed after reading it off a websocket. I'm in the very early stages and probably not explaining it well off the top of my head. But it's real event data back to the client with a fake backend. All in memory.

The use case right now is you can make a function to setup your bot instance, add your cogs, message handlers, etc, and write a test for what you want, like test_should_get_level_up_reply_on_first_message and create a guild add a user to it add the bot to it, have the user say something and see if the bot replies, while hiding all of the implementation details of the bot away, except for maybe database connection details.

GitHub

A package that assists in writing tests for discord.py - CraftSpider/dpytest

dry kelp
#

I will be nice, but i have a limit.

dry kelp
fast osprey
grave sandal
# fast osprey Ideally a testing suite would use mocking, but I don't think anyone has bothered...

Mocking doesn't allow you to specify the what of your application and avoid the how though. You can't say your bot is fit for release anyway if you don't test it in a production like environment, as a philosophy to me with just the features I use it's worth the investment and the discord API is well documented and the discord library as well. I practically have a little mini discord domain model entirely in memory at the moment with just the parts I'm using of guilds, messages, users, and something to fire off events on any changes and send details to the client with default values for anything not used.

fast osprey
#

I don't think anyone seriously suggests that automated tests completely negate the need for manual checks

#

Just that mocking is probably the best tool we have for the automated side when you're dealing with an external api

gritty inlet
#

What you're doing is automating testing on your bot with demo users?

grave sandal
gritty inlet
#

Thought about the concept of this in the past but just turned it down in my head as it's too much work when I can usually test it with my user or demo variables

grave sandal
# gritty inlet Thought about the concept of this in the past but just turned it down in my head...

It becomes easy once you do it. If you can manually test you can write a good acceptance test if there is enough in place. It becomes easy and turns into stuff like "make guild" "make user" "add user to server", "send message as user" "wait for message back" if you want to go know your bot will reply to someone right you got to basically do that anyway and when you write tests a lot it becomes fast. (In general)

gritty inlet
#

Realistically I don't need to be afraid of my code failing in some various ways depending on the user or whatever object.
Your project has purpose but Idk how necessary it is

#

When I manually test, it's a matter of a few minutes or less. I don't do long term testing

#

Also some things genuinely need zero testing

grave sandal
#

My goal is to be able to change large amounts of code without worrying about any of it breaking or changing. I agree that you can get away with no testing, I imagine by limiting what you change, but it's not how I prefer to approach it. i would manually test of course to see if it looked right but I'd personally make progress faster with automated tests.

gritty inlet
#

Hmm, maybe that's just besides my use cases. You do deserve props tho

#

๐Ÿ’”

#

At some point it starts saying the same things over and over again

grave sandal
#

The dpytest library deserves it really and anyone before me who emphasized acceptance testing before it for me to even be doing it. I'm literally using pieces of existing code that still work to get started.

gritty inlet
grave sandal
gritty inlet
#

It's actually quite simple to interact with

grave sandal
#

Ohhh, it's Gemini saying the same thing over and over again, I've noticed that.

gritty inlet
#

The instructions work quite well.

gritty inlet
#

Yea it works

fast osprey
#

Sure hope that's the paid version of Gemini

gritty inlet
#

Question regarding discord.py:
I have a GroupCog. How do I add it as a child of an app_commands.Group

gritty inlet
fast osprey
gritty inlet
#

aw man

fast osprey
grave sandal
# fast osprey Just that mocking is probably the best tool we have for the automated side when ...

I agree that mocking is incredibly valuable. I've actually used it on important code when I was foregoing end to end testing. But there's also the setup code necessary to make sure everything works. (I can't think of a good comparison with discord so I'm gonna keep this more general) If I have a class that needs the current weather it shouldn't care where the weather comes from and I should be able to test that It works in isolation, and mock it out, but if it is supposed to get it from weather.com I gotta set it up with the right implementation for real, which I also have to test against a url to a real page to know if it will work (e.g. with wiremock), and when I do all of this I don't know that when input comes in to my application the right stuff will even be called. Mocking also doesn't necessarily help me when I do something and an event should be fired off, it's just not enough. My application can still break. Also I'm not saying automated testing should stop manual checks I'm just saying I can see why people might be so loose here.

fast osprey
#

There are always caveats when you consider this space is like 99.9% hobbyists and there's really no money involved

gritty inlet
#

How'd I add a Group to another Group when both are subclassed

#

Just set parent?

fast osprey
#

Just put everything into the class?

gritty inlet
#
class G1(Group):
   ...
   class G2(Group): ...```

You mean to say like this?
fast osprey
#
class Parent(Group):
  middle = Group(....)
  @middle.command()
  async def ....
gritty inlet
#

Ah so middle shall not be subclass thumbsup

fast osprey
#

You could stitch this together if you really wanted but I suggest this way

#

!d discord.app_commands.Group.add_command

unkempt canyonBOT
fast osprey
#

is the alternative

gritty inlet
#

Yeah knew about that one

#

Thanks ๐Ÿ™๐Ÿป

grave sandal
fast osprey
#

You could also do this with a separate subclassing for middle too and just

class Parent(Group):
  middle = Middle()

class Middle(Group):
  @command()
  ...

But that feels unnecessarily verbose

gritty inlet
#
def commands_payload_from_tree(tree: app_commands.CommandTree, /, walk: bool = True):
    """Returns a list of all commands as dicts, used for TopGG's commands feature."""
    func = tree.walk_commands if walk else tree.get_commands
    return json.dumps([cmd.to_dict(tree=tree) for cmd in func()], indent=4)```

Something I made for <https://top.gg/bot/bot_id/dashboard/commands>
dry kelp
gritty inlet
#

Show me a screenshot of what you mean

dry kelp
#

I've had a code that was removing it a while back, while discussing with mimu bot developers, they've helped me out.

#

So you know top.gg has a default gradient appearing onto the pages, which is customizable, default red.

#

Like a red glow top page.

#

What i mean is removing the gradient from your own bot's page.

gritty inlet
#

You know you can edit the whole page with css, right?

dry kelp
#

Yes, mimu owners gave me a code to remove gradient, but it doesn't work anymore, i haven't been updating my top.gg

gritty inlet
#

I can quickly figure it out with inspect, wait

dry kelp
#

It just looks lame when you make your own page fully built with css, and custom colors.

#

having the default top.gg gradient

#

let's say i'll follow my style, having black white and gray shades

#

that gradient just makes it look terrible

gritty inlet
#

Weirdly they let you remove anything with that css

#

lol

dry kelp
#

๐Ÿคฃ

#

I just had a snippet that worked like a year ago

#

If you find out let me know, that's a huge improvement

gritty inlet
#

link the typing animation at the top is cool

dry kelp
#

that is indeed

gritty inlet
#

anyway i dont want this to look like self promo so ill just delete

dry kelp
#

I don't think it does, u good.

#

see, that top red gradient

#

looks horrible if you customize your whole page.

#

"flashy gradient" ๐Ÿคฃ

gritty inlet
#

Im figuring it out atm

dry kelp
#

Oh im tripping

#

it does work

gritty inlet
#

The css?

dry kelp
#

Yeh, wait ill show u

#
body > div[class^="sc-"],
body > div[class*="sc-"] {
  background: none !important;
  background-image: none !important;
  box-shadow: none !important;
}

this removes any gradient backgrounds from top gg containers

gritty inlet
#

I found it lul

dry kelp
#
body > div > svg,
body > div[class^="sc-"] > svg,
body > div[class*="sc-"] > svg {
  display: none !important;
}

and this hides top.gg default color at the top

gritty inlet
dry kelp
#

try them out in ur current css

#

on the bot

#

shit finna look so much smoother, that gradient is terrible placed on bot's pages

#

I js had a quick chat like a year ago with a mimu dev, they helped me, but probably don't know about my existance ๐Ÿ˜‚

gritty inlet
dry kelp
#

i js received it ๐Ÿ˜‚

#

but try it up, it's actually cool

gritty inlet
dry kelp
#

even better

#

Mind if i use that?

gritty inlet
#

It seems in the css you had it covers more elements

#

Idk which

gritty inlet
dry kelp
gritty inlet
#

Or if you want a different-color gradient, I can do that too

waxen quest
#

i love this anyone wanne rate my dc bot script

dry kelp
#

Yeah, im familiar, you can change the whole page, even texting, it can be savage.

dry kelp
gritty inlet
dry kelp
#

I just discontinued my bot, and im creating a new v2, it will be absolute savage can't lie, i'll show you something in a bit.

waxen quest
dry kelp
#

One mistake there currently is, im "uploading" images, instead of using urls, kind of delains my containers.

gritty inlet
#

I like this actually

waxen quest
dry kelp
#

But some nah

#

Let's gossip a bit

#

what you think about carl bot developers?

waxen quest
#

me6 is ass

waxen quest
dry kelp
#

as in posting your codes like this

waxen quest
#

ahhh ok how i do it like u like the box thing

dry kelp
#

put small ones, i don't wanna read a whole file

waxen quest
#
@app_commands.describe(member="The member to ban", reason="Reason for the ban")
@app_commands.check(rollen_check)
async def ban(interaction: discord.Interaction, member: discord.Member, reason: str = "No reason provided"):
    if member == interaction.user:
        await interaction.response.send_message("You cannot ban yourself.", ephemeral=True)
        return

    if member == interaction.guild.me:
        await interaction.response.send_message("I cannot ban myself.", ephemeral=True)
        return

    if interaction.user.top_role <= member.top_role:
        await interaction.response.send_message("You cannot ban a member with an equal or higher role.", ephemeral=True)
        return

    try:
        await member.ban(reason=reason)
        await interaction.response.send_message(f"Member {member} has been banned.\nReason: {reason}")
    except discord.Forbidden:
        await interaction.response.send_message("I lack the permissions to ban this member.", ephemeral=True)
    except discord.HTTPException:
        await interaction.response.send_message("Failed to ban the member due to an unexpected error.", ephemeral=True)

@ban.error
async def ban_error(interaction: discord.Interaction, error):
    if isinstance(error, app_commands.errors.CheckFailure):
        await interaction.response.send_message("You do not have the required role to use this command.", ephemeral=True)
    else:
        await interaction.response.send_message("An unexpected error occurred.", ephemeral=True)```
#

this iss jst for ban

dry kelp
#

pffffff

quick gust
#

You don't really need an application to ban someone from a server when Discord already gives you that ability

dry kelp
#

Why do people still do @cmd.error that's something inside of 2019 youtube tutorials

waxen quest
#

tbh my code looks like shit

waxen quest
quick gust
#

Understandable

gritty inlet
dry kelp
gritty inlet
#

Half of the moderation features are now covered by the Discord client and are unnecessary on bots

quick gust
#

I'd be careful using that word, not even sure what that means in this context...

waxen quest
gritty inlet
#

Yeah edit that out

dry kelp
waxen quest
dry kelp
#

chatgpt codes based on your prompt, in can be good, it can be bad.

#

You need to have your own experience into coding, to be using chatgpt properly.

#

chatgpt is frying people's brain thinking they code.

waxen quest
#

i didnt just copy and paste i used it to explain it to me

dry kelp
#

It can be good if you have experience, and you already know the structure in your head, it can be a lot more productive.

dry kelp
#

And im not talking about a prompt e.g "Create me a ban command"

gritty inlet
#

I started with chatgpt, 2 years ago xD
I remember telling it "make me a command that ..."
Will not shame people for doing that. But eventually you should get good enough to grow out of that "phase"

dry kelp
#

5

gritty inlet
#

๐Ÿ˜ญ

dry kelp
#

0

#

time expired, sorry

quick gust
#

wild

dry kelp
#

that's exactly why beginners into coding world should avoid using chatgpt

gritty inlet
#

idk depends how they use it

dry kelp
#

and not just chatgpt, but any AI models

waxen quest
dry kelp
gritty inlet
#

Code completions can actually help people. But there's a difference

dry kelp
#

chatgpt is brain frying

quick gust
dry kelp
waxen quest
gritty inlet
dry kelp
#

__slots__ another beautiful python feature

gritty inlet
waxen quest
gritty inlet
#

I doubt that

waxen quest
#

but i can made scripts bymyself

dry kelp
gritty inlet
#

What's the point of disallowing users to add attrs to a class

#

Like i get it

dry kelp
#

Studies prove it can save 30-40%

gritty inlet
#

But I don't get it at the same time

#

Nah you made that up SKULL_SKELETON

dry kelp
#

it's just, beautiful

#

i didn't ๐Ÿ˜ญ i swear

gritty inlet
#

Don't glaze

dry kelp
#

It's good!

gritty inlet
#

Faiiir

dry kelp
#

Ok ok, what about __all__, have you been using it?

gritty inlet
#

Yeah (ok u got me its similar)

dry kelp
#

Oh ok good good

#

I was about to dummy explain it

#

๐Ÿ˜ญ

gritty inlet
#

Speaking of that, anyone else here used Discord's webhook events?

#

Good feature

dry kelp
gritty inlet
#

I made a wrapper that I'm very proud of

dry kelp
#

it's just

quick gust
#

Is it public?

gritty inlet
#

Holy docstring

dry kelp
#

lovely

quick gust
#

Or did you make it for your personal use

gritty inlet
gritty inlet
#

f it ill put it right now

quick gust
#

Awesome

dry kelp
gritty inlet
#

Is it "Pythonic" to use underscore in module name?

gritty inlet
#

For now I'll put it on my Github as dumb code, not planning to make it an actual module rn

dry kelp
#

check pep 8

fallen halo
#

Yo

gritty inlet
#

Gurt

dry kelp
fallen halo
#

I'm new, and looking forward to knowing the way things are done here

dry kelp
fallen halo
#

I'm new to both of them

waxen quest
quick gust
unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

fallen halo
#

And the ui of discord is strange to me

gritty inlet
gritty inlet
#

If I see that people like it (what's the chance...), I'll make it pipable (:

timber dragon
#

good work!

gritty inlet
#

Waiting for Discord to document Entitlement Delete & Update wait

dry kelp
#

bro

#

the entitlements are so ass

gritty inlet
#

Not using them personally (I can't, ineligible country), but for my wrapper

dry kelp
#

luckly i can, and i use them, but they're shit

narrow hazel
#

Do you mean something like this?

fast osprey
#

where is setup_hook in there?

narrow hazel
#

I have no idea what that is

#

Cuz this is the only info on like 6 websites I just tried to look through

fast osprey
#

yeah, it's a method you can implement in a bot subclass

narrow hazel
#

yeah i havent messed with subclassing in a way I understand it so im just not gonna risk screwing up my cogs for some errors im already raising through try and except

fast osprey
#

subclassing (OOP) is an extremely fundamental concept in python generally and these libraries specifically

narrow hazel
#

I never learned OOP i just dove straight in

fast osprey
#

You are doing yourself a massive disservice in avoiding it

narrow hazel
#

I can look at a tutorial but I doubt I'll understand it

#

I learned discord.py just by memorizing patterns of code and adjusting it to what I need all your terminology is just another language to me

fast osprey
#

If I tell you that is not an effective way of gaining skill or learning, would you listen?

#

If you don't share common terminology or fundamental concepts, people aren't going to be able to help you. You're just asking people to write code for you at that point

narrow hazel
#

probably but I got my bot working with systems I wanted

#

I got a lot of stuff to work

burnt quiver
#

json as a db ๐Ÿคจ

narrow hazel
#

yeah Im not learning SQL or using a DB

#

thats beyond me

fast osprey
#

With that attitude sure

burnt quiver
#

I mean ig you learn file handling all that, but just so you know it's not a db u want in the future

#

when u learn SQL you'll really see the diff

narrow hazel
#

It's not like I just looked at it and didn't try, I spent a few hours looking at tutorials, following and trying to understand but eh I couldnt get it to work nor understand it

fast osprey
#

What precisely do you mean by "tutorials"

narrow hazel
#

as well as any youtube videos I could find on any info

fast osprey
#

YouTube is made up shit

#

By mouth breathers in their basement trying to get Internet attention

#

Terrible educational resource

narrow hazel
#

dont talk about brocode like that, he taught me some coding stuff

fast osprey
#

And how do you know that stuff is accurate, complete, or best practice?

narrow hazel
#

Cuz they work

#

And in my book that'd the best kind of code

fast osprey
#

You think they work

narrow hazel
#

meh I just learned what subclasses are but I dont see its usecase

fast osprey
#

It's a way of taking an existing class and either overriding parts of it or adding on additional things

narrow hazel
#

yeah idk maybe its cuz im not in a developer mindset but I dont see the usecase for that

fast osprey
#

You have one right in front of you

#

You have an existing class (Bot) and you want everything it does normally except for overriding one thing (setup_hook)

narrow hazel
#

btw quick question does anyone know why my discord.CustomActivity works in VSC but when I move it to my server it just doesnt?

#

Im using a task.loop to achieve it with an array of statuses

#
status = discord.Status.idle

@bot.event
async def on_ready():
        update_status.start()
        try:
            synced = await bot.tree.sync()
            print(f"Synced {len(synced)} command(s)")
            for s in synced:
                print(f"โœ… {s}")
        except Exception as e:
            print(f"Error syncing commands: {e}")

@tasks.loop(seconds=30)
async def update_status():
        statuses = [
          discord.CustomActivity(name='Cats > People'),
        ]
        current = update_status.current_loop % len(statuses)
        await bot.change_presence(activity=statuses[current], status=status)
narrow hazel
#
await bot.cog_add(persistant_buttons(bot))
woeful hill
#
class A:
    ...

class B(A):
    ...

B is a subclass of A

narrow hazel
#

yeah

#

Oh wait it would be a subclass of the component not the command

#

My dumb ahh

burnt quiver
#

as of now I don't think there's a way to check the total size of the embed in chars

#

lemme see if I can write a func

gritty inlet
#

There's no builtin but it's easy to make

burnt quiver
#
def find_total_chars(embeds: list[discord.Embed]) -> int:
    total_chars = 0
    for embed in embeds:
        if embed.title:
            total_chars+= len(embed.title)
        if embed.description:
            total_chars+= len(embed.description)
        if embed.fields:
            for field in embed.fields:
                if field.name:
                    total_chars+= len(field.name)
                if field.value:
                    total_chars+= len(field.value)
        if embed.author and embed.author.name:
            total_chars+= len(embed.author.name)
        if embed.footer and embed.footer.text:
            total_chars+= len(embed.footer.text)
    return total_chars
```Should work, and I believe values can be an empty string here? so Im using a falsey check instead of a `is None` check
#

well techinically using is a is None check would work and the len() of emtpty string would return 0 either ways

gritty inlet
#

Aw man

burnt quiver
#

no ui

#

!d discord.Embed.fields

unkempt canyonBOT
#

property fields```
Returns a [`list`](https://docs.python.org/3/library/stdtypes.html#list) of `EmbedProxy` denoting the field contents.

See [`add_field()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Embed.add_field) for possible values you can access.

If the attribute has no value then `None` is returned.
gritty inlet
#

Oh right

#

If I was on pc I'd check if those are empty attrs

burnt quiver
#

oh so it returns None instead of an empty string, interesting

#

wait nvm that's right

gritty inlet
#

Falsy checks cover None anyway

burnt quiver
#

ye

#

np!

#

i doubt danny would implement a utils helper func for this since it's pretty simple

#

lemme see

#

wait wait

#

LMAO IM STUPID

#

just do len(your_embed)

#

it will return the total chars

#

yes

gritty inlet
#

Yea they got that and more operations for embed, like eq and bool

#

IIrc bool is True when embed is not empty

#

!d discord.ui.LayoutView.content_length

unkempt canyonBOT
#

content_length()```
[`int`](https://docs.python.org/3/library/functions.html#int): Returns the total length of all text content in the viewโ€™s items.

A view is allowed to have a maximum of 4000 display characters across all its items.
dry kelp
#

That event can fire multiple times.

#

Since you were so smart yesterday, create your own safe_message while making an enum with maximum discord's limit.

#

And you check the same_message with the enum created with maximum discord's limit for messages.

burnt quiver
#

wha

dry kelp
burnt quiver
dry kelp
#

Are you reading what i've said?

#

He can simply make a enum class containing the max characters for embed / message

burnt quiver
#

what why do u need an enum

dry kelp
#

a class that could potetially be re-used in a longer term.

burnt quiver
#

just use it as a constant

dry kelp
dry kelp
burnt quiver
#

also what safe_message

burnt quiver
#

seems like u aren't reading what I said ๐Ÿ˜ญ

burnt quiver
burnt quiver
dry kelp
dry kelp
#

Imagine running that every single time into your code.

#

terrible choice, if you help people, atleast tell them the right ways of doing a thing.

burnt quiver
#

what's wrong with len(embed)

dry kelp
#

And if you cannot understand the logic of having an enum with max characters, just don't talk.

burnt quiver
#

uh ok

dry kelp
#

Iโ€™m not doing len(embed) for the sake of it. The point of the enum is to centralize Discords known hard limits (like max title length = 256, description = 4096, total embed = 6000, etc.), so I never risk exceeding them. This is clean, maintainable, and avoids magic numbers sprinkled everywhere. It also makes future validation checks easier and prevents runtime errors due to Discord rejecting oversized payloads.

burnt quiver
#

guess what the user asked

#

Hey, how do I check the size of an embed message?
I know the total size can't exceed 6,000 characters.
For example, I want to send 10 embeds in one message, but if any of them exceeds this limit when added to the rest, they would be skipped.

dry kelp
#

.

burnt quiver
#

?

dry kelp
#

so message will always be safe and available

#

so what i've said is FURTHER validations

burnt quiver
#

not sure what you're saying here lmao so I'm just gonna stop this cuz the user already got what they need, .i.e, "Hey, how do I check the size of an embed message?", which is using the len function

dry kelp
#

Im not sure what you're saying

How to validate his code using enums, but if it's so hard understanding the whole point of an enum, might aswell consider quitting development tbh (You).

dry kelp
#

๐Ÿ˜‚

#

Good one

timber dragon
#

Thanks

dry kelp
#

Im still working on that menu i've showed u yesterday

#

I'll ping u once i have a finalized prototype, it looks so cool smirkey

timber dragon
#

Nicee

stark ingot
dry kelp
#

They generate the initial init of database file, they allow you to migrate, downgrade database after changes.

#

e.g you can use PostgreSQL, which is used for long term data storing, and most common across discord bots.

#

In order to setup the connection, you'll have to learn that on your own, but there are various ways.

#

It only depends if you use windows or linux, most common vps used is ubuntu (linux), so if you plan on hosting your bot, you just have to download psql locally

#

and just create your table, which is the only thing you have to learn.

#

and easiest way it's just granting all permissions to table you create lol

#

All this doesn't even require a day, but a few hours to set up properly.

#

or if you use windows, localhost, just download pgadmin

#

or you can use Docker, most common tool across developers, and you can just literally run the database on it, without downloading anything ๐Ÿ˜‚

#

just passing some default values you'll use into your .env or settings, wherever you get your settings from

stark ingot
#

You can even connect to remote databases (on your VPS) with PG admin on your PC

dry kelp
#

exactly

#

i just feel like using json it's more work than making your life easier ๐Ÿ’€

#

and it ain't even a db

gritty inlet
#

Jsons are definitely easier to interact with but are just not meant to serve as a db

dry kelp
#

it's just easier to manage a orm at that point

#

Model.create_or_update()

#

like ong ๐Ÿคฃ

gritty inlet
#

Anyway I switched some of my code to use an ORM, it works fine, I had a few times where two processes interfered with each other and caused a db lock though

quick gust
#

jsons are fine if your data is static

dry kelp
#

or Mee6

gritty inlet
quick gust
#

?

dry kelp
#

after trying some, i went for sqlalchemy

#

tortoise orm has migrations failures if not handled in a certain way, it's harder to understand

gritty inlet
#

Yuh

gritty inlet
dry kelp
quick gust
#

WAL writes the database transaction to a log file first

gritty inlet
#

I have 2 py processes that use the same db file, idk if that's exactly why it may happen though

gritty inlet
quick gust
#

Not really

#

it needs to be persistent so that the transactions aren't lost in cases of a crash

gritty inlet
#

Does it also make it auto retry on db lock? or must i manually do that
unless it really ensures db locks don't happen

quick gust
#

afaik it significantly reduces the database locks (if not completely remove them)

#

you could just set a busy_timeout PRAGMA if you want sqlite to auto-retry

gritty inlet
#

I moved to a db BECAUSE of race conditions so I really hate still having them

#

But tbh it's probably not such good practice to save to disk each operation, maybe I'm wrong
But due to my RPI's low specs I don't want to overload the ram with stuff like redis

quick gust
#

I really don't think that two different programs should be both accessing a single database file simultaneously

gritty inlet
#

That's right but Idk how else I should implement it
I have a process for topgg webhook events, it saves the time of when the user voted in the db

Then my bot process checks, on command execution for example, if 12 hours have passed since the said time and if so, set that field to None, etc

#

I could possibly make the 12 hours check in the first process, maybe in another thread
But the check still has to be done on the bot process if I want to actually use the information

quick gust
#

why do you need two different database connections for that

#

"race conditions" can happen regardless of if it's the same or a different process

gritty inlet
#

Sorry for mention

quick gust
#

No worries, but I just start an aiohttp server inside a Cog which has access to all the attributes of my Bot, including the database wrapper - which manages the database operations

#

Or just make your life easier and use topggpy

#

!pypi topggpy

unkempt canyonBOT
gritty inlet
#

That doesn't matter, what matters is where the process runs

gritty inlet
#

Do you run on a separate thread?

quick gust
#

Of course...

woeful hill
#

Cant you just store the last voted timestamp to the db and then check them when the user use the command the next time

gritty inlet
#

So having a single process with the topgg webhook events being on a second thread should do it?

quick gust
#

Does it for me, haven't run into a race condition for the past 2 years

gritty inlet
woeful hill
#

You done it different than my approach tho

quick gust
woeful hill
#

You set it as voted or not
I set it as last voted
๐Ÿค”

gritty inlet
# quick gust Yes

I'll try it then, what do you use for running on another thread (__PatrickOof )

woeful hill
#

Am i reading it wrong

gritty inlet
quick gust
#

In fact, I have more than 2 aiohttp apprunners that access the same database file

gritty inlet
#

I'll probably just use uvicorn

#

to_thread or threadsafe

#

Never done that before lul

fast osprey
#

Wut. It's totally fine to have two processes access the same sqlite db, you don't need to migrate them into the same process

#

That's an anti pattern, you want separate processes

quick gust
#

Not directly? I mean it's fine if theres another layer that queues/manages the transactions, which the two processes communicate with, but both processes shouldn't be accessing the database file directly

#

Or am I wrong

gritty inlet
#

And is enabling WAL the best thing I can do about it?

quick gust
#

tbf then there's probably something else wrong with your code. The transactions don't take long enough for you to have frequent db locks

fast osprey
#

You should have WAL mode enabled regardless

#

This is why libraries like asqlite enable it by default

gritty inlet
#

And does the file it uses just keep growing

#

I mean to say does it get auto cleared anyhow

fast osprey
#

WAL doesnt grown indefinitely, no afaik

quick gust
#

Ideally it doesn't

dry kelp
#

@gritty inlet Is there a specific reason why you've selected using SQLite?

gritty inlet
#

Recommendations

gritty inlet
dry kelp
#

Umm, i see, most of the people i work with, we all use PostgreSQL for discord bots, or any long term data storage.

#

And honestly, it's just so much better, and no need to do all that.

fast osprey
#

SQLite is perfectly fine

gritty inlet
dry kelp
finite salmon
dry kelp
dry kelp
gritty inlet
fast osprey
#

What is "all that shit" which SQLite "makes you do"

dry kelp
dry kelp
woeful hill
#

SQLite and PosgreSQL are very similar

fast osprey
#

I asked you a pretty simple question and you're dodging it

#

Just to insult me

dry kelp
#

Im not speaking about specifically related usage of postgresql or slqlite

woeful hill
#

In my use i only change $1 to ? And the same postgres sql i use run perfectly on sqlite

dry kelp
#

and i don't care if you take it as an insult, or not, im telling the man to try postgresql, since he might enjoy it more.

#

It's preferences.

fast osprey
#

And we're asking you to justify why and instead of answering you just insult me

dry kelp
#

You came into my subject out of nowhere.

fast osprey
#

It's not "your" subject. You're speaking in an open forum

dry kelp
#

Right, it's a topic i specifically wanted to discuss with @woeful hill and @gritty inlet, is there a problem im not invloving you in it?

#

ooffff, you felt left out, im sorry, here take a pickle ๐Ÿฅ’

fast osprey
#

I'm discussing it too, and that doesnt give you a right to just insult me

#

If you don't want to engage that's your decision

dry kelp
#

Not in the postgreSQL topic, sorry, u outta it.

fast osprey
#

I'm not

dry kelp
#

Then keep talking to yourself, you'll feel ignored even more, but i don't have an extra pickle.

gritty inlet
fast osprey
#

I'm not talking to myself

gritty inlet
#

Alright then...

fast osprey
#

Anyways, if you want an in depth discussion on databases that's better served in #databases . But SQLite is completely fine

dry kelp
#

If you do want to try postgresql, and not go against similiar problems, ping me or dm me.

#

It was meant to be a recommandation, not saying one is better than other.

fast osprey
gritty inlet
#

Hm I see the WAL logic now
But thing is, I want changes to take effect pretty much immediately
So saving every x amount of data might not be good unless it's a low amount, still Idk

fast osprey
#

They will, WAL doesnt introduce a meaningful delay

#

There's an eye opening page on the SQLite website about how sqlite operates at scale. It's designed for what you're describing

gritty inlet
dry kelp
#

But, consider that in discord bots, postgrelsql might be a better choice in my opinion after trying both, very small knowledge into using "SQLite", i can start off by saying the concurrency, postgresql is designed for multiple concurent read/write operations, while sqlite it's like single file locked under multiple writes, different is that postgresql won't choke under load.

fast osprey
#

You're imagining WAL like some slow queue that gets popped from occasionally

#

That's not how it works

gritty inlet
#

My situation: I want users to vote and right after that have the benefits of it

#

Isn't it a save each x amount of data

vocal plover
#

As a somewhat side-comment, frankly you're not building something where the speed of one database vs another actually matters. Build software first, scale it when you need to, because most software never actually needs to scale

dry kelp
#

about scalability, SQLite is used for small projects, meanwhile postgreSQL can scale milions of rows, heavy traffic.

fast osprey
#

SQLite is not only used for "small" projects

vocal plover
#

SQLite is used for some massive thing with huge scale, and it functions perfectly well in that capacity

dry kelp
fast osprey
#

The SQLite website itself runs on a sqlite database and thar incurs orders of magnitude more usage than you ever will

#

It does have async drivers wut

vocal plover
dry kelp
fast osprey
#

asqlite and aiosqlite are the most popular

dry kelp
#

Oh shit, my bad, i thought it didn't

burnt quiver
#

why is bro always finding a way to argue with someone

#

๐Ÿคฆโ€โ™‚๏ธ

dry kelp
gritty inlet
dry kelp
#

quick question tho

#

@fast osprey

#

What if app crashes mid write?

#

file corruption is inevitable i believe, using SQLite

fast osprey
#

No, SQLite does atomic writes

dry kelp
#

mmmm

#

How about the queries?

#

or features?

#

Last time i tried it, it was absolute basic, compared to postgresql having jsonfields, enums, indexing (also partial indexing), triggers etc.

#

lame

vocal plover
#

postgres certainly has more features than sqlite but uh, indexing? that's pretty much universal across any real database

gritty inlet
#

Choose your DB based on its features and your needs, you don't always need something advanced

dry kelp
#

ngl, for postgresql

#

is also complex

vocal plover
#

sharding most databases is complex, sharding postgres certainly isn't a walk in the park either

dry kelp
woeful hill
#

Do you need what it called the "scale" of the program

fast osprey
#

SQLite requires vastly less overhead and moving a database between infrastructure is incredibly easy

vocal plover
#

also refer to my earlier message: your software probably isn't ever going to reach the scale where that matters, and if on the off chance it does you can migrate at that stage, if you design everything you make to work like large scale software from the get-go you won't be able to get anything done

woeful hill
#

If you write the code solely based on one thing that you cant change when it scale, its the design problem, i have it myself with some libraries

fast osprey
#

People love solving for problems they don't have and probably never will

dry kelp
#

Since you all are trying to ride SQLite so much, over PostgreSQL, make a clear label of why you think SQLite would be eventually a best practice.

In complex projects / relatively small

#

I am actually curious to see.

#

Me personally, i would NEVER use SQLite into a complex projects.

woeful hill
#

Im saying sqlite is on pair with postgres

vocal plover
#

like, to be 100% honest, 99% of people who have ever sent a message asking for help with data storage in this channel could probably run their database off a single json file and rarely if ever experience an issue with it. It's not a good idea and you really should use a database, but modern computers and data storage are phenomenally powerful and reliable

woeful hill
#

I have never said one is absolutely better than the other

woeful hill
#

I dont care about the scale, my program have no users, and if i do, i will change it when i feel i need the changes

dry kelp
#

I understand at a small scale, or local projects, it might be great.

#

But here, we are talking about discord bots.

woeful hill
#

You were saying sqlite is bad, so we just back it up?

vocal plover
#

We don't care about it being better, we care about it being misrepresented as not being good enough for production software and that you must use an alternative, which is quite definitively is, and is widely used as such

dry kelp
#

I didn't say it's bad, im saying postgreSQL might suit most discord bots.

woeful hill
#

You are the one comparing one with the other

dry kelp
#

Yeah, cause you guys kept on riding SQLite.

#

All i did was come with a recommandation to that guy to try postgreSQL over SQLite, since he might enjoy it more.

woeful hill
#

The sqlite web page is using sqlite if so you know

#

See how it scale

vocal plover
#

I love postgres, I use it for everything and I have no intent to switch to sqlite, but the reality is that almost anyone making a bot here could use sqlite without issue and with a huge degree less complexity than what's required to set up and manage postgres

dry kelp
dry kelp
woeful hill
#

You were saying its hard to scale, so im saying that sqlite is absolutely viable for large scale uses

#

Dont take it the wrong way

dry kelp
fast osprey
#

"Most people prefer Postgres" is a gross mischaracterization

dry kelp
fast osprey
#

I didn't say I was offended

vocal plover
#

I prefer postgres because I'm an experienced software engineer writing production software at places that use it. When I started programming I used sqlite because it was good enough and it meant I didn't have to learn both SQL databases and managing infrastructure & networks and stuff. sqlite is an amazing choice for people who don't want to deal with the complexity of managing a separate database service

dry kelp
#

you're lucky, i don't have pickles anymore for you, but i can give you a ๐Ÿฌ

fast osprey
#

And really people shouldn't even have a preference. They are different tools that fit different use cases better. That's like saying you prefer a hammer to a screwdriver

dry kelp
vocal plover
#

Honestly if we took a database usage chart for bots I would imagine it's pretty evenly split between sqlite3, postgres, mariadb, and mongodb

dry kelp
fast osprey
#

I'm not mad

dry kelp
#

tell Dyno bot to use mongodb

woeful hill
#

Mysql and oracle would be the best engines then since they are 2nd and 1st in most used databases ๐Ÿ˜”

#

Talks about stats

vocal plover
#

Mongo is widely used among larger apps lol? It wouldn't be my preference but as with sqlite the fact remains that it's fineโ„ข and you can get away with using it to a way higher scale than I think you realise

fast osprey
#

This is all completely anecdotal, and even if you did have data on what database is used most that doesn't remotely inform you about what database is best in this specific case. It's random trivia

dry kelp
#

But, i respect everyone point, apart of solstice, You guys can use SQLite, me saying try postgreSQL was strictly to recommend him a proper database for discord bots.

quick gust
#

new day, new argument

dry kelp
#

Im not entertaining this anymore, since everyone clearly has they're own things in mind.

vocal plover
#

solstice is making similar points to me in a well presented and respectful way, I don't think it's at all fair to go "I respect everyone's ideas but theirs" tbqh

dry kelp
#

My final and honest recommandation, for discord bots, is that your fingers won't hurt trying out postgreSQL over SQLite.

fast osprey
#

They've been adversarial against me for some weird personal hangup

dry kelp
timber dragon
#

Why is it always you vs everyone KEKW

dry kelp
burnt quiver
#

always this channel

quick gust
#

looking forward to tomorrow's argument

timber dragon
#

But also, wtf you got 25 hours on vscode

vocal plover
#

I've had some arguments with solstice in the past, that doesn't mean I need to be adversarial to them for all future points, we agree on many things regardless of things we may disagree on

dry kelp
dry kelp
#

๐Ÿ˜‚

timber dragon
#

๐Ÿ’€

dry kelp
#

Oh, yeah, so look, for further validations, about "Enum" part, it wasn't to write something from scratch, it was to validate the max embed / message limits.

#

Directly doing an Enum, that's for the best practice, making your own safe_message

#

You don't like people helping you? I've been nothing but nice to you thinkCat

timber dragon
#

It's called a suggestion..

dry kelp
#

^^

dry kelp
#

How you've felt forced? I've only told you the best practices, if you wanna learn the shit practices go again. I've marked my help with ^^, you called me a GPT user while debugging your code.

timber dragon
#

Spooky, does this happen to you often, like outside this channel ๐Ÿคฃ

gritty inlet
#

From what I understood the default checkpoint is every 1000 pages of data which should be around 4MB
But I don't think my operations fit for that as they take much less - I don't want to have data in the WAL storage for too long

gritty inlet
#

I hope I got a correct understanding of it

mild kiln
#

hello who wanna developa discord bot with me

timber dragon
dry kelp
#

It's just special here

vocal plover
#

I'm still convinced this channel is actually just a social experiment

burnt quiver
#

This channel is special

dry kelp
#

For trying to teach best practices i get called in so many terms by this adam guy, the conversation can be seen above.

fast osprey
dry kelp
#

^

mild kiln
#

guys who wanna dev a discord bot with me

dry kelp
#

Like, he thought event doesn't load for him, or thinking it was library issue and not his code ๐Ÿ˜‚

woeful hill
#

This isnt a job board

mild kiln
#

guys who wanna dev a discord obt

dry kelp
#

And when i told him he was showing me that he was logging the fucking exception of .load_extension

#

never logging the actual files loading, only logging if the .load_extension fail, and not your cogs

#

but i guess some people dont' wanna learn, and would rather be imbeciles.

mild kiln
#

GUYS WHO WANNA DE VIWTH ME A DISCORD BOT

timber dragon
#

Can someone explain WAL mode in baby terms?

quick gust
gritty inlet
#

Imma assume WAL isnt useful for read only, shall I

dry kelp
timber dragon
mild kiln
vocal plover
# dry kelp Like, he thought event doesn't load for him, or thinking it was library issue an...

Beginners don't have a great working knowledge of how software is made. If you want my honest opinion I think you went in way too hard with sarcasm/talking down to them about the issues. It's understood in pydis that people may have little experience, or not know how to solev problems or ask for help effectively. If you're going to contribute by helping people here IMO you need to have patience for those people as a prerequisite. Not everyone you help will have a decent knowledge level and you've got to tailor your help to individuals.

woeful hill
#

Should be clear enough

mild kiln
#

yes come

timber dragon
#

Smh

burnt quiver
timber dragon
timber dragon
dry kelp
#

And best practices today over how to validate messages, since it seems like he is making heavy messages, its even easier for him to set max values over a enum for best practices

woeful hill
#

Chill, everyone starts somewhere

#

People don't know everything day 1

quick gust
#

If you feel like someone isn't receptive to your "help", then don't help them

quick gust
#

Then why are you bringing up yesterday's conversation

dry kelp
#

and my points were good, he probably thinks i was yapping

dry kelp
#

you are a pickle

#

Perhaps, i wanna show y'all something, i still need to validate a few things, and remove lag caused due to attachments, since im uploading and not using an url, i'll js make a github public repo with my assets

#

y'all see when i'll send video in a sec

woeful hill
#

Thats not the help they need

dry kelp
#

And im trying to teach them best practices, but they've proved to me that they are not here to learn, but only complain thinking what they do is right.

vocal plover
#

Sometimes you've got to pick one battle at a time, people learn good practices over time. I really wish we could just get everyone to make perfect code, but yeh reality is if we push tons and tons of best practice into people's heads before they even get started they'll just quit.

dry kelp
#

Told you i will ping you once i have a prototype.

#

smirkey If command disabled, that deny turns into allow, basically doing the opposite of denial.

gritty inlet
#

Updated my db code, we'll see if it goes good

dry kelp
gritty inlet
#

The command?

dry kelp
#

that's 1 feature of the panel.

#

As in commands management of the bot.

#

and the callable already exists and it's handled.

If command enabled, they can deny users / roles

if command disabled, they can allow users / roles

#

doing opposite, all done thru a proper ui, and not 1000 commands

fast osprey
gritty inlet
#

It works good
I set one process to use WAL and the other not to. The one that doesn't - only reads

timber dragon
# dry kelp <@150665783268212746>

that looks really good. I think the layout can be better like with bokder and bigger text, but the functionality is nice

also good music KEKW

fast osprey
#

Isn't that just the integration panel but slower

gritty inlet
#

Wait I just realized, yeah setting roles or users for commands is already a thing in integrations

dry kelp
#

Panel will hold all features settings.

#

removing in totality commands usage for setups

#

Users also have settings, for theyre privacy and all

dry kelp
fast osprey
#

Why not just point people to the native feature rather than trying to compete with it

gritty inlet
#

It's less about speeds if you ask me

dry kelp
#

You guys need to understand that if you want your bot to be big, you need to also implement shit people use/want

#

even prefix commands, people wont change that, you gotta understand the marketplace

#

or even most coms, use antinukes, which are useless also, its easy to say โ€œjust dont give permsโ€

#

so i want to compete with current market, the users can also have fake perks to use bot commands and not actually having the permission

#

its just about the market manโ€ฆ we cant change that

#

since discord wanted to bad to get rid of prefix commands, years back, fully interactionable

#

you think they couldnt stop bots doing so? nah

#

its just that people wont change some things

compact chasm
#

okay so hello y'all i need a bit of help with syncing slash commands (also i'm using pycord) it's apparently not happening automatically but DOES happen when i kick and re add my bot, i can't really access my command tree since pycord is weird, i'd appreciate some help here

dry kelp
#

and this is something going on for years now

fast osprey
#

Reload your client

gritty inlet
#

As an example

#

But do as you choose

dry kelp
compact chasm
fast osprey
#

Ctrl + R

compact chasm
#

i've done that many many times now ๐Ÿ˜ญ

fast osprey
#

Do it immediately after syncing

gritty inlet
fast osprey
#

And then check the integrations tab in server settings

gritty inlet
#

The immediately

#

As one who has done that a lot

fast osprey
#

I'm not implying it needs to be done within nanoseconds

gritty inlet
#

xd

fast osprey
#

Just before doing other things to isolate the variables at play

dry kelp
gritty inlet
#

You choose not to

#

Personally I have given up few stuff once I realized Discord had better implementations of them

gritty inlet
fast osprey
#

Really not a huge fan of the fatalism that users are stupid and refuse change and it's a good idea to cater to that. It's a self fulfilling cycle

#

It's a conscious decision to feed that vs refusing and dragging them to better end results

gritty inlet
woeful hill
#

if you think the average people are stupid and design your software base on that, that, is the problem

gritty inlet
compact chasm
#

okay so should i be looking for anything specific in integrations tab ๐Ÿ˜ญ

woeful hill
#

you dont have to always spoonfeed everyone everything

fast osprey
#

The commands you're expecting

compact chasm
#

the command is there but it's just not synced

fast osprey
#

If you see the commands there but not in your slash menu, that's an issue with your local client

#

If it's in the integrations menu it is synced

compact chasm
#

no it literally isn't

fast osprey
#

It is

#

That's what syncing means

compact chasm
#

i removed an option from the command in my code but in the server the option is still there

#

i'm new so sorry if i'm using words wrong ๐Ÿ˜ญ

fast osprey
#

How are you checking if that option is there?

compact chasm
#

by typing the command?

fast osprey
#

Then that's your local client

#

The integrations tab is canonical. What you see in the / menu is what your client has cached

compact chasm
#

wow okay

#

thanks anyway

#

it appears i was just misunderstanding what you said it works now ๐Ÿ˜ญ

fast osprey
#

nw prettythumbsup

gritty inlet
#

Memory usage of my bot's process

#

As of the feature I mentioned earlier
I don't have any paid features whatsoever but I just wanted a nice lil way to potentially encourage votes ๐Ÿ˜„ Worth doing

#

I mean as long as the vote doesn't give you a removal of any paywall or other advantages there's no real reason for users to do it, but hey a special color is something

fast osprey
#

If this is top.gg that's well within their tos afaik and actively encouraged

gritty inlet
gritty inlet
#

What does your bot do, generally

#

"Music bot" got it bro ๐Ÿฅ€

#

That's all I need to know when it comes to memory consumption

gritty inlet
#

Don't get why people still make these bots

fast osprey
#

either a lack of ideas or because the alternatives are (rightfully) dropping left and right

narrow hazel
#

66gb? Are yoy making GTA6

gritty inlet
#

I don't have anything against the concept of music bots

#

But I absolutely don't get how someone can sit and make a bot that exists in thousands of copies

narrow hazel
#

I just euphony bot. I looked up how to make a music bot and it's not worth the hassle

finite salmon
gritty inlet
#

It really isn't.

finite salmon
gritty inlet
finite salmon
#

lmao

#

i was studying a bit of audio engineering long ago, i need to pick it up again

gritty inlet
#

Yes, just with thousands of other bots. I don't criticize you specifically but I just don't get it

finite salmon
#

its really interesting

gritty inlet
#

Music bots

#

They really don't need to; Have you ever seen someone using all those services "in one" outside of Discord?

#

Plus you really shouldn't support YouTube, at least not in the typical way

narrow hazel
#

Isn't youtube music not allowed cuz youtube didn't want people using their api for music bots and discord cracked down on it

gritty inlet
#

Yep

#

Can't you resolve video name from link in any way that doesn't violate their tos though?

fast osprey
#

this absolutely violates tos (and the rules of this server lol)

finite salmon
gritty inlet
#

Music bot devs should just do that

#

Instead of using yt dlp or some shit

fast osprey
#

resolving the video name isn't the problem

#

redistributing the content is, which violates law in addition to tos

gritty inlet
narrow hazel
#

You can still make music bots you just gotta find a source that's legal

fast osprey
#

If the content itself is copyrighted, you are violating law by redistributing it without a license from the copyright holder. Youtube is irrelevant

finite salmon
fast osprey
#

Even if it's royalty free, you may not be violating copyright law but you are violating youtube TOS

gritty inlet
fast osprey
#

If you have royalty free music you got yourself, you can distribute it. That's the only case

tropic kelp
#

!rule 5

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.

tropic kelp
#

might apply

gritty inlet
#

Some bots/apps like Rythm (Rythm now) genuinely buy licenses

#

But most don't. And that's a problem

#

I bet a thousands bets none of these songs are royalty free though kekw

fast osprey
#

spotify listening sessions exist, compensate the artist, and have vastly better audio quality than a shitty discord call shrug

gritty inlet
#

Listen Together is an underrated feature, indeed.

#

Don't try to argue about copyright

#

Bots can do 1% of what users can in terms of normal client things

#

So no it wouldn't work

tropic kelp
#

So you mean a bot that does as if it was a user? Im pretty sure thats against the tos

gritty inlet
#

Not if you use a bot token. But again you'd be very limited

#

It can be done very partially

tropic kelp
#

So just a wrapper around the whole discord GUI? Good luck with that, especially in Python

gritty inlet
#

First of all, yeah this would not be a Python thing
Second, it's too much work
Third, it's too much work just to not being able to do much

#

tkinter is so ass in tasks

#

better just not try to do this or at least use javascript

tropic kelp
#

Well yeah, still i think you should really think about this once more.

marble comet
#

there are many such open source project u could reference from though

fast osprey
#

even if not against the letter of the tos, that would absolutely be a misuse of a bot account

gritty inlet
#

Sketchiest looking container xd

#

Anyway no idea what you mean by connecting to html

#

HTML is just a format, not code

narrow hazel
#

Looks like a website made by AI

#

I know because it looks like a huge companies email login

gritty inlet
#

Yes but at the end of the day you'd be using javascript

#

Pairing html with python is shit

fast osprey
#
  1. Do not impersonate other Applications, Discord employees or partners, or Discord services. This includes deception via your and your Applicationโ€™s account and identity.
gritty inlet
fast osprey
#

Reasonably discord isn't going to take action against a rando using a bot to send their own messages because tee hee

#

but it is completely against the spirit of the distinction between account types

gritty inlet
#

I just think it's useless

marble comet
fast osprey
#

Custom clients using user tokens are very explicitly against the TOS

gritty inlet
#

That one does?

marble comet
#

discord moderators have come forward multiple times in the official discord community server saying they don't care

fast osprey
#

Will I get banned for using Swiftcord/Is using Swiftcord illegal?
Nobody really knows what Discord's official stance on unofficial clients is. However, hundreds of people and I have been using Swiftcord for quite a while, and nobody has been banned to date. I do not take any responsibility for account bans due to the use of Swiftcord, whether direct or indirect, although there's a very low possibility of that occurring. I recommend trying Swiftcord with an alt if possible.

What a joke of an answer

#

individual opinions don't override tos

gritty inlet
marble comet
gritty inlet
#

-_- you DONT

marble comet
#

which means?

gritty inlet
#

Are you sure you know the difference betwen bot token and user token

#

Why would you need a custom client for a user

marble comet
#

๐Ÿค” what does bot token have to do with this

gritty inlet
#

You already got a client right now

marble comet
#

why people want alternative clients? uh most likely because discord is electron

#

and probably because they want client features discord currently doesnt offer

gritty inlet
#

Oh so it is vencord-like?

#

The design looks so shitty icel

#

Anyway that violates tos

marble comet
#

ish, vencord modifies the existing discord client, what i sent is a fully custom client built from scratch using native widgets

gritty inlet
#

i dont have something against people who use anything but it'd be smart from those people to not share that they do

fast osprey
gritty inlet
#

Please man don't try to argue how it is not against the tos because it just is ๐Ÿ˜น again you'd be smart to not tell people you use it

marble comet
#

it neither smart nor dumb there is no recorded case of discord banning custom clients and official staff members at discord have come forward saying they couldn't care less, but yes it's written in their ToS to not modify the client

#

which makes legally sense, but in practice discord doesn't care so why should the users

gritty inlet
#

Why does it matter what the staff members say? Staff members do NOT mirror the tos neither can you trust them for legal matters

fast osprey
#

It's a pretty moot point because this isn't bot related, or python related, and this server's rules specifically say not to violate service TOS regardless of whether you personally think it's okay or not

marble comet
gritty inlet
#

You are already wrong by saying staff are the true representation of the platform and its rules

marble comet
#

the employees are sure representitive of the company they work for, which is why they are hired

fast osprey
#

People are hired for specific reasons. Not every employee has the authority to communicate binding policy

#

that's like saying a grocery store cashier can just tell you it's okay to take whatever you want

gritty inlet
#

I said representation of the platform and its rules, not representitives

marble comet
#

if they dont have the authority and make such claims then they would be legally liable for any act based on said claims

gritty inlet
#

Yeah?

fast osprey
#

TOS aren't legally binding

marble comet
#

im not speaking of ToS

fast osprey
#

This whole conversation has been about tos

marble comet
#

i'm talking about an employee making a claim which then a user could act against

#

and if that act happens to fall under unlawful terms then the employee in question would be held liable

gritty inlet
fast osprey
#

Nobody in this conversation has made a point about the likelihood of being acted against, but you're fixated on that for some reason

#

that is irrelevant

marble comet
#

multiple official discord moderators have legitemetialy come forward saying they don't care, i see no reason for a user to care themselves at that point, regardless of what is stated in a ToS

fast osprey
#

That is your choice to make, but again it is against tos and everything I said stands

marble comet
#

yes im not disagreeing

fast osprey
#

it is irrelevant to this channel, irrelevant to this server, and against the rules

gritty inlet
#

๐Ÿฆ—๐Ÿฆ—for now here's a random snippet

import asyncio

def to_thread(func) -> ...:
    """
    A decorator to automatically turn synchronous functions to asynchronous
    by running them in a separate thread with `asyncio.to_thread`.
    """

    def wrapper(*args, **kwrags):
        return asyncio.to_thread(func, *args, **kwrags)
    
    return wrapper

@to_thread
def sync_func():
    print("Hello World")

async def main():
    await sync_func()

asyncio.run(main())```
fast osprey
#

dope

timber dragon
#

hot

#

but where paramspec

#

or for 3.12+

import asyncio
from typing import Awaitable, Callable

def to_thread[**P, T](func: Callable[P, T]) -> Callable[P, Awaitable[T]]:
    async def wrapper(*args: P.args, **kwargs: P.kwargs) -> T:
        return await asyncio.to_thread(func, *args, **kwargs)
    return wrapper
gritty inlet
#

Meh was too lazy for any typing

gritty inlet
timber dragon
#

good question

#

oh probably because minver is 3.8 for jishaku

gritty inlet
#

And it actually doesn't matter if you make wrapper async or not

narrow hazel
#

im so confused why it's only getting 2 of my roles neither one is the conditional

narrow hazel
#

thats everything involving the issue

#

anything else just continues the action of the component

#

I have 4 roles the roles its printing is Early Support and the @ everyone role. The conditionals is the manager and mod role

#

but it's only printing 2 roles even tho I put a print above the conditional

narrow hazel
#

I used names instead of IDs

#

still only 2 of the roles

vast gale
narrow hazel
#
 for roles in interaction.user.roles:
     print(roles.name)
     if roles.id == (1424179881880584232, 1413800644787310592):
        pass
     else:
        pass
          ```
#

thats the whole code

#

I've tried a few different stuff

#
     print(roles.name)
     if roles.id == (1424179881880584232 or 1413800644787310592):
        pass
     else:
        pass```
           ```for roles in interaction.user.roles:
     print(roles.name)
     if roles.id in (1424179881880584232 or 1413800644787310592):
        pass
     else:
        pass```
merry cliff
vast gale
#

What else is in that loop?

narrow hazel
#

nothing

vast gale
#

Where you create the embed

narrow hazel
gritty inlet
#

What are you expecting lol

narrow hazel
#

It keeps going to else

gritty inlet
#

You only let 2 roles be printed

narrow hazel
#

when I should

gritty inlet
#

Oh you mean it doesn't print that text?

narrow hazel
#

It should be letting the interaction continue when the button is pushed if you have either of the 2 roles

gritty inlet
narrow hazel
#

when it's printed theres only 2 roles in the terminal

gritty inlet
#

---__---

#

The tuple has only 2 role IDs......

narrow hazel
#

im getting tired of explaining the same way

  • You click the button
  • It loops your roles
  • If you have 1 of the roles it continues
  • Else you're denied
  • The print statement only shows 2 roles in the user list
#

I have 5 roles total

gritty inlet
narrow hazel
gritty inlet
#

No, show the code that prints

#

prints

narrow hazel
vast gale
# narrow hazel

the second time this loop runs interaction.response.send_message is raising an error. That happens after the second print statement.

Somewhere your error handling is eating that exception and not printing it to console.

gritty inlet
#

I'd just like to see the lines in the code where he prints the roles

narrow hazel
#

it's right above the conditional

vast gale
#

Once you sent your full code it was a lot easier to figure out the error, so when people are asking for your full code it's really Important to provide it.

vast gale
gritty inlet
#

hmmm

vast gale
#

It is a full member object. Using the cache may make problems worse and would rely on the cache they may not even be enabled.

gritty inlet
#

Don't do an interaction response inside an iteration unless you stop the iteration right after (return await ...)
@narrow hazel

narrow hazel
#

oh so just move it back to the for loop

gritty inlet
#

no, if the rols is in the tuple, do return await to stop the iteration

#

add return before the await

narrow hazel
#

Finally

gritty inlet
#

And move the last statement to outside of the loop

#

Otherwise it's unreachable

quick gust
narrow hazel
#

Because it works now

gritty inlet
#

yea that too lol

narrow hazel
vast gale
#

It doesn't. It only checks the topmost role you have

#

I wonder if you can do a bitwise and with roles hmmm

gritty inlet
#

Why though, his logic is fine

narrow hazel
#

Yeah this works

#

just moved the condition outside the loop

gritty inlet
#

And you need to stop iteration when you respond

narrow hazel
#

well clearly it still works

vast gale
gritty inlet
narrow hazel
#

thanks zenith

vast gale
#

You need to check all of the allowed roles with the roles the user has, breaking at the first match, and falling back to no permissions error if the user doesn't have either of the roles

gritty inlet
#

His code almost does that correctly

vast gale
#

Pseudo code:

For role in roles
  if role in user.roles:
    break
Else:
 # handle not allowed
 Return # very important!!

# handle allowed
gritty inlet
#

I mean that else is indented wrong

#

Matter of fact you don't need it at all

gritty inlet
vast gale
# gritty inlet I mean that else is indented wrong

It's not. You can have an else on a loop which only executes if you didn't break out of the loop earlier.

This code flow I've illustrated follows code standards including guard clause ifs, which prevents nesting all of your code inside a bunch of checks

gritty inlet
#

Whatever you put after the loop will happen, with else or without, wouldn't it

#

Ah i get it actually

vast gale
#

!e The break prevents it from happening.

for i in range(5):
  print(i)
  if i == 3:
    break
else:
  print("didn't break")

print("6")
gritty inlet
#

Yeah thought so

unkempt canyonBOT
vast gale
#

I'm on mobile don't judge my typing lol

gritty inlet
#

Personally I'd just return instead of break

quick gust
#

Wouldn't this work?

for role in user.roles:
  if role.id in (role_id1, role_id2):
    # allowed logic
    return
  
# not allowed logic
gritty inlet
#

That's what I'd do, yes

narrow hazel
#

doesnt the comma mean and?

gritty inlet
#

No

#

List/Tuple items are comma separated

#

He just used placeholders

narrow hazel
#

oh

#

I need to start learning using a DB. I just spent like 10 minutes trying to figure out why a button wasn't working. turns out my persistant buttons doesnt save anything except the buttons ๐Ÿ’€

gritty inlet
#

I started using a db not too long ago

#

But I don't exactly get what you mean

narrow hazel
#

because I save None to the persistant buttons