#discord-bots

1 messages ยท Page 1114 of 1

shell wing
#

how ?

#

like self, ctx, message

slate swan
#

yeah?

shell wing
#
@cog_ext.cog_slash(name="uwu", guild_ids=[933980948268208130],options=[
                           create_option(name="Partner Ad",
                                         description="Type the AD here",
                                         option_type=1,
                                         required=True)
                           
                       ])
    async def uwu(self, ctx, message):
        
        await ctx.send(message)
``` so like this ?
slate swan
#

yeah

#

uwu

shell wing
#

ok uwu

slate swan
#

alright thanks!

shell wing
#

gets ashley's habit of uwu, uwu

slate swan
#

im so funny

dusky pine
#

i'm trademarking uwu

#

now you have to ask me for permission before you say it

shell wing
#

@slate swan using discord-py-slash-command for that attachment stuff

@cog_ext.cog_slash(name="uwu2", guild_ids=[933980948268208130],options=[
                           create_option(name="attach ur meme here",
                                         description="memeee",
                                         option_type=11,
                                         required=True)
                           
                       ])
    async def uwu2(self, ctx, attachment):
        
        await ctx.send(attachment)
``` right way ??
dusky pine
#

i'm suing you

shell wing
slate swan
#

dunno if that works

shell wing
#

typehint ? how ?

slate swan
#

...?

dusky pine
#

attachment: discord.Attachment

warm tulip
#

guys help how i can set 2 prefixes

paper sluice
warm tulip
#

thanks

slate swan
#

you can pass any iterable

shell wing
slate swan
#
command_prefix = (prefix, uwuprefix) # or [prefix, uwuprefix], {prefix, uwuprefix}, {prefix: 0, uwuprefix: 0} :pensive:
swift pumice
slate swan
#

the dict looks cursed though

slate swan
swift pumice
#

oh okay thanks

paper sluice
slate swan
placid skiff
#

You can't

#

I don't have enough patience to handle those who don't know python and want to develop a bot

#

we need you

slate swan
placid skiff
#

Better than nothing

slate swan
#

maybe

#
@client.command()
async def get(ctx):
    embed = DiscordEmbed(title="test1", description="", color=0x00ff00)
    embed.add_embed_field(name="test2", value="", inline=False)
    await ctx.send(embed=embed)
``` any idea why it is not sending the embed, sorry i've been out of dpy for about half a year
dusky pine
paper sluice
#

i think u need a description on ur embed, and what is DiscordEmbed?

slate swan
#

oooooo i forgot to add a . after discord my bad

dusky pine
#

and it's add_field not add_embed_field

slate swan
#

description shouldn't be left empty, rather just dont define it, and the value always need to be something

placid skiff
#

well it is lowercase too D_D

placid skiff
#

!d discord.Embed.add_field

unkempt canyonBOT
#

add_field(*, name, value, inline=True)```
Adds a field to the embed object.

This function returns the class instance to allow for fluent-style chaining. Can only be up to 25 fields.
dusky pine
slate swan
#

i heard dpy got a new update that's why

#

imagine using copilot

dusky pine
#

damn copilot ๐Ÿคฆ

placid skiff
#

Oh sorry

slate swan
placid skiff
#

Lol copilot suggests add_field lmao

paper sluice
#

all my homies hate github copilot

