#discord-bots

1 messages · Page 19 of 1

slate swan
#

Send me link pls :(

crystal glen
#

I have a role that overwrites it...

silk fulcrum
#

ctx.guild.default_role

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

silk fulcrum
crystal glen
#

I just want to do it for every role, How do I do it

slate swan
vocal snow
#

:(

slate swan
#

f

crystal glen
#

ok just leave it

unkempt canyonBOT
#

await edit(*, reason=None, **options)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the channel.

You must have the [`manage_channels`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to use this.

Changed in version 1.3: The `overwrites` keyword-only parameter was added.

Changed in version 1.4: The `type` keyword-only parameter was added.

Changed in version 2.0: Edits are no longer in-place, the newly edited channel is returned instead...
silk fulcrum
#

that's a hundred percent a text channel

#

or not

zealous jay
#

Best way to charge for premium commands?

slate swan
zealous jay
slate swan
#

but yeah patreon would be okay mmLul if you do have them

zealous jay
#

im asking 🤷‍♂️

silk fulcrum
#

MEE6: yes:)

zealous jay
#

i mean most bots have premium features

#

if not all of them

silk fulcrum
#

most big* bots

zealous jay
#

yeah was about to say that

slate swan
#

premium dogepray

#

master could make them within 2 minutes

vocal snow
sick birch
slate swan
vocal snow
#

Scammed

zealous jay
zealous jay
#

I'll investigate

#

thanks

zealous jay
vocal snow
#

If you have the student dev pack you get some stripe benefits

zealous jay
#

well the commands im planning on making will give you access to a database with bans

vocal snow
zealous jay
#

like, check where x user is banned and stuff like that, and the bot has already gathered quite a few bans from 230+ servers

zealous jay
crystal glen
#

how do I add error message, For example if a command is wrong or missing arguments, any error, Should ctx.send(error)

sick birch
#

Add an error handler, and check for specific types of errors

crystal glen
sick birch
#

Right, but different errors will have different error messages

zealous jay
#

I would use the bot's docs command but I don't remember how its called

crystal glen
slate swan
silk fulcrum
#

Now I can code my bot in absolute safety, I have a guardian

#

okimii, hey!

slate swan
slate swan
crystal glen
slate swan
silk fulcrum
slate swan
#

smh

#

nobody, literally nobody does, why you gotta even say that

slate swan
sick birch
silk fulcrum
slate swan
silk fulcrum
#

lmao

slate swan
sick birch
#

Ah that's an event error handler

#

It was.. on_command_error?

shrewd apex
#

7 kilos hmm that's a lot

slate swan
sick birch
#

Which is what they want, I suppose

silk fulcrum
shrewd apex
crystal glen
# sick birch It was.. `on_command_error`?
@client.event
async def on_command_error(ctx, error):
    await ctx.message.delete()
    if isinstance(error, commands.CommandNotFound):
        await ctx.send(f'Command not found. Type ?help for a list of commands.')
    elif isinstance(error, commands.MissingRequiredArgument):
        await ctx.send(f'Missing required argument. Type ?help for a list of commands.')
    elif isinstance(error, commands.MissingPermissions):
        await ctx.send(f'You do not have permission to use this command.')
    else:
        await ctx.send(f'An error has occurred. Type ?help for a list of commands.')
#

lmao

#

I love github co-pilot

silk fulcrum
sick birch
#

Except the else part

silk fulcrum
#

okimii: then gimme that bg

shrewd apex
#

err i tried co pilot but it dosent suit my task it always gives code suggestions i don't need and then i switched it off

slate swan
sick birch
#

You should also use the traceback library to print the exception traceback to your console

crystal glen
shrewd apex
#

her standards are a bit high

#

u can go with what u are doing

#

just remember to dm urself the traceback

sick birch
#

For the most part it's good... the else is obviously wrong. it could be improved a little bit. E.g commands.MissingRequiredArgument has an attribute that says which argument was missing, so you can provide more detailed error messages depending on the command

shrewd apex
#

dm or print or send in a channel

crystal glen
slate swan
#

he will be a box with a fragile sticker on him

shrewd apex
#

he won't fit in mail u go pick it up personally

slate swan
silk fulcrum
slate swan
#

!ot

unkempt canyonBOT
vocal snow
silk fulcrum
slate swan
silk fulcrum
sick birch
slate swan
silk fulcrum
#

i want that too

#

@slate swan come here, live with me:)

slate swan
#

✈️

silk fulcrum
slate swan
#

5hours😪

silk fulcrum
#

that's a take off time?

slate swan
#

no the whole flight🗿

silk fulcrum
#

wow that's fast

#

where do you live

slate swan
#

plot twist i live with you

#

😳

silk fulcrum
#

😳

#

then who are you? my mom, dad, grandma?

final walrus
#

@brazen raft

@tasks.loop()
async def streamThread(channel,users):
    stream.filter(token)
slate swan
silk fulcrum
slate swan
final walrus
#

Unless I don't understand the tasks.loop() decorator

silk fulcrum
#

you need seconds or minutes or hours in it i gues

final walrus
silk fulcrum
#

lowerCamelCase

final walrus
final walrus
silk fulcrum
final walrus
#

Roie said there was no need for multithreading and that it can be done with tasks but i don't know how

sick birch
slate swan
final walrus
sick birch
#

discord.py internally uses a few while True loops adhering to this rule

pliant gulch
#
async def foo() -> None:
    while True:
        ...

asyncio.create_task(foo())
unkempt canyonBOT
final walrus
#

no

#

twitter stream api

#

im fetching tweets

brazen raft
#

Is the Python wrapper library for Twitter's API not asynchronous?

#

What library are you using for this

final walrus
#

tweepy and no it isn't *

#

misunderstood question

brazen raft
#

tweepy seems to have an asynchronous subpackage with an AsyncStream object

final walrus
#

which all it does is just run in a seperate thread

#

which I wanted to do manually from the start p much

#
  • that's v1
brazen raft
#

You just have to use the asynchronous tools tweepy provides

brazen raft
final walrus
#

has a different client but is available i just checked

#

I just don't see the difference to just running it on another thread

brazen raft
#

There's also tweepy.asynchronous.AsyncStreamingClient if you can use streaming clients instead

brazen raft
#

API (or literally all HTTP) requests can be issued and awaited with Python's async/await stuff instead of multi-threading

shrewd apex
slate swan
silk fulcrum
# shrewd apex aunt

uhm, I have one aunt and he does not live with me, well in same country but not even in same city

slate swan
shrewd apex
#

he💀

slate swan
slate swan
#

master has stopped working

silk fulcrum
#

that prooves that im 100000 times stupider than everyone here

shrewd apex
#

master32 playing gender bender

brazen raft
slate swan
slate swan
shrewd apex
#

tf auto correct

slate swan
#

now we all cant type😳

shrewd apex
#

it's a feature not a bug

slate swan
#

haha

shrewd apex
#

everyone drunk here

#

fingering going wrong

slate swan
#

fingering-

silk fulcrum
#

iiii cant evem tyoe properly, im too laughonf/

slate swan
#

asher made it all worse

#

im waiting for someone to give me my breakfast in bed😔

silk fulcrum
#

wytf am i goinb french

slate swan
shrewd apex
silk fulcrum
#

oh my gosshhh, aight gotta remember my aunts

shrewd apex
#

any preferences?👀

silk fulcrum
slate swan
silk fulcrum
#

she's my aunt

slate swan
#

hes my aunt🗿

silk fulcrum
#

he/she doesn't matter nnow

final walrus
slate swan
final walrus
#

why is the discord-bots chat so horny

silk fulcrum
#

what did he say? i couldn't see I was laughing and crying at my pillow

slate swan
slate swan
final walrus
brazen raft
shrewd apex
#

it's the second most active channel for a reason

silk fulcrum
silk fulcrum
shrewd apex
#

idk German to me is like the first language with most weird pronunciations and words

slate swan
#

you should try spanish

silk fulcrum
shrewd apex
#

Krankenhaus

shrewd apex
#

thats hospital in german

slate swan
#

Asher es mi bebe😳

shrewd apex
#

precise my ass

#

i am pretty sure everyother almost all languages hospital has h in it atleast but whats krakenhaus😭

slate swan
#

kill the kraken

silk fulcrum
slate swan
#

looks like a snail

#

ль

silk fulcrum
#

lmao

slate swan
shrewd apex
#

master i sense malice coming from u just sent a tingle down my spine👀

slate swan
slate swan
shrewd apex
#

it looks like encoding gone wrong

slate swan
shrewd apex
#

i was gonna use another synonym for kitty

silk fulcrum
#

you know russian was hard for me to learn, im native speaker bruh, wtf is да нет конечно (word by word trans: yes no of course)

shrewd apex
#

hmm ic 👌

slate swan
#

why does it look like little cool houses

slate swan
silk fulcrum
#

lmaooo your associations are so good

swift pumice
final walrus
shrewd apex
#

to me it looks like someone mixed utf-8 ansii and effed up encoding and put in a food processor

silk fulcrum
brazen raft
#

You are affirming their negatively toned question by saying "of course"

slate swan
swift pumice
#

uh

final walrus
#

double negations are also a must in russian

swift pumice
#

deutsch ist eine gute sprache

#

🤓

slate swan
#

me with spanish: shipit

swift pumice
silk fulcrum
#

you know what? E-e

shrewd apex
#

ik Hindi and little sanskrit😔

#

and i also speak google translate

silk fulcrum
shrewd apex
#

no

silk fulcrum
#

how

shrewd apex
#

Chinese speak baidu

#

no Google for them

silk fulcrum
#

cyka, why

final walrus
#

WHAT if I execute a short loop in my async function and another function would get called during this outside of the loop, it would get dropped or am I just not understanding it @brazen raft

slate swan
swift pumice
#

@shrewd apex what is your native language

shrewd apex
#

i am from West Bengal so begali hindi Sanskrit and English thats my language set

brazen raft
silk fulcrum
shrewd apex
#

i learned a bit of German in school but i forgot

final walrus
brazen raft
slate swan
slate swan
silk fulcrum
shrewd apex
swift pumice
vocal snow
#

Inb4 Elias gets banned

slate swan
swift pumice
#

im sorry

silk fulcrum
shrewd apex
swift pumice
slate swan
#

😤

silk fulcrum
#

bugs have copyrights

shrewd apex
#

features have patents

silk fulcrum
#

bugs: bzzzbzzz

slate swan
#

ok now

#

!rule 7 after all what has happened

unkempt canyonBOT
#

7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.

shrewd apex
#

yes it was a good convo while it lasted

slate swan
#

ash mad she doesnt get a 7 kilo cat sent to her from the mail

#

😳

silk fulcrum
# slate swan ok now

bruh I pressed reply and almost sent !ot but remember that i cant delete that pythons message

silk fulcrum
slate swan
shrewd apex
#

alr gn guys have fun

silk fulcrum
#

bbye

swift pumice
silk fulcrum
#

good dreams

slate swan
#

get it byte as in the 8 bit storage unit😳

brazen raft
slate swan
silk fulcrum
final walrus
brazen raft
# final walrus So if I understood it correctly, the point of asynchronous programming is to onl...

In asynchronous programs, there is an asynchronous event loop which schedules tasks. Only one task can run at a time because computers run synchronously (at least in the same thread). What async/await in Python lets library developers do, is use asyncio.sleep in IO blocking operations such as waiting for file reads or for stream or HTTP responses, for example, so that other tasks can run (asyncio.sleep tells the scheduler to come back to this task after the given number of seconds, so the scheduler runs other tasks if any)

#

So, if you use tweepy.asynchronous, you will be able to use its asynchronous classes which wrap around Twitter's API asynchronously, which means the library can abstract API interactions in such a way that lets you run other tasks meanwhile an interaction waits for a response from the API

slate swan
sick birch
slim grotto
#

Not related to execution, but does anyone know why my IDE throws "delete" is not a known member of "None"

#
@client.event
async def on_command(ctx: commands.Context) -> None:
    """
    Delete command invocations.
    """

    # Delete Command Invocation
    await ctx.message.delete()
#

Is it because I am using type annotations and discord.py has funky ones?

brazen raft
#

Maybe the context doesn't have a discord.Message object associated with it

slim grotto
#

I think it's because the type for ctx.message is Unknown | None according to my IDE.

brazen raft
#

Does it work at runtime, then?

slim grotto
#

Yeah it works at runtime because the type of ctx.message is only found once you send a message

#

The IDE can't figure it out before

#

How can I make it realize that it's a discord.Message? Do I just have to add # type: ignore?

silk fulcrum
#

it's Message

#

what version of dpy are u using?

slim grotto
#

Let me check though

slate swan
#

how can I create a status for my bot which displays the current time and updates on a new minute

just ping or dm me

slim grotto
brazen raft
#

I like how the closing parenthesis is on the next line on my screen

slim grotto
#

Thanks though

slate swan
#

How can I create a status for my bot which displays the current time and updates on a new minute

Just ping or dm me

silk fulcrum
slim grotto
#

discord.context.Context

silk fulcrum
#

ext.commands?

brazen raft
#

That's the link I got from clicking on the fancy anchor thing

silk fulcrum
#

and that's the thing you have to pass in !d command

brazen raft
#

What?

silk fulcrum
#

!d discord.discord.ext.commands.on_command_completion

unkempt canyonBOT
#

discord.ext.commands.on_command_completion(ctx)```
An event that is called when a command has completed its invocation.

This event is called only if the command succeeded, i.e. all checks have passed and the user input it correctly.
brazen raft
#

Weird

#

Interesting

crisp thunder
#
class MyView(discord.ui.View):
    def __init__(self,*args,**kwargs):
        super().__init__(*args,**kwargs)
        self.ctx = None

    async def interaction_check(self, interaction) -> bool:
        if interaction.user != self.ctx.author:
            await interaction.response.send_message(content="You are not allowed to do that!",ephemeral=True)
            return False
        else:
            return True

I am subclassing around the discord View class and I want the interaction_check to send a message and delete it after like 1-3 seconds

#

what is the correct approach for this?

silk fulcrum
#

sed, there is no delete_after arg. then probably the sleep way?

brazen raft
#

Does discord.InteractionResponse.send_message return anything though

#

It isn't documented

crisp thunder
brazen raft
#

Also no delete_after is documented

brazen raft
silk fulcrum
#

wait ephemeral messages cant be deleted 😳

#

only by receiver

brazen raft
crisp thunder
#

oh I see thanks for enlightening

brazen raft
crisp thunder
#

Coroutine[Any, Any, Interaction]

silk fulcrum
#

message - interaction

brazen raft
silk fulcrum
#

nothing

#

im jsut bein drunk

brazen raft
#

For example, I like the automatic suggestions

silk fulcrum
#

Optional[commands.Context] :power:

brazen raft
#

I don't like importing typing

#

Correction

#

I don't like importing unnecessary modules

silk fulcrum
#

it makes your code look 🆒

#

or not

#

but yes

brazen raft
#

Doesn't it always return a Connection

#

When would it not

#

Isn't it a getter?

#

Oh because you type hinted the actual thing with | None

silk fulcrum
#

when my db will be hecked and closed for using unnecsessary 7 kilo cats

brazen raft
#

I wonder how SQLite data is stored

#

It's a binary format so it has to be concise

slate swan
silk fulcrum
#

MySQL huh

#

outsmarted everyone (no one)

slate swan
#

same thing whatevah

#

still a blocking lib

#

if mysql

silk fulcrum
#

guess the owner ||spoiler: not me||

#

correct! okimii

final walrus
#

@brazen raft I got it to work thanks to you

brazen raft
#

I am glad I helped

final walrus
#

Appreciated, allthough it feels like with craft or something

#

And it seems not to drop anything, just delays it by queueing it which is great

silk fulcrum
#

wth, do I really have to do isinstance(message.reference.resolved, DeletedReferencedMessage) to check if message is deleted? There must some other way, right?

#

it is absolutely possible

#

also people are lazy, there are audit logs

brazen raft
silk fulcrum
#

well pretty enough

slate swan
silk fulcrum
#

are u always watching for me?

slate swan
#

im always watching

silk fulcrum
#

but you're not lemon

#

and also i didnt ping you or him

slate swan
#

I am the Watcher. I observe all that transpires here. And I do not, can not, will not interfere 😳

brazen raft
#

cannot*

#

can not means something else

silk fulcrum
#

vocobalaru

slate swan
#

😡

brazen raft
#

What quote

slate swan
#

bro

#

the watchers quote, from marvel🗿

brazen raft
#

Is it a movie? I know nothing about Marvel's comics and I also haven't watched every Marvel movie obviously

slate swan
slate swan
#

How can I create a status for my bot which displays the current time and updates on a new minute

Just ping or dm me

silk fulcrum
#

there is no built in logging system, you should make it yourself, and the channel is just a property to where send logging messages, you can store in db or in a json file

slate swan
#

why json files smh

#

dont give me an assy reason about it being easy to use

silk fulcrum
#

i am not, it's just an option and so I listed it, I don't like it either

slate swan
#

why would you state anyways, that's not a good practice too

vale wing
#

@slate swan remember about my 3am idea about nerd bot

slate swan
#

yeah I do, it's 3 am ?

vale wing
#

No

slate swan
#

got some nerdy idea?

brazen raft
slate swan
#

I know.....?

vale wing
#

It's really philosophic

slate swan
silk fulcrum
#

wowww, can you give it to me pls, I want this satisfaction

vale wing
brazen raft
#

Oh god

vale wing
#

What he means

brazen raft
#

Now you've got me

vale wing
#

Meaning of life is everything

silk fulcrum
slate swan
# vale wing

I'd actually be annoyed by the responses already kek

silk fulcrum
#

what is sus

vale wing
#

It's encouraging members to break rules ig I will have to ban it

slate swan
#

I want some help with discord-ext-menus

marsh mulch
quaint epoch
silk fulcrum
slate swan
#

How can I create a status for my bot which displays the current time and updates on a new minute

Just ping or dm me

Like in the image shown below :

austere vale
#

is it possible to make your bot so that if someone tries to use a command in a channel that isnt in the bot channels, the bot simply doesnt respond at all? instead of saying something like "you're not in the right channel"

@bot.check
async def is_in_bot_channel(ctx: commands.Context) -> bool:
  return ctx.channel.id in (#insert channel ids here)
vale wing
#

When the check fails the commands.CheckFailure is raised, ig you just gotta eat it in the error handler

vale wing
#

!d discord.ext.tasks.loop examples are on top

unkempt canyonBOT
#

discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/latest/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
gusty shard
#

is there any way to add some stuff to every command?

slate swan
gusty shard
#

like giving random item on every command randomly

vale wing
silk fulcrum
vale wing
#

Getting the time itself or updating the presence

slate swan
vale wing
#

Could you show your code that works and the one that doesn't

slate swan
#

Sure later when I’m on pc

flat solstice
silk fulcrum
brazen raft
brazen raft
vale wing
silk fulcrum
#

oh wait im super dumbass

#

all that time i could've just used try, and i wanted to check the deletness of message

vale wing
#

But with own decorator you can parse some stuff into the function unlike with the @commands.check

#

I mean sort of a decorator argument

gusty shard
#

thank you

flat solstice
vale wing
#

Nice

#

How could I even recommend this to someone wtf

slate swan
gusty shard
#

thanks uwu

slate swan
#

❤️

flat solstice
#

Do Discord App and Bot names have limits on how long they can be?

glad cradle
flat solstice
#

thank you

slate swan
#

how can i fix this

full lily
dry kelp
#

sorry what's wrong with my models again

austere vale
#
  @commands.Cog.listener()
  async def on_message_delete(self, message):
    async for entry in message.guild.audit_logs(action=nextcord.AuditLogAction.message_delete,limit=1):
      embed=nextcord.Embed(title="Message delete", description= f"Deleted by {entry.user.mention} in {message.channel.mention}\nMessage: {message.content}\nMessage author: {message.author.mention}",color=0xfd9fa1, timestamp=datetime.datetime.utcnow())    
        await self.bot.get_channel(933978399280599080).send( embed=embed)

can someone help me with my audit log line? Im trying to correctly return entry.user for who deleted the message, but sometimes it doesnt work and returns the wrong person

sick birch
austere vale
#

ahh so no fix?

dry kelp
#
NAME_HEX_MAP: Final[Mapping[str, int]] = {color['name']: int(color['hex'][1:], base=16) for color in RAW_COLOR_MAP.values()}
COLOUR_NAMES: Final[list[str]] = list(NAME_HEX_MAP.keys())


def color_autocomplete(ctx: discord.AutocompleteContext):
    return sorted(color for color in COLOUR_NAMES if color.lower().startswith(ctx.value.lower()))[:25]


class ColourNameConverter(Converter[discord.Colour]):
    async def convert(self, ctx: Context, argument: str) -> discord.Colour:
        try:
            return discord.Color(value=NAME_HEX_MAP[argument])
        except KeyError:
            raise BadColourArgument(argument)
#

it just raises the keyerror

sick birch
calm ridge
#

there is no error for this code but the bot doesnt do anything

sick birch
flat solstice
#

So I have a slash command which takes a attachment input and sends it in a embed but I also want this command to send a modal.
This model will create a embed with all of the values from the modal and I also want it to add the attachment to the embed.
Is there a way for me to pass the attachment through to the model to access in the on_submit or should I use return statements in the on_submit and on_error funcs of the model and construct the embed in the command func?

Some ppl over on dpy suggested using the init to pass the attachment object in, Whilst I have used init and super init a few times now they still confuse me when writing them to start with.
Is there anything inherently wrong with doing this:

should I use return statements in the on_submit and on_error funcs of the model and construct the embed in the command func?

slate swan
#

discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction does someone know why this happens?

#

It happens when i click sometimes the button

#

The strange part is that happens when i run the from vps host

#

When I run the bot from the pc, it doesnt throw that error

#

And it happens for all the buttons that i have

calm ridge
sick birch
calm ridge
#

still does nothing

#

thats super weird

sick birch
#

What channel are you calling the test command in?

calm ridge
sick birch
#

What version are you using? I'm seeing an obvious problem but it's strange you're not getting any errors

sick birch
#

Right

hushed galleon
#

it wouldnt necessarily error if you use an event name that doesnt exist

sick birch
#

I'm talking about sent_msg = await ctx.send_message(ctx.channel, embed=embed)

#

Maybe in an older version it's called send_message?

calm ridge
#

yes this code is quite old

sick birch
#

And ctx.add_reaction

hushed galleon
#

a lot has changed since their legacy version

flat solstice
hushed galleon
#

whats even defining bot?

sick birch
#

Oh yeah bot isn't used either

#

Whoever wrote this code doesn't seem to know what they're doing

#

You did say earlier that you got it from github?

flat solstice
sick birch
#

I'd suggest you try to re-write it yourself

sick birch
calm ridge
hushed galleon
flat solstice
#

👍

sick birch
#

Here it's just commands.Context.send_message which I'm not even sure was a thing in legacy?

#

I'm trying to access the legacy docs but it's hard to navigate lol

slate swan
sick birch
#

I don't even know if the ext.commands extension was a thing then

hushed galleon
slate swan
#

by changing the code

hushed galleon
#

if your code is potentially slow sure, you could start with a defer() so you dont have the 3 second limit

slate swan
#

so

#

await interaction.response.defer()

#

and then the await interaction.response.send_message()

hushed galleon
#

your response afterwards would need to use the .followup webhook

slate swan
#

How i can use that?

hushed galleon
#

though id test with a plain send_message('hello world') to see if rewriting your code would even do anything

slate swan
#

No i mean the followup

#

is this import?

hushed galleon
#

its an attribute of Interaction

#

!d discord.Interaction.followup

unkempt canyonBOT
hushed galleon
#

you'd use it like a normal webhook, i.e. Webhook.send(...)

slate swan
#

Do I need webhook url?

hushed galleon
#

the interaction already has the url set for you

slate swan
#

oh ok

#

and the import is import Webhook

flat solstice
hushed galleon
#

yeah thats what i meant by the .followup attribute part...

slate swan
#
await interaction.response.defer() 
await interaction.followup.send(f"**test**")```
#

Is this ok?

calm ridge
#

can someone help me with this indentation

flat solstice
slate swan
#

I mean it replies after 2-3 seconds

calm ridge
slate swan
#

and this happens sometimes again

#

not every time

#

Sometimes replies with good speed 😂

flat solstice
slate swan
verbal junco
#

guys, how i can make commands run only in a specific server?

wicked atlas
slate swan
wicked atlas
verbal junco
#

sure

#

i'll search for this invoke guild check

verbal junco
#

tyy

#

another thing

slate swan
#
IDS= ["id1", "id2"]

def is_in_server_list(server_list):
    def predicate(ctx):
        return ctx.message.server.id in server_list
    return commands.check(predicate)

@bot.command()
@is_in_server_list(IDS)
async def dosomething(ctx) -> None:
      # command here

something like that probably.

verbal junco
#

"cog" is the better way to put my commands in other folder and call in my main?

slate swan
#

try it out

slate swan
flat solstice
# calm ridge

Not sure but there might be a white space on that line which could do with being removed. If its the line between the for and if statements

sick birch
# calm ridge
@client.event
async def test(ctx):
    global api
    if str(ctx.channel.name) == "success": #Set channel name it is viewing

guessing this is what it is

#

You have an empty if statement

#

If the channel name is "success", then what?

slate swan
#

Oh yeah

indigo pilot
#

Did i do something wrong? Or why isnt the if statement running lol
https://i.leaked-your.info/XN6SN1b3
https://femboi.best/5QipZlrc

When i print user premium guilds, its there https://i.leaked-your.info/6FX8C8vR

sick birch
#

server.id is an integer

#

!e print(12345 == "12345") # this is what's going on here

unkempt canyonBOT
#

@sick birch :white_check_mark: Your 3.11 eval job has completed with return code 0.

False
indigo pilot
#

wait oh, it looks like its a int in compass, oooops

#

tyty

smoky cedar
#

Can you make an ephemeral message not ephemeral after already sending?

#

Sorry pal, this was not a response to you

fading marlin
#

have you synced your tree?

smoky cedar
fading marlin
vale cape
#

Is there anyway to restrict command use/visibility to role-specific users?

torn sail
vale cape
torn sail
#

!d discord.app_commands.checks.has_role

unkempt canyonBOT
#

@discord.app_commands.checks.has_role(item, /)```
A [`check()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.check "discord.app_commands.check") that is added that checks if the member invoking the command has the role specified via the name or ID specified.

