#discord-bots

1 messages Ā· Page 935 of 1

slate swan
#

i want it

#

pls help?

dull terrace
#

This isn't where you're creating the buttons?

azure tulip
#

I hid the token

slim ibex
#

inefficient way, but make a list of restricted words, loop through them, and check if its in the message

slate swan
narrow grail
#

is it possible that the bot can use server emojis without having nitro?

slate swan
#
await b.send(emb,components=Closetic(bot))
#

wai

#

wait

narrow grail
dull terrace
slate swan
#

i forgot embed=emb

dull terrace
#

right click and open image and youll find the id number in the url

#

i think your bot needs to be in server of emoji you're trying to use

slate swan
#

uh same error

slate swan
dull terrace
slate swan
#

do u mean this

dull terrace
#

idk how disnake works but when i make a button it's components=[ActionRow(Button(style=2, label="this is an example, custom_id="butt monkeys"))]

azure tulip
#

Whom? I just don't understand a little

dull terrace
#

oh and style

slate swan
#

blurple

#

so

#

@slate swan nothing all fixed

#

Stop using 3rd party libraries, go for a fork or discord.py master branch

#

disnake is third party?

#

Example.

#

Is that Disnake?

#

yes

narrow grail
slate swan
#

..

slate swan
slate swan
#

Ok nvm, you won't use components for sending a view, it's .send(view= ViewClass())

#

yes

#

components is used for an ActionRowBuilder

dull terrace
slate swan
#

wait

dull terrace
#

i think you just string it

slate swan
#

i put component there by mistake tf

slate swan
#

instead of view

slate swan
#

thats the issue ig

rocky trench
#

how do I add category's to the help command? I always used groups, I wanna modify it now

slate swan
#

You can't use that @button decorator there then

narrow grail
slate swan
#

It's meant for views

slate swan
rocky trench
#

how do I add category's to the help command? I always used groups, I wanna modify it now

slate swan
#

mistakely i put components there

#

šŸ‘

dull terrace
#

you're not fetching the emoji correctly

narrow grail
dull terrace
dull terrace
dull terrace
#

then change client to bot

narrow grail
#

I know, but that's not the problem

#

it's something with the emoji

dull terrace
#

do you have the correct emoji number and passing it as an int?

narrow grail
#

ik

#

can you try it with my id?

dull terrace
#

wont work with my bot because im not in server

#

show code where you get the emoji

narrow grail
#
    await ctx.channel.send(content=f'not working, sorry {sad}')``` @dull terrace
dull terrace
#

hmmm

narrow grail
#

and when I call this command it sends not working, sorry None

dull terrace
#

well the only thing that could be is that it's not getting the emoji

#

not sure why that is

#

try with different emojis

dull terrace
narrow grail
#

oooh I copied the ID from the message and not from the emojibrainmon @dull terrace

dull terrace
#

šŸ˜…

slate swan
#

oof

narrow grail
#

bro discord just literally pranked me

dull terrace
#

it pranks us all

cold sonnet
#

why do you async run client.run()

#

it's a normal func

#

dunno

#

what can't you do on client with cogs

#

oh that

vocal plover
#

Why not just use commands.Bot?

cold sonnet
#

nah it really doesn't have cogs

vocal plover
#

command handling is only part of what commands.Bot does

#

cogs are a perfectly good reason to use it

#

it would be better if you didn't need to for cogs I agree

lament mesa
#

yes

#

but i won't recommend it though

#

just use good ol commands.Bot

narrow grail
#

how to send a message which only the executer can see?

vocal plover
#

You can send ephemeral messages in response to interactions only, so if someone runs a slash command or clicks a button you can use interaction.response.send(..., ephemeral=True)

slate swan
#

and isnt the executer the bot itself šŸ˜”

#

why it doesn't work

narrow grail
slate swan
#

because you are using the Member class itself rather than using an instance of it

#

rip the reply didnt even work

#

so I should do that ?

#

yeah

south jetty
#

How can I put time in the bot status

slate swan
slate swan
south jetty
slate swan
south jetty
#

I mean docs on it

slate swan
unkempt canyonBOT
#
Nope.

No documentation found for the requested symbol.

slate swan
#

tf

#

!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)`.
slate swan
#

you can use the strftime attribute on this to format your time

#

and use pytz with datetime for different timezones

south jetty
#
@client.event
async def on_ready():
  await client.change_presence(status=discord.Status.dnd, activity=discord.Game(f'Time {datetime.utcnow()}'))
  print(f"Logged in as {client.user}")```
#

like this?

azure tulip
#

How to fix it?

#

And I found everything

slate swan
#

how to fix this

#

here's my code

hoary cargo
azure tulip
hoary cargo
#

what your typos tho

#

it's says pretty clear

hoary cargo
formal nova
hoary cargo
# slate swan thanks my bad

in your command member is a required argument, so just by doing prefix userinfo will not do anything, you can do member: discord.Member = None and make an error handler though or a check

south jetty
#
await client.change_presence(status=discord.Status.dnd, activity=discord.Game)```
How can I make it watching instead of playing
compact ruin
#

Quick question how do i unban a user using their user ID?

slim ibex
compact ruin
gaunt ice
#

hm

slim ibex
#

you would have the match your member parameter’s discriminator and name to the user (discord account) discriminator and name

compact ruin
gaunt ice
#

ctx.guild.unban(userid)

#

or am i wrng

#

im tired rn my brain is just wandering in pain

#

that is if he had a name

#

he said id

slim ibex
#

bro every discord account has a name

gaunt ice
#

yea

#

he has id so why make it complex

slim ibex
#

oh didn’t see that lol

gaunt ice
#

lol

compact ruin
#

Lmao im tryna keep it simple using ID

slim ibex
#

It’s only a few lines for what I’m suggesting

compact ruin
#

but for whatever reason it does not find the ID

south jetty
#
await client.change_presence(status=discord.Status.dnd, activity=discord.ActivityType.watching(f'Time{datetime.utcnow()}'))```
How am I support to put strftime in it
gaunt ice
compact ruin
spring flax
#

has anyone used fastapi for a bot dashboard?

compact ruin
#

but apparently it does not find the user

slim ibex
#

I think my approach would be the fastest and easiest

compact ruin
#

and idk if its me but i couldnt find the api

slim ibex
#

But what you CAN do is

#

pass your id param to fetch_user

#

That should work

gaunt ice
#

bot.fetch_user(id)

#

like moai said

slim ibex
#

user = bot.fetch_user(id)

gaunt ice
#

hello ashley

slim ibex
#

await ctx.guild.unban(user)

hoary cargo
spring flax
slate swan
unkempt canyonBOT
#

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

15:21:29
slim ibex
slate swan
#

the time is wrong pepe_exit it will work properly for you though

spring flax
slim ibex
spring flax
#

i mean...

slate swan
slim ibex
#

and i have never used discord.Object šŸ—æ

hoary cargo
#

!d discord.Object

unkempt canyonBOT
#

class discord.Object(id)```
Represents a generic Discord object.

The purpose of this class is to allow you to create ā€˜miniature’ versions of data classes if you want to pass in just an ID. Most functions that take in a specific data class with an ID can also take in this class as a substitute instead. Note that even though this is the case, not all objects (if any) actually inherit from this class.

