#Basic Pycord Help (Quick Questions Only)

1 messages · Page 78 of 1

grizzled sentinel
#

They would have to send a message I believe. If they just click message but do not send anything I do not think that counts as user interaction.

#

But otherwise yes you should be fine

hardy crescent
#

i could not find any async pillow packages, can i use threading module for pillow?

proud mason
#

I would use asyncio.to_thread to call the blocking function

This puts it in a separate thread

#

So main thread which has the event loop is not blocked

hardy crescent
#

does it return the value?

vital timber
proud mason
#

You can even return values

proud mason
hardy crescent
#

thx

proud mason
#

Np

vital timber
proud mason
#

asyncio.to_thread manages everything for you

#

The threadpool executor and returning of result

#

Even context vars

vital timber
#

Yeah - but processpool specifically means you're not hogging your eventloop CPU if that's something you're worried about

proud mason
#

Process pool is difficult to work with imo. Because io between processes is not easy

#

Objects need to be pickled and sent through a pipe

vital timber
#

result = await loop.run_in_executor(my_process_pool_executor, my_pillow_task, timeout)

#

for trivial objects the pickling is rarely an issue

proud mason
#

Hmm

vital timber
#

yeah didn't mean to troll the help channel though, sorry!

hardy crescent
#

So if i use asyncio.to_thread with this function it should work?

def join_images(urls, r_id):
    images = []
    for i in range(len(urls)):
        bytes_ = httpx.get(urls[i]).content
        image = Image.open(io.BytesIO(bytes_))
        images.append(image) 
    canvas = Image.new("RGB", (512 * 3, 512))
    for i in range(len(images)):
        canvas.paste(images[i], (512 * i, 0))
    canvas.save(f"/tmp/{r_id}.png")
    return f"/tmp/{r_id}.png"
proud mason
#

Is pillow written in C? 🤔

Because then a process pool could be the best, as GIL might be released

proud mason
vital timber
#

just meant that if your pillow task is CPU intensive then to_thread is probably not the best solution

proud mason
#

True

vital timber
#

https://docs.python.org/3/library/asyncio-task.html#running-in-threads
This coroutine function is primarily intended to be used for executing IO-bound functions/methods that would otherwise block the event loop if they were run in the main thread.

proud mason
proud mason
#

This will be faster

hardy crescent
#

good idea

#

the code works now

#

thx

vital timber
candid coral
#

I need to store information about some settings that apply to the entire server. For example a specific channel for a specific command. A familiar advised me to use Json instead of Sqlite3. What is the best way for me to use?

proud mason
#

Json is not meant to be modified programmatically. It is ideal for network communication, but not as a database

candid coral
#

Thank you

candid coral
#

I have a small problem. I need to have only one row of data in the table, which is set when the bot is turned on. Is it possible to set variable values immediately when creating a table? It's Sqlite3

cyan quail
#

wouldn't you just do another instruction then commit last

candid coral
cyan quail
#

hm perhaps im misunderstanding

#

are you trying to create a table and insert a row into it at the same time?

candid coral
#

Yes

#

Apparently there is no other way

cyan quail
fervent cradle
#

Hey, quick question. How do i send dms using pycord?

silver moat
#

.rtfm user.send

winter condorBOT
fervent cradle
#

Alright, Thanks

jaunty raft
#

hey guys how can I send a followup message like ctx.followup.send for like pagination?

#

I mean like


import discord
from discord.ext import commands, pages

bot = commands.Bot(...)


@bot.slash_command()

async def slash(ctx: discord.ApplicationContext) -> None:
  await ctx.defer()
  pagination = pages.Pagination(["one", "two"])
  await pagination.send() # what must I pass as parameter?
  await ctx.followup.send()
young bone
#

maybe you mean interaction.followup.send()?

jaunty raft
#

yeah like that

#

or how must I send the pagination then as a followup

jaunty raft
cyan quail
#

ctx.interaction

jaunty raft
#

okay let me try

jaunty raft
fervent cradle
#

Hey uh. How do i get the name of the server where a command is sent?

silver moat
#

.rtfm applicationcontext.guild

fervent cradle
#

Ty

silver moat
fervent cradle
#

1 more question lol, whats the best way to store member data?

young bone
#

I use MongoDB

fervent cradle
#

Alright

young bone
#

Its not 100% great for this but ok for me

fervent cradle
#

I need to store a string

candid coral
#

How can I save time to Sqlite3 database?

proud mason
candid coral
#

I couldn't do it last time so I saved the month and day separately

proud mason
#

that happily accepts timestamps for me

#

even discord ids and stuff

#

sqlite also has a DATETIME column type, but i always found it weird to use

candid coral
#

I couldn't work with Datetime

candid coral
proud mason
proud mason
candid coral
#

Thank you

candid coral
#

How can I refer to a category by its ID? Method get_category(id) doesn't exist

cyan quail
#

you just use get_channel because categories are a type of channel

candid coral
cyan quail
#

that doesn't change anything...

candid coral
#

Do categories count as channels?

cyan quail
#

yes

candid coral
#

Oh, I'm sorry. Thank you for the help

pallid token
#

Is there any way to acknowledge a button push, but not send a text reply?

#

I'm looking to have a button that may be pushed multiple times in a short period of time and don't want to have to always be sending a message in response as that gets spammy and annoying.
It edits its own message to reflect the change anyway.

candid coral
pallid token
candid coral
#

But any button should always respond

#

If I'm not mistaken

young bone
#

but you could auto delete the messages

pallid token
pallid token
young bone
pallid token
young bone
#

With the editing you can get really fast a ratelimit but Im not 100% sure

candid coral
#

You won't be able to quickly press the buttons

young bone
#

^

candid coral
#

And double-clicking can also happen which is quite unpleasant

#

I could be wrong

pallid token
#

Yeah... Editing the original message it seems to result in a "Interaction failed". I get a 404 Not Found.

proud mason
proud mason
#

smth as simple as await interaction.response.edit_message(content=interaction.message.content) might work

but i really recommend defer and ignore

candid coral
#

I was wrong again, sadly

pallid token
#

Defer actually works perfectly.

#

Thanks guys 😄

coarse cargo
#

How can i get an user by the id with discord.utils?

coarse cargo
jaunty jewel
#

discord webhooks can used for interacting with users only if the bot is the hook creator

HOW TO MAKE THEM WITH APP COMMANDS! 💀

the docs have nothing about the webhooks and app commands but if they can interacting so they can make app commands, the idea that i tried to make an request to register a app command with the hook token and the hook id which is made with a normal bot but it fails with 401 :|

although even if its possible how the hook will respond in a channel if it wasn't assigned to..

#

hmm... this think tbh is the only thing i got can lead for like that

full basin
#

application webhooks are interaction responses

#

you cant manually create them

jaunty jewel
#

i mean this is the question trigger:|

cyan quail
#

That's a http bot

#

Which pycord technically can't do I think?

jaunty jewel
jaunty jewel
#

i mean how from the api side

cyan quail
#

Idk never worked with them

jaunty jewel
cyan quail
#

You'd be better off looking for a lib that supports them

jaunty jewel
#