If a string is specified, you must give the exact name of the role, including caps and spelling.

If an integer is specified, you must give the exact snowflake ID of the role.

This check raises one of two special exceptions, [`MissingRole`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.MissingRole "discord.app_commands.MissingRole") if the user is missing a role, or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.NoPrivateMessage "discord.app_commands.NoPrivateMessage") if it is used in a private message. Both inherit from [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.CheckFailure "discord.app_commands.CheckFailure").

New in version 2.0...
torn sail
#

Won’t show in ui tho

vale cape
#

Appreciate you Master man

torn sail
#

👍

jovial plover
#

How can i get ctx.content of a Webhook

#

Appreciate any help please

sick birch
#

Are you syncing?

#

The only thing I am doing is making a request to an API
@slender hamlet what request are you making and to what endpoint?

scenic badge
#

Anyone wanna make a discord bot together?

slate swan
jovial plover
#

Yes

slate swan
silk fulcrum
#

yt tutorials are bad for dpy

#

lomao

#

so no errors? you just run command and it does nothing right?

#

wait why the hell would you name the function self? I mean.. it probably won't affect but why not just name it stats or _stats?

#

Also.. I don't really get what does self.synced do, because in docs Client does not have this attr, but I did not use slash commands so probably it matters

shrewd apex
#

