#discord-bots

1 messages · Page 407 of 1

timber dragon
#

You didn't have to respond ya know..

proper halo
#

Hi, I have a question, how can I split commands in files? I want to have each command on a file

fast osprey
#

That's egregious

#

Id recommend questioning where you got the idea that is good practice

#

Either way, a bot isnt any different than any other python program. You can put whatever definitions you want in a file, then import those definitions in another file. Works for commands too.

Libraries like discord.py have an extension system which makes loading and reloading of those modules easier, but it's not required

unkempt canyonBOT
#
Available tags

» args-kwargs
» async-await
» blocking
» botvar
» class
» classmethod
» codeblock
» comparison
» contribute
» customchecks
» customcooldown
» customhelp
» dashmpip
» decorators

fast osprey
#

config formats are relatively irrelevant

brave niche
#

dotenv influences your environment variables directly, and that could include 'system' ones vs. ones you care about in your app. JSON has the advantage of being fully contained in your app, and only able to do what you decide it should do.

stark ingot
#

^

brave niche
#

So you need to trust your dotenv files more than your JSON files arguably

viscid hornet
brave niche
#

That too, yeah

fast osprey
#

then why are you still working on it

vocal kettle
fast osprey
#

....sure

#

anywho, both python3 and pip are ambiguous to what python installation they're hitting. They're most likely hitting different installations

#

on windows, any python command line commands IMO should use py, both for running code and interacting with pip

tender bobcat
#

Idk if py handle that, but I would leaning towards using python for venv instead

fast osprey
#

they are presumably not in a venv if they are encountering this, but yes

tender bobcat
#

Well
Idk it it's my bias but for me windows python is just harder to use

unkempt canyonBOT
#
Concurrency in Python

Python provides the ability to run multiple tasks and coroutines simultaneously with the use of the asyncio library, which is included in the Python standard library.

This works by running these coroutines in an event loop, where the context of the running coroutine switches periodically to allow all other coroutines to run, thus giving the appearance of running at the same time. This is different to using threads or processes in that all code runs in the main process and thread, although it is possible to run coroutines in other threads.

To call an async function we can either await it, or run it in an event loop which we get from asyncio.

To create a coroutine that can be used with asyncio we need to define a function using the async keyword:

async def main():
    await something_awaitable()

Which means we can call await something_awaitable() directly from within the function. If this were a non-async function, it would raise the exception SyntaxError: 'await' outside async function

To run the top level async function from outside the event loop we need to use asyncio.run(), like this:

import asyncio

async def main():
    await something_awaitable()

asyncio.run(main())

Note that in the asyncio.run(), where we appear to be calling main(), this does not execute the code in main. Rather, it creates and returns a new coroutine object (i.e main() is not main()) which is then handled and run by the event loop via asyncio.run().

To learn more about asyncio and its use, see the asyncio documentation.

unkempt canyonBOT
#
Mutable default arguments

Default arguments in Python are evaluated once when the function is
defined, not each time the function is called. This means that if
you have a mutable default argument and mutate it, you will have
mutated that object for all future calls to the function as well.

For example, the following append_one function appends 1 to a list
and returns it. foo is set to an empty list by default.

>>> def append_one(foo=[]):
...     foo.append(1)
...     return foo
...

See what happens when we call it a few times:

>>> append_one()
[1]
>>> append_one()
[1, 1]
>>> append_one()
[1, 1, 1]

Each call appends an additional 1 to our list foo. It does not
receive a new empty list on each call, it is the same list everytime.

To avoid this problem, you have to create a new object every time the
function is called:

>>> def append_one(foo=None):
...     if foo is None:
...         foo = []
...     foo.append(1)
...     return foo
...
>>> append_one()
[1]
>>> append_one()
[1]

Note:

  • This behavior can be used intentionally to maintain state between
    calls of a function (eg. when writing a caching function).
  • This behavior is not unique to mutable objects, all default
    arguments are evaulated only once when the function is defined.
dusk pelican
#

hello, I am new to python. Why are you guys building discord robots, when there are millions of them?

#

Can I also build a robot, but what if the idea is taken?

jaunty cape
fast osprey
#

A few responses:

  • Bots layer on several python concepts simultaneously. They are not for beginners. You can choose to do it anyways, and I'm sure a lot of people in here will say "it's fine bro I learned building a bot", but unless you're a genius you are going to get frustrated and make very slow progress trying to learn several advanced concepts simultaneously
  • There are a ton of bots, and 95% of the ones I see people build here are uninspired, recycled ideas. But people can still do it for fun, or to make minor tweaks for personal servers.
  • You can do whatever you want, nobody will stop you just because it's a copy of functionality
  • That said, there's still tons of unexplored ideas that people seem allergic to for some reason
brave niche
#

Yeah, still haven't seen an interesting Code Climate integration with Discord for example, and there's a ton of easy stuff to do there

dusk pelican
#

Do you guys understand completely what the module discord.py does and how its working? Would be a start

brave niche
#

I mean, yeah? Are you familiar with asyncio? That's really what discord.py is built around.

#

You could argue it's a 'typical' network library using asyncio.

dusk pelican
#

I dont think it is just asyncio since SolsticeShard just said it has several python concepts

#

Anyway, I was curious what it is all about discord robots

jaunty cape
#

You need to know Object-oriented programming

brave niche
#

Well it depends on your perspective, yeah; you could say you need to understand socket programming also, if you want to understand what it's actually doing for you.

#

But asyncio is how it 'runs'

#

I mention it first because you can't even follow the code flow until you understand it.

dusk pelican
#

I mean the documents for discord api seems really understandable for me as a beginner. Just curious and reading

brave niche
#

Sounds like you're on the right track.

fast osprey
#

The main things to understand are OOP and async programming generally, plus general ability to debug and read docs

brave niche
#

Knowing vaguely what a WebSocket is is probably useful too.

fast osprey
#

I'd argue that modern libraries pretty much completely abstract you away from any sockets or network issues, it's good to know but you can implement a fully featured bot without it

jaunty cape
#

Also learn to stop hardcoding your tokens

#

Because apparently that’s a very difficult concept for beginners

brave niche
#

I guess it sorta makes sense; you have to learn how to make "variables your code can see" suddenly depend on the outside world, and a lot of people probably just barely got their first script.py working.

hearty basalt
#

?tag cogs

novel apexBOT
#

This is not a Modmail thread.

hearty basalt
#

whoops

tender bobcat
dusk pelican
#

are you now understanding everything?

fast osprey
#

it's a constant learning process lol

#

I do community help for discord.py and I've done python in the industry for like 7 years now, always something new that you don't get the first time

fast osprey
#

!d discord.TextChannel.threads

unkempt canyonBOT
fast osprey
#

try it and see what it gives you

sick birch
#

what do you consider an active thread

#

you have the discord.Thread.archived and discord.Thread.locked properties respectively

#

you can apply a filter to a discord.Thread list to only get what you want

stark ingot
#

It might be more economical to get all active guild threads and then filter by channel ID

hushed galleon
unkempt canyonBOT
#

discord/channel.py line 389