@cyan quail it was a discord http/interactions application.command scope app with no bot profile (which is discord doesn't like idk why) and it looks like a webhook 🗿

cyan quail
#

Yes, that's a http bot

jaunty jewel
#

btw it would be cool if the hook have a something like that!

cyan quail
#

It might be supported in v3 but not in v2

jaunty jewel
cyan quail
#

Yeah

#

Specifically you can try to do it in pycord just by inviting the bot without the bot scope

#

And it might work to some extent, but there's a high chance of running into unusual errors because the library was designed around having an actual bot user

silver moat
cyan quail
#

yeah LOL

#

our first cve

silver moat
#

and hopefully our last

pallid token
#

RIP lol. What happened there?

#

Ahh CVE-2022-36024. Yup. That's fun.

fervent cradle
#

I keep getting an error stating "NoneType has no attribute edit". How can I update the view with the disabled button?

class mobileButton(discord.ui.View):

    def __init__(self, address: str):
        super().__init__(timeout=2)
        self.address = address

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

    @discord.ui.button(emoji="📱", label="Mobile", style=discord.ButtonStyle.grey)
    async def first_button_callback(self, button, interaction):
        await interaction.response.send_message(self.address, ephemeral=True)
fervent cradle
silver moat
#

is it deferred?

fervent cradle
#

Yes

silver moat
#

There is a known bug where the view's message isn't sent if the message was sent by a webhook.
As a workaround, you can set the view's message like so:

view = mobileButton(address=address)
interaction = await ctx.respond(embed=embed, view=view)
view.message = await interaction.original_response()

https://docs.pycord.dev/en/stable/api/models.html#discord.Interaction.original_response

fervent cradle
#

Okay, thank you!

proud mason
cyan quail
#

Eh

#

Seeing how fundamentally different http bots are, they should be their own class that's even lighter than client or bot

proud mason
#

I've done it shrug

#

True

#

Http bots shouldnt use the gateway

#

That was the original thought behind it iirc

proud mason
#

How do i always forget the "nt" when typing in mobile 😂

somber pelican
#

Couldn't find anything that worked for me

candid coral
#

How can I check if a member has access to a particular permission? Use guild_permissions gives me permissions code but I can't check particular

full basin
#

.rtfm guild_permissions

full basin
#

.rtfm discord.Permissions

quiet field
#

I am trying to get bridge to show descriptions when you use slashcommands

#

However, when I do this,

#

and run it as a regular command

#

I get the following error

#

discord.ext.commands.errors.BadArgument: Converting to "Option" failed for parameter "command".

solemn idol
#

Try using the Option Decorators :P

quiet field
#

I'm working with bridge

solemn idol
#

Yes they also work with bridge

#

Atleast last time I checked :P

quiet field
solemn idol
#

Gonna need to do a bit of searching there myself :v

quiet field
#

nevermind, I think I found it

solemn idol
#

O alright then :)

quiet field
solemn idol
quiet field
#

Got it, thank you

solemn idol
#

Those should just work with bridge too

candid coral
#

Is this fine?

full basin
#

It's just .ctx.author.guild_permissions.administrator

#

And that returns a boolean

candid coral
#

Thank you

candid coral
#
class Question(discord.ui.Modal):
    def __init__(self, ...):
        super().__init__(???)
        self.add_item(discord.ui.InputText(label="String name"))
        self.add_item(discord.ui.InputText(label="String name", style=discord.InputTextStyle.long))

    async def callback(self, interaction: discord.Interaction):
        embed = discord.Embed(title="Title name")
        embed.add_field(name="String name", value=self.children[0].value)
        embed.add_field(name="String name", value=self.children[1].value)
        await interaction.response.send_message(embed=embed)```

I decided to learn modal to be able to work with forms. I want to ask a few questions to make to understand how it works.

1) What does `discord.ui.Modal` pass to the class via super()?
2) Does the function inside a class should be called "callback"?
3) How does "children" work?
proud mason
agile snow
#

Is there a maximal time await view.wait() is working?
I have the problem, that the buttons of my view, stopped working after some time (several hours) without that the timeout event triggered. So somehow the thread waiting on that point is just killed after some (longer) time without processing the rest of the code after await view.wait(). I currently have no idea why

cyan quail
#

wait is useful for pausing the current code to wait for the view to end

#

meaning, if wait is triggered then the view is already stopped.

agile snow
cyan quail
#

because you should be using the callback to process the rest of your code

candid coral
#

The modals returns the value of strings in str, but I need to separate str from int. Should I use try-expect-finally?

cyan quail
#

if you just wait in a random command or other function and try to wait for several days, if something manages to kill that process you'd never know

cyan quail
#

oh i see

#

either try except, or use isdigit to validate it's an int

candid coral
#

Thank you

agile snow
fleet viper
#

Hi guys, I was toying around a bit with slash_command options and i came to the problem of updating the choices of one input on runtime.
I built a classic slash_command in a cog, following the github examples and it worked flawless with the @option(), constructor and the autocomplete parameter. I implemented it so that the autocomplete is passed a list and whenever i update the value of the options I run the bot.reload_extensions(<the Cog>) and it actually updates in discord. However when I try the same thing with using choices in the functions constructor, it stops updating the data. Is there a significant difference between them updating or am I messing something up?

young bone
fleet viper
#

the list starts with 0 items and i try adding one or two at max

#

I will try syncing the command

fleet viper
cyan quail
#

that's why autocomplete exists

fleet viper
#

ah i see

#

well i just like the aspect that you cant enter a wrong entry and get stopped right there by discord, while in autocomplete it just gives you hints of what you could enter but doesnt check it live. However its not really that big of a deal, thank you :)

tribal girder
#

help? I'm creating an afk command but this on_message event don't triggered, the user.id is already in the file but it's only printing until 3, idk why the if condition not triggered.

the data is a json from other files and don't have any problem when i print it

class Utils(commands.Cog):
    @staticmethod
    async def json():
        with open("f.json", "r") as f:
            return json.load(f)

    def __init__(self, bot):
        self.bot = bot
        self.load_afk = Utils.json()

    @commands.Cog.listener()
    async def on_message(self, msg):
        if msg.mentions:
            print("0")
            mentioned = [user for user in msg.mentions if user != self.bot.user]
            print("1")
            for user in mentioned:
                print("2")
                data = self.load_afk
                print("3")
                if user.id in data:
                    print("4")
                    await msg.channel.send(f"{user.display_name} is currently in AFK.\nReason: {data[user.id]}")
cyan quail
tribal girder
cyan quail
#

mhm

tribal girder
#

ill try

cyan quail
#

or even better, data.get(str(user.id))

quasi stratus
#

Hi, is there a way to add a custom check inside a cog so i can use it as an instance method ?
I need to get access to the bot variable which is an instance variable, currently i put the check in my main file that instance the bot and load all the extensions so i can access it and then i import the method but it doesn't feel like it's a good move :/
Maybe it's good but if there's a better way i take it

#
# main file : 
if __name__ == "__main__":
    # The informations available for the bot
    intents = discord.Intents.none()
    intents.members = True
    intents.guilds = True
    intents.messages = True
    intents.message_content = True
    intents.reactions = True

    josix = Josix(intents)
    josix.run()

def check_owner(ctx: discord.ApplicationContext):
    return ctx.author.guild_permissions.administrator or josix.is_owner(ctx.author)

# extension file
    @commands.slash_command(description="test owner")
    @commands.check(check_owner)
    async def test_own(self, ctx: ApplicationContext):
        await ctx.respond("All good")```
cyan quail
quasi stratus
#

hooo

candid coral
#

What do annotations do?

cyan quail
#

just defines a type for your type checker to verify

#

in the actual program they don't have a real function because python isn't a typed language

#

