#Basic Pycord Help (Quick Questions Only)

1 messages · Page 24 of 1

signal sandal
#

prints 1

silver moat
signal sandal
#

it says 42

silver moat
signal sandal
#

Ic

#

when i guild chunk i recive an error with player_manager'

#

on_voice_state_update

#

disabling guild chunk is the way i fix it so far

#

or will it fix it self after on_ready

#

Along with this if it doesnt chunk on start

#

Can i grab the data at a later point?

#

fukin hell mate

#

chunk took me 12 mins

tiny wagon
#

can i configure message_commands in a way that they appear in context menus of user only if a particular check has returned true?

spice sedge
#

How do I add a codeblock to set_author

#

This is the output

rugged lantern
#

codeblock is two `

#

not one

spice sedge
#

it's the same

rugged lantern
#

perhaps it doesn't work as author then

spice sedge
#

yea that's what im thinking

#

so the author field is constantly bold?

rugged lantern
#

mhm

spice sedge
#

Here's what I did instead

rugged lantern
#

btw, consider using f string formatting as opposed to "str" + "str" + "str"....

#

nvm u already did

#

was looking at the first img

covert loom
#

hey quick question bot.latency returns me a scary long number, wonder how to format it properly so it'd show it as accurate ms value

proud mason
#

you could do smth like f" Latency is {round((bot.latency)*1000, 2)} ms"

#

cuz 1000 ms is 1 sec
and bot.latency returns the latency in sec

covert loom
#

oh cool, thanks a lot

cobalt tangle
#

why is bot.user being declared as NoneType

#

in my code

#
bot = commands.Bot(debug_guilds=[905460493597167697], intents=intents)

bot_user_id = bot.user.id
#

Exception has occurred: AttributeError 'NoneType' object has no attribute 'id'

cyan quail
cyan quail
#

are you sure the bot had already started at that point? on_ready must also be complete before trying it

cobalt tangle
#

bot.run was after that

#

anyways how do i get it in cogs

cyan quail
#

wdym "how", as long as the bot has started it will work

#

what are you even trying to do

cobalt tangle
cyan quail
#

but in what context

#

why wouldn't you just do it after the bot's ready

tiny wagon
#

Nvm i saw old chats

cyan quail
tiny wagon
#

Lol same i did @rare ice

#

Discord shows old chats brrr

slim nebula
#

How to not 'respond' to a slash command or as in have it so it doesn't display e.g. Duck used /ban at the top? I don't want it waiting and then going, The application did not respond

cyan quail
slim nebula
#

I want it publicly viewable, I just don't want Duck used /<commandname> at the top and people being able to see the options you used.

Essentially just a ctx.send without it going The application did not respond.

#

Is there not a way to respond with nothing and shut it up from going The application did not respond?

cyan quail
#

or do an ephemeral response and a separate ctx.channel.send

slim nebula
slim nebula
cyan quail
#

what you're asking for is impossible then

#

(maybe not literally impossible, someone's probably figured out some stupid hack like deferring a ping then pong the interaction response and then use a send or something, but the point is if you respond to a command it will always have the command run attached to it, if you want to remove it you have to send a separate message)

slim nebula
#

Hate that - alright thanks for your help

fervent cradle
#

my @\tasks.loop functions are starting multiple times, I'm using

        if not self.check_for_circular.is_running():
            self.check_for_circular.start()
sage galleon
#

Where do I upload images to so I can use the URL?

sage galleon
# copper dew imgur ?

and if I'd rather it not be easily accessible to the public? I don't care if it's a public link, but not on a site like Imgur if it makes sense

copper dew
#

or u could put the images on an CDN

fierce hazel
#

Could anyone please explain me the difference between application commands and slash commands? I'm a bit lost on this.

young bone
fierce hazel
#

Oh I see, application commands are just the parent of slash commands then

#

each slash command is an application command

fierce hazel
#

yeah I just found that resource too, unfortunately they don't go in dept about what application commands themselves are, but seeing them grouping slashcommands and others its clear to me that its just the grouping of all types of commands

#

I guess slash commands inherit from application commands?

proud pagoda
# fierce hazel yeah I just found that resource too, unfortunately they don't go in dept about w...

Application commands include slash commands, user commands, and message commands. They're effectively ways to interact with bots that are built directly into discord, in contrast with prefixed commands which are just the bot scanning message content and then doing something. Slash commands are a type of application command, that can be triggered by typing a slash in chat and then selecting the corresponding command from the autocomplete that appears

fierce hazel
#

Hey sounds good, thanks man!

sly grail
#

#general message

.close()

thanks for sending me here so i can write my solution

#

very helpful

wooden zenith
#

?tag codeblock

obtuse juncoBOT
#

Please put your code in a code block:
```py
Here is your Code
```

That makes reading code in Discord a lot easier:

print("This is an example.")
wooden zenith
#

ik im probaly gonna get flamed by someone saying simple python but can anyone help?

@bot.slash_command(description="nick")
async def nick(ctx, user: discord.Member):
 if(message.author.id == "1007797339643195455"):
    await ctx.respond("nick man is {user}")
 else:
    await ctx.respond("no perms :skull:")

error:

discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: module 'email.message' has no attribute 'author'

young bone
wooden zenith
#

and i have the id

#

and when i still type i get the one thats supposed to pop up if your not me

loud holly
#

bc the ID is int not string...

wooden zenith
#

huh

loud holly
#
if(message.author.id == "1007797339643195455"):

You're comparing an int against a string, ofc it won't work and choose the latter

wooden zenith
naive steppe
#

Which wont work

naive steppe
#

Same difference

#

Still returns an int

wooden zenith
#

how do i fix it then

naive steppe
#

Int == string ❎
Int == int / string == string ( dont do this one ) ✅

young bone
#

@wooden zenith pls learn python basics

wooden zenith
#

you dont know anything abt my medical history

#

i learned it

naive steppe
#

What

wooden zenith
#

i have a bad memory

naive steppe
#

What does that have to do with learning python?

wooden zenith
#

i forget things easily

naive steppe
#

I present some good options
Google
Stackoverflow
Coding assistant

I personally forget basic shit too, so i refer to already documented problems and use them as references :3

#

No flame, but sometimes its quicker to google than ask and rely on other humans

wooden zenith
#

okay thank you

#

@naive steppe what do u reccomend searching up for it?

naive steppe
#

Just look at examples

#

Its a simple fix honestly

round rivet
#

there are resources at the top of #help-rules

naive steppe
#

You just need to compare a different datatype

young bone
wooden zenith
#

please stfu

#

you know nothing abt me

round rivet
#

if you don't want help then don't ask

naive steppe
#

Not a bad idea, adding comments in code and explaining what it does, does help learning

round rivet
#

we're doing what we can

wooden zenith
#

some stuff doesnt work for me

wooden zenith
round rivet
#

then explain that instead of saying 'stfu you know nothing'

wooden zenith
#

that i cant help

pine grotto
round rivet
young bone
#

^

wooden zenith
naive steppe
#

If you let a medical order hold you back you wont get anywhere, there are athleates with missing limbs

wooden zenith
#

this kid does shit like this

naive steppe
#

You need to push through

loud holly
#

do you know about casting? If you don't, it means you still have stuff to learn. Even though the option is still there, it's much better to understand the type that it's sending over. In the docs (pretty sure) it explains the type when it sends over

glossy socket
#

how can i make an inputText field in a modal an integer field and set a min and max integer?

glossy socket
#

damn, thats a weird choice of discord

round rivet
#

you can validate it server side if you want though

glossy socket
pine grotto
#

If anyone has time, I made a post explaining an error i'm experiencing.
I'm basically trying to edit the content of a message by using interaction.message.webhook_id, but when trying to edit it with interaction.followup.edit_message(), an 'unknown webhook' error is raised
the following is a link to the post https://discord.com/channels/881207955029110855/1024439410655248455

wooden zenith
#

hey @naive steppe did i fix it or no?

@bot.slash_command(description="nick")
async def nick(ctx, user: discord.Member):
 if({ctx.author.id == "1007797339643195455"}):
    await ctx.respond("**nick man is**")
 else:
    await ctx.respond("no perms :skull:")
#

act no i didnt shit

#

nvm sorry for ping

full basin
#

ID is an int

#

Not a string

wooden zenith
#

ik ik

full basin
#

It'll always default to else

wooden zenith
#

im trying to learn how to fix it

full basin
#

It's somehow basic python

glossy socket
#

are menus also not supported in modals?

loud holly
#

discord limitation

glossy socket
#

annoying af

young bone
#

the max is 5 text fields

loud holly
#

they're working on it however knowing discord, it'll take a lot of time

young bone
#

it works in some way but on mobile it can crash discord

loud holly
cyan quail
#

they were like fully functional on desktop for months

young bone
#

oh

cyan quail
#

then called it a bug and removed it apensive could have taken a bit of time to fix it for other platforms and then formally announce it as a feature

glossy socket
#

does someone have the docs link for directmessage?

#

not sure if im blind but i cant find it

waxen whale
signal sandal
#

any one know why any "reg commands" non slash do not work?

silver moat
obtuse juncoBOT
#

As of Pycord Beta 5, Discord API v10 requires message content intent to receive message content. This affects the traditional commands. Not enabling this intent will result in the messages' content, embeds, and components being empty.

You will need to enable the intent on the developer portal, as well as in your code:

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

Docs: https://docs.pycord.dev/en/master/api.html#discord.Intents.message_content

silver moat
#

#library-updates message

stiff fiber
#

How can I add more than 1 parameter to a slash command? I have something that looks like

@slash_command(name="example")
async def test(ctx, a: discord.Option(str), b: discord.Option(str)):
    # do stuff

However, when I run this command, I'm only prompted for option b.

stiff fiber
#

yeah

silver moat
#

you are missing the self parameter

stiff fiber
#

oh facepalm

#

thanks

silver moat
#

yw

spice sedge
#

Has this been fixed?

#
Evaluating...
Starting Download...


Unfortunately all 20 could not be downloaded because some images were not downloadable. 0 is all we got for this search filter!

Errors: 0```
#

