#Basic Pycord Help (Quick Questions Only)

1 messages · Page 42 of 1

undone mulch
#
await ads.set_permissions(ctx.guild.default_role, overwrite=perms)```
If I wanna set a permission can I provide the actual role id before "overwrite="
limber urchin
#

No, it needs to be a role or member object

#

It says in the docs

undone mulch
#

So when im defining the perms like
perms = chat.overwrites_for(ctx.guild.default_role);perms.send_messages=False

#

How can I define multiple roles?

#

Without duplicating lines twice

#

I wanna change the permission for 2 roles

limber urchin
#

You can just loop over the roles

undone mulch
#

It seems when I change the perm it removes all existing perms.

#
    @commands.command()
    async def test(self, ctx):
      await ctx.message.delete()
      casino = self.bot.get_channel(mpcasinoid)
      overwrite = discord.PermissionOverwrite()
      overwrite.send_messages = False
      await casino.set_permissions(ctx.guild.get_role(976315422708228107), overwrite=overwrite)```
#

This works but I got a problem. It's not keeping the current permissions it's updating the send_messages perm and removing the others.

#

Hmm. I don't get how to keep the existing perms.

silver moat
#

wait that's a slash command?

limber urchin
limber urchin
#

huh?

silver moat
#

oh yeah resolved in DMs

limber urchin
#

oh, okay

tired goblet
#

My bot printed this

#

Could someone help me understand what this is saying and how can i fix it if it needs any fixing?

rare cloak
#

Hey people! I'd like to ask a question concerning cogs and the default help command(the output is what I'm talking about here).

When using cogs(by inheriting commands.Cog), and extending the class by adding a few methods(adding commands, @commands.command();async def....), the default help command(which is DefaultHelpCommand) will format the commands like the image below:

#

My goal is to not want that happen, what I wish is that the commands in snipe (snipe is a class, one of the cogs), to be mixed with others(initially no_category but I changed it to others).

#

Can I achieve this without inheriting and extending the HelpCommand?

simple canopy
#

i don't think you can do that without inheritance

rare cloak
#

So I have to manually inherit the help command to achieve this?

simple canopy
#

yeah, this way you can customize it better iirc

rare cloak
#

Thank you!

simple canopy
#

might be helpful tho

rare cloak
#

Thanks for the reference.

full basin
tired goblet
#

Oh

#

Thanks, but i never import that aiohttp package in my code?

#

And I'm not really sure where I'm creating that session in my code

#

Is it something happening in the background?

full basin
#

Hm

#

What py-cord version are you on

tired goblet
#

Latest

proud mason
tired goblet
#

Just a second please

full basin
#

Oh god save me

tired goblet
#

I'm basically trying to fetch new posts from certain subreddits and send to discord

full basin
#

Why you're doing stuff on on_ready and why a WHILE loop

tired goblet
full basin
#

If you're not good at programming or with async stuff. Then refer to #help-rules 1

tired goblet
#

Well

full basin
#

Second, py-cord has a tasks extension which can do that or you can use asyncio itself

errant craneBOT
#

Here's the background task example.

tired goblet
#

I go to learn async and they say make something with it, i make something with it and you guys say go back and learn it first

#

Good while loop going on there

#

But thanks for the example

full basin
#

A Discord bot is no simple thing to start with

tired goblet
#

Gotta agree with that

#

Thanks again for the example

quartz thunder
#

Hey is there a way to suppress link embed preview on sending message ?

full basin
#

<link>

quartz thunder
#

?

full basin
#

Just like that... add <> around the link.

quartz thunder
#

ah ok 🙂 thx

green hinge
#

Is it possible to disable the keyboard input for slash commands with autocomplete so that you can only select values from the list that are predefined?
So if for $var1 [1 , 2 , 3 , 4] are available, that you can not enter a 5 via keyboard?

full basin
green hinge
# full basin Yeah. `number: discord.Option(int, "Select a number from the provided list", ch...

Here's how I have it:

art = ["Raub", "Überfall"]

@staticmethod
def artAutocomplete(self: discord.AutocompleteContext):
        return art

@option("art",description="Welche Art wurde durchgeführt?",autocomplete=artAutocomplete)
async def bank(self, ctx: ctx_parse, art: str):
  await ctx.respond(f"{art}")

And would like that only the two options are selectable and one can enter no other values.

full basin
#

There's no reason to have an autocomplete

#

Use the choices kwarg

green hinge
full basin
green hinge
full basin
#

How that matters?

green hinge
# full basin How that matters?

This is my whole code and there I want that the variables that have a default can't accept keyboard input anymore but only the selection from the list.

full basin
#

Provide the list in all options

#

And that's it. Don't know what you don't understand about it

#

And there's no reason to use autocomplete because you don't need to dynamically provide options.

west vault
#

was zum geier wird das haha

rare cloak
#

Hey people! Me again. I have a question whether it is possible to access discord.ClientUser in another file without cogs.

Imagine a file named echo.py with a simple function in it used to output arguments.

from discord.ext import commands

@commands.command()
async def echo(ctx, *arg):
    arg = ' '.join(arg)
    await ctx.send(f"out: \`\`\`\n{arg}\n\`\`\`")

def setup(bot):
    bot.add_command(echo)