return [thread for thread in self.guild._threads.values() if thread.parent_id == self.id]```
timber dragon
#

Archived threads aren't cached iirc

slate swan
#

Hey can someone show me how to code with Python?

fast osprey
#

Bit of a tall ask to start from scratch. Have you done any self learning with the resources available?

fast osprey
#

There are lots of free and quality self-guided resources for learning the basics

slate swan
#

Where can I find them?

stark ingot
#

!res

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.

barren veldt
#

is it possible to run a discord bot 24/7 in a VM and when a question is asked pinging the bot it reaches out to a VM running a LLM and gets an answer from that all this free of cost?

keen dome
#

Hello, has anyone used seleniumbase before? I'm trying to automate appointment booking but I keep hitting 401 often and it logs me out

stark ingot
#

You will probably have better luck asking in the help channel instead of the discord bot channel: #❓|how-to-get-help

keen dome
#

I was wondering the same thing

stark ingot
# barren veldt is it possible to run a discord bot 24/7 in a VM and when a question is asked pi...

You could listen to the Message Create event. Then check if the message contains a mention to your bot. Although it would be more resource efficient if you used a slash command like /ask text:abc. Then you can use an API or localhost a LLM (just make sure it follows TOS such as not training on the input and making sure you have the users explicit consent). For the free of cost part you can localhost on your own hardware for the cost of electricity. You can also use free trials from big name hosting companies like oracle but these will not be the highest quality. My guess is self hosting the LLM will be the only way to get unlimited free responses

smoky sinew
#

If u do host it locally you'll have to use something with a good gpu

timber dragon
#

@austere whale lol

sick birch
#

?

#

oh you're reporting it

dusk pelican
#

I think this person does. Some crypto thing or so. I dont remember

#

can you send it to me, I want to read what this person posted

fast osprey
#

It's just boring uninspired grifting

dusk pelican
# fast osprey It's just boring uninspired grifting

Hey SolsticeShard, I read a good amount of the discord api and it is very interesting. But I dont understand the snowflake id, if you may give further explanation? Is a channel id also a snowflake id? Has a every component a snowflake id?

dapper ocean
#

Anything with id attribute is a snowflake

#
@runtime_checkable
class Snowflake(Protocol):
    id: int
stark ingot
#

Except components which have a custom_id which is a string that can be 100 characters long. In the components update there is also a new id field which is not a snowflake either. It is an 32 (or 64? Cant remember) unsigned int that can be used for whatever the dev wants.

#

Channels/threads, users, guilds, custom emojis, messages, roles, forum channel tags, etc are all snowflakes

#

I think this image is from the docs but just in case you did not see it

fast osprey
#

It really depends what you actually care about in regards to snowflakes. It's just a method discord uses for generating its ids

tender bobcat
#

also discord way of saying
there are nothing there and don't even brother decoding this except getting the timestamp of generation

fast osprey
#

It's an identifier

tender bobcat
#

well, maybe someone think it have some random data and try to decode it for whatever reason

#

or maybe I just overthinking and no one would think to do this if discord doesn't post the structure of a snowflake

fast osprey
#

I mean I don't know who else is in the habit of seeing random long numbers and trying to "decode" them

fast osprey
#

Make a bot that gives people ideas for bots

dusk pelican
#

I have seen in the docs components. Maybe you could do a game in there. Like guessing game or hang man.

dusk pelican
fast osprey
#

you would not use that in the context of discord

dusk pelican
fast osprey
#

you would not use requests in an asyncio based application

#

which all modern discord libraries are

#

aiohttp is the async equivalent

dusk pelican
#

Huh?

#

Ah ok, got it. it is blocking is that what you mean?

fast osprey
#

yes

#

aiohttp is what you'd use to make nonblocking http requests, which is the library that discord.py and others use under-the-hood to make requests to discord

dusk pelican
#

Sounds great

jaunty cape
#

Make a bot that takes Roblox player Vector3 data from an in-game drone, converts it to a numpy array, and then launches a bomb at that player

viscid hornet
#

isn't that just a graph?

#

you could probably just handwrite the connections and then make a parser for them: ```yml
hello - i'm, Kuba, friends
i'm - Kuba
to eat - strawberrie
Kuba - likes
likes - strawberries, to eat

#

sure, why not

fast osprey
#

don't use json to save generated data, period

viscid hornet
# viscid hornet you could probably just handwrite the connections and then make a parser for the...
@dc
class node:
    value: str
    children: list['node'] = []

    def add(*o: 'node'):
        self.children += o

    def __hash__(self):
        return hash(self.value)


def interpret(graph: str):
    cache: dict[str, node] = {}

    for line in graph.split('\n'):
        left, right = line.split(' - ')
        right = right.split(', ')

        if left in cache:
            leftN = cache[left]
        else:
            leftN = node(left)
            cache[left] = leftN

        children = []

        for ch in right:
            if ch in cache:
                n = cache[ch]
            else:
                n = node(ch)
                cache[ch] = n

            children.add(n)

        leftN.add(*children)

    # something here, idk
full ether
viscid hornet
#

i'd be simple and have a simple from | to table

viscid hornet
full ether
#

yeah but with networkx or such you could navigate the resulting graph to make the response chains

viscid hornet
#

to make an apple pie you must first invent the universe

#

"to make an apple pie you must first invent the universe"
"!pip universe-inventor - there's a lib for that"

viscid hornet
viscid hornet
#

lmao dude's making an LLM by hand

#

keras get out the way

#

we got trev tryna make chatgpt manually

lime osprey
#

alr im really slow but why cant i pip install?

#

"The term 'pip' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again."

jaunty cape
#

And Ubuntu is the most common distro so I’m going to assume that as well

lime osprey
#

yeah im on linux

jaunty cape
#

sudo apt install python3-pip

lime osprey
jaunty cape
#

Huh.

#

Try running pip3 instead of pip

lime osprey
#

yeah it doesnt work

jaunty cape
#

I had the same issue before on arch

#

Give me a moment

lime osprey
#

okay

jaunty cape
#

run curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py\npython3 get-pip.py --force-reinstall

lime osprey
jaunty cape
#

What the

#

I swear that worked for me the first time

#

Well if all else fails just stick with python3 -m pip

lime osprey
#

this is weird bc ive done pip install b4 i hard reset my laptop

#

idrk whats happening

lime osprey
#

"Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Apps > Advanced app settings > App execution aliases."

jaunty cape
#

???

lime osprey
#

i have python downloaded 😭

jaunty cape
#

Btw this discussion doesn’t really belong in #discord-bots just so you know

lime osprey
#

oh..

jaunty cape
jaunty cape
#

Yeah that should not happen on Linux

viscid hornet
#
  • MS commands on linux?
dusk pelican
viscid hornet
dusk pelican
dusk pelican
viscid hornet
#

sure, devving on windows is kinda hard but only for lower-level programming, from what i've seen

upper gorge
unkempt canyonBOT
fast osprey
stark ingot
wise mica
#

yea thats a lot of code to check for errors. from my quick look through i didnt see where you were creating most of your mongo documents. Like rakeback stats returns 0s but doesnt create them for the user

jaunty cape
#

Bruh 78 KB of code

#

That’s like a thousand lines at least

woeful hill
#

is subclassing View that hard

#

why would people still use Item.callback = callback_func

patent hull
#

Because they’ve seen other people, have been told so, or have seen YouTube tutorials that do that

woeful hill
#

pretty sad that people rely on youtube tutorials for everything and when the problem they want to solve isnt on youtube they just quit because theyve learned minimal to nothing

timber dragon
#

It's not always tutorials

#

Some people find is easier and more convenient

#

Instead of a ""whole class"" and passing state around etc

timber dragon
#

Why are we caring about KB's now

finite salmon
#

The psychological superiority one gains from observing their program's size grow, giving them a higher mental status over others to flex; regardless of the potentiality of just writing extremely verbose and inefficient program is inexplainable.

merry cliff
#

it's actually all comments!!!!

woeful hill
#

string

#

anyways should we care that much for tens of KB files

#

not like your storage is gonna goes out with that

dusk pelican
#

The only thing that cares is, if the Code ist well written and for sure well documented

#

It is like, oh I have written a 10 Page Essay, but the Essay is badly written.

stark ingot
jaunty cape
#

Doesn’t that mean your complexity is just O(n^3) every time you call that function

grave sandal
#

Is this that vibe coding everyone's been talking about? 😂

fast osprey
#

It's people hyperfixating on random things that don't matter, not really worth entertaining

jaunty cape
dusk pelican
jaunty cape
dusk pelican
#

good one

patent surge
#

Heyo gais

tender bobcat
shrewd ivy
#

could anyone help me code

dusk pelican
#

ok

quick gust
#

why can the bot not ping roles as a response to an interaction but can otherwise?

stark ingot
#

Do you have allowed mentions set correctly?

quick gust
#

yep, I tested it in the same channel with the same bot and the same role. The first image is me sending the message through the bot through jishaku and the second is of a command
Also, individual user mentions work fine

jaunty cape
#