google_images_download module

copper dew
#

probably not. the last commit to master (for that module) was May 21, 2019

spice sedge
#

sad....

copper dew
#

probably might want to find another one. if u can't find one that suits your needs, you can always create your own lib for that

spice sedge
#

yea i'll find another one

worldly schooner
#

how can I avoid a discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction when doing a slash command?

loud holly
#

Will the bot get rate limited or something if they send messages in like a lot of server chats "at once"

So what I'm trying to do is on_ready event, it'll send message to all the log channel that the server has enabled, is that not recommended to do?

It'll loop through all of the log channels, if needed I can set up an async sleep if needed to not get ratelimited

spice sedge
#

bing_image_urls and google_images_search for easy web image scraping, the bing one not better, but way easier. I can't believe how I missed these two. I know there's more out there but I'll stick to these for now.

glossy socket
#

is there any way to remove ephemeral messages?

grizzled sentinel
#

You can delete the the same way as a normal message but it is slightly more buggy. Due to the user deleting it or it not being stored anymore

rugged lantern
#

the the

waxen whale
#

ephemeral messages can't be deleted by bots

#

at least not supposed to

grizzled sentinel
grizzled sentinel
glossy socket
#

ahh damn

waxen whale
#

it was never intended sadly

young bone
#

You can edit them

glossy socket
tiny wagon
#

ez

tiny wagon
glossy socket
#

invalid emoji

#

check your emoji id

loud holly
cyan quail
#

the rate limits are applied individual route

loud holly
cyan quail
#

every route; even each channel technically has its own

#

as long as you don't exceed the global ratelimit which is pretty high already

#

it's like 50 per second or something

loud holly
#

ah, then I should be fine. It's only during the startup that it sends in every channel and I'm hoping as well that during pretty big updates, it'll send message in the log system and ping the owner and admins on the downtime coming

#

awesome thanks!

limber sorrel
#

I have a question, is there a limit on command count?

zinc minnow
#

hey everyone! how I can add reaction and open thread on interaction message

#

ping pls

silver moat
# limber sorrel I have a question, is there a limit on command count?

You can have 100 global commands, and each command can have up to 25 sub-command groups. Each sub-command group can have up to 25 sub-commands.

100 x 25 x 25 = 62.5k

Of course, "slash commands can have a maximum of 4000 characters for combined name, description, and value properties for each command and its subcommands and groups", so you're not likely to hit that 62.5k command limit (because every command would have an average of 6.4 characters).

You can also multiply this number by two if you register the bot's commands in every guild as guild commands.

silver moat
#

then do normal message stuff with it

zinc minnow
#

and how, let's say, to bind it to a button

silver moat
errant craneBOT
#

Here's the cooldown example.

errant craneBOT
#

Here's the reaction roles example.

limber bison
#

Buttons have to be responded to within the same session right?

fervent cradle
#

I tried creating 5 rows but only 2 show up

#

never mind

#

I'm kinda dumb that way

fair crescent
#

discord.errors.NotFound: 404 Not Found (error code: 10015): Unknown Webhook

i have this error when try to edit a message with:
await interaction.followup.edit_message(interaction.message.id, embed = embed, view = None)

this message was edited a few times in a row, any ideas ?

edit: the interaction variables is an interaction: <discord.interactions.Interaction object at 0x7f77ee51aba0>

glossy socket
#

is it possible to have multiple instances of 1 bot running?

#

on a button click my aws lambda will run and i want that lambda to give updates in dm

copper dew
glossy socket
copper dew
glossy socket
#

sending updates from a lambda function to discord

copper dew
#

And deploy the docker image to AWS since it seems like u are already using that

glossy socket
#

ty i might do it that way

#

tho i was hoping that theres some serverless way

copper dew
glossy socket
#

just sending updates

copper dew
#

ah ok

glossy socket
#

itd make sense for what im trying to achieve

young bone
topaz rune
#

Him I have this code:

async def xp(self,ctx,user = None):
        font = ImageFont.truetype("C:/taf/test_python/BebasNeue-Regular.otf",35)

        le_gif = []
        size = (800,200)
        millieu = (0,0)
        premierp = Image.open("C:/taf/test_python/test.png").convert("RGBA")
        barre_v = Image.open("C:/taf/test_python/barre_v.png").convert("RGBA")
        barre = Image.open("C:/taf/test_python/barre.png").convert("RGBA")
        pp = ctx.author.avatar
        width, height = pp.size
        pp = pp.resize((round(width*0.3),round(height*0.3)))
        for img_act in range(18):
            im = Image.new('RGB', size)

            frame = Image.open("C:/taf/test_python/frames_pp/" + str(img_act) + ".gif").convert("RGBA")
            width, height = frame.size
            frame = frame.resize((round(width*0.8),round(height*0.8)))


            im.paste(frame, (510,-70),frame)
            im.paste(barre_v,(13,130),barre_v)
            a = 5 #  0% = -640,  100% = 5
            b = 130
            im.paste(barre,(a,b),barre)
            im.paste(pp,(14,12),pp)
            im.paste(premierp,millieu,premierp)

            I1 = ImageDraw.Draw(im)
            I1.text((130, 90), "Level :", font=font)
            I1.text((350, 90), "XP :", font=font)


            le_gif.append(im)


        le_gif[0].save('C:/taf/test_python/atest_bann.gif',
                save_all = True, append_images = le_gif[1:], 
                optimize = False, duration = 10, loop=0)
        
        await ctx.send(file=discord.File('C:/taf/test_python/atest_bann.gif'))

does someone have an idea on how I can use the pp of the user that send the command on the imge that my code create?

clever nova
#

Hey guys! Is it a valid approach to divide a bot into 2 different project, running its own instances, and make one only manage, for example, slash commands, and the other one only background tasks, so that i can edit change one without killing the other?

silver moat
#

