#Basic Pycord Help (Quick Questions Only)

1 messages · Page 19 of 1

young bone
#

It that in a cog?

dawn escarp
#

yes

topaz rune
#
def setup(bot):
    bot.add_cog(lg_class(bot)) #Me permet d'ajouter le bot dans les autres fichiers
dawn escarp
#

and in main.py

bot.load_extension('lg')
young bone
#

Im not sure if you get something with "store=False" in the load_extension

topaz rune
cyan quail
#

the other prints were working so i don't think that's the issue, store=False is default on 2.1+ anyway

#

actually what version are you even on

#

have you tried reinstalling

dawn escarp
#

I think 2.0.0

#

but not sure we're lookin'

cyan quail
#

can you upgrade to the master branch?

#

git+https://github.com/Pycord-Development/pycord when using pip

#

oh wtf

#

2.1.3 released but there wasn't an announcement

#

bruh

topaz rune
young bone
#

Wait

cyan quail
#

i suggested master because that was the release candidate, but just install 2.1.3 instead

topaz rune
#

I just did

#

imma try the code now

dawn escarp
#

we got some problem with the code bc of the upgrade

#

we're doing it...

#

might take a moment

cyan quail
#

what error

topaz rune
#

smth on another place on the code

#
    if len(label) > 100:
TypeError: object of type 'int' has no len()
#

just this
we're working on it

dawn escarp
#

ok so

#

still not working

topaz rune
#

even with the upgrade

cyan quail
#

does it work on another test bot?

#

that, or a different guild

dawn escarp
#

we do not have another bot

cyan quail
#

actually yeah try guild first

dawn escarp
#

or another guild

cyan quail
#

just make one

dawn escarp
#

but we can try

#
UnboundLocalError: local variable 'role' referenced before assignment

On the new guild

topaz rune
#

with this code:

for user in players_in_game:
        print('qqqqqqq')
        try:
            role = await guild.create_role()
        except Exception as e:
            print(e)
        else:
            print(role)
        finally:
            print('YEAH')

        roles.append(role)
        print(await user.guild.create_role(name=f'LG - {user.name}'))
dawn escarp
#

we tried

#

and it has done that

#

wich is normal

topaz rune
#

it seems to work on another guild

fervent cradle
#

How can I add this to my bot

cyan quail
topaz rune
#

how can we check that?

cyan quail
#

well

#

idk if you can

#

ah do you have logging set up

dawn escarp
#

?

cyan quail
#

that's typically where ratelimit messages end up

dawn escarp
#

ok, we're putting it in

#
WARNING:discord.http:We are being rate limited. Retrying in 84896.90 seconds. Handled under the bucket "None:923316085950918656:/guilds/{guild_id}/roles"
#

ok

cyan quail
#

LOL

dawn escarp
#

rate limited for 24h

topaz rune
#

ok lets kill ourself

dawn escarp
#

YEAH !

cyan quail
#

welp you just gotta create less roles

dawn escarp
#

anyways thx @cyan quail for your help

topaz rune
#

yeah

cyan quail
#

all good

topaz rune
#

thanks buddy

fervent cradle
#

cant find anything on the bot's profile page

cyan quail
fervent cradle
#

Oh is it a only verified app thing? sad

cyan quail
#

yeah

agile tartan
#

Is cogs possible?

silver moat
#

yes

chilly mica
#

anyone help me thanks

silver moat
chilly mica
simple canopy
#

bot

#

is not defined

chilly mica
silver moat
#

?tag op

obtuse juncoBOT
#

dynoError No tag op found.

silver moat
#

?tag lp

obtuse juncoBOT
#
chilly mica
#

@silver moat can you help me thanks

simple canopy
#

no, learn python

chilly mica
simple canopy
#

then, don't code and pay someone to do it for you

#

error message says everything

chilly mica
fervent cradle
#

uh guys

#

So acually I want it so that whenever the client uses and invalid url for the thumbnail
it returns it with a "Invalid url msg" with the rest of the embed
I used try...except block for this purpose but it doesn't seem to work..

#
@bot.slash_command(name="embed", description="Make embeds!",guild_ids=[949883077738496040, 831508434872565762])
async def em(ctx, title, description, image_url: Option(str, "Custom image for embed!", required = False, default = None)):
    author = ctx.author.name
    embed = discord.Embed(
        title = title,
        description= f"{description}",
        color= random.choice(c_lists)
    )
    try:
        embed.set_thumbnail(url=f"{image_url}") 
    except:
        print("hmm")
        pass
    embed.set_footer(text=f"{author}",icon_url=f"{ctx.author.avatar.url}")
    await ctx.respond(embed=embed)```
#

please review this code

#

i keep getting this error

Traceback (most recent call last):
  File "C:\Users\casho\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 127, in wrapped 
    ret = await coro(arg) File "C:\Users\casho\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 908, in _invoke 
 await self.callback(ctx, **kwargs)
  File "c:\Users\casho\OneDrive\Desktop\Chores\VS Code\programs\discordpy bot\raeger.py", line 420, in em
    await ctx.respond(embed=embed)
  File "C:\Users\casho\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\context.py", line 276, in respond
    return await self.interaction.response.send_message(*args, **kwargs)  # self.response
  File "C:\Users\casho\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\interactions.py", line 727, in send_message
    await self._locked_response(
  File "C:\Users\casho\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\interactions.py", line 975, in _locked_response
    await coro
  File "C:\Users\casho\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\webhook\async_.py", line 213, in request
    raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In data.embeds.0.thumbnail.url: Scheme "yo" is not supported. Scheme must be one of ('http', 'https').
Traceback (most recent call last):
  File "C:\Users\casho\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 382, in _run_event     
    await coro(*args, **kwargs)
  File "c:\Users\casho\OneDrive\Desktop\Chores\VS Code\programs\discordpy bot\raeger.py", line 128, in on_application_command_error
_command
    await ctx.command.invoke(ctx)
  File "C:\Users\casho\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 359, in invoke
    await injected(ctx)```
rocky stump
#

How can I auto accept friend requests?

silver moat
rocky stump
rocky stump
fervent cradle
#

yup

silver moat
rocky stump
silver moat
rocky stump
fervent cradle
#

It think he meant that if someone has "Friends only"

fervent cradle
#

that only friends can dm him/her

silver moat
#

yeah there is no way around that

rocky stump
#

ahright ok

fervent cradle
#

any http / https

silver moat
#

add a debug print statement that prints the url

fervent cradle
#

no like here is what i mean

#

generally you put title and description and an optional image

#

the image has to be an http/https one to be shown in the embed

#

but if some user mistakenly put any random thing like "image.txt" then it show reply them with "Invalid image url"

#

with then rest of the embed

silver moat
#

ok so why doesn’t try except work

fervent cradle
#

yea that's the issue

silver moat
fervent cradle
#

ok

rocky stump
#

I have another question as well, my bot downloads images users have posted temporarily. At the moment the only check is that it ends in a known image extension, e.g .png, .jpeg etc. I was wondering if this is actually safe? As I don't want to download some malware disguised as an image

silver moat
rocky stump
#

I'd hope so

fervent cradle
#
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In data.embeds.0.thumbnail.url: Scheme "yo" is not supported. Scheme must be one of ('http', 'https').```
getting this error
silver moat
rocky stump
#

as this is the one I do download

silver moat
#

yeah

rocky stump
#

yeah 👍

silver moat
#

well, why not just store the url

rocky stump
#

I perform ocr on the image so I need to download it

silver moat
#

ic

rocky stump
#

yeah bummer

fervent cradle
#

what's ocr?

rocky stump
silver moat
#

also known as reading text from image

rocky stump
#

yeah

fervent cradle
#
Ignoring exception in on_application_command_error
Traceback (most recent call last):
  File "C:\Users\casho\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 127, in wrapped
    ret = await coro(arg)
  File "C:\Users\casho\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 908, in _invoke
    await self.callback(ctx, **kwargs)
  File "c:\Users\casho\OneDrive\Desktop\Chores\VS Code\programs\discordpy bot\raeger.py", line 420, in em
    await ctx.respond(embed=embed)
  File "C:\Users\casho\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\context.py", line 276, in respond
    return await self.interaction.response.send_message(*args, **kwargs)  # self.response
  File "C:\Users\casho\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\interactions.py", line 727, in send_message
    await self._locked_response(
  File "C:\Users\casho\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\interactions.py", line 975, in _locked_response
    await coro
  File "C:\Users\casho\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\webhook\async_.py", line 213, in request
    raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In data.embeds.0.thumbnail.url: Scheme "yo" is not supported. Scheme must be one of ('http', 'https').

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

#
Traceback (most recent call last):
  File "C:\Users\casho\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 382, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\casho\OneDrive\Desktop\Chores\VS Code\programs\discordpy bot\raeger.py", line 128, in on_application_command_error
    raise error
  File "C:\Users\casho\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 997, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "C:\Users\casho\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 359, in invoke
    await injected(ctx)
  File "C:\Users\casho\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 135, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In data.embeds.0.thumbnail.url: Scheme "yo" is not supported. Scheme must be one of ('http', 'https').```