(though there are exceptions when you've explicitly made it functional, e.g. we can annotate with discord.Option)

candid coral
#

Thank you

uneven beacon
#

does anyone know how to setup and use ffmpeg on replit?

ocean pumice
#

Can someone help me with this code snippet? It is checking if the token is valid or not. To do so, it connects to the discord api and if it's successfully connected, it disconnects. And that's where I get a problem

def check_token_validity(token):
    try:
           
        @client.event
        async def on_ready():
            print("Valid token. Continuing...")
            #add_account_token(token)
            await client.close()
            return True
        client.run(token) 

    except :
        print("Sorry, it seems like this token is not valid.")
        return False```
#

I'm a piece of sht at coding so, if this makes you cringe, excuse me lol

#

This is the error I get, i forgor to post it Valid token. Continuing... Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x00000248FC3870A0> Traceback (most recent call last): File "C:\Users\sofia\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 116, in __del__ self.close() File "C:\Users\sofia\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 108, in close self._loop.call_soon(self._call_connection_lost, None) File "C:\Users\sofia\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 750, in call_soon self._check_closed() File "C:\Users\sofia\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 515, in _check_closed raise RuntimeError('Event loop is closed') RuntimeError: Event loop is closed Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x00000248FC3870A0> Traceback (most recent call last): File "C:\Users\sofia\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 116, in __del__ self.close() File "C:\Users\sofia\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 108, in close self._loop.call_soon(self._call_connection_lost, None) File "C:\Users\sofia\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 750, in call_soon self._check_closed() File "C:\Users\sofia\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 515, in _check_closed raise RuntimeError('Event loop is closed') RuntimeError: Event loop is closed Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x00000248FC3870A0> Traceback (most recent call last): File "C:\Users\sofia\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 116, in __del__ File "C:\Users\sofia\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 108, in close File "C:\Users\sofia\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 750, in call_soon File "C:\Users\sofia\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 515, in _check_closed RuntimeError: Event loop is closed

young bone
#

Do you know basic python?

tribal girder
#

💀

#

why check the token valid or not

full basin
#

why would you validate the token by running the bot, then closing the connection and then starting it again?

#

if the token is invalid the bot just wont run and pycord will raise an improper token passed error

solemn idol
#

Checking an event before running the code to even be able to check an event bigbrain

ocean pumice
# tribal girder why check the token valid or not

Because I need to check if it’s valid, literally
And if it’s not, ask for another one. Because that’d be shit to put an invalid token on the database and just having to go on the json and delete it if it’s not valid

#

It’s supposed to be a public project, not for me

#

Else i’d have done simpler

ocean pumice
#

Mindfucking isn’t it

#

You didn’t even try to understand it before saying your nonsense shit

somber pelican
#

i have never seen this error, what's the potential cause?

proud mason
#

?tag blocking

obtuse juncoBOT
#

dynoError No tag blocking found.

proud mason
#

oof

somber pelican
#

not using blocking, im using aiohttp

proud mason
#

any other libraries

somber pelican
#

i dont use any sync libraries at all

#

only redis.asyncio, aiohttp, and pycord

proud mason
#

hmm

somber pelican
#

oh and websockets too

proud mason
#

it might be due unstable internet too

somber pelican
#

but that's also async

somber pelican
#

this is completely fine right?

proud mason
#

mhm

#

the library will reconnect if needed

somber pelican
#

okay great thank you!

rose onyx
#

Hey there, I have a problem, can I get some help please

#

so I have a cog

#

Let me show the code in the cog

#
import discord
from discord.ext import commands
import asyncio


class Embeds(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @discord.slash_command(name="create_embed", description="Send an embed.")
    async def send_embed(self, ctx: discord.Interaction):
        await asyncio.sleep(1)
        await ctx.channel.send("Embed sent!")


def setup(bot):
    bot.add_cog(Embeds(bot))
#

this is the code in the cog

#

but every time I run the bot and attempt to run th create _embed slash command

#

it sends the message "Embed Sent", but says "the application did not respond"

#

any ideas why and how I can fix this?

#

@strange beacon @grizzled sentinel plz help, helpers

#

this should be a simple issue, but I can't seem to solve it

#

😭

#

I hate being a beginner

#

I look so dumb

strange beacon
#

It is a simple issue.

It is ctx.respond not send, you are getting a the application did not respond because you didn't.

rose onyx
#

it is channel.send(embed=embed) right?

rose onyx
#

and thanks a lot

strange beacon
#

Yes

#

Assuming you want to send the embed and the "embed sent" message.

rose onyx
#

well I am trying to make an embed builder command where the user sets the title and description and so on

strange beacon
#

Great, there is nothing in the code you have posted that has any embed code. So I helped with the issue at hand.

When responding to a / command you need to either respond or defer or you are going to get the application did not respond error.

rose onyx
#

I still get the error

#

oh god, this is tricky

rose onyx
#

I am doing something wrong fr

wintry wraith
#

why is this:

guild = await bot.fetch_guild(guild_id)
print(len(guild.members))```
returning 0, even though i have done
```python
intents = discord.Intents.all()
bot = commands.Bot(intents=intents)```
?
rose onyx
#

uh, no?

rose onyx
#

sorry I know what you mean

rose onyx
rose onyx
#

nah still got the error, damn

#

idk what I am doing wrong

rose onyx
#

I'll just read up about it and try to work it out myself ig

#

tricky tho ngl

gentle geode
#

Can anyone help me in my forum

rose onyx
young bone
gentle geode
#

Send me link to there please

rose onyx
rose onyx
young bone
gentle geode
#

You can check mine out
Its in the forum

cyan quail
rose onyx
rose onyx
# young bone Can you show the code again?
import discord
from discord.ext import commands
import asyncio


class Embeds(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @discord.slash_command(name="create_embed", description="Send an embed.")
    async def send_embed(self, ctx: discord.ApplicationContext):
        await ctx.respond("Embed sent!")


def setup(bot):
    bot.add_cog(Embeds(bot))
rose onyx
young bone
#

the same you load them

#

but with reload

cyan quail
#

or just restart the bot

rose onyx
#

I'm not that dumb lol

gentle geode
#

i need help making this code into a button
if the button is clicked it opens a new channelin that channel the /Apply'command would be use to get the embed with the questions

rose onyx
#

or maybe I am, idk, can't wwork this bug out

rose onyx
young bone
#

did you also save the files?

rose onyx
#

maybe try replicating it

#

I can send my code if you want

#

like all of it

#

I am very frustrated

#

been trying to solve it so long

#

and such a seemingly simple issue

young bone
#

what is the py-cord version?

rose onyx
#

let me see

rose onyx
#

2.4.1

tribal girder
#

how to add cooldown to sub event? i want to add cooldown for the sub event 1

@commands.Cog.listener()
async def on_message(self, msg):
    if msg.channel_id == 123:
        if "hi" in msg.content:
            await msg.channel.send("hello")
    if msg.channel_id == 321:
  #sub event 2
#

so the bot not sending again the hello msg for a specific time

tribal girder
#

all user

#

is it possible?

young bone
#

you could save something like a number and use task.loop to change it after some time again

gentle geode
#

Anyone gonna help me

#

#1108677291476779058

young bone
gentle geode
#

Oky but i am waiting a long time

full basin
#

You waited 2 hours.

gentle geode
#

Yes

quasi stratus
#

Is there a way to get \n character in slash command option ?
If i put one it's just ignored and print it, it does not add a newline :/

lethal nexus
#

I guess I can compare it to the vanity invite of the guild

violet heron
#

How can I make sure that the “this interaction failed” error doesn’t pop up?

#

This one

#

My code works normally and it still pops up, I just want to disable it

young bone
#

Its from discord and not from py-cord

proud mason
quasi stratus
#

(Or editing the original response)

violet heron
proud mason
violet heron
proud mason
#

but you do have a solution

#

just defer the response. message components are not required to send a followup

violet heron
#

Wdym

young bone
#

ctx.defer()

violet heron
#

Ah ok

#

Ty

proud mason
#

uh

#

buttons dont have ctx...

#

await interaction.response.defer() that

#

@violet heron ^

young bone
#

oh

violet heron
#

Yeah that the problem

#

Every time I call that I get button object has no attribute response

violet heron
#

Yeah

proud mason
#

the parameter order is self, button, interaction

violet heron
#

Yeah

proud mason
#

then you might have dpy installed

violet heron
#

I don’t

proud mason
#

show pip list

violet heron
#

Is it ok if I get back to you

#

I’ll be back in like 20 minutes

proud mason
#

sure anytime

#

no rush

violet heron
# proud mason no rush

aiohttp 3.8.3
aiosignal 1.3.1
argon2-cffi 21.3.0
argon2-cffi-bindings 21.2.0
async-timeout 4.0.2
attrs 22.2.0
cachecontrol 0.12.11
cachy 0.3.0
certifi 2022.12.7
cffi 1.15.1
charset-normalizer 2.1.1
cleo 0.8.1
click 8.1.3
clikit 0.6.2
crashtest 0.3.1
cryptography 38.0.4
debugpy 1.6.5
discord 2.2.3
discord-py 2.2.3
distlib 0.3.6
filelock 3.9.0
flask 2.2.2
frozenlist 1.3.3
fuzzywuzzy 0.18.0
html5lib 1.1
idna 3.4
iso8601 1.1.0
itsdangerous 2.1.2
jedi 0.18.2
jeepney 0.8.0
jinja2 3.1.2
keyring 21.8.0
levenshtein 0.21.0
lockfile 0.12.2
markupsafe 2.1.2
msgpack 1.0.4
multidict 6.0.4
numpy 1.24.1
openai 0.27.6
packaging 23.0
parso 0.8.3
passlib 1.7.4
pastel 0.2.1
pexpect 4.8.0
pip 22.2.2
pkginfo 1.9.6
platformdirs 2.6.2
pluggy 1.0.0
poetry 1.1.11
poetry-core 1.0.8
protobuf 4.21.12
ptyprocess 0.7.0
pycparser 2.21
pycryptodomex 3.16.0
pyflakes 2.5.0
pylev 1.4.0
pyparsing 3.0.9
pyseto 1.7.0
python-levenshtein 0.21.0
python-lsp-jsonrpc 1.0.0
pytoolconfig 1.2.5
rapidfuzz 2.13.7
replit 3.2.5
replit-python-lsp-server 1.15.9
requests 2.28.2
requests-toolbelt 0.9.1
rope 1.7.0
secretstorage 3.3.3
setuptools 63.2.0
shellingham 1.5.0.post1
six 1.16.0
toml 0.10.2
tomli 2.0.1
tomlkit 0.11.6
tqdm 4.65.0
typing-extensions 3.10.0.2
ujson 5.7.0
urllib3 1.26.14
virtualenv 20.17.1
webencodings 0.5.1
werkzeug 2.2.2
whatthepatch 1.0.3
yapf 0.32.0
yarl 1.8.2

#

turns out it was, idek how

proud mason
#

?tag replit

obtuse juncoBOT
violet heron
young bone
#

Also py-cord is not installed

violet heron
#

💀

#

Hold up

modest mica
#

Am I the only one, who has issues with discord.Member at that moment?
The context: I made a slash command, which can add people to voice channels (connect permission), but type=discord.Member stopped working, when I start to type someone, it doesn't show anyone, also, when I try to tag someone, it gives this error back:
'str' object has no attribute 'id'

#

This issue is related to discord's new name system?

fervent cradle
#

How would I auto start a scheduled event at the event's start time? i.e. Event is created to start in 72 hours and the bot makes the event go live on time.

modest mica
modest mica
# full basin Code
async def szoba_hozzaadas(self, interaction: discord.Interaction,
                              first: discord.Option(name='felhasznalo', type=discord.SlashCommandOptionType.mentionable)):
full basin
#

Why you have interaction?

#

And the option should be first: discord.Option(discord.Member, name="...")

zinc cloak
#

Is message.reactions.me referring to the discord bot itself?

cyan quail
zinc cloak
fervent cradle
#
 res = await ctx.reply("Connecting to Database")

Is mentioning/pinging the author off in reply/respond?

#

How do i mention the author the context of ctx is BridgeContext

cyan quail
#

unless you physically add a mention but eh

fervent cradle
#

ohh

#

thanks

solemn idol
#

wait nvm

#

(deleted my previous msg :) )

jaunty jewel
#

tbh i have no idea how to edit a component response message after sending

because the interaction.response.send_message() returns a interaction object

and i have no idea to edit that boui... :)