shell wing
#
Task exception was never retrieved
future: <Task finished name='Task-1' coro=<SlashCommand.sync_all_commands() done, defined at /opt/virtualenvs/python3/lib/python3.8/site-packages/discord_slash/client.py:364> exception=HTTPException("400 Bad Request (error code: 50035): Invalid Form Body\n'uwu'.options.0.name: String value did not match validation regex. Command name is invalid")>
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord_slash/client.py", line 440, in sync_all_commands
    raise ex
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord_slash/client.py", line 420, in sync_all_commands
    existing_cmds = await self.req.put_slash_commands(
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py", line 254, in request
    raise HTTPException(r, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
'uwu'.options.0.name: String value did not match validation regex. Command name is invalid
``` wtf is this ๐Ÿ’€
dusky pine
shell wing
slate swan
shell wing
#

whats wrong in uwu

dusky pine
shell wing
dusky pine
#

what args does ur command have

slate swan
# slate swan what's wrong with it?
embed = discord.Embed(title=..., description=..., colour=...) #all the arguments in the Embed __init__ are optional
embed.add_field(name=..., value=..., inline=...) #every argument except inline is required

#to set the value to be invisible

embed.add_field(name="uwu", value="** **") #alternatively use "_ _" instead of "** **"

that's how you create an embed

shell wing
dusky pine
#

color > colour ๐Ÿ˜”

dusky pine
slate swan
slate swan
#

what the-

dusky pine
shell wing
#
@cog_ext.cog_slash(name="partners", guild_ids=[933980948268208130],options=[
                           create_option(name="Partner Ad",
                                         description="Type the AD here",
                                         option_type=1,
                                         required=True)
                           
                       ])
  
    async def partners(self, ctx, message):
        
        await ctx.send(message)
slate swan
#

nice

shell wing
#

!d discord.Embed

unkempt canyonBOT
#

class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, timestamp=None)```
Represents a Discord embed.

len(x) Returns the total size of the embed. Useful for checking if itโ€™s within the 6000 character limit.

bool(b) Returns whether the embed has any data set.

New in version 2.0.

For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") for you.

Changed in version 2.0: `Embed.Empty` has been removed in favour of `None`.
slate swan
dusky pine
#

change Partner Ad to partner-ad or something

slate swan
#

i guess i'll just step out than to argue with you guys

dusky pine
#

i kinda forgot that it was named options instead of args, mb lol

shell wing
# dusky pine see that's the problem, `name` has a space and an uppercase letter
Task exception was never retrieved
future: <Task finished name='Task-1' coro=<SlashCommand.sync_all_commands() done, defined at /opt/virtualenvs/python3/lib/python3.8/site-packages/discord_slash/client.py:364> exception=HTTPException("400 Bad Request (error code: 50035): Invalid Form Body\n'partnerrr'.options.0.required: Required cannot be configured for this type of option")>
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord_slash/client.py", line 440, in sync_all_commands
    raise ex
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord_slash/client.py", line 420, in sync_all_commands
    existing_cmds = await self.req.put_slash_commands(
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py", line 254, in request
    raise HTTPException(r, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
'partnerrr'.options.0.required: Required cannot be configured for this type of option
dusky pine
#

you can't set required for this type of option

paper sluice
dusky pine
#

since the option_type is 1, i think that's why

#

i don't even know what 1 is

dusky pine
#

you rude

slate swan
#

whatever

shell wing
dusky pine
slate swan
shell wing
slate swan
shell wing
#


      
    @cog_ext.cog_slash(name="partnerrr", guild_ids=[933980948268208130],options=[
                           create_option(name="partnerrr",
                                         description="Type the AD here",
                                         option_type=1,
                                         required=False)
                           
                       ])
  
    async def partnerrr(self, ctx, message):
        
        await ctx.send(message)
dusky pine
#

i said remove not make it false ๐Ÿ˜”

slate swan
shell wing
dusky pine
#

they're gone now ash stop

shell wing
#

so i made it false..

dusky pine
shell wing
slate swan
dusky pine
#

what was that

slate swan
shell wing
paper sluice
#

no, not gonna do that

dusky pine
paper sluice
#

dwa

dusky pine
#

tf is dwa

slate swan
shell wing
slate swan
#

wha...

shell wing
#
@cog_ext.cog_slash(name="ping", guild_ids=[933980948268208130])
    async def ping(self, ctx):
        embed = discord.Embed(title="Bot's latency",description=f'Loading :loading: ',
                           color=0xE6E6FA)
        embed1 = discord.Embed(title="Bot's latency",description=f'**Pong!** Latency: {round(self.bot.latency * 1000)}ms',
                           color=0xE6E6FA)
        message = await ctx.send(embed=embed)
        await asyncio.sleep(1)
        await message.edit(embed=embed1)
#

see lmaoo

paper sluice
slate swan
shell wing
#
from discord_slash import cog_ext, SlashContext
``` ok my bad
#

its discord_slash

#

๐Ÿ˜ญ

slate swan
#

same lib

#

it's discord-py-slash-command but wtf...

shell wing
#

oo

#

lmao alr

#

curse on dic later ๐Ÿ˜ญ why it isnt workinggg

slate swan
#

nvm

shell wing
slate swan
shell wing
forest oyster
#

hey guys

#

I have a problem

slate swan
#

mhm?

paper sluice
shell wing
slate swan
#

I'll just go to sleep instead, good night

#

and goodluck

#
@client.event
async def on_ready():
    print("Game time!")
#

why this no work

shell wing
#

ok im done with this shit now i aint using slashhssss

slate swan
#

in discord.py-self

paper sluice
slate swan
paper sluice
unkempt canyonBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.

slate swan
#

that does not break laws..

paper sluice
slate swan
#

just printing hi when a bot is ready?

paper sluice
#

self-botting is against discord's tos

forest oyster
#
@bot.command()
async def play(ctx, *, search):
    query_string = parse.urlencode({"search_querty": search}) 
    html_content = request.urlopen("http://www.youtube.com/results?" + query_string)
    search_results = re.findall('href=\"\\/watch\\?v=(.{11})', html_content.read().decode())
    await ctx.send("http://www.yotube.com/watch?v=" + search_results[0])
slate swan
forest oyster
slate swan
#

shouldnt the search_querty key be search_query, I mean by common sense

forest oyster
slate swan
#

read the error

#

search_results is None

#

@paper sluice @slate swan thx for helping very useful

#

๐Ÿ‘

#

nice sarcasm

forest oyster
paper sluice
forest oyster
#

its the same

slate swan
#

@shell wing why arent you using the latest version for discord-py-slash-command?

#

I'm tripping with words smh

shell wing
#

ill do it on a test bot once i got plenty time

paper sluice
slate swan
#

LAG

#

i also tried it on heroku

#

still takes long

slate swan
#

Sad

paper sluice
slate swan
paper sluice
#

no one said to subscript

slate swan
#

..

forest oyster
#
@bot.command()
async def play(ctx, *, search):
    query_string = parse.urlencode({"search_querty": search}) 
    html_content = request.urlopen("http://www.youtube.com/results?" + query_string)
    search_results = re.findall('href=\"\\/watch\\?v=(.{11})', html_content.read().decode())
    await ctx.send("http://www.yotube.com/watch?v=" + search_results[0])
#

can you do it please? ๐Ÿ™‚๐Ÿ˜˜

slate swan
#

add some lovey-touchy emojis, maybe he'll do it then

forest oyster
#

now?

#

xd

slate swan
#

lmaooooo

forest oyster
#

xddddd

#

btw con someone tell me how is my other proyect?

warm tulip
#
async def on_server_join():
    print=("joined one server!")```

guys i did this but its not working
#

helppppppppp

shrewd apex
#

wth

#
@bot.event
async def on_guild_join(guild):
    print("joined one server!")
dusky pine
#

it's on_guild_join

rocky trench
#

Yeah indeed.

dusky pine
#

in the 1.0 version server has been replaced with guild throughout the codebase

#

they also have an equals after the print

#

which is valid syntax but it will not do what you think it'd do

slate swan
#

.

warm tulip
#

hmm and how i can set a role id for a cmd i forget

rocky trench
#

@commands.has_role()

slate swan
dim sentinel
#

just got to know we can't use Ephemeral messages in discord.py

#

can we use it in nextcord?

#

and am i going to regret shifting to nextcord

dusky pine
#

personally i like disnake

slate swan
dim sentinel
#

then use an embed from the bot

#

but i have no idea how i am supposed to add it, can't find it in the docs either

slate swan
#

huh?

dim sentinel
slate swan
#

just set ephemeral=True in the send_message method

dim sentinel
#

damn.

proud apex
#

How to add a user's avatar to the background and when the account was created, etc.?

proud apex
#

no

#

Like a membership card

limpid thicket
unkempt canyonBOT
#

property created_at```
Returns the userโ€™s creation time in UTC.

This is when the userโ€™s Discord account was created.
slate swan
#

and what background

dusky pine
#

oh they're probably generating an image using PIL

proud apex
slate swan
slate swan
limpid thicket
#

@slate swan Where is the example/QuickStart and API reference for slash commands?

limpid thicket
hushed galleon
#

i dont know if they're still working on a guide to app commands

#

i still sometimes reference their gist, even tho its pretty out of date

slate swan
#

fr

heady sluice
#

it's not that hard to make those slash commands once you got an example

#

but explaining it to someone who still is confused is pain in the ass

#

someone explained it to me, sorry for them

limpid thicket
#

Idek what Iโ€™m looking at in this basic.py

heady sluice
hushed galleon
#

when i came back like a few days ago to add a new cog + group, i found out about their GroupCog and that the group parameters were passed to the class itself, but then i had to look in the source code to figure out that i need to assign __discord_app_commands_default_guilds__ = [int, ...] to specify the guild ids

slate swan
heady sluice
#

why temporary

forest oyster
forest oyster
heady sluice
#

not youtube

forest oyster
#

๐Ÿ˜ฆ

heady sluice
#

search results is empty

forest oyster
#

and how to fix it?

heady sluice
#

get something in search results

forest oyster
#

like what?

forest oyster
#

ok i alredy saw that

slate swan
#

and pretty sure you cant search for your stuff with spaces, you need to join them

slate swan
alpine cove
forest oyster
dim sentinel
#
PS D:\vsc\Spiral> & C:/Python310/python.exe d:/vsc/Spiral/spi2.py
Traceback (most recent call last):
  File "d:\vsc\Spiral\spi2.py", line 7, in <module>
    slash=SlashCommand(bot,sync_commands=True)
NameError: name 'SlashCommand' is not defined
PS D:\vsc\Spiral> pip install discord-py-slash-command                                                                   
Requirement already satisfied: discord-py-slash-command in c:\python310\lib\site-packages (4.2.1)
Requirement already satisfied: aiohttp>=3.8.1 in c:\python310\lib\site-packages (from discord-py-slash-command) (3.8.1)
Requirement already satisfied: multidict<7.0,>=4.5 in c:\python310\lib\site-packages (from aiohttp>=3.8.1->discord-py-slash-command) (6.0.2)
Requirement already satisfied: attrs>=17.3.0 in c:\python310\lib\site-packages (from aiohttp>=3.8.1->discord-py-slash-command) (21.4.0)
Requirement already satisfied: yarl<2.0,>=1.0 in c:\python310\lib\site-packages (from aiohttp>=3.8.1->discord-py-slash-command) (1.7.2)
Requirement already satisfied: aiosignal>=1.1.2 in c:\python310\lib\site-packages (from aiohttp>=3.8.1->discord-py-slash-command) (1.2.0)
Requirement already satisfied: frozenlist>=1.1.1 in c:\python310\lib\site-packages (from aiohttp>=3.8.1->discord-py-slash-command) (1.3.0)
Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in c:\python310\lib\site-packages (from aiohttp>=3.8.1->discord-py-slash-command) (4.0.2)
Requirement already satisfied: charset-normalizer<3.0,>=2.0 in c:\python310\lib\site-packages (from aiohttp>=3.8.1->discord-py-slash-command) (2.0.12)
Requirement already satisfied: idna>=2.0 in c:\python310\lib\site-packages (from yarl<2.0,>=1.0->aiohttp>=3.8.1->discord-py-slash-command) (3.3)
WARNING: There was an error checking the latest version of pip.
PS D:\vsc\Spiral> 
``` mmm
forest oyster
#

reintall the pip versions

slate swan
#

and do, python3 -m pip install discord-py-slash-command

#

wait, why are you using a third party lib

dim sentinel
slate swan
#

prolly

#

nothing happened to pip you just didn't import SlashCommand from the library

#

nvm my bad

#

didnt see that was a warning

dry kelp
#
whitelisted = fields.ManyToManyField("Bot.UserModel", on_delete=fields.SET_NULL, null=True)
#

issue coming from this model...

austere gust
#

Hi

#

I am trying to host my discord bot on a vps, installed everything that is required to run the bot, and 99% of the features doesn't work.

#

When I start on my pc, they do work.

slate swan
#

probably an issue with the vps you're using

lone sail
#

Is it throwing any exceptions? Any logs?

slate swan
#

havent been specified in the docs, maybe try it

#

nor does dpy handle ig

austere gust
#

how can I screenshoot on the vps to save it on my pc?

pseudo zealot
#

Can anyone help?

austere gust
cloud dawn
austere gust
# lone sail Is it throwing any exceptions? Any logs?

?[30;1m2022-06-22 12:29:51?[0m ?[34;1mINFO ?[0m ?[35mdiscord.client?[0m logging in using static token
?[30;1m2022-06-22 12:29:52?[0m ?[34;1mINFO ?[0m ?[35mdiscord.gateway?[0m Shard ID None has sent the IDENTIFY payload.
?[30;1m2022-06-22 12:29:52?[0m ?[34;1mINFO ?[0m ?[35mdiscord.gateway?[0m Shard ID None has connected to Gateway (Session ID: some random things).

slate swan
#

"hello from the pygame community"
but...

#

hm

#

regex time

cloud dawn
austere gust
#

yeah

#

these are the only thing

#

that shows in terminal...

#

well, when I start the bot on my pc, everything works

#

when I start on the vps, only some featrues work

#

I think no

#

but everything is installed

cloud dawn
#

I think so?

austere gust
#

on_raw_reaction add only

#

other events or commands doesn't work

#

ofc ๐Ÿ’€

#

yes

#

not slash commands.

#

I am not idiot man. When I start the bot on my pc, everything works, when I start on the VPS, not much things

pseudo zealot
austere gust
#

man u think I am an idiot

empty vine
#

hey guys, im trying to make my bot send embeds using a paginator, but the image files are local so i cant update them with message.edit, is there another way?

austere gust
pseudo zealot
#

I can pay money if this error gets fixed

austere gust
#

thinking that I am an idiot and thinking that I know nothing, doesn't help

lone sail
#

Gathering information is the first step to figuring out what's wrong..

pseudo zealot
lone sail
#

Nobody knows what you did to host your bot, hence why they ask. To make sure every step is correct and build a understanding of how your setup is.

empty vine
#

not sure if that solves it but you can try

velvet compass
unkempt canyonBOT
#

9. Do not offer or ask for paid work of any kind.

austere gust
#

so anyone?

cloud dawn
pseudo zealot
#

ok

unkempt canyonBOT
#

Whether message content, attachments, embeds and components will be available in messages which do not meet the following criteria:

โ€ข The message was sent by the client

โ€ข The message was sent in direct messages

โ€ข The message mentions the client

This applies to the following events...

cloud dawn
#

@pseudo zealot Yerl provided a possible solution, I didn't take into consideration if you had 2.0 or 1.7.3

pseudo zealot
cloud dawn
pseudo zealot
#

2.1.2 version

cloud dawn
pseudo zealot
cloud dawn
#

Ratelimit go ducky_bike

pseudo zealot
pseudo zealot
cloud dawn
#

That means you are doing something that uses the api too much.

#

Spamming etc.

pseudo zealot
#

sure

#

Dms

#

ok

austere gust
#

I am trying to host my discord bot on a vps, installed everything that is required to run the bot, and 99% of the features doesn't work.

cloud dawn
austere gust
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.

pseudo zealot
#

ok

austere gust
#

only on_raw_reaction_add features working

#

other events, commands doesn't

cloud dawn
#

on_message

austere gust
#

it is enabled ofc, when I start on my pc, they are working

#

when I start on my pc, they are working

cloud dawn
#

Dunno I personally use as paid vps so I don't have a lot of issues py_guido

cloud dawn
#

Ah azure is a pain.

unkempt canyonBOT
#

Hey @austere gust!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

austere gust
#

I am hosting my fivem server on it too

#

I just don't want to pay for bot hosting too

cloud dawn
#

Just look at a VPS like a wireless VM that you can access remotely.

austere gust
#

the code is kinda weird, but yeah

#

everything works

#

I can't understand aswell

#

ok sure

#

2.0.0a3575+g45d498c1

#

I downloaded the same version

#

they are enabled on the website

#

this isn't on my code but still works on my pc, but ok I put it. Lemme try

#

yeye done alr

#

oy bros

#

thank you soo much

warm tulip
#

hey how i can set a cmd that locks a channel for @evreyone

austere gust
#

now everything is working proplery โค๏ธ

#

big thanks @slate swan @slate swan

#

and sorry if I was rude ๐Ÿ˜‚

#

oh wait not everything

warm tulip
#

heeeellllppppp

#

ok thanks

#

what y m

austere gust
#

@slate swan the ticket system doesn't wanna work

warm tulip
#

wait cket system???

#

its my dream to get ticket system

#

wow

austere gust
#

sec

warm tulip
austere gust
#

line 204

#

no

#

I press the button to open ticket

#

but interaction failed

warm tulip
#
  async def lock(self, ctx: commands.Context)
    channel = bot.get_channel(whatever_id)
    guild = bot.get_guild(whatever_id)
    channel.set_permissions(guild.default_role, read_messages=True, send_messages=False)```  itsnot working...
austere gust
#

doesn't create channel

scarlet aurora
#

no shit

#

he obviously just put it there for an example

#

please use your brain before you try to help people

#

oh

austere gust
#

Imma copy the error @slate swan

warm tulip
#
  async def lock(self, ctx: commands.Context)
    channel = bot.get_channel(989043208438841345)
    guild = bot.get_guild(whatever_id)
    channel.set_permissions(@everyone, read_messages=True, send_messages=False)``` not working
scarlet aurora
#

then using that id, store it in a variable

#

code block

austere gust
#

?

lone sail
#

!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.

austere gust
#

it is an error only

#

same shit, works on my pc, doesn't work when I start on the vps

warm tulip
#

idk

#

nvm

#

can someone teach me how to create a welcome cmd

#

i mean not a cmd

#

just a welcome

austere gust
#

welcome message?

warm tulip
#

yea

#

embed welcome message

austere gust
#
@bot.event
async def on_member_join(member):
    channel = bot.get_channel(channel_id)
    await channel.send(f'Welcome{member.mention}!')
    await member.send(f'Something that the bot will send as a private message to the member{member.mention}!')
warm tulip
#

how i can add member pfp to it

#

ok

#

@austere gust i type it in cog or in main.py

slate swan
#

Yo can someon dm me i need help I want my command to be run by members every 24 hours and if they try to run it before 24hrs they get an error message thst they need to wait 24hrs

austere gust
#

@slate swan cool, the ticket is opened now, but when I press the claim button, same shit (interaction failed)

#

replace all buttons with self, interaction: discord.Interaction, button: discord.ui.Button?

#

oo

#

ok ty

warm tulip
#

why it have a eror

  async def on_member_join(member):
    channel = bot.get_channel(989043208438841345)
    embed.set_thumbnail(url=member.avatar.url)
    await channel.send(f'Welcome To Wibuos Army{member.mention}!')
    await member.send(f'Welcome To Wibuos Army{member.mention}!')```
quaint epoch
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.

quaint epoch
#

just saying "error" is not very helpful

#

!d discord.Embed

unkempt canyonBOT
#

class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, timestamp=None)```
Represents a Discord embed.

len(x) Returns the total size of the embed. Useful for checking if itโ€™s within the 6000 character limit.

bool(b) Returns whether the embed has any data set.

New in version 2.0.

For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") for you.

Changed in version 2.0: `Embed.Empty` has been removed in favour of `None`.
austere gust
#

oy big thanks @slate swan

warm tulip
#

@austere gust chek your dm plsss

slate swan
warm tulip
#

nvm'

slate swan
#

simply calling the set_thumbnail method wont work

warm tulip
#

do u know how to create ticket?

#

with cmddd

slate swan
#

what ticket-

warm tulip
#

wym

slate swan
warm tulip
#

bot creates a channel for mods and that person created ticket

slate swan
#

oh lmao

warm tulip
#

soo..

#

do u know how?

#

offffffffffff

#

bruh u was typing and i was thinking you are sending me the code.......๐Ÿ’€

placid skiff
#

!d discord.Guild.create_text_channel

unkempt canyonBOT
#

await create_text_channel(name, *, reason=None, category=None, news=False, position=..., topic=..., slowmode_delay=..., nsfw=..., overwrites=..., default_auto_archive_duration=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Creates a [`TextChannel`](https://discordpy.readthedocs.io/en/latest/api.html#discord.TextChannel "discord.TextChannel") for the guild.

Note that you need the [`manage_channels`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to create the channel.

The `overwrites` parameter can be used to create a โ€˜secretโ€™ channel upon creation. This parameter expects a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.10)") of overwrites with the target (either a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")) as the key and a [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/latest/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite") as the value.

Note

Creating a channel of a specified position will not update the position of other channels to follow suit. A follow-up call to [`edit()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.TextChannel.edit "discord.TextChannel.edit") will be required to update the position of the channel in the channel list...
dim tapir
#

how would u go about tracking ur api calls

whole flicker
#

API calls in python of API calls to an external website?

dim tapir
#

to discord my boy

slate swan
#

Can anyone give me that tutorial site link pls

slate swan
#

Ye thanks

#

I needed it for my friend

whole flicker
slate swan
#

slash commands work on webhooks right?

iron sorrel
paper sluice
paper sluice
maiden fable
slate swan
dim tapir
#

wrong channel

lofty pecan
#

Hey there, is there a way to create a color picker in discord py?

hasty loom
lofty pecan
hasty loom
#

well uh i dont think its possible to make a slider inside discord lol

#

i think the easiest way would simply be to let the user input a hex value

lofty pecan
#

yeah but

#

apparently people don't like that

hasty loom
#

well theres no way to have an exact colour picker inside discord

#

u could make a drop down menu with like 10 colours

#

but if u want to have an exact colour u would need a hex or rgb input or something

lofty pecan
hasty loom
#

unfortunately thats not possible in discord atm lol

slate swan
#

๐Ÿ‘€ nice command idea brb

velvet compass
#

.color hex #8BE6D8 sad noises

ionic turtle
ionic turtle
#

thats not a color picker as in slider

#

thats ust autocomplete

slate swan
#

making a slider on discord is not possible as you might be aware, read the chats below that.

ionic turtle
#

im aware,

slate swan
#

they need some way to allow a user to get color hex? and thats basically it

ionic turtle
#

why cant they just redirect to a color picking hesx

#

or even better like ask for the basic color in autocomplete then send a dropdown with color emojis

slate swan
#

how many emojis?

ionic turtle
#

too many

#

it would be like

#

100+

slate swan
#

discord has a limit on reactions?

ionic turtle
#

yes in dropdown its 25

slate swan
#

the autocomplete i made can process 740+ colors.

ionic turtle
#

im saying,

#

autocomplete has basic options like

red
blue
green...

slate swan
#

the gif says otherwise

ionic turtle
#

boi

#

im saying you could also just have basic colors and then use a dropdown with variations of those colors

#

and since dropdown options have an emoji space you could technically have like colored blobs

ionic turtle
#

is it better?

slate swan
#

best lib for python discord imo.

ionic turtle
slate swan
#

and yeah, i can provide explanations.

ionic turtle
#

pls do, im curious

slate swan
#

I'll backup

#
  1. discord.py is very badly typed. there are many #type: ignore
  2. hikari is not cache dependent, i.e. the 200-300mbs of ram discord.py uses for an average bot is not a case in hikari, you have full control on the cache
  3. documented and persistent restclient and cache ( people using discord.py arent even aware of the HTTPClient???)
  4. multiple command handlers
  5. hikari is faster
  6. more object oriented
ionic turtle
#

what would the use be for http cleint?

slate swan
#

thats basically everything your bot is dependent on, sir.

ionic turtle
slate swan
ionic turtle
slate swan
#

*exposing to the

heady sluice
slate swan
#

๐Ÿ˜” discord folder > http.py > class HTTPClient

ionic turtle
#

its not like httpclient is some malicious thing

heady sluice
#

I'm not going to navigate to the discord folder

slate swan
#

thats not an issue, never said discord.py is bad, i just said how "hikari is better."

paper sluice
slate swan
ionic turtle
#

i dont understand it after basic stuff. like generics make me want to die

slate swan
#

thats not the point, the point is: in hikari you can use the RestClient without a gateway.

ionic turtle
#

fr we're so dumb ๐Ÿ˜ญ

heady sluice
#

no connect internet still use

#

hikari moment

slate swan
#

heh

heady sluice
#

isn't that what you said

lofty pecan
#

that went pretty far lmao

#

I guess I'll just made an embed with a list of color

jovial plover
#

May i know the official library for Buttons, Select Menus, User commands etc

#

is there none yet

#

Where can read to get started

ionic turtle
#

yea almost all if not all at this point support interactions

slate swan
#

no, definitely, i think y'all should look into https://discord.dev and have a look on how the discord api actually works.

making a gateway connection is not necessary at all, its just a medium to exchange the events, you can do stuff like sending messages, kicking members, updating objects and other POST, GET and PATCH requests without a gateway. discord.py abstractions will never allow you do that. as it totally relies on the gateway

libraries like hikari and discord.js allows you to make a rest only client... which basically is just used to get and send requests. basically what an interaction server or a dashboard would need.

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
ionic turtle
#

pure http

heady sluice
warm tulip
#

guys how to make mute cmd and set a role for muted

jovial plover
#

You can do Timeout now

warm tulip
#

i now

#

i wanna mute

jovial plover
#

Then make a role with send messages disabled perm

slate swan
#

HTTPClient is the class which makes requests in discord.py
RestBot is the class which makes requests in hikari

thats basically it.

ionic turtle
warm tulip
jovial plover
#

he wants to make mute role

ionic turtle
#

and discord does the unmuting for u

ionic turtle
#

u need a member and role object

slate swan
#

there's a lot, http is a protocol, REST is a type of api
but the libraries chose their own class name, even tho having same functionality

warm tulip
#

can u send all of the code im beginner

ionic turtle
warm tulip
#

::|||

slate swan
#

*gateway,
it just helps you receive the events from discord, nothing else.

ionic turtle
slate swan
#

for the person who asked why should the http be revealed.
it saves you from 2-3 extra operations/requests

ionic turtle
#

wdym 2-3 extra

slate swan
#

how would you normally send a message to a channel if you have its id

ionic turtle
#

use the bot's cache to get the channel and then send api request to send message through the function

#

you rarely ever fetch stuff

slate swan
#

you can bot.http.send_message(id, "this is the message")

warm tulip
#

how to timeout members full cmd pls

minor totem
#

Are you looking to create a Discord API framework?

ionic turtle
warm tulip
#

howwwwwwwwwww

ionic turtle
#

!d discord.Member.timeout

unkempt canyonBOT
#

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

Applies a time out to a member until the specified date time or for the given [`datetime.timedelta`](https://docs.python.org/3/library/datetime.html#datetime.timedelta "(in Python v3.10)").

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

This raises the same exceptions as [`edit()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member.edit "discord.Member.edit").
ionic turtle
#

there u go

minor totem
slate swan
ionic turtle
#

you can always access the bot's http tho

slate swan
#

eh wrong enter press, wait

ionic turtle
#

just use the private attr

#

actually its not even private

pliant gulch
#

HTTPClient & RESTClients' will be a library abstraction, you don't really need to know them persay

minor totem
#

If I want to edit a channel, with discord.py I still need to fetch the channel just to edit it. If the API methods are exposed, I can just directly edit the channel by the ID that I have.

slate swan
#

tbh i really love using the REST classes instead of making requests thru the discord Model methods

pliant gulch
#

If only restcord wasn't in PHP

ionic turtle
minor totem
ionic turtle
#

use the cache, dpy cache is quite decent

slate swan
minor totem
#

Yup

pliant gulch
#

Decent kek? It's literally just a mapping

#

And python's mapping is very bad compared to other languages

#

It would be nice if discord.py had a cache driver system

slate swan
minor totem
#

Yeah that's the RESTClient-thing we've been talking about.

pliant gulch
#

Don't even get me started on discord.py's message cache

cerulean folio
#
@bot.command(name='add')
@commands.has_any_role(role)
@cooldown(1, 1000, commands.BucketType.user)
async def cmd_add(ctx):
  await cmd.add_report(ctx, bot)
  cmd_add.reset_cooldown(ctx)
@cmd_add.error
async def cmd_add_error(ctx, error):
    if isinstance(error, commands.MissingRole):
      await ctx.send("You don't have access to this role")

This doesn't show error when used without role :o
It just doesn't allow people that don't have role

ionic turtle
cerulean folio
#

somethow

slate swan
#

andy with his 0(n) complaints

minor totem
pliant gulch
#

It's a deque for the popleft, but they made getting message O(n)

#

They could've used a dictionary

#

They are ORDERED NOW kek

#

Just encapsulate a dict inside of a class that handles popping left, then you have a deque with constant time getitem

sick birch
#

Is it still linear time?

#

After ordering, I mean

pliant gulch
#

Popping left will be probably, unless you store the key before hand

warm tulip
#
  @commands.has_any_role(989043172007104552,989044819101896735,)
  async def timeout(self, ctx: commands.Context, target: discord.member, *, reason):
      await timeout(until, /, *, reason=None)
      await ctx.send("member timeouted :white_check_mark:")```
its not working
sick birch
minor totem
#

Circular buffer ftw

maiden fable
#

Let's eat popcorn ๐Ÿฟ

pliant gulch
#

Cause you'll have to do list(dict.keys())[-1]

#

I cba

minor totem
slate swan
pliant gulch
#

You could store the keys as well in the encapsulating class

#

That'll prob get rid of needing to call list()

#

But it'll be a total upgrade from the current deque

#

Which after all, the only reason it seemed to be used for is popping left

minor totem
ionic turtle
sick birch
#

Wait, is the current message cache an iterable? As opposed to a hashmap?

ionic turtle
#

timeout is a method of cls: discord.Member

slate swan
pliant gulch
#

Hashmaps are iterable too

sick birch
#

Well yeah, I mean in the sense of a list/array

minor totem
unkempt canyonBOT
#

discord/state.py lines 462 to 463

def _get_message(self, msg_id: Optional[int]) -> Optional[Message]:
    return utils.find(lambda m: m.id == msg_id, reversed(self._messages)) if self._messages else None```
unkempt canyonBOT
#

discord/state.py line 273

self._messages: Optional[Deque[Message]] = deque(maxlen=self.max_messages)```
maiden fable
#

Let's just make it a dict of message id and message object

pliant gulch
#

๐Ÿ’€

sick birch
#

Yikes, a dict or something similar would be better wouldn't it?

pliant gulch
#

That's what I've been saying above

#

Literally my entire tangent

ionic turtle
#

what is a Deque again ๐Ÿ˜ญ

maiden fable
#

I would love to see Danny denying the request tho

maiden fable
unkempt canyonBOT
#
Nuh-uh.

No documentation found for the requested symbol.

maiden fable
#

Rip, anyways it belongs to the collections module

sick birch
#

Someone must've put in a PR or an issue at least for this?

cerulean folio
#
@bot.command(name='add')
@commands.has_any_role(roles)
@cooldown(1, 1000, commands.BucketType.user)
async def cmd_add(ctx):
  await cmd.add_report(ctx, bot)
  cmd_add.reset_cooldown(ctx)

@cmd_add.error
async def cmd_add_error(ctx, error):
    if isinstance(error, commands.MissingRole):
      await ctx.send("You don't have access to this role")

Someone knows why this doesn't return the last message when someone uses it without role?

sage otter
pliant gulch
unkempt canyonBOT
#

rin/models/cacheable.py lines 14 to 15

@attr.s(slots=True)
class Cache(Generic[T]):```
unkempt canyonBOT
#

hikari/impl/cache.py lines 1530 to 1538

def get_message(
    self, message: snowflakes.SnowflakeishOr[messages.PartialMessage], /
) -> typing.Optional[messages.Message]:
    if not self._is_cache_enabled_for(config_api.CacheComponents.MESSAGES):
        return None

    message_id = snowflakes.Snowflake(message)
    message_data = self._message_entries.get(message_id) or self._referenced_messages.get(message_id)
    return self._build_message(message_data) if message_data else None```
maiden fable
unkempt canyonBOT
#

class collections.deque([iterable[, maxlen]])```
Returns a new deque object initialized left-to-right (using [`append()`](https://docs.python.org/3/library/collections.html#collections.deque.append "collections.deque.append")) with data from *iterable*. If *iterable* is not specified, the new deque is empty.

Deques are a generalization of stacks and queues (the name is pronounced โ€œdeckโ€ and is short for โ€œdouble-ended queueโ€). Deques support thread-safe, memory efficient appends and pops from either side of the deque with approximately the same O(1) performance in either direction.

Though [`list`](https://docs.python.org/3/library/stdtypes.html#list "list") objects support similar operations, they are optimized for fast fixed-length operations and incur O(n) memory movement costs for `pop(0)` and `insert(0, v)` operations which change both the size and position of the underlying data representation.
ionic turtle
#

ty

sage otter
#

Uppercase belongs to typing.

pliant gulch
ionic turtle
#

oh generic version

slate swan
#

PleadingClown do it

pliant gulch
#

Maybe in CPP

sick birch
slate swan
pliant gulch
#

I suck at rust ๐Ÿ˜ฉ

minor totem
maiden fable
minor totem
#

The deque is great because you can set a max_len and re-use memory from my understanding

pliant gulch
#

You can set a max length with what I showed as well

#

So it doesn't go past a certain amount of messages

maiden fable
#

Let's just sit in the back and eat popcorn

wicked atlas
#

current message cache system in discord.py slow, other methods faster

maiden fable
#

I also can't understand anything

minor totem
#

Google the terms you don't understand

wicked atlas
#

ยฏ_(ใƒ„)_/ยฏ

maiden fable
#

Because its Danny ๐Ÿ‘€

pliant gulch
slate swan
#

O(1)

maiden fable
#

First one

slate swan
#

less cpu operations.

paper sluice
#

i aspire to be O(1)

#

u output the stuff in constant time no matter how big the input is

slate swan
#

other libraries? no
we were talking about hikari lol

shrewd apex
#

...

slate swan
#

i feel its better than libs like hata.

shrewd apex
#

hello

slate swan
#

hey asher

minor totem
#

The fact that you pop the item after adding the new is making it worse though. You should pop first to free up that hash slot in the index.

pliant gulch
#

WeakRef would be good, but wouldn't that cause issues later on, or in some cases?

slate swan
#

better cache,
Is faster
more pythonic
strictly typed
multiple command handlers
you are not restricted to use gateway ( the thing we discussed earlier )
are a few of them

ionic turtle
#

dpy typing is fine tho? it lies well

shrewd apex
#

faster by how much?

pliant gulch
slate swan
#

ctrl + f for #type: ignores

pliant gulch
#

Gateway is a Websocket connection between you and discord

ionic turtle
#

seems to return bot obj

pliant gulch
#

Using the gateway when you DON'T need it will end up costing you bandwith and other stuff

slate swan
pliant gulch
#

Yes

#

So does the API

minor totem
ionic turtle
#

my bot class which supclasses commands.Bot

minor totem
pliant gulch
#

iirc they have like 3 generics for a mixin

#

Or some other class I cba to remember

slate swan
#

if you wanna use something like mypy, discord.py would be a hell

ionic turtle
minor totem
#

If you don't use the gateway, you shouldn't be forced to use it.

Discord.py relies a lot on its cache and that would not stay relevant if you just use the REST API with no events incoming.

pliant gulch
#

Websockets are bi-directional, with the way it works, you need to send heartbeats every so often. You'll also receive data from the websocket, imagine having presences intents in a 5k+ Member guild, you'll get an event with DATA everytime they update their presence (very often), with rest only you don't receive any events, you only post, fetch, etc

#

The overheard that comes with the websocket will probably be adding onto that

#

With rest you really, realistically speaking need an aiohttp.ClientSession and your done

slate swan
ionic turtle
#

master br

pliant gulch
slate swan
pliant gulch
ionic turtle
#

dpy uses pyright instead of mypy

#

pycharm pro

pliant gulch
#

Neovim

slate swan
#

vscode atm

slate swan
#

am i right andy?

minor totem
#

You are, yes, but Mypy is a bit behind in the typing world

#

A lot of bugs and a lot less people fixing them

ionic turtle
#

yepp

pliant gulch
#

Mypy ๐Ÿ‘ฟ Pyright ๐Ÿ˜ˆ

slate swan
#

Kannakillyourself I'll still keep it

pliant gulch
#

I'll get errors from mypy that pyright doesn't even flag

slate swan
#

is that bad?

pliant gulch
#

I have pyright on strict typing, so yes

slate swan
#

yeah

#

most of the errors i get comes from Optional[type].attributeS

pliant gulch
#

For good reason

slate swan
#

depends on ur command handler

#

lightbulb and crescent wont, optional in tanjun

#

lightbulb

#

why not use the setup_hook?

#

it has been working like Discord.py hybrid commamds for a long time, basically slash and prefix both under one function

#

well, that's a different story

#

its indeed a good thing

#

also, not something really impressive, but built-in paginators support wut

#

and the default help command generated is even more uwuer

pliant gulch
#

when dpy has builtin paginator

#

I've never seen anyone actually use it though kek

slate swan
#

you can do it the way you want, prefix only, slash only or both.

slate swan
#

yep, better than dpykannapogg

pliant gulch
#

What kind of paginators were you talking about

slate swan
#

they are called plugins

slate swan
pliant gulch
#

Oh

slate swan
#

if you want client, use hikari.GatewayBot
if you want Bot, use some command handler and its Botclass

#

why not

#

it does but its hard

#

it does too

#

yea~

#

prefix commands is a command handler thing, so no

#

lemme tell in the most basic words
hikari = discord
a command handler = discord.ext.commands

#

AnyaWTF i feel writing hikari = discord is illegal

dim tapir
#

fellas

pliant gulch
#

I'm assuming the bot class in the command handler latches onto GatewayBot

dim tapir
#

how would one run a async command without await

pliant gulch
#

Which is the same reason why you use discord.ext.commands instead of just discord for prefix commands\

ionic turtle
#

Unless like asyncio.run

dim tapir
#

perfectt

errant coral
#

Not to disturb but do someone know a code that deletes a voice channel after all people leave the channel?

slate swan
#

no?

#

oh nvm

#

the bot class of that library suclases GatewayBot

dim tapir
#
RuntimeError: asyncio.run() cannot be called from a running event loop
quaint epoch
dim tapir
#
    async def getImg(self, userURL):
        async with aiohttp.ClientSession() as session:
            async with session.get(str(userURL)) as resp:
                return Image.open(BytesIO(await resp.read()))

    img = asyncio.run(self.getImg(userAvatarUrl))

slate swan
#
quaint epoch
#

instead maybe try await getImg()

dim tapir
#

i cant want to use await

quaint epoch
dim tapir
#

im using jit

quaint epoch
#

?

dim tapir
#

to compile everything in this function

quaint epoch
#

im out

dim tapir
#

image processing moment

quaint epoch
#

not messing with numba and async

quaint epoch
dim tapir
#

we do a little bit of numba and async

uncut jacinth
#
class Transfermoneybuttons(discord.ui.View):
    def __init__(self, amount, author, timeout=180):
        super().__init__(timeout=timeout)
        self.amount = amount
        self.author = author

    async def interaction_check(self, interaction: discord.Interaction):
        if interaction.user != self.author:
          await interaction.response.send_message("You can't use that", ephemeral=True)
          return False
        return True

    @discord.ui.button(label="Deposit "+moneycurrency,style=discord.ButtonStyle.blurple, emoji=":up:")
    async def deposit(self,interaction:discord.Interaction,button:discord.ui.Button):

This has a Timeout in it, How can i make that the buttons get grey on timeout error?

errant coral
# quaint epoch you could just use on_voice_state_update, everytime a user leaves a channel, you...
@client.event
async def on_voice_state_update(member, before, after):
	if after.channel.id == 984492572544213083:
		CAT = discord.utils.get(member.guild.channels, id = 984491906237075496)
		vc = await member.guild.create_voice_channel(f"{member.name}", category = CAT)
		await member.move_to(vc)
	elif str(before.channel.name) == str(member.name) and after.channel == None:
		await before.channel.delete()โ€Š

Ok. I made this code but it only creates and when everyone leave it wont delete

dim tapir
#

pingu look at what i sent slime

errant coral
#

Ok

quaint epoch
#

!d discord.VoiceChannel.members

unkempt canyonBOT
errant coral
#

Ok

slate swan
#

there's a lot of resources in .gg/hikari 's #886584307454472243 ( getting-started-with-hikari ) channel, in case you wanna check out

quaint epoch
#

oh shit no lol

#

!d discord.Member.voice

unkempt canyonBOT
quaint epoch
#

bruh

errant coral
#

Hope it works

quaint epoch
#

wtf

errant coral
#

?

quaint epoch
#

bruh

#

the docs are fucking with me

quaint epoch
#

okay maybe try this py elif not before.voice is None and after.voice is None: if len(before.voice.channel.members) == 0: await before.channel.delete()

#

there we go

uncut jacinth
slate swan
#

on_timeout method

#

basically an async function called on_timeout under that class

uncut jacinth
#

Ok thanks

#

I gonna try

dim tapir
#

numba doesnt like bytesIO

cerulean folio
#
@bot.command(name='add')
@commands.has_any_role(roles)
@cooldown(1, 1000, commands.BucketType.user)
async def cmd_add(ctx):
  await cmd.add_report(ctx, bot)
  cmd_add.reset_cooldown(ctx)

@cmd_add.error
async def cmd_add_error(ctx, error):
    if isinstance(error, commands.MissingRole):
      await ctx.send("You don't have access to this role")

Someone know why this doesn't return message on missing role? Just blocks the command and that's it

slate swan
#

whats the role variable, a list or something?

cerulean folio
#

a list of roles, each role is an integer

torn sail
#

try commands.MissingAnyRole

slate swan
#

you need to add a * before roles in the has_any_role pithink

#

!pip hikari

unkempt canyonBOT
slate swan
#

nah thats optional lol

cerulean folio
#

That worked ! โ™ฅ๏ธ

torn sail
#

๐Ÿ‘

cerulean folio
slate swan
#

pip install hikari-lightbulb

slate swan
#

not important, as said
hikari is like discord
lightbulb is like discord.ext.commands

#

like if you wanna make an embed so you will ofcourse use hikari to do that

#

ยฏ_(ใƒ„)_/ยฏ

#

are you on mac/linux by any chance?

dim tapir
#

okay i dont feel like doing numba with PIL to keep my sanity

uncut jacinth
# slate swan on_timeout method
class Transfermoneybuttons(discord.ui.View):
    def __init__(self, amount, author, timeout=20):
        super().__init__(timeout=timeout)
        self.amount = amount
        self.author = author

    async def on_timeout(self, interaction: discord.Interaction):
        print(test)
        for child in self.children:
            child.disabled=True
        await interaction.response.edit_message(view=self)

You know why this is not workin ive set the timeout to 20s eventho its like 3 minutes + the on_timeout isn't working

slate swan
#

see the error in your console

uncut jacinth
#

Idk why but since i started using cogs no errors will show up

slate swan
#

you probably have a error handler which eats up ur error

#

any on_command_error events?

uncut jacinth
slate swan
#

/listeners?

uncut jacinth
#

No

#

Only on message and on ready

dim tapir
#

if you guys want dis feel free to use it

sage otter
#

Two blocking libraries

#

PIL and default standard sqlite

#

Dope.

uncut jacinth
dim tapir
eager bluff
#

any way to only take the argument but still work if it doesn't have the argument?

#

for example, if there is an argument, it would use it, otherwise not

dim tapir
#

i havent done much research on async photo editing libraries

uncut jacinth
eager bluff
#

so if i did !update it would update me but if i did !update th it would update th

uncut jacinth
eager bluff
uncut jacinth
eager bluff
#

ofc not like that

uncut jacinth
#

Whats the argument self

eager bluff
#

but you know what i mean

uncut jacinth
#

Yes

#

You could replace it (Like you did) with another argument

#

Or just place in a string

#

This same works with
int=0, discord.Member=None

#

and more

eager bluff
uncut jacinth
#

Wait i will send a code

paper sluice
#

like

def ...(ctx, val: str | None = None):
    if val is None:
        val = 'foo'
eager bluff
uncut jacinth
#

So that should work, You can also change it to message.author.nickname

#

or what ever you want

eager bluff
#

i kinda forgot what the better way to do this is

uncut jacinth
#

elif

#

@eager bluff

#
class Transfermoneybuttons(discord.ui.View):
    def __init__(self, amount, author, timeout=20):
        super().__init__(timeout=timeout)
        self.amount = amount
        self.author = author

    async def on_timeout(self, interaction: discord.Interaction):
        print(test)
        for child in self.children:
            child.disabled=True
        await interaction

Any body know why the on_timeout function does nothing, Not even a error?

fading marlin
#

why are you awaiting interaction? what's that supposed to do in your head?

dim tapir
uncut jacinth
dim tapir
uncut jacinth
fading marlin
#

you don't pass any args to on_timeout, and if you're not getting any errors, you probably have an eh that's eating it up

uncut jacinth
#

My english is very bad

fading marlin
#

fix what? errors not showing up or buttons not being disabled when on_timeout is called?

fading marlin
#

you'll have to set an attribute of the class to the message that was sent via a Messageable.send, and use that as your message-edit method

class View(...):
    async def on_timeout(self):
        await self.message.edit(view=self)

# in your command function
view = View()
message = await ctx.send(..., view=view)
view.message = message
uncut jacinth
#

I even put a print("test") on start no response

#

nvm

#

await self.message.edit(view=self)
AttributeError: 'Transfermoneybuttons' object has no attribute 'message'

THis what happens

fading marlin
#

did you add a message attribute in your __init__?

uncut jacinth
#

like

#

self.message = self.message?

eager bluff
#

how would i do this but for administrators? admistrator_guild doesnt work

@has_permissions(manage_guild=True)

fading marlin
uncut jacinth
#

Ok

eager bluff
#

oh wait

uncut jacinth
eager bluff
#

without guild?

uncut jacinth
uncut jacinth
fading marlin
uncut jacinth
#
    @commands.command()
    async def transfer(self, ctx, amount: int=100):
        await open_account(ctx.author)
        users = await get_economy_data()
        
        message = await ctx.send(embed = embed,view=Transfermoneybuttons(amount, ctx.author))
        view.message = message
#

Thats right?

fading marlin
#

you're not defining view though

uncut jacinth
uncut jacinth
fading marlin
#

traceback?

uncut jacinth
#

The command doesn't even work

#

anymore

fading marlin
#

show code

uncut jacinth
#
@commands.command()
    async def transfer(self, ctx, amount: int=100):
        await open_account(ctx.author)
        users = await get_economy_data()
        embed = discord.Embed(title="Withdraw or Deposit", description=f"Choose if you want to withdraw or deposit `{amount}{moneycurrency}`")
        message = await ctx.send(embed = embed,view=Transfermoneybuttons(amount, ctx.author))
        view.message = message

#
class Transfermoneybuttons(discord.ui.View):
    def __init__(self, amount, author, timeout=10):
        super().__init__(timeout=timeout)
        view.message = None
        self.amount = amount
        self.author = author

    async def on_timeout(self):
        print("test")
        for child in self.children:
            print(child)
            child.disabled=True
        print("test")
        await self.message.edit(view=self)
fading marlin
uncut jacinth
#

view.message = message??

#

Doesn't this define it?

fading marlin
#

no, python has no clue what view is, therefore it will have even less of a clue what view.message is

uncut jacinth
#

Ohh ok

fading marlin
#

when instantiating your ui.View class, assign it to a variable, and use that variable to set the .message attr

uncut jacinth
#
view=Transfermoneybuttons(amount, ctx.author)
``` do i have to replace this with view?
fading marlin
#

yes and wdym

alpine cove
#

lmao

uncut jacinth
fading marlin
#

let's see your updated code

uncut jacinth
#
@commands.command()
    async def transfer(self, ctx, amount: int=100):
        await open_account(ctx.author)
        users = await get_economy_data()
        view = View()
        embed = discord.Embed(title="Withdraw or Deposit", description=f"Choose if you want to withdraw or deposit `{amount}{moneycurrency}`")
        message = await ctx.send(embed = embed,view=Transfermoneybuttons(amount, ctx.author))
        view.message = message
fading marlin
uncut jacinth
#

idk why it doesn't show any errors

fading marlin
#

hmm, well either way, that's why your command is not functioning

uncut jacinth
#

and it stops after the view variable

fading marlin
#

because the class View doesn't exist

uncut jacinth
#

No i changed it with Transfermoneybuttons

#

Ohh wait

fading marlin
#

did you pass in the required arguments to the class?

uncut jacinth
#

it think because i forgot the variables

uncut jacinth
fading marlin
#

code?

uncut jacinth
#
@commands.command()
    async def transfer(self, ctx, amount: int=100):
        await open_account(ctx.author)
        print("1")
        users = await get_economy_data()
        print("1")
        view = Transfermoneybuttons(amount, ctx.author)
        print("1")
        embed = discord.Embed(title="Withdraw or Deposit", description=f"Choose if you want to withdraw or deposit `{amount}{moneycurrency}`")

        print("1")
        message = await ctx.send(embed = embed,view=view)
        view.message = message
#

stops after 2nd print

fading marlin
uncut jacinth
#

Didnt you said i should do that?

fading marlin
#

well yes, but that's in the command, not in the view

uncut jacinth
fading marlin
#

that's the ui class?

uncut jacinth
#
class Transfermoneybuttons(discord.ui.View):
    def __init__(self, amount, author, timeout=10):
        super().__init__(timeout=timeout)
        view.message = None
        self.amount = amount
        self.author = author

    async def on_timeout(self):
        print("test")
        for child in self.children:
            print(child)
            child.disabled=True
        print("test")
        await self.message.edit(view=self)
#

Thats it

fading marlin
#

that's what I'm referring to

#

in line 4, you've got view.message = None, what's view?

#

do you mean self?

uncut jacinth
#

could you change it?

#

so its right

fading marlin
uncut jacinth
#

I dont really understand you because my english is very bad

#

Im also very new at programming and not experienced with discord.py

fading marlin
#

dpy isn't a really beginner-friendly library

uncut jacinth
#

so sorry, I thank you much but i dont think i understand it and i dont want to waste your time any more

uncut jacinth
fading marlin
#

it's fine. What's happening is that your trying to access view where it is not defined. Just replace view with self in the class and see where that takes you

uncut jacinth
#

still doesn't goes after

#
view = Transfermoneybuttons(amount, ctx.author)
#

@fading marlin

slate swan
#

dont call the deco

#

its just

@Bot.event
#

because it only takes 1 argument which is a coroutine object

heady sluice
#
@bot.event()
async def on_ready():
    ...

@bot.event(on_ready)
async def on_message(message):
    ...
#

siuu

slate swan
#

you can also use the enum

@Bot.on(GatewayEvents().MESSAGE_CREATE)
async def example(payload: dict[str, "Any"]) -> None:
    ...
#

i still have allot to do

#

how can i downgrade back to discord py 1

#

i do not like the new version

slate swan