make sure to turn off auto_sync_commands on your bg task bot

clever nova
#

thankyou!

rare ice
#

For some reason, when I have intents = discord.Intents.default() then set intents.members=True when my bot is verified and I have the guild members intent, my on_ready doesn't want to fire and it still doesnt think i have the guild members intent when I do on the dev portal since i applied for it. this issue only occurs when setting intents.members to True.

#

nvm it just takes a really long time to start the bot AYS_Hmm

peak chasm
#

how to send private message ?

copper dew
peak chasm
#

pls 🥺

silver moat
waxen whale
#

Hilarious

peak chasm
#

I have a doubt. can I make the bot send messages without events?

sinful laurel
#

How do I delete commands?

#

my commands have doubled

silver moat
rare ice
silver moat
sinful laurel
#

what

#

i just want to delete global commands

silver moat
#

since if they are duplicates the only way is that they are registered differently, global-level and guild-level

sinful laurel
#

k

silver moat
#

just don’t test on production

fringe socket
#

How do I make my Discord Bot have a custom colour for their banner?

fringe socket
#

Also, what is the event for when the bot joins or leaves a guild?

fringe socket
#

TYSM

fringe socket
spice oyster
#

I doubt that's possible.

fringe socket
#

ouch

#

Also, how do I make a bot display a user's banner in an embed as the "embed.set_image"

#

@spice oyster

rugged lantern
#

figure it out

cobalt tangle
#

why does my defer() go on forever?

#
Traceback (most recent call last):
  File "/home/container/.local/lib/python3.9/site-packages/discord/client.py", line 382, in _run_event
    await coro(*args, **kwargs)
  File "/home/container/main.py", line 33, in on_application_command_error
    await interaction.response.send_message(embed=embed)
  File "/home/container/.local/lib/python3.9/site-packages/discord/interactions.py", line 674, in send_message
    raise InteractionResponded(self._parent)
discord.errors.InteractionResponded: This interaction has already been responded to before
#

now this error

worldly schooner
#

is there a way to persist the discord.cooldown for a user using the bucket type?

cobalt tangle
worldly schooner
#

like not reseting it when I restart the bot

cyan quail
cyan quail
cobalt tangle
cyan quail
#

oh right

cyan quail
cobalt tangle
cobalt tangle
cyan quail
#

just do it in that command

cobalt tangle
#

not a cmd

cyan quail
#

oh this is inside the error handler

#

i mean

cobalt tangle
#

async def on_application_command_error

cyan quail
#

you can just do ctx.respond and it'll handle the logic for you

cobalt tangle
#

So i have to pass in ctx in the ()

cyan quail
#

you always do?

cobalt tangle
#

I didnt do that in the error handler

#

for application_command

cyan quail
#

....you're meant to

#

what does it look like

cobalt tangle
#

cuz it wasnt there in an example i saw

#
@bot.event
async def on_application_command_error(interaction, error):
    if isinstance(error, MissingPermissions):
        embed=discord.Embed(title="Error : Permissions", description=error)
        await interaction.response.send_message(embed=embed)
    elif isinstance(error, CommandOnCooldown):
        embed=discord.Embed(title="Error : Cooldown", description=error)
        await interaction.response.send_message(embed=embed)
    else:
        embed=discord.Embed(title="Error", description="Something went wrong... Please inform the developers of this!")
        await interaction.response.send_message(embed=embed)
        raise error
cyan quail
#

interaction is ctx

#

you just named it differently

rugged lantern
#

how do you assign a custom on_timeout to a view that is not inside its own class

cobalt tangle
#

well so i do interaction.respond?

cyan quail
#

i guess

cobalt tangle
#

oki

#

ill try

cyan quail
cobalt tangle
#

Exception has occurred: AttributeError 'interaction' object has no attribute 'respond'

cyan quail
#

how in the hell are you getting interaction when it passes context

cobalt tangle
#

idk

#

my pc says that

#

should i try checking my version?

cyan quail
#

yeah

cobalt tangle
#

k

rugged lantern
#

i tried that but some reason it is inaccurate to the prerequisite arguments

cyan quail
#

elaborate

#

or idk show your code

cobalt tangle
#

2.1.3

#

how abt i try interaction: discord.ApplicationContext

#

@cyan quail

cyan quail
#

sure

cobalt tangle
#

oki

young bone
#

can you try ctx.respond?

cobalt tangle
cyan quail
#

interaction is ctx

#

in your code

cobalt tangle
#

hm

#

Ill try re-installing

#

i did update python today, maybe that caused some nonsense

young bone
#

do you have something else installed?

cobalt tangle
#

As far as i see in my pip list, pycord is the only discord API wrapper

#

working, i re-installed Py-Cord and re-opened Cmd and VSC

cyan quail
#

yeah you were using dpy

#

wait

#

eh

#

some mix of it idk

#

they take interaction in their error handler

amber shale
#

await ctx.defer() changed?

cyan quail
young bone
#

did discord change something?

#

all my prefix commands doesn´t work anymore

rare ice
winter condorBOT
# young bone all my prefix commands doesn´t work anymore

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.

young bone
cyan quail
#

skill issue

rare ice
young bone
#
import json

import discord
from discord.ext import commands

client = commands.Bot(
    command_prefix="1",
    help_command=None,
    debug_guilds=[903607882564636683],
    case_intensitive=True,
    intents=discord.Intents.all())

@client.event
async def on_ready():
    print("Ready!")

@client.command()
async def test(ctx):
    await ctx.send("test")

@client.event
async def on_message(message: discord.Message):

    if message.content == client.user.mention:
        await message.channel.send(f"Hello {message.author.mention}")

    if message.content.lower() == "hello":
        await message.channel.send(f"hello {message.author.mention}")


with open("Database/Config.json", "r") as f:
    data = json.load(f)
    testbot = data["Bot"]["testbot"]

client.run(testbot)
``` this is a test file
cyan quail
#

overrides on_message
complains about commands not working

#

add await client.process_commands(message) to the end of that event

spice sedge
#

Does this mean that the token I passed is not a valid token?

#
Traceback (most recent call last):
  File "main.py", line 108, in <module>
    bot.run(TOKEN) # run the bot with the token```
#

Got confused, it worked a while ago now it doesn't....

fervent cradle
#

hey there can anyone help me

#

So the thing is, i wanted to create a welcome command which looks like this after completion

#

but when anyone joins the server the bot replies pretty late, say like 5-6 secs after

#

I have worked with easy_pil for this

#

is there a way by which I can make the response asap when anyone joins

#

If anyone answers please ping me

cyan quail
#

if you want it faster you'd either have to find more efficient code or get a better server to run the bot on

oblique sonnet
#

Is there any better way to ignore self (bot) messages? other than if else

cyan quail
oblique sonnet
#

i mean if there is any other way it would be good to know cz rn i want to listen for user messages only in a channel where my bot send logs of a console

cyan quail
#

not really, you literally just check message.author.bot or compare message.author.id to your bot's id

#

that's only 1 or 2 lines at most

oblique sonnet
#

yea ik that one... but just wanted to know if any other way was there or no

cyan quail
#

this sounds like trying to reinvent the wheel

#

it's the most straightforward way

#

is it because of else?

hushed ledge
#

One message removed from a suspended account.

#

One message removed from a suspended account.

cyan quail
#

utcnow() gets the exact current time

#

and you're removing x days from it

#

it doesn't round or anything, it'll still be the same exact time; just x days ago

hushed ledge
cyan quail
#

ah oh well

#

use datetime.utcfromtimestamp(...) to convert an int unix time to datetime

spice oyster
#

How can I make the autocomplete show "Lúcio" with accent (working) but also find it when written without accent (not working)? Solved.

async def autocomplete(context: discord.AutocompleteContext):
    input = "".join(item for item in context.value if item.isalpha()).lower()
    heroes = await Hero.catalog()
    return [hero for hero in heroes if "".join(item for item in hero if item.isalpha()).lower().startswith(input)]
cyan quail
#