fervent cradle
rocky stump
fervent cradle
#

nah I'm okay

rocky stump
#

savage

fervent cradle
#

not a professional yk

rocky stump
#

you'll get there 🙂

silver moat
#

because it seems that the error is still raised on

line 420, in em
await ctx.respond(embed=embed)

fervent cradle
#

no it is outside the block

#
    try:
        embed.set_thumbnail(url=f"{image_url}") 
    except:
        await ctx.send("Invalid image url")
        pass
    embed.set_footer(text=f"{author}",icon_url=f"{ctx.author.avatar.url}")
    await ctx.respond(embed=embed)```
silver moat
#

yeah I meant for you to put the try on the respond

#

because that's where the error is raised

fading granite
#

why does ctx.guild.members only return me and my bot?

fervent cradle
fading granite
#

you're welcome

silver moat
fading granite
#

after enabling it should i reinvite the bot

silver moat
#

no

fading granite
#

i enabled it but it still shows two members

#

my intents are coded like this

rocky stump
#

Does anyone know a way I can execute asynchronous code while the bot is still running, like as a command? (obv dev only) but python's eval() or exec() don't seem to work as they are non asynchronous

silver moat
#

also it should be passed into the parent class

rocky stump
#

I thought it was discordpy only

silver moat
#

yea

rocky stump
#

oh really

silver moat
#

it works

rocky stump
#

how's that happen then?

#

they made it compatible?

silver moat
#

It was always compatible

rocky stump
#

so discordpy and pycord cogs are compatible or they just coded jishaku in the way for that?

fading granite
#

ah

#

apparently i tried not subclassing it and it works

rocky stump
#

I think it's the best news I've ever had that jishaku works with pycord FalseFacePalmLaugh

rocky stump
fading granite
#

i think it's the only way

fervent cradle
#

can anyone give me some command ideas?

#

simple yet hooking?

agile tartan
#

My timeout isn't working on my code

#

It i says View not callable

#
'Moderation Support Bot#7400 is online!
(Ignoring exception in on_message_delete
#Traceback (most recent call last):
\  File "/usr/local/lib/python3.10/site-packages/discord/client.py", line 382, in _run_event
     await coro(*args, **kwargs)
N  File "/home/user_750844707755786252/main.py", line 52, in on_message_delete
/    await delete_mod_channel.send(embed=embed)
T  File "/usr/local/lib/python3.10/site-packages/discord/abc.py", line 1517, in send
*    data = await state.http.send_message(
W  File "/usr/local/lib/python3.10/site-packages/discord/http.py", line 359, in request
(    raise HTTPException(response, data)
Udiscord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
3In embeds.0.fields.1.value: This field is required
JSON Derulo#0184 joined
%Ignoring exception in on_member_join
#Traceback (most recent call last):
\  File "/usr/local/lib/python3.10/site-packages/discord/client.py", line 382, in _run_event
     await coro(*args, **kwargs)
L  File "/home/user_750844707755786252/main.py", line 151, in on_member_join
U    f"{staff_role.mention} Should I verify {member.mention}?", view=V(timeout=None))
)TypeError: 'View' object is not callable

cyan quail
#

it looks like you already created/initialized the view

agile tartan
#

ah

#

stupid me why didnt i notice

thorny breach
#

Hey all, I recently ditched heroku like i'm sure many other people have an switched to railway, and everything is running fine except one thing, autocomplete isn't working, I haven't touched the code at all and now it's not showing any values.

#

Any ideas what it could be

cyan quail
#

might be taking too long to respond

#

has to be < 3 seconds

thorny breach
#

I see, i guess i'll just preload the value names on boot

white wadi
#

hi, is there any way to parse like arguments while importing script or somehow determine from what script a certain file was loaded? i know this isnt exactly pycord question, if it is a problem, i can ask elsewhere

hushed ledge
#

One message removed from a suspended account.

rocky stump
#

Guys does Jishaku work with Pycord

#

I can load it in fine via load_extension, but I can't seem to invoke any of their commands

#

update: fixed with pip install jishaku==2.3.2

rocky stump
cyan quail
weak violet
#

is there a way to turn an attachment to a file object?

wooden zenith
#

i have a question

young bone
#

or if its an image you can read the bytes and write them to a file

wooden zenith
#

i want to amke a code where when i press a button a diffrent piece of code will activate any idea if its possible

weak violet
hushed ledge
wooden zenith
#

or something?

rocky stump
wooden zenith
#

yes i know that

#

but like i want it to where a model will pop up after u press the button

wooden zenith
young bone
simple canopy
#

grammar question, is it okay to write you needn't, that sounds so bad...

white wadi
# cyan quail kinda depends on what you're doing if it's an entire module, e.g. `import discor...

I divided my bot into multiple files (all of them for different commands, so i can easily setup bots for my friends adding only what they want) but i need one of those files to access something in the other, but not loading all the other code like commands, events, etc. The closes thing i found was to add if __name__ == "main":, this will prevent the part of the code to be run when the file is imported by another file. This is not a solution for me, because i need the file to be imported the main bot file. I hope you can understand what i mean 😄

cyan quail
#

like cogs?

cyan quail
white wadi
#

i have no idea what a cog is

cyan quail
#

bruh

undone smelt
#

How would I implement a user command check? A typical check involves passing the ctx, but can I also pass it the member?

cyan quail
cyan quail
undone smelt
#

I'm trying to make a check so people can't use a particular user command on themselves. Does ctx.author return whoever invoked it, or who it's invoked on?

cyan quail
#

whoever invoked it

undone smelt
#

Right. I also need who it's invoked on.

cyan quail
#

hmmm

#

is this a slash command?

undone smelt
#

Yup

white wadi
#

is there any problem with that?

cyan quail
undone smelt
cyan quail
#

pls dont use youtube tutorials

cyan quail
# white wadi is there any problem with that?

it "works", but cogs are a far cleaner way of having a multi-file setup, and your use case of getting something from another file can be done easier that way using functions like get_cog

white wadi
cyan quail
#

alright

white wadi
#

so if i get it right, i just put all the commands into a class then call it with an add cog function?

cyan quail
#

mhm

#

then in your main file, you use load_extension

white wadi
#

okay, that sounds nice

#

so if i dont use the load extension i guess i wont trigger the code when accessing something different in the same file

cyan quail
#

load_extension loads the Cog class and all commands under it to register them to the bot. If you want to access a function from another cog, you would do bot.get_cog(name) and access it through there

young ledge
#

how do i get a user that just joined the server and create a dm with them??

white wadi
#

okay, that seems exactly like the thing i need rn, thank you

cyan quail
young ledge
#

thank you :)

#

Nelo the goat fr fr

wooden zenith
#

it says somthing at most 2 argument and 3 is given

#

how to fix

cyan quail
cyan quail
wooden zenith
cyan quail
#

what was the full error?

wooden zenith
#

Exception has occurred: TypeError
module() takes at most 2 arguments (3 given)
File "C:\Users\doree\Downloads\Workspace\beatabot.py", line 12, in <module>
class menu(discord.ui.view)

cyan quail
#

use uppercase View

wooden zenith
#

nope

#

still not workin

cyan quail
#

can you copy paste the full error

wooden zenith
#

that is the full erroe

#

oh wait hold

#

on

#

now its saying that bot isnt defined

#

any idea how to fix heres full code

young ledge
cyan quail
young ledge
#
@client.event
async def on_member_join(member):
    member.send("test")
#

am new to this so idk if this is wrong

cyan quail
young bone
#

and dont forget to enable intents

young ledge
#

Still doesnt work @cyan quail

cyan quail
young ledge
#

I do not think so how do i do it?

cyan quail
#

?tag intents

obtuse juncoBOT
#

https://docs.pycord.dev/en/master/intents.html
https://discord.com/developers/docs/topics/gateway#gateway-intents

import discord
from discord.ext import commands