#

however msg.edit()

edits the og cached message that interaction belongs to :|

cyan quail
jaunty jewel
cyan quail
#

in 2.5(?), we've introduced interaction.respond and interaction.edit to make this more straightforward

cyan quail
cyan quail
#

not released yet

jaunty jewel
elfin dagger
#

is there any way for a bot to have this thing or can they only have the title like "playing..."

silver moat
elfin dagger
#

F 😔
alright ty

undone falcon
#

Does someone know why this error is occuring ? I check and they inherit from the base Exception

 class    except Forbidden | NotFound:
TypeError: catching classes that do not inherit from BaseException is not allowed
#

nvm I just use the wrong syntax for the except

proud mason
#

Persistent views are made the same way regardless of cogs or not

proud mason
#

and where are the view classes defined?

#

if you have your views in the same files as cogs, then just add them in an on_ready listener in the cog. like this-

import discord
from discord.ext import commands

class MyView(discord.ui.View):
  ...

class MyCog(commands.Cog):
  ...
  
  @commands.Cog.listener()
  async def on_ready(self):
    self.bot.add_view(MyView())
#

DO NOT define your views like this

import discord
from discord.ext import commands

class MyCog(commands.Cog):
  ...
  class MyView(discord.ui.View):
    ...
jaunty raft
#

for example if the view is

class testView(discord.ui.View):
    def __init__(self, a: int, b: int) -> None:
        self.result = a + b
fleet viper
ocean pumice
fleet viper
#

nice

nimble rose
#

Hi I have problem with guild.members in main bot file it returns empty list. But when i do same thing in cog it works fine.

target_channel = await client.fetch_channel(values[1])
print(target_channel)
target_guild = await client.fetch_guild(guild_id)
print(target_guild.members)
online_members = 0
for member in target_guild.members:
     if member.status == discord.Status.online:
     online_members += 1
full basin
#

Use get_guild

nimble rose
#

ok thanks it works

uneven beacon
#

hey!
i have a random bug that i dont know how to fix

im running this code on replit