e.g. if you find ú in context.value then replace it with u

#

or rather the other way round

#

for the sake of finding Lúcio, you should instead match against Lucio and then you return Lúcio

spice oyster
#

Hmm, I'll see what I can do.

hushed ledge
cyan quail
#

no

#

wait

#

ignore me, that's fine

hushed ledge
#

One message removed from a suspended account.

spice oyster
hushed ledge
#

One message removed from a suspended account.

crisp burrow
#

how do you create message object from only message id?

hushed ledge
silver moat
#

No cross posting thanks

naive steppe
#

You may need to fetch the guild and channel first

pearl leaf
#

is there any way to get the built-in DefaultHelpCommand to work with slash commands? if not what is the best way to build a help command response for all my slash commands?

waxen whale
#

tbh I wouldn't use default help.
It's already in the ui with name and descriptions

rare ice
#

omg i love overwatch

livid salmon
#

Hey there. I'm making a command for entering and registering players' scores for a game in a database. I want to have players enter their scores through a slash command, then have a message ping the mods so they can verify the score with an in-game screenshot from the player, then input a slash command to have the score finalized and written into the database.

Basically, I was wondering how to get a slash command to wait for a response from another slash command before continuing.

silver moat
pearl leaf
waxen whale
#

you'll need to write that yourself I think

waxen whale
rare ice
#

tbh idk

waxen whale
#

send me your tag in dms doggolul

waxen whale
waxen whale
#

Squid always helpful love

silver moat
waxen whale
#

yeah I guessed so

copper dew
#

Wished there was a native way to do it, and I might make a cog that does that

tiny wagon
fringe socket
#

Hey, how do I make some of my Discord bot's commands work in ALL servers?

spice oyster
spice oyster
fringe socket
#

aah ok

waxen whale
spice oyster
waxen whale
#

nah, don't like crossover
aaand I driftet too much OT here.
Let's drop that topic

fervent cradle
#

Hi my Py cord dont work any Idees how to fix it??

winter condorBOT
fervent cradle
#

it says "No module named 'discord'"

naive remnant
fervent cradle
#

I allready did that

naive remnant
#

Send me the code man

#
import discord 
naive remnant
young bone
fervent cradle
#

but thanks

fervent cradle
#
@autorole.command(name='add', description='setup the autorole')
    @discord.default_permissions(manage_guild=True)
    async def autorole_add(self, ctx, *, role: discord.Option(discord.Role, 'the role to be given', required=True)):
        await ctx.defer()
        try:
            await db.run_query(f'INSERT INTO autorole(guild_id, role_id) VALUES({ctx.author.guild.id}, {role.id});')
            await ctx.respond('Configuration saved! Autorole is setup', ephemeral=True)
        except asyncpg.exceptions.UniqueViolationError:
            await ctx.respond('Autorole is already setup!', ephemeral=True)
#

this is my code but the messages arent ephemeral ones

cyan quail
fervent cradle
slim plaza
#

Found some replies in the help threads but thought id just ask here: What hosting service would you guys recommend? Id only use the bot for my private server and the bot is rather simple

copper dew
#

might throw a Prometheus exporter on some of my bots so I can get some metrics to track later

errant craneBOT
#

Here's the persistent example.

spice oyster
#

Did you forget to await something?

hushed ledge
#

One message removed from a suspended account.

proud mason
#

whats the thing you are planning to use this for? you could use the on_mesage event. you can either store the counter in a dict (it will reset when the bot resets) or you could use a database like sqlite

hushed ledge
#

One message removed from a suspended account.

proud mason
# hushed ledge One message removed from a suspended account.

you can do smth like

user_msg_count = {}

async for message in ctx.channel.history(limit=None, oldest_first=True, after=after_date):
    if user_msg_count[message.author.id]:
        user_msg_count[message.author.id] += 1
    else:
        user_msg_count[message.author.id] = 1
#

also, because you have put limit=None, dont forget to break

hushed ledge
#

One message removed from a suspended account.

proud mason
#

yea its not necessary, it depends on what you are planning to do

hushed ledge
#

One message removed from a suspended account.

proud mason
#

np!

hushed ledge
#

One message removed from a suspended account.

loud holly
#

I presume the send_messages_in_threads includes sending messages in forum posts right?

glossy socket
#

is it possible to edit a message based on the message id in a dm channel? so i can save the message id in a database to edit later

glossy socket
#

also is it possible to do a defer on a button click

spice oyster
spice oyster
glossy socket
spice oyster
#

Posts are basically Threads, just slightly different.

loud holly
spice oyster
#

Oh, you are talking about permissions.

loud holly
fervent cradle
#

How can i not spam my console when using @commands.has_permissions and don't have the perms?

fervent cradle
#

thanks

#

i couldn't find it in the docs

spice oyster
hushed ledge
#

One message removed from a suspended account.

#

One message removed from a suspended account.

full basin
#

Working with strings is some basic python

naive steppe
hushed ledge
spice oyster
#

When the difference is just capitalization, you can use lower().

long moat
foggy mesa
#

Hi, so I'd like to make a slash command group inside a cog. What's the easiest way to do this? Should I make a variable in the class constructor, or is there some decorator I can put on a function?

fervent cradle
#

guys

#

Why does it take so long for my bot to send messages

#

I checked the execution time

#

for each part

#

everything happens quickly in like 0.1265.. secs

errant craneBOT
#

Here's the slash cog groups example.

full basin
#

@foggy mesa ^

full basin
fervent cradle
#

but when await ctx.respond(...)

#

the time reaches 8-9 secs

#

the entire program executes in 2 secs at max

foggy mesa
fervent cradle
#

but just including the await ctx.send thing

#

it goes upto 8-9 secs

#

and I don't want that

#

bc it is a welome message

lilac citrus
#

I was wondering how to keep the selected item in the select menu the same when I edit the message of the interaction
code for the callback function of the select menu:

async def callback(self, interaction: discord.Interaction):
    embed = CountConfigEmbed(interaction.guild)
    await interaction.response.edit_message(embed=embed)```
rugged lantern
#

by not including view?

lilac citrus
#

oh right, i tried without but it didnt work

#

should've removed from the example

fervent cradle
#

Can anyone brief mei what cogs are use for ?

#

and their importance

lilac citrus
hushed ledge
fierce elm
#

is there an easy way to get_or_fetch_user without connecting 2 bots at the same time

#

e.g. I have a bot that is online, but I want to also not have to bring over a full bot to the code that I want to run

#

This is what I have so far

def make_embed(ticket):
    last_updated_by_id = ticket.last_updated_by_id
    await discord.Bot.get_or_fetch_user(last_updated_by_id) # <--- this
    embed = discord.Embed(title=f"Ticket {ticket.id}", color=0x00ff00)
    embed.add_field(name="Ticket ID", value=f"{ticket.id}", inline=False)
    embed.add_field(name="Ticket Status (open-1/closed-0)", value=f"{ticket.open}", inline=False)
    embed.add_field(name="Ticket Author", value=f"{ticket.user_id}", inline=False)
    embed.add_field(name="Ticket Subject", value=f"{ticket.subject}", inline=False)
    embed.add_field(name="Ticket Content", value=f"{ticket.content}", inline=False)
    embed.add_field(name="Ticket Created", value=f"{discord.utils.format_dt(ticket.created, 'F')}", inline=False)
    embed.add_field(name="Ticket Last Updated", value=f"{discord.utils.format_dt(ticket.last_updated, 'F')}", inline=False)
    embed.add_field(name="Ticket Last Updated By", value=f"{ticket.last_updated_by}", inline=False)

    return embed
#

I'm aware I'm not capturing the result of the get_or_fetch_user

analog crest
#

How can I update slash commands without having to register it again?

hoary dirge
#

hi is there any special intent (in the code) my bot needs in order to use slash commands ?

#

cause they are not registered even on my debug serv :(

#

(i invited it with this scope so it should be fine on this side
permissions=0&scope=applications.commands%20bot)

#

and this is the bot creation in the code

intents = discord.Intents.default()
intents.emojis = True
bot = Bot(debug_guilds=[913042210348486710], intents=intents)```
#