# Get specific intents for fine control
intents = discord.Intents()
intents.emojis = True
intents.guilds = True
intents.messages = True  # Required for prefix commands!
...
# Get all non-priveliged intents; this excludes presences, members and message_content 
intents = discord.Intents.default()

# Set priveliged intents: these must be enabled on dev portal
intents.members = True
intents.presences = True
intents.message_content = True  # Required for prefix commands >= 2.0.0b5

# Get all intents; all intents must be enabled on dev portal.
intents = discord.Intents.all()

# Apply intents when creating your bot
bot = commands.bot(prefix="?", intents=intents)
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.

young ledge
#

thx

cyan quail
#

basically you want intents = discord.Intents.default(), then set intents.members = True and finally pass intents=intents into your bot object

fervent cradle
#

How do i use a float for a argument in a slashcommand

cyan quail
fervent cradle
#

type(float)

#

like thta?

cyan quail
#

how do you normally do types

fervent cradle
#

like that....

cyan quail
#

for slash command options

fervent cradle
#

i have no clue

#

thats why im asking

cyan quail
#

fair enough, you just typehint the variable like name: type

fervent cradle
#

Thanks

young bone
#

that is basic python...

fervent cradle
fervent cradle
cyan quail
#

right

indigo badger
#

For some reason it is not popping up the right status and I am not sure why.

#

If anyone knows and could tell me why that would be great.

simple canopy
#

you probably don't have presence intent enabled

indigo badger
#

That is the thing.

errant craneBOT
#
:class:`Status`: The member's status on the desktop client, if applicable.```
simple canopy
#

its for me, ignore ^

simple canopy
lean marten
#

Why am I keep getting this error?

@bot.event
async def on_message(message):
    try:
        guildProfile = guildCollection.find_one({"_id":message.guild.id})
        profile = collection.find_one({"_id":"settings"})
        if guildProfile is None:
            newguild = {"_id":message.guild.id, "gtn_channel":"", "gtn_number":"", "gtn_guesses":0, "gtn_range":0, "advertising_channel":"", "messages_total":0}
            guildCollection.insert_one(newguild)

        guild_total_messages = guildProfile["messages_total"] + 1
        guildCollection.update_one({"_id":message.guild.id}, {"$set": {"messages_total":guild_total_messages}})

        if "gtn_channel" in guildProfile:
            if guildProfile["gtn_channel"] != "":
                if message.channel.id != guildProfile["gtn_channel"]:
                    return
                else:
                    try:
                        if int(message.content) == guildProfile["gtn_number"]:
                            guesses = guildProfile["gtn_guesses"] + 1
                            guildCollection.update_one({"_id":message.guild.id}, {"$set": {"gtn_guesses":guesses}})
                            embed = discord.Embed(title=f":tada: Congratulations {message.author.name}!", description=f"The number you guessed was right! The game has ended and the channel has been locked, thanks for playing!", color=0x2f3136)
//embed send etc. here

                        else:
                            guesses = guildProfile["gtn_guesses"] + 1
                            guildCollection.update_one({"_id":message.guild.id}, {"$set": {"gtn_guesses":guesses}})
                    except Exception as e:
                        if message.author.bot:
                            return
                        else:
                            await message.delete()
    except Exception as e:
        await notusLog("Automated Error/bug report.", f'{e} - Ignore the error.')
simple canopy
#

try print()ing this out tho

#

@indigo badger

simple canopy
#

you did, my bad

#

what does it says in console

lean marten
full basin
#

No

#

That's just the error

cyan quail
lean marten
cyan quail
#

member statuses recieved over interactions are always offline for some reason

cyan quail
#

maybe try getting the member object again with ctx.guild.get_member

lean marten
full basin
#

I'm asking for the traceback

cyan quail
#

they're try-excepting so they don't have a traceback apensive

lean marten
#

yea

simple canopy
#

i hate when people TRY/EXCEPTING everything

#

😔

cyan quail
#

anyway we can't really help you properly without it lol

#

you can only guess what the issue is

lean marten
#

alr wait..

#

there you go

cyan quail
#

so message.guild is none

lean marten
#

yea but why

cyan quail
#

guild isn't cached or the message is in dms GuraShrug

lean marten
#

not in dms

#

what do you mean with isnt cached?

cyan quail
#

well it literally isn't in the bot's cache

lean marten
#

and how can I fix this

cyan quail
#

what intents did you set

lean marten
#

all of them

cyan quail
#

does it break in other guilds?

lean marten
#

it gets spammed in the log

#

I had it before and it didnt send an error

#

but now it does

indigo badger
#

Especially when they’re trying to get all developers to switch to slash command.

lean marten
#

I mean it works but I still get the error

#

thats the weird thing

cyan quail
#

it still works?

lean marten
#

yea ig so, everything works fine

cyan quail
#

like, the rest of the code after that line runs?

lean marten
#

yea

cyan quail
#

uhhhhhhh

lean marten
#

It gets the data from the db

#

everything

indigo badger
#

Also I tryed my prefix one of that and it worked but with slash it does not.

cyan quail
#

are you sure the error message itself isn't bugged

lean marten
#

uh yea

#

ig

cyan quail
lean marten
#

would that even be possible?

cyan quail
#

potentially

#

hmm

indigo badger
lean marten
#

Maybe just because the document wasnt created for some guilds

#

nope

#

still getting it as soon as I run the command..

#

everything works fine tho

indigo badger
cyan quail
#

im guessing you have process_commands there at the end?

cyan quail
#

yeah

lean marten
#

Were at the end

cyan quail
#

of the message event

lean marten
#

no

cyan quail
#

oh wait i see it isn't a message command