@bot.event
async def on_voice_state_update(member, before, after):
    target_channel_id = 989472704249884672 

    if after.channel and after.channel.id == target_channel_id:
        if not bot.voice_clients: 
            voice_channel = await after.channel.connect()
            print("Voice activated")        
            voice_channel.play(discord.FFmpegPCMAudio(source='test.mp3'))```
it doesnt print anything and doesnt play the sound
it seems like nothing after ```voice_channel = await after.channel.connect()``` gets activated
young bone
uneven beacon
young bone
#

Update to 2.4.1

uneven beacon
young bone
#

Replit is really bad

uneven beacon
fervent cradle
#

how can i get the id / name of a command thats in a slash group?

young bone
fervent cradle
#

okay thanks

fervent cradle
#

can someone point me towards a place for good embed styling

grizzled sentinel
#

What do you mean? There are a few websites that allow you to design an embed than you can use that design in your code. Or do you mean the docs?

fervent cradle
#

design embed

#

i can make them but mine look pretty crappy

grizzled sentinel
#

I dont think there is really a official guide. But my suggestion is you use fields to split up everything that could be split up. Don't mash everything into a description or 1 field.

fervent cradle
#
async def createVerificationEmbed(self, ctx, gameName, currentCountryIcon, targetCountryIcon, currentcountryName, targetName):
        res = discord.Embed(
            title="Username Verification",
            description=f"{ctx.author.mention} change the country flag of {gameName}",
            color=discord.Color.dark_gold(),
            timestamp=discord.utils.utcnow()
        )
        res.add_field(
            name="From",
            value=f":{currentCountryIcon}:: {currentcountryName}",
            inline=True
        )
        res.add_field(
            name="To",
            value=f":{targetCountryIcon}:: {targetName}",
            inline=True
        )
        return res

thats what m doing rn

grizzled sentinel
#

I think that looks good. You could add the image of there profile picture

proud mason
grizzled sentinel
fervent cradle
#

also can i edit the orignal response which did not have any embeds to have an embed?

res = ctx.respond(content="Some text")
res.edit(embed = someEmbed)

can this be done or should the edit only contain the parameters present in the orignal response

#

i tried using res.edit() and res.edit_original_response() but none worked
they had different parementers than the orignal responses

proud mason
#

You awaited them right

solemn idol
quasi stratus
#

Hi,
In a multiple selction (discord.ui.select() etc...) there's no way to have values as int for each selection ?

I only see strign or custom ones like role, channel or mentions :/

quasi stratus
#

🥲

cyan quail
#

though nothing stopping you from converting it after

quasi stratus
#

That's what i'm doing

#

I just had some hope xD

#

Thx for the answer

grizzled sentinel
cyan quail
#

yeah but value still has to be a string

quasi stratus
grizzled sentinel
#

Oh, sorry

grizzled sentinel
quasi stratus
#

Np ^^

cyan quail
#

no, value is still passed to discord

grizzled sentinel
#

Ah ok. Do they do something with it?

cyan quail
#

well it has to be stored there

#

same with custom_id

#

let's say you work with the raw api without any lib features, if you just recieve raw interaction data then you'd need that value from them

grizzled sentinel
#

I thought it would be something that would only worked when the view was in cache

cyan quail
#

not necessarily, it's more or less all on custom_id

grizzled sentinel
#

👍

cyan quail
#

whenever you add_view you're adding to a dict which uses custom_id (among some other stuff) as the key

#

so then on_interaction pulls from there

fervent cradle
cyan quail
#

if you wanted, you could completely ignore pycord's callback system and just use on_interaction listeners

fervent cradle
#

can anyone tell me why my intents arent working?
i load them up like this


# Configure the intents
intents = Intents.all()

# Create the bot
bot = MatrixBot(command_prefix="/", intents=intents, case_insensitive=True)``` yet they still dont work
astral python
#

hi

#

hi

elfin dagger
gleaming falcon
#

General Python question. So.. say I'm using a method in a Cog as a callback to another part of the application. It seems the callback is mapped by memory address? ("bound method mycallback of object at 0x12345" etc). So does that mean if I were to reload the Cog, those callbacks are now invalid?

If so, is there any way to assign a callback so that it survives a Cog reload?

gleaming falcon
#

Although the old Cog reference does still seem to be 'active', so I guess that's not the problem.

What I'm trying to do is determine if a callback has already been registered. But when I reload a Cog, the existing callback does not == the new callback, and I'm having trouble figuring out the best way of doing so

#

Hm. callback.__func__.__code__ is equal. But I still have questions on whether the "existing" callback will even fire. It didn't seem to in my testing but I could have been doing something wrong.

solemn idol
gleaming falcon
#

nm, I think my whole premise was wrong and there was simply an issue in my callback 😅
But I did learn that I cannot blindly compare the callbacks to determine if it's registered; .__func__.__code__ does allow me to make that determination. Unsure if there's a less convoluted way

candid coral
#

How can I find out the ID of a channel just created by the bot? In addition to searching for its ID by name

candid coral
#

Yes

cyan quail
#

just assign it to a variable ```py
channel = await guild.create_text_channel(...)

now access channel.id```

candid coral
#

Thank you

#

but.. I can't find a channel permissions change where one can specify a channel rather than use the selected one

#

.set_permissions(target, overwrite, permissions, reason) — there is no parameter for a channel. Then what should I use?

cyan quail
#

e.g. use guild.get_channel(id) or discord.utils.get(guild.channels, name="...")

candid coral
cyan quail
candid coral
cyan quail
#

https://docs.pycord.dev/en/master/api/models.html#discord.TextChannel.set_permissions
some of the provided examples ```py
await message.channel.set_permissions(message.author, read_messages=True,
send_messages=False)

Deleting overwrites

await channel.set_permissions(member, overwrite=None)

Using PermissionOverwrite

overwrite = discord.PermissionOverwrite()
overwrite.send_messages = False
overwrite.read_messages = True
await channel.set_permissions(member, overwrite=overwrite)```

cyan quail
candid coral
#

Yes

cyan quail
#

then use channel = guild.get_channel(id)

#

and then you can do channel.set_permissions(...)

candid coral
#

oh, I'm stupid, I'm sorry. Thank you again

candid coral
#

How does overwrite work?

cyan quail
#

Overwrite is also useful for modifying specific perms without damaging the whole system

candid coral
#

Where does information come from? From category or role settings?

cyan quail
#

e.g. if you just wanted to edit someone's send_messages perm you want to use overwrites_for: py o = channel.overwrites_for(member) o.send_messages = False await channel.set_permissions(member, overwrite=o)

candid coral
#

I get it

cyan quail
#

this would effectively mute a specific member

vapid pumice
#

How to retrieve a webhook URL? I understand retrieving a list of webhook objects from a channel, an ID from a Webhook.Message, but I can't figure out how to get the URL

vapid pumice
vapid pumice
cyan quail
#

uhh if it's from a message, let's see...

vapid pumice
#

I thought there would be some way to use the ID to fetch since you can't get URL from WebhookMessage

#

But it seems you always must use the URL

#

I tried to use a for loop to checkIDs, but Webhooks aren't iterable

#

I feel like I'm missing something though because I'm pretty sure discoHook utils does this from just a message object

cyan quail
#

probably can't get it from a message for security reasons

#

might be wrong though

vapid pumice
#

Okay, I'll figure out something! Thanks <3

#

@cyan quail Found the solution around here! ^-^
#1057705183905329182 message

#

Can't get the webhook, but can get the WebhookMessage object which is what I need here

cyan quail
#

ah nice

normal tusk
#

there is a way to remove the bot profile from the new applications NekoCatBored

cyan quail
#

are you asking if there's a way or just saying it

normal tusk
cyan quail
#

you can't

#

never been able to delete a bot user

#

unless, of course, you delete the whole app

normal tusk
proud cargo
#

All of the bots I have running just went down at the same time; does this traceback indicate a connection loss or something else?

young bone
#

How many bots are they and are you already at the 1000 times starting the bots?

young bone
#

You have a limit of 1000 times that you can start a bot

proud cargo
#

im not aware that im up to that

young bone
#

If you have like 100 bots and do that 10 times you are at the 1000 and all your bots shutdown

proud cargo
#

i dont see why theyd all run fine for a week with no restarts then randomly shut down

proud cargo
young bone
#

Idk how

proud cargo
#

oh and all the bots restarted and now work fine

young bone
#

weird

proud cargo
cyan quail
#

i'll push a fix, but i recommend downgrading to 2.4.1 instead

cyan quail
proud cargo
#

Ah like discord audit logs

cyan quail
#

yes

#

the reason this happened is because the audit log entry had a user_id of None, which we thought shouldn't be possible

proud cargo
#

@cyan quail

#

That looks like the culprit

cyan quail
#