and a simple command

@bot.command(description="Contact and code for the bot")
async def info(ctx):
    await ctx.channel.send(f"Author: Inspi#8989\nCode: a link to the code")
opal flax
#

is this a bug? I've used 'none' in the parameters, but why does raised appear?

#
@commands.command()
    async def purge(self, ctx, limit: int, filter: Union[discord.Member, str] = None):
        if limit >= 0:
            if limit <= 100:
                if filter:```
#

output

#
raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: filter is a required argument that is missing.```
#

@kindred sail

kindred sail
hoary dirge
#

cause legacy code; and it seems it made a difference

#

i can't find the doc that lists what you can access in ctx ?

#

is there any ?

woeful spindle
#

Everything I use this and run my server, it just goes offline (with no error).. anyone know why?

async def main():
    async with Bot() as bot:
        await bot.start(os.getenv('TOKEN'), reconnect = True)
hoary dirge
#

ty

woeful spindle
#

I know the basics… I’m trying to use .start instead of .run and I’m tryna to start my program asynchronously

spice oyster
#

Sorry, I can't guess your level or intentions. eddaniChromie

#

Can you do that without using the with statement? eddaniSherlock

hoary dirge
#

i got a command that you can tag any number of people with (including none); what would be the correct function definition ? command(ctx, *mentions) ?

somber remnant
#

Hello guys
i want to know how to remove some RAM in my bot
First, what will increase it ?
and, is the autoshard can remove the problem ?
My host limit the RAM to 100mb, and my bot (without anyone make command) have 42/100 MB.
If you have a better host without limit, you can send it to me in DM

cyan quail
hoary dirge
#

uuh oki imma look into that thanks Danki

worldly schooner
#

what bots can do this? looking for one that is not bloxlink

covert loom
#

hey I'm not entirely sure where to send it but for some reason vscode intellisense is often missing what methods an object might have.
like in an example here

@bot.event
async def on_message(message):
    if 'funk' in message.content:
        await message.add_reaction(bot.get_emoji(1025750885961322636))``` 
here I am adding a reaction to a message and it seems to work fine but it seems like vscode doesn't believe `message` has `.content`
cyan quail
covert loom
#

o it worked, ty

cyan quail
#

there's also extensions like jishaku that can offer other functionality alongside it

full basin
hoary dirge
cyan quail
#

yeah

#

i mean

#

with response.edit_message(view=...)

#

the same as any other edit

hoary dirge
# cyan quail can you paste the full traceback, and is this slash or prefix?

yeah it's slash, here's the backtrace

Traceback (most recent call last):
  File "D:\Documents\Repos\DiscordWordCloud\main.py", line 137, in <module>
    async def cloud(ctx, members: Greedy[discord.Member]):
  File "D:\Documents\Repos\DiscordWordCloud\venv\lib\site-packages\discord\bot.py", line 834, in decorator
    self.add_application_command(result)
  File "D:\Documents\Repos\DiscordWordCloud\venv\lib\site-packages\discord\bot.py", line 138, in add_application_command
    command._set_cog(None)
  File "D:\Documents\Repos\DiscordWordCloud\venv\lib\site-packages\discord\commands\core.py", line 575, in _set_cog
    self.cog = cog
  File "D:\Documents\Repos\DiscordWordCloud\venv\lib\site-packages\discord\commands\core.py", line 780, in cog
    self._validate_parameters()
  File "D:\Documents\Repos\DiscordWordCloud\venv\lib\site-packages\discord\commands\core.py", line 673, in _validate_parameters
    self.options: List[Option] = self._parse_options(params)
  File "D:\Documents\Repos\DiscordWordCloud\venv\lib\site-packages\discord\commands\core.py", line 712, in _parse_options
    option = Option(option)
  File "D:\Documents\Repos\DiscordWordCloud\venv\lib\site-packages\discord\commands\options.py", line 199, in __init__
    self.input_type = SlashCommandOptionType.from_datatype(input_type)
  File "D:\Documents\Repos\DiscordWordCloud\venv\lib\site-packages\discord\enums.py", line 689, in from_datatype
    if datatype.__name__ in ["Member", "User"]:
AttributeError: 'Greedy' object has no attribute '__name__'. Did you mean: '__ne__'?
cyan quail
#

pain

#

greedy could probably be fixed to work with slash but not atm

#

i'd say take it as a string then split and convert inside the command

#

in the next release we'll have discord.utils.raw_mentions(text) that will grab all user IDs from mentions in a string so you can get them all at once to make converting easier

hoary dirge
#

oh oki thanks for your answer prayge

worldly schooner
#

WHY... I'm disabling the buttons in other view during the on_timeout event, but in a different view it gives me an error:

future: <Task finished name='discord-ui-view-timeout-fc00f94177271408f01d3447da1a9399' coro=<MyOperationView.on_timeout() done, defined at C:\Users\Administrator\Desktop\Atalhos\workspacenova\BBot\venv\cogs\Crypto.py:85> exception=AttributeError("'WebhookMessage' object has no attribute 'edit_original_message'")>
Traceback (most recent call last):
  File "C:\Users\Administrator\Desktop\Atalhos\workspacenova\BBot\venv\cogs\Crypto.py", line 87, in on_timeout
    await self.interaction.edit_original_message(view=self)
AttributeError: 'WebhookMessage' object has no attribute 'edit_original_message'
cyan quail
worldly schooner
cyan quail
#

you probably used followup.send

worldly schooner
#

i have no idea, its pretty much the same as the other view

#

lemme show you how i called both

#

This one works with the edit_original_message

#

This one dont

cyan quail
#

because the first ctx.respond will use ctx.interaction.response.send_message, as it's the first response

#

but after that you can no longer use the function, since it's already been responded to

#

so using ctx.respond again will use ctx.interaction.followup.send

worldly schooner
#

ohhhh damn, thanks for the explanation

cyan quail
worldly schooner
#

understood, so I will use only edit instead

#

tysm 🤝

cyan quail
#

all good

worldly schooner
#

ok

cyan quail
lilac citrus
#

hmm, but for the select menus on dank memer, the selected item stays the same when the message edits

verbal gulch
#

Hello, why i get this error?

#

(the error is so long, im going to make a google file

spice oyster
cyan quail
verbal gulch
#

Ah

#

Oof

somber remnant
west flume
#
import asyncio 

from discord.ext import commands
from discord.commands import slash_command, user_command, SlashCommandGroup
from discord.commands import Option

class General(commands.Cog):
    def init(self, bot):
        self.bot = bot

    @commands.slash_command(description="Get the bot's current latency!")
    async def ping(ctx: discord.ApplicationContext):
        embed = discord.Embed(
            description="Ping: {int(self.bot.latency*1000)} ms",
            color=discord.Colour.blurple() 
        )
 
        embed.set_author(name="Pong", icon_url="https://cdn.discordapp.com/avatars/836895718563250196/cafaf0d749d1aaa938f8c0bd7be4fa2d.png?size=1024%22)
        await ctx.respond(embed=embed)

def setup(bot):
    bot.add_cog(General(bot))```
verbal gulch
#

Solved

#

You can see it now

west flume
#

It's showing error

silver moat
verbal gulch
#

Sure, wait

somber remnant
silver moat
lilac citrus
#

ill try later today thanks

silver moat
#