there is nothing called self.synced its a custom attr

#

and also use a setup hook dont that in on_ready

silk fulcrum
#

u are in the guild with id that you set in command right?

cold tide
#
@bot.command()
async def roll(ctx):
    embed=discord.Embed()
    embed=discord.Embed(title=f"{ctx.author} just rolled a ",description=(random.randint(10,1000)),color=0FF00)
#

Why wont it run?

#

Oh.

silk fulcrum
#

why would you create embed var and recreate it on the next line?

cold tide
#

idk 😭

#

is that the issue??

silk fulcrum
#

probably not

cold tide
#

Shouldnt be.

#

i always do that

silk fulcrum
#

also in description= you put your randint into brackets

#

there is not reason to do that

cold tide
#

Oh

silk fulcrum
#

description=random.randint(10,1000)

#

and your color code looks weird

cold tide
#

Still a error

silk fulcrum
#

what error?

#

lmaoo

cold tide
silk fulcrum
#

show the error

cold tide
#

Yes.

silk fulcrum
#

it should point with ^ where is inval syntax

cold tide
#

😭

silk fulcrum
#

in code there is ( missing

#

right where your cursor is

cold tide
#

just did that

#

Still a error

silk fulcrum
#

same?

cold tide
#

Yes

#

Can you show me what u have

#

Copying urs might fix it.

silk fulcrum
#

wdym that I have?

cold tide
eternal fox
#

the closing ) ?