lean marten
#
@bot.event
async def on_message(message):
    try:
        guildProfile = guildCollection.find_one({"_id":message.guild.id})
        if guildProfile is None:
            newguild = {"_id":message.guild.id, "gtn_channel":"", "gtn_number":"", "gtn_guesses":0, "gtn_range":0, "advertising_channel":"", "ticket_category":"", "autorole":"", "joindm":"", "joinping":"", "giveaway_manager":"", "ticket_manager":"", "event_manager":"", "music_manager":"", "messages_total":0}
            guildCollection.insert_one(newguild)

        guild_total_messages = guildProfile["messages_total"] + 1
        guildCollection.update_one({"_id":message.guild.id}, {"$set": {"messages_total":guild_total_messages}})

        if "gtn_channel" in guildProfile:
            if guildProfile["gtn_channel"] != "":
                if message.channel.id != guildProfile["gtn_channel"]:
                    return
                else:
                    try:
                        if int(message.content) == guildProfile["gtn_number"]:
                            guesses = guildProfile["gtn_guesses"] + 1
                            guildCollection.update_one({"_id":message.guild.id}, {"$set": {"gtn_guesses":guesses}})


                        elif int(message.content) > guildProfile["gtn_range"]:
                            if message.author.bot:
                                return
                            else:
                                await message.delete()
                        else:
                            guesses = guildProfile["gtn_guesses"] + 1
                            guildCollection.update_one({"_id":message.guild.id}, {"$set": {"gtn_guesses":guesses}})
                    except Exception as e:
                        if message.author.bot:
                            return
                        else:
                            await message.delete()
    except Exception as e:
        await notusLog("Automated Error/bug report.", f'{e} - Ignore the error.')```
#

thats the whole thing excluding the embed and some collection updates

cyan quail
#

idk you should probably try to make the error more descriptive/format it with traceback instead of just letting it be a single line

lean marten
#

how can I do that?

cyan quail
#

perhaps include e.__traceback__ in the message

cyan quail
indigo badger
cyan quail
#

nono

indigo badger
#

So I would have to add the (id ) to that?

cyan quail
#

id being the id of the member

indigo badger
#

Oh because that is what member thing reads?

cyan quail
#

mhm

lean marten
#

if it still works

#

is there a way to just ignore the error?

cyan quail
#

pass

cyan quail
indigo badger
cyan quail
#

yeah but show

#

ah oh well, i usually try to be indirect but it's ctx.guild.get_member(ctx.author.id)

#

probably the easiest way to get around the bug

indigo badger
cyan quail
#

and member is optional?

indigo badger
#

Yes.

#

Should I try it differently?

cyan quail
#

hmmm

#

could you un-indent the last line so it always prints?

indigo badger
cyan quail
#

hmmm it should be working fine since the cache has the correct status

indigo badger
#

I know.

#

I asked Bob in the main chat if he knows.

#

But not sure if he knows.

lean marten
#

class gtnInviteVoteButtons(discord.ui.View):
    def __init__(self):
        super().__init__(timeout=None)

    @discord.ui.button(label="Invite", custom_id="gtnInviteBtn", style=discord.ButtonStyle.link, url="https://discord.com/api/oauth2/authorize?client_id=850494888155938826&permissions=1644971818199&scope=applications.commands%20bot")
    async def button_callback(self, button, interaction):
        pass
    @discord.ui.button(label="Vote", custom_id="gtnVoteTopggBtn", style=discord.ButtonStyle.link, url="https://top.gg/bot/850494888155938826/vote")
    async def button_callback(self, button, interaction):
        pass
#

why does it not work

rare ice
cyan quail
#

you should create them inside the init with discord.ui.Button and then use self.add_item

lean marten
#

I did it like the pycord guide said

cyan quail
#

the guide does include decorator buttons, but not for urls

lean marten
#

ah alr

#

I'll try that ty

fiery tiger
#

how can i fix whitespaces?

fervent cradle
#

How can I create a check on an interaction (buttons) to be only me allowed to press the buttons?

fiery tiger
#

if its not then return an error...

fervent cradle
#

true

#

im dumb asf

fiery tiger
#

you can check it by ur id..

fervent cradle
#

yy

#

thx

fiery tiger
#

np

fiery tiger
fervent cradle
#

and how can I create pre defined options to specific argument?

rare ice
#

let me find it in the guide

fiery tiger
rare ice
fervent cradle
#

remove the whitespace between i and :

rare ice
#

@fiery tiger try removing the spaces between the semicolon

fiery tiger
#

black format won't let me do that...

fervent cradle
young bone
#

In a slash command?

fervent cradle
young bone
#

name: Option(str, choices=[])

fervent cradle
#

understood

rare ice
fervent cradle
#

docs has examples

rare ice
#

I feel like that should be in the guide

#

time to make a pr

#

Oh wait nvm you mean options in general

lean marten
#

how can i use usual emojis like 🔒 in buttons?

simple canopy
#

use unicode characters they represent

#

\🔒

lean marten
#

how do I find them?

simple canopy
#

type in regular emoji, and add \ before it

#

so like \:emoji:

lean marten
#

ik that doesnt work

#

or wait

simple canopy
#

uh, you need to do it in discord, or copy them from some website

#

or just use window's builtin tool

#

then you specify them as a string

#

emoji='emoji'

lean marten
#

ik

#

like that or with
< >

simple canopy
#

😔

lean marten
#

😭

simple canopy
#

copy from here and paste

lean marten
#

I tried that lmao

simple canopy
#

this SHOULD work

lean marten
#

im not stupid... 😦

simple canopy
#

unless specific emoji is not represented in Twemoji

lean marten
#

thats what I tried

simple canopy
#

💀 i mean, i use that

#

why the fuck this doesn't work

lean marten
#

hm..

#

😭

simple canopy
#

should work

#

try at least :/

lean marten
#

nvm

#

It worked ._.

simple canopy
lean marten
#

I'm stupid anyways.. lmao

#

it was set to the other thingy

#

ty

simple canopy
#

👍🏻

wooden zenith
#

How do I get a modal through button press

wooden zenith
#

@rare ice do I put that instead of the button response?

rare ice
#

You do that in the callback

#

You have to have an interaction to respond to.

fading granite
#

i just started learning pymongo

simple canopy
#

cool

fading granite
#

My command says I successfully updated the values in my database

#

But somehow when I try to get the data, there is no data

rare ice
#

And any errors you got, if any.

lean marten
#

Is it possible to add objects to a document? (pymongo)
e.g.

links: {

  "youtube":"https://yt.com"
  "my discord":"https://dsc.gg/mydiscord"
  "my twitter":"https://t.co/mytwitter"

}
fading granite
undone smelt
#

I have the following cooldown on my command, but it's not applying. Is it because I'm an admin in the server, or am I missing something?

    @commands.cooldown(1, 60, type=commands.BucketType.user)
    @user_command(name=":punch: Mug")
    async def mug(self, ctx: discord.ApplicationContext, member: discord.Member):
      ...
fervent cradle
#

why is one of my slashcommands just not showing up

rare ice
obtuse juncoBOT
#

Saying it doesn't work or asking what's wrong with this code? is not helpful for yourself or others.
Describe what you expect and/or tried (with your code), and what isn't going right.
Please provide any errors you get for optimal assistance.

wanton pondBOT
#

⚠ Warned Hiddenvelix#9007

rare ice
waxen whale
#

good idea

#

7 days help block love

undone smelt
scenic elbow
#

i need help on my railway, how do i install modules there

silver moat
#

what's your requirements.txt and errors

scenic elbow
undone smelt
#

f"{ctx.command.get_cooldown_retry_after}s remaining" sends <bound method ApplicationCommand.get_cooldown_retry_after of <discord.commands.UserCommand name=:punch: Mug>>s remaining

scenic elbow
#

@silver moat i added the requrement file i ahve the error Error: Docker build failed

fervent cradle
#

General Question: If i hade a base price lets say 1 UDT is 5$ how could i calculate how much in USD the user has off of the base price like if i hade 0.5 bitcoin or 0.1 bitcoin and i wanted to get the price of the 0.1 bitcoin using what 1 bitcoin would be i know its some complex math im not sure how i would go about it

silver moat
fervent cradle
#

How would i do that using math module in python

#

Ik the problem

silver moat
silver moat
scenic elbow
#

ah wait i see it now

#

what do i put in it

silver moat
silver moat
fervent cradle
#

yes i have the rate data

#

Kk thanks

rugged lantern
#

third grade math really is complex

scenic elbow
#

can railway still see it

#

i dontwant poeple havign my bot otken

silver moat
#

but use environment variables for your bot token

scenic elbow
silver moat
#

also regen your token

scenic elbow
#

i did

silver moat
#

because your token was leaked lol

silver moat
scenic elbow
#

so do i just change the run into client.run(token)?

errant craneBOT
#

bot/main.py lines 834 to 835

bot.run(
    os.environ.get("BOTTOKEN"),```
silver moat
#

import os

scenic elbow
#

i ahve os imported

silver moat
#

well "token" in your case

scenic elbow
#

yes ik

scenic elbow
#

is this correct

silver moat
#

missing a closing parentheses

scenic elbow
#

cogs didnt load

silver moat
#

what's your requirements.txt?

scenic elbow
#

only 1

#

discord

#

when i did the commands from the sirteu gave

silver moat
#

it should be py-cord

scenic elbow
#

i followede verything but i only got 1 line

#

i updated the file, it should now

#

i think

#

