#General Help

1 messages ยท Page 3 of 1

glossy thicket
#

Well, everything works. The modal opens but when I want to send it doesn't work

#

He has all the permissions but it does not change

slate heron
#

Yeah you need to remove the bot and re-add with the new permissions

glossy thicket
#

Yes but it will not change that when I receive a channel it does not return none

slate heron
#

If manage channels is not on, I don't think the bot can see the channel, thus why it's None

#

I could be wrong

crimson gale
#

manage channels does not let people see channels regardless of permissions

#

only administrator does

glossy thicket
#

But on the other commands it works fine...

exotic cape
#

view channel does

#

let you see a channel

#

but yeah admin overrides everything

slate heron
#

Wait, so if you get_channel (the one you're trying to get) outside of your model it works?

slate heron
#

I see

glossy thicket
#

In the class it does not work

slate heron
#

I replicated it, and it works fine

#
class Graphisme(discord.ui.Modal):
    def __init__(self):
        super().__init__("Tu recherches un graphiste ?")

        self.add_item(discord.ui.InputText(label="Description :", placeholder ="Entrer une courte description de ce que vous recherchez.", style=discord.InputTextStyle.long))
        self.add_item(discord.ui.InputText(label="Budget :", placeholder ="Entrer votre budget."))

    async def callback(self, interaction: discord.Interaction):
        user = interaction.user
        embed = discord.Embed(color=0x2f3136, description=
                            f":coc_arrow: **{user.name} recherche un graphiste !**\n\n" +
                            "> :coc_message: **ยป Description :**\n" +
                            f"{self.children[0].value}\n" +
                            "> :coc_message: **ยป Budget :**\n"
                            f"{self.children[1].value}\n"
                            )

        embed.set_thumbnail(url=user.avatar)
        embed.set_image(url="https://i.ibb.co/RctGDPz/barrejaunecoc.png")

        button_contacter = discord.ui.Button(label="Contacter", style=discord.ButtonStyle.green)
        viewGraph = discord.ui.View(timeout=None)
        viewGraph.add_item(button_contacter)

        channel = client.get_channel(your_channel)

        await channel.send(embed=embed, view=viewGraph)
glossy thicket
slate heron
#

I added it to a button in my own bot

#

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

#

and I'm not using cogs

glossy thicket
slate heron
#
modal = Graphisme()
await interaction.response.send_modal(modal)
#

This was in a button callback

glossy thicket
slate heron
#

I'm not familiar with cogs and how they differ from a standard bot, sorry

violet night
#

Getting Error 405'd when trying to run a command; is that an error on my end or Pycord's end?

merry thicket
#

Discord and Pycord I guess?

#

Permissions arent yet released in the main branch, so

worthy basin
violet night
#

The command doesn't run properly; do I just have to wait for the update?

violet night
nocturne hazel
#

Is there an easy way to see if a message has a thread attached to it?

worthy basin
#

What do you mean by run properly? Does it not show up in the list after typing / or it just dosent respond?

#

@violet night

violet night
#

On one instance, the first, and on another instance, the second.

violet night
#

I did not change the code at all between these two instances.

worthy basin
#

There has been a lot of registration bugs recently. Could you go to your server interactions tab and see if the commands are synced?

#

Updating pycord to master might also fix this. I think there was a fix implemented

gaunt cairn
#

whats the issue here?

worthy basin
#

There commands are not registering sometimes

gaunt cairn
#

it takes time to register

violet night
#

Commands aren't synced

violet night
gaunt cairn
#

oh its not slash commands?

#

then its just internet or something

#

idk

violet night
#

it is a slash command, but it's registered as a guild command so it registers instantly

worthy basin
#

Are you using debug guilds with one guild ID?

violet night
#

I'm using my personal guild to debug, as far as I know it only has one ID.

worthy basin
#

Do you define it as a debug guild in the bot constructor or in the command decorator?

violet night
#

I don't, how do I go about that?

worthy basin
#

So how are you registering the command as a guild command?

violet night
#
class MakeAnAccount(commands.Cog):
    def __init__ (self, bot):
        self.bot = Bot
        self.registry = []

    @discord.commands.command(guild_ids=[532672466255085598])
    async def register(self, ctx, username):
        new_user = Account(ctx.author.id, username)
        self.registry.append(new_user)
        print("Registered!")
worthy basin
#

Hmmm. I think it might just be a bug with registration. Someone else might have more information, but I dont have anything else to try sorry :/

slate heron
#

Uh, add a response, see if it still errors?

violet night
slate heron
#

You can add debug_guilds=[guild_id] to your bot init to help make them instant while deving

violet night
slate heron
#

I looked at some docs, they are using @commands.command()

violet night
slate heron
#

Has it ever shown up?

violet night
keen shore
#

hi

slate heron
#

Are you running it with /

keen shore
#

so the terminal said bot online but when i look in my server the bot isnt ๐Ÿ’€

violet night
past gate
#

is what he's asking

violet night
#

yes, it is

#

at least that's the idea

slate heron
#

Alright 1 sec

violet night
#

and the one time it did register it appeared as a slash command

slate heron
#

from discord.commands import slash_command

then use
@slash_command()

violet night
nocturne hazel
#

Yo how do I get the content of the first message in a thread

slate heron
violet night
#

nevermind, fixed that error, still nothing.

slate heron
#

@violet night

@slash_command(guild_ids=[532672466255085598], name="Register", description="")
@option("username", str, description="Username", required=True)
async def register(ctx, username: str):
violet night
#

need self as an argument in register because I need to save the input on the command to an array.

slate heron
#

The input would be username?

violet night
#

also

slate heron
#

Oh I see

violet night
#
@option("username", str, description="Username", required=True)

NameError: name 'option' is not defined

slate heron
#

import option with the slash_command

vestal kelp
#

Anyone know why I'm getting this error even though my bot works exactly as expected? I can provide code if I need to

violet night
#

Lots of people getting 405'd atm, likely to do with the permissions v2 update

slate heron
past gate
#

no need to worry

vestal kelp
#

PES_Okay Thank you

#

Was first time seeing it, so was confused

past gate
#

You could get rid of it by upgrading to the master branch

violet night
past gate
#

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

slender lintel
#

Hi, I seem to have run to an issue and I am unsure if it has to do with the new discord v2 permissions .

It seems that my bot is completely ignoring discord channel permissions. I've gone as far as removing all permissions, however bot is still able to respond to commands. Any help will be greatly appreciated

vestal kelp
#
@client.slash_command(guild_ids=servers, name="config logchannel")
async def logchannelset(ctx, channel):
    c.execute(f'select logchannel from configuration where serverid = {ctx.guild.id}')
    exists = c.fetchone()
    if exists is None:
        c.execute(f'insert into configuration(logchannel) values (?) where serverid = {ctx.guild.id}', (channel.id))
        conn.commit()
        setEmbed = discord.Embed(title="Configuration Changed", description=f"Configuration for Log Channel has changed.", color=0x008080)
        setEmbed.add_field(name="Log Channel Set", value=channel, inline=True)
        setEmbed.set_author(name=ctx.interaction.user)
        await ctx.interaction.response.send_message(embed=setEmbed)
    else:
        setEmbed = discord.Embed(title="Configuration Exists", description="A configuration exists for Log Channel", color=0x008080)
        logchan = client.get_channel(exists)
        logchan = logchan.mention
        setEmbed.add_field(name="Log Channel Configuration", value=logchan)
        setEmbed.set_author(name=ctx.interaction.user)
        await ctx.interaction.response.send_message(embed=setEmbed)

Can anyone possibly help me with this ValidationError occurring in my ```py
async def logchannelset(ctx, channel):

Edit: I've tried searching online and trying to find it on my own, I couldn't find anything that helped me, so here I am.
slate heron
#

@violet night I just had success with this

@slash_command()
async def register(self, interaction: discord.Interaction, username: str):
past gate
#

if you want to achieve that you need to use groups

vestal kelp
#

Ah yeah, forgot about that ๐Ÿฅฒ

violet night
slate heron
#

yep

#

interaction.user.id

violet night
sharp summit
#

is there a way to check if channel has slowmode?

slate heron
#

0 is disabled

sharp summit
#

like

#

if channel.slowmode_delay > 0?

slate heron
#

Sure

sharp summit
#

Thanks

slate heron
#

@violet night I forgot to tell you, self.bot = bot yours has a B

cloud lotus
#

How can I add description to the slash command options?

slender lintel
#

do bots need a specific perm to create slash commands

slate heron
slate heron
slender lintel
#

Is there a way to embed a videofile in pycord?

slate heron
#

Youtube or actual video?

#

Cos I think it works for both tbh

ornate spade
#

just send it

terse plinth
#
embed = discord.Embed(
  title = ...
  color = discord.Color.red()
  )

Am i limited only to the inbuilt discord.Color colors? How do i use other colors?

#

for example, i want this to be the embed color

#

how would i manage that?

ornate spade
#

get the hex code

terse plinth
#

color = <hex code>

ornate spade
#

for example 0xFFFFFF would be white

terse plinth
#

that would work?

ornate spade
#

yes

terse plinth
#

no # im assuming

#

thanks

idle linden
#

correct, otherwise you'd create an inline comment

terse plinth
#

ye, thanks

slender lintel
ornate spade
#

you cant do that

#

sorry

terse plinth
#

F

terse plinth
ornate spade
#

adding 0x makes it a hexadecimal integer iirc

terse plinth
#

I see

#

Thanks for the help

slender lintel
ornate spade
#

no problem

slate heron
#

It seems delete_after does not work on a hidden interaction response ๐Ÿ™

earnest sail
#

How do I change the order of the itens on a desired row? I have added some itens with the decorators and also with the self.addmethod on the view constructor. The issue is that the itens added through the decorator are added first and I haven't found a way to change the order.

slate heron
#

Could you show your code please, I got lost

earnest sail
#

there's a lot of lines

#

I basically want to shift a button's position

slate heron
#

Hmm, so you're creating a View() with buttons

earnest sail
#

on a single row

#

i want that hitbox button moved to the left

#

between "back to move selection" and โ–ถ๏ธ

#

as I said, the issue is that the hitbox button is added with self.add

#

while the others use the decorator

slate heron
#

Right I see

earnest sail
#

I haven't found an option on the pycord API reference that allows me to change that order

slate heron
#

I don't think you can

ornate spade
#

is there no insert_item method?

earnest sail
gusty merlin
supple ravineBOT
#

examples/views/paginator.py line 108

"""Demonstrates how to pass a list of custom buttons when creating the Paginator instance."""```
earnest sail
#

it looks like view.children is mutable so i'll try rearenging that

#

but I thought pycord would have a simple method to do that

#

๐Ÿ˜”

dapper quiver
#

whenever I reload my bot, my pre-existing buttons stop working, anyway to prevent this?

slate heron
#

not easily, on bot load you would have to find the message, get the buttons and re-add the listeners.

earnest sail
toxic tapir
#

#971833232574271540 if yall can help 3>

dapper quiver
#

What do you mean by listeners? I could do the rest but not sure what you mean by that

slate heron
slate heron
dapper quiver
#

ooh perfect thanks

ornate spade
exotic cape
#

how do we edit a forum's title if the problem is solved?

gloomy yacht
#

I'm having some trouble getting a user's banner, is it possible? it seems like it behaves differently than getting an avatar

stable torrent
#

its Asset, so .url for url

gloomy yacht
stable torrent
#

user don't have a banner then

#

nvm

#

you need to fetch him (aka api call) to get this info

tall umbra
#

hi, sorry to bother but i get this error:

ImportError: cannot import name 'bridge' from 'discord.ext' (unknown location)```

I recently switched to pycord and i want to start using the bridge extension but whatever i do i get this error, i install, uninstall and reinstall pycord etc (and discord.py its uninstalled)

||english is not my native spanish, sorry for the orthography errors||
#

also the version i using of pycord is 1.7.3

past gate
#

for bridge you need a beta version iirc

#

pip install py-cord=2.0.0b7

tall umbra
#

a okey, thanks

tall umbra
#

and a last question...

#

how do i expect an error whit bridge extension?

#

because when i use @purge.error to expect an error in a cog y get this when i try to run it:

    @purge.error
AttributeError: 'BridgeCommand' object has no attribute 'error'
frosty slate
#
bot = commands.Bot(command_prefix='$', case_insensitive=True, intents=intents)
now = datetime.datetime.now()
column = -1
number = 0000
active_op = False
attend = 1111
id_num = 00
row = 4

class MyModal(Modal):
    def __init__(self) -> None:
        super().__init__("Operation Attendance Code")
        self.add_item(InputText(label="Attendance Code", placeholder="0000", min_length=4, max_length=4))
        self.add_item(InputText(label="ID Number", placeholder="0000", max_length=2))

       

    async def callback(self, interaction: discord.Interaction):
        global attend
        global column
        global row
        global number
        id_column = column + 1
        attend = self.children[0].value
        id_num = self.children[1].value
        #correct_code = False

        if attend == number:
            embed = discord.Embed(title="Your Modal Results", color=discord.Color.random())
            embed.add_field(name="First Input", value=self.children[0].value, inline=False)
            embed.add_field(name="second Input", value=self.children[1].value, inline=False)
            worksheet = sh.sheet1
            worksheet.update_cell(row, column, attend)
            worksheet.update_cell(row, id_column, id_num)
        else:
            embed = discord.Embed(title="Incorrect Code", color=discord.Color.random())
        await interaction.response.send_message(embeds=[embed])
#

I have a discord bot, when they enter a code into the modal, if the code is correct, it should log the data into a spreadsheet, if they enter the wrong code, tehn it should tell them in an embed. but they way i have it, if they get the code correct, it tells them that the code is incorrect and doesnt log it.
i know its an issue with the if statement but i cant seem to figure out what

gilded widget
#

you could either convert the correct code you're storing to a string or do int(self.children[0].value)

#

you'll have to make sure the value is numeric before doing int(self.children[0].value) as well

old plover
#

Anyone have any experience with Tortoise ORM here?

potent rivet
#

i tried this and it still isnt working

#

is it because i have my .env in a .gitignore folder?

#

eee that fixed it

exotic cape
#

anyone here knew how to make persistent buttons but in cogs?

@bot.event
async def on_ready():
    bot.add_view(MyView()) # Registers a View for persistent listening

class MyView(discord.ui.View):
    def __init__(self):
        super().__init__(timeout=None) # timeout of the view must be set to None

    @discord.ui.button(label="A button", custom_id="button-1", style=discord.ButtonStyle.primary, emoji="๐Ÿ˜Ž") # the button has a custom_id set
    async def button_callback(self, button, interaction):
        await interaction.response.send_message("Button was pressed", ephemeral=True)

@bot.command()
async def button(ctx):
    await ctx.send(f"Press the button! View persistence status: {MyView.is_persistent(MyView())}", view=MyView())

this but in cogs, this code is supposed to be persistent that even after the bot restarts you would still be able to interact with the buttons.

I used this same code but put it inside a cog and when I restarted the bot, the interaction failed which should not happen

#

nvm found a way

  1. move the MyView class to the main script
  2. add the bot.add_view(MyView()) inside the async def on_ready():
  3. import the MyView class on the cog file from main
  4. use the MyView class in the cog
brazen hill
#

Replit: Updating package configuration

--> python3 -m poetry install
/home/runner/sir-aramis/venv/bin/python3: No module named poetry.main; 'poetry' is a package and cannot be directly executed
exit status 1

Replit: Package operation failed.

#

why did i get this im using replit btw

#
Replit: Updating package configuration

--> python3 -m poetry install
/home/runner/sir-aramis/venv/bin/python3: No module named poetry.__main__; 'poetry' is a package and cannot be directly executed
exit status 1


Replit: Package operation failed.
slow dome
balmy flame
#

!install

robust nebulaBOT
#

Install pycord:

pip install py-cord```
Install pycord beta:
```pip uninstall discord.py
pip install py-cord==2.0.0b5```
Install pycord alpha from git:
```pip uninstall discord.py
pip install git+https://github.com/Pycord-Development/pycord```
exotic cape
#

python3 -m pip install poetry try this @brazen hill

toxic tapir
#
06.05 03:13:54 [Bot] File "/cogs/events.py", line 23, in on_member_join
06.05 03:13:54 [Bot] guild = self.client.get_guild(id=mpGuild)
06.05 03:13:54 [Bot] TypeError: get_guild() got some positional-only arguments passed as keyword arguments: 'id'```
#

Works in discord.py but in PyCord it's broken. I'm not worried just curious why?

exotic cape
#

see if this would work

toxic tapir
#

Yeah just did that assuming it's the positional arguments thingy haha

toxic tapir
#

Yeah.

#

I'm pretty sure PyCord positional arguments is just different than d.py

#

Never the less working as it should ๐Ÿ˜„

exotic cape
brazen hill
# exotic cape `python3 -m pip install poetry` try this <@731836857326895145>

Replit: Updating package configuration

--> python3 -m poetry install
Traceback (most recent call last):
File "/nix/store/2vm88xw7513h9pyjyafw32cps51b0ia1-python3-3.8.12/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/nix/store/2vm88xw7513h9pyjyafw32cps51b0ia1-python3-3.8.12/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/runner/sir-aramis/venv/lib/python3.8/site-packages/poetry/main.py", line 5, in <module>
from .console import main
File "/home/runner/sir-aramis/venv/lib/python3.8/site-packages/poetry/console/init.py", line 1, in <module>
from .application import Application
File "/home/runner/sir-aramis/venv/lib/python3.8/site-packages/poetry/console/application.py", line 7, in <module>
from .commands.about import AboutCommand
File "/home/runner/sir-aramis/venv/lib/python3.8/site-packages/poetry/console/commands/init.py", line 2, in <module>
from .add import AddCommand
File "/home/runner/sir-aramis/venv/lib/python3.8/site-packages/poetry/console/commands/add.py", line 8, in <module>
from .init import InitCommand
File "/home/runner/sir-aramis/venv/lib/python3.8/site-packages/poetry/console/commands/init.py", line 14, in <module>
from tomlkit import inline_table
ImportError: cannot import name 'inline_table' from 'tomlkit' (unknown location)
exit status 1

brazen hill
#

i did

exotic cape
#

you did

python -m poetry install

#

@brazen hill

brazen hill
#

Looking in indexes: https://package-proxy.replit.com/pypi/simple/
Requirement already satisfied: poetry in ./venv/lib/python3.8/site-packages (1.1.13)
Requirement already satisfied: crashtest<0.4.0,>=0.3.0 in ./venv/lib/python3.8/site-packages (from poetry) (0.3.1)
Requirement already satisfied: packaging<21.0,>=20.4 in ./venv/lib/python3.8/site-packages (from poetry) (20.9)
Requirement already satisfied: pexpect<5.0.0,>=4.7.0 in ./venv/lib/python3.8/site-packages (from poetry) (4.8.0)
Requirement already satisfied: tomlkit<1.0.0,>=0.7.0 in ./venv/lib/python3.8/site-packages (from poetry) (0.10.2)
Requirement already satisfied: cachecontrol[filecache]<0.13.0,>=0.12.9 in ./venv/lib/python3.8/site-packages (from poetry) (0.12.11)
Requirement already satisfied: keyring>=21.2.0 in ./venv/lib/python3.8/site-packages (from poetry) (23.5.0)
Requirement already satisfied: shellingham<2.0,>=1.1 in ./venv/lib/python3.8/site-packages (from poetry) (1.4.0)
Requirement already satisfied: poetry-core<1.1.0,>=1.0.7 in ./venv/lib/python3.8/site-packages (from poetry) (1.0.8)
Requirement already satisfied: requests-toolbelt<0.10.0,>=0.9.1 in ./venv/lib/python3.8/site-packages (from poetry) (0.9.1)
Requirement already satisfied: pkginfo<2.0,>=1.4 in ./venv/lib/python3.8/site-packages (from poetry) (1.8.2)
Requirement already satisfied: clikit<0.7.0,>=0.6.2 in ./venv/lib/python3.8/site-packages (from poetry) (0.6.2)
Requirement already satisfied: html5lib<2.0,>=1.0 in ./venv/lib/python3.8/site-packages (from poetry) (1.1)
Requirement already satisfied: requests<3.0,>=2.18 in ./venv/lib/python3.8/site-packages (from poetry) (2.27.1)
Requirement already satisfied: virtualenv<21.0.0,>=20.0.26 in ./venv/lib/python3.8/site-packages (from poetry) (20.14.1)
Requirement already satisfied: cachy<0.4.0,>=0.3.0 in ./venv/lib/python3.8/site-packages (from poetry) (0.3.0)
Requirement already satisfied: cleo<0.9.0,>=0.8.1 in ./venv/lib/python3.8/site-packages (from poetry) (0.8.1)
ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: '/home/runner/sir-aramis/venv/lib/python3.8/site-packages/CacheControl-0.12.11.dist-info/METADATA'

exotic cape
#

hmmm

brazen hill
#

Traceback (most recent call last):
File "/nix/store/2vm88xw7513h9pyjyafw32cps51b0ia1-python3-3.8.12/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/nix/store/2vm88xw7513h9pyjyafw32cps51b0ia1-python3-3.8.12/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/runner/sir-aramis/venv/lib/python3.8/site-packages/poetry/main.py", line 5, in <module>
from .console import main
File "/home/runner/sir-aramis/venv/lib/python3.8/site-packages/poetry/console/init.py", line 1, in <module>
from .application import Application
File "/home/runner/sir-aramis/venv/lib/python3.8/site-packages/poetry/console/application.py", line 7, in <module>
from .commands.about import AboutCommand
File "/home/runner/sir-aramis/venv/lib/python3.8/site-packages/poetry/console/commands/init.py", line 2, in <module>
from .add import AddCommand
File "/home/runner/sir-aramis/venv/lib/python3.8/site-packages/poetry/console/commands/add.py", line 8, in <module>
from .init import InitCommand
File "/home/runner/sir-aramis/venv/lib/python3.8/site-packages/poetry/console/commands/init.py", line 14, in <module>
from tomlkit import inline_table
ImportError: cannot import name 'inline_table' from 'tomlkit' (unknown location)

brazen hill
#

ok?

exotic cape
#

cause i don't know much about poetry ๐Ÿ˜…

brazen hill
#

...

#

emm

#

i think that still doesnt work ...

#

error: /usr/bin/env: โ€˜./python3โ€™: No such file or directory

kind nimbus
#

Is specifying a debug guild in the bot constructor sufficient to set all my commands as guild specific?

south ermine
#

yes

idle linden
#

If I wanted to add some functions into the 'discord'(py-cord) namespace, is creating the package 'discord' in my own project sufficient or will that cause errors

kind nimbus
#

any package you create will replace rather than merge

idle linden
#

does anyone know if there is a name for this sort of thing, because I swear ruby merged, and while I know this isn't ruby, the concept/name usage should still exist

toxic tapir
#

#972027353029046315

slate heron
fair cradle
#

cant get message with id, it alway return None

slate heron
#

Paste your code

#

Just the snippet

fair cradle
#
test = self.bot.get_message(972019839013105724)
        print(test)
slate heron
#

The channel where that message is, is your bot in the user side panel

fair cradle
#

Yes

slate heron
#

actually, you should need an await on that

fair cradle
#

then i get an error

slate heron
#

Could you give me more, I need more context to what self is

fair cradle
#
Ignoring exception in modal <cogs.survey.SurveyModal object at 0x000001CE7C5B7850>:
Traceback (most recent call last):
  File "C:\Users\witti\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ui\modal.py", line 245, in dispatch
    await value.callback(interaction)
  File "C:\Users\witti\OneDrive\Dokumente\Icons\Programmieren\PycharmProjects\ASTR0-Bot\cogs\survey.py", line 126, in callback
    test = await self.bot.get_message(972019839013105724)
TypeError: object NoneType can't be used in 'await' expression
slate heron
#

Ah it's a cog

fair cradle
#

yes

#

i save the message id in a database and want to get the Object... it dont work

#

and now with only the id it wont work too

slate heron
#

How are you running it, is it inside an interaction?

fair cradle
#

yes, inside a modal now for test, but before it was inside a task

slate heron
#

you can use interaction.client.get_message()

#

I could be wrong, but I think cog bot's are limited in what they can get

fair cradle
slate heron
#

Alright give more code, something must be up

fair cradle
# slate heron Alright give more code, something must be up
@button(label="1 Agree", style=ButtonStyle.green, emoji="โœ…", custom_id="test")
    async def agree(self, _button: Button, interaction: Interaction):
        """
        :param _button:
        :param interaction:
        """
        test = interaction.client.get_message(972043628786638888)
        print(test)
slate heron
#

That should work fine

fair cradle
#

i get None...

#

the message exists

slate heron
#

Are you using intents?

past gate
#

maybe try fetching the message

fair cradle
fair cradle
slate heron
#

fetch_message()

past gate
slate heron
#

Your bot def has perms to read msgs?

fair cradle
# past gate just change get to fetch
Ignoring exception in view <PersistentView timeout=None children=2> for item <Button style=<ButtonStyle.success: 3> url=None disabled=False label='1 Agree' emoji=<PartialEmoji animated=False name='โœ…' id=None> row=None>:
Traceback (most recent call last):
  File "C:\Users\witti\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ui\view.py", line 371, in _scheduled_task
    await item.callback(interaction)
  File "C:\Users\witti\OneDrive\Dokumente\Icons\Programmieren\PycharmProjects\ASTR0-Bot\cogs\survey.py", line 75, in agree
    test = self.bot.fetch_message(972043628786638888)
AttributeError: 'Bot' object has no attribute 'fetch_message'
fair cradle
kind mesa
#

Does AutoComplete have a limit? I have a list of 41 items that I want to autocomplete, but it only shows 30 or so

ornate spade
#

25

rigid sandal
#
async def test(ctx):
    role = get(ctx.guild.roles, id=964563688747069460)
    await ctx.author.add_roles(role, reason="Test")```
Anyone know what's wrong here? `get` (imported from discord.Utils):
```Ignoring exception in command test:
Traceback (most recent call last):
  File "C:\Users\zakye\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 110, in wrapped
    ret = await coro(arg)
  File "C:\Users\zakye\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 774, in _invoke
    await self.callback(ctx, **kwargs)
  File "C:\Users\zakye\Desktop\ใ…คใ…ค\Freelance\DomingoxSita\DomingoxSita_Bot\main.py", line 140, in test
    await ctx.author.add_roles(role, reason="Test")
  File "C:\Users\zakye\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\member.py", line 950, in add_roles
    await req(guild_id, user_id, role.id, reason=reason)
AttributeError: 'coroutine' object has no attribute 'id'

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

Traceback (most recent call last):
  File "C:\Users\zakye\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 768, in process_application_commands
    await ctx.command.invoke(ctx)
  File "C:\Users\zakye\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 306, in invoke
    await injected(ctx)
  File "C:\Users\zakye\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 116, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.commands.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'coroutine' object has no attribute 'id'
C:\Users\zakye\AppData\Local\Programs\Python\Python310\lib\asyncio\events.py:80: RuntimeWarning: coroutine 'ApplicationCommand.__call__' was never awaited
  self._context.run(self._callback, *self._args)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

If I use await on the get I get a new error:

Traceback (most recent call last):
  File "C:\Users\zakye\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 110, in wrapped
    ret = await coro(arg)
  File "C:\Users\zakye\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 774, in _invoke
    await self.callback(ctx, **kwargs)
  File "C:\Users\zakye\Desktop\ใ…คใ…ค\Freelance\DomingoxSita\DomingoxSita_Bot\main.py", line 139, in test
    role = await get(ctx.guild.roles, id=964563688747069460)
  File "C:\Users\zakye\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 191, in __call__
    return await self.callback(ctx, *args, **kwargs)
  File "C:\Users\zakye\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 198, in callback
    return self._callback
AttributeError: 'SlashCommandGroup' object has no attribute '_callback'

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

Traceback (most recent call last):
  File "C:\Users\zakye\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 768, in process_application_commands
    await ctx.command.invoke(ctx)
  File "C:\Users\zakye\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 306, in invoke
    await injected(ctx)
  File "C:\Users\zakye\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 116, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.commands.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'SlashCommandGroup' object has no attribute '_callback'```
#

Found the error seems to occur after I've created a slash command group like this get = client.create_group("get", "Get command") , don't know how this is related though

exotic cape
rigid sandal
#

do you mean in the slash command decorator

exotic cape
#

get = client.create_group(name="get", description="Get command")

#

@rigid sandal

#

also i would try to add guild_ids=[] so that commands would load faster for those guilds

rigid sandal
#

thanks

inland acorn
#

how can i get the editted message context from old message id
like the message content was editted and i have its id

#

hmm

exotic cape
keen eagle
#

I have py-cord installed for some time and started to do some slash commands and suddenly it doesn't recognize cmds.slash_command and discord.Option
It did recognize them before and I first uninstalled discord.py and then installed py-cord

#

PIng me if you respond please

stable tiger
#

might be stupid question, but do decorators from yesterday permission v2 commit work ? is it fully released by discord ? because this code is still allowed to be used in dms bubuHmm not bot owner can use /test too, waited hour as well bubuHmm so idk, havent seen anybody talk about anything so i feel weird.

from discord import Intents, guild_only, Bot
bot = Bot(command_prefix='~', intents=Intents.all())

@bot.slash_command()
@guild_only()
async def test(ctx):
    await ctx.respond('You are in guild.')

bot.run(getenv("DISCORD_YEN_TOKEN"))
slender lintel
#

Autocomplete interactions can be used for modal textinputs? Or they are only supported by slash command options?

#
class PickChannel(discord.ui.View):
    def __init__(self, chns):
        self.channels = chns

    @discord.ui.select( # the decorator that lets you specify the properties of the select menu
        placeholder = "Chooses a Channel", # the placeholder text that will be displayed if nothing is selected
        min_values = 1, # the minimum number of values that must be selected by the users
        max_values = 1, # the maxmimum number of values that can be selected by the users
        options = channels
    )
    async def select_callback(self, select, interaction): 
        #do stuff
        await interaction.response.send_message(f"Channel set to {select.values[0]}")

class testing(commands.Cog):
    def __init__(self, bot):    
        self.bot = bot
    
    @commands.command()
    async def pickchannel(self, ctx):
        chns = []
        for i in ctx.guild.channels:
            chns.append(discord.SelectOption(
                label=f"{i.name}",
            ))
        await ctx.send(view=PickChannel(chns))
``` how could I make this work? I'm trying to make a channel selector with select menus
crimson gale
#

options can only be a list of str or SelectOption and limited to 25 elements iirc

slender lintel
#

there are 5 channels

#
class PickChannel(discord.ui.View):
    def __init__(self, chns):
        self.children[0].options = chns

    @discord.ui.select( # the decorator that lets you specify the properties of the select menu
        placeholder = "Chooses a Channel", # the placeholder text that will be displayed if nothing is selected
        min_values = 1, # the minimum number of values that must be selected by the users
        max_values = 1 # the maxmimum number of values that can be selected by the users
    )
    async def select_callback(self, select, interaction): 
        #do stuff
        await interaction.response.send_message(f"Channel set to {select.values[0]}") ```
You need to define options after creating an instance of the view, you can do it in init method of the view just like I did @slender lintel
#

nice, works, thanks @slender lintel

stiff nebula
#

Is there a way I could see if an interaction response has been deferred? It seems there is InteractionResponse._responded is it intended for use?

past gate
#

well considering its prefixed with _ it'd suggest its not

slender lintel
stiff nebula
#

Since deferred interactions are considered responded

stiff nebula
#

Follow up question, how do i send modals after deferred?

slender lintel
slender lintel
#

But yeah you can send modals as an initial response, if it's not been responded yet, InteractionResponse.send_modal(...)

stiff nebula
#

That's sadly very unfortunate

#

Understood ! thanks

tawny orchid
#

is it currently possible to get the member's guild banner, or not yet?

past gate
#

possible

stiff nebula
#

Is there a fix now to the command registration issue that only a single command appears?

slender lintel
#

I'm trying to my bot to get a list of the roles assigned to itself, but it keeps returning
"'Bot' object has no attribute 'roles'"

rancid saddle
#

hi, guild.channels returns empty list, why is that? I've set intents.guilds = True

rigid sandal
#

How do I get the message my bot has just sent? I tried client.deposit_msg = await ctx.interaction.response.send_message(embed=text,view=DepositButton())
But I get returned an interaction instead, and trying to access client.deposit_msg.message gives me NoneType

tribal vapor
rancid saddle
tribal vapor
#

so it's out of date is what I'm hearing

steep lark
#

You probably have an older version

tribal vapor
#

probably

#

let me run pip and see

steep lark
#

Maybe you did pip install py-cord, which installs the older stable version

tribal vapor
#

yup on 1.7.3

frosty slate
#

is there a way to have a select menu within a modal?

coral stratus
#

what is this? and how it implement in bot?

steep lark
copper stag
#

Pretty dumb question but does anyone have examples with using guild.create_text_channel in a view subclass? I kind of looked everywhere

slender lintel
#

Hey, how i can the embed command edit with buttons also the command has a embed with text so when i click to the button has be change the embed

balmy flame
#
Traceback (most recent call last):
  File "C:\Users\small\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 382, in _run_event
    await coro(*args, **kwargs)
TypeError: on_message() missing 1 required positional argument: 'message'```
#
async def on_message(ctx, message):
    contents = message.content
    for bad_word in bad_words:
        if bad_word in contents:
            await message.delete()
            await ctx.send(f"{message.author.mention} your message has been censored.")```
#

any fix?

ornate spade
#

no ctx

balmy flame
#

yeah but it wont send the ctx.send part without it

#

message.send dosent work either

ornate spade
#

message.channel.send

balmy flame
#

oh

#

hold up

#

ok thanks

little isle
#

Is it not possible to use a commands.Paginator with a bridge.BridgeContext?

#

I get expected Context not <class 'discord.ext.bridge.context.BridgeApplicationContext'>

earnest sail
#

I thought bots didn't need messages intent enabled to delete their on sent messages? Or am I missing something?

#

it is a ephemeral message

#

#971846901152497694 message I see

little isle
#

You can't delete ephemeral messages

exotic cape
crimson coral
little isle
#

Oh, whoops, it's ext.pages.Paginator that's throwing the error. b7

crimson coral
#

uhhh what exactly is throwing the error?

little isle
#

(I have to use commands.Paginator in the same function, but it works fine because it doesn't need a context)

crimson coral
#

looking at the code paginator.respond allows bridgecontext

little isle
#
embed_paginator = pages.Paginator(pages=embeds, show_disabled=False)
await embed_paginator.send(ctx)

ctx is a bridge context

#

Testing more, it works with the message command but not with the slash command

crimson coral
#

should be .respond in a bridge command, but it looks like this actually isn't on b7; it is present in master

empty oak
#

anyone else getting a 405 code when syncing commands?

crimson coral
#

basically b7 ext.pages doesn't properly support bridge commands

crimson coral
empty oak
#

yeah I know but now none of my commands are getting recognised as debug commands so I have to wait like an hour for them to process

crimson coral
#

though note this completely changes the @permissions decorator if you're currently using it, so make sure to look into that before updating

empty oak
#

am just doing this

crimson coral
#

i'd just update to master then, the perms v2 rollout had some bugs with syncing alongside the 405 which they claimed to have fixed yesterday

empty oak
#

I can't

#

I'm using modals

crimson coral
#

i mean

#

? modals are fine on master

empty oak
#

oh

#

they didn't exist for me

#

sorry kek

crimson coral
#

the heck

#

maybe you had a bad install

exotic cape
empty oak
#

yea maybe

empty oak
#

a piece of code

empty oak
#

updated to master

#

and ui doesn't exist

#

OMEGALUL

crimson coral
#

ui definitely exists in master

#

no clue what you're doing wrong there

#

maybe just download it manually from github and throw in the files yourself

exotic cape
empty oak
crimson coral
#

pypi isn't gonna have master...

#

they have full releases

empty oak
#

o

crimson coral
#

you probably installed 1.7.3

empty oak
#

right

#

sorry kek

crimson coral
#

all good

#

if you want master you should install git+https://github.com/Pycord-Development/pycord

#

if using pip

empty oak
#

yea ty

empty oak
#

๐Ÿ™

exotic cape
#

better and always up to date

#

but messy to look at hahha

crimson coral
#

also remember if you're updating to master, things like @permissions.has_role, is_user etc were removed because discord implemented a new permission system... for better or worse. If you're using them, you should switch to ext.commands.has_role etc which are internal checks

empty oak
#

OO IT WORKED

crimson coral
#

nice

exotic cape
crimson coral
#

well

empty oak
crimson coral
#

which sucks because now you can't set user/roles via the bot on discord's end, you have to use internal checks

#

which is fine if you can access the integrations panel in your servers but otherwise a pain

#

(and if you don't own the server, you can't add your own permission to it)

exotic cape
#

ohhh then would the ext.commands.permissions still work after and disable the commands if one does not have any permission?

crimson coral
#

ext.commands checks are all internal, so they will continue to work

#

but they won't hide commands

exotic cape
#

but they would disable it right?

crimson coral
#

you want owner only commands to be hidden? haha nope

exotic cape
crimson coral
#

no, greying out was replaced with hiding

#

(or is in the process of happening)

exotic cape
#

that's bad hahaha

#

ohhh right there'a a way but the commands won't be hidden

#

the commands would only respond 'you don't have permission to use that command' if you have no permission

crimson coral
#

pretty much

#

the best solution for owner commands now is to register them to a single guild you control but that just makes them so much more inconvenient to use

exotic cape
crimson coral
#

if it's relying on discord permissions like administrator=True then permissions v2 should work for you

exotic cape
#

it is easier to manage in integration but restricting

crimson coral
#

yeah

exotic cape
#

only need to change one thing to enable it on all sub commands but has a lot of downs too

#

a dashboard would be better for further customization

minor fox
#

Oop, was just about to ask about hiding commands, hahaha, glad I checked here when I did.

exotic cape
#

yep server setting > integrations > bot

minor fox
#

Nice. Thank you.
On a second note though, what'd be the most elegant solution if I want to use both slash commands AND standard prefix commands? Or is that really more painful than it sounds...

crimson coral
#

do you mean the same command as slash and prefix?

crimson coral
#

or just using them alongside

minor fox
#

Same command

crimson coral
#

ext.bridge

exotic cape
#

but bridge does not have group commands iirc

minor fox
#

Fantastic! Just needed a point in the right direction haha

crimson coral
#

a bit basic at the moment but it does do the job for the most part

minor fox
#

Yeah, I don't have command groups so that works.

exotic cape
#

also you ctx.send() would throw a interaction failed on / and ctx.respond on prefix

crimson coral
#

well in bridge you're meant to use respond anyway

minor fox
#

Yeah, I branched my main repo and have a functioning slash commands rewrite, but want to conduct a poll on my community if they want me to keep the original prefix as well, or just go all in on slash commands.

#

I'd prefer to go all in on slash commands, but I'm not sure if there'd be serious backlash.

exotic cape
#

or you could just add them as cogs?

#

but i guess that would cause errors

#

hmmm

crimson coral
#

if newer slash command features make it easier to develop over prefix i'd just go all in

exotic cape
#

currently bridge is the best solution for your situation but it has its cons too

crimson coral
#

stuff like autocomplete and smarter options made features i wanted to implement actually possible on a scale

minor fox
#

Yeah, slash commands have been wonderful thus far.

exotic cape
#

they are less prone to user errors

#

if you configure it right

crimson coral
#

yeah it's easier to guide them

exotic cape
#

like options, autocompletes and others

#

and no need to remember things

wraith finch
#

so I'm trying to make the bot send a list of users but instead of it sending just like user IDs I want it to send the names like Rad#3196 Without pinging them. I'm using json files btw

exotic cape
#

you could also add descriptions on commands and parameters

crimson coral
#

well

#

i is a string

minor fox
#

There's one case that sorta irks me with slash commands. I had a feature that allows you to search a role to tag and it could convert those annoying ๐™ช๐™ฃ๐™ž๐™˜๐™ค๐™™๐™š ๐™›๐™ค๐™ฃ๐™ฉ๐™จ back into plaintext in the backend. Doesn't seem to be a way to have an option be either a role or str()

wraith finch
crimson coral
#

but like

#

are they IDs?

wraith finch
exotic cape
crimson coral
wraith finch
#

alright

crimson coral
#

similar to discord.Channel, discord.Member etc.

#

but (whacky) unicode fonts in general are just a pain

minor fox
crimson coral
#

might be weird but maybe you could use an autocomplete?

#

have some custom logic to convert their names

#

hell you say you already have the plaintext logic, you should be able to use that to some extent

minor fox
#

Python actually has a built in function for the conversion part, just unfamiliar with how to create options so perhaps an autocomplete would do the trick.

exotic cape
#

or make a command that returns the user's or role's id?

crimson coral
#

yeah i'd look into autocomplete

#

it's very useful for searching when the user doesn't know the exact input

minor fox
#

I just want to retain the functionality of what you get when you're using a Option(discord.Role, **)

#

Thanks for the tip, I'll have a look into that.

crimson coral
#

strictly speaking, if the autocomplete only returns role names in guild.roles you should be able to convert it safely back to a role with discord.utils.get

minor fox
#

Oh yeah, all that conversion stuff between weird role names and back to a role object is something I built a fun little nightmare library to do automagically, it's more just populating the autocomplete options.

crimson coral
#

isee

minor fox
#

Aha perfection, was just about to look for an example. Thank you so much for the link.

crimson coral
#

all good

exotic cape
crimson coral
#

if you have a user or member object, it's just user.send

#

e.g. ctx.author.send would be to whoever ran the command

exotic cape
#

how about if the allow dm is disabled?

crimson coral
#

well the only way to check if someone has dms disabled is to try and dm them

crimson coral
#

if it raises Forbidden they have them disabled i believe

#

so i think you could handle it with try / except discord.Forbidden

exotic cape
#

thanks

crimson coral
#

all good

exotic cape
#

right aside form auto complete OptionChoice would work too

minor fox
#

Got the autocomplete working! Very cool.
Any way to set the color of the autocomplete options though?

EDIT: Looking through the REST API it seems that roles are a distinct option type, while a custom autocomplete seems to only function with string types, so perhaps not.

kind wadi
#

i can get anything here ๐Ÿ˜

exotic cape
#

my commands are not are not registering parameters

command(ctx, paramhere)
but after running the bot it is not accepting params like this
/command

should be /command paramhere[]

#

it is inside a cog and a sub command

#

the insteraction : Interaction seems to be the problem

haughty narwhal
#

How do i get information about a user (eg name, display avatar) via the id?

exotic cape
#

you need to fetch/get the user first then .name .id after

crimson coral
crimson coral
#

well all slash arguments are technically option choices to some extent

exotic cape
#

hmmm

crimson coral
#

but if the autocomplete -> conversion works then hey that's fine

exotic cape
#

sheee my command params are not showing

#

ohhh

#
@test.command()
async def has_role_members(ctx, message:str='Hello'):
    for member in ctx.guild.members:
        for role in member.roles: 
            if role.name == 'test':
                await member.send(message)
            else: pass
#

message[] is not showing up

wraith finch
#

I want to make it so like in 3 days time an action happens how do I do that? And like would me turning the bot off mess with it?

#

basically I do a command it adds something to a list and I want the bot to delete that item after exactly 3 days

tidal beacon
#

Is it possible to create a reaction listener within a function? I want to run a command that spits out an embed and then allows people to react to that embed in order to join a queue for an event. this is what i have right now, im not sure where the listener goes and if it is outside the function how to access its data when it gets triggered

exotic cape
crimson coral
#

though if you're looking for multiple (unknown amount) reactions, you're better off just sleeping

#

do note you have to fetch the message again to get the reactions

worthy basin
# wraith finch I want to make it so like in 3 days time an action happens how do I do that? And...

You can use Tasks to complete this. But you would need external storage to keep track of the time if your bot was to go down. And you likely do not want 100 tasks running. So you would want to chunk it. How I do it is I store all my times in a database and every 30 minutes it finds all the timers that would end in the next 30 minutes. Than every minute after that I check if any of the times collected from the 30 minute or less list have ended and than I do the function.

Long term timers are kind of complicated.

wraith finch
#

so what I think I can do is first when I add the user I make another list with the times of when the users were added

worthy basin
#

When do you access the list?
What triggers you to access the list?

south ermine
#

it's easier to store the delete time, then you can just check if delete_time < now

wraith finch
wraith finch
#

this is when I access the list

pretty sure something is wrong cause I'm really new to coding

#

yea it says discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'list' object has no attribute 'time'

south ermine
#

you need to use datetime if it's multiple days

worthy basin
#

So you access the list from a command?

south ermine
#

really you should just always use datetime imo

wraith finch
south ermine
#

time is a list and you're calling .time on it instead of calling it on the time module

wraith finch
#

oh

#

I see

#

I'm thinking I can just check all the items in the list and remove all the ones that's under the current time

worthy basin
wraith finch
#

yea ok ty

#

I'd do that too but the thing is

#

I do this to make the names I've stored be shown as in Rad or smth instead of the ID

#

and I'd have to change that to remove the , endtime

#

but now I just have to check all the items in the list and see which ones are below the current time and remove them and the corresponding index of the other list too cause they have the same index

barren cedar
#

how do i get the list of application commands like client.commands but for application commands?

wraith finch
worthy basin
#

I dont exactly understand but something like this would work

for pos in range(len(clanMembers)):
  if member[pos][1] < now:
    member.pop(pos)
wraith finch
#

what's pos?

worthy basin
tough moss
#

range len ๐Ÿ’€

worthy basin
#

?

wraith finch
#

so I'll just change them all to datetime

worthy basin
#

pos is an int that increases by one every iteration of the for loop

wraith finch
#

I see

tough moss
# worthy basin ?

use enumerate

for index, element in enumerate(clanMembers.copy()):
  if element[1] < now:
    member.pop(index)
worthy basin
#

Im not very familiar with enumerate would this also avoid the deleting list elements with iterating problem where it skips to element 2 after deleting element 0?

tough moss
#

make a copy of the list using .copy() method

#

idk what the code is doing. Is it cooldown timer?

wraith finch
#

so like I add a user to a list

tough moss
#

what is the goal then?

wraith finch
#

and its supposed to be deleted after 3 days

tough moss
#

now is datetime object

barren cedar
wraith finch
#

and there's a command to access the list

tough moss
#

so user triggers that command?

wraith finch
#

so whenever we access the list I want it to delete any users that's past the date

wraith finch
tough moss
#

is it also triggered via timer?

wraith finch
#

no there is no timer as the bot will turn off and stuff, I'm gonna make it so if the time mentioned in the list is lower than the current time the item gets deleted from the list

#

it then copies the index of where the time was lower and then deletes the item of the same index from a different list where the usernames are stored

tough moss
#

why not use dictionary like {"Rad": endtime, "Ice Wolfy": endtime}

wraith finch
#

yea the reason why I'm not doing that

tough moss
#

you don't even need to iterate

wraith finch
#

later on I have to do smth like this

#

to make the user ids 549587402054696960 like this to just Rad

#

and if I had them like that {"Rad": endtime,} I don't really know how to alter them in that way

tough moss
#

dict is mutable

#

do clan_members["Rad"] = new_end_time

tough moss
# wraith finch

explain the significance of this piece of code to me. Why is it needed?

wraith finch
#

I have them stored like this

#

the IDs

#

But I wanna show them like this

wraith finch
tough moss
#

so if rad makes a purchase. you want to add it to his list?

wraith finch
#

no no
Another clan purchases a user

#

and its added to the list

#

so yea basically that but instead of a user making a purchase of an item its a clan making a purchase of a user

tough moss
#

I haven't played the game you are talking about so I am not very knowledgeable about it

wraith finch
tough moss
#

Though I think that the data can be organized better than just list of lists.

wraith finch
#

hm

tough moss
#

like dataclass for example

wraith finch
#

ig

tough moss
#
@dataclass
class ClanMember:
  id: str
  purchases: list
  name: str
tough moss
wraith finch
#

yea ok

#

I'll do that

wraith finch
tough moss
#

ah. thanks

wraith finch
#

well ty

#

I'm gonna go to bed now

#

bye

wraith finch
#

over here

#

what is the element

tough moss
#

value

wraith finch
#

which value?

tough moss
#

basically you won't need to do clanMember[index]

#

it is the value stored at that index

wraith finch
#

oh ok

south ermine
slender lintel
#

Hello, I have a question, why is the server region not displayed? It says "deprecated"..
Code: ctx.guild.region

crimson coral
#

maybe docs should be updated to reflect that

slender lintel
crimson coral
#

well not guild.channel, you're looking for a voice channel's rtc_region

slender lintel
#

okay i try

#

this error is there:

Ignoring exception in view <testbutton timeout=180.0 children=1> for item <Button style=<ButtonStyle.primary: 1> url=None disabled=False label='General' emoji=<PartialEmoji animated=False name='๐ŸŽจ' id=None> row=None>:
Traceback (most recent call last):
  File "C:\Users\zReaxrYT\PycharmProjects\Discord\venv\lib\site-packages\discord\ui\view.py", line 371, in _scheduled_task
    await item.callback(interaction)
  File "C:\Users\zReaxrYT\PycharmProjects\Discord\extensions\Buttons.py", line 31, in first_button
    value=f"**`{interaction.guild.channel_region}`**", inline=True)
AttributeError: 'Guild' object has no attribute 'channel_region'
crimson coral
#

no....

#

you need a voice channel object

#

to get its rtc_region

#

because guilds literally no longer use region, it's per channel

#

and if rtc_region is None then it's set to automatic

slender lintel
#

ohh

#

so how there?

slender lintel
#

How could I get a bot to get a list of the roles that it has?

stable tiger
#

guild.me.roles i guess

obsidian garnet
#

One message removed from a suspended account.

unique glacier
#

Hey what's a good ping range for your bot to stay in? Currently my bot is bouncing in about the 88-102ms range. How much ping should i start worrying about?

slender lintel
#

anything below is 160-180 is fine, i usually have between 80 and 120

slender lintel
#

so you can compare before and after

tidal beacon
little tapir
#

how do i use slash perms in cogs?

slender lintel
#

I do not know why it say "button is not defined"

little tapir
#

from discord.ui import Button

#

any one of these

slender lintel
#

i install this:
py-cord py-cord[voice] py-cord[speed]

south ermine
slender lintel
#

hmmmm

#

i use Pterodactyl panel...

crimson gale
#

you have 1.7.3 installed

slender lintel
#

oh....

crimson coral
#

that's a better approach if you're looking for an unknown amount of reactions, but if you want to wait for let's say 10 reactions, then using wait_for with a check on the amount of reactions is better

smoky canyon
#

H

slender lintel
#

Hey how i can level of boosts? not count, level

crimson coral
slender lintel
#

thank you

balmy flame
#

can i make it so my bot replys to pings

#

but dosent react to reply pings

#

for example @my_bots_name: works

balmy flame
weak gate
#

I wrote the code as below, but the checks are not working.
What can I do?

weak gate
bleak vault
#

how do i make a slash command cooldown

little tapir
#

i hv installed py-cord 2.0.0b7 but it still shows 2.0.0b5 in print(discord.__version__)

obsidian garnet
slender lintel
#

check for differences in boost amounts ShrugYeah

raw tulip
#

hey

#

i know i have to enable the message_content intent on the dev panel if i want to use it

#

unfortunately my bot is in more then 100 servers and i cant apply yet

#

so is there any way to force it to turn on?

crimson coral
#

why can't you apply? you should have been able to at 75 servers

raw tulip
#

i rly dont have a good reason to apply

crimson coral
#

well then you kinda have to give up on message content

raw tulip
#

... its literally just forced by pycord rn

crimson coral
#

? what intents do you have

#

you can just set message_content=False

#

it's not forced by default either, it's only enabled if you explicitly enabled it

sharp summit
#
ERROR: Command raised an exception: AttributeError: 'int' object has no attribute 'slowmode_delay'
#

How can I check if the channel has slowmode_enabled?

sudden path
#

Get the channel

#

And then check the slowmode.

sharp summit
#

Thanks

slender lintel
#

Hi im trying to edit a message based on its ID heres the code-

sent_message = await ctx.send(content="Message 1")
msgID = sent_message.id

await msgID.edit(content="Message 2")

apparently the code neither edits the message nor gives me any error

#

help

crimson coral
#

sent_message.edit

#

that should be giving you an error though

slender lintel
#

oh

#

doesnt but lemme try that

#

nope still doesnt work

#

doesnt give any error either :I

crimson coral
#

...you sure it's running at all?

slender lintel
#

it only sends the message but doesnt edits it

crimson coral
#

what if you send another message after trying to edit it

#

if you're not getting any errors then you screwed up your error handler somehow

slender lintel
#

hmm

#

im making a command in such a way that it first sends a message and then edits the message when ANOTHER user initiates the command

#

idk if u understand

#

;/

crimson coral
#

i think i know what you mean but that doesn't seem like the best implementation

slender lintel
#

yeah :(

obsidian garnet
sudden path
#

You should store the message id

#

To then get the object again and edit it.

crimson coral
#

not even the ID, you can just store the entire message

sudden path
#

Or just the object yeah

crimson coral
tidal beacon
obsidian garnet
crimson coral
#

well

#

you have two options:

  • track guild.premium_subscribers and see who's missing
  • track on_member_update and see who loses their boosting status
#

note this wouldn't detect a specific user that's doing multiple boosts going down to less boosts, e.g. 2 -> 1

kind mesa
#

Im currently using the latest version of pycord (2.0.0b7)
And the prefix isnt working. is this a known bug?

kind mesa
#

is set

slow dome
#

if you want prefixed commands, you would need message content intent set both in the code and in the dev portal

kind mesa
#

it is

slow dome
#

?tag intents

hearty rainBOT
#
import discord
from discord.ext import commands

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

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

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

# Apply intents when creating your bot
bot = commands.bot(prefix="?", intents=intents)
slow dome
kind mesa
slow dome
#

message_content = True

#

as well

kind mesa
#

oh yeah that fixed it

#

thank you

slow dome
#

np

little tapir
kind mesa
tropic fractal
#

How do you edit the message sent by ctx.respond?

little tapir
#

doesn't hurt to hv it all lol

tropic fractal
#

I think I'm just being really thick but I genuinely forgot the way to do it

little tapir
#

try this

#

i am not sure actually

tropic fractal
#

I'll give that a shot one sec

#

.message is None

#

for both ctx.interaction and the ctx.respond-returned interaction

#

ctx.followup.edit_message requires a message ID

crimson coral
#

does ctx.edit not work?

little tapir
#

and not for slash cmds

crimson coral
#

no it works for slash

tropic fractal
little tapir
tropic fractal
#

ok I'll try that one sce

tropic fractal
#

I definitely knew .edit was a function mhm yep

crimson coral
#

nice

minor fox
#

I was running some tests and added my slash_commands bot to a new server. I know it can take up to an hour for commands to register but it has been at least 12 hours and the commands aren't there?

#

Ah, wait, #972227609431801977 message found this message. From other threads I figured it could have something to do with the new perms-v2 but couldn't find a solid correlation between my issue and that.

Edit: More recent communications in https://discord.com/channels/881207955029110855/972554650727358535 has proven to be useful too. Excited for the next beta!

slender lintel
#

Hello, i have tryed a uptime command for looking the bot uptime, i want a datetime format ,,hours, min, sec" but my datetime object is not working?
Code:

times = datetime.datetime.utcnow().strftime('%H:%M:%S')

@bot.slash_command()
async def uptime(ctx):
    now = datetime.datetime.utcnow().strftime('%H:%M:%S')
    uptimes = now - times
    await ctx.respond(uptimes)

Error:

Ignoring exception in command uptime:
Traceback (most recent call last):
  File "C:\Users\zReaxrYT\PycharmProjects\Discord\venv\lib\site-packages\discord\commands\core.py", line 122, in wrapped
    ret = await coro(arg)
  File "C:\Users\zReaxrYT\PycharmProjects\Discord\venv\lib\site-packages\discord\commands\core.py", line 829, in _invoke
    await self.callback(ctx, **kwargs)
  File "C:\Users\zReaxrYT\PycharmProjects\Discord\main.py", line 28, in uptime
    uptimes = now - times
TypeError: unsupported operand type(s) for -: 'str' and 'str'

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

Traceback (most recent call last):
  File "C:\Users\zReaxrYT\PycharmProjects\Discord\venv\lib\site-packages\discord\bot.py", line 1098, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "C:\Users\zReaxrYT\PycharmProjects\Discord\venv\lib\site-packages\discord\commands\core.py", line 331, in invoke
    await injected(ctx)
  File "C:\Users\zReaxrYT\PycharmProjects\Discord\venv\lib\site-packages\discord\commands\core.py", line 128, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: unsupported operand type(s) for -: 'str' and 'str'
crimson gale
#

remove the .strftime to get the datetime objects. when you subtract datetime objects from each other it will produce a timedelta with the difference and i believe you can call strftime on that

tidal beacon
#

i have this block of code, i am unsure how to access the user data on the result2 line

slender lintel
crimson gale
#

the math is easy

slender lintel
#

math has never been my forte.. xd

crimson gale
#

we know that 1 minute is 60 seconds

slender lintel
#

yeah i know

crimson gale
#

one hour is 60 * 60 * 1 seconds

#

so one hour in seconds is 3.6k

slender lintel
#

ah i know hence the *

#

and one day 60 * 1440 * ?

crimson gale
#

60*60*24

magic dock
#

Hello, is there a way to have multiple users execute a command using permissions?

@permissions.is_user(198067816245624833) # should accept a list of pre-determined people
midnight cedar
magic dock
midnight cedar
#

you can use check decorators from ext.commands

slender lintel
#

When writing a bot in OOP Python, do I need to use command decorators in my Bot class?

midnight cedar
#

you shouldn't really be defining commands inside your bot class

slender lintel
#

So bot class only for setting it up?

midnight cedar
#

for creating the bot

#

which handles events and such

magic dock
slender lintel
#

copied one of the examples from the git so far

midnight cedar
#

outside of the bot you can use @bot.command as a decorator to create a command

slender lintel
#

okay

midnight cedar
#

or make a Cog with a @discord.slash_command

#

and add the cog with add_cog

slender lintel
#

and event handling like on_message or on_reaction add? That all happens inside of my bot class?

midnight cedar
#

it's no longer supported

slender lintel
magic dock
frosty slate
#
@bot.slash_command(name="apply", guild_ids=[])
async def apply(ctx, member):
    global idrow
    idrow_off = idrow + 1
    modal = profile()
    await ctx.interaction.response.send_modal(modal)
    userid = str(ctx.author.id)
    worksheet = sh.worksheet("Roster")
    worksheet.update_cell(idrow_off, 6, userid)
    role = discord.utils.get(member.guild.roles, name="Junior Operator")
    await member.add_roles(role)
#

role = discord.utils.get(member.guild.roles, name="Junior Operator")
AttributeError: 'NoneType' object has no attribute 'guild'

#

how do i fix?

#

please @ me

crimson coral
tropic fractal
#

@discord.default_permissions() and SlashComandGroup(default_member_permissions=...) isn't working?

config_group = discord.SlashCommandGroup(
        "settings", "Manage server settings.", default_member_permissions=discord.Permissions(manage_guild=True)
    )

This is still @.everyone -> yes

    @commands.slash_command(name="setup")
    @discord.default_permissions(manage_guild=True, manage_channels=True, manage_roles=True)
    async def foo(...):

This is the same result. No change in the UI.

#

am I doing something wrong?

slender lintel
#

Hey, i have a question i have a ping command i want 1 - 200er Ping is a "Good" Ping but my command is not working...

    pings = round(bot.latency * 1000)
    if pings == 1 - 200:
        await ctx.respond(f"Good Ping: {pings}")
    else:
        await ctx.respond(f'Ping {pings}ms')

Feel free to ask if you don't understand my question

stable tiger
#

Whatโ€™s not working? And 1 - 200 equals -199 ; you probably want just pings <200

slender lintel
#

is that even possible?

stable tiger
#

What I am saying is

1 - 200 = -199 so your if pings == 1 - 200 actually becomes if pings == -199 which wonโ€™t happen.

Thus I suggest if pings < 201 ;

slender lintel
#

so?

    pings = round(bot.latency * 1000)
    if pings < 201:
        await ctx.respond(f"Good Ping: {pings} - 1")
    else:
        await ctx.respond(f'Ping {pings}ms - 2')
stable tiger
#

Yeah, try and see

slender lintel
#

thanks ๐Ÿ˜„

#

can i do 3 levels good, medium and bad?

crimson coral
slender lintel
prisma pasture
#

how can i add a reaction to a webhook?

#

that i send with webhook.send()

tropic fractal
crimson coral
tropic fractal
#

Oh yeah the commands appear in the integration tab and when typing / but just with the default โ€œ@ฤ—veryone can useโ€ permission set

crimson coral
#

so the integrations tab is pretty whack honestly

tropic fractal
#

Discord problem?

crimson coral
#

it's very subtle how it displays permissions

tropic fractal
#

Well yeah it doesnโ€™t show permissions actually does it

#

It just shows roles and channels

#

I just realised that

crimson coral
#

let's say we have permissions that look like this

#

if it says default, then that's equivalent to the existing bot setting without changing anything

#

so for this command the bot has defined that @ everyone is false, but Server Moderator has a permission that is valid

#

if i was to set Server Moderator to GreenTick, the (default) text would pop up next to it

tropic fractal
#

I see

crimson coral
#

as you can see, this is incredibly intuitive and not confusing at all

tropic fractal
#

Yeah thatโ€™s a bit

#

Well

#

Idk what to expect itโ€™s discord

#

At least perms v2 is better than v1 ig lmao

#

Let me rephrase

#

Better -> more customisable

crimson coral
#

ever so slightly by having default perms yeah

#

just a pain that bots lose control over user/role

tropic fractal
#

Did many people actually use that for public bots?

crimson coral
#

for public bots? probably not, it's impractical at that scale

tropic fractal
#

I donโ€™t think thereโ€™s a large enough volume of bots thatโ€™re exclusively used in certain servers for discord to care about it
Theyโ€™d just tell you to check yourself in the code

crimson coral
#

yeah that's probably the approach

tropic fractal
#

But I can see how per-user would be nice anyway (E.g whitelist)

pale depot
#
  @commands.Cog.listener()
  async def on_application_command_error(ctx, error):
    if isinstance(error, commands.CommandOnCooldown):
      embed = discord.Embed(description="`/slash` command on cooldown!",color=p84clr)
      await ctx.respond(embed=embed)
    else:
        raise error  # raise other errors so they aren't ignored```
#

How come this doesn't work?

#

Traceback:

TypeError: on_application_command_error() takes 2 positional arguments but 3 were given```
pale depot
#

It's in the cog yes.

crimson coral
#

you want self, ctx, error

tidal beacon
#

currently having an issue with this, running this code and getting this error output. It fails on return reaction.msg == msg

exotic cape
#

your checking does not make sense to me

#

ohhh wait you are printing the line where the code is being executed

exotic cape
tidal beacon
#

im now here, for some reason the if react.emoji == ๐Ÿ˜€: is failing to read the reaction as that emoji. Not sure if im grabbing the emoji from the reaction improperly or what other thing im doing wrong. Console prints made it to line 60 and nothing else with this code

exotic cape
#

sorry i am not an expert on the emoji/reaction count part i haven't learned that one yet ๐Ÿ˜…

tidal beacon
#

np

lament stag
#

Hi, how can i show a confirmation view on a dropdown callback?

what i want is after selecting smtng on the dropdown it will ask you a yes or no button.

thank you in advance

stable anvil
#

@tidal beacon

return reaction.message == msg

You've used equal to operator thus it is either returning true or false.

#

oh nvm it's a check func

crimson gale
lament stag
lament stag
#

how can i disable the dropdown after select

crimson gale
#

select.disabled = True and edit the message to use the updated view

pale depot
#

How can I use await to call a asynchronous function in an init ?

Ex:


@class():
def __init__():
  await myAsyncFunc()

async def myAsyncFunc():
  do..

I'm unable to call the function in the init because it's async.
I tried making the init an async but that just creates a monster of errors.

blissful socket
#

you cant

pale depot
blissful socket
#

theres no way to call an async function using await

pale depot
#

i thought coding was infinite ๐Ÿ˜ญ

blissful socket
exotic cape
#

as callback

pale depot
blissful socket
pale depot
#

So how do I get the init to the function?

#

There's gotta be a way

blissful socket
exotic cape
#

what are you trying to do?

blissful socket
#

asyncio.run if you havent create an event loop

pale depot
blissful socket
#

asyncio.create_task if you created an event loop

#

ofc no await

exotic cape
#

yep not my field hahaha asyncio errors are everywhere

#

i don't even know how to catch a future error

#

or something of the likes if it is correct

exotic cape
brazen hill
#

idk

exotic cape
#

though i haven't encountered an async class to my knowledge or maybe i did but dis not recognize it? hahaha

cedar eagle
#

you can't async inits in python

exotic cape
#

see? hahaha async hell

cedar eagle
#

this is something I looked into a while ago when programming an api interface. it's not possible to async your inits

pale depot
#

this sucks

#

this legit breaks my entire code

#

all because of one init

cedar eagle
#

you can use an async factory pattern to initialize your class that way

exotic cape
#

but the question is why are you trying to async init?

pale depot
#

you know how hard that is ;O;

cedar eagle
#

Yes

#

I had to do it

exotic cape
#

i mean you could try to do it on a function

pale depot
exotic cape
#

hmmmm i know nothing about ai

cedar eagle
#

Heres a question. does the initialization of the class need to be asynchronous? or can it be a blocking call?

exotic cape
#

if not it could be a threading?

cedar eagle
#

your best bet is probably the factory pattern

exotic cape
#

right, do commands work on threads by default or do we need to permit them?

#

haven't tried it yet but they should work by default right?

cedar eagle
#

I'm seriously getting confused about how the slash command permissions work. Is it not possible to just supply a permission type? like manage_bots permission? or administrator permissions? I don't want to enforce either adding your guilds "admin" permission to the list of admins, nor do I want to enforce needing to create specific named roles to accommodate my bot

young hollow
#

nvm ty

cedar eagle
#

๐Ÿ‘

cedar eagle
ornate spade
#

You can also do it in code, documentation soon

cedar eagle
#

is there a simple way of having commands disabled to the everyone role by default? I'm realizing now it's not a huge deal with the bot I'm making but it would be cool to know for the future

ornate spade
cedar eagle
#

Oooooooooooooh

#

neat!

#

At first it looked just like the v2 example but that's some good stuff right there

tall fossil
#

Does anybody else get a 405 Error: Method not allowed when starting their bot?

idle linden
supple ravineBOT
# idle linden due to v1->v2 permissions see ##1335 and ##1328
GitHub

Summary
This is a copy of #1183 to re-do the merge conflict resolution after it was previously broken
Checklist

If code changes were made then they have been tested.

I have updated the documen...

GitHub

Checklist

If code changes were made then they have been tested.

I have updated the documentation to reflect the changes.

If type: ignore comments were used, a comment is also left explaining...

tall fossil
#

thank you. Hope it will help

#

wait. Is it on my site or do I only have to wait until it gets fixed?

crimson coral
#

you can ignore the error, but if you want it gone you can update to the master branch

#

or wait for the next release

tall fossil
#

I am on b7 rn but I guess its fine

#

I`ll just wait

idle linden
#

!install

robust nebulaBOT
#

Install pycord:

pip install py-cord```
Install pycord beta:
```pip uninstall discord.py
pip install py-cord==2.0.0b5```
Install pycord alpha from git:
```pip uninstall discord.py
pip install git+https://github.com/Pycord-Development/pycord```
idle linden
#

@tall fossil see the last one

#

also that command needs to be updated

#

since the latest installable beta is b7 obv

#

also the latest git is labeled as b7 still which is a bit misleading

tall fossil
#

nah I dont wanna use the alpha ^^

#

It's just a bit annoying but It's fine

tall fossil
brazen hill
#

Where can I get stuff like tutorials

#

also is it possible to store per server settings in json/sqlite/any other storage with pycord?

crimson coral
#

and you can use any storage method you can use in python

#

it's generally preferred to use asynchronous libraries if you're working with databases

brazen hill
#

ok

crimson coral
#

e.g. aiosqlite is a popular choice

slate stirrup
#

What's the code for inputing to the bot like args

sharp summit
#

Hi

#

I wanna make

#

my bot sends a message in slowmode enabled channel in a loop

#

but the next time it's sending the message it should tell me that there is slowmode of x minutes is enabled

#

any help would be appreciated

crimson gale
#

posting the code is better than not

sharp summit
# crimson gale posting the code is better than not
@client.event
async def msg_task():
    while True:
        #Put comma separated channel ids below in the "channels" list
        channels = [970671777187512344, 970671805192876096, 970671832556527639, 970671857458102285, 970671883139817535]
        for channel in channels:
            chnl = client.get_channel(channel)
            if chnl.slowmode_delay > 0: #if the channel in the list has slowmode enabled, but will log the following message in the console
                def check(m):
                    return m.author.id == 970668440639668265
                try:
                    msg1 = await client.wait_for("message", check=check, timeout=5)
                    if msg1.content == messagee.content:
                        await chnl.send(messagee)
                        print(f"Sent message to {chnl} on {chnl.guild.name}") #message sent confirmation message    
                except asyncio.TimeoutError:
                    print(f"Slowmode is enabled in {chnl} at {chnl.guild.name}")
            else:
                try:
                    await chnl.send(messagee)
                    print(f"Sent message to {chnl} on {chnl.guild.name}") #message sent confirmation message
                    await asyncio.sleep(time)
                except (discord.Forbidden):
                    print(f"Can't send message to {chnl}") #message sent failure message
#

My current code

slate stirrup
#

p.tag install

supple ravineBOT
sharp summit
#

...

twilit cobalt
#

e

#

how to edit a message on button interaction i tried this:
btn1 = Button(
label = 'Survivor Stats',
style= discord.ButtonStyle.success,
)
view = View()
view.add_item(btn1)

    interaction = await ctx.respond(embed=embed, view = view)

    async def btn1callback(interaction : discord.Interaction):
        await interaction.edit_original_message('e')

    btn1.callback = btn1callback
#

did i send same message twice

#

sorry if i did

crimson gale
#

await interaction.response.edit_message()

twilit cobalt
#

is rest correct?

crimson gale
#

why are you storing interaction in button? there is no use for it

twilit cobalt
#

hm?

crimson gale
#

why do you have an interaction kwarg in the button constructor?

twilit cobalt
#

the command work like it send general stats but if a player want specific survior stats the use button

#

oh

#

it copied with wrong indentation

#

it not inside button

crimson gale
#

oh wait yeah

#

but you still dont need it

twilit cobalt
#

need what

#

i need to respond to command

crimson gale
#

interaction variable assignment

twilit cobalt
#

oh

#

hhow do i edit tho ;-

#

it give this error await interaction.response.edit_message('e')
TypeError: InteractionResponse.edit_message() takes 1 positional argument but 2 were given

crimson gale
twilit cobalt
#

i want to edit from one embed to another

#

kk lemme try

crimson gale
#

iirc content has to be edited using the kwarg

#

so content="blah blah"