silk fulcrum
#

yeah also closing

#

oh you thought I was talking about all brackets?

cold tide
#

I did do that

slate swan
#

you forgot the x in your hexcode

silk fulcrum
#

you need to have random.randint(10, 1000)

cold tide
#

I did that

silk fulcrum
cold tide
#

?

slate swan
#

it would currently be undefined lol

#

as its not a hexcode pithink

cold tide
#

Oh okay

silk fulcrum
#

i also saw that color is not good but i didnt think it could raise syntax inavlid

slate swan
#

it wouldnt, the brackets were raising the syntax error, what was passed to the color kwarg would just raise undefined

silk fulcrum
#

ohkay

slate swan
#

since it thinks its a varpithink

#

and hey master👋

silk fulcrum
#

hey okimii 👋

slate swan
#

✌️

#

Hi okimii

slate swan
slate swan
#

lol

static lintel
#

hi i had a quick question: what goes in place of the 123456 and token-here

webhook.send('Hello World', username='Foo')```
silk fulcrum
#

id and token of webhook

vocal snow
#

!d discord.SyncWebhook.partial

unkempt canyonBOT
#

classmethod partial(id, token, *, session=..., bot_token=None)```
Creates a partial [`Webhook`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Webhook "discord.Webhook").
static lintel
#