@silver moat still no work :(

silver moat
#

huh. Same error?

scenic elbow
#

wait i think i missed one

fervent cradle
#

@silver moat

    def _convert(rate, amount_of_btc):
    #   assuming rate is what 1 BTC is in USD
        return rate/amount_of_btc*rate #usd
    conversion = _convert(PriceOrRate, token_count)
    return conversion

_convert(0.06147591247046411, 1) <- 0.06 is the price for 1 trx (tron) coin, and the 1 stands for the amount, so why is it returning 0.003779287814076165

scenic elbow
#

yep still nothing

silver moat
scenic elbow
#

these are the only imports i got before

fervent cradle
#

thanks man

silver moat
#

there might be something that I am overlooking

scenic elbow
fervent cradle
#

thanks squid

silver moat
silver moat
silver moat
#

yes

scenic elbow
#

OGM ITS WOKRING @silver moat

#

let me tets the commands

#

THANKKK YOU BROOO @silver moat

silver moat
#

you're welcome

fierce elm
#

anyone got ideas on how to keep state between a select -> modal -> database?
person selects an item from a select list, select list opens a modal, with the title being the item they selected, but how to get the item to the database with the textinput from the modal at the same time is escaping me

silver moat
fierce elm
#

i'm trying to get the value from the select

#

to add into the database object

#

I mean I can either add a check for extra_kwargs in the modal object, or set a disabled(hopefully) inputtext

silver moat
fierce elm
#

then check for kwargs it is

silver moat
#

gl

#

or do you need help on that?

fierce elm
#

possibly, copilot says to do
extra_kwargs = kwargs.pop("extra_kwargs", {})

fervent cradle
#

Do you need an indent to check if the bot got mentioned?

silver moat
fervent cradle
#

like the bot user is mentioned

silver moat
#

I meant the indent

fervent cradle
#

because I'm trying to make an indent-less bot

silver moat
#

what is an indent in this context?

prisma flicker
#

Do you mean intent?

silver moat
fervent cradle
#

Are ephemeral messages available outside interactions or webhooks?

silver moat
fervent cradle
stiff fiber
#

Hi, I'm trying to create a 5x5 array of buttons, controlled by a view - but for some reason, the buttons aren't changing colour (I want them to toggle between green/red).

silver moat
silver moat
stiff fiber
silver moat
#

yes

stiff fiber
#

Got it, thanks!

silver moat
#

yw

tiny wagon
# rocky stump I perform ocr on the image so I need to download it

just why download the image, thats bad practice, just fetch the image url, convert it into buffer by BytesIO, and then OCR, many ocr engines support numpy array or base64 encoded image as input, you can just convert the bytes buffer to numpy array or base64 encoded image

rocky stump
night warren
#

Hi is there an event such as on_server_boost?

#

I looked through the docs but I couldn't find anything

round rivet
#

No

fervent cradle
#

i've got this error

AttributeError: partially initialized module 'tolkit.ui' has no attribute 'Verify' (most likely due to a circular import)

how can i fix it?

#

is there a way to specify user avatar size?

#

like in dpy user.avatar_url_as(size= 128)

fervent cradle
#

so how sould I write it?

young bone
fervent cradle
#

did

#

but understood half of the total thing

#

I am kinda stupid..So uh please help

young bone
fervent cradle
#

oh nvm I almost did the correct thing lmao

tiny wagon
#

hi i am making buttons using subclassed way. For url buttons, do i need to add a callback??

fervent cradle
#

i don't think so

#

how can I wait for the ctx.author's response

#

?

tiny wagon
tiny wagon
#

and when i try at add it in init, an error appears that got an unexpected kwarg: label

cyan quail
cyan quail
silver moat
#

oh right, there’s a 2.1.3

cyan quail
#

if the issue was slash groups then yeah it'll have been fixed

tiny wagon
#

discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: __init__() got an unexpected keyword argument 'label'

cyan quail
#

well rc1 works fine enough

#

hm

cyan quail
#

you can definitely call discord.ui.Button with label

tiny wagon
#

error:

Ignoring exception in command helpme:
Traceback (most recent call last):
  File "", line 127, in wrapped
    ret = await coro(arg)
  File "", line 904, in _invoke
    await self.callback(self.cog, ctx, **kwargs)
  File "", line 36, in helpme
    await ctx.respond(embed=embed, view=HelpButtons(self.bot))
  File "", line 43, in __init__
    self.add_item(Button(label='Invite Me', style=discord.ButtonStyle.url,
TypeError: __init__() got an unexpected keyword argument 'label'

#

the way is correct of adding url buttons?

cyan quail
#

yeah... that error's weird because it should be referencing Button.__init__() and not just __init__()

#

what version?

tiny wagon
#

w8

#

2.1.0 or 2.1.1

#

lemme confirm

cyan quail
#

can you try upgrading to 2.1.3

tiny wagon
#

2.1.1

#

hmm ok, is it on pip?

cyan quail
#

yeah it's a release version

tiny wagon
#

nop

#

same error

cyan quail
#

do you by any chance have a class or function called Button

tiny wagon
#

in the cog, just 2 classes, Help and HelpButtons

fervent cradle
#
rpsg = discord.SlashCommandGroup("rps", "Commands related to Rock-Paper-Scissors!")

@rpsg.command(name="play", description="Play Rock-Paper-Scissors!!",guild_ids=[949883077738496040, 831508434872565762, 970977973039685673])```
#

What am I doing wrong here

#

The command doesn't show up on discord

cyan quail
#

the only way for this error to be possible is if you've overridden the Button class in your code somewhere

fervent cradle
#

ok

tiny wagon
#

nah, i dont see any conflict in file

  • if you remove those 3 lines in init , it works fine
cyan quail
#

right there

tiny wagon
#

oh w8

#

are those 2 different?

cyan quail
#

yes

#

remove the 2nd one

tiny wagon
#

ok

cyan quail
#

well ButtonStyle is fine, but not Button

#

...i guess it's misleading but all examples and guides do use discord.ui

tiny wagon
#

lol there is again a pblm

#

if i remove first one, same error

#

if i remove second one, some other error

fervent cradle
cyan quail
silver moat
cyan quail
#

You don't need it usually

fervent cradle
#
rpsg = discord.SlashCommandGroup("rps", "Commands related to Rock-Paper-Scissors!")

@rpsg.command(name="play", description="Play Rock-Paper-Scissors!!",guild_ids=[949883077738496040, 831508434872565762, 970977973039685673])
async def play(ctx, text):
    await ctx.respond("something")```
silver moat
tiny wagon
#

pass guild_ids in SlashCommandGroup

cyan quail
#

It works fine without in cogs, not sure elsewhere

fervent cradle
#

is bot.create_group better than this?

tiny wagon
fervent cradle
#

better way*

cyan quail
#

Go for it

fervent cradle
#

k

#
rpsg = bot.create_group("rps", "Commands related to Rock-Paper-Scissors!")

@rpsg.command(name="play", description="Play Rock-Paper-Scissors!!",guild_ids=[949883077738496040, 831508434872565762, 970977973039685673])
async def play(ctx, text):
    await ctx.respond("something")```
#

now okay?

#

i've got this error

AttributeError: partially initialized module 'tolkit.ui' has no attribute 'Verify' (most likely due to a circular import)

how can i fix it?

tiny wagon
#

oof

tiny wagon
#

so basically when i keep the discord.ui.Button, same error @cyan quail

cyan quail
tiny wagon
#
Ignoring exception in command helpme:
Traceback (most recent call last):
  File "C:\Users\Rajesh Gulati\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\commands\core.py", line 127, in wrapped
    ret = await coro(arg)
  File "C:\Users\Rajesh Gulati\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\commands\core.py", line 907, in _invoke
    await self.callback(self.cog, ctx, **kwargs)
  File "C:\Users\Rajesh Gulati\PycharmProjects\Discord\cogs\help_command.py", line 36, in helpme
    await ctx.respond(embed=embed, view=HelpButtons(self.bot))
  File "C:\Users\Rajesh Gulati\PycharmProjects\Discord\cogs\help_command.py", line 43, in __init__
    self.add_item(Button(label='Invite Me', style=discord.ButtonStyle.url,
  File "C:\Users\Rajesh Gulati\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ui\view.py", line 283, in add_item
    if len(self.children) > 25:
AttributeError: 'HelpButtons' object has no attribute 'children'

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

Traceback (most recent call last):
  File "C:\Users\Rajesh Gulati\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\bot.py", line 1009, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "C:\Users\Rajesh Gulati\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\commands\core.py", line 359, in invoke
    await injected(ctx)
  File "C:\Users\Rajesh Gulati\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\commands\core.py", line 135, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'HelpButtons' object has no attribute 'children'

fervent cradle
tiny wagon
fervent cradle
#

ok

cyan quail
fervent cradle
#

yup[

#

i did

cyan quail
#

you didn't because that exact error was fixed in 2.1.3

silver moat
#

pycharm?

jovial shoal
#

how would I prevent users from using a slash command while the same slash command is still "thinking"?

#

do cooldowns register from start of use?

cyan quail
fervent cradle
cyan quail
silver moat
#

or venv

tiny wagon
#

@cyan quail ohk thankx, i removed the super class call b4 for some trial error testing, now its working

fervent cradle
tiny wagon
#

in docs its written, custom_id is optional + my buttons are not persistent and i didnt specify any timout which defaults 180 ig

young bone
#

looks like you still have to add some custom ids

fervent cradle
#
rpsg = bot.create_group("rps", "Commands related to Rock-Paper-Scissors!")

@rpsg.command(name="play", description="Play Rock-Paper-Scissors!!",guild_ids=[949883077738496040, 831508434872565762, 970977973039685673])
async def play(ctx, text):
    await ctx.respond("something")```
#

this still doesn't work

errant craneBOT
#

Saying it doesn't work or asking what's wrong with this code? is not helpful for yourself or others.
Describe what you expect and/or tried (with your code), and what isn't going right.
Please provide any errors you get for optimal assistance.

fervent cradle
#

ok

#

So the thing is- I created a group "rpsg" to make all the commands related to rock-paper-scissors under one group

#

when i try the play command it shows up in the menu as expected

#

but it never responds and I get a error

grizzled sentinel
#

What error?
The one is discord that says. Application did not respond?

fervent cradle
#

and yes i already updated py-cord to 2.1.3

grizzled sentinel
#

Can you send the last few lines. Of the error I'm on mobile and cannot see files

fervent cradle
#

Tried various ways but no difference 😦

grizzled sentinel
#

Could you try uninstalling and reinstalling. If that does not work I think you are installing it in the wrong place

#

I gtg someone else will help in a bit

fervent cradle
#

k

fervent cradle
#

still getting the same error over and over again

#

I uninstalled and reinstalled but no good

fervent cradle
#

and now the commands which wer working before don't work aswell

undone smelt
#

f"{ctx.command.get_cooldown_retry_after}s remaining" sends <bound method ApplicationCommand.get_cooldown_retry_after of <discord.commands.UserCommand name=:punch: Mug>>s remaining

Any ideas?

manic spoke
#

hello

#

i am having problems using variables in other class when trying to create buttons and modals

fervent cradle
#

Uh why are the commands taking longer than usual to execute?

fossil canopy
#

`import discord
import json
from discord import app_commands
from discord.ext import commands
import base64

class Blacklist(commands.Cog):

def __init__(self, bot):
    self.bot = bot

@app_commands.command()
async def test(self, interaction : discord.Interaction):
    await interaction.response.send_message("test")

async def setup(bot):
await bot.add_cog(Blacklist(bot))`

The app_command isn't showing, anyone knows why?

proud pagoda
#

Pycord doesn't have an app_command namespace

fossil canopy
#

Traceback (most recent call last):
File "c:\Users\Anwender\Desktop\workspace python-kurs\bots\Buisness\babycode5K\src\cogs\blacklist.py", line 8, in <module>
class Blacklist(commands.Cog):
File "c:\Users\Anwender\Desktop\workspace python-kurs\bots\Buisness\babycode5K\src\cogs\blacklist.py", line 13, in Blacklist
@discord.slash_command()
AttributeError: module 'discord' has no attribute 'slash_command'

proud pagoda
#

Send tej contents of pip list @fossil canopy

fossil canopy
#

cachetools 5.2.0
certifi 2021.10.8
cffi 1.15.0
chardet 4.0.0
charset-normalizer 2.1.1
click 8.0.3
colorama 0.4.4
commonmark 0.9.1
comtypes 1.1.11
cryptography 36.0.2
customtkinter 4.5.4
cycler 0.11.0
darkdetect 0.6.0
DateTime 4.3
discord 2.0.0
discord-components 2.1.2
discord-ext-ipc 2.1.1
discord.py 2.0.1
discord-py-interactions 4.3.1
discord-py-slash-command 4.2.1
discord-ui 5.1.6
discord-webhook 0.16.3
DiscordUtils 1.3.4
distlib 0.3.4
Eel 0.12.4
fastenum 1.0.4
filelock 3.6.0
Flask 2.0.2
Flask-Cors 3.0.10
Flask-JSGlue 0.3.1
flatbuffers 1.12
fonttools 4.33.3
frozenlist 1.3.1
future 0.18.2
gast 0.4.0
germanetpy 0.2.2
gevent 21.8.0
gevent-websocket 0.10.1
google-auth 2.8.0
google-auth-oauthlib 0.4.6
google-pasta 0.2.0
greenlet 1.1.2
grpcio 1.47.0
h11 0.13.0
h2 4.1.0
h5py 3.7.0
holidaycal 0.0.1
hpack 4.0.0
html2image 2.0.1
htmlwebshot 0.1.2
hypercorn 0.13.2
hyperframe 6.0.1
idna 3.3
importlib-metadata 4.11.4
iniconfig 1.1.1
itsdangerous 2.0.1
jarowinkler 1.0.2
Jinja2 3.0.3
joblib 1.1.0
Js2Py 0.71
keras 2.9.0
Keras-Preprocessing 1.1.2
keyboard 0.13.5
kiwisolver 1.4.2
libclang 14.0.1
lxml 4.9.1
Markdown 3.3.7
MarkupSafe 2.1.1
matplotlib 3.5.2
mcpi 1.2.1
mindstorms 0.1.2
MouseInfo 0.1.3
multidict 6.0.2
mutagen 1.45.1
mysql-connector-python 8.0.29
nltk 3.7
numpy 1.22.1
oauthlib 3.2.0
opencv-python 4.5.5.64
opt-einsum 3.3.0
outcome 1.2.0
packaging 21.3
pandas 1.4.0
paramiko 2.10.3
peewee 3.15.1
pefile 2021.9.3
Pillow 9.0.1
pip 22.2.2
platformdirs 2.5.1
playsound 1.3.0
pluggy 1.0.0
priority 2.0.0
profanity-check 1.0.3
protobuf 3.19.4
py 1.11.0
py-cord 2.0.0b5
pyasn1 0.4.8
pyasn1-modules 0.2.8
PyAutoGUI 0.9.53
pybricks 3.1.0
pycodestyle 2.8.0
pycparser 2.21
pycryptodomex 3.14.1
pyee 8.2.2
pygame 2.1.0
PyGetWindow

tiny wagon
#

?tag install

obtuse juncoBOT
#
  1. Uninstall discord.py or any other forks of discord.py you might have with the namespace discord.
    python -m pip uninstall discord.py discord -y

2a. Install py-cord
python -m pip install py-cord

2b. Update py-cord
python pip install -U py-cord

Installing other builds:
Note: You need to have git installed. Use !git to find out how to install git.

Updating the module to Alpha (unstable):
pip install -U git+https://github.com/Pycord-Development/pycord

tiny wagon
#

Uninstall all packages starting with discord, if dont want to, make a venv

manic spoke
#

How do i handle errors inside MODAL

#

pls help

fervent cradle
#

i’m currently getting this error:
TypeError: TypedDict does not support instance and class checks
I found this report but i’m not sure how i fix the error: https://bugs.python.org/issue44919

rocky stump
#

How can I get this?

solid agate
#

Can someone tell me if I'm just making shit up, or if this should work?

#

I have a discord.ui.Select, with a secondary parameter, that adds it to the self.

self.message

when in the callback, this self.message is always NONE, eventhough I know it's set correctly prior to the callback 🤔

#

Isn't that how it's supposed to work? That you can set custom properties?

proud pagoda
hushed ledge
#

One message removed from a suspended account.

round rivet
#

there should be an after parameter in history

prisma flicker
hushed ledge
full basin
#

Compare ID'S? Isn't that an option

hushed ledge
#

One message removed from a suspended account.

undone smelt
#

do tasks not fire once at init then repeat at specified duration? or does it only fire for the first after the specified duration?

#
import random

import discord
from discord.ext import commands, tasks
from goonbot import GoonBot

LISTENING_TO = [
    ...
]

PLAYING = [
    ...
]

WATCHING = [
    ...
]


class Activities(commands.Cog, name="Activities"):
    def __init__(self, bot: GoonBot):
        self.bot = bot
        self.set_activity.start()

    def cog_unload(self):
        self.set_activity.cancel()

    @tasks.loop(minutes=15)
    async def set_activity(self):
        self.bot.activity = random.choice(
            [
                discord.Activity(type=discord.ActivityType.playing, name=random.choice(PLAYING)),
                discord.Activity(type=discord.ActivityType.listening, name=random.choice(LISTENING_TO)),
                discord.Activity(type=discord.ActivityType.watching, name=random.choice(WATCHING)),
            ]
        )

    @set_activity.before_loop
    async def before_set_activity(self):
        await self.bot.wait_until_ready()


def setup(bot):
    bot.add_cog(Activities(bot))
full basin
#

You have to start it

undone smelt
#

I even tried moving the activity logic into the init, and that worked just fine. Just not as a task

fervent cradle
#

Question is there slash command alias,

silver moat
fervent cradle
#

thats depressing

silver moat
#

did you mean discord.ext.commands.BucketType

undone smelt
#

TYSM

rare ice
#

Is there a limit of auto complete options you can have? If so, what’s the limit?

silver moat
#

and also that 3 second to respond limit

rare ice
silver moat
#

Random Access Memory

rare ice
#

Oh you mean system memory

#

I thought there was a limit with the api

#

Like 1,000 or so

silver moat
#

and you process the selection

rare ice
#

Ah

fervent cradle
#

hey

#

I want to send a image

#

as a response

#
await ctx.respond(file= discord.File("profile.jpg"))
#

is something wrong?

somber cloak
#

i can't seem to get the right keywords on google for this so --

is there a common/good way to do typehints for classes that are defined after that particular function/method in the code? e.g. if i did

class A:
    def foo(self, b:B):
        ...

class B:
    ...

then pylint complains that B is not defined in the typehint.

for this example i know i could move the code of B to come before that of A, but in a case where there are circular dependencies that wouldn't work

pseudo glen
#

we supported sub command?

#

like:

#

/... ...

round rivet
#

yes

pseudo glen
#

example?

copper dew
fervent cradle
spice oyster
#

Hello! I have a subclass View with 3 buttons and a custom method to handle clicks. When the third button is clicked, I want to disable it. How should I approach this problem? rooThink

Done! I couldn't find it before asking but now I managed to. Your guide and docs are amazing. rooDuck

pseudo glen
#

ty guys

fervent cradle
fervent cradle
#

can someone help me?
AttributeError: 'User' object has no attribute 'username'
Code:

@bot.event
async def on_user_update(before, after):
    guild = bot.get_guild(1014092119746543727)
    role = guild.get_role(1015255000391356416)
    #channelx = bot.get_channel(logschannel)

    if name6_keyword in str(after.username) and not role in before.roles:
             try: await after.add_roles(role)
             except: print(f'Try to give {after.username} role, but fail')
             #embedVar = discord.Embed(title="Status Added", description=f'{after.username} added the status and got the role `{role}`', color=0x00ff00)
             #await channelx.send(embed=embedVar)
    elif name6_keyword not in str(after.username) and role in before.roles:
             try: await after.remove_roles(role)
             except: print(f'Try to give {after.username} role, but fail')
             #embedVar2 = discord.Embed(title="Status Removed or Offline", description=f'`{role}` revoked from {after.username}', color=0xFF0000)
             #await channelx.send(embed=embedVar2)

pseudo glen
#

User object

fervent cradle
#

oh

pseudo glen
#

try it

#

y

#

i think

fervent cradle
#

Hello there!
I have a question regarding docs:

colors = ["yellow", "red"]
async def get_colors(ctx: discord.AutocompleteContext):
    return [color for color in colors if color.startswith(ctx.value.lower())]

@bot.slash_command(name="ac_example")
@option("color", description="Pick a color!", autocomplete=get_colors)
async def autocomplete_example(ctx: discord.ApplicationContext, color: str,):
    await ctx.respond(f"hi{color}")```
so according to the docs to create auto complete option we first create the list
#

but if I put the list directly into the "autocomplete" argument the options never appear

#

I have to create a whole function like:

async def get_colors(ctx: discord.AutocompleteContext):
    return [color for color in colors if color.startswith(ctx.value.lower())]```
For the options to apppear and I am not able to figure out why
#

any help would be appreciated

topaz rune
#
for el in role_list:
        salon_vocal.set_permissions(el, view_channel=True,
                                        connect = True,
                                        speak = False)

does someone have an idea on why it dont set the permissions?

vivid plaza
woeful spindle
#

Think I found a fix.

signal hare
#

Hello, good afternoon.

#

Been trying to get back into a bot i was making for my clan/community. To deal with recruits and have a voting system. A lot of was already working, but i was updating to newer versions and had to re-do some stuff. Then i noticed there were modals in this newer version, sweet! Been working with a test slash command to get it working, which went alright. Took 2 days to get it down but that test command is working.

But now i'm facing a challenge i can't get my head arround. I have a on_raw_reaction_add that takes payload and nothing else, but i've been working with ctx.interaction.resonse.send_modal for the other modal(s). How do i go about this?

full basin
signal hare
#

Uh, i thought that was possible? That you could put a modal up when someone reacts with an emjoi? 🤭

#

So modals are limited to the slash commands?

#

Or rather interactions?

full basin
#

Interactions.

#

You could use a button instead?

signal hare
#

What do you mean? Instead of having reactions underneath my "poll", add buttons for the votes?

#

Ah found an example

dreamy raft
#

Can you send a message after interaction response has been deferred?

await interaction.response.defer()
then
await interaction.response.send_message(...)

proud pagoda
dreamy raft
#

ah, thanks

smoky forge
#

I'm getting this exception when creating a select menu. It reads as follows

Traceback (most recent call last):
  File "e:\Documents\GitHub\wooperbot\env\lib\site-packages\discord\client.py", line 382, in _run_event
    await coro(*args, **kwargs)
  File "E:\Documents\GitHub\wooperbot\classes\bot.py", line 209, in on_application_command_error
    return await ctx.invoke(ctx.command, **options)
  File "e:\Documents\GitHub\wooperbot\env\lib\site-packages\discord\commands\context.py", line 137, in invoke
    return await command(self, *args, **kwargs)
  File "e:\Documents\GitHub\wooperbot\env\lib\site-packages\discord\commands\core.py", line 237, in __call__
    return await self.callback(self.cog, ctx, *args, **kwargs)
  File "E:\Documents\GitHub\wooperbot\cogs\art.py", line 398, in _ocs
    await ctx.respond(embed=embed, view=view)
  File "e:\Documents\GitHub\wooperbot\env\lib\site-packages\discord\commands\context.py", line 278, in respond
    return await self.followup.send(*args, **kwargs)  # self.send_followup
  File "e:\Documents\GitHub\wooperbot\env\lib\site-packages\discord\webhook\async_.py", line 1561, in send
    data = await adapter.execute_webhook(
  File "e:\Documents\GitHub\wooperbot\env\lib\site-packages\discord\webhook\async_.py", line 213, in request
    raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In components.0.components.0.options.1.emoji.name: Invalid emoji

#

The emoji i'm using is 🐟

wooden zenith
#

@rare ice

#

Can u tell me the await thing for sending a modal through button click agian

rare ice
#

Don’t ping staff for help. You won’t be getting help from me.

wooden zenith
#

I did it to you so much times

#

Now u wanna warn me

#

Jeez someone’s on there man period

rare ice
#

There is no prior context of me helping you. Don’t argue or you may be muted.

smoky forge
marsh dagger
#

What's best practice?

gleaming falcon
#

I feel like online is a bool, you’re either on or you’re not. So default False seems logical.

IP and Port could theoretically be in a state of non-configuration, which None would be appropriate. OTOH, since port can’t logically be 0 for a configured state, there’s a valid argument for that being a default

worldly schooner
#

how do I make slash command callable only if the user has an especific role?

silver moat
worldly schooner
#

oh i see

#

thanks

fervent cradle
#
    users0.pop(users0.index(bot.user))
AttributeError: 'coroutine' object has no attribute 'pop'```
#

I am trying to get the users ho reacted on a particular message

#
new_msg = await ctx.channel.fetch_message(message.id)
    users0 = new_msg.reactions[0].users().flatten()
    users0.pop(users0.index(bot.user))
    print(users0)```
#

but I keep getting the Attribute error

cyan quail
#

you have to await when using users()

fervent cradle
cyan quail
#

yes

fervent cradle
#

thanks it works

deep dew
#

which is the decorator for creating a slash group in a Cog?

#

i've looked under ext.commands but that only exposes slash_command or non-slash group

silver moat
cyan quail
#

this is inside the class but outside the init, which is in-line with where commands would go

silver moat
#

oh I read it wrong :/

deep dew
#

ok so let me get this into an example, see if i understood

class MyCog(commands.Cog):
    group = discord.SlashCommandGroup()

    @group.slash_command()
    async def a_command(self, ctx ...):
       pass

    @group.slash_command()
    async def another_command(self, ctx ...):
      pass
cyan quail
#

i think it might just be @group.command()

#

but try that anyway

#

could be aliased

errant craneBOT
#

Here's the slash cog groups example.

silver moat
#

just for ref

cyan quail
#

oh also group requires the first argument py discord.SlashCommandGroup("group_name")

#

...odd

#

i thought we made description optional

deep dew
#

thanks both!
PS: it's group.command()

cyan quail
#

fair enough

cyan quail
#

didn't update from rc1 because literally every newer version had somewhat significant bugs but 2.1.3 should be pretty stable...

fervent cradle
#

i've been getting the same error for days when a user interacts with a button. i've uninstalled py-cord and reinstalled it and removed any of the discord packages:
TypeError: TypedDict does not support instance and class checks

fervent cradle
# silver moat send full trace back?
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/client.py", line 382, in _run_event
    await coro(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/bot.py", line 1058, in on_interaction
    await self.process_application_commands(interaction)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/bot.py", line 722, in process_application_commands
    ) and isinstance(interaction.data, interactions.ComponentInteractionData):
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/typing.py", line 2385, in __subclasscheck__
    raise TypeError('TypedDict does not support instance and class checks')
TypeError: TypedDict does not support instance and class checks```
#

how do I remove all reactions from a message?

fervent cradle
fervent cradle
fervent cradle
# cyan quail update to 2.1.3

i tried but i get ERROR: Package 'py-cord' requires a different Python: 3.6.0 not in '>=3.8.0' , yet im using Python 3.10.6

cyan quail
#

Are you on windows?

fervent cradle
#

no, Mac

cyan quail
#

Geh not sure how the versioning commands work on there

fervent cradle
#

its still the same

#

i still use pip

silver moat
#

use pip3

cyan quail
#

Nah I mean version specific PiP, it's different on windows and mac/linux

fervent cradle
#

oh

cyan quail
#

Just Google the command idk

fervent cradle
silver moat
#

it’s pip but you type pip3

fervent cradle
silver moat
#

because mac has a built in python

cyan quail
#

It'll be the same as the Linux command probably

fervent cradle
#

pip3 seemed to work

deep dew
#

how do i refresh the list of available slash commands each time the bot restarts? it seems that an old command still shows up but isn't linked to any callback

silver moat
#

and then removed from your discord client's cache

coral kindle
#

how can i send message to channel by its name

coral kindle
#

examples?

silver moat
#
channel = discord.utils.get(guild.channels, name='Foo')
await channel.send('Bar')
coral kindle
#

thx

fervent cradle
#

Why pycord said in @bridge.bridge_command this to me?

Expected type '_SpecialForm', got 'str' instead

fervent cradle
silver moat
#

full traceback?

fervent cradle
silver moat
fervent cradle
silver moat
#

so ignore it. It's a typing issue

fervent cradle
#

it´s only in the latest version of pycord

void fable
#

slash commands can't have *args right?

silver moat
errant craneBOT
#

Here's the slash options example.

void fable
spice oyster
#

Hello! What could be the reason why my bot cannot be used in Threads on a server but works in another one? I didn't test more than two servers.

silver moat
#

describe doesn't work

spice oyster
#

Maybe it's because of their permissions. I'll tell them to check if they have blocked other channels with the "new" feature for doing so. rooThink

spice oyster
silver moat
#

sounds like a permission thing

worn void
#

I can't figure out why my button wont disable?
this is my code

    @discord.ui.button(label="Transcript", custom_id="transcript_ticket", style=discord.ButtonStyle.danger, emoji="📜")
    async def trans_button_callback(self, button, interaction):
        channel = client.get_channel(transchanid)
        try:
            channel = client.get_channel(transchanid)
            transcript = await chat_exporter.export(interaction.channel)
            transcript_file = discord.File(io.BytesIO(transcript.encode()), filename=f"{interaction.channel.name}.html")
            
            button.disabled = True

            embed=discord.Embed(color=0xffff00)
            embed.add_field(name="Transcript", value=f"Transcript for {interaction.channel.name} has been created!", inline=False)
            embed.set_footer(text="Report bugs or suggestions with /bug or /suggest!")

            await channel.send(file=transcript_file, embed=embed)
            embed=discord.Embed(color=0xffff00)
            embed.add_field(name="Transcript", value=f"Transcript for {interaction.channel.mention} has been created!", inline=False)
            embed.set_footer(text="Report bugs or suggestions with /bug or /suggest!")
            await interaction.response.send_message(embed=embed)
        except:
            await interaction.response.send_message("Please do a /bug report with the bug being, `Error Code: 30`")
silver moat
worn void
#

ahh thank you

worn void
# silver moat you need to update the original message with the updated view: ```py await inter...
Traceback (most recent call last):
  File "C:\Users\Ryanh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ui\view.py", line 396, in _scheduled_task
    await item.callback(interaction)
  File "F:\[bots]\MyChemicalCult Bot\bot.py", line 185, in trans_button_callback
    await interaction.response.send_message("Please do a /bug report with the bug being, `Error Code: 30`")
  File "C:\Users\Ryanh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\interactions.py", line 727, in send_message
    await self._locked_response(
  File "C:\Users\Ryanh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\interactions.py", line 975, in _locked_response
    await coro
  File "C:\Users\Ryanh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\webhook\async_.py", line 211, in request
    raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
silver moat
silver moat
#

?

worn void
#

1 sec

silver moat
#

I'm stupid. You should use interaction.response.edit_message

worn void
#

oh shit

#

lol

silver moat
#

and then send the other messages by followup

worn void
#

it's taking longer than 3 seconds

#

is there a way to fix that?

#

oh ik

#

nvm

#

i gtg now but ill be back

deep dew
#

using Paginator could I paginate modals? Or else, is there a workaround to have more than 5 elements into a modal?

full basin
#

Discord limitation.

rare ice
#

So I have 2 buttons in a subclassed view and I keep getting an error of "This interaction has already been responded to" when I use it a second time but it haven’t deffered the response or anything.

  @discord.ui.button(label="Index Page", style=discord.ButtonStyle.blurple, disabled=True)
  async def index_page_callback(self, button, interaction):
    for child in self.children:
      if child.label == button.label:
        child.style = discord.ButtonStyle.blurple
        child.disabled = True
      else:
        child.style = discord.ButtonStyle.grey
        child.disabled = False
     main = # my embed stuff (retracted)
    await interaction.response.edit_message(embed=main, view=self)
    
  @discord.ui.button(label="Credits", style=discord.ButtonStyle.grey)
  async def credits_callback(self, button, interaction):
    for child in self.children:
      if child.label == button.label:
        child.style = discord.ButtonStyle.blurple
        child.disabled = True
      else:
        child.style = discord.ButtonStyle.grey
        child.disabled = False
      credits = # embed stuff (retracted)
      await interaction.response.edit_message(embed=credits, view=self)```
worn void
#

Can anyone help me with this error:

Ignoring exception in view <TicketClosedButtons timeout=None children=2> for item <Button style=<ButtonStyle.danger: 4> url=None disabled=False label='Transcript' emoji=<PartialEmoji animated=False name='📜' id=None> row=None>:
Traceback (most recent call last):
  File "C:\Users\Ryanh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ui\view.py", line 396, in _scheduled_task
    await item.callback(interaction)
  File "F:\[bots]\MyChemicalCult Bot\bot.py", line 174, in trans_button_callback
    await interaction.response.send_message(embed=embed)
  File "C:\Users\Ryanh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\interactions.py", line 727, in send_message
    await self._locked_response(
  File "C:\Users\Ryanh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\interactions.py", line 975, in _locked_response
    await coro
  File "C:\Users\Ryanh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\webhook\async_.py", line 211, in request
    raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction

Code:

class TicketClosedButtons(discord.ui.View):
    def __init__(self):
        super().__init__(timeout=None)
    @discord.ui.button(label="Delete", custom_id="delete_ticket", style=discord.ButtonStyle.danger, emoji="🔒")
    async def delete_button_callback(self, button, interaction):
        support = discord.utils.get(interaction.guild.roles, name="Staff")
        channel = client.get_channel(transchanid)
        embed=discord.Embed(color=0xff0000)
        embed.add_field(name="Ticket Deletion", value="Ticked will be deleted in a few seconds.", inline=False)
        embed.set_footer(text="Report bugs or suggestions with /bug or /suggest!")
        await interaction.response.send_message(embed=embed)
        await asyncio.sleep(5)
        await interaction.channel.delete()

    @discord.ui.button(label="Transcript", custom_id="transcript_ticket", style=discord.ButtonStyle.danger, emoji="📜")
    async def trans_button_callback(self, button, interaction):
        channel = client.get_channel(transchanid)
        transcript = await chat_exporter.export(interaction.channel)
        transcript_file = discord.File(io.BytesIO(transcript.encode()), filename=f"{interaction.channel.name}.html")

        embed=discord.Embed(color=0xffff00)
        embed.add_field(name="Transcript", value=f"Transcript for {interaction.channel.mention} has been created!", inline=False)
        embed.set_footer(text="Report bugs or suggestions with /bug or /suggest!")
        await channel.send(file=transcript_file, embed=embed)
        await interaction.response.send_message(embed=embed)

        #embed2=discord.Embed(color=0xffff00)
        #embed2.add_field(name="Transcript Created", value=f"Transcript has been created!", inline=False)
        #embed2.set_footer(text="Report bugs or suggestions with /bug or /suggest!")
        #await interaction.response.send_message(embed=embed2)

        button.disabled = True
        await interaction.response.edit_message(view=self)
        #except:
        #    await interaction.response.send_message("Please do a /bug report with the bug being, `Error Code: 30`")```
#

Happens when clicking the "transcript" button

full basin
worn void
#

Like can I interaction.response.send_message at the start and solve it?

full basin
#

Or defer it?...

worn void
#

How would I do that?

full basin
#

await interaction.defer()

worn void
#

Found it

#

Yeah lol

full basin
#

And then to respond await interaction.followup.send