huh...

#

do you know who did this? or maybe dyno themselves could have... not sure

proud cargo
#

Don't know how it would've went to unknown user, I've never seen anything like that before

cyan quail
#

yeah theoretically that should be impossible

#

but the more you know i guess

normal tusk
#

interactions messages have an issue with the animated emojis ?

i mean two of the functions are the same, just one of them are configured to work with the interactions and the other one works with the App context

silver moat
normal tusk
silver moat
normal tusk
silver moat
#

interaction webhooks?

#

aka followups

normal tusk
silver moat
#

yes

normal tusk
normal tusk
#

💀

silver moat
#

it's on the top

normal tusk
silver moat
#

and also probably explicitly enable use external emojis on the bot role

silver moat
#

could you just try

normal tusk
silver moat
#

oof

normal tusk
young bone
#

can you show the code for the emoji?

silver moat
normal tusk
silver moat
#

because you're code looks fine

#

assuming all the IDs and stuff are correct

normal tusk
#

lemme try other thing

young bone
#

what is with the a:?

silver moat
young bone
#

oh

silver moat
#

unless it isn't animated PeepoPeek

young bone
#

If its not animated, it would explain why its not working

normal tusk
#

my head hurts me rn 😭

silver moat
#

for the @everyone role

normal tusk
# silver moat ?