what is the token from tho?

#

wait sorry im stupid and didn't read

silk fulcrum
static lintel
#

i only see the url but no id and token?

unkempt canyonBOT
#

@silk fulcrum, looks like you posted a Discord webhook URL. Therefore, your message has been removed, and your webhook has been deleted. You can re-create it if you wish to. If you believe this was a mistake, please let us know.

silk fulcrum
#

i wanted to send an example

static lintel
#

is it possible to screenshot?

slate swan
silk fulcrum
static lintel
#

how do i know which is which?

slate swan
static lintel
#

gotcha

#

tysm

silk fulcrum
#

how long should I wait for my bot's avatar to change?

slate swan
shrewd apex
#

umm it's instant is it not?

silk fulcrum
shrewd apex
#

sed make it leave and join again

silk fulcrum
#

ok..

glad cradle
#

could it be that you changed the avatar too many times in a short period of time?

silk fulcrum
#

the only time I changed it was when I created it

glad cradle
#

A

silk fulcrum
#

and second right now

slate swan
# silk fulcrum

you should change it in the bot settings, not application settings

#

this avatar will appear while inviting the bot, not on discord

silk fulcrum
#

ohbruh

#

I somehow thought that bot's changes automaticly

#

with app's

slate swan
#

🗿 same but sometime it does, sometime it doesnt