There are also some cases where some websocket events are received in [strange order](https://github.com/Rapptz/discord.py/issues/21) and when such events happened you would receive this class rather than the actual data class. These cases are extremely rare.

x == y Checks if two objects are equal.

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

hash(x) Returns the object’s hash.
spring flax
#

i'd suggest discord.Object, saves an API call for one and is just more efficient i heard

slim ibex
#

ahh ok

hoary cargo
#

whatTf i mean efficient in what sense

spring flax
#

to who was asking for it, it'd be ```py
async def unban(ctx, member_id : int):
member = discord.Object(member_Id)
await ctx.guild.unban(member)

hoary cargo
#

both do their job

spring flax
slim ibex
#

It’s essentially the same thing, though.

hoary cargo
maiden fable
#

u can directly do member_id: discord.Object iirc

sage otter
#

I mean if you read above you’d see that he said it makes an unnecessary api call that just gets wasted.

maiden fable
#

But idk never tried

sage otter
south jetty
spring flax
maiden fable
#

idk never made an unban command ĀÆ_(惄)_/ĀÆ

spring flax
#

yes what Tylerr said, discord.Object doesn't use an API call

compact ruin
#

Got it to work

#

Ty @slim ibex

hoary cargo
sage otter
#

That’s a shitty way to think of it

slim ibex
slate swan
#
bot.timer = 0

@bot.command()
async def addtimer(ctx, duration):
    bot.timer += 1
    await asyncio.sleep(int(duration))
    bot.timer -= 1

@bot.command()
async def myrunningtimers(ctx):
    await ctx.send(f"{bot.timer}")

Does anyone know how i could make it so if i have a timer running and he does the myrunningtimers command it wont show one for him?

sage otter
#

Just because your bots not big doesn’t mean you shouldn’t avoid stuff like that.

slate swan
sage otter
#

Good developers actually optimize their code beforehand so they won’t have to waste time doing it later šŸ‘Œ

spring flax
sage otter
#

that’s a generator?

spring flax
#

yeah

slim ibex
#

(expression for elem in something) is a gen exp

sage otter
#

!e
print(type((i for i in range(5))))

unkempt canyonBOT
#

@sage otter :white_check_mark: Your eval job has completed with return code 0.

<class 'generator'>
sage otter
#

oh ok.

slim ibex
#

Generator expressions are what everyone thinks tuple comprehension are

sage otter
#

That’s what I was just thinking it was I’m not gonna lie.

slim ibex
#

don’t think tuple comps exist

spring flax
#

yeah they don't

#

it'll return a generator object if you try it iirc

slim ibex
#

!e

a = (x for x in range(10))
print(a.__next__())
print(a.__next__())
print(a)
unkempt canyonBOT
#

@slim ibex :white_check_mark: Your eval job has completed with return code 0.

001 | 0
002 | 1
003 | <generator object <genexpr> at 0x7f909c843ca0>
south jetty
#
line 17, in on_ready
    await client.change_presence(status=discord.Status.dnd, activity=discord.ActivityType.watching(datetime.utcnow().strftime("%H:%M:%S")))
TypeError: '_EnumValueBase_ActivityType' object is not callable```
compact ruin
# slim ibex np

One more question do you know how i would convert the UID into the Username?

wooden vale
#
@client.command()
async def frame(ctx):
  message = await ctx.channel.fetch_message(ctx.message.reference.message_id)
  if message.author.id == 646937666251915264:
    reg = re.compile('<@!?([0-9]+)>')
    matches = reg.findall(message.content)
    await ctx.send(f"User: {matches}")```
Why i get as output ```[]```
compact ruin
teal fern
south jetty
compact ruin
#

Does anyone know how i can convert the user id into a name of someone who is not in the guild?

south jetty
#

because I don't know how it works

spring flax
#

Anyways, has anyone made a dashboard with fastapi?

sage otter
spring flax
teal fern
sage otter
#

that has to be the dumbest shit I’ve ever read in this channel

#

() implies it’s a callable

slim ibex
#

šŸ’€

maiden fable
unkempt canyonBOT
wooden vale
sage otter
#

Meaning it can also be a function.

maiden fable
#

!d discord.MessageReference

unkempt canyonBOT
#

class discord.MessageReference(*, message_id, channel_id, guild_id=None, fail_if_not_exists=True)```
Represents a reference to a [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message").

New in version 1.5.

Changed in version 1.6: This class can now be constructed by users.
spring flax
#

oh didn't know that existed

teal fern
sage otter
#

And the error means is saying ActivityType is not a callable and that is an enum.

teal fern
hoary cargo
sage otter
#

i sure hope so.

slim ibex
#

^

teal fern
#

K

wooden vale
sage otter
#

I never said you had to optimize 100%. I said if you have the chance you should try.

teal fern
#

Cya

spring flax
#

oh what did you make?

sage otter
#

why do it later when your bot gets big when you can do it now and save yourself some effort later.

#

You're making it harder on yourself

#

For no reason at all.

spring flax
maiden fable
#

šŸ‘€ Ash coming to run the ot command

#

I'mma delete the messages instead

#

!d disnake.Member.timeout

unkempt canyonBOT
#

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

Times out the member from the guild; until then, the member will not be able to interact with the guild.

Exactly one of `duration` or `until` must be provided. To remove a timeout, set one of the parameters to `None`.

You must have the [`Permissions.moderate_members`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.moderate_members "disnake.Permissions.moderate_members") permission to do this.

New in version 2.3.
sage otter
#

What library are you using

#

if you're using dpy 2.0 you have to use Member.edit()

slate swan
maiden fable
#

šŸ˜”

sage otter
#

no that’s just another useless abstraction

maiden fable
#

I just hate it when discord turns off ping automatically

maiden fable
sage otter
#

Member.edit(timed_out_until) was the implementation he gave us

maiden fable
#

Well that's is cool

#

u have the member object so get the username. u have the time till which the member is muted so u get the time of mute. reason is just another kwarg in the command

maiden fable
slate swan
#

no means no

maiden fable
#

weirdo ĀÆ_(惄)_/ĀÆ

slate swan
#

gib code not shit Docspepe_exit

maiden fable
#

No thanks

slate swan
south jetty
#

where can I find timestamp styles

maiden fable
#

!d discord.utils.format_dt

unkempt canyonBOT
#

discord.utils.format_dt(dt, /, style=None)```
A helper function to format a [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "(in Python v3.10)") for presentation within Discord.

This allows for a locale-independent way of presenting data using Discord specific Markdown...
south jetty
maiden fable
#

Or that, yea

spring flax
south jetty
#

how can I get 12hr clock style

spring flax
spring flax
#

twenty four hour only as short or long time

south jetty
#

ok nvm found what im looking for

sick birch
#

It’s locale specific

slate swan
sick birch
#

Depending on where you live the clock will show 24h/12h

slate swan
#

timestamp

compact ruin
#

Guys is it possible to use the timeout feature using python?

slate swan
#

sometimes my json glitch and dump 2 same

#

key value

compact ruin
slate swan
sage otter
buoyant zodiac
#

how do i get a role then?

compact ruin
sage otter
#

Oh. My bad then. Which lib are you using.

#

A fork or the main dpy.

compact ruin
#

Main

sage otter
#

2.0?

slate swan
#

anyone know the code to the timestamp without the .882340?

sage otter
#

Or 1.7.3?

compact ruin
#

Im usin Python 3.9 atm

pure sparrow
slate swan
#

absolutely nothing

pure sparrow
slate swan
#

yeh

south jetty
#
  await client.change_presence(status=discord.Status.dnd, activity=discord.Activity(type=discord.ActivityType.watching, name=datetime.utcnow().strftime("%I:%M %p")))```

How can I change time to est
south jetty
#

didnt work

#

change to cst rather

unkempt canyonBOT
south jetty
#

so it would be pytz.cst?

#

wait no uh

spring flax
#

you can see examples on the docs, i'm not that familiar try it and check

boreal ravine
#

which one do you guys like?

slate swan
#

1st

boreal ravine
#

ty

slate swan
#

Idk if i spelled it right lmao

slate swan
slate swan
buoyant zodiac
#
if role.position > ctx.author.highest_role:
buoyant zodiac
#

would that work ?

slate swan
#

Board*

slate swan
buoyant zodiac
#

its top_role, okay

slate swan
#

top_role.position

pliant gulch
#

No need

#

discord.Role impl's gt or lt

#

So you can just do if role > ctx.author.top_role

spring flax
boreal ravine
#

gt = >
lt = <

spring flax
#

oh you mean greater than or less than

quick gust
#

greater than less than

pliant gulch
#

Yep

#

__gt__ & __lt__

slate swan
slate swan
spring flax
slate swan
buoyant zodiac
#

how to edit a roles name?

slate swan
slate swan
unkempt canyonBOT
#

await edit(*, name=..., permissions=..., colour=..., color=..., hoist=..., display_icon=..., mentionable=..., position=..., reason=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the role.

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

All fields are optional.

Changed in version 1.4: Can now pass `int` to `colour` keyword-only parameter.

Changed in version 2.0: Edits are no longer in-place, the newly edited role is returned instead...
south jetty
#

pytz is confusing

slate swan
#

red emoji on red button is not the best idea so text is better

boreal ravine
#

just gotta get used to it ig

boreal ravine
buoyant zodiac
#
await role.edit(colour=color)

i typed:

,role color muted #800080
quick gust
buoyant zodiac
#

it knows the role but the color didnt set?

slate swan
buoyant zodiac
#

so no #?

slate swan
#

Try int(color, 16)

#

Color is str

#

it changes it to an int

buoyant zodiac
#

i got it

slate swan
# buoyant zodiac where

For example : py @bot.command() async def mycommand(ctx, color, otherparams): em = discord.Embed(color = int(color, 16))

slate swan
autumn trench
#

with discord.py, how do i get a user object from a guild? i'm trying to make it so a command sent in the dms can change the role of the user in the server, this is what i have right now: bot.get_guild(guild_id).get_user(author.id).roles

quick gust
#

iirc it's get_member

#

!d discord.Guild.get_member

unkempt canyonBOT
#

get_member(user_id, /)```
Returns a member with the given ID.

Changed in version 2.0: `user_id` parameter is now positional-only.
autumn trench
#

thank you!

quick gust
#

no worries

slate swan
toxic thicket
#
@bot.command()
async def преГы(ctx, member: discord.Member = None):
	cursor.execute("""CREATE TABLE IF NOT EXISTS warning(guild BIGINT, userid BIGINT, warn INT, count INT, reasons VARCHAR)""")
	base.commit()
	print(1)
	global warnings
	warnings = cursor.execute("SELECT * FROM warning WHERE userid = ?", (ctx.author.id,)).fetchone()
	print("работает")
 
         
	if member is None:
	   	await ctx.send(f"ŠŸŃ€Š¾Š²ŠµŃ€ŠŗŠ° по базе Ганных...\nŠŸŃ€Š¾Š²ŠµŃ€ŠŗŠ° ŠæŃ€Š¾ŃˆŠ»Š°.\n{ctx.author.name} Š£ вас {warnings[2]} ŠæŃ€ŠµŠ“ŃƒŠæŃ€ŠµŠ¶Š“ŠµŠ½ŠøŠ¹")
	else:
	   	 await ctx.send(f"ŠŸŃ€Š¾Š²ŠµŃ€ŠŗŠ° по базе Ганных...\nŠŸŃ€Š¾Š²ŠµŃ€ŠŗŠ° ŠæŃ€Š¾ŃˆŠ»Š°.\n{member.name} Š£ вас {warnings[2]} ŠæŃ€ŠµŠ“ŃƒŠæŃ€ŠµŠ¶Š“ŠµŠ½ŠøŠ¹!")ā€Š

Help me please.Why when a member is mentioned, their warn are shown??

slate swan
azure tulip
#

how to remove it? The code works fine, the bot starts up

slate swan
formal nova
#

Change it

azure tulip
#

Thank

slate swan
slate swan
#

hmmmm

#

Ye šŸ¤·šŸ¾

#

disnake is the best PB_finger_point_cool change ma mind

#

maybe

#

!d disnake.ext.commands.Bot.slash_command

unkempt canyonBOT
#

@slash_command(*args, **kwargs)```
A shortcut decorator that invokes [`slash_command()`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.slash_command "disnake.ext.commands.slash_command") and adds it to the internal command list.
toxic thicket
#

I forgot to remove it, so why, at the mention, my number of warns is shown@slate swan

slate swan
#

Why BotMissingArgument doesn't work

slate swan
#

I really dont know what u want

azure tulip
#

Why doesn't it work?

toxic thicket
#

To show how many warns the user has when he is mentioned@slate swan

tough lance
#

You have it as on_rady

azure tulip
toxic thicket
#

no, it shows only its own varnas even when the user is mentioned@slate swan

azure tulip
#

Why does this pop up for me?
"The system could not find the specified path"

slate swan
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

slate swan
#

@slate swan tu sais pourquoi BotMissingArgument Marche pas ?

slate swan
#

you're french?

#
import requests, discord, os, random, subprocess
from startBot import *
from commands.normal import *

class gradientFunctions:
    async def SendGradientSingle(ctx, RGBValues:str):
        Sensitive_Chars = ['"', '@','#','{','}',';','-','>','<','`','*','=','+','curl','\\']
        if len(RGBValues)>=7:
            await ctx.send(" Please provide a 6-digit hex character.")
            return
        for x in RGBValues:
            for f in range(0,len(Sensitive_Chars)):
                if x in Sensitive_Chars[f]:
                    await ctx.send(" Your input contains an invalid character.")
                    return
                else:   pass
        random = random.randint(1,900)
        s = subprocess.getoutput(f"curl -X GET https://singlecolorimage.com/get/{RGBValues}/400x100 --output temp.{random}.myTemporaryFile")
        await ctx.send(f"Output\n{s}",file=discord.File(f'temp.{random}.myTemporaryFile'))
        return

Can anyone help me with why the program is not working after s = os.system(f"curl -X GET https://singlecolorimage.com/get/{RGBValues}/400x100 --output temp.{random}.myTemporaryFile")

slate swan
slate swan
slate swan
#

!d discord.ext.commands.BotMissingPermissions

unkempt canyonBOT
#

exception discord.ext.commands.BotMissingPermissions(missing_permissions, *args)```
Exception raised when the bot’s member lacks permissions to run a command.

This inherits from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")
slate swan
toxic thicket
#

@slate swan

@bot.command()
async def преГы(ctx, member: discord.Member = None):
	cursor.execute("""CREATE TABLE IF NOT EXISTS warning(guild BIGINT, userid BIGINT, warn INT, count INT, reasons VARCHAR)""")
	base.commit()
	print(1)
	global warnings
	warnings = cursor.execute("SELECT * FROM warning WHERE userid = ?", (ctx.author.id,)).fetchone()
	print("работает")
 
         
	if member is None:
	   	await ctx.send(f"ŠŸŃ€Š¾Š²ŠµŃ€ŠŗŠ° по базе Ганных...\nŠŸŃ€Š¾Š²ŠµŃ€ŠŗŠ° ŠæŃ€Š¾ŃˆŠ»Š°.\n{ctx.author.name} Š£ вас {warnings[2]} ŠæŃ€ŠµŠ“ŃƒŠæŃ€ŠµŠ¶Š“ŠµŠ½ŠøŠ¹")
	else:
	   	 await ctx.send(f"ŠŸŃ€Š¾Š²ŠµŃ€ŠŗŠ° по базе Ганных...\nŠŸŃ€Š¾Š²ŠµŃ€ŠŗŠ° ŠæŃ€Š¾ŃˆŠ»Š°.\n{member.name} Š£ вас {warnings[2]} ŠæŃ€ŠµŠ“ŃƒŠæŃ€ŠµŠ¶Š“ŠµŠ½ŠøŠ¹!")ā€Š
slate swan
#

the problem?

azure tulip
#

Why does this pop up for me?
"The system could not find the specified path"

slate swan
#

i dont quite understand what he means tbh

slate swan
slate swan
dull terrace
slate swan
azure tulip
slate swan
#

i wish i could help but i only speak english and spanish

#

so i dont know what the tb means

slate swan
tropic flame
#

yo btw there's no text chanel to advertise right ?

slate swan
#

can you advertise anywhere in this server no

slate swan
tropic flame
#

u got any server where u can advertise python stuff

slate swan
unkempt canyonBOT
#

6. Do not post unapproved advertising.

slate swan
#

this is the rule btw

tropic flame
slate swan
#

i know i just wanted to prove my point lol

tropic flame
slate swan
#

uhh i'm having a huge problem, if I enable the command in one server it will activate, but if I do it on another server it desactivate it

slate swan
#

how

#

so u can check if the guild has that option on or off

#

If its on then the bot is going to do stuff if its off then it will return or whatever you trying to do

#

Can anyone help me with discord.py, a image is not sending

#

!code

#
import requests, discord, os, random
from startBot import *
from commands.normal import *

class gradientFunctions:
    async def SendGradientSingle(ctx, RGBValues:str):
        Sensitive_Chars = ['"', '@','#','{','}',';','-','>','<','`','*','=','+','curl','\\']
        if len(RGBValues)>=7:
            await ctx.send(" Please provide a 6-digit hex character.")
            return
        for x in RGBValues:
            for f in range(0,len(Sensitive_Chars)):
                if x in Sensitive_Chars[f]:
                    await ctx.send(" Your input contains an invalid character.")
                    return
                else:   pass
        ranNum = random.randint(1,1000)
        with os.system(f"curl -X GET https://singlecolorimage.com/get/{RGBValues}/400x100 --output temporary.{ranNum}.myTempFile.jpg") as Request:
            await ctx.send(" R G B ",file=discord.File(f"D:\\Gradient Bot\\src\\temporary.{ranNum}.myTempFile.jpg"))
            os.remove(f"temporary.{ranNum}.myTempFile.jpg")
            return
slate swan
#

I want it to make public so it is a huge problem

#

I don't know how to make a db

sick birch
#

SQLite is a good starting point

south jetty
#
@commands.has_role("Support, Leaf")``` uh not working
slate swan
#

and thats not the deco for multiple roles

slate swan
south jetty
south jetty
slate swan
unkempt canyonBOT
#

@discord.ext.commands.has_any_role(*items)```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member invoking the command has **any** of the roles specified. This means that if they have one out of the three roles specified, then this check will return True.

Similar to [`has_role()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.has_role "discord.ext.commands.has_role"), the names or IDs passed in must be exact.

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

Changed in version 1.1: Raise [`MissingAnyRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingAnyRole "discord.ext.commands.MissingAnyRole") or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")
slate swan
#

is the deco you should use

south jetty
#

alright

slate swan
#

has_role checks if the author has those roles right?

#

yes

south jetty
#

so if I used role id 492212595072434186 i dont have to put ""

slate swan
#

the author who invoked the context of the command

slate swan
south jetty
slate swan
#

it has to be an int

south jetty
#

int?

slate swan
#

!e print(type(1))

unkempt canyonBOT
#

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

<class 'int'>
slate swan
#

no

south jetty
#
@commands.has_any_role(492212595072434186)```
slate swan
#

a number without a decimal point

south jetty
#

alright

#

thank you

slate swan
azure tulip
#

How to fix it?
"The system could not find the specified path"

#

code is working fine

lilac orbit
#

hey culd someone help me out with hosting a dc bot for free?

#

cause i hv got the code working it just the hosting part that's left

slate swan
#

i doubt someone would host your bot for free

lilac orbit
#

no like any hosting service that's free

#

cause i know 2 of em but hv issues with it

slate swan
#

well most of them arent really good tbh

lilac orbit
#

i've heard heroku is gud but not sure how to host a bot there

#

and in replit, if we edit the bot its difficult to re-host the bot

slate swan
#

you can but its not really meant for that

lilac orbit
#

^^"

slate swan
lilac orbit
#

o

sick birch
#

"Good free hosting" is a bit of an oxymoron

#

You either get frankly bad but free hosting, or high quality hosting that's paid

lilac orbit
#

oh

sick birch
#

Yep, I'll try my best

#

And you're using d.py as opposed to any forks?

polar plinth
#

Someone have economy Code or tutorial for it

cold sonnet
#

no

sick birch
#

Cool, yeah have you tried importing your tree instance?

slate swan
unkempt canyonBOT
cold sonnet
#

wait ashley didn't you do some economy bot shit cuz all the people want it

slate swan
#

yeah lol

sick birch
polar plinth
#

?

sick birch
#

I think it'd be better if you imported your slash command class/method instead

#

and used .add_command() on it

cold sonnet
#

no it's

#

meh

polar plinth
cold sonnet
#

shit as in good stuff

#

"That's the shit!" - That's the good thing!

slate swan
sick birch
#

Well would it be bad?

polar plinth
sick birch
#

Importing functions/classes between files isn't necessarily bad

#

If we're talking about performance, it's all done within memory so it's blazing fast

manic wing
#

?

sick birch
#

Well cogs do exactly that

#

Behind the scenes cogs are doing the same thing

#

For the time being there's no multi-file functionality

slate swan
sick birch
#

You could do it dynamically as well, with a for loop of sorts

slate swan
sick birch
#

Perhaps, but it would be easier to just do it manually

#

You'll only be overcomplicating it

#

"Slash command cogs" or not you're still importing the slash commands

#

It's only a matter of ease of use

slate swan
#

It doesn’t have to be designed like a cog

slate swan
#

Each command can just be in its own file

#

or each group

#

Make it whatever you want

#

Or create a class that acts similar to a cog where you iterate through its attributes to filter out its commands

#

importing can be fully dynamic tho

pliant gulch
unkempt canyonBOT
#

You are not allowed to use that command here. Please use the #bot-commands channel instead.

slate swan
#

jesus typing on a phone sucks

unkempt canyonBOT
#

importlib.import_module(name, package=None)```
Import a module. The *name* argument specifies what module to import in absolute or relative terms (e.g. either `pkg.mod` or `..mod`). If the name is specified in relative terms, then the *package* argument must be set to the name of the package which is to act as the anchor for resolving the package name (e.g. `import_module('..mod', 'pkg.subpkg')` will import `pkg.mod`).

The [`import_module()`](https://docs.python.org/3/library/importlib.html#importlib.import_module "importlib.import_module") function acts as a simplifying wrapper around [`importlib.__import__()`](https://docs.python.org/3/library/importlib.html#importlib.__import__ "importlib.__import__"). This means all semantics of the function are derived from [`importlib.__import__()`](https://docs.python.org/3/library/importlib.html#importlib.__import__ "importlib.__import__"). The most important difference between these two functions is that [`import_module()`](https://docs.python.org/3/library/importlib.html#importlib.import_module "importlib.import_module") returns the specified package or module (e.g. `pkg.mod`), while [`__import__()`](https://docs.python.org/3/library/functions.html#import__ "__import__") returns the top-level package or module (e.g. `pkg`).
slate swan
#

i typed it wrong again šŸ˜ž

pliant gulch
#

This is the same thing discord.py uses under the hood for cogs as well iirc

slate swan
#

What I used to do is define a __all__ variable in the file declaring the names of the objects i wanted exported

#

Then after importing the module I would iterate through __all__ and use getattr() on the module

#

If you want to reload your app during runtime, you can do so by deleting any python files that you want to be reloaded from sys.modules and then reimport it with importlib

#

!d sys.modules

unkempt canyonBOT
#

sys.modules```
This is a dictionary that maps module names to modules which have already been loaded. This can be manipulated to force reloading of modules and other tricks. However, replacing the dictionary will not necessarily work as expected and deleting essential items from the dictionary may cause Python to fail. If you want to iterate over this global dictionary always use `sys.modules.copy()` or `tuple(sys.modules)` to avoid exceptions as its size may change during iteration as a side effect of code or activity in other threads.
sick birch
#

What do you mean by group?

slate swan
#

It’s a dict[str, ModuleType]

sick birch
#

Do you mean like subcommands or?

pliant gulch
#

It would be funny if you could with open() a python file and make it act as a module

sick birch
#

That's one way

#

Another way would be to dynamically import all slash command callbacks, and in your main file (which has tree instance), use add_command()

#

You could copy the cog implementation and modify it to work with slash commands yeah

#

You could also have something like a setup() function that can add multiple slash commands per file, so that can double as "groups" like you mentioned

pliant gulch
#

The add_command way would increase your startup time

#

Actually, not even sure about that

#

Because either way commands get registered on runtime

slate swan
#

How?

pliant gulch
#

Because of how decorators work

sick birch
#

Well doesn't the decorator call add_command?

slate swan
#

!d discord.app_commands.CommandTree.command

unkempt canyonBOT
sick birch
#

yeah that

slate swan
#

add_command()’s speed is negligible

#

If anything, you will experience performance issues when importing modules

#

Python is pretty slow at this

pliant gulch
#

Importing will barely affect your performance

sick birch
#

Nah, if you're using slash commands that's not necessary

pliant gulch
#

I can't remember the exact steps, but I do remember there is only two steps with importing and it barely costs anything

compact ruin
#
@commands.has_permissions(ban_members = True)

I am typing this right correct?

#

For whatever reason it say's i do not have permissions

#

as server owner lol

pliant gulch
#

For some reason I feel like this might cause a namespace pollution

sick birch
#

šŸ‘ best of luck

pliant gulch
#

Probably not though

compact ruin
# cloud dawn More info?

@commands.command(name="ban")
@commands.cooldown(1, 3, commands.BucketType.user)
@commands.has_permissions(ban_members = True)

It says i am missing permissions

#

however as server owner i have the permissions to ban someone

#

however the bot decides otherwise?

#

Any idea why?

dusky cradle
#

someone has the banner command?

#

py

cloud dawn
cloud dawn
#

Since you are mixing stuff

pliant gulch
#

Namespace pollution just means that the namespace is filled with wrong information or etc

compact ruin
pliant gulch
#

Like, for an instance rin.aiohttp is a problem I had because I didn't have a proper __all__

compact ruin
#

Still the same

pliant gulch
cloud dawn
#

Likely you are trying to ban a member that is higher than the bot.

autumn trench
#

Hello! I'm trying to make a command that gives a user a category of their own, but for some reason it's not letting them edit the category at all, despite the fact that it should give them the perms for that. Is this a discord issue, or something I did wrong myself?

@bot.command()
async def category(ctx, *category_name):
    if category_name==[]:
        category_name = random.choice(open('data/WORDS.txt').read().split('\n')) + '_' + random.choice(open('WORDS.txt').read().split('\n'))
    else:
        category_name=' '.join(category_name)
    category = await bot.get_guild(917640265475440681).create_category(category_name)
    await category.set_permissions(bot.get_guild(917640265475440681).default_role, read_messages=True,send_messages=True,add_reactions=True,attach_files=True,create_instant_invite=False,manage_channels=False,manage_messages=False,manage_permissions=False,read_message_history=True,view_channel=True,mention_everyone=False,connect=True,speak=True,stream=True)
    await category.set_permissions(bot.get_guild(917640265475440681).get_member(ctx.author.id), read_messages=True,send_messages=True,add_reactions=True,attach_files=True,create_instant_invite=True,manage_channels=True,manage_messages=True,manage_permissions=True,read_message_history=True,view_channel=True,mention_everyone=False,connect=True,speak=True,stream=True)
    await category.set_permissions(bot.get_guild(917640265475440681).get_member(431544605209788416), read_messages=True,send_messages=True,add_reactions=True,attach_files=True,create_instant_invite=True,manage_channels=True,manage_messages=True,manage_permissions=True,read_message_history=True,view_channel=True,mention_everyone=False,connect=True,speak=True,stream=True)
    await bot.get_guild(917640265475440681).create_text_channel(category_name, category=category)
    await ctx.send(f'Your new category "{category_name}" has been created <@{ctx.author.id}>!')
compact ruin
cloud dawn
compact ruin
#

Ah got it-

#

The Role was simply below the person i was trying to ban

#

shoot- howd i miss that-
Crap-

compact ruin
#

@cloud dawn Ty For your help lmao

cloud dawn
compact ruin
#

Ah

#

Got you, Thanks

cloud dawn
#

Personally like adding a logger, kwargs according to that pep person is smashed against each other intents=None. The class name is also a bit weird since it doesn't describe what this class is.

austere vale
#
async def giveaway(self, ctx, time: int, *, prize):
        giveawayembed = nextcord.Embed(
            title="šŸŽ‰ New Giveaway! šŸŽ‰",
            color=0xfd9fa1
            )
        giveawayembed.add_field(name="Prize", value="{}".format(prize), inline=False)
        giveawayembed.add_field(name="Hosted by", value=f"{ctx.author.mention}", inline=False)
        giveawayembed.add_field(name="Ends in", value="{}s".format(time))
        msg = await ctx.send(embed=giveawayembed)
        await msg.add_reaction("šŸŽ‰")
        await asyncio.sleep(time)
        msg = await msg.channel.fetch_message(msg.id)

my giveaway code lets me set time limits in seconds only, how can i make it so that it accepts arguments like 1h, 3d, etc?

cloud dawn
#

!source tempmute

unkempt canyonBOT
#
Command: tempmute

Temporarily mute a user for the given reason and duration.

Source Code
austere vale
#

yeah it looks really complicated aniblobsweat

wooden vale
#

How i get name and # with regex?
Like <@!?([0-9]+)>

spring flax
austere vale
slate swan
#

regular expression

manic wing
slate swan
#

!d discord.Message.mentions

unkempt canyonBOT
#

A list of Member that were mentioned. If the message is in a private message then the list will be of User instead. For messages that are not of type MessageType.default, this array can be used to aid in system messages. For more information, see system_content.

Warning

The order of the mentions list is not in any particular order so you should not rely on it. This is a Discord limitation, not one with the library.

spark sentinel
#

mariadb can i use this db in pycharm

wooden vale
spark sentinel
#

because i dont finde the hoste name or the port

narrow grail
#

do you have already started with the bot?

azure tulip
#

Why is the print at an angle?

final iron
#

Your IDE

cerulean olive
#

!source jail

unkempt canyonBOT
#
Bad argument

Unable to convert 'jail' to valid command, tag, or Cog.

#
Command Help

!source [source_item]
Can also use: src

Display information and a GitHub link to the source code of a command, tag, or cog.

narrow grail
#

create a bot event

#

yeah

#

first you need that the bot knows on which guild(server) he needs to send this message

#

guild = bot.get_guild(your server id)

final iron
narrow grail
#

i mean a event for the bot

final iron
#

What

spring flax
#

!d discord.ext.commands.Bot.event

unkempt canyonBOT
#

@event```
A decorator that registers an event to listen to.

You can find more info about the events on the [documentation below](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events).

The events must be a [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine "(in Python v3.10)"), if not, [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.10)") is raised.

Example

```py
@client.event
async def on_ready():
    print('Ready!')
```...
#

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

Times out the member from the guild; until then, the member will not be able to interact with the guild.

Exactly one of `duration` or `until` must be provided. To remove a timeout, set one of the parameters to `None`.

You must have the [`Permissions.moderate_members`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.moderate_members "disnake.Permissions.moderate_members") permission to do this.

New in version 2.3.
junior verge
#
{len(client.users)}
``` Why does this return me 1?
final iron
#

!intents

unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.

To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.

Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

intents = Intents.default()
intents.members = True

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

For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.

slate swan
final iron
slate swan
#

its a coroutine of the member class

junior verge
slate swan
slate swan
unkempt canyonBOT
slate swan
#

you need intents

junior verge
#

but it used to work, so i dont know why it stopped working

slate swan
#

as my bf said (bestfriend)02smug

junior verge
slate swan
junior verge
#
await client.change_presence(activity=discord.Activity(type = discord.ActivityType.watching,name = f'{servers} servers and {len(client.users)} members'))
junior verge
#

you mean that

#
client = commands.Bot(command_prefix=get_prefix, help_command=None)
slate swan
#

yes you need to add an instsnce if the intents class in the intents kwarg

slate swan
junior verge
#

@slate swan ty cute

slate swan
#

await member_obj.timeout(...) in this case member_obj should be a member obj which then you can use the coroutine on the class since the coroutine is a method of the member class

wicked quest
#

How would i make a global database attribute for the bot (asqlite/aiosqlite) in dpy 2.0? I tried using the main async function but that for some reason didn't work

slate swan
#

im just a bit lost here where can i install dpy 2.3?

#

2.3?

#

2.0

slate swan
#

there isnt a release on pip its only 1.7.x

wicked quest
# slate swan im just a bit lost here where can i install dpy 2.3?

2.0 (Installing/Upgrading from GitHub):

# With non-voice support:
py -m pip install -U git+https://github.com/Rapptz/discord.py

# With voice support:
py -m pip install -U git+https://github.com/Rapptz/discord.py#egg=discord.py[voice]```
   - Linux/Mac: 
```# With non-voice support:
python3 -m pip install -U git+https://github.com/Rapptz/discord.py

# With voice support:
python3 -m pip install -U git+https://github.com/Rapptz/discord.py#egg=discord.py[voice]

Notes:

  • Make sure you have git installed and have git in your PATH. To check if git is installed and is in your PATH, just do git --version. To install git, visit https://git-scm.com/
  • You need Python 3.8 or above to install 2.0
slate swan
wicked quest
slate swan
# wicked quest yes

have you tried subclassing the Bot class and then making a method which returns a connection?

quick dust
#
    keep_alive()
NameError: name 'keep_alive' is not defined``` can anyone help?
slate swan
#

!e a()

unkempt canyonBOT
#

@slate swan :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | NameError: name 'a' is not defined
slate swan
#

its not a defined function

#

can someone give an example how to use the timout function with ctx or any param?

slate swan
#

!d discord.Message.author

unkempt canyonBOT
slate swan
#

or you can just fetch the member

#

!d discord.Guild.fetch_member

unkempt canyonBOT
#

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

Retrieves a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") from a guild ID, and a member ID.

Note

This method is an API call. If you have [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") and member cache enabled, consider [`get_member()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.get_member "discord.Guild.get_member") instead.

Changed in version 2.0: `member_id` parameter is now positional-only.
slate swan
#

really depends on the situation

#

await ctx.author.timeout_for

why wont this work tho member doesnt have this attribute how can i use it otherwise here

#

1.7.3 doesnt have that method

#

you need to use a fork or main

#

yeah im using 2.0

#

did you uninstalled 1.7.3?

#

how can i check the ver?

slate swan
#

not sure if dpy has that method

slate swan
#

wait ima just reinstall everything

#

youre not using main then.

slate swan
#

!pypi py-cord

unkempt canyonBOT
slate swan
#

kinda bad fork imo

solid summit
hoary gust
#

i like disnake much more than py-cord

azure tulip
#
@bot.command()
async def info(ctx, arg=None):
    author = ctx.massage.author
    if arg == None:
        await ctx.send(f'{author} ВвеГите: \n !info general \n !info commands')
    elif arg == 'general':
        await ctx.send(f'{author} In future')
    elif arg == 'commands':
        await ctx.send(f'{author} !test - Online bot check\n !status - My warnings')
    else:
        await ctx.send(f'{author} no such command...')

Why doesn't this code work?

slim ibex
#

and you did cts not ctx

slate swan
slim ibex
#

it’s message, not massage

slate swan
slim ibex
azure tulip
slim ibex
#

it’s message, not massage
@azure tulip

slate swan
slim ibex
#

🤨

slate swan
azure tulip
slate swan
#

you spelt message wrong

pliant gulch
slate swan
#

just do ctx.author

#

and i recommend you download pyright for sublime

slate swan
#

pls increase your video resolutoin or make it full screen to view it clearly 😭

#

or even better dont follow yt tutorialsthink

#

+1

#

but could be that he's a beginner.. or not familiar with OOP (not judging btw)

#

so let him play around

azure tulip
slate swan
#

and?

slate swan
pliant gulch
#

Pyright doesn't give intellisense

slate swan
#

or use tabnine.. it's kinda ok ok.. like it works

#

in vsc

somber sky
#

anyone know how to make a enable/disable command when u run it the command doesnt work till u enable it

slate swan
pliant gulch
#

Pyright would more fall under the linter category, it’s a type checker

azure tulip
# slate swan and?
@bot.command()
async def info(ctx, arg=None):
    author = ctx.message.author
    if arg == None:
        await ctx.send(f'{author.mention} Enter: \n !info general \n !info commands')
    elif arg == 'general':
        await ctx.send(f'{author} In future')
    elif arg == 'commands':
        await ctx.send(f'{author} !test - Online bot check\n !status - My warnings')
    else:
        await ctx.send(f'{author} no such command...')

It work!
Thanks to everyone who could

slate swan
azure tulip
#

I'm download, thanks for the advice

sick birch
azure tulip
#

I'm new, I'm only studying programming for the second day and I do everything according to the guides, if you can do subclass helpcommand at once, then I will do it that way

slim ibex
#

copying from tutorials won’t help you learn

#

hopefully you atleast know the basics like variables, functions, control flow, iteration, etc

pliant gulch
#

!customhelp

unkempt canyonBOT
#

Custom help commands in discord.py

To learn more about how to create custom help commands in discord.py by subclassing the help command, please see this tutorial by Stella#2000

pliant gulch
#

Heres a guide for subclassing the help command

slate swan
#
        if isinstance(error, commands.MissingRequiredArgument):
          embed = discord.Embed(title='Missing Argument',description=f'You must include all arguments to do this command!')
          await ctx.send(embed=embed)
          c = ctx.invoked_with
          c.reset_cooldown(ctx)

And, i keep getting this error: AttributeError: 'str' object has no attribute 'reset_cooldown'

final iron
#

!d discord.ext.commands.Context.invoked_with

unkempt canyonBOT
final iron
slate swan
final iron
#

The docs don't lie

#

Don't know what to tell you

#

It can't physically work

slate swan
#

ok then

slate swan
azure tulip
slate swan
azure tulip
kindred drum
#
TypeError: edit() takes 1 positional argument but 2 were given```
#

await msg_id.edit("šŸŽ‰ GIVEAWAY ENDED šŸŽ‰")

#

anyone know the error?

slate swan
#

!d discord.Message.edit

unkempt canyonBOT
#

await edit(content=..., embed=..., embeds=..., attachments=..., suppress=False, delete_after=None, allowed_mentions=..., view=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the message.

The content must be able to be transformed into a string via `str(content)`.

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

Changed in version 2.0: Edits are no longer in-place, the newly edited message is returned instead.

Changed in version 2.0: This function will now raise [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.10)") instead of `InvalidArgument`.
azure tulip
#

why so many pythons? which is the best to learn?

slate swan
azure tulip
#

I want to make discord bots and maybe websites in the future

slate swan
#

well you can just learn web development and oop

azure tulip
#

Šžk

slate swan
# azure tulip Šžk

In this Python Object-Oriented Tutorial, we will begin our series by learning how to create and use classes within Python. Classes allow us to logically group our data and functions in a way that is easy to reuse and also easy to build upon if need be. Let's get started.

Python OOP 1 - Classes and Instances - https://youtu.be/ZDa-Z5JzLYM
Python...

ā–¶ Play video
azure tulip
#

Thanks

slate swan
azure tulip
#

Well, I'll look at a fresh head tomorrow, but now I'm going to sleep, good night)

sonic lintel
#

Does anyone know how to make buttons using discord.py?

#

Im so stuck and I dont know how to

slate swan
sonic lintel
#

@slate swan

slate swan
#

you need dpy 2.0

sonic lintel
#

how do I install it?

slate swan
#

in cmd

#

if youre on windows

sonic lintel
#

on mac

slate swan
# sonic lintel on mac

just do it where you install packages btw you need git but if you dont want to install git you can just install a fork like disnake with pip

sonic lintel
slate swan
sonic lintel
#

SyntaxError: invalid syntax
alanabeaton@sonic lintels-Air Auora Bot % /usr/local/bin/python3 "/Users/alanabeaton/Auora Bot/main.py"
Traceback (most recent call last):
File "/Users/alanabeaton/Auora Bot/main.py", line 66, in <module>
bot.run("token")
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/client.py", line 709, in run
asyncio.run(runner())
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
return future.result()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/client.py", line 706, in runner
await self.start(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/client.py", line 680, in start
await self.connect(reconnect=reconnect)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/client.py", line 617, in connect
raise PrivilegedIntentsRequired(exc.shard_id) from None
discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.

Discord Developer Portal

Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.

slate swan
#

you need to enable the intent

sonic lintel
slate swan
#

in the dev portal

sonic lintel
#

ok

slate swan
sonic lintel
slate swan
#

do you have all of them on?

sonic lintel
#

I do now

#

it works tysm!

slate swan
#

:))

sonic lintel
#

@slate swan I want to make a guided breathing bot

#

So that it responds in a thread with buttons

#

but Im still really unsure what to do

slate swan
sonic lintel
slate swan
slate swan
# sonic lintel Ill try

heres an easy example

class ExampleView(discord.ui.View):
    def __init__(self) -> None:
        super().__init__()

    @discord.ui.button(label='Button', style=discord.ButtonStyle.green)
    async def button_callback(self, interaction: discord.Interaction, button: discord.ui.Button) -> None:
        await interaction.send("You pressed the button!", ephemeral=True)
        self.stop()

@bot.command()
async def button_example(ctx: commands.Context) -> None:
    await ctx.send("Heres a message with a button!", view=ExampleView())
#  this command is outside of the view ^
sonic lintel
slate swan
#

on an interaction?

#

!d disnake.Interaction.send

unkempt canyonBOT
#

await send(content=None, *, embed=..., embeds=..., file=..., files=..., allowed_mentions=..., view=..., components=..., tts=False, ephemeral=False, delete_after=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sends a message using either [`response.send_message`](https://docs.disnake.dev/en/latest/api.html#disnake.InteractionResponse.send_message "disnake.InteractionResponse.send_message") or [`followup.send`](https://docs.disnake.dev/en/latest/api.html#disnake.Webhook.send "disnake.Webhook.send").

If the interaction hasn’t been responded to yet, this method will call [`response.send_message`](https://docs.disnake.dev/en/latest/api.html#disnake.InteractionResponse.send_message "disnake.InteractionResponse.send_message"). Otherwise, it will call [`followup.send`](https://docs.disnake.dev/en/latest/api.html#disnake.Webhook.send "disnake.Webhook.send").

Note

This method does not return a [`Message`](https://docs.disnake.dev/en/latest/api.html#disnake.Message "disnake.Message") object. If you need a message object, use [`original_message()`](https://docs.disnake.dev/en/latest/api.html#disnake.Interaction.original_message "disnake.Interaction.original_message") to fetch it, or use [`followup.send`](https://docs.disnake.dev/en/latest/api.html#disnake.Webhook.send "disnake.Webhook.send") directly instead of this method if you’re sending a followup message.
slate swan
#

the ephemeral kwarg

#

just set it to True

#

i said on interaction context doesnt have that kwarg and you cannot send an ephemeral message if its not on Interaction

#

!d discord.ext.commands.Context.send

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/master/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/master/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/master/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/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
slate swan
#

on the button call back

slate swan
#

?

#

ok?

#

show code

austere vale
#

all of a sudden i cant turn on my bot even though i didnt change the code. how do i fix this?

slate swan
#

show full tb

austere vale
#

oh what do i need to do to get out of it?

final iron
#

Are you using replit?

neat sail
#

Can I ask how to install pycord here?

slate swan
austere vale
#

yes im using replit

slate swan
neat sail
#

Ok

final iron
slate swan
neat sail
slate swan
#

original python pardon?

neat sail
torn sail
#

shouldnt button come before interaction?

neat sail
#

o wrong message

neat sail
#

what*

neat sail
#

wth

slate swan
#

main does have slash commands

#

as long as it's the master branch version

neat sail
#

What's wrong with my code then AHSUBGSJND

slate swan
#

care to share the traceback?

neat sail
slate swan
#

!traceback

unkempt canyonBOT
#

Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.

A full traceback could look like:

Traceback (most recent call last):
  File "my_file.py", line 5, in <module>
    add_three("6")
  File "my_file.py", line 2, in add_three
    a = num + 3
TypeError: can only concatenate str (not "int") to str

If the traceback is long, use our pastebin.

neat sail
#

Oh

#

Well I can't copy it and I don't feel like typing so ima just send a snippet

neat sail
#

I can't think straight hearing my sister kiss her boyfriend bruh

sonic lintel
#

@slate swan For discord buttons, do you have any idea how to make it so only the author can react to the button and how to make a private thread with the author

neat sail
#

I'm gonna go outside and go back to biking for a little

slate swan
sonic lintel
slate swan
#

which is bound to an instance of View or the subclass of it ofc

#

!d discord.ui.View.stop

unkempt canyonBOT
#

stop()```
Stops listening to interaction events from this view.

This operation cannot be undone.
sonic lintel
#

sorry I have never worked with buttons before

#

This is an example, the author is able to react multiple times

#

which results in a spam

#

also other people can also react

#
class YesButton(discord.ui.View):
    # When this button is pressed, it will respond with a Counter view that will
    # give the button presser their own personal button they can press 5 times.
    @discord.ui.button(label='Yes', style=discord.ButtonStyle.green)
    async def receive(self, interaction: discord.Interaction, button: discord.ui.Button):
        # ephemeral=True makes the message hidden from everyone except the button presser
        await interaction.response.send_message('Start by finding a comfortable postion, either lying on the floor or sitting with your legs crossed.')
        discord.ui.View.stop()


bot = GuidedMediationBot()


@bot.command()
async def breathe(ctx: commands.Context):
    """Starts a breathe for pressing."""
    await ctx.send('Confirm to start guided breathing excerise.', view=YesButton())```
slate swan
# sonic lintel still really confused
class ExampleView(discord.ui.View):
    def __init__(self, author: discord.Member) -> None:
        super().__init__()
        self.author = author

    async def on_interaction(self, interaction: discord.Interaction) -> None:
        if interaction.author != self.author:
            return False
        return True

    @discord.ui.button(label='Button', style=discord.ButtonStyle.green)
    async def button_callback(self, interaction: discord.Interaction, button: discord.ui.Button) -> None:
        await interaction.send("You pressed the button!", ephemeral=True)
        self.stop()

@bot.command()
async def button_example(ctx: commands.Context) -> None:
    await ctx.send("Heres a message with a button!", view=ExampleView(ctx.author))
#  this command is outside of the view ^

heres an example

sonic lintel
#

Ill try it ty!

#

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/ext/commands/bot.py", line 1234, in invoke
await ctx.command.invoke(ctx)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/ext/commands/core.py", line 923, in invoke
await injected(*ctx.args, **ctx.kwargs) # type: ignore
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/ext/commands/core.py", line 196, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: init() takes 1 positional argument but 2 were given

slate swan
#

show code

sonic lintel
#
from discord.ext import commands

import discord
import time

class GuidedMediationBot(commands.Bot):
    def __init__(self):
        intents = discord.Intents.default()
        intents.message_content = True

        super().__init__(command_prefix=commands.when_mentioned_or('a.'), intents=intents)

    async def on_ready(self):
        print(f'Logged in as {self.user} (ID: {self.user.id})')
        print('------')


# Define a simple View that gives us a counter button
class Counter(discord.ui.View):

    # Define the actual button
    # When pressed, this increments the number displayed until it hits 5.
    # When it hits 5, the counter button is disabled and it turns green.
    # note: The name of the function does not matter to the library
    @discord.ui.button(label='Yes', style=discord.ButtonStyle.green)
    async def breathe(self, interaction: discord.Interaction, button: discord.ui.Button):
        await interaction.response.edit_message(view=self)


# Define a View that will give us our own personal counter button
class YesButton(discord.ui.View):
    # When this button is pressed, it will respond with a Counter view that will
    # give the button presser their own personal button they can press 5 times.
    @discord.ui.button(label='Yes', style=discord.ButtonStyle.green)
    async def receive(self, interaction: discord.Interaction, button: discord.ui.Button):
        # ephemeral=True makes the message hidden from everyone except the button presser
        await interaction.response.send_message('Start by finding a comfortable postion, either lying on the floor or sitting with your legs crossed.')
        self.stop()


bot = GuidedMediationBot()


@bot.command()
async def breathe(ctx: commands.Context):
    """Starts a breathe for pressing."""
    await ctx.send('Confirm to start guided breathing excerise.', view=YesButton(ctx.author))
    time.sleep(5)
    await ctx.reply('Are you in a comfortable position?')```
slate swan
#

no

#

its not a cog.

slate swan
sonic lintel
#

I havent made it into a cog yet

#

Im working in the main script for now

#

then Ill seperate it into cogs

slate swan
#

you can get rid of that Counter class

sonic lintel
slate swan
sonic lintel
#

Ignoring exception in command breathe:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/ext/commands/core.py", line 187, in wrapped
ret = await coro(*args, **kwargs)
File "/Users/alanabeaton/Auora Bot/main.py", line 45, in breathe
await ctx.send('Confirm to start guided breathing excerise.', view=YesButton(ctx.author))
TypeError: init() takes 1 positional argument but 2 were given

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/ext/commands/bot.py", line 1234, in invoke
await ctx.command.invoke(ctx)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/ext/commands/core.py", line 923, in invoke
await injected(*ctx.args, **ctx.kwargs) # type: ignore
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/ext/commands/core.py", line 196, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: init() takes 1 positional argument but 2 were given

sonic lintel
slate swan
sonic lintel
slate swan
slate swan
sonic lintel
#
class GuidedMediationBot(commands.Bot):
    def __init__(self, author: discord.Member) -> None:
        intents = discord.Intents.default()
        intents.message_content = True

        super().__init__(command_prefix=commands.when_mentioned_or('a.'), intents=intents)

    async def on_ready(self):
        print(f'Logged in as {self.user} (ID: {self.user.id})')
        print('------')```
#

so would this be correct then?

slate swan
#

no

#

in your View subclass

#

yes just name the methods differently

#

all of the components are bound to an instance of the class which you can get a list of them with children

#

yes

sonic lintel
#
from discord.ext import commands

import discord
import time

class GuidedMediationBot(commands.Bot):
    def __init__(self):
        intents = discord.Intents.default()
        intents.message_content = True

        super().__init__(command_prefix=commands.when_mentioned_or('a.'), intents=intents)

    async def on_ready(self):
        print(f'Logged in as {self.user} (ID: {self.user.id})')
        print('------')


# Define a simple View that gives us a counter button


# Define a View that will give us our own personal counter button
class YesButton(discord.ui.View):
    def __init__(self, author: discord.Member) -> None:
    # When this button is pressed, it will respond with a Counter view that will
    # give the button presser their own personal button they can press 5 times.
        @discord.ui.button(label='Yes', style=discord.ButtonStyle.green)
        async def receive(self, interaction: discord.Interaction, button: discord.ui.Button):
            # ephemeral=True makes the message hidden from everyone except the button presser
            await interaction.response.send_message('Start by finding a comfortable postion, either lying on the floor or sitting with your legs crossed.')
            self.stop()

class IamButton(discord.ui.View):

    # Define the actual button
    @discord.ui.button(label='I am', style=discord.ButtonStyle.green)
    async def breathe(self, interaction: discord.Interaction, button: discord.ui.Button):
        await interaction.response.edit_message(view=self)


bot = GuidedMediationBot()


@bot.command()
async def breathe(ctx: commands.Context):
    """Starts a breathe for pressing."""
    await ctx.send('Confirm to start guided breathing excerise.', view=YesButton(ctx.author))
    time.sleep(5)
    await ctx.reply('Are you in a comfortable position?', view=IamButton )```
unkempt canyonBOT
sonic lintel
#

Ignoring exception in command breathe:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/ext/commands/core.py", line 187, in wrapped
ret = await coro(*args, **kwargs)
File "/Users/alanabeaton/Auora Bot/main.py", line 46, in breathe
await ctx.send('Confirm to start guided breathing excerise.', view=YesButton(ctx.author))
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/abc.py", line 1403, in send
with handle_message_parameters(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/http.py", line 186, in handle_message_parameters
payload['components'] = view.to_components()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/ui/view.py", line 224, in to_components
children = sorted(self.children, key=key)
AttributeError: 'YesButton' object has no attribute 'children'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/ext/commands/bot.py", line 1234, in invoke
await ctx.command.invoke(ctx)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/ext/commands/core.py", line 923, in invoke
await injected(*ctx.args, **ctx.kwargs) # type: ignore
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/ext/commands/core.py", line 196, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'YesButton' object has no attribute 'children'

slate swan
#

bro?

sick birch
#

wait a second

slate swan
#

šŸ’€

sick birch
slate swan
sick birch
#

And also call super().__init__()

slate swan
#

so you can get children

#

rooMonkaS that sounds sus

sick birch
#

very much so

slate swan
#

im a good personrooBulli

sonic lintel
slate swan
sonic lintel
#

In the yesbuttonclass?

slate swan
#

in its initiate yes

sonic lintel
#

ok

#

Ignoring exception in command breathe:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/ext/commands/core.py", line 187, in wrapped
ret = await coro(*args, **kwargs)
File "/Users/alanabeaton/Auora Bot/main.py", line 48, in breathe
await ctx.send('Confirm to start guided breathing excerise.', view=YesButton(ctx.author))
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/abc.py", line 1403, in send
with handle_message_parameters(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/http.py", line 186, in handle_message_parameters
payload['components'] = view.to_components()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/ui/view.py", line 224, in to_components
children = sorted(self.children, key=key)
AttributeError: 'YesButton' object has no attribute 'children'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/ext/commands/bot.py", line 1234, in invoke
await ctx.command.invoke(ctx)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/ext/commands/core.py", line 923, in invoke
await injected(*ctx.args, **ctx.kwargs) # type: ignore
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/ext/commands/core.py", line 196, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'YesButton' object has no attribute 'children'

#

Still the same error

#

code:

#
from discord.ext import commands

import discord
import time

class GuidedMediationBot(commands.Bot):
    def __init__(self):
        intents = discord.Intents.default()
        intents.message_content = True

        super().__init__(command_prefix=commands.when_mentioned_or('a.'), intents=intents)

    async def on_ready(self):
        print(f'Logged in as {self.user} (ID: {self.user.id})')
        print('------')


# Define a simple View that gives us a counter button


# Define a View that will give us our own personal counter button
class YesButton(discord.ui.View):
    def __init__(self, author: discord.Member) -> None:
    # When this button is pressed, it will respond with a Counter view that will
    # give the button presser their own personal button they can press 5 times.
        @discord.ui.button(label='Yes', style=discord.ButtonStyle.green)
        async def receive(self, interaction: discord.Interaction, button: discord.ui.Button):
            # ephemeral=True makes the message hidden from everyone except the button presser
            await interaction.response.send_message('Start by finding a comfortable postion, either lying on the floor or sitting with your legs crossed.')
            self.stop()
            super().__init__()

class IamButton(discord.ui.View):

    # Define the actual button
    @discord.ui.button(label='I am', style=discord.ButtonStyle.green)
    async def breathe(self, interaction: discord.Interaction, button: discord.ui.Button):
        await interaction.response.edit_message(view=self)


bot = GuidedMediationBot()



@bot.command()
async def breathe(ctx: commands.Context):
    """Starts a breathe for pressing."""
    await ctx.send('Confirm to start guided breathing excerise.', view=YesButton(ctx.author))
    time.sleep(5)
    await ctx.reply('Are you in a comfortable position?', view=IamButton )```
slate swan
#
class YesButton(discord.ui.View):
    def __init__(self, author: discord.Member) -> None:
        super().__init__()

it should be done in the initiate dunder as shown above^

sonic lintel
#

Now the button is not shown at all

slate swan
#

you never called the class lol

#
await ctx.reply('Are you in a comfortable position?', view=IamButton )
sonic lintel
#

I did

slate swan
#

not quite

#

you need to call it.

#
IamButton()

like this

sonic lintel
#

Do I call it in the yesbutton class?

slate swan
#

!e

def function() -> str:
    return "Hello this function has a value of a string"

print(function)
print(function())

you see how one prints the memory location and the other prints the value of the function

unkempt canyonBOT
#

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

001 | <function function at 0x7f2d051e3d90>
002 | Hello this function has a value of a string
sonic lintel
#

Because I want it to act as a reply after the yes button

slate swan
#
await ctx.reply('Are you in a comfortable position?', view=IamButton())

as so

sonic lintel
#

Im really confused sorry

#

from discord.ext import commands

import discord
import time

class GuidedMediationBot(commands.Bot):
    def __init__(self):
        intents = discord.Intents.default()
        intents.message_content = True

        super().__init__(command_prefix=commands.when_mentioned_or('a.'), intents=intents)

    async def on_ready(self):
        print(f'Logged in as {self.user} (ID: {self.user.id})')
        print('------')


# Define a simple View that gives us a counter button


# Define a View that will give us our own personal counter button
class YesButton(discord.ui.View):
    def __init__(self, author: discord.Member) -> None:
        super().__init__()
    # When this button is pressed, it will respond with a Counter view that will
    # give the button presser their own personal button they can press 5 times.
        @discord.ui.button(label='Yes', style=discord.ButtonStyle.green)
        async def receive(self, interaction: discord.Interaction, button: discord.ui.Button):
            # ephemeral=True makes the message hidden from everyone except the button presser
            await interaction.response.send_message('Start by finding a comfortable postion, either lying on the floor or sitting with your legs crossed.')
            self.stop()
            

class IamButton(discord.ui.View):
    def __init__(self, author: discord.Member) -> None:
        super().__init__()

    # Define the actual button
    @discord.ui.button(label='I am', style=discord.ButtonStyle.green)
    async def breathe(self, interaction: discord.Interaction, button: discord.ui.Button):
        await interaction.response.send_message('Are you in a comfortable position?')
    
bot = GuidedMediationBot()

@bot.command()
async def breathe(ctx: commands.Context):
    """Starts a breathe for pressing."""
    await ctx.send('Confirm to start guided breathing excerise.', view=YesButton(ctx.author))
    time.sleep(5)
    await ctx.reply('Are you in a comfortable position?', view=IamButton())```
#

This is my code, can you tell me what I should change

slate swan
#

use asyncio.sleep btw

hoary cargo
#

SuchMeme you really put to sleep whole code to breathe damn