(You'd then load this with the load_extension() function in other files)

I can't seem to find a way to make this possible(to access the properties in discord.ClientUser, like bot.user.id, bot.user and etc) without the help of cogs(in cogs, you'd normally use self to access these(self.user.id, self.user and etc.).

green hinge
# west vault was zum geier wird das haha

Habe den Ansatz nun von dark verstanden. Gibt es da irgendwie die Möglichkeit wenn ich bei Art: Raub auswähle, dass locationb erst gar nicht angezeigt wird?

    async def setglobal(self, ctx, art: Option(str, "Select a number from the provided list", choices=["Raub", "Überfall"]), 
    locationa: Option(str, "Select a number from the provided list", choices=["Mond", "Erde"]),
    locationb: Option(str, "Select a number from the provided list", choices=["Erde", "Mond"]),
    number: Option(int, "Select a number from the provided list", choices=[1, 2, 3, 4])):
west vault
#

Nope
Ignorier den Input einfach und setz die restlichen Optionen auf optional.

green hinge
west vault
#

Müsste. Kann aber nicht mehr helfen. Wechsel mal zurück auf englisch.

green hinge
#

Ok 👍🏼

#

Thank you 😂

grizzled sentinel
# rare cloak Anyone free?

You can make a _init_ function in the cog class. The bot instance is passed to this.

def __init__(bot):
self.bot =bot
grizzled sentinel
#

I tried :(

young bone
#

yes

#

for a slash command and prefix command

rare cloak
#

I don't think you understand my point here

#

My point is not to use cogs to achieve this

young bone
rare cloak
young bone
rare cloak
#

Not to suggest it is impossible, if it is possible. Is there any way?

#

Without the help of cogs, no cogs or inheritance involved.

young bone
rare cloak
#

What are you implying? Yes, I know the basics well.

rare ice
rare cloak
#

Good lord. Ok. Nevermind then, thanks for all the help. I appreciate it.

green hinge
#

Why does the selection not work with autocomplete. If I have e.g. house in the list and then type in the field hou then all options are still shown and not only all with hou 🤔

grizzled sentinel
full basin
grizzled sentinel
granite mirage
#

I'm expecting to get a list of banned users in the last hour in _ub, is there something I don't understand or am I doing wrong?

green hinge
# full basin What's your autocomplete function
art = ["Raub", "Überfall"]
locationa = ["Mond", "Erde"]

    @staticmethod
    def locationbtypeAutocomplete(self: discord.AutocompleteContext):
        chosen_art = self.options["art"]
        match chosen_art:
            case "Überfall":
                return ["Erde", "Mars", "Pluto", "Mond"]
            case "Raub":
                return ["NONE",]
            case _:
                return ["Error"]

    @slash_command(description="Das ist ein Test")
    async def setglobal(self, ctx : ctx_parse, art: Option(str, "Select a number from the provided list", choices=art), 
    locationa: Option(str, "Select a number from the provided list", choices=locationa),
    locationb: Option(str, autocomplete=locationbtypeAutocomplete),
    number: Option(int, "Select a number from the provided list",  choices=[1, 2, 3, 4]),
    player: Option(str,"Trage hier den Namen des Spielers ein")):
        await ctx.respond(f"Die Einstellungen für {number}") 
fervent cradle
#
            @discord.ui.button(label="Close Ticket",style=discord.ButtonStyle.red, emoji="❌")
            async def button_callback(self,ctx,button, interaction):
                await self.fetch_channel(NewChannel)
                await interaction.guild.delete(NewChannel)
class Support(discord.ui.View):
    @discord.ui.button(label="General Support",style=discord.ButtonStyle.success, emoji="📄")
    async def button_callback(self,button, interaction: discord.Interaction ):
        
        category = interaction.client.get_channel(1052267160724049970)
        global NewChannel
        NewChannel = await interaction.guild.create_text_channel(name=f"Ticket ",category=category)
        await NewChannel.send(embed = StartMsg, view=NewButtons())``` No error, Im trying to delete the channel once the button is clicked
full basin
green hinge
full basin
#

Check if the content is in the list and return the items that contain it

fervent cradle
#
class MyModal(discord.ui.Modal):
    def __init__(self, *args, **kwargs) -> None:
        super().__init__(
            discord.ui.InputText(
                label="Discord Name & Tag Ex: Bob#3456",
                placeholder="Please put your discord ID",
            ),
            discord.ui.InputText(
                label="How old are you?",
                placeholder="Please put your age!",
            ),
            discord.ui.InputText(
                label="Country & Time Zone",
                placeholder="Please put your Country & Time Zone",
            ),
            discord.ui.InputText(
                label="Job/Education Status",
                placeholder="Please put your job or education",
            ),
            discord.ui.InputText(
                label="Please provide an about you [ 150 words ]",
                placeholder="Please fill this out fully!",
                style=discord.InputTextStyle.long,
            ),
            *args,
            **kwargs,
        )

    async def callback(self, interaction: discord.Interaction):
        channel = bot.get_channel(STAFF_APP_LOGS)
        staff_embed = discord.Embed(
            title="Your Staff Application",
            fields=[
                discord.EmbedField(
                    name="Discord Tag", value=self.children[0].value, inline=False
                ),
                discord.EmbedField(
                    name="Age", value=self.children[1].value, inline=False
                ),
                discord.EmbedField(
                    name="Country/Timezone", value=self.children[2].value, inline=False
                ),
                discord.EmbedField(
                    name="Job/Education", value=self.children[3].value, inline=False
                ),
                discord.EmbedField(
                    name="About You", value=self.children[4].value, inline=False
                ),
            ],
            color=discord.Color.random(),
        )
        await channel.send(embed=staff_embed)```


Need help getting this in my staff application logs channel.
green hinge
fervent cradle
# fervent cradle ```class NewButtons(discord.ui.View): @discord.ui.button(label="Clos...
class NewButtons(discord.ui.View):
            @discord.ui.button(label="Close Ticket",style=discord.ButtonStyle.red, emoji="❌")
            async def button_callback(self,button, interaction: discord.Interaction):
                await self.fetch_channel(NewChannel)
                await interaction.guild.delete(NewChannel)``` 
Traceback (most recent call last):
  File "C:\Users\Wacky\Documents\FoolishBot\.venv\Lib\site-packages\discord\ui\view.py", line 414, in _scheduled_task
    await item.callback(interaction)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: NewButtons.button_callback() missing 1 required positional argument: 'interaction'
errant craneBOT
#

Here's the slash autocomplete example.

fervent cradle
#

slighly updated code

full basin
#

@green hinge

fervent cradle
#

I added ctx tryna fix it

full basin
#

Buttons don't receive ctx

fervent cradle
#

Edited

full basin
#

Then try again

fervent cradle
#

dark, Can you help me with my question, please?

full basin
#

You never provided errors or what's not working

fervent cradle
fervent cradle
#

sorry abt that ❤️

full basin
#

And interaction.guild.delete?

full basin
fervent cradle
full basin
#

.rtfm fetch_channel

full basin
#

You can even use

#

.rtfm Guild.get_channel

winter condorBOT
fervent cradle
#

i believe i am getting the channel

full basin
#

And wheres NewChannel defined?

fervent cradle
#

How would i fetch(or get) the channel i just created though? as i wont have a pre-set ID or name (as its going to have a new name each time)

fervent cradle
full basin
fervent cradle
#
class Support(discord.ui.View):
    @discord.ui.button(label="General Support",style=discord.ButtonStyle.success, emoji="📄")
    async def button_callback(self,button, interaction: discord.Interaction ):
        
        category = interaction.client.get_channel(1052267160724049970)
        global NewChannel
        NewChannel = await interaction.guild.create_text_channel(name=f"Ticket ",category=category)
        await NewChannel.send(embed = StartMsg, view=NewButtons())```
#

ay okay

fervent cradle
full basin
#

Do you realize classes don't share variables

fervent cradle
#

No then obviously i've made a mistake

#

What would be the proper way to do it?

full basin
#

I remember I told you to pass the channel into the NewButtons init and then use it in the class

fervent cradle
#

sorryyy

fervent cradle
fervent cradle
full basin
#
class NewButtons(discord.ui.View):
      def __init__(self, channel):
            super().__init__()
            self.channel = channel```
#

Then when you send the view:

await NewChannel.send(embed=..., view=NewButtons(NewChannel))```
fervent cradle
#

Thank you, channel is NewChannel correct?

#

yh

full basin
fervent cradle
#

how would I d this? im moving from discord.py to pycord so

full basin
#

The Get function gets the channel from the bot cache. The fetch function makes an API call

fervent cradle
full basin
#

You could also try

channel = interaction.guild.get_channel(STAFF_APP_LOGS)```
fervent cradle
#

thanks ❤️

#

Have i messed up here dark?

class NewButtons(discord.ui.View):
      def __init__(self, NewChannel):
            super().__init__()
            self.channel = NewChannel
            @discord.ui.button(label="Close Ticket",style=discord.ButtonStyle.red, emoji="❌")
            async def button_callback(self,button, interaction: discord.Interaction):
                await self.fetch_channel(NewChannel)
                await interaction.guild.delete(NewChannel)``` The button no longer shows but im unsure what i did wrong
#

Do i need to change it to self.channel.fetch.channel or smth?

full basin
#

You indented it inside the init function

#

And you don't even need to fetch the channel now. You already have a channel object stored.

#

You just do await self.channel.delete()

fervent cradle
#

Oh thank you

full basin
#

Consider reading the docs because you're making up functions or attributes that don't exist.

fervent cradle
#

im pretty sure it is

full basin
#

No

fervent cradle
#

mhm ok

full basin
#

What's STAFF_APP_LOGS

#

An int?

fervent cradle
#

its my config

#
TICKET_CHANNEL = config.TICKET_CHANNEL #Ticket Pan Channel
MEMBER_ROLE_ID = config.MEMBER_ROLE_ID

CATEGORY_ID1 = config.CATEGORY_ID1 #Support1 Channel
CATEGORY_ID2 = config.CATEGORY_ID2 #Support2 Channel
CATEGORY_ID3 = config.CATEGORY_ID3
CATEGORY_ID4 = config.CATEGORY_ID4
CATEGORY_ID5 = config.CATEGORY_ID5
WELCOME_LOGS = config.WELCOME_LOGS
STAFF_APP_LOGS = config.STAFF_APP_LOGS

TEAM_ROLE1 = config.TEAM_ROLE1 #Permissions for Support1
TEAM_ROLE2 = config.TEAM_ROLE2 #Permissions for Support2

LOG_CHANNEL = config.LOG_CHANNEL #Log Channel


TOKEN = config.TOKEN```
full basin
#

What's in the variable

fervent cradle
#

an ID

full basin
#

Is it an int

fervent cradle
#

yes.

#

it works on everything else but this.

full basin
#

Then try this

channel = bot.get_channel(STAFF_APP_LOGS)
channel = await bot.fetch_channel(STAFF_APP_LOGS) if channel is None else channel```
fervent cradle
#

thx

fervent cradle
full basin
#

No

#

The channel is an attribute of the class

fervent cradle
#

Ohh yeah

#

That hasnt fixed it

#

I dont see whats causing it

#

As theres no error to help me

full basin
#

Cose

#

Code

fervent cradle
#
      def __init__(self, NewChannel):
            super().__init__()
            self.channel = NewChannel
      @discord.ui.button(label="Close Ticket",style=discord.ButtonStyle.red, emoji="❌")
      async def button_callback(self,button, interaction: discord.Interaction):
        await self.channel.delete()
class Support(discord.ui.View):
    @discord.ui.button(label="General Support",style=discord.ButtonStyle.success, emoji="📄")
    async def button_callback(self,button, interaction: discord.Interaction ):
        
        category = interaction.client.get_channel(1052267160724049970)
        NewChannel = await interaction.guild.create_text_channel(name=f"Ticket ",category=category)
        await NewChannel.send(embed = StartMsg, view=NewButtons(NewChannel))``` if you want full file i can send
fervent cradle
# full basin Then try this ```py channel = bot.get_channel(STAFF_APP_LOGS) channel = await bo...
Ignoring exception in view <MyView timeout=None children=1> for item <Select type=<ComponentType.string_select: 3> placeholder='Choose a Ticket option' min_values=1 max_values=1 options=[<SelectOption label='Support' value='support1' description=None emoji=None default=False>, <SelectOption label='Player Reports' value='support2' description=None emoji=None default=False>, <SelectOption label='VPN Whitelist' value='support3' description=None emoji=None default=False>, <SelectOption label='VIP/Payment Issues' value='support4' description=None emoji=None default=False>, <SelectOption label='Staff Application' value='support5' description=None emoji=None default=False>, <SelectOption label='Ban Appeal' value='support6' description=None emoji=None default=False>] channel_types=[] disabled=False>:
Traceback (most recent call last):
  File "/home/container/.local/lib/python3.10/site-packages/discord/ui/view.py", line 414, in _scheduled_task
    await item.callback(interaction)
  File "/home/container/main.py", line 283, in callback
    await interaction.response.send_message(embed=embed, ephemeral=True)
  File "/home/container/.local/lib/python3.10/site-packages/discord/interactions.py", line 765, in send_message
    raise InteractionResponded(self._parent)
discord.errors.InteractionResponded: This interaction has already been responded to before
Ignoring exception in modal <__main__.MyModal object at 0x7fecc6e8e170>:
Traceback (most recent call last):
  File "/home/container/.local/lib/python3.10/site-packages/discord/ui/modal.py", line 341, in dispatch
    await value.callback(interaction)
  File "/home/container/main.py", line 385, in callback
    channel = await bot.fetch_channel(STAFF_APP_LOGS) if channel is None else channel
  File "/home/container/.local/lib/python3.10/site-packages/discord/client.py", line 1628, in fetch_channel
    data = await self.http.get_channel(channel_id)
  File "/home/container/.local/lib/python3.10/site-packages/discord/http.py", line 360, in request
    raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access```
fervent cradle
fervent cradle
#

nvm then

#

your good ❤️

#

thanks tho

#

np

fervent cradle
#

yup

#

I have been trying to figure it out but cant

frozen holly
#

Trying to make a quick slash command but for some reason the bot isn't accepting any arguments when the command gets run?

import discord

bot = discord.Bot()

@bot.slash_command(guild_ids=[513201373169319937])
async def chat(ctx, message):
    print(message)

bot.run(open('token.tok','r').read())
```Terminal only shows "None" whenever the command is run. Any help would be appreciated!
fervent cradle
#

So /chat hello then enter

frozen holly
young bone
fervent cradle
fervent cradle
#

so wouldnt it be fine without that?

young bone
fervent cradle
#

In my case it was a cog, sorry forgot to tell them its in a cog for me

errant craneBOT
#

Here's the slash basic example.

young bone
#

@frozen holly ^

fervent cradle
#
class NewButtons(discord.ui.View):
      def __init__(self, NewChannel):
            super().__init__()
            self.channel = NewChannel
      @discord.ui.button(label="Close Ticket",style=discord.ButtonStyle.red, emoji="❌")
      async def button_callback(self,button, interaction: discord.Interaction):
        await self.channel.delete()
class Support(discord.ui.View):
    @discord.ui.button(label="General Support",style=discord.ButtonStyle.success, emoji="📄")
    async def button_callback(self,button, interaction: discord.Interaction ):
        
        category = interaction.client.get_channel(1052267160724049970)
        NewChannel = await interaction.guild.create_text_channel(name=f"Ticket ",category=category)
        await NewChannel.send(embed = StartMsg, view=NewButtons(NewChannel))``` It isnt deleting the channel, no error either
frozen holly
#

so i have to put ctx: discord.ApplicationContext instead of just ctx? that seems to have been the issue

#

kinda weird nikoThink
thanks for the help!

fervent cradle
young bone
fervent cradle
#

Oh didnt notice that

fervent cradle
young bone
#

can you do try and except?

fervent cradle
young bone
#

except Exception as e
print(e)

fervent cradle
#
      async def delete_channel(self,button, interaction: discord.Interaction):
        try:
            await self.channel.delete()
        except Exception as e:
            print(e)``` this?
young bone
#

like that yes

fervent cradle
young bone
fervent cradle
fervent cradle
young bone
fervent cradle
#

I was told i didnt need interaction as its being passed through the class

fervent cradle
# young bone await interaction.channel.delete()
      def __init__(self, NewChannel):
            super().__init__()
            self.channel = NewChannel
      @discord.ui.button(label="Close Ticket",style=discord.ButtonStyle.red, emoji="❌")
      async def delete_channel(self,button, interaction: discord.Interaction):
            await interaction.NewChannel.delete()```
#

I tried it but dosent fix it

young bone
fervent cradle
#

huh

#

i did not understand the 2nd part of your message

fervent cradle
young bone
#

if you send the button in a channel and press the button, it will delete the channel where the button was pressed

fervent cradle
#

I have no error to help me figure this out either

#
      def __init__(self, NewChannel):
            super().__init__()
            self.channel = NewChannel
      @discord.ui.button(label="Close Ticket",style=discord.ButtonStyle.red, emoji="❌")
      async def delete_channel(self,button, interaction: discord.Interaction):
            await interaction.NewChannel.delete()
      
class Support(discord.ui.View):
    @discord.ui.button(label="General Support",style=discord.ButtonStyle.success, emoji="📄")
    async def button_callback(self,button, interaction: discord.Interaction ):
        
        category = interaction.client.get_channel(1052267160724049970)
        NewChannel = await interaction.guild.create_text_channel(name=f"Ticket ",category=category)
        await NewChannel.send(embed = StartMsg, view=NewButtons(NewChannel))``` full code (kinda)
young bone
fervent cradle
# young bone

Yeah but i have it defined as newchannel, so wouldnt it be that?

young bone
#

change "NewChannel" to just channel

young bone
fervent cradle
#

Thanks it worked

#

I also see what i had wrong

full basin
#

Pass the author to the view and then either check before running the callback or override the interaction_check method

frank yew
#

Hi, I have my bot in pycord 2.1.1 and I have in requeriments py-cord==2.1.1. But when I add my repro in Replit It download the last version

obtuse juncoBOT
livid monolith
#

ModuleNotFoundError: No module named 'discord.commands'

silver moat
#

pip list and send output. pip3 if unix

livid monolith
#

aiohttp 3.8.3
aiosignal 1.3.1
async-timeout 4.0.2
attrs 22.1.0
certifi 2022.12.7
charset-normalizer 2.1.1
discord 2.1.0
discord.py 2.1.0
frozenlist 1.3.3
idna 3.4
keyboard 0.13.5
MouseInfo 0.1.3
multidict 6.0.3
PyAutoGUI 0.9.53
PyGetWindow 0.0.9
PyMsgBox 1.0.9
pyperclip 1.8.2
PyRect 0.2.0
PyScreeze 0.1.28
pytweening 1.0.4
requests 2.28.1
urllib3 1.26.13
yarl 1.8.2

silver moat
#

well, I don't see py-cord.

livid monolith
#

oh shit yeah

sturdy garden
#

important, you need to uninstall discord.py before installing py-cord

livid monolith
#

done thank you

young bone
#

eh

#

I know what the problem is

sturdy garden
#

first thing

silver moat
#

learn python ty

young bone
#

^

sturdy garden
#

yep

#

but we're friendly so

livid monolith
#

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

sturdy garden
#
await msg.edit(embed=embed3)

@fervent cradle

livid monolith
#

aiohttp 3.8.3
aiosignal 1.3.1
async-timeout 4.0.2
attrs 22.1.0
captcha 0.4
certifi 2022.12.7
charset-normalizer 2.1.1
discord 2.1.0
frozenlist 1.3.3
idna 3.4
keyboard 0.13.5
MouseInfo 0.1.3
multidict 6.0.3
Pillow 9.3.0
py-cord 2.3.2
PyAutoGUI 0.9.53
PyGetWindow 0.0.9
PyMsgBox 1.0.9
pyperclip 1.8.2
PyRect 0.2.0
PyScreeze 0.1.28
pytweening 1.0.4
requests 2.28.1
typing_extensions 4.4.0
urllib3 1.26.13
yarl 1.8.2

silver moat
#

discord kek

young bone
silver moat
#

?tag replit

obtuse juncoBOT
sturdy garden
#

no

#

look now

#

no

#

but ithink you need to learn python a bit before

young bone
#

#help-rules Nr. 1

obtuse juncoBOT
#
eternal wing
#

Am trying to get an emoji for a reaction through a modal, all i get is the :sunglasses: text, but when passing into await msg.add_reaction(discord.PartialEmoji.from_str({emoji))i get an error Application Command raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body In emoji_id: Value "" is not snowflake. Help please

rare ice
eternal wing
#

The :sunglasses:

rare ice
#

.rtfm discord.PartialEmoji.from_str

winter condorBOT
rare ice
eternal wing
#

Oh... will try something

#

Nah did not go.. Then a followup question forms of how do i get the id? I guess the :sunglasses: is name not the id, yet that is all i get anyway so i don't have much to work with there

rare ice
#

well for an emoji like :sunglasses:, it's automatically turned into an emoji in markdown; so it doesn't really have an ID. i think there is a converter for emojis

#

.rtfm discord.EmojiConverter

winter condorBOT
#

Target not found, try again and make sure to check your spelling.

rare ice
#

hm

#

i guess not

#

im sure there is another way of doing this that i dont know of.

eternal wing
#

if i pass in just the :sunglasses: in await msg.add_reaction(discord.PartialEmoji.from_str(":sunglasses:") it still throws the same error, seems like what i am trying to do is probably not feasable

copper knot
#

(its a subclass of bot)

silver moat
dull onyx
#

what is that and how to do that it in pycord?

errant craneBOT
#

Here's the context menus example.

silver moat
amber shale
#

which intent is needed to get member from a guild using his id

proud mason
#

interaction.respond returns another interaction. not the message object

#

.rtfm edit_original_response

winter condorBOT
proud mason
#

use that to edit the msg sent

viscid rapids
#

is there an ability to purge a member?

#

like await ctx.channel.purge(limit=messages) but for a member?

proud mason
#

you can define a check that checks the author id with the member id you have

proud mason
#

np 👍

vale heath
#

.rtfm ephemeral

winter condorBOT
vale heath
#

Is there a way to make a response message as ephemeral ?

full basin
fervent cradle
#

slash commands doens't show for me but for my friend it does

proud mason
#

Hard reload if using discord web

#

And clear chahe if using mobile

fervent cradle
proud mason
#

Check server Slash perms

fervent cradle
#

it works for my friend

#

just not for me

livid monolith
#

--> python3 -m poetry add py-cord
Using version ^2.3.2 for py-cord

Updating dependencies
Resolving dependencies...

SolverProblemError

Because no versions of replit match >3.2.4,<3.2.5 || >3.2.5,<4.0.0
and replit (3.2.5) depends on typing_extensions (>=3.7.4,<4.0.0), replit (>3.2.4,<4.0.0) requires typing_extensions (>=3.7.4,<4.0.0).
And because replit (3.2.4) depends on typing_extensions (>=3.7.4,<4.0.0), replit (>=3.2.4,<4.0.0) requires typing_extensions (>=3.7.4,<4.0.0).
Because no versions of py-cord match >2.3.2,<3.0.0
and py-cord (2.3.2) depends on typing-extensions (>=4,<5), py-cord (>=2.3.2,<3.0.0) requires typing-extensions (>=4,<5).
Thus, py-cord (>=2.3.2,<3.0.0) is incompatible with replit (>=3.2.4,<4.0.0).
So, because python-template depends on both replit (^3.2.4) and py-cord (^2.3.2), version solving failed.

at venv/lib/python3.8/site-packages/poetry/puzzle/solver.py:241 in _solve
237│ packages = result.packages
238│ except OverrideNeeded as e:
239│ return self.solve_in_compatibility_mode(e.overrides, use_latest=use_latest)
240│ except SolveFailure as e:
→ 241│ raise SolverProblemError(e)
242│
243│ results = dict(
244│ depth_first_search(
245│ PackageNode(self._package, packages), aggregate_package_nodes
/home/runner/OutrageousPlainGame/venv/lib/python3.8/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
exit status 1

Replit: Package operation failed.

silver moat
#

?tag norepl

obtuse juncoBOT
#

Why NOT to use Repl as a hosting platform

You should not use Repl.it to host your bot.
It may be a nice option as its "free" but you should use something else considering the major flaws.

  • The machines are super underpowered.
    • This means your bot will lag a lot as it gets bigger.
  • You'll need a web server alongside your bot to prevent it from being shut off.
    • This isn't a trivial task, and eats more of the machines power.
  • Repl.it uses an ephemeral file system.
    • This means any file you saved via your bot will be overwritten when you next launch.

IMPORTATNT

  • They use a shared IP for everything running on the service.
    This one is important - if someone is running a user bot on their service and gets banned, everyone on that IP will be banned. Including you.

Please avoid using repl.it to host your bot. It's not worth the trouble.

If you're looking for free options, consider using AWS/Google Cloud Platform/Azure and its respective free tiers or just pay for an actual VPS.

livid monolith
#

ModuleNotFoundError: No module named 'cogs'

grizzled sentinel
#

Is your cogs folder in the same folder as main.py?

astral mist
#

Is it possible to make global app commands with this api wrapper

silver moat
#

yes

grizzled sentinel
#

Yes, just don't include debug_guilds or guild_ids

astral mist
#

Wait that ez

proud mason
#

Yeah lmao

astral mist
#

So I just have to forget about it

#

Wow

grizzled sentinel
#

Yes. It is "harder" to make a guild only command XD

proud mason
#

😂

astral mist
#

I will try that

#

Ig

livid monolith
#

fixed that but now i have a new error discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: OSError: cannot open resource

eternal wing
#

I don't know how to explain but do your cogs "load" themselves?

#

I just know that in the examples there were 2 functions that needed to be in there

livid monolith
eternal wing
livid monolith
#

all that is in that is exten=["cogs.verification"]

#

def setup(bot):
try:
bot.add_cog(Verification(bot))
print("Loaded verification.py")
except Exception as e:
print(f"Error loading verification.py: {e}")

lime totem
#

how to get categories

#

unique categories

eternal wing
livid monolith
#

thanks for trying

astral mist
#

i got trolled

eternal wing
#

By global commands did you mean so they can be executed on any server right?

astral mist
#

any server the bot is in

eternal wing
#

Then it was the right thing, it just takes sometimes a lil bit to sync with all of the discord physical servers. When you specify which guilds exactly to sync with it does it instantly, with global it can take 5-30min

#

If you get unlucky once mine synced only after 2 hours...

astral mist
eternal wing
#

By not working do you mean it throws an error?

astral mist
#

the thing

astral mist
astral mist
eternal wing
astral mist
#

yes

eternal wing
#

Of course, how else would it sync with the bot? xD

astral mist
eternal wing
#

No

#

I usually leave my bot on if i need to sync the commands, but recently it has only taken like 5min

plush meadow
#

quick question. when I restart my bot, do my tasks create duplicate instances? they are being started at on_ready()

astral mist
#

wait when i dont

#

add the guild thing

#

this happens

astral mist
errant craneBOT
#

Here's the slash basic example.

eternal wing
#

bot.slash_command did you mean to write?

astral mist
eternal wing
#

Right there in the error it says that you have @bot.slashcommand, but proper way is @bot.slash_command

#

Aka you forgot the underscore

astral mist
astral mist
#

without the @

eternal wing
#

@bot.slash_command()

#

The parenthesis

astral mist
#

oh i need those

#

ig imma wait for sync

silver moat
eternal wing
#

Thanks squid

astral mist
#

?

livid monolith
#

that means the bot has slash commands

eternal wing
#

Yea

gleaming falcon
#

Anyone know of any open-source Poll implementations? I know Pycord Manager has one, but seems it's just creating the poll. Looking for something that actually watches votes and issues results.

astral mist
#

or the clones

eternal wing
astral mist
gleaming falcon
#

No doubt I could make one, just mostly looking for something as a reference (specifically the monitoring aspects)

eternal wing
#

Unfortunately i don't have anything, sorry, i can just kinda pitch ideas xd

silver moat
#

if they are still there, you would comment on all commands and reset your token and your bot. uncomment the commands and re-run the bot.

astral mist
#

and i tried to refresh discord

#

with ctrl + r

silver moat
#

try using them

proud mason
astral mist
young bone
#

@astral mist add this auto_sync_commands=True to where you define the bot

#

I also had the problem

astral mist
#

alr

young bone
#

yes

#

also add Intents

astral mist
#

srry for ping

#

if i pinged u

young bone
#

you need intents for ban commands and other stuff

astral mist
#

well its still not syncing

dry gazelle
#

if this needs a new thread let me know

limber urchin
#

Make a thread please

astral mist
#

its been syncing for 10 min

young bone
#

I had it for 2 days

#

and after that I created a new bot

silver moat
#

could you use

for command in bot.walk_application_commands():
  print(command)

in on_ready and show output?

astral mist
silver moat
#

yes, you

astral mist
#

Pong!
205ms
this is the latency of the bot

this is my output because i have a loop running to tell me

#

the ping

silver moat
#

so is on_ready not firing?

astral mist
silver moat
#

Do you have on_connect in your code?

astral mist
limber urchin
#

Check your code then

#

And add a print in your on_ready

astral mist
limber urchin
#

huh

astral mist
limber urchin
#

what event? and what kind of loop?

eternal wing
#

To see if it executes

eternal wing
#

If it doesn't, somethin wrong big time

astral mist
silver moat
#

you still haven't answered the question

limber urchin
#

what event? and what kind of loop?

astral mist
# limber urchin what event? and what kind of loop?

@bot.event
async def on_ready():
while True:
game = discord.Game("syncing slash commands")
await bot.change_presence(status=discord.Status.idle, activity=game)
print(f'Pong! \n {round(bot.latency * 1000)}ms \n this is the latency of the bot ')
hook.send(STATUS)
time.sleep(30)
print(f'Pong! \n {round(bot.latency * 1000)}ms \n this is the latency of the bot ')
hook.send(STATUS)

#

like this type

#

that dose stuff on being run

silver moat
#

bruh

limber urchin
#

?tag codeblock

obtuse juncoBOT
#

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

That makes reading code in Discord a lot easier:

print("This is an example.")
limber urchin
#

and also

astral mist
#

and its a while true loop that dose for me

limber urchin
#

facepalm

astral mist
limber urchin
#

Do you know basic Python?

#

and async in Python?

silver moat
#

async is basic

astral mist
limber urchin
astral mist
#

to my server while being online

limber urchin
#

so why time.sleep? which is blocking

eternal wing
#

use tasks for that

astral mist
limber urchin
#

while that loop is running

#

which is forever

astral mist
limber urchin
#

Learn async/await in python and use tasks

astral mist
#

cant u just help me

limber urchin
#

I have helped you

eternal wing
#

You need to learn stuff not only copy code

limber urchin
#

I have told you everything you need to know

astral mist
#

at least the bot works now

little breach
#

Jo, I am new writing Discord Bots and i have a weird error message. You can see the code on the picture. I try to make a member Join message, but when the event get triggerd, than the console giving me a weird error message and I dont check why. Can someone maybe help me?

young bone
#

remove that and use member.guild

little breach
#

oh yeah it worked, thx 😄

astral mist
eternal wing
astral mist
fervent cradle
#

How can i get the interaction.user (or interaction.user.name) from another button, so for eg
I am creating an embed but need the user who used a button from another button

#

Im not sure if that makes sense

fervent cradle
astral mist
fervent cradle
#

Learning to code takes time, and effort

astral mist
fervent cradle
#

👍

astral mist
#

Or

#

I will motivate my self

eternal wing
#

Technically you have all the time in the world

eternal wing
#

It works, definitely will get either slow or overwrite stuff if it gets executed quickly and a lot at the same time

fervent cradle
#

What would be the best way to do it?

eternal wing
#

No idea, that's why i said about the janky way

proud mason
#

That's a legit way. Using db

#

That's is soo much better than using global variables

proud mason
#

Or like the other guy said, db

eternal wing
#

Personally i would suggest sqlite, it's easy to learn, not that heavy on the system too i believe

limber urchin
#

If you don't care about persistence, redis will be fine too

gaunt cosmos
#

i keep getting this error but dont know how to fix it, this was working some time ago but doesnt work now for some reason

#

any ideas on how i can fix this and why this is happening?

fervent cradle
#

you haven't defined message or have it anywhere

#

explains itself

green hinge
#

Can I limit the length of the str for an input option?

fervent cradle
#

eh you could check how many characters it's got then have an if statement to allow or deny it

green hinge
limber urchin
#

?

#

that is literally the class for the options used in slash commands

green hinge
limber urchin
#

Did you read the docs? bruh

green hinge
#

Oh nvm I am stupid 😄

worldly smelt
#

hi, how can i start/stop/restart a task that's defined in a different cog?

fervent cradle
full basin
#

You place your super().init first

#
def __init__(self):
     super()...
     options = ....```
#

interaction.response.edit_message should be

#

Not interaction.message.edit

#

Oh

#

.rtfm interaction.original_message

winter condorBOT
full basin
#

message = interaction.original_message
message.edit

#

Then send the modal

#

You always could

#

You were not able to delete them

silver moat
#

I think you are mis-understanding what interaction.message is. It is the response message, not the message it is attached to.

full basin
#

.rtfm interaction.message

winter condorBOT
silver moat
#

Is what possbile? Editing ephemeral messages, yes.

#

you have to await it

full basin
#

Yeah a couroutine. Forgot about it

#

Yes you can

#

You're doing it with the original_message

silver moat
#

Not the message the view is associated to

#

you can use self.view.message to retrieve the message

full basin
silver moat
full basin
#

Oh you were just quoting the docs lmao

delicate spade
#

how do i add text like this with an embed

full basin
#

Just like you did

delicate spade
#

alright how do i @frank cedar without pinging them within an embed

#

sorry someone

silver moat
delicate spade
silver moat
#

user.mention returns a string that you can use to mention people

rare ice
#

or <@{user.id}>, but preferably user.mention

silver moat
#

native solutions are usually preferred.

delicate spade
#

another question. how do i check if a the command was typed in a specific channel

#

docs are down rn thats why im asking

young bone
dawn vector
#

do you guys know how to make the bot appear on the user list?

young bone
dawn vector
#

which one do i need to add

#

@young bone ?

young bone
dawn vector
delicate spade
#

Uh oh! This site is in maintenance mode. Something big is coming, check back later!

#

so either way whats the answer if you know

rare ice
gilded niche
#

await interaction.edit_original_response(embed=embed, view=view, ephemeral=True) Why doesnt this work? I get unexpected keyword 'ephemeral'

rare ice
#

You can’t edit a message to be hidden.

#

You can only send a message as hidden from an interaction

gilded niche
#

But if i try it without it says unknown webhook

#

How would i fix that?

rare ice
gilded niche
#

@rare ice

rare ice
#

Send full code and full error

#

@gilded niche

gilded niche
#

@rare ice

rare ice
#

.edit_original_response is mainly used for ephemeral messages

gilded niche
#

Thanks! That worked

#

❤️

fervent cradle
#
Traceback (most recent call last):
  File "/home/container/.local/lib/python3.10/site-packages/discord/ui/view.py", line 414, in _scheduled_task
    await item.callback(interaction)
  File "/home/container/main.py", line 283, in callback
    await ticket_channel.send(embed=embed, view=StaffApp)
  File "/home/container/.local/lib/python3.10/site-packages/discord/abc.py", line 1550, in send
    components = view.to_components()
TypeError: View.to_components() missing 1 required positional argument: 'self'``` 

Error!!
#
    def __init__(self):
        super().__init__(timeout=None)
        @discord.ui.button(label="Staff Application", style=discord.ButtonStyle.primary)
        async def button_callback(
            self, button: discord.ui.Button, interaction: discord.Interaction
        ):
            modal = MyModal(title="Staff Application")
            await interaction.response.send_modal(modal)```
#

code

young bone
#

for what do you need the view=?

#

@fervent cradle

fervent cradle
#

im removing it rn

daring trout
#
channel = ctx.message.channel
young bone
#

?tag idw

obtuse juncoBOT
#

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

viscid rapids
daring trout
#

File "d:\Coding\Discord.py\Trignometry Bot\main.py", line 19, in ping
channel = ctx.message.channel
^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'channel'

#
channel = ctx.message.channel
```` solve this
viscid rapids
#

whats the context here.

daring trout
#

this is

fervent cradle
daring trout
#
@bot.slash_command()
async def ping(ctx):
    channel = ctx.message.channel
    t1 = time.perf_counter()
    await bot.send_typing(channel)
    t2 = time.perf_counter()
    await bot.say("pseudo-ping: {}ms".format(round((t2-t1)*1000)))
    print("Ping Command activated")
viscid rapids
#

also u dont have to await that, I don't think.

fervent cradle
#
async def ping(ctx):
    channel = await ctx.message.channel
    t1 = time.perf_counter()
    await bot.send_typing(channel)
    t2 = time.perf_counter()
    await channel.send("pseudo-ping: {}ms".format(round((t2-t1)*1000)))
    print("Ping Command activated")```
#

there.

viscid rapids
#

u changed nothing??

fervent cradle
viscid rapids
#

ohh right

#

I mean that's one error

fervent cradle
#

await channel.send("pseudo-ping: {}ms".format(round((t2-t1)*1000)))
that was
await bot.say("pseudo-ping: {}ms".format(round((t2-t1)*1000)))

viscid rapids
daring trout
#

hmm

daring trout
viscid rapids
daring trout
#

how it can be executed

#

if the error comes in the line before it

viscid rapids
#

try ctx: Context

daring trout
silver moat
#

?tag guide

obtuse juncoBOT
viscid rapids
#

oh yeah noticed his decorator was completely wrong lol

#
@bot.slash_command(guild_ids=[ID], description="Ping")
async def ping(ctx):
    channel = ctx.message.channel
    t1 = time.perf_counter()
    await bot.send_typing(channel)
    t2 = time.perf_counter()
    await ctx.respond("pseudo-ping: {}ms".format(round((t2-t1)*1000)))
    print("Ping Command activated")

@daring trout this prolly works.

silver moat
silver moat
#

await bot.send_typing(channel) also no longer works

viscid rapids
#

ah jesus christ

daring trout
silver moat
#

ctx.message.channel also would not work

#

the message would be None. The correct is ctx.channel, but channel isn't used.

daring trout
#

what should i do now?

silver moat
#

which would not work

silver moat
viscid rapids
#

very sadge

daring trout
#

thanks

silver moat
#

you're welcome

daring trout
#

now tell me how to read the docs

#

I am very bad in it

silver moat
#

In what sense?

daring trout
#

I have completed learning python a few months ago

#

I want to know how to use pycord

silver moat
daring trout
#

so i am facing problem

silver moat
#

did you learn these concepts?

daring trout
#

hmm what to do after this

silver moat
#

you can begin by reading the guide

daring trout
#

after that what to do

silver moat
#

Do whatever you want with pycord.

#

Implement your own Discord bot, wherever your imaginations take you.

daring trout
#

is this enough

#

that i can use pycord easily?

silver moat
#

It comes with practice.

daring trout
#

ok

silver moat
#

gl

#

If you have any questions, we are here for you!

daring trout
#

@silver moat

#

solve this

silver moat
#

is the correct link

daring trout
#

how to understand docs

#

i am not able to justify it

daring trout
#

hlo

#

cogs are not working

#

@silver moat

#

bro cogs are not working

silver moat
#

.idw

winter condorBOT
#

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

daring trout
#
Microsoft Windows [Version 10.0.22621.963]
(c) Microsoft Corporation. All rights reserved.

D:\Coding\Discord.py\Trignometry Bot>C:/Users/Dell/AppData/Local/Programs/Python/Python311/python.exe "d:/Coding/Discord.py/Trignometry Bot/main.py"
Traceback (most recent call last):
  File "C:\Users\Dell\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\cog.py", line 561, in _inject
    bot.add_command(command)
    ^^^^^^^^^^^^^^^
AttributeError: 'Bot' object has no attribute 'add_command'. Did you mean: 'all_commands'?
#

see

#
import discord
from dotenv import load_dotenv
import os 

load_dotenv()

client = discord.Bot()

client.load_extension("cogs.basics")

token = str(os.getenv("TOKEN"))
client.run(token)
silver moat
#

.codeblocks

#

?tag codeblocks

obtuse juncoBOT
#

dynoError No tag codeblocks found.

silver moat
#

?tag codeblock

obtuse juncoBOT
#

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

That makes reading code in Discord a lot easier:

print("This is an example.")
silver moat
#

and also show code for the cog itself

daring trout
#
import discord
from discord.ext import commands
import time
import random


class Greetings(commands.Cog):
    def __init__(self, client):
        self.client = client
        self.random = random

    @discord.slash_command(name = 'gtn', description = 'A Slash Command to play a Guess-the-Number game.')
    async def guess_no(self, ctx):
        await ctx.respond('Guess a number between 1 and 10.')
        guess = await self.client.wait_for('message', check=lambda message: message.author == ctx.author)

        if int(guess.content) == self.random.randint(1, 10):
            await ctx.send('You guessed it!')
        else:
            await ctx.send('Nope, try again.')

def setup(client): # this is called by Pycord to setup the cog
    client.add_cog(Greetings(client))
    print("Greetings Cog Loaded")
daring trout
#

not able to paste

#

becuz i dont have nitro

#

discord not allows me

silver moat
#

send in multiple messages

daring trout
#

bruh!!!

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

Traceback (most recent call last):
  File "d:\Coding\Discord.py\Trignometry Bot\main.py", line 9, in <module>
    client.load_extension("cogs.basics")
  File "C:\Users\Dell\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\cog.py", line 910, in load_extension
    self._load_from_module_spec(spec, name)
  File "C:\Users\Dell\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\cog.py", line 791, in _load_from_module_spec
    raise errors.ExtensionFailed(key, e) from e
discord.errors.ExtensionFailed: Extension 'cogs.basics' raised an error: AttributeError: 'Bot' object has no attribute 'remove_command'
#

this is the remaining

silver moat
#

I don't see the first part?

daring trout
#

#998272089343668364 message

silver moat
#

try using Python 3.10 or lower

daring trout
#

bruh

daring trout
#

@silver moatstill errror

silver moat
daring trout
#

see

daring trout
silver moat
#

try re-installing.

daring trout
#

?

#

what

silver moat
#

re-installing py-cord?

daring trout
#

bruh

daring trout
silver moat
daring trout
#

some problem in your library

silver moat
#

restarted IDE?

daring trout
#

Enough, THanks for help

silver moat
daring trout
#

no

sick quest
#

is there a way to pass in parameters to a button view?

class MyView(discord.ui.View):
    def __init__(self, msglink):
        self.msglink = msglink

    @discord.ui.button(label="Message Link", style=discord.ButtonStyle.link, url=self.msglink)
    async def callback(self, button, interaction):
        ...

I've tried ^ but it says self is not defined where I say url=self.msglink

silver moat
daring trout
#

😶

silver moat
silver moat
sick quest
#

also is there a way to ctx.send_response and get the message that is sent? (as a discord.Message object)

silver moat
sick quest
#

I know that

#

that's not what I mean

#

like if you send a message with await ctx.send_response("foo")

#

I want to get that message, the one the bot sent

silver moat
sick quest
#

I see

viscid rapids
#
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: filter expected 2 arguments, got 4

filter is defined here:

async def filter(self, ctx, img, usr, op):
#

called like this:

@discord.slash_command(guild_ids=config['main_guilds'],description="turns an image to black & white.")
    async def bw(self, ctx, image: discord.message.Attachment = None, user: discord.Member = None):
        image = await filter(ctx, image, user, "bw")
verbal marten
#

But not sure about the 2 args Confusion

viscid rapids
#

YEAH, it's cus filter is an internal arg.

#

which takes two.

#

that was the fck up........

verbal marten
#

OH that makes sense

viscid rapids
#

is there a way to like abort a command?

verbal marten
viscid rapids
#

dope, that works.

amber shale
#

what is rate limit for editing a guild command?

viscid rapids
#

I don't get how there is no description?

@discord.slash_command(guild_ids=config['main_guilds'], description="Mass deletes messages")
    @commands.has_permissions(manage_messages=True)
    @option("messages", description="Amount of messages to delete.")
    @option("member", description="Specific member to delete from.")
    async def purge(self, ctx: Context,  messages: int, user: discord.Member = None):
viscid rapids
#

in any example, it doesn't look like I can provide multiple options

wild cobalt
#

is there a quick way to get a datetime of the last activity in a thread? could use the creation time of the last message but that would ignore reactions etc yes?

amber shale
#

oh

#

i thought we were in here

worn prawn
# amber shale i thought we were in here

There is some discord rate limits and in pycord sync is automatically so i guess pycord handle the rate limits and your command will updates later but I'm not sure please read discord api docs before doing this

#

Also not recommended for production

amber shale
worn prawn
amber shale
#

yeah 😅

worn prawn
#

It's on you what you wanna do but it's not recommended

amber shale
#

yeah but thats what i want to do

worn prawn
#

Because discord has rate limits and you are saying you are gonna update your command in every second then it will hit the rate limits and you will get warning and then you will get rate limited from discord or ban

amber shale
#

i can reduce that to every 5 sec or more

worn prawn
#

Also there is not any reason that you are have to update a command 😂

worn prawn
amber shale
#

can i know how many times i can update command?

#

in 1 min

worn prawn
#

Also Your bot will die soon if you do this in production

amber shale
worn prawn
amber shale
worn prawn
#

Then why are you creating your bot ?? Know one use it too 😂

fervent cradle
#

🤣

sick quest
#

What is the best way to test a discord bot? I typically develop on my personal computer and then when I've tested it push it to a home server and run it there -- but I have to then take down the bot every time I am developing it. I was thinking I could either:

  1. Create another bot, and just replace the token on my personal computer to the test bot
  2. Subclass my existing bot as like a test bot and have it run differently on my personal computer?

The first option seems easier and less complicated than the second one, but I saw that the Pycord docs use the second method

fervent cradle
#

jk

simple canopy
#

объясни на русском лучше

fervent cradle
#

Я с ролями такое делал

simple canopy
#

||god, dang it, why would you need to name a fucking function in russian 💀||

fervent cradle
#

с участниками не понял

simple canopy
fervent cradle
#

чота не получается

simple canopy
#

там в конструкторе interaction

#

есть interaction.user.id

#

а при создании view

#

ты можешь передавать туда айди чела, который команду юзанул

#

и просто сверять

fervent cradle
#

а там только через айди работает?

simple canopy
#

это самый удобный способ

fervent cradle
#

ладно, попробую

#

спасибо

simple canopy
#

👍

amber shale
#

chat was encrypted 👍

proud cargo
#

Can you create a new discord bot account through pycord?

simple canopy
#

no

#

you can only create bots on developer portal and then code them with pycord.

plush meadow
#

forgive the stupid question, is there something like an on_command event? I am looking to perform some sort of operation every time any slash command is invoked. I wasn't able to find anything in the docs 😦

#

if someone has a link to it in documentation, that totally works

#

I notice discord.on_application_command(context), but I am looking to do something in between the actual invocation of the command and its actual operation (and perhaps be able to stop the command from triggering under certain conditions)

proud mason
#

Are you looking for checks

#

.rtfm check

proud mason
#

Oof those are too many

plush meadow
#

well, I'm not entirely sure. can this be accomplished with checks? I would like to be able to intervene with the command being called if possible

proud mason
#

Yeah command checks are run before invoking the command callback. You can raise errors to stop the callback from being run. These errors and be picked up by the command error handler or the global error handler to respond something like "you can't run this cmd"

#

@limber urchin hey I saw you typing. You got any example/docs links or tags for checks? I'm a noob with tags

limber urchin
plush meadow
#

this is exactly it, global checks

#

you guys are awesome, thanks a lot

median ridge
#

How to make slash command response hidden to everyone except the executor

limber urchin
#

Add ephemeral=True in your response method

median ridge
grizzled sentinel
#

@stoic sage
You likely forgot to update the message with the new view.
interaction.edit_original_message(view=view)

fervent cradle
limber urchin
#

Remove what? The tooltip?

fervent cradle
#

this part

limber urchin
#

No, you can not

fervent cradle
#

?tag install github

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

limber urchin
#

@fervent cradle move to #app-commands if you're going to spam random commands

fervent cradle
#

I didnt spam, but yes ill use that chat for future use sorry

limber urchin
#

that way it won't display above the message

fervent cradle
fervent cradle
#

I am learning to create a slash command group, and i dont understand what this is doing/for?

        "secret_greetings",
        "Secret greetings",
        checks=[
            commands.is_owner().predicate
        ],  # Ensures the owner_id user can access this group, and no one else
    )```
#

Is that command groups that only owner can use?

silver moat
fervent cradle
#

👍

#

ty

storm hull
#

is there any public repos that have a good setup with examples of the different functionality, like cogs, slash commands, buttons, embeds, tasks etc? Looking at some of these, but they are all very different in some ways https://github.com/topics/pycord-bot

#

talking about "best practice" in terms of naming, setup etc. Maybe some included default slash commands like unload, reload, help etc?

silver moat
#

It is structurally sound

limber urchin
#

You are probably trying to edit a message that doesn't exist

fervent cradle
#

TypeError: issubclass() arg 1 must be a class

from discord.ext import commands
from discord.commands import SlashCommandGroup
from discord import option
class poll(commands.Cog):
    def __init__(self, bot: discord.Bot):
        self.bot = bot
    Poll = SlashCommandGroup("poll", "Different Poll Groups")
    PollOptions = Poll.create_subgroup(
        "pollcreate", "help", "anonymous"
    )
    @Poll.command()
    async def poll(self,
    ctx: discord.ApplicationContext,
    message,
    choice1: option(str,"First Poll Option"),
    choice2: option(str,"Second Poll Option"),
    choice3: option(str,"Third Poll Option"),
    choice4: option(str,"Fourth Poll Option"),
    choice5: option(str,"Fifth Poll Option"),
    choice6: option(str,"Sixth Poll Option"),
    choice7: option(str,"Seventh Poll Option"),
    choice8: option(str,"Eighth Poll Option"),
    choice9: option(str,"Ninth Poll Option"),
    choice10: option(str,"Tenth Poll Option")):
        await ctx.respond()
def setup(bot):
    bot.add_cog(poll(bot))
#

I've never gotten this error before, i have no idea whats happened

#

I changed them from discord.Option to option because the params wouldnt show

limber urchin
#

option can only be used as a decorator, use discord.Option if you're going to typehint

fervent cradle
#

Alright

#

None of the choice params are showing when i run the command

fervent cradle
#

Is using @real compasstion better for this?

#

@real compasstion

#

sorry mate its auto corrected to ping ya

#

But spaxter yk what i mean?

fervent cradle
#

Okay

fervent cradle
proud mason
fervent cradle
#

So @ Option (
blah blah
)

proud mason
fervent cradle
fervent cradle
#
    "age",
    description="Enter your age",
    min_value=1,
    max_value=99,
    default=18,
    # Passing the default value makes an argument optional.
    # You also can create optional arguments using:
    # age: Option(int, "Enter your age") = 18
)``` should i do this sorta thing then
#

Its cleaner + probably better?

proud mason
#

Yep

fervent cradle
#

Alright thanks

fervent cradle
proud mason
#

There is min and Max length

fervent cradle
#

Alright

fervent cradle
# proud mason There is min and Max length

Weird, Have i done something wrong? Choice1 isnt showing

from discord.ext import commands
from discord.commands import SlashCommandGroup
from discord import option

class poll(commands.Cog):
    def __init__(self, bot: discord.Bot):
        self.bot = bot
    Poll = SlashCommandGroup("poll", "Different Poll Groups")
    PollOptions = Poll.create_subgroup(
        "pollcreate", "help", "anonymous"
    )
    @Poll.command()
    @option("choice1",
    description = "Option one of the poll",
    default=None,)

    async def poll(self,
    ctx: discord.ApplicationContext,
    message,
    choice1: str,
    choice2: str,
    choice3: str,
    choice4: str,
    choice5: str,
    choice6: str,
    choice7: str,
    choice8:str,
    choice9: str,
    choice10: str,
    ):
        await ctx.respond("Works")
def setup(bot):
    bot.add_cog(poll(bot))``` No error btw
proud mason
#

Hmm

proud mason
#

Gonna conflict

#

Name the cog smth like PollCog

fervent cradle
#

Oh thanks, i always just forget abt the cog related code

proud mason
#

Also don't forget the decorators for the other options

#

Lol

fervent cradle
proud mason
#

Oh and if you make an option optional or set a default then don't forget to do the same for the python typehint

fervent cradle
#

Im just having a look over the code again

#

Weird i dont see anything still, if anyone else knows please lmk and @ me

limber urchin
#

no, look at the docs

#

and is interaction.response an instance of Interaction?

#

?

green hinge
#

Hello,
is it possible to create a slashcommand where you tag users from the server?

/slash @User1 @User2 @User3

And then evaluate the corresponding User.IDs from the bot, so that I can move these users? 🙂

limber urchin
limber urchin
#

what?

fervent cradle
#

No that isnt how i works

#

it*

proud mason
green hinge
fervent cradle
proud mason
fervent cradle
limber urchin
proud mason
proud mason
fervent cradle
green hinge
proud mason
green hinge
# proud mason Yep

But the select options are also static and can not be built dynamically or?

fervent cradle
proud mason
fervent cradle
#

Isnt that version like v1?

proud mason
#

.rtfm user_select

winter condorBOT
proud mason
#

2nd one

proud mason
fervent cradle
#

Okay

fervent cradle
green hinge
proud mason
errant craneBOT
#

Here's the dropdown example.

proud mason
#

Check if that has an example

proud mason
#

Uninstall and reinstall

fervent cradle
# proud mason Hmm
from discord.ext import commands
from discord.commands import SlashCommandGroup
from discord import option

class pollCog(commands.Cog):
    def __init__(self, bot: discord.Bot):
        self.bot = bot
    poll = SlashCommandGroup("poll", "Different Poll Groups")
    PollOptions = poll.create_subgroup(
        "pollcreate", "help", "anonymous"
    )
    @poll.command()
    @option("choice1",
    description = "Option one of the poll",
    default=None,)

    async def poll(self,
    ctx: discord.ApplicationContext,
    message,
    choice1: str,
    choice2: str,
    choice3: str,
    choice4: str,
    choice5: str,
    choice6: str,
    choice7: str,
    choice8:str,
    choice9: str,
    choice10: str,
    ):
        await ctx.respond("Works")
def setup(bot):
    bot.add_cog(pollCog(bot))
``` The command isnt even showing up at all anymore...??
#

Not sure if its my discord or not

green hinge
proud mason
proud mason
#

Btw that link doesn't have example

#

It's an example for a normal select menu. Not a user select menu

fervent cradle
# fervent cradle Weird, Have i done something wrong? Choice1 isnt showing ```import discord from ...

Reverted back to this code, it runs, no command but i get this
Traceback (most recent call last):
File "C:\Users\Wacky\Documents\Poll Bot\venv\Lib\site-packages\discord\client.py", line 377, in _run_event
await coro(*args, **kwargs)
File "C:\Users\Wacky\Documents\Poll Bot\venv\Lib\site-packages\discord\bot.py", line 1164, in on_connect
await self.sync_commands()
File "C:\Users\Wacky\Documents\Poll Bot\venv\Lib\site-packages\discord\bot.py", line 719, in sync_commands
registered_commands = await self.register_commands(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Wacky\Documents\Poll Bot\venv\Lib\site-packages\discord\bot.py", line 599, in register_commands
registered = await register("bulk", data, _log=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Wacky\Documents\Poll Bot\venv\Lib\site-packages\discord\http.py", line 366, in request
raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In 0.options.1.options.2: Required options must be placed before non-required options
In 0.options.1.options.3: Required options must be placed before non-required options
In 0.options.1.options.4: Required options must be placed before non-required options
In 0.options.1.options.5: Required options must be placed before non-required options
In 0.options.1.options.6: Required options must be placed before non-required options
In 0.options.1.options.7: Required options must be placed before non-required options
In 0.options.1.options.8: Required options must be placed before non-required options
In 0.options.1.options.9: Required options must be placed before non-required options
In 0.options.1.options.10: Required options must be placed before non-required options

#

do i need to finish the options

limber urchin
#

The error explains exactly what's wrong

fervent cradle
#

Yeah thats what i just said ^

#

Fixed it

proud cargo
#

how do i make this

#

(the Ends: in a day thing)

fervent cradle
#

<t:1671217800:R>

proud cargo
green hinge
woeful spindle
# silver moat I'm sorry. I don't know what else I can help you with. The code is correct and a...

discord.Bot has no add_command attribute, as their error said. They probably want to use add_application_command. -> https://docs.pycord.dev/en/stable/api/clients.html#discord.Bot.

#

@daring trout If you still need help. ^

fervent cradle
#

How can i have

    choice2: str,
    choice3: str,
    choice4: str,
    choice5: str,
    choice6: str,
    choice7: str,
    choice8:str,
    choice9: str,
    choice10: str,``` in a variable sorta thing? so i can check for eg if len(options) is 2 then reacts with certian reactions
silver moat
woeful spindle
stoic sage
#

how can we get label instead of value from discord.ui.Select

#

select.values[0] works for value but select.labels[0] doesn't for labels

silver moat
silver moat
#

or you can iterate through select.options and find the discord.SelectOption with said value.

stoic sage
silver moat
#

Why do you need the label?

stoic sage
#

i've title for level and an id for value

#

bot should display the title so it set in label

#

but i require both on select callback

silver moat
#

you can set the value to include the label as well.

stoic sage
#

any other method?

silver moat
#

This is rather inefficient because it is linear time complexity, while the previous method is constant time complexity.

proud mason
green hinge
silver moat
proud mason
green hinge
# proud mason select.values should have a list of users selected

What am I doing wrong?

import discord
from discord.ui import Select, View
from discord.ext import commands

bot = discord.Bot()

@bot.event
async def on_ready():
    print('Bot is Online!')

class MySelect(View):

    @discord.ui.user_select(
        placeholder='Wähle einen User'
    )

    async def select_callback(self, select, interaction):
        select.disabled=True
        print(select.values)


@bot.command()
async def menu(ctx):
    view = MySelect()
    await ctx.send(view=view)

bot.run('TOKEN')```
silver moat
green hinge