@jaunty cape

quick gust
#

No the ping is sent before the edit

jaunty cape
#

Nvm

fast osprey
#

are you deferring?

quick gust
#

Yeah

#

Deferring then sending the message using ApplicationCommandInteraction.send (disnake)

fast osprey
#

deferring and then following up counts as an edit

quick gust
#

I see, alright thank you

quick gust
#

no progress

    async def sprint_start(
        self,
        interaction: ApplicationCommandInteraction,
        duration: str,
        ping_role: disnake.Role,
        start_in: str = "60s",
    ) -> None:
        """
        Start a reading sprint

        Parameters
        ----------
        duration : str
            The duration of the sprint
        ping_role : disnake.Role
            The role to ping when the sprint starts
        start_in : str, optional
            The time after which the sprint will start, by default 60seconds
        """
        await interaction.response.send_message(content=ping_role.mention)```
jaunty cape
#

Dang I just witnessed disnake in the wild

quick gust
#

this is crazily annoying

quick gust
#

nevermind I got it

timber dragon
#

What was it

dusk pelican
#

So far I understand fully what the concept of discord api is

viscid hornet
dusk pelican
#

The gateway is a socket connection that gives live updates what happens inside discord and the http requests are like to respond to these events ping pong

#

Please correct me

fast osprey
#

you can hit the api whenever you want

#

it doesn't have to be tied to any event happening

dusk pelican
fast osprey
#

"interesting" is pretty divorced from explaining how something works

#

There are some cases where these things are more strictly tied (i.e. getting an interaction through the gateway and responding through the API) but otherwise they're entirely separate

dusk pelican
#

I think the gateway and the http requests make it interesting together

#

Getting an event and then parse the informations into the http requests like channel id

fast osprey
#

I mean sure, but that's an implementation detail you choose and not how the system fundamentally works

dusk pelican
#

Ok then my reading about discord api docs were not good

#

I give up

fast osprey
#

It's a pretty minor detail lol

dusk pelican
#

When I send a text into this channel is it also a http request or no?

fast osprey
#

It is

dusk pelican
#

Wait

#

Explain furthee

fast osprey
#

how

dusk pelican
#

So when I click the button it sends a post http request ?

fast osprey
#

Sure

#

that's the protocol your local client uses to send requests to the discord servers

dusk pelican
#

So every chat app telegram whats app do this?

fast osprey
dusk pelican
#

What? You dont know

fast osprey
#

I don't use those things

#

and I'm not going to speculate how they work

dusk pelican
#

Ok fair enough

#

The discord docs are so well documented every discord worker needs a raise of 500%

stark ingot
#

Discord docs are really good, a combination of staff and community work

tender bobcat
#

As far as I concern
Client --HTTPS--> Discord --Websocket--> Bot(event)

hexed tinsel
#

i think the discord client uses websockets too right?

sick birch
#

it does

tender bobcat
#

But e.g. if you send a message it will be HTTPS instead?

fast osprey
#

I believe so, but given that you should never be handling a user token yourself it shouldn't matter

tender bobcat
#

I mean you can also just replace client -> bot, given that the bot is the one triggering the event

fast osprey
#

those are entirely different questions

#

bots do send http requests to post things to discord, yes. I believe the only exception is presence that's set through the websocket but I could be wrong

sick birch
#

both for users and bots

tender bobcat
#

Weird on requesting member and requesting soundboard specifically is in ws

sick birch
#

it might just be because they take a while

tender bobcat
#

But soundboard is literally like emoji but for sound

sick birch
#

yeah idk why thats on there

fast osprey
#

oh right right, especially for large guilds members get sent in chunks when you request them

#

and voice stuff is in its own protocol

sick birch
#

yeah but get soundboards just returns some metadata about the soundboard, and since the number of sounds per server is limited it shouldn't be taking that long

quick gust
#

it was the allowed mentions not being set properly, not the deferring -> sending message

timber dragon
#

Aha good to know

quick gust
#

I have a guild_user_relation table which maintains relations between user <-> guild
I need this because my bot hasn't been approved for members intent
Now I need to remove a specific relation whenever a member leaves a server to avoid outdated data
Adding a relation is easy because I just add it whenever the first command is ran by a user in a guild, but I'm not sure how I can remove obsolete relations too.

dusk pelican
tender bobcat
quick gust
#

well yes theres on_member_remove but I need members intent for it

quick gust
tender bobcat
#

Great lmao

dusk pelican
#

who is they?

quick gust
#

Discord...

dusk pelican
#

ah

tender bobcat
#

Discord team that approve the usage of intents

fast osprey
#

what functionality do you have which needs to know every person in a guild, even the people who have chosen not to interact with your bot

quick gust
#

Never said I do?

dusk pelican
#

I dont know how to handle that, maybe solsticeshard can or who is expert on this?

#

we need an expert to answer that question

tender bobcat
#

I mean, you could do periodic scan, depends on the size of db ig

quick gust
#

periodic scan okay but check that against what?

dusk pelican
#

are intents to subscribe to discord events that are sent throufgh gateway? correct me

tender bobcat
#

And if it doesn't exist, it would give error (not in guild)

dusk pelican
#

but why all users in database?

fast osprey
#

If you don't need to know people who don't interact with your bot, then why do you want the intent

quick gust
tender bobcat
fast osprey
#

also depending on what you're actually trying to do, you may not need this data at all persisted

#

Data doesn't become "outdated" when you don't actually need it in the first place

quick gust
fast osprey
#

So then put differently, why does your database care about what guild a user is in

tender bobcat
quick gust
#

it's alright friend I'll go with @tender bobcat's suggestion, thank you

dusk pelican
#

but why should every user in a guild memorized in a database? what is the functionality behind it?

tender bobcat
#

Just so you know the operation is expensive and don't do it too frequently

quick gust
#

having a sorting function for a command which allows you to read reviews submitted by bot users
you can sort by "guild members only"
so it will display reviews only from the guild members where the interaction took place

tender bobcat
#

It's just need to remove if the user leaves the server
It doesn't add automatically if the user join the server

fast osprey
#

Then the guild is a property of the interaction not the user

#

X user left a review in Y guild doesn't change no matter what that user does

tender bobcat
#

?

quick gust
#

I think you're confused as to what I want, that's okay maybe I haven't explained well but my question has been answered

fast osprey
#

lol sure

fast osprey
tender bobcat
#

X user create a review on Y guild
When user X leave the server, the sorting functionality must allow to not show the user review when "Guild Member only" options is used

tender bobcat
quick gust
#

its alright @tender bobcat we can leave this topic, I belive they're just confused anyways I have got what I needed

fast osprey
#

So what is the endpoint you're proposing that will tell you if someone is in a guild without the members intent?

#

I don't think I'm confused here

#

and it's pretty condescending to insist I am without actually responding to my points

tender bobcat
#

The top one
And the bottom one is what restricted, but top one seemingly isn't

quick gust
fast osprey
#

You can say that without insisting I'm "confused". That is condescending. You could choose not to say that, but you did

quick gust
#

Welp my bad if it came off as condescending 🤷‍♂️

fast osprey
#

You didn't "come off". You were condescending

#

you chose your words specifically

quick gust
#

Okay

tender bobcat
fast osprey
#

I didn't say it did

#

I was asking why if it did, which was heavily implied by their initial phrasing

quick gust
tender bobcat
#

It was never implied

#

That's just your assumption, and it's also incorrect

hexed tinsel
fast osprey
#

It was implied. Why would you say "I wasn't approved for members intent" unless you were implying you requested it.

#

This was again clarified, but you can't look at that sentence and read it another away

tender bobcat
#

?
Member intent doesn't have a singular use

fast osprey
#

I didn't say it did?

tender bobcat
#

It's clearly indicated that they want to listen the member remove event

quick gust
#

damn what have I started

tender bobcat
#

And you made the incorrect assumption after clearly stated

hexed tinsel
fast osprey
#

It was after they clarified jesus

quick gust
fast osprey
#

literally goldfish levels of conversation context

hexed tinsel
#

lmao mood

tender bobcat
#

Well, I made my point
There are nothing implied in the first message and clearly stated
I have something else to do now, good bye

fast osprey
#

Either way, the endpoint works in singular instances but is not designed for what you're suggesting they do. The rate limits get clamped down pretty quickly when it becomes apparent that it's being used to bypass the members intent

hexed tinsel
#

yeah that's a good point

dusk pelican
#

SolsticeShard his point is, why they need to know every user in a guild, when not interacting with the bot

quick gust
#

oh god lemon_sweat

fast osprey
#

and they have clarified that isn't what they're trying to do, which is fine

hexed tinsel
dusk pelican
#

ok. end of this topic period

quick gust
#

watch this conversation come back alive hours later when someone else reads it lol

dusk pelican
#

I go eat now

hexed tinsel
#

i've done that before. stir shit in a discord server (not without good reason, mind you) and then get pelted with responses hours later from people scanning it and totally missing the context

#

it happens though

quick gust
fast osprey
#

Really either a) you justify to discord you need to know who is in a server or b) change your functionality such that it's not built on top of knowing whether or not someone is presently in a server but only with the context you're given at the time of interaction. The fetch member endpoint will work in small cases, but the rate limit is dynamic/unpublished and I've seen plenty of cases of endpoints getting tightened

quick gust
#

Makes sense

tender bobcat
#

Randomly thought of an idea
Probably not recommended tho
Listen to messages event and have a timer for each user
Update the timer if they send a message in the server
And maybe check the user if timer>some large value

Again, not recommended but possible

quick gust
#

nah that requires message content intent

tender bobcat
#

You also don't have that? Oh well

quick gust
#

no, that intent I actually don't need at all

tender bobcat
#

Well
I'm out of idea maybe

quick gust
#

That's alright, thanks for your help

fast osprey
#

you can get messages without content, but yeah this is all approximating a question discord has decided you don't need the answer to

quick gust
#

also too hacky I don't like it

quiet ocean
grave sandal
#

Spiciest channel in python discord server

grave sandal
fast osprey
#

The thing is, as far as discord is concerned with intents it's not just what people say they'll do with the intent, but what they could do with it. While they clarified that they intend to only track when people leave a server, that also inherently comes with being able to determine all people in all the servers their bot is in at any time

vapid parcel
#

Can bots send voice messages?

jaunty cape
#

no

vapid parcel
#

Ok.

wanton current
#

Well, technically, but not very straightforward

outer elm
#

I did see some text to speech stuff in the discord api docs, but I haven't looked at it in detail. Search those docs for 'TTS' and have a look

still cove
#

I need ia boots for boxing league on discord

#

Reference of boxing league

fast osprey
#

huh

quick gust
#

what's that supposed to mean

jaunty cape
#

fr

stark ingot
quick gust
#

Could you explain? Im curious

fast osprey
#

isn't it just sending an attachment with a specific filetype?

dusk pelican
#

For Voice there is a request to the api and the you Need to Connect to a Voice Gateway

#

I think Voice works with udp Protocol rather than tcp

stark ingot
#

They are talking about voice messages, not connecting to a voice channel.
All you have to do is send a attachment with a supported file type (wav is what I used). In the attachment you can set a duration and a waveform. You also have to set the IS_VOICE_MESSAGE flag to have discord render the file as a voice message. There are some limits on other content in the emssage that IO cant remember rn tho

vapid parcel
#

I figured it was something like that, but I was on mobile when I was reading the docs

#

so I just came in here to ask cuz it would be easier than trying to read on phone ngl

vapid parcel
jaunty cape
#

I’ve honestly never heard of that before

stark ingot
jaunty cape
#

Idk tbh

#

Dude you don’t need to say wsg in every single channel

stark ingot
#
  1. Make sure you have a good understanding of python
  2. Select a library (or use the raw API but that is generally not recommended). This is a good list: https://libs.advaith.io/#python
  3. Follow that libraries tutorials/examples/docs (specifically the one the library recommends not random ones online)
dusk pelican
#

chat is tcp protocol I guess, but voice is udp protocol

grave timber
#

how can i fix this please?

fast osprey
#

what's the error when you run it

grave timber
fast osprey
#

When you run it

#

you should get an error in your terminal from python itself

dusk pelican
#

is it because your imports kinda "overlab" with python?

#

nah, I dont know

#

sry

timber dragon
#

type checker is dumb sometimes

jaunty cape
#

from Source.Commands import

#

from Source.Functions import

#

anyways can we get some hate going for the python interpreter's error messages?

❯ python3 main.py
An error occurred: near "names": syntax error

#

that's not helpful man, i have no idea where the error could have happened

woeful hill
#

Ctrl F

jaunty cape
#

Such a smart idea man

#

I really appreciate your absolute genius advice

hushed galleon
jaunty cape
cosmic palm
#

hi

copper gulch
restive grove
#

Hi

fast osprey
drifting arrow
#

So what we working on friends?

tulip tinsel
trim wind
#

Hello,

im new to python. Check my field value:

value=(
        f"[Vote]({SERVER_VOTE_LINK}) * "
        f"[Website]({SERVER_WEBSITE}) * "
        f"[Shop]({SERVER_SHOP})"
),

i wanted it to look like this:

Vote (Unordered Dot) Website (Unordered Dot) Shop

but im getting:

Vote * Website * Shop

Appreciate it! Thank you!

opal vortex
#

it’s because of the stars in the string

jaunty cape
#

Just add newlines after every value

#

Because discord doesn’t parse what you’re doing as a list

#

Ok nvm that’s bad

blissful crane
#

This one looks a bit too small, so I recommend you put it in bold **•**

bitter hill
#

been struggling with this all day, nothing but errors hopefully somebody here knows

drifting arrow
# tulip tinsel What do you mean

We're all friends here. Just curious as to what we're all working on. I havent coded in a while so need to get back into it lol

drifting arrow
blissful crane
#

Yes. But they won't be on the same line

drifting arrow
#

oh he wants them same line? :( shame

drifting arrow
#

🤔 Is there a legitimate, legal and within TOS way to get the member list of a discord server? 🤔

#

So far all I've managed to figure out is self bots (against TOS sadly) and actual discord bots, but actual discord bots require you to be invited lol

quick gust
#

sadly

drifting arrow
#

yes indeed, sadly.

#

I dont wanna risk getting banned off discord forever lol

quick gust
#

Yeah there's no "legal" way

drifting arrow
#

Alright. Lets pretend we dont care about legalities and it's simply whatever method doesnt get me perma banned lol

quick gust
#

self bots are against ToS

drifting arrow
#

i know i said that

quick gust
#

Yeah you won't get help related to that here then

drifting arrow
#

I was hoping there was a way to monitor a server without an actual bot or being in it myself and not breaking tos

quick gust
drifting arrow
#

:( well drats

quick gust
#

Unless you monitor it with your physical self, and your eyes

drifting arrow
#

Le Sigh

#

Well there goes that idea I had :(

fast osprey
#

Think about it for more than 5 seconds. How would that be remotely private or safe if any rando could just find out who is in whatever server whenever they wanted

drifting arrow
fast osprey
#

narp

drifting arrow
#

oh

hasty plume
timber dragon
#

Almost impossible with any other language

viscid hornet
viscid hornet
#

!e print(set(dir(Exception)) - set(dir(object)))

unkempt canyonBOT
viscid hornet
#

!e

try:
raise TypeError("sup")
except Exception as e:
print(e.traceback)
print(e.context)
print(e.cause)

unkempt canyonBOT
viscid hornet
#

!e

try:
raise TypeError("sup")
except Exception as e:
print(e.traceback.dict)

unkempt canyonBOT
# viscid hornet !e try: raise TypeError("sup") except Exception as e: print(e.__traceback__...

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

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 2, in <module>
003 |     raise TypeError("sup")
004 | TypeError: sup
005 | 
006 | During handling of the above exception, another exception occurred:
007 | 
008 | Traceback (most recent call last):
009 |   File "/home/main.py", line 4, in <module>
010 |     print(e.__traceback__.__dict__)
... (truncated - too many lines)

Full output: https://paste.pythondiscord.com/V7EEMDPTNQ7ZRQAAZGWHJUODLI

dapper ocean
#

you are everywhere I go

viscid hornet
#

!e
class A: ...

f = lambda x: set(dir(x)) - set(dir(A))

try:
raise TypeError
except Exception as e:
print(f(e.traceback))

unkempt canyonBOT
viscid hornet
#

!e
class A: ...

f = lambda x: set(dir(x)) - set(dir(A))

try:
raise TypeError
except Exception as e:
tb = e.traceback

print(tb.tb_frame, tb.tb_next, tb.tb_lineno)

#

oh my fuck

unkempt canyonBOT
dapper ocean
#

yikes

#

#bot-commands

#

:stab:

viscid hornet
viscid hornet
limpid sky
#

im a lot into hockey stats and i coded a bot that fetch stats from a google sheet

stark ingot
#

Nice! Next step is to use the NHL API so that you do not have to rely on a potentially outdated google sheet

limpid sky
#

dont need no api

stark ingot
#

Ah, gotcha

formal jungle
#

hey does anyone know how I should / could verify my discord bot as someone under 16? Would I need to ask a parent, or what would be needed

timber dragon
formal jungle
drifting arrow
limpid sky
#

Added a command that updates this message every time a new score is posted

stark ingot
fast osprey
#

Arguably, someone who isn't an adult really should not be operating an application at that scale

formal jungle
#

how come

#

i mean verification is only 100+ servers

fast osprey
#

A kid doesn't need to be managing anything that affects random people they don't know at any scale

#

Anyways, this is the relevant clause from the dev tos:

You also confirm and agree that (i) you are at least 13 years of age and meet the minimum age required by the laws in your country, and (ii) if you are not old enough to have authority to consent to the Terms in your country, that your parent or legal guardian must agree to the Terms on your behalf. If you are a parent or legal guardian, and your teenager accesses or uses the APIs, then the Terms also apply to you and you are responsible for your teenager’s activity. Please read all the Terms carefully.

(The Stripe identity requirements at verification are separate)

opaque void
#

was the bot to study coding?

burnt quiver
#

?

brazen crane
fast osprey
#

The exceptions do not make the rule. Children very rarely cannot comprehend fully the data privacy laws they are agreeing to, and even then it's very difficult to hold them accountable for fucking up data privacy that has very serious real world implications

stark ingot
#

Which is the reason the whole sponsor thing exists. If it was a major issue they would increase the age.

grave sandal
# fast osprey The exceptions do not make the rule. Children very rarely cannot comprehend full...

I think that adults screw this up and often have crappy attitudes and don't care and that it is slightly unfair to single out teenagers here. Like if I am not mistaken these same kids could get a job in some places regarding working with food which is very serious about sanitation and safety and they'd be able to understand, so like why can't a teenager be taught the principles of data privacy acts and examples of what not to do? Like right to erasure, right to access, purpose limitation, data minimization, etc.

fast osprey
#

I'm not saying that adults handle data privacy well, they often don't. What I'm saying is that kids don't have proper accountability if/when they do (and they do all the fucking time)

#

I see it a lot. Kids just storing people's private messages unencrypted and have no clue there's a problem with that

limpid sky
#

made it so instead of editing it deletes and repost the schedule with the updated scores

fast osprey
#

There are pretty hefty rate limits on consistently editing a single message

grave sandal
# fast osprey I see it a lot. Kids just storing people's private messages unencrypted and have...

Idk. I think it is more of an issue with kids and people in general not knowing better. Like if you think about it as being a data subject or know that your information is not supposed to be collected without your consent most of this could be avoided. Like, can I store these people's messages in my server? Do I need to? Is it communicated? Like anyone, if they know better could weigh it against the data minimization principle and I think the issue (at least in situations I can realistically imagine using ORMs and stuff that makes SQL injection unlikely) would be that they stored the messages at all (because I am thinking that if the application is hacked and thus the server then they'd have access to the database plus the decryption keys). And it's like a teenager could be stupid and email everyone who signed up to their site something but if they were to know about purpose limitation they could think, can I use these login emails to send notifications and they could be like "oh I can't cause it violated the purpose limitation principle". I am not gonna sit here and say making a discord bot is not serious and that accountability shouldn't be expected, but I just think that not enough would realistically go wrong if someone got the concept of data privacy and acted in good faith. It's not complicated people are just not taught it and even though they can't be held accountable, enough in good faith could be done that I don't think it matters as much for a discord bot.

fast osprey
#

There's two separate issues between people not reading what they agree to (which isn't going to change), and children being allowed to agree to things they can't legally be held accountable for

gusty drum
#

Can someone create a discord bot for me pls

full lily
jaunty cape
drifting arrow
burnt quiver
#

lmao

timber dragon
#

Why is it always you two that say some bs lmao

drifting arrow
timber dragon
#

Yes

drifting arrow
#

:O I would never!

dapper ocean
#

Let's say I tried to get a member object from d.py cache and it wasn't found. If I call the fetch method on the guild object, will that member be added to the cache?

Also if I have members intent enabled, is there still a chance that a member wouldn't be added to cache for some reason?

drifting arrow
#

If the bot cant find the member its coz the member isnt in the bots view

dapper ocean
#

that didn't really help AlexCluelessBastard

#

For the first question, its a no. I decided to look at the src

#

but what about the second

fast osprey
#

No, fetch does not add to cache

#

And things don't get added to the cache randomly. There's a reason why it's not in there

dapper ocean
#

Alright, guess that's all I needed

fast osprey
#
  • you don't have the intent
  • you're looking for a member on a guild on a different shard
  • you've disabled chunking
  • you're checking before the cache is populated
dapper ocean
#

yep that's all I need

#

ty AlexThumbsup

#

@fast osprey I found also this in documentation of fetch

"""
This method is an API call. If you have :attr:`Intents.members` and member cache enabled, consider :meth:`get_member` instead.
"""

does this mean that I can have members intent enabled and member cache disabled? If yes, how?

fast osprey
#

What are you trying to accomplish

dapper ocean
#

I'm just curious

drifting arrow
fast osprey
#

You can't fully disable the cache, but there is an option to tell it to not populate the cache automatically (chunking)

dapper ocean
#

Kind of a dumb question

#

I could've already assumed that is a yes

fast osprey
#

Yes

#

!d discord.ext.commands.Bot

unkempt canyonBOT
#
class discord.ext.commands.Bot(command_prefix, *, help_command=<default-help-command>, tree_cls=<class 'discord.app_commands.tree.CommandTree'>, description=None, ...)```
Represents a Discord bot.