bro the user are the same everyone role (likely haven't any role)

young bone
silver moat
normal tusk
#

and two of the messages on the same channel and ye the channel are enabled the external emojis

normal tusk
#

@jaunty jewel

silver moat
#

i wouldn't know, but ok then

silver moat
#

it's still open?

young bone
#

well, you could try it without admin and see if it works

normal tusk
young bone
#

you still cannot see names in the embed if you mention someone

normal tusk
#

i will just make it send a new message and defer the interaction cuz i have no mind for that kek

normal tusk
normal tusk
#

🗿

#

where the issues starts to appear NekoCatBored

#

this command are working on dms and.. ugh

#

aughhhhhhhhhhhhhhhhhhhhhhhhhh

HOW THE WORLD THIS THING EVEN POSSIBLE

THIS IS A DM AND THE BOT JUST SENT ME THE EMOJI BEFORE WUHS WORNG WITH IT!!!!!!!!

#

(THIS IS A ENTIRE NEW MESSAGE NOT A FOLLOW UP)

full basin
#

girl spamming wont take u anywhere to solve it

coarse cargo
#

Hey there, is possible to use in autocomplete the member object defined in an option before? I don't want to use the member object of the user who is executing the command

#

Maybe ctx.options[0]?

#

nvm

#

i need to use ctx.options["myoptionname"]

normal tusk
normal tusk
graceful brook
#

Does anyone know how to use permissions for commands and/or buttons? I'm not sure if its possible with commands, but I want it so if a user does not have a specific permission, it will give that "Missing Permissions" errors below the buttons in red.

grizzled sentinel
#

For commands you can use default permissions

#

.rtfm default_permissions

winter condorBOT
grizzled sentinel
#

for buttons (or commands) you will have to compare the permissions for the user to the permissions you want. I dont think there is a way to do this

"Missing Permissions" errors below the buttons in red.

fervent cradle
#

how can i send an interaction to a specific channel?

grizzled sentinel
#

You can only send an interaction response to the current channel. You can send an addition message to another channel though.

fervent cradle
#

yeah i have a message which gets sent to the current channel with a confirmation, how can i send a message to another channel would it also work with a button?

grizzled sentinel
#

ctx.channel.send() to send to another channel. And you can still have a view=. Views work on normal messages.

candid coral
#

How can I find out a server inside the View class in the __init__ function?
self.message.guild.id doesn't work

grizzled sentinel
#

What are you trying to do?
I think you would have to pass guild.id when you create the view

fervent cradle
grizzled sentinel
#

You can but you would still have to respond(send/edit/delete message, etc) to the button interaction. A bit annoying but not much we can do.

fervent cradle
#

that's honestly fine since it will be the final message for the giveaways, there will only be another button to enter, how would i do it though?

candid coral
grizzled sentinel
winter condorBOT
grizzled sentinel
#

one og those actions. Feel free to ask if you still dont understand

grizzled sentinel
candid coral
grizzled sentinel
#

It doesnot have to be I was just asking

candid coral
#

I always create a class separately

fervent cradle
grizzled sentinel
candid coral
#

Yes, I will do it

#

I just thought that you can find out inside the class, it turns out I can't

grizzled sentinel
fervent cradle
#

ahh okay thanks, ill try

#

oh but i still dont know how to send it, like do i do interaction.channel_object.response() or followup or i change it entirely

grizzled sentinel
#

channel_object.send(view=view)

fervent cradle
graceful mason
#

how to run a function when any slash command runs?

candid coral
#

To add a new variable to the table on Sqlite3 do I need to recreate it?
For example, there is a table with 5 variables and I need to add 6th

full basin
candid coral
coarse cargo
#

Max number of options to choose from with autocomplete?

young bone
worn void
#

how do I make a utils file with my cogs? like a post log function in a class from another file I can call that sends a message to a channel with given values? how do I pass the bot object?
Utils.utils.PostLogs(self=self, line1="Test Log", line2="Test Line 2")
can I just pass self like this?
then call self.bot in the class?

proud mason
worn void
#

then can I call it with this?

    @discord.slash_command(name="test_log")
    async def test_logging(self, ctx, header, content, footer, color):
        await utils.Utilities.PostLog(self=self, header=header, content=content, footer=footer, color=config.embed_color)
        await ctx.respond("Send log!", ephemeral=True)

#

nvm ^ it does work first try too lol nice

proud mason
worn void
proud mason
#

Why use a class?

worn void
#

idk

#

i could just remove the class

#

it wouldnt change anything

proud mason
#

Yeah lol you don't really need one

worn void
#

better for grouping if i make more utils

proud mason
#

They all would still be accessible through utils file

worn void
proud mason
#

You can fix that with better imports

worn void
#

i already did

proud mason
#

Nice

worn void
#

import cogs.utils.utils as utils

worn void
halcyon gorge
#

Seeing a lot of warnings of not doing change_presence in the on_ready command, any reason why?

halcyon gorge
#

no warnings in console, just on stackoverflow

silver moat
worn void
#

well read the post

halcyon gorge
candid coral
#

What function can I use for message ID that works like get_role()?

fervent cradle
#

im creating a giveaway command, how should i go about checking the time if the giveaway has ended?

candid coral
#

I didn't find it

young bone
#

Did you even search for it at the docs?

uneven beacon
#

is there still a way to play youtube videos with a pycord bot?

serene spindle
uneven beacon
serene spindle
#

Send the link then ig

#

If you mean in the embed image, you can try putting the link there

#

I doubt that’ll work tho

worn void
#

does anyone have a warning command using mysql that I can look at? I just dont understand tutorials on mysql and it would help me way more of someone had a command to manipulate sql that I can base my warning system after? (it doesnt matter if its dpy or slash commands because im only interested in the sql calls)

silver moat
#

?tag how2sql

proud mason
worn void
candid coral
fervent cradle
worn void
worn void
#

soo....

import mysql.connector as sql
 
mydb = sql.connect(
    host = "",
    user = "",
    password = ""
)

cursor = mydb.cursor()


cursor.execute("CREATE TABLE warnings(id int, warns int)")

??

#

like I said I dont have a clue what im doing so just showing me that isnt very helpful... as I dont know how sql works or how to use it with python

fervent cradle
#

i use postgres so i dont know the syntax for mysql in python so i cant help there, also, int can hold i think 10 digits so not useful for storing user ids

worn void
fervent cradle
#

bigint can store up to 19 digits

candid coral
#

How can a bot delete a message what was sent it past run?
client.get_message(id).delete() can't see these messages

young bone
#

what are your intents?

candid coral
normal tusk
#

are you sure the bot have access to that channel?

#

btw discord.Intents.all() is more then enough to get the bot up and running with every single intent :/

candid coral
#

After restarting it stops accepting previously sent messages

#

If a message to be deleted is sent in the same launch where it needs to be deleted, then everything works

normal tusk
#

try to print the message obj

see if the method is returning a obj or not

if it returns None so the bot aren't able to fetch the message or there is other issue :/

normal tusk
#

ik that's why i mentioned that

rare ice
candid coral
#

Thank you

young bone
rare ice
#

yeah thats what i meant

fervent cradle
#

so im tryna make a scratch command and have this

@bot.command()
async def scratch(ctx):
    rewards = ['reward1', 'reward2', 'reward3', 'reward4', 'reward5', 'reward6', 'reward7', 'reward8', 'reward9']
    scratched = [False] * 9

    async def scratch_button_callback(button: discord.ui.Button, interaction: discord.Interaction):
        index = (view.children.index(button))
        if not scratched[index]:
            reward = random.choice(rewards)
            rewards.remove(reward)
            scratched[index] = True
            button.emoji = '💰'
            button.style = discord.ButtonStyle.success
        await interaction.response.edit_message(view=view)

    view = discord.ui.View()
    for i in range(9):
        button = discord.ui.Button(style=discord.ButtonStyle.secondary, emoji='📦', label='', row=i // 3)
        button.callback = scratch_button_callback
        view.add_item(button)

    message = await ctx.send('Scratch the boxes to reveal your rewards!', view=view)
``` but when i press any of the buttons it creates, i get:

```Ignoring exception in view <View timeout=180.0 children=9> for item <Button style=<ButtonStyle.secondary: 2> url=None disabled=False label='' emoji=<PartialEmoji animated=False name='📦' id=None> row=1>:
Traceback (most recent call last):
  File "C:\Users\Acer\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ui\view.py", line 382, in _scheduled_task
    await item.callback(interaction)
TypeError: scratch_button_callback() missing 1 required positional argument: 'interaction'
silver moat
fervent cradle
#

oh im stupid, thanks!

silver moat
#

imo, from what I can see, your code would be better if you subclass instead of creating button objects

normal tusk
worn void
#

how do I properly access a mysql database with a pycord command?

silver moat
#

for mysql

worn void
#

im using mysql.connector

fervent cradle
#

wtf

worn void
fervent cradle
#

where else should i?

worn void
worn void
silver moat
fervent cradle
#

i will eventually, i tried it earlier in a class and it was so annoying to get it to work

silver moat
fervent cradle
#

very true

worn void
silver moat
#

you should be able to access your database just like normal inside of a pycord command callback

worn void
fervent cradle
silver moat
silver moat
distant blade
#

for some reason it just doesnt work anymore

silver moat
#

pip list and send output

distant blade
silver moat
#

?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 ?tag git to find out how to install git.

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

silver moat
#

step 1

young bone
#

also py-cord 3.0.0

#

?

silver moat
#

also not sure where you got a py-cord v3 stable

distant blade
#

the webstie?

#

now im getting

silver moat
#

kill terminal

distant blade
#

done

#

still there

silver moat
distant blade
#

im not calling the v3

#

thats import pycord

silver moat
#

well, there's no py-cord 2.x.x

distant blade
#

i just deleted everything and reinstalled seemed to work

#

now it downloaded2.4.1

silver moat
#

yay

fervent cradle
#

Dont know where this question belongs but is there a way to convert this relative timestamp into seconds instead of mins when above 60 seconds
<t:1684657000:R> Gives -> <t:1684657000:R>

#

also is there any other way of adding a timer to an embeded/text response

stable cradle
# fervent cradle also is there any other way of adding a timer to an embeded/text response

That's the only "official" way to do it. Unless you're going to edit your message every minute which is not practical this is the best way to do it. Here's an example of how I use it in my code.

epochtime = int(time.time())
timez = (60*60*hours) + (60*minutes) + seconds
new_epoch = epochtime + timez
embed2 = discord.Embed(title ="Moderation Timeout",description=f"You have been timed out in {ctx.guild.name}. It will end <t:{new_epoch}:R>")
#

now let me ask my own question

How can I kick people from a specific guild? I tried this but it doesn't kick the user.

gulidz = 1094233212257042544
await gulidz.kick(user=user, reason=f"{reason} - {ctx.author}")  
fervent cradle
#

or if you are using cogs and have self.bot then

gulidz = self.bot.get_guild(guild_id)
await gulidz.kick(...)
#

m not sure if get_guild() is await or not but you can check it out

timber skiff
#

How could you go about locking a thread programmatically?

#

I don't see a specific method for it under discord.Thread

#

Nvm, found it.

stable cradle
#

let me try

#

yes it worked ty so much

fervent cradle
#

Is there a way yet to access the new global display name?

fallen cove
#

Any recommendations for shortening big if statements. E.g if role 1 in member.roles:
Do x
.
.
.
To role 20

fervent cradle
fallen cove
fervent cradle
fervent cradle
# fallen cove Yup
result = {"1": [], "2": [], "3": []} # The roles you're looking for
for i in range(len(result):
   if int(i) in member.roles: # Check if the member has the role
      result[i].append(member.id) # Add the member to the list
#

I think that's what you're looking for

fervent cradle
#

yw

#

(updated 2 things)

stable cradle
#

I want to timeout a user in a specific guild but this is not working. When I tried await guildz.timeout() it didn't work either.

async def synced_timeout(self, ctx, user, reason, hours, minutes, seconds):
    guildz = self.bot.get_guild(1094233212257042544)
    await user.timeout(guild_id=guildz, reason=f"{reason} - {ctx.author}", until=discord.utils.utcnow() + datetime.timedelta(hours=hours, minutes=minutes, seconds=seconds))
``````py
Member.timeout() got an unexpected keyword argument 'guild_id'
#

I also tried guild=guildz but that didn't work as well

young bone
#

Is the bot public or not?

fervent cradle
#

member = guildz.get_member(user)

#

and set a timeout for the member object

stable cradle
#

alr let me try that

young bone
shadow quiver
#

There is a new release, 22.3.1 to 23.1.2 Does this really matter if I make that change?

#

And I also installed the python 11 through microsoft, do I need to add it to my varibles now?

#

Oh I cant even do that...

stable cradle
#

wait

#

It's for a bunch of servers that are linked together

#

The servers are public but the bot is only being used for those servers

#

oh wait

#

nvm

topaz ruin
#

is something like this possible with pycord?
notsobot uses commands with spaces in them like /a convert or /a identify and i was wondering how this is possible

young bone
spring hare
young bone
#

;3

topaz ruin
#

ill take a look, thank you

#

yes, that's what i was looking for
thank you for the links lol

livid wolf
#

How do I have it close a form post

silver moat
#

as a bot or as a user

spring hare
#

How to insert items in a view?
Like self.add_item, but with ability to specify position of an item in a row?

spring hare
#

Change self.children?

young bone
#

what?

spring hare
#
class SomeClass(View):
  def __init__(self):
    super().__init__(...)
    self.add_item(<Button "World">)

  @ui.button(...)
  async def hey(self):
    ...
young bone
#

Menu?

#

ok

spring hare
#

Button hey will be first than the world button

young bone
#

if you create a new one after the button, the button should be at the right then

#

just create to buttons and you will see what I mean

spring hare
#

?

torpid wraith
#

Is changing a channel's name rate limited?... I just tried changing it every 5 seconds (for testing), and it only changed twice?...

young bone
#
class MyView(discord.ui.View):
    def __init__(self):
        super().__init__(timeout=None)

    @discord.ui.button(label="A button")
    async def button_callback(self, button, interaction):
        await interaction.response.send_message("A button", ephemeral=True)

    @discord.ui.button(label="B button")
    async def second_button_callback(self, button, interaction):
        await interaction.response.send_message("B button", ephemeral=True)

soemthing like this @spring hare

silver moat
young bone
spring hare
#

Blue button was created with self.add_item
All other buttons and select menu were created inside View class
I wanna place my blue button to the left

torpid wraith
spring hare
#
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In components.0.components.1: The specified component exceeds the maximum width
#

If I try to self.children.insert(1, value)

silver moat
spring hare
#

self.add_item row=1
self.children.append row=1

#

I just don't understand why self.add_item and self.remove_item exist, but not self.insert_item

silver moat
#

then make a PR

spring hare
#

fair enough

#

I just don't understand how to insert it

#

If just self.children.append don't work

silver moat
spring hare
#

Okay, I found the problem
I need to also add item._rendered_row

spring hare
#

Solution (if someone needed)

self.add_item(item)
self.children.insert(pos, self.children[-1])
del self.children[-1]```
cyan quail
#

but yeah wouldn't be too hard to pr an insert method

normal tusk
#

someone have any idea about a ui builder (library) to build a ui components and export its request?

spring hare
#

Or wdym

normal tusk
#

should i wait forever?

spring hare
#

Discord moment

normal tusk
spring hare
normal tusk
spring hare
normal tusk
young bone
#

?

spring hare
#

I think they want to get json

spring hare
normal tusk
spring hare
normal tusk
#

but for interactions (the image is for commands rigs data)

spring hare
normal tusk
#

@spring hare

#

:>

spring hare
#

Works?

normal tusk
#

there is no method called _from_data

spring hare
#

Interaction._from_data

spring hare
normal tusk
spring hare
#

wdym???
This is from official pycord guide

class MyView(discord.ui.View):
    @discord.ui.button(label="Button 1", row=0, style=discord.ButtonStyle.primary)
    async def first_button_callback(self, button, interaction):
        await interaction.response.send_message("You pressed me!")

    @discord.ui.button(label="Button 2", row=0, style=discord.ButtonStyle.primary)
    async def second_button_callback(self, button, interaction):
        await interaction.response.send_message("You pressed me!")

    @discord.ui.select(
        row = 1,
        options = [...]
    )
    async def select_callback(self, select, interaction):
        await interaction.response.send_message(f"Awesome! I like {select.values[0]} too!")```
Buttons get the same interaction as select or modals
spring hare
#

@normal tusk It works?

livid wolf
normal tusk
silver moat
graceful brook
#

Interesting, does anyone know why my webhook is returning a Invalid Webhook Token on the 480th message, no matter what that message is?
Webhook Declaration:

history_webhook = await ctx.channel.create_webhook(name="CopyMessages", avatar=None, reason="For CopyMessages")

Inside for loop looping through message history:

await history_webhook.send(content=content, embeds=embeds, files=files,
                                       username=nick,
                                       avatar_url=avatar)

Error

Ignoring exception in command paste:
Traceback (most recent call last):
  File "C:\Users\Thiel User\Documents\GitHub\CopyMessages\main.py", line 115, in paste
    await loading_message.edit(embed=embed)
  File "C:\Users\Thiel User\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\webhook\async_.py", line 899, in edit
    return await self._state._webhook.edit_message(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Thiel User\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\webhook\async_.py", line 1945, in edit_message
    data = await adapter.edit_webhook_message(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Thiel User\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\webhook\async_.py", line 221, in request
    raise HTTPException(response, data)
discord.errors.HTTPException: 401 Unauthorized (error code: 50027): Invalid Webhook Token

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Thiel User\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\commands\core.py", line 124, in wrapped
    ret = await coro(arg)
          ^^^^^^^^^^^^^^^
  File "C:\Users\Thiel User\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\commands\core.py", line 982, in _invoke
    await self.callback(ctx, **kwargs)
  File "C:\Users\Thiel User\Documents\GitHub\CopyMessages\main.py", line 123, in paste
    await loading_message.edit(embed=embed)
  File "C:\Users\Thiel User\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\webhook\async_.py", line 899, in edit
    return await self._state._webhook.edit_message(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Thiel User\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\webhook\async_.py", line 1945, in edit_message
    data = await adapter.edit_webhook_message(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Thiel User\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\webhook\async_.py", line 221, in request
    raise HTTPException(response, data)
discord.errors.HTTPException: 401 Unauthorized (error code: 50027): Invalid Webhook Token

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

Traceback (most recent call last):
  File "C:\Users\Thiel User\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\bot.py", line 1114, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "C:\Users\Thiel User\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\commands\core.py", line 375, in invoke
    await injected(ctx)
  File "C:\Users\Thiel User\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\commands\core.py", line 132, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: HTTPException: 401 Unauthorized (error code: 50027): Invalid Webhook Token
#

I apologize for that wall of an error

solemn idol
graceful brook
#

It is not an invalid webhook tho. If i restart the bot it will work with that webhook perfectly. Like I said, it sends the webhook messages perfectly for the first 479 messages, then sends that error on the 480th.

To clarify, it doesn't create a new webhook every restart. It first checks if theres already an existing webhook with the name CopyMessages. If it does, it doesn't create a new one and instead uses that.

Edit: If the error is valid, and the webhook is invalid, am I missing something? Is there a message limit for webhooks in one session or period of time?
@solemn idol @young bone

graceful brook
#

hold up, is there a limit to the amount of times a message can be edited?

topaz rune
#

Hi, quick question, how do I hide admin/modos commands for users

#

/ commands

young bone
topaz rune
#

ty

topaz rune
#

they cant use but they see

normal tusk
#

add inside of the the default permission
@topaz rune
eg

@bot.slash_command("cool", description="this is my cool command!")
@discord.default_permissions(administrator=True)
async def cool(ctx: discord.ApplicationContext):
  # do some cool stuff here
  pass
tribal girder
#

is there a way to get a msg content if the msg is deleted?

#

for reporting a message log in specific channel

verbal marten
verbal marten
#

How would I queue audio for the voice client to play after the current audio has finished?

#

I have tried using voice_client.is_playing() but it returns false even when audio is being played

proud mason
#

In that function, play the next song

#

.rtfm voiceclient.play

winter condorBOT
verbal marten
#

gotcha thanks

violet heron
#

Is there a way to have a slash command option, if one of the options is selected it opens another option?

cyan quail
fervent cradle
#

Hello, I have a question. How I can code that the users who authorized this joins a server?

normal tusk
fervent cradle
mellow remnant
#

is there a way to call a page callback(interaction) from a custom_view in a Page?

normal tusk
mellow remnant
torpid wraith
#

Anyone know the rate limit for editing a single message? (ie. a status post that updates every X seconds)

meager mica
#

so i have a bot that uses oauth to give bot access to have them join server how do i actually have them join the server

full basin
normal tusk
#

i cant delete a webhook message ?

#

this kinda confused me

young bone
#

Mhm

#

Imagine using google

normal tusk
fervent cradle
#

how can i add reactions to the result of a slash command?

normal tusk
#

and that's why i used follow up hook

young bone
#

Mhm

normal tusk
#

:(

young bone
#

That is for the slash command question

fervent cradle
young bone
normal tusk
#

.rtfm ApplicationContext

normal tusk
#

if it was the 1st response on slash so you can use msg.add_reaction()