static lintel
#

im trying to change the avatar for the webhook and when i set an image link i get this
Command raised an exception: TypeError: startswith first arg must be str or a tuple of str, not bytes

silk fulcrum
#

what's the code

#

or full traceback

#

cus you use bytes object in startswith

static lintel
#
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/webhook/sync.py", line 792, in edit
    payload['avatar'] = utils._bytes_to_base64_data(avatar) if avatar is not None else None
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/utils.py", line 570, in _bytes_to_base64_data
    mime = _get_mime_type_for_image(data)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/utils.py", line 556, in _get_mime_type_for_image
    if data.startswith(b'\x89\x50\x4E\x47\x0D\x0A\x1A\x0A'):
TypeError: startswith first arg must be str or a tuple of str, not bytes

The above exception was the direct cause of the following exception:```
silk fulcrum
#

that is the problem

#

b'...'

static lintel
#

?

static lintel
silk fulcrum
#

nope?

#

b makes it bytes

static lintel
#

ohhh so i just need to add the b in front of the string and ill be good to go?

still swan
#

hello, im getting an error TypeError: can't subtract offset-naive and offset-aware datetimes, may someone help me please?

@Cog.listener()
async def on_member_join(self, member: discord.Member) -> None:
  created_at = member.created_at
  delta = (datetime.now() - created_at).days
  print(delta)
silk fulcrum
static lintel
#

okok

silk fulcrum
#

well anyways it's type error, not arguemnt...

lone lichen
silk fulcrum
#

uhoh

slate swan
#

lol another breaking change in 2.0

silk fulcrum
#

discord.utils.utcnow() :laom:

still swan
lone lichen
slate swan
#

yeah that exists

lone lichen
#

Fair

lone lichen
#

Yea thats good since It’ s tz aware

still swan
#

i dont know why..

slate swan
#

maybe because the time difference is 1707 days

silk fulcrum
#

!e

print(1707/365.4)```
still swan
slate swan
#