This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Client) and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Client) you can do with this bot.

This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.GroupMixin) to provide the functionality to manage commands...
fast osprey
#

It's chunk_guilds_at_startup

tender bobcat
#

I remember there is something that set the cache size but forgot where

timber dragon
#

only for messages

#

and members

#

chunk_guilds_at_startup
max_messages
member_cache_flags

tender bobcat
#

Oh

drifting arrow
#

Neato.
Can you show us in real time and not sped up?

drifting arrow
#

Are you updating the message or sending a new one?

drifting arrow
#

Neat

tender bobcat
#

Hmm
I made a timer once before and I only got to message edit every 6s consistently (it's a timer) and any less would give me 429

fast osprey
#

discord specifically does not want you spam editing a single message, and will clamp down your rate limits if you try to

tender bobcat
#

Yep I am aware
Just questioning is could it actually update every 2s if without interaction

timber dragon
#

Interactions only count up to the global limit anyways

#

so 5/5s iirc?

dusk pelican
#

grrrr makes me angry such statements

#

did you make it yourself?

#

everything

#

ok fair enough

#

have you experience in discord api?

#

nice

#

seems good

#

ok, where do you host your dc bot

#

fair enough, I want to buy a raspberry pi 5

#

just to expirement with linux

#

sry experiment

#

ah that is why you are java developer

#

isnt minecraft java?

fast osprey
#

It works until it doesn't

#

And if you wait for things to break instead of reading documentation and following advice, things breaking will be your only feedback point

fast osprey
#

Same way you import any definition from any file in python

#

Why would you have a group and a command in that group in different files

#

That's not good practice and is actively making your code worse

#

You should bundle definitions that are related to each other in one file

#

It's more complex than that. But a module is meant to have all of the definitions that are deployable/reloadable/interdependent together

#

Thinking "long files are bad" is a very common newbie trap that isn't grounded in any kind of rigorous framework

#

That's a personal neurosis worth questioning and backing up with community standards

#

You could get this to work, but you're going to be patching together several files for no functional purpose

dusk pelican
#

every advice is good to know

fast osprey
#

This in particular is very squishy and opinionated. But when it's "make more convoluted code" vs "appease my personal neurosis", it's a pretty easy call. I encourage people to look up when it's appropriate to make multiple modules and why you would functionally want to, rather than just go on a random gut feeling

dusk pelican
#

for example /game1 / game2 /game3 .......

#

when you have a module called moderation then all commands that refer to that in one module

#

correct?

#

correct me guys if I am wrong or so, I dont want to spread false informations

fast osprey
#

I mean that's some pretty imprecise language that's hard to comment on

#

Definitions that directly refer to each other (like a group and a command in that group) really should be in the same module unless you have a functional reason not to.

For commands that are "related", which is a pretty subjective and squishy term, that's really up to you

limpid sky
gusty drum
stark ingot
#

The first one you are not instantiating the class.

#

Are you familiar with object oriented programming?

dapper ocean
#

yikes

stark ingot
#

It is a bigger topic that I will not be able to explain quickly. I recommend these videos about it
https://www.youtube.com/playlist?list=PL-osiE80TeTsqhIuOqKhwlXsIBIdSeYtc
1, 2, and 4 are probably the most important for now but it is only ~1.5 hours total and it is a very important topic ot understand

round folio
#

What is async & await function and why we are using it to make discord bot

fast osprey
round folio
#

Like the main idea of it

fast osprey
#

did you read all of that?

round folio
#

I don't like reading too much

#

And I'll read in a minute

fast osprey
#

Give it a read, ask questions on what doesn't make sense

drifting arrow
fast osprey
#

Then you pick one to start with

vapid parcel
#

can't remember the part of the docs, but in dpy 2.5.2, does it allow you to upload emojis to the discord panel?

#

if so, where is that in the docs?

fast osprey
#

!d discord.Client.create_application_emoji

unkempt canyonBOT
#

await create_application_emoji(*, name, image)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Create an emoji for the current application.

New in version 2.5.
broken sluice
#

Guys

#

Help me on this please..

#
from discord.ext import commands
from discord import app_commands

intents = discord.Intents.default()
intents.message_content = True

bot = commands.Bot(command_prefix="!", intents=intents)

@bot.event
async def on_ready():
   status_channel = bot.get_channel(1374024344698617866)
   if status_channel:
     await status_channel.edit(name="BOT STATUS: :green_circle:")

   channel = bot.get_channel(1372999749925470379)
   if channel:
      await channel.send(f"HELLOOO {bot.user.name} IS HERE")

@bot.event
async def on_disconnect():
   status_channel = bot.get_channel(1374024344698617866)
   if status_channel:
     await status_channel.edit(name="BOT STATUS: :red_circle:")

bot.run("TOKEN_")```
#

So yes I checked and it does make the channel go green when active

#

But when it shuts down it doesnt make it red

#

@sharp lintel

#

Or anybody 😭

dapper ocean
#

I assume on_disconnect is not an event?

broken sluice
dapper ocean
#

Yep, you shouldn't really use AI for d.py

broken sluice
#

What AI should I use then?

dapper ocean
#

from own experience, it creates trash code that doesn't work 96% of the time

#

you should just learn the d.py library by yourself and not depend on AI

broken sluice
broken sluice
#

I just ask it for some minature questions

dapper ocean
#

Okay so for your case

You should most likely create a commands.Bot subclass and override the close method (coroutine) to execute the logic that you want to be ran when tho bot is being closed

broken sluice
#

Well I did think of that, But the main reason why I wanted it to be automatic was because of my slow wifi, Which might shutdown the bot randomly

#

My wifi's peak is at 500kbps

jaunty cape
dapper ocean
jaunty cape
#

Stop vibe coding smh…

hearty basalt
#

If a bot disconnects how is it gonna edit a channel

#

Or am i just slow

broken sluice
broken sluice
dapper ocean
#

I assume that this should work

broken sluice
hearty basalt
dapper ocean
#

close is not an event

fast osprey
#

You shouldn't be using channel names as a data holder in the first place

#

That's api abuse

dapper ocean
#

true

broken sluice
fast osprey
#

You aren't supposed to be using channel names to record things that change

hearty basalt
fast osprey
#

Channel names are for the channel's purpose, which isn't something that changes repeatedly

jaunty cape
#

Jajajajaja

broken sluice
dapper ocean
#

I mean this also seems pointless as the user can just check the status of your bot by checking its profile

fast osprey
#

That doesn't change the fact you're using channel names for something discord has specifically said they're not for

drifting arrow
#

I bet it's for something silly

fast osprey
#

And it's not unlikely they'll see you're doing this and clamp your limits further

dapper ocean
jaunty cape
drifting arrow
#

What does that even mean? like if a bots online or not?

jaunty cape
#

Bro he’s not even doing it right

#

He’s spamming the API by having it done in on_ready

drifting arrow
#

But.. Why?

jaunty cape
#

Idk, don’t ask me

#

I’m not the madman

drifting arrow
#

Just set the bots role to display separately from everybody elses and check if it's there..

#

Your logic is this:
if bot dot green. bot online

#

Another way you can tell your bots offline is if it responds to commands..

woeful hill
#

checking bot's status
wow i dont even need to click a single thing

#

i wonder if the bot is offline when it says Online on the status

dapper ocean
#

d.py community at its finest

broken sluice
#

Not sure but CoPilot sciprted what I need

#

and it works

#
    """Perform shutdown tasks such as updating the status channel and closing the bot."""
    status_channel = bot.get_channel(STATUS_CHANNEL_ID)
    if status_channel:
        try:
            await status_channel.edit(name="BOT STATUS: :red_circle:")
            await status_channel.send("Bot is shutting down!")
            print("Status channel updated to red and shutdown message sent.")
        except Exception as e:
            print(f"Error during shutdown cleanup: {e}")
    else:
        print("Status channel was not found during shutdown.")

    await bot.close()
    print("Bot closed gracefully.")

def shutdown_signal_handler(sig, frame):
    print(f"Received exit signal {sig}. Beginning graceful shutdown...")
    loop = asyncio.get_event_loop()
    loop.create_task(shutdown_bot())

# Register signal handlers for SIGINT (Ctrl+C) and SIGTERM
signal.signal(signal.SIGINT, shutdown_signal_handler)
signal.signal(signal.SIGTERM, shutdown_signal_handler)```
#

sadly I dont understand anything so I wont use it 😭

#

I like using stuff that I understand only

jaunty cape
#

Get a load of this guy

woeful hill
dusk pelican
#

What the hell

#

Please do not use AI please

drifting arrow
#

Can you show me all your code @broken sluice?

dusk pelican
#

You can read the docs on how to discord api

drifting arrow
#

or more specifically. the command itself?

broken sluice
drifting arrow
#

Show me the command to shutdown your bot

broken sluice
#

Did AI add something by itself

drifting arrow
#

you dont have a command? :|

broken sluice
#

Im just testing around and learning

drifting arrow
#

You got any commands?

broken sluice
#

not really I didnt reach that point yet

drifting arrow
#

Dont rely too much on AI to build your bot

woeful hill
#

discord.py or any library has the bare bone example code in their github repo

#

if you dont understand the bare bone version of the bot well its better to learn the language first

dusk pelican
#

It also important what await or async does because it is essential for serving thousand of io network operations

#

The first version of discord py wasnt async

stark ingot
rough palm
fast osprey
#

yes

#

AI's are routinely blatantly wrong. They are not a substitute for learning and reading documentation

stark ingot
#

Just yesterday someone was asking why there bot was not working, it was because the AI combined multiple different discord bot libraries together. The training data out there related to discord bots is often of very low quality and extremely outdated.

fast osprey
#

ChatGPT will routinely spit out completely wrong things like claiming 3 isn't a prime number, and it will be incredibly confident about it

jaunty cape
dusk pelican
#

I use AI to chat when I am feeling lonely, I just write how you find these shoes I have found on the internet and what outfit fits on and other bullshit

jaunty cape
#

Who’s with me

dusk pelican
#

What do you mean by that ?

#

Soheab why that emoji?

dapper ocean
#

sobheap

rough palm
jaunty cape
rough palm
#

And GitHub is mostly private you won't find anything impressive there but sure there are no major projects done i am doing them but it is taking a lot of time

drifting arrow
rough palm
#

I learnt that don't rely on ai too much better to learn it yourself if you have time to learn that way we would have more control of what we are doing

#

Where do I learn about this discord bot development?

woeful hill
#

?

drifting arrow
#

@quick quest please stop dming people. Nobody wants to make your bot.

#

Worse than that thing from rick and morty who just wants to make an app

jaunty cape
#

Yeah can you please make a bot for yourself

drifting arrow
#

@jaunty cape Did he dm you as well? lol

jaunty cape
drifting arrow
#

lol

jaunty cape
#

Wait since when could non-nitro users use emojis from other servers

drifting arrow
#

He dm'd me, I asked for 500 usd for his basic ass bot, he said sure np.then demanded to see my past work. i said na he came to me. i aint begging for a job i didnt know about or want.

jaunty cape
#

Aw man why did it show up like I could

woeful hill
#

Free nitro trial

#

From discord 10th anniversary

drifting arrow
#

Nothing is free

#

If you think it's free than you're the product

#

Please do not be tricked into thinking it's free

woeful hill
#

Think of it how you want, but its is indeed a nitro trial from discord

drifting arrow
#

Ya'll out here thinking they're giving you free shit out of the goodness and kindness of their hearts

#

Like they're out here being all "Why thank you valued free user of our services who never pays us anything, have some free shit."

hearty basalt
#

Cinema

stark ingot
#

Who cares if it is free or "free"

drifting arrow
#

Because discord is doing it to convince you that you need nitro in your life

stark ingot
#

so ¯_(ツ)_/¯

jaunty cape
#

Never a dull moment in this channel

#

This channel deserves to be its own server

#

I declare independence and I am now seceding #discord-bots from the rest of the server

drifting arrow
#

oh

#

Do you have your own police force? your own currency? laws? citizens?

#

you cant just declare something its own nation

celest pelican
#

Please stay on topic everyone... the subject of this channel is Discord/Discord bots.

wise mica
arctic egret
#

look at honey

#

markiplier caught that 5 years ago

celest pelican
#

What does this have to do with discord bots?

arctic egret
#

also isnt this a python server since when was goku coding 💀

arctic egret
celest pelican
arctic egret
#

i didnt read the rules

#

like i said

#

i just joined and went straight to the lounge

#

besides what does python have to do with dsc bots

#

WE MAKE GAMES

#

IN THE FAVELAS

celest pelican
#

!timeout 1287493549251629077 Time to read the rules then.

unkempt canyonBOT
#

failmail :ok_hand: applied timeout to @arctic egret until <t:1747764290:f> (1 hour).

topaz lodge
#

lol

#

I read the rules cuz im a good boy innit

safe harbor
#

The .topic bot here is pretty cool

stark ingot
#

would be better if it had slash commands

jaunty cape
#

How do I write unit tests for my bot

dapper ocean
#

does anyone actually do that?

sick birch
#

you should

sick birch
# jaunty cape How do I write unit tests for my bot

it's a bit tricky but in concept it's similar to unit testing API endpoints (but pretend the http endpoint testing tools don't exist)
you need to separate out the "business logic" part from the part that interacts with discord, then you simply test your separated functions.
you could also write up mock objects for contexts, channels, guilds, etc but generally speaking you want to avoid mocking as much as possible, since the more you mock the farther you're going from a real environment

#

remember that you get the most value by going from no tests at all to a good amount of tests than you do going from a good amount of tests to even more tests

jaunty cape
sick birch
#

yeah you can do that

#

im personally not a fan of how python does testing for the bot

jaunty cape
#

Oh

#

They’re not using best practices?

dapper ocean
#

rules won't answer the question AlexLooky

sick birch
#

its just heavily debated and i think you're likely to find people on either side

#

that doesn't really answer the question either. i think we're all aware about bad practices and how prevalent they are in the discord bot space

#

they were referring to writing unit tests

jaunty cape
#

Did you even read what the conversation was about

grave sandal
arctic egret
#

mods that once given power go rogue

#

mods who are on a power trip

#

I stand for what's right, and this isn't it

#

Free Discord

#

'good boy' this isnt the 1800's

#

stop bending over to their will

#

It makes them stronger

#

They might have the power to push a few buttons but they have no power to push around people

#

FREE DISCORD

#

FREE PALESTINE

quick gust
#

wilding

arctic egret
#

ur name is infernum talking about wilding

#

ironic

celest pelican
#

!tempban 1287493549251629077 3d Looks like you need some more time to read?

unkempt canyonBOT
#

failmail :ok_hand: applied ban to @arctic egret until <t:1748085425:f> (3 days).

grave sandal
#

free discord 😂

topaz lodge
fast osprey
#

They clearly just lack attention, you're better off not giving it to them

jaunty cape
#

Bro got banned

#

Ibn kalb

stoic forum
# jaunty cape Ibn kalb

Seeing someone use an arabic insult is the least thing i expected to see on a python server

jaunty cape
grave sandal
#

Seeing free discord and free Palestine unironically in the same sentence in here did it for me.

tender bobcat
#

Anyway, did anyone build something awesome with Component v2 yet? so I can steal them

tender bobcat
#

2-3 month I think?
Not library tho, I meant API

#

I think all the popular library is at most PR rn

timber dragon
#

djs has it iirc

#

Yes in 14.19

tender bobcat
#

Consider this is a python server, I am only discussing about the discord library bot for python

timber dragon
#

Fair enough

#

Discord released it <t:1745316000:R>

tender bobcat
#

Hmm it's later than I thought it was
I found back on the message that let me know component v2 is available and it was 19 April

timber dragon
#

yeah the "lock" was lifted days before

#

but 22 april is when the official announcement was

ruby tapir
#

suppose i want to master creating discord bots (being able to create any kind of bot), but i don't want to fully learn python what parts of python do i need to learn for that?

#

Ping me when you reply

quick gust
#

learn another language if not python sofunnylmao

ruby tapir
quick gust
#

that's a really weird question...
having the ability to build "any kind of bot" in python requires you to know everything about python

grave sandal
quick gust
#

you can't learn specific parts and be able to build anything

timber dragon
#

that's a list from the dpy server

ruby tapir
#

Thanks

quick gust
#

This list only tells you what you need to know to be able to build a good discord bot
Depending on the features you want to add to the bot you will also need knowledge relating to that

ruby tapir
#

Lets say i want to build a bot like bleed,

quick gust
#

Database management, API integrations, web management, security practices, logging, version control, proper deployment practices

stark ingot
# ruby tapir suppose i want to master creating discord bots (being able to create any kind of...

2 things
Saying that you want to master something like discord bots is not really possible. There will always be more to learn and always be ways to improve your bot.
What you need to learn will depend on what you need your bot to do. Most people probably do not go into a project knowing everything that they need. They need to do research and learn new things even if they have a lot of experience programming.

drifting arrow
robust fulcrum
#

Who learns python just for bots 😭

robust fulcrum
drifting arrow
timber dragon
drifting arrow
#

@robust fulcrum Hey, I see you thumbs down my comment, that's cool. Why did you learn to program?

shadow vigil
drifting arrow
#

I do what I want. I just wanted to roast him

shadow vigil
#

ah I see lol

fast osprey
#

Nobody cares why you decide to learn something. What matters is how, and you all seem to be conflating the two.

Sure you could get into the medical field because one day you want to do brain surgery, but that doesn't mean you start on day one by cracking open someone's skull. Even if your goal is eventually to make a bot, learning programming from scratch by starting on a bot is misguided and impatient.

tender bobcat
drifting arrow
robust fulcrum
#

ye, i don't have a bad reason to learn programming, nvm bro i was just kidding

safe mist
#

How do I sync discord.py slash commands to work in DMs? I thought this would work automatically as when I add the bot to a new server I can use the commands there w/o doing anything, but when I add the app to myself for use in DMs the commands list is empty.

timber dragon
#

You can set it for all command at once or per command

safe mist
#

i just want to sync all commands globally the same way i do for servers

#

but i dont see anything in the docs

timber dragon
#

You first need to mark the commands as installable and useable

#

Syncing will still be the same

#

To set it for all commands at once, pass the allowed_contexts and allowed_installs kwargs to Bot:

commands.Bot(
    ...,
    allowed_contexts=app_commands.AppCommandContext(
        guild=bool,
        dm_channel=bool,
        private_channel=bool,
    ),
    allowed_installs=app_commands.AppInstallationType(
        guild=bool,
        user=bool
    )
)
safe mist
#

tysm works fine now

sick birch
#

what command did you use to run the bot?

fast osprey
#

pip and python are ambiguous. They don't necessarily hit the same python installation

timber dragon
#

You should be checking python -m pip list

drifting arrow
#

It has been just under 9 hours. are you home yet?

tender bobcat
#

"just under" - yep I am on my way walking from north pole to south pole, wish me luck /j

dusk pelican
#

Hehe 😜

silk mulch
#

I Need A Discord That Have A Currency Only And Have A Shop No Games That's it

#

But I Add Balance

#

That's It

#

@dusk pelican @

timber dragon
#

We Do Not Write Bots For You Here.

#

And this isn't a job listing board

fast osprey
#

Not with that attitude

dusk pelican
#

why ping me ?

#

Database and discord py. Make something cool

tender bobcat
#

I have a previous attempt on using python only as a wrapper and do basically everything (or almost everything) in SQL
Which is a fun attempt

tender bobcat
#

Idk lmao

#

It just ends up with curse SQL statement

keen shale
#

hello

lucid radish
#

From where do i start in the process of making discord bots?

#

Like i need complete guidance of it

sick birch
timber dragon
#

Do you know Python? If not, see these resources.

if you do, choose a library you want to use and read their guide, if any I guess.
I've listed some known guides here.

drifting arrow
#

:D

burnt idol
#

How bad isit to use discord channel webhook to receive form data from a website? (will be used in frontend)

#

so what can discord webhooks do? other than sending messages to channel?

fast osprey
#

That's all they do

timber dragon
#

See GitHub webhooks

burnt idol
drifting arrow
#

No security issue as far as I am concerned and I dont know a lot about much

#

Just dont give the webhook URL to people who dont need it

timber dragon
#

Same. I just know that you shouldn't share the ID/TOKEN at the end of the URL. Since that'll basically allow anyone to send messages via it.

burnt idol
#

can someone kindly share d.py link?

#

discord server link cant join using ur tags for some reason

drifting arrow
#

Web hooks are meant to not be seen. So wherever you're seeing someone elses webhook means they did an oopsies

fast osprey
pale zenith
#

It's also in the channel topic

stark ingot
#

Which for some reason does not have any information about any other libraries other than noting that "other relevant python libraries" exist.

pearl forge
#

And a lot of the other relevant libraries are just forks of it. It's more practical to refer to the source itself

fast osprey
#

we had a whole ass argument about what default meant and if dpy was that, not worth barking up that tree with these particular folks

stark ingot
pearl forge
#

I'm yet to see any library replace discord.py in its popularity

#

You may see in PyPi

stark ingot
pearl forge
#

Is it untrue?

stark ingot
pearl forge
#

It does not. It however does mean that it's the de-facto choice

sick birch
#

i dont think anybody ever said the others dont exist

pearl forge
#

We're talking an objective metric here

stark ingot
# pearl forge Is it untrue?

Yes, the other libraries are forks. But in one of the core aspects of modern discord bots, app commands, all these libraries are different. Discord.py is not the "source itself" it is one of many sources. If you think that discord.py is of higher quality and makes better design decisions that is your opinion, but that differs from my opinion.

pearl forge
#

Thankfully, that's not what I said

fast osprey
stark ingot
#

I dont get why people who still use discord.py are so against other libraries being added to the list of resources in a python discord server. Why is there any argument at all?

pearl forge
#

We're not

#

!d discord

unkempt canyonBOT
#

In order to work with the library and the Discord API in general, we must first create a Discord Bot account.

Creating a Bot account is a pretty straightforward process.

stark ingot
#

And this means what?

fast osprey
#

Please point to where anyone said the other libraries shouldn't be added

pearl forge
#

!d disnake.discord

unkempt canyonBOT
#

Unable to parse the requested symbol due to a network error.

pearl forge
#

Other libraries are available for consulting in the docs

#

I'm not sure what your point is

stark ingot
#

Py-cord is not

pearl forge
#

You may submit an issue on the bot, or perhaps bring it up on #community-meta

stark ingot
#

And that is also unrelated to my original statement

pearl forge
#

From what I recall, you support directly replacing the discord symbol

#

Or am I mistaking you for somebody else?

stark ingot
fast osprey
#

If that's how you want to read it, that belies a pretty severe victim complex

stark ingot
pearl forge
#

As in, doing !d discord yields multiple choices in which the user is forced to make a choice

stark ingot
#

Yes, I am in support of that

pearl forge
#

It just means that. discord.py is the de-facto library for Discord bots, hence why it gets a link.

#

And hence why it's the also go-to symbol when consulting the docs

fast osprey
#

Any of the forks could have very trivially just picked a different package name

#

It's wild to me that most didnt

pearl forge
#

Same as;

#

!d arrays

unkempt canyonBOT
#

Array objects

NumPy provides an N-dimensional array type, the ndarray, which describes a collection of “items” of the same type. The items can be indexed using for example N integers.

All ndarrays are homogeneous: every item takes up the same size block of memory, and all blocks are interpreted in exactly the same way. How each item in the array is to be interpreted is specified by a separate data-type object, one of which is associated with every array. In addition to basic types (integers, floats, etc.), the data type objects can also represent data structures.

pearl forge
#

Although array also exists in stdlib

pearl forge
#

I assure you that there's simply no witchhunting or bias against other Discord libraries.
But we simply acknowledge what is mostly frequently what people mean when consulting docs

fast osprey
pearl forge
stark ingot
fast osprey
#

🙄

pearl forge
#

Point being?

quick gust
#

That's totally unrelated

fast osprey
#

I encourage you to try ?tag who is the most intelligent developer

sick birch
#

also if we look at stats, discord.py has had ~550,000 downloads in the past week (500,000 for discord.py and 50,000 for discord). and if we take py-cord, it's had ~18000 downloads in the past week. i use the past week because i'm assuming those are the people that are most likely going to ask for help. if we go by those stats you can assume someone asking for help is using discord.py and you'll be right 97% of the time. of the remaining 3%, you most likely only really need to change up your answer if the person is asking for help with app commands

i think assuming the software 97% of people use is fair to call the default

pearl forge
stark ingot
jaunty cape
#

?tag who is the most intelligent developer

novel apexBOT
#

This is not a Modmail thread.

jaunty cape
#

Solstice Sha-‘3ard is number wa’3aann

pearl forge
#

Because at this point, I may have either completely lost what you mean or misunderstood

stark ingot
stark ingot
pearl forge
sick birch
#

sure. it's still the vast majority of people using discord.py, i'd only really consider it if it was like, 60-40 but i guess thats arguable

fast osprey
#

And what are the criteria you would use to determine which forks "earn" a spot

stark ingot
#

Discord recognized libraries

fast osprey
#

Oh wow hikari is still there

timber dragon
#

What happened