so it should be ```py
@commands.slash_command(description="Get the bot's current latency!")
async def ping(self, ctx: discord.ApplicationContext):

west flume
#

Oh alr

#

It's working. Thanks.

silver moat
verbal gulch
#

mhm

silver moat
#

had pymongo worked before this?

verbal gulch
#

yes

#

i solved the pymongo problem. but i get another one

silver moat
#

and what's your other problem

verbal gulch
verbal gulch
# silver moat and what's your other problem
Ignoring exception in command strike_give:
Traceback (most recent call last):
  File "C:\Users\danie\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\commands\core.py", line 127, in wrapped    
    ret = await coro(arg)
  File "C:\Users\danie\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\commands\core.py", line 911, in _invoke    
    await self.callback(ctx, **kwargs)
  File "c:\Users\danie\OneDrive\Documentos\Phython\Applicaciones\Pokemnia's staff manafger\.py", line 68, in strike_give
    await ctx.respond(f'El usuario {usuario} ha recibido un warn correctamente por `{razon}`. ``id:`` {numero}')
  File "C:\Users\danie\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\commands\context.py", line 275, in respond 
    return await self.interaction.response.send_message(*args, **kwargs)  # self.response
  File "C:\Users\danie\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\interactions.py", line 727, in send_message    await self._locked_response(
  File "C:\Users\danie\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\interactions.py", line 975, in _locked_response
    await coro
  File "C:\Users\danie\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\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
#
The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\danie\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\bot.py", line 1009, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "C:\Users\danie\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\commands\core.py", line 359, in invoke     
    await injected(ctx)
  File "C:\Users\danie\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\commands\core.py", line 135, in wrapped    
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction
silver moat
severe storm
#

hello everyone, i need to call an async function when my bot starts, but it needs to not be in on_ready event, how can i do this?

silver moat
silver moat
severe storm
verbal gulch
#

done

severe storm
# silver moat you can call an async function with `asyncio.run()`

hello again, i tried this and it does call the function yes, but it doesnt run the bot after calling it, im assuming its because the murder (dont question the name) function has an asyncio.sleep, how can i make it run the bot without stopping to call the murder function?

silver moat
severe storm
cyan quail
#

as long as you remember to sync commands

severe storm
cyan quail
#

it's basically just py await client.sync_commands()

#

if you override on_connect just make sure to include that somewhere in it and you should be fine

hoary dirge
#

I can't seem to have an optional discord.Member as argument

@bot.command(description="Creates a workcloud for you or someone you tag")
@guild_only()
async def cloud(ctx, member: discord.Option(discord.Member, required=False, default=None)):

i tried this but discord is forcing me to input a member

#

is it normal behavior ?

cyan quail
hoary dirge
#

k

barren portal
#

Is it possible to tell the difference between a failed everyone ping and someone just saying iy, such as in a code block?

rare ice
amber shale
#

i am getting this when i use await ctx.defer()

silver moat
amber shale
full basin
#

Yes

amber shale
silver moat
#

does the "{bot_name} is thinking.." message show up?

covert loom
#

I've decided to reformat my project to one with modules and all that stuff. Does anybody know how to parse the bot variable from __init__.py to __main__.py?

#

__main__.py just contains a single bot.run(env['DISCORD_TOKEN']) line, everything else sits in __init__.py. I'm not that good at python stuff sorry XD

covert loom
#

nor importing main in init

covert loom
#

ok I've finally figured it out, just had to import as and then specify vars correctly

spice oyster
#

I'm using a Modal. The UI says "up to 4000 characters" but the error message says "up to 1024 characters". Why?

discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In data.embeds.0.fields.0.value: Must be 1024 or fewer in length.
severe storm
#

or maybe if there is a way to read console outputs?

cyan quail
cyan quail
severe storm
cyan quail
#

eh...

spice oyster
# cyan quail actually not sure, can you post the full traceback?
Ignoring exception in modal <cogs.matchup.Matchup.MatchupModal object at 0x00000160F386E370>:
Traceback (most recent call last):
  File "C:\Users\Elitesparkle\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ui\modal.py", line 324, in dispatch
    await value.callback(interaction)
  File "c:\Users\Elitesparkle\Documents\GitHub\Snowball\cogs\matchup.py", line 35, in callback
    await interaction.response.send_message(embeds=[embed])
  File "C:\Users\Elitesparkle\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\interactions.py", line 727, in send_message
    await self._locked_response(
  File "C:\Users\Elitesparkle\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\interactions.py", line 975, in _locked_response
    await coro
  File "C:\Users\Elitesparkle\AppData\Local\Programs\Python\Python39\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.fields.0.value: Must be 1024 or fewer in length.
cyan quail
#

if it's a replit issue im not sure i can help you further, don't think there are any events before on_connect so you'd have to make do with your own function

young bone
cyan quail
#

embed field value is max 1024

spice oyster
#

Oh, right! I didn't think about that.

#

Thanks! First time using them. I was just trying the code from the guide.

cyan quail
#

i guess in general, if you're planning on outputting modal input back to the user it's a good idea to set a max input length

spice oyster
#

Cool! I'll need that for sure.

glossy socket
#

how can self.message in my view be NoneType all of the sudden?

class ConfirmBoost(discord.ui.View):
    def __init__(self, orders: list[list[str]]):
        super().__init__(timeout=120)
        self.orders = orders
        self.confirmed = False

    async def on_timeout(self):
        if not self.confirmed:
            await self.message.edit(content="You took too long! Try again", view=None, embeds=[])
#

could it have to do something with this:

await interaction.followup.send(embeds=embeds, view=ConfirmBoost(orders), ephemeral=True)
#

it used to be a message_send

cyan quail
#

but you could get around this by pre-assigning the view and then assigning it manually

#

e.g. py view = ConfirmBoost(orders) view.message = await interaction.followup.send(...)

glossy socket
#

thanks! that works

severe storm
severe storm
silver moat
#

if your Bot's object's name is client, yes

severe storm
cyan quail
severe storm
silver moat
severe storm
silver moat
#

check discord.ext.tasks

severe storm
#

i tried using tasks before, i think they stop when the bot gets ratelimited during runtime

cyan quail
#

depends on the ratelimit i guess...? most ratelimits just log a warning and don't actually crash the bot, the only example i can think of that does crash the bot is command syncing... which happens to be the issue here

silver moat
cyan quail
#

but arguably the library shouldn't really need extra mitigation from people using shared IP hosting, if you're ratelimited because of that then ultimately it's out of scope

severe storm
cyan quail
#

GuraShrug that's the cost of using replit

severe storm
silver moat
#

You can change replit containers using "kill 1"

severe storm
silver moat
#

if the other containers are not ratelimited, then you can run your bot again

severe storm
cyan quail
#

probably because replit wasn't as well known a year ago

#

it happens like clockwork

cyan quail
#

free hosting service pops up > "wow this is cool" > gets popular > ratelimits increase > another one pops up which isn't being ratelimited > rinse and repeat

silver moat
#

yeah, but you still need to manually restart it

silver moat
cyan quail
#

glitch, replit, heroku, and now railway's gaining popularity

silver moat
#

heroku not so much

cyan quail
#

fair enough, but ultimately there's a limit

severe storm
cyan quail
#

heroku's solution was to give up their free tier lol

silver moat
severe storm
#

most of the time my bot is not online is because it got ratelimited while runtime

silver moat
#

a few solutions:

  • have 2 bots: one being your main bot. the second bot would notify you if the other bot is down and you turn it on
  • not use replit.
proud pagoda
silver moat
#

There's railway.app render.com

proud pagoda
#

Cuz if you are you could potentially use microsoft azure

#

That's what I'm using atm to host my bot for free

severe storm
proud pagoda
#

Oh

#

Yea then nvm

proud pagoda
silver moat
#

also oracle

proud pagoda
#

Railway works if you've got a credit card

proud pagoda
cyan quail
#

if you have at least access to a debit card then there's a lot of <3$/month hosts you can find pretty easily which would be far more reliable than free options, but understandably not everyone has a bank account

young bone
proud pagoda
silver moat
#

?tag orcale

obtuse juncoBOT
#

dynoError No tag orcale found.

silver moat
#

?tag oracle

proud pagoda
obtuse juncoBOT
#

Oracle Cloud Always Free Tier

☑️ 2 virtual machine with 1/8 OCPU and 1 GB RAM each
☑️ 2 Block Volumes, 100 GB total. 10 GB Archive Storage
☑️ Outbound Data Transfer: 10 TB per month

For more info check: https://www.oracle.com/cloud/free/#always-free

severe storm
silver moat
verbal gulch
#

Why i get this error, again?

#

ummm ima use a google text file again

silver moat
#

is this a one-time thing?

verbal gulch
stiff fiber
#

Is it possible to defer an interaction, then send a modal to it afterwards?

molten wigeon
#

Not sure if this is the correct place to ask -- can anyone explain what the difference is between on_thread_remove and on_thread_delete? Looking at the lib, 'remove' scans through threads while 'delete' relies on an actual delete event. When would I need to use on_thread_remove, then?

EDIT: nevermind, I assume this is to do with how archiving works, and 'thread_remove' is dispatched when a thread is archived?

silver moat
cyan quail
molten wigeon
#

gotcha, thank you!

undone girder
#

when i use self.bot.unload_extensions i can still use the slash commands in the cog

#

is this indended behavior?

#

do i understand the command incorrectly

silver moat
undone girder
#

huh

#

weird

silver moat
slender abyss
#

how to read the data from on_raw_message_edit event

#

i get this error

#
new_page = msg.data.embeds[0].description.split("\n")[-1].split(" ")[-1].split("/")[0]
AttributeError: 'dict' object has no attribute 'embeds'
ebon hearth
#

for some reason, this is being thrown:

File "/home/container/.local/lib/python3.9/site-packages/discord/webhook/async_.py", line 213, in request
    raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 40060): Interaction has already been acknowledged.```