yeah thats basically (timedelta).days

unkempt canyonBOT
#

@silk fulcrum :white_check_mark: Your 3.11 eval job has completed with return code 0.

4.671592775041051
still swan
#

but the member just joined the guild

lone lichen
#

Datetime - timedelta = datetime

#

Not timedelta

silk fulcrum
#

created_at = account created at

#

not joined_at

slate swan
still swan
#

yea i want to defined if its alt account or no

lone lichen
silk fulcrum
#

ip ban :laomeo:

lone lichen
#

Try printing everything not just .days

still swan
#

okay

still swan
lone lichen
#

Can you send a ss of ur code

still swan
lone lichen
#

Ty

still swan
#

np xd

lone lichen
#

Print out created_at

slate swan
#

you have to add the timezone yourself iirc

still swan
slate swan
lone lichen
#

It’ s tz aware

slate swan
silk fulcrum
#

Oh that's not the same

lone lichen
#

No, thats tz aware

lone lichen
slate swan
#

why is the datetime library so weird

lone lichen
#

Wdym

lone lichen
silk fulcrum
slate swan
vale wing
#

Um, actually, pendulum is an upgraded version of datetime library 🤓

lone lichen
vale wing
#

!pypi pendulum

silk fulcrum
unkempt canyonBOT
lone lichen
#

Oh okok

slate swan
#

@still swan what is your code supposed to do

silk fulcrum
lone lichen
slate swan
lone lichen
silk fulcrum
silk fulcrum
lone lichen
silk fulcrum
still swan
#

on_member_join

lone lichen
#

You mean self bots?

silk fulcrum
#

alt != selfbot

lone lichen
#

Cus I have alts that were created 2 years ago

still swan
#

xd..

silk fulcrum
#

these are alts

still swan
#

👀

silk fulcrum
#

wait wtf is this

still swan
#

O_O

lone lichen
silk fulcrum
#

when discord made it, i totally missed

lone lichen
#

For testing

lone lichen
#

Yesterday I discovered it

silk fulcrum
slate swan
#

@still swan add .days to your delta variable

lone lichen
slate swan
#

What does discord.utils.utcnow() do exactly?

silk fulcrum
lone lichen
slate swan
#

why not use datetime.utcnow() and compare with Member.created_at

silk fulcrum
#

!d datetime.datetime.utcnow

unkempt canyonBOT
#

classmethod datetime.utcnow()```
Return the current UTC date and time, with [`tzinfo`](https://docs.python.org/3/library/datetime.html#datetime.datetime.tzinfo "datetime.datetime.tzinfo") `None`.

This is like [`now()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.now "datetime.datetime.now"), but returns the current UTC date and time, as a naive [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") object. An aware current UTC datetime can be obtained by calling `datetime.now(timezone.utc)`. See also [`now()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.now "datetime.datetime.now").

Warning

Because naive `datetime` objects are treated by many `datetime` methods as local times, it is preferred to use aware datetimes to represent times in UTC. As such, the recommended way to create an object representing the current time in UTC is by calling `datetime.now(timezone.utc)`.
silk fulcrum
#

they're same

slate swan
silk fulcrum
slate swan
lone lichen
silk fulcrum
little lava
#

is there any alternative of

await ctx.send``` ?
lone lichen
#

Read the 3rd paragraph

lone lichen
slate swan
little lava
lone lichen
#

datetime.now(timezone.utc) would be the same as discord.utils.utcnow

silk fulcrum
silk fulcrum
slate swan
silk fulcrum
#

do you even see your code?

little lava
#

there is 2 problems

lone lichen
unkempt canyonBOT
#
Not in a million years.

No documentation found for the requested symbol.

slate swan
lone lichen
#

!d discord.Message

unkempt canyonBOT
#

class discord.Message```
Represents a message from Discord.

x == y Checks if two messages are equal.

x != y Checks if two messages are not equal.

hash(x) Returns the message’s hash.
silk fulcrum
unkempt canyonBOT
#
await send(content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sends a message to the destination with the content given.

The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.

To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/latest/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`File`](https://discordpy.readthedocs.io/en/latest/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.

To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`Embed`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
slate swan
#

a bot can send stickers

little lava
#

i dont want triggers so

lone lichen
#

What do u wanna do

silk fulcrum
#

kill his code

slate swan
#

probably use utils and get the channel object

little lava
#

send offline status to the text channel

#

of EC2 instance

slate swan
silk fulcrum
#

it's not even in function

#

the simplest is that you cant use await

#

bbruh

lone lichen
little lava
#

await requires async def

slate swan
#

underlines mean code is very good

lone lichen
#

You cant await coroutines outside async function

little lava
lone lichen
#

U can do asyncio.run

slate swan
lone lichen
#

But not just straight await …

slate swan
#

master32 is genius ask him @little lava

silk fulcrum
#

im colorblind

lone lichen
#

😂

slate swan
silk fulcrum
#

i didnt see the t

#

wait that's not colorblind

#

bruh im brainblind

slate swan
lone lichen
silk fulcrum
#

aight gonna test it

#

should definetly work

slate swan
#

works

#

💯

lone lichen
# little lava

Do you want this to check status continuously or just once

silk fulcrum
#

AHAHAHHA python is like pointing everywhere, like saying are u stupid?

little lava
#

continuously, but when status changed to "stopped"

silk fulcrum
lone lichen
#

Just wanna confirm

slate swan
#

enslo code it for them

lone lichen
silk fulcrum
#

lets go

slate swan
#

you sure

slate swan
little lava
#

i don't have much knowledge on coding but im trying..

lone lichen
slate swan
lone lichen
slate swan
#

they are meanies don't listen to their mean words

little lava
silk fulcrum
silk fulcrum
#

Um actually, xtc?

slate swan
#

Um actually, tcx

lone lichen
# little lava that's delete

Yes, that wont work, even if the await outside coroutine wouldnt be an issue, it would only check it once and stop running

slate swan
silk fulcrum
#

Um actually, txc

slate swan
slate swan
#

I hate pycharm

#

why is ther slowmode in this channel

lone lichen
slate swan
silk fulcrum
lone lichen
slate swan
silk fulcrum
slate swan
silk fulcrum
#

hot potato game?

lone lichen
silk fulcrum
#

idontcare

slate swan
#

does anyone actually use pycharm?

lone lichen
#

Me

silk fulcrum
#

i can outsmart him really easy

slate swan
#

asyncio.run expects a coroutine object pithink

silk fulcrum
slate swan
lone lichen
slate swan
#

fair

silk fulcrum
lone lichen
slate swan
#

🤔

silk fulcrum
lone lichen
slate swan
#

i wanna learn how to use @tasks.loop and waht it does

slate swan
lone lichen
silk fulcrum
slate swan
lone lichen
#

Vscode is text editor with ide plugin

slate swan
#

it's getting on my nerves 😭

silk fulcrum
slate swan
slate swan
#

Real

lone lichen
#

Also It’ s from Microsoft

slate swan
#

bill gates can take my money

silk fulcrum
#

or how its called

slate swan
#

@slate swan When comparing strings of same lens, are their byte sizes compared?

lone lichen
lone lichen
lone lichen
silk fulcrum
#

windwows is good only because EVERYTHING is wrote for it

lone lichen
#

I have to use windows in school for coding

silk fulcrum
#

every single game

lone lichen
#

Game

slate swan
#

Windows > 😄

lone lichen
#

Not bash

slate swan
#

windows != linux

lone lichen
#

Or brew

lone lichen
silk fulcrum
lone lichen
#

Programming on windows is basically shooting yourself in the foot

#

And in the head

silk fulcrum
#

absolutely

lone lichen
#

Except if u do game dev

slate swan
unkempt canyonBOT
#

@slate swan :white_check_mark: Your 3.11 eval job has completed with return code 0.

True
silk fulcrum
#

well it can be easier with WSL, but still not that easy as on linux

slate swan
silk fulcrum
unkempt canyonBOT
#

@silk fulcrum :white_check_mark: Your 3.11 eval job has completed with return code 0.

False
slate swan
#

lame

#

now oneline it

lone lichen
slate swan
#

!e

import sys
print(sys.getsizeof("a"),  sys.getsizeof("A"))
unkempt canyonBOT
#

@slate swan :white_check_mark: Your 3.11 eval job has completed with return code 0.

50 50
silk fulcrum