#

it happens when a command is called

#

the command is doing what it is expected to do and flufills it but this stil comes up for some reason

#

it happens in both commands where i ctx.defer() first and where i don't defer

fervent cradle
ebon hearth
#

most likely bad auth, check your username or password ig

fervent cradle
#

oh

slender abyss
slender abyss
#

we can use dot operation on dict right

#

so why this error when there is a 'embeds' key

#

?

fervent cradle
#

Anyone can refer me a good bot host? (for free if possible)

copper dew
#

there are some other options but i dont remember

fervent cradle
copper dew
#

i personally self host my own bots, and they run as docker containers

fervent cradle
#

actually the thing is I can't keep my laptop on continuously

#

so I need some good once to host

#

thanks for your help

copper dew
fervent cradle
copper dew
fervent cradle
#

with Oracle, I can connect to outside services like mongoDB and stuff right?

fervent cradle
#

ok thanks

copper dew
#

np

fervent cradle
#

why do I get this error?

#
Traceback (most recent call last):
  File "c:\Users\user\OneDrive\Desktop\Chores\VS Code\programs\discordpy bot\raeger.py", line 1, in <module>
    import requests, random, json, base64, asyncio, discord, time
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\__init__.py", line 64, in <module>
    from . import utils
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\utils.py", line 28, in <module>
    from .cookies import RequestsCookieJar, cookiejar_from_dict
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\cookies.py", line 164, in <module>
    class RequestsCookieJar(cookielib.CookieJar, collections.MutableMapping):
AttributeError: module 'collections' has no attribute 'MutableMapping'```
gilded viper
#

Im trying to use the bridge group with cogs and get error about missing callback argument. you can check previous msgs here. #general message and #general message

fervent cradle
#

Why don't I get my function option when I use them inside a slashcommand group

#

no option shows up

gilded viper
fervent cradle
# fervent cradle Why don't I get my function option when I use them inside a slashcommand group

I keep getting this error een when I copied the code from official docs

Ignoring exception in on_interaction
Traceback (most recent call last):
  File "C:\Users\.\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 127, in wrapped
    ret = await coro(arg)
  File "C:\Users\.\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 1201, in _invoke
    await command.invoke(ctx)
  File "C:\Users\.\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 356, in invoke
    await self.prepare(ctx)
  File "C:\Users\.\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 278, in prepare
    if not await self.can_run(ctx):
  File "C:\Users\.\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 373, in can_run
    local_check = cog._get_overridden_method(cog.cog_check)
AttributeError: '_MissingSentinel' object has no attribute '_get_overridden_method'```
#
The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\.\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 1009, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "C:\Users\.\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 359, in invoke
    await injected(ctx)
  File "C:\Users\.\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: AttributeError: '_MissingSentinel' object has no attribute '_get_overridden_method'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\.\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 382, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\.\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 1058, in on_interaction
    await self.process_application_commands(interaction)
  File "C:\Users\.\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 756, in process_application_commands
    await self.invoke_application_command(ctx)
  File "C:\Users\.\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 1013, in invoke_application_command
    await ctx.command.dispatch_error(ctx, exc)
  File "C:\Users\.\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 401, in dispatch_error
  File "c:\Users\.\OneDrive\Desktop\Chores\VS Code\programs\discordpy bot\raeger.py", line 203, in on_application_command_error
    raise error
#
  File "C:\Users\.\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 1009, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "C:\Users\.\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 359, in invoke
    await injected(ctx)
  File "C:\Users\.\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: AttributeError: '_MissingSentinel' object has no attribute '_get_overridden_method'```
#

and I don't even know what is wrong

#

heellllpp

#

updated code for reference:

slender abyss
#

Switch to version 2.0.1

fervent cradle
#

will the devs not fix this issue?

slender abyss
#

Dk im still using 2.0.1 and all works

fervent cradle
#

ok

slender abyss
full basin
#

Data is a dict

#

Dicts dont have attributes, they have indexes.

slender abyss
#

We cant use dot operation?

#

I thought we could

#

Hmm

full basin
#

It is a dict....

slender abyss
#

I see it was a feature in js

full basin
slender abyss
severe storm
#

hey, is it possible to read print outputs from the console?

gilded viper
#

Hey Im using bridge command. and trying to run command like this. !nutrition word1 word2. During this the variable's value is word1... But with the slash command variable's value is word1 word2 . So is this expected behaviour ?

@bridge.bridge_command()
async def nutrition(self, ctx: bridge.BridgeContext, food: str):
        print(food) # Prints `word1` with prefix command but `word1 word2` with slash command.
spice oyster
#

Is it possible to have a Slash Command in all servers except one, without listing all the servers and without having intents?

fervent cradle
fervent cradle
#

i am trying to implement a translate command, but cant find any api which is free or any wrapper which is asynchronous

copper dew
fervent cradle
#

oh damn

spice oyster
#

Is there a way to execute a Slash Command if "A or B" is true?
The current code only works if "A and B" is true.

    @commands.is_owner()  # A
    @commands.has_role("Contributor")  # B
loud holly
#

IIRC

spice oyster
#

It still goes through Roles, which isn't ideal for my case.

eternal wing
#

This code used to work a few months ago when i made the command, but now it just throws an error.


await ctx.send_modal(modal)```
Error:
```Application Command raised an exception: AttributeError: 'ApplicationContext' object has no attribute 'send_modal'```
barren portal
loud holly
#

1234 - Your Role ID
4567 - Contributor Role ID

@commands.has_any_role(1234, 4567)
#

I think this should work

#

you don't need to have the

@commands.is_owner()

since if you have that, I believe that'll then raise an error etc

fading granite
#

my bot registers slash commands as new slash commands when i host it somewhere else

#

is there a way to fix it?

west flume
#

Can someone help me?

import datetime, time ---#this is the important set for generating an uptime

from discord.ext import commands

#this is very important for creating a cog
class Uptime(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @commands.Cog.listener()
    async def on_ready(self):
        print(f'{self} has been loaded') 
        global startTime --------#global variable to be used later in cog
        startTime = time.time()--# snapshot of time when listener sends on_ready
        
        uptime = str(datetime.timedelta(seconds=int(round(time.time()-startTime))))
        
    @commands.slash_command(description="Get the bot uptime")
    async def uptime(self,ctx: discord.ApplicationContext):
        embed = discord.Embed(
            description=f"(uptime)",
            color=discord.Colour.blurple()
        )    
        
        embed.set_author(name="Uptime", icon_url="https://cdn.discordapp.com/avatars/836895718563250196/cafaf0d749d1aaa938f8c0bd7be4fa2d.png?size=1024")
        await ctx.respond(embed=embed)


def setup(bot)
    bot.add_cog(Uptime(bot))```
silver moat
silver moat
#

in other words, remove -s

west flume
fading granite
#

no these

#

you can't simply put -

west flume
#

Alr

silver moat
#

also please use an IDE like Visual Studio Code

fading granite
silver moat
fading granite
#

this is from one of my commands but they're pretty much the same @discord.slash_command(name="leaderboard", description="Check who's on top!")

silver moat
#

when you mean register as new commands, the same command is registered twice?

fading granite
#

this is the situation:
I have a slash command group with manage server default permissions
I override the permissions in a server
I hosted my bot in a new place
The slash commands are registered as new commands with the old ones being replaced
This resulted in the slash command group using back the default permission

fading granite
#

so this is normal?

silver moat
#

yeah

proud pagoda
#

when declaring the view, set timeout=300

#

So like this: my_view = discord.ui.View(timeout=300)

full basin
#

You have to override the on_timeout method

spice oyster
fervent cradle
#

how can we make such long buttons in pycord?

chrome skiff
fervent cradle
#

oh ic

#

i thought it was some new ui component lol

chrome skiff
#

no

fervent cradle
#

hey

#

original file size

#

file after pillow modifications (no change to resolution)

#

is there a way to lower this size quickly?

barren portal
glossy socket
#

hey, is it possible to run the discord bot without a listener? so i can run a second instance of the bot just to send updates in dm

glossy socket
cyan quail
glossy socket
#

and i want that cloud function to send updates of the process in the persons dm

cyan quail
#

could you not create it as a task and start it on button click instead?

glossy socket
#

you mean within the discord bot?

cyan quail
#

yes

glossy socket
#

nope it needs to be scalable

#

cloud function is the best way for what im trying to achieve

cyan quail
#

using a second instance of your bot is the opposite of scalable

glossy socket
cyan quail
#

if you want to override every single listener to do nothing then go ahead i guess, but in general with the presence of interactions in the api having two instances at once is bound to lead to issues

glossy socket
#

also when just sending updates to a dm?

cyan quail
#

?

glossy socket
#

i just want the cloud functions part to just send an update to dm nothing more

#

if it could be a simple http request itd be sufficient

cyan quail
glossy socket
cyan quail
#

afaik we don't have any functions to do it for you, you'd need to dig through the lib files to find what you want

#

it was somewhat discussed in a suggestion at #970398410790297730 message, but we can't really help you further than that

proud mason
glossy socket
silver moat
glossy socket
silver moat
glossy socket
young bone
#

How can I sync Channels with the Category permission or is that automatic?

cyan quail
lost lodge
#

why my button won't disable after press

    @discord.ui.button(label="Claim", emoji="✒️", custom_id="button_3", style=discord.ButtonStyle.gray)
    async def button_3_callback(self, button, interaction):
        button.disabled = True  # set button.disabled to True to disable the button
        button.label = "claimed!"  # change the button's label to something else
        embed = discord.Embed(title="Ticket claimed!", description=f"{ticket_user} you will be supportet now by {interaction.user.mention}")
        await interaction.channel.send(embed=embed, delete_after=10)
        embed1.remove_field(index=0)
        embed1.add_field(name="Support Status:", value=f"{ticket_user} is supported by {interaction.user.mention}")
        await embed1_send.edit(embed=embed1)
        ticket_topic = f"supported by {interaction.user.name}"
        channel = await interaction.channel.edit(topic=f"**User:** {open_ticket_topic_user_name} \n**User-ID:** {open_ticket_topic_user_id} \n**Status:** {ticket_topic}")
        await interaction.response.edit_message(view=self)```
proud pagoda
#

oh

#

hold on, it shoudl disable after 300 seconds after the last use, as per the docs:

Timeout from last interaction with the UI before no longer accepting input. If None then there is no timeout.

near hollow
#
                    coroutines = [webhook.send(embed=embed) for webhook in webhook_list] 
                    await asyncio.gather(*coroutines)```
~~Is there any way to put a try in the webhook.send part?~~

Adding ``return_exceptions=True`` seemed to have work in ``asyncio.gather``
hardy rune
#

How to I make a ctx.respond mention (just using role.mention doesn't ping and allowed_mentions doesn't help)?

hardy rune
#

no

silver moat
#

so use ctx.send

hardy rune
#

ohhh I see

#

so it's not possible to make it look like a response to a slash command, right?

silver moat
#

nope

#

I mean you can, but it won't ping

hardy rune
#

Alright, thank you!

woven gale
#

Good evening. I want to learn pycord. Does anyone have any ideas on the best way to learn this?

obtuse juncoBOT
woven gale
silver moat
#

yw

woven gale
# silver moat yw

Is it also in German? I can speak English, but you don't want to misunderstand me. xD

silver moat
woven gale
silver moat
#

If you don't understand anything, feel free to ask.

woven gale
#

👍

spice oyster
spice oyster
#

Hmm, I see. I don't need that, so maybe it's fine to keep it None.

silver moat
#

interaction.response.is_done()

fervent cradle
#

what does tis error mean

#

all emojis are valid

#

i mean they exist

fervent cradle
#

😴

silver moat
fervent cradle
silver moat
fervent cradle
#

Okay

fervent cradle
#

solved

#

thx @silver moat

fervent cradle
#
@bot.slash_command(name = "find",description = "Seach Pokemon dex entries!")
async def find(ctx, pokemon: str):
    p = pokeinfo(pokemon)
    print(p)
    if p != None:
        x, y, all_ab, all_type, img = p[0], p[1], p[2], p[3], p[5]
        HP, attack, defense, spatk, spdef, speed = p[4]["hp"], p[4]["attack"], p[4]["defense"], p[4]["special-attack"], p[4]["special-defense"], p[4]["speed"]
        embed = discord.Embed(
            title=f"{pokemon.capitalize()}",
            description = f"Pokedex result for **{pokemon.capitalize()}**:",
            color = random.choice(c_lists)
        )
        embed.add_field(name= "Weight:", value= f"{x}", inline = True)
        embed.add_field(name= "Height:", value= f"{y}", inline = True)
        embed.add_field(name= "Abilities:", value= f"{all_ab}", inline = True)
        embed.add_field(name= "Types:", value= f"{all_type}                                  ", inline = True)
        embed.add_field(name= "HP:", value= f"{HP}", inline = True)
        embed.add_field(name= "Attack:", value= f"{attack}", inline = True)
        embed.add_field(name= "Defense:", value= f"{defense}", inline = True)
        embed.add_field(name= "Special-Attack:", value= f"{spatk}", inline = True)
        embed.add_field(name= "Special-Defence:", value= f"{spdef}", inline = True)
        embed.add_field(name= "Speed:", value= f"{speed}", inline = True)
        embed.set_thumbnail(url = img)
        await ctx.respond(embed = embed)
    elif p == None:
        await ctx.respond("Not Found!")```
#

i keep getting the error on the last respond line

#

pokeinfo is a helper function*

#
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 911, in _invoke
    await self.callback(ctx, **kwargs)
  File "c:\Users\casho\OneDrive\Desktop\Chores\VS Code\programs\discordpy bot\raeger.py", line 723, in find
    await ctx.respond("Not Found!")
  File "C:\Users\casho\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\context.py", line 275, 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 796, in send_message
    await self._locked_response(
  File "C:\Users\casho\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\interactions.py", line 1057, in _locked_response
    await coro
  File "C:\Users\casho\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\webhook\async_.py", line 221, in request
    raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction

The above exception was the direct cause of the following exception:
  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: NotFound: 404 Not Found (error code: 10062): Unknown interaction 
#

anyone can tell why am I getting this error

fierce elm
fervent cradle
#

thanks for the response though

fierce elm
#

now my question, can I automatically delete a component/embed message on timeout?

fervent cradle
#

probably do asyncio.sleep(time)