#Basic Pycord Help (Quick Questions Only)

1 messages · Page 47 of 1

polar plume
#

is that the issue?

silver moat
#

maybe

polar plume
#

lemme test it

proud mason
#

Doesn't matter tbh

limber urchin
#

Can you pass args like that?

silver moat
limber urchin
#

Never seen it done like that before, unsure if it works

whole urchin
#

client = commands.Bot*

astral mist
#

?tag embeds

obtuse juncoBOT
#

dynoError No tag embeds found.

whole urchin
astral mist
#

Where can u find embeds docs

whole urchin
astral mist
#

So I am asking if someone can give me the link to it

whole urchin
#
@bot.command()
async def embed(ctx):
  embed=discord.Embed(
    title="yes",
    description="yes",
    color=discord.Colour.green
  )
  await ctx.send(embed=embed)```
#

@astral mist example of an embed ^^^

astral mist
whole urchin
#

the docs are kinda useless, super complicated

#

better off asking someone else

astral mist
#

Since it’s a fork and not much different

whole urchin
#

embeds in pycord, d.py and Nextcord are the same

astral mist
#

Alr

whole urchin
#

in Nextcord just change the discord.Embed to nextcord.Embed

astral mist
#

Yeh

#

Alr

proud mason
astral mist
#

.rtfm discord.Embed

limber urchin
serene spindle
#

Navigating is just difficult tbh

limber urchin
#

Eh, not really. The search feature is a bit lacking but other than that it's perfectly fine

serene spindle
#

Oh yeah fs, search feature works perfectly. It’s just navigating with the sidebar menu thing that’s a bit weird imo

limber urchin
#

I don't see a situation where you'd need the sidebar tbh. Just search for what you need and navigate through the hyperlinks. But I'd definitely like to see the search to be improved. It doesn't prioritize exact matches, and for some reason doesn't seem to take underscores into account when searching.

#

In this case, the on_connect docs should definitely be the first result imo

serene spindle
#

Hmm yeah, same with things like discord.Embed which are most of the time really important in a bot lol

limber urchin
#

Either way, learning to navigate and utilize documentation is a must if you ever want to become a good developer. If you only rely on code examples and help from other people you won't get too far.

fringe socket
#

Anybody know what this error means? I don't have any loops at all in my code.

limber urchin
#

That's referencing your asyncio event loop. And the error means the loop has closed. Why? Impossible to say since you don't show the code causing the error.

fringe socket
#

The bot runs fine, it's just that when I close the connection, it doesn't shut down, and gives me that error, and only shuts down when I close it again.

limber urchin
#

And how are you closing the connection?

fringe socket
#

Thank you for watching my tutorial on how to stop your code. doggokek

#

Well... the bot shuts down. The code doesn't.

limber urchin
flat merlin
#

Is it possible to have a local file as a thumbnail on an embed sent using the paginator?

proud mason
#

Try it and see

#

?tag localfile

obtuse juncoBOT
#
f = discord.File("some_file_path", filename="image.png")
e = discord.Embed()
e.set_image(url="attachment://image.png")
await messagable.send(file=f, embed=e)```
prime creek
#
from discord.ext import commands
import discord

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

    @commands.command()
    async def ping(self, ctx: commands.Context):
        await ctx.send(
            embed = discord.Embed(title="ping",description=f"the ping is {round(self.bot.latency * 100, 2)} ms ",color=discord.Color.random())
        )

    @commands.Cog.listener("on_ready")
    async def on_ready(self):
        print(f"connesso il bot {self.bot.user}")

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

i don't know why it doesn't work

#

the script that i use for loading the cog is this:

#
import discord
from discord.ext import commands
import os
from dotenv import load_dotenv

load_dotenv()
token = os.environ["token"]


intent = discord.Intents.all()

bot = commands.Bot(command_prefix=commands.when_mentioned_or("."), intents=intent)
 
cogfiles = [f"cog.{filename[:-3]}"for filename in os.listdir("./cog/") if filename.endswith(".py")]


for cogfile in cogfiles:
    try:
        bot.load_extension(cogfile)
    except Exception as err:
        print(err)


@bot.event
async def on_ready():
    print("connesso")


"""
@bot.command()
async def ping(ctx):
    await ctx.reply("sesso")
"""


bot.run(token)
limber urchin
winter condorBOT
# prime creek i don't know why it doesn't work

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.

prime creek
#

basically when i try to run the command from the cog it says "command.notfound"

limber urchin
#

Add a print in the cog's setup function and see if it runs

prime creek
#

ok

whole urchin
#

it sounds very similar

#

its funny

limber urchin
#

Good for you, now please stay on topic or move to #general

#

Generating options?

errant craneBOT
#

Here's the slash autocomplete example.

#

Here's the slash options example.

prime creek
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.

prime creek
#

issue fixed

#

ty you all

summer sierra
#

so i just started using Pycord, but i have been using python for 2 years now, and i've used DJS a lot so i have a grasp on bot development

im working with cogs atm and while the command works, the event doesn't... as you can see, it's found but it just doesn't do anything. what am i doing wrong, and how do i fix it?

summer sierra
#

fixed it: changed name="ready" to name="on_ready", my bad lmaocry

cinder pilot
#

I see
Thanks btw

proud mason
vale prism
#

can I use the @has_permissions decorator to check if the user has any of the provided permissions, not all

west venture
#

Question
I have a shop server where i want my ppl to create ticket and once they close the ticket they have to get a dm thing in which "rate us" as a button , than the bot will ask rate the server out of 5 , proceded by the answer for eg. the user choosed 3 it should send in a specific channel of the server that the user rated 3/5. so i have no idea how to do that

cyan quail
#

it's either one or the other

west venture
# west venture **Question** I have a shop server where i want my ppl to create ticket and once ...
    async def callback(interaction):
        await interaction.response.send_message(f"Wait creating a {select.values[0]}", ephemeral=True)
        guild = bot.get_guild(c.guild)
        ticket_category = get(guild.categories, name="━━| TICKETS |━━")
        ticket_channel = await guild.create_text_channel(f"{select.values}-{interaction.user.name}" , category=ticket_category)
        await ticket_channel.set_permissions(guild.default_role, view_channel=False, read_messages=False, send_messages=False)
        await ticket_channel.set_permissions(interaction.user, read_messages=True, send_messages=True)

        embed = discord.Embed(
            title="Ticket Created",
            description=f"Ticket for {interaction.user.mention} is created\n**Support will be with you shortly.**\n\nTo close this ticket react with 🔒",
            timestamp=datetime.datetime.utcnow()
        )
        button = Button(label="Close", emoji="🔒", style= discord.ButtonStyle.danger)
        async def button_callback(interaction):
            await interaction.response.send_message(f"Wait Closing your {select.values[0]}")
            await ticket_channel.set_permissions(interaction.user, read_messages=False, send_messages=False)
            await ticket_channel.delete()

            embed = discord.Embed(
                title="Ticket Closed",
                description=f"hey {interaction.user.mention} your ticket let us know your review",
                timestamp=datetime.datetime.utcnow()
            )
            button_review = Button(label="Rate Us", emoji="⭐", style= discord.ButtonStyle.primary)
            view = View()
            view.add_item(button_review)
            await interaction.user.send(interaction.user.mention ,embed=embed, view= view)

        view = View()
        view.add_item(button)
        await ticket_channel.send(interaction.user.mention , embed=embed, view=view)
        
        button.callback = button_callback
    select.callback = callback

vale prism
cyan quail
#

if im not mistaken it would require all

vale prism
#

okay

#

thanks

rugged iris
#

why isnt discord.commands not popping up anymore like in the old version i had no problems

rare ice
#

Please don't cross post.

rare ice
proud mason
#

You don't really have any alternative other than checking each command manually

#

Huh

errant craneBOT
#

Here's the slash autocomplete example.

proud mason
#

Check that out

rugged iris
#

why i am getting this error
like why am i getting this error

proud mason
#

Show pip list

rugged iris
#

aah got it

proud mason
rugged iris
#

i dint link my current virutal environment with the code

proud mason
#

Ah lol

rugged iris
#

lol

spare juniper
#

Doesnt that loop thru characters?

#

Wait

#

if in

#

noted

proud mason
#

Uh what?

grizzled mason
#

Yoo folks i aint long into discord bots and i wanted to run mine and this is the error i get can somone help me?

proud mason
#

Don't name your file discord

spare juniper
#

dont name your file discord

grizzled mason
proud mason
grizzled mason
spare juniper
#

main anything ekse

grizzled mason
#

ok 👍

proud mason
grizzled mason
proud mason
#

I sent you a GitHub example of autocomplete

spare juniper
grizzled mason
cinder pilot
#

Yes that is the problem

#

Rename one of the commands

rare ice
grizzled mason
rare ice
#

in your terminal

fervent cradle
#

how do i get roles in slash commands options?

grizzled mason
#

client = main.Client()

@client.event
async def on_ready():
    print(f'{client.user} has connected to Discord!')

@client.event
async def on_message(message):
    if message.author == client.user:
        return

    if message.content.startswith('/verify'):
        # Check the user's credentials here
        verified = True  # Replace this with your verification function
        if verified:
            await message.channel.send('You have been verified!')
        else:
            await message.channel.send('no.')

client.run('nothing to see here')
rare ice
fervent cradle
#

thanks

rare ice
#

.rtfm discord.Option.option_type

winter condorBOT
#

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

proud mason
#

Oh wait that was not for you. It was for the guy after you

rare ice
#

.rtfm discord.Option

grizzled mason
rare ice
proud mason
#

Not really. Doesn't seem an issue. Are they in the same file?

proud mason
rare ice
#

just use discord.Client

proud mason
#

Yeah that's the issue. Rename the function. Command name is fine

spare juniper
#

or new issue

grizzled mason
grizzled mason
rare ice
winter condorBOT
# grizzled mason like this?
spare juniper
rare ice
#

You should learn basic python before using pycord.

proud mason
#

🗿

rare ice
#

@grizzled mason store discord.Client() in the client variable

grizzled mason
grizzled mason
rare ice
#

still, you should know basic python and oop before using pycord.

#

client = discord.Client()

proud mason
#

Yeah learning python will really help you

grizzled mason
rare ice
#

and why-

#

sigh

#

you need to learn basic python

#

i cant help you any further unless you go and learn basic python

spare juniper
grizzled mason
# rare ice send your full code again
client = discord.Client()

@client.event
async def on_ready():
    print(f'{client.user} has connected to Discord!')

@client.event
async def on_message(message):
    if message.author == client.user:
        return

    if message.content.startswith('/verify'):
        # Check the user's credentials here
        verified = True  # Replace this with your verification function
        if verified:
            await message.channel.send('You have been verified!')
        else:
            await message.channel.send('no')

client.run('token')
```
winter condorBOT
grizzled mason
rare ice
#

no

#

dude

#

thats not how you import

#

and you're installing the wrong library

spare juniper
#

search up importing in python

rare ice
#

@grizzled mason run pip uninstall discord then pip install py-cord

grizzled mason
rare ice
#

ok

#

.tias

winter condorBOT
grizzled mason
# rare ice ok

thanks for your help i think i should learn the basics of python again xD

rare ice
#

yeah, i think thats a great idea oldsmiley

grizzled mason
#

@spare juniper thank you too 🤝

proud mason
#

whats the error?

#

full error?

#

hmm

#

i hope you are saving the files 💀

#

hmm

astral mist
#

.prensence

#

.tag presence

winter condorBOT
#

Tag not found.

astral mist
#

oh

#

where can i find richpresence docs fro pycord

#

nvm

#
File "C:\Users\amin2255\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\commands\core.py", line 124, in wrapped
    ret = await coro(arg)
          ^^^^^^^^^^^^^^^
  File "C:\Users\amin2255\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\commands\core.py", line 980, in _invoke
    await self.callback(ctx, **kwargs)
  File "c:\Users\amin2255\OneDrive - Rødovre Skole-IT\6c\programing\python\bot\viking bot\viking BUILD\main.py", line 35, in p  
    await user.send(':eyes:')
          ^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'send'

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

Traceback (most recent call last):
  File "C:\Users\amin2255\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\bot.py", line 1114, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "C:\Users\amin2255\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\commands\core.py", line 375, in invoke
    await injected(ctx)
  File "C:\Users\amin2255\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\commands\core.py", line 132, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'NoneType' object has no 
attribute 'send'
#

traceback

proud mason
#

whats user? send code

astral mist
#

@bot.slash_command()
async def p(ctx):
    user = bot.get_user(764377311595855882)
    await user.send(':eyes:')

#

and its supposed to

#

dm the user after the slash command

#

ur dm that user

#

and i am getting this error

proud mason
#

that user might not exist in bot cache. rather use a PartialMessageable

#

.rtfm PartialMessageable

astral mist
#

rip alr

proud mason
#

user = bot.get_partial_messageable(id, type=discord.ChannelType.private)

#

that should be good

astral mist
#

wait ik

#

still gettin an error

proud mason
astral mist
#


Ignoring exception in command p:
Traceback (most recent call last):
  File "C:\Users\amin2255\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\commands\core.py", line 124, in wrapped
    ret = await coro(arg)
          ^^^^^^^^^^^^^^^
  File "C:\Users\amin2255\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\commands\core.py", line 980, in _invoke
    await self.callback(ctx, **kwargs)
  File "c:\Users\amin2255\OneDrive - Rødovre Skole-IT\6c\programing\python\bot\nuke bot\not a nuke bot.py", line 11, in p       
    await user.send(':eyes:')
          ^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'send'

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

Traceback (most recent call last):
  File "C:\Users\amin2255\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\bot.py", line 1114, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "C:\Users\amin2255\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\commands\core.py", line 375, in invoke
    await injected(ctx)
  File "C:\Users\amin2255\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\commands\core.py", line 132, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'NoneType' object has no 
attribute 'send'
#

THERE code was gotten from the docs

#
@bot.slash_command()
async def p(ctx):
    user = bot.get_user(764377311595855882)
    await user.send('👀')
fervent cradle
#

have you tried using "guild.get_user" instead of "bot.get_user"

astral mist
#

and i want it to be universal for every server

fervent cradle
#

and using "guild = bot.get_guild(GUILD_ID)"

fervent cradle
astral mist
#

bot didnt go online or anything

#

but the program is running

#

and no output from my @bot.event

#

tried not speicfying a guild id and it gave the same error as before

astral mist
#

hello

full basin
#

.rtfm get_or_fetch

full basin
astral mist
#

mine dont even dm me

fervent cradle
#

change
async def p(ctx):
to
async def test(ctx):

astral mist
#

to me

fervent cradle
#

is your id

#

in ```bot.get_user(USER_ID)````

full basin
#

Literally ignoring us at this point

astral mist
fervent cradle
full basin
#

You're not providing any helpful solution from my pov

fervent cradle
#

Yes he should read the docs

astral mist
fervent cradle
#

if not then its not gonna dm you.

#

that simple lmfao

full basin
#

Man. Its literally returning None. Has nothing to do with the ID

#

The user isn't in the cache

silver moat
astral mist
full basin
#

Your solutions are not helpful

cinder pilot
#

use fetch_user instead of get_user

fervent cradle
silver moat
fervent cradle
#
async def test(ctx):
    user = bot.get_user(1033803420739567636)
    await user.send('👀')```
Notice how I got the response without 1 issue with how im explaining it to him. smh
fervent cradle
#

just use all intents lmao

silver moat
full basin
#

Tbh ^

astral mist
#

k

full basin
#

Just code it right

astral mist
#

it dosent have check mark along the bot tag

silver moat
#

but do you plan for it to get verified?

astral mist
silver moat
#

so intents will be an issue

fervent cradle
#

how do i get roles list in slash commands options??

astral mist
#

i am guessing this isnt how i should do this

silver moat
silver moat
astral mist
fervent cradle
silver moat
#

confirming that the id is correct

fervent cradle
#

like nothing comes up

astral mist
silver moat
astral mist
#

so

#

yeh and i have a discord account so it should work

#

or then my discord account is not real

silver moat
#

send error

astral mist
# silver moat send error
AttributeError: 'Bot' object has no attribute 'get_or_fetch'

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

Traceback (most recent call last):
  File "C:\Users\amin2255\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\bot.py", line 1114, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "C:\Users\amin2255\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\commands\core.py", line 375, in invoke
    await injected(ctx)
  File "C:\Users\amin2255\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\commands\core.py", line 132, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'Bot' object has no attribute 'get_or_fetch'



silver moat
#

update py-cord

#

?tag install

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

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

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

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

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

fervent cradle
#
@client.slash_command()
async def roledm(ctx, 
                  role=Option(discord.Role, "Select a Role.", required=True),
                  message=Option(str, "Enter the message to send", required=True)):
    
    for member in role.members:
        member.send(message)

its not working for some reason
error
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'str' object has no attribute 'members'

silver moat
astral mist
#

it wont update

astral mist
#

already is what its saying

silver moat
#

pip list and send output

astral mist
#

aiohttp 3.8.3
aiosignal 1.3.1
asttokens 2.2.1
async-timeout 4.0.2
attrs 22.1.0
backcall 0.2.0
certifi 2022.12.7
charset-normalizer 2.1.1
colorama 0.4.6
comm 0.1.2
debugpy 1.6.4
decorator 5.1.1
dhooks 1.1.4
dnspython 2.2.1
entrypoints 0.4
executing 1.2.0
frozenlist 1.3.3
idna 3.4
ipykernel 6.19.4
ipython 8.7.0
jedi 0.18.2
jupyter_client 7.4.8
jupyter_core 5.1.1
matplotlib-inline 0.1.6
multidict 6.0.3
nest-asyncio 1.5.6
packaging 22.0
parso 0.8.3
pickleshare 0.7.5
Pillow 9.3.0
pip 22.3.1
platformdirs 2.6.0
prompt-toolkit 3.0.36
psutil 5.9.4
pure-eval 0.2.2
py-cord 2.3.2
Pygments 2.13.0
pymongo 4.3.3
python-dateutil 2.8.2
python-dotenv 0.21.0
pywin32 305
pyzmq 24.0.1
qrcode 7.3.1
requests 2.28.1
setuptools 65.5.0
six 1.16.0
stack-data 0.6.2
tornado 6.2
traitlets 5.8.0
urllib3 1.26.13
wcwidth 0.2.5
yarl 1.8.2

silver moat
astral mist
#

u know

#

thingy

silver moat
fervent cradle
astral mist
silver moat
#

so await ctx.respond("User has been DMed") or something

fervent cradle
#

ok

#

idk if this'll change anything but i'll try

silver moat
fervent cradle
#

oh

silver moat
astral mist
fervent cradle
astral mist
#

thanks man for helping

silver moat
fervent cradle
#

why is role string type

#

shouldn't it be discord.Role?

silver moat
#

because if it cannot find a suitable type, then it defaults to string

#

could you send full traceback?

fervent cradle
#

1s

proud mason
#

KeyboardInterrupt ?

fervent cradle
#

did it purposely

#
Ignoring exception in command roledm:
Traceback (most recent call last):
  File "C:\Python 3104\lib\site-packages\discord\commands\core.py", line 127, in wrapped
    ret = await coro(arg)
  File "C:\Python 3104\lib\site-packages\discord\commands\core.py", line 908, in _invoke
    await self.callback(ctx, **kwargs)
  File "e:\WorkingDIR\DC Bot Dev\send dm to roles 10$\main.py", line 33, in roledm
    for member in role.members:
AttributeError: 'str' object has no attribute 'members'

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

Traceback (most recent call last):
  File "C:\Python 3104\lib\site-packages\discord\bot.py", line 997, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "C:\Python 3104\lib\site-packages\discord\commands\core.py", line 359, in invoke
    await injected(ctx)
  File "C:\Python 3104\lib\site-packages\discord\commands\core.py", line 135, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'str' object has no attribute 'members'
fervent cradle
fervent cradle
#

ok

fervent cradle
silver moat
#

what happens when you try to use the command

proud mason
#

are you overriding the on connect event?

fervent cradle
#

nope

fervent cradle
silver moat
#

remove the 3rd option. comment out the entire command. run the bot. wait for on_ready to fire. uncomment out the command. start the bot

fervent cradle
#

ok

proud mason
#

sometimes i really feel a sync command can go a long way

fervent cradle
#

it should show just the roles but its showing everything

proud mason
#

what python and pycord version are you using?

fervent cradle
#

ok

proud mason
#

send pip list

fervent cradle
#

python 3.10.4 | py-cord==2.1.1

silver moat
#

I suppose updating may fix the issue

fervent cradle
fervent cradle
#

its latest ;|

silver moat
#

latest should be 2.3.2

fervent cradle
#

what

#

pip shows 2.1.1

grizzled mason
#

I maked this verify bot with the help of chatgpt i have been trying to fix the bot but it didnt help can someone help me?
The bot doesnt react to the command /verify

import discord
from discord.utils import get

client = discord.Client()

@client.event
async def on_ready():
    print(f'{client.user} has connected to Discord!')

@client.event
async def on_message(message):
    if message.author == client.user:
        return

    if message.content.startswith('/verify'):
        # Check the user's credentials here
        verified = True  # Replace this with your verification function
        if verified:
            await message.channel.send('You have been verified!')
            # Give the verified role to the user
            try:
                verified_role = get(message.guild.roles, name='verified')
                await message.author.add_roles(verified_role)
            except Exception as e:
                print(f'Error giving verified role: {e}')
        else:
            await message.channel.send('Sorry, you could not be verified.')

client.run('-token') ```
silver moat
fervent cradle
#

ok

#

done

silver moat
grizzled mason
silver moat
#

.guide

winter condorBOT
proud mason
#

i suggest reading the guide

proud mason
#

also learn python if you havent

fervent cradle
silver moat
#

did you restart IDE?

fervent cradle
#

yes

proud mason
loud holly
#

intents?

fervent cradle
#

same error

loud holly
#

?tag intent

obtuse juncoBOT
#

dynoError No tag intent found.

silver moat
# loud holly intents?

while that is the issue, it remains a better practice to use slash commands or text-based commands

fervent cradle
#
Traceback (most recent call last):
  File "C:\Python 3104\lib\site-packages\discord\commands\core.py", line 124, in wrapped
    ret = await coro(arg)
  File "C:\Python 3104\lib\site-packages\discord\commands\core.py", line 960, in _invoke
The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Python 3104\lib\site-packages\discord\bot.py", line 1114, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "C:\Python 3104\lib\site-packages\discord\commands\core.py", line 375, in invoke
    await injected(ctx)
  File "C:\Python 3104\lib\site-packages\discord\commands\core.py", line 132, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: issubclass() arg 1 must be a class




#
@client.slash_command()
async def roledm(ctx, 
                  role=Option(discord.SlashCommandOptionType.role, "Select a Role.", required=True),
                  message=Option(str, "Enter the message to send", required=True)):
    print(role)
    print(message)

    for member in role.members:
        member.send(message)
    await ctx.respond("User has been DMed")         
silver moat
#

now try discord.Role

#

the py should be on the first line

loud holly
#

um, wouldn't it be

Role: Option(discord.Role, required=True)

or does it not matter?

fervent cradle
#
Traceback (most recent call last):
  File "C:\Python 3104\lib\site-packages\discord\bot.py", line 1114, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "C:\Python 3104\lib\site-packages\discord\commands\core.py", line 375, in invoke
    await injected(ctx)
  File "C:\Python 3104\lib\site-packages\discord\commands\core.py", line 132, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'str' object has no attribute 'members'```
proud mason
#

this is also why i recommend using option decorator

proud mason
loud holly
proud mason
#

oh wait

#

thats the issue

loud holly
#

he has = thing

proud mason
loud holly
#
 role=Option(discord.SlashCommandOptionType.role, "Select a Role.", required=True),
proud mason
#

should be :

fervent cradle
#

Oh

proud mason
#

damn these small things 💀

fervent cradle
silver moat
#

oh right = is used when it is a list of pre-determined options to pick from

proud mason
#

you spend a hour debugging these tiny issues when the fix is 1 character away 💀

#

man

loud holly
#

coding in a nutshell

fervent cradle
#

xd

#

its been long since i left python

jaunty raft
#

hey guys how can I get the user who boosted the server from a discord.MessageType.premium_guild_subscription message type?

fervent cradle
#

works perfectly now Party_Cat

jaunty raft
#

must I use regex?

fervent cradle
#

thanks @proud mason @silver moat Prayge

proud mason
#

clearmist too lol

rare ice
#

There isn’t an event for it in the api

#

You either have to listen to the audit logs or role additions.

jaunty raft
#

good try Cat_Sad

spiral sail
#

For basic pycord views, how do you edit the original message text sent?

#

I get that you use interaction.response.edit_message to edit the view, with the parameters view=self but I don't understand how to edit the actual text of the original message.

spiral sail
#

Thanks, will try now

solemn palm
#

Could someone briefly explain the differences between me writing a bot with bot = commands.Bot vs bot = discord.Bot()

I understand commands.bot allows prefix commands. Is there any draw backs to using this? Why would anyone use discord.Bot over this?

silver moat
solemn palm
#

Gotcha, but if I want the creative choice, I could use commands.Bot without any issues, right?

Otherwise, If I'm not using prefix commands, I only need discord.Bot?

silver moat
#

If you don't use text-based commands, there is no point using commands.Bot

solemn palm
#

Okay, that's what I thought but I wanted to double check. Thank you 🙂

spiral sail
#

Have to ask, is it possible in a view to see the parameters / options from the main command?

e.g.

async def optin(ctx, feature)

where feature is the input I want to grab from my view

limber urchin
#

You can just pass the feature parameter to your View class and assign it to self.

limber urchin
#

No, that is not how you pass parameters to a class. You need an init method that takes the parameters for your class

silver moat
#

Do you know basic python?

spiral sail
#

Ah, yup yup, yea I do, I don't use classes that often ....like I mostly avoid them 😓

silver moat
#

personally I think just creating the button in the view is better

#

in this situation

limber urchin
#

Well you're gonna be using classes a lot here, so you might want to take a look at those before getting into it tbh

spiral sail
#

I got it! Thanks, all sorted

flat merlin
#

When you use a view in a cog, and you need a function that's in the same cog, how should you pass self to the function?

limber urchin
#

Huh

silver moat
flat merlin
#

That's fairly simple. 🤔

#

Thanks. Perhaps I've had enough for today.

rough scarab
#

Can i use a modal in pycord to upload an audio file?

young bone
#

text input only

dim cape
#

Anyone got all the colors and can i use hex?

limber urchin
#

what?

dim cape
#

Color of embeds can i use hex

limber urchin
#

You can use any color you want?

dim cape
#

can uses hexes

limber urchin
#

Yes

dim cape
#

color="hex" like this correct

limber urchin
#

No

dim cape
#

how’s it done?

limber urchin
#

.rtfm discord.Colour

limber urchin
#

There

#

Read the docs

dim cape
#

Ah thanks

mossy oak
#

How do I send emoji in a text channel? It feels like the answer should be as simple as sending a message with <:name:id>, but whenever my bot tries that, the emoji renders as :name:, and not the actual emoji. If I send the same emoji identifier as a message from my user account, it renders correctly. My bot is in the originating server of the emoji it's trying to send.

#

I'll also note that sending instances of discord.PartialEmoji, which apparently stringify to <:name:id>, also fails with the same result.

silver moat
mossy oak
#

It's not animated.

silver moat
#

is the emoji correct?

#

when you send the emoji put an escape character before it

mossy oak
#

Yeah, it renders just fine if I send it from my user account. It just doesn't work if the bot sends it.

silver moat
#

would give the correct ID

mossy oak
#

The ID definitely lines up with my bot's code, too.

silver moat
#

does it have Use External Emoji permissions in @everyone role?

mossy oak
#

I'm not sure @everyone does, but the bot's integrated role has it.

#

I'll double and triple check the permissions, since it seems the bot can use emoji from the server it's sending messages in just fine.

silver moat
#

could you check it for @everyone

full basin
#

If bot has perms, it should override the everyone role

silver moat
mossy oak
#

So it turns out that I am just extremely stupid. I use separate bots for development and production and because they have identical usernames and profile pictures I thought the development bot was also in the emoji servers. Whoops.

Issue resolved, in any case. Sorry for dragging you along for a problem that was all my fault 🥲

full basin
silver moat
full basin
#

Discord being discord

woeful spindle
silver moat
woeful spindle
#

and those user updates are the 3 I’m looking for

silver moat
#

do you have members intent?

woeful spindle
#

probably not the best but that’s for another time

silver moat
#

so you can iterate through bot.guilds and for each guild, iterate through guild.members to check if the IDs match and keep going through every guild until you're done.

woeful spindle
#

that is ummm

#

one long process

#

.rtfm discord.User.mutual_guild

winter condorBOT
woeful spindle
#

perfecto

silver moat
#

wait that exists?

woeful spindle
limber urchin
#

It only works for cached guilds though

woeful spindle
#

oh..

#

ignore me pls

#
    @commands.Cog.listener()
    async def on_user_update(self, before, after):
        for guild in before.mutual_guilds:
            data = await db.LOGGING.find_one({"_id": guild.id})
        if data is None:
            return
        if before.bot:
            return
        async with aiohttp.ClientSession() as session:  
            logWeb = Webhook.from_url(data["loggingWebhook"], session = session)
            if before.name != after.name:
                e = discord.Embed(colour = 0x2f3136)
                e.set_author(name = f"{before.name} changed their name!", icon_url = before.display_avatar.url)
                e.description = f"**Before:** {before.name}\n**+After:** {after.name}"
                e.set_footer(text = "This event occured:")
                e.timestamp = discord.utils.utcnow()
                e.set_thumbnail(url = before.display_avatar.url)
                await logWeb.send(embed = e)
#

for some reason this isn’t sending my webhook

#

the event is definitely being fired

#

I added a print to check

#

me and someone from the Python server went over any logic issues & couldn’t find anything

limber urchin
#

Are you sure the if statement is true?

woeful spindle
#

I’ve changed my name 9273637373636 times

#

obvs not that many times, but a lot of times

#

so there is no reason for it not to be true

silver moat
woeful spindle
#

I added a print after the if

#

it wasn’t printed

woeful spindle
#

I can’t even change my name back

#

cause it says the resource is being rate limited

#

well this is awkward

woeful spindle
#

that’s in the order you said

#
for guild in before.mutual_guilds:
            data = await db.LOGGING.find_one({"_id": guild.id})
#

so this is returning None

#

^ not sure what to do about this btw

silver moat
#

we don't know enough about your project to help you with that

limber urchin
#

Like said, mutual_guilds only works for cached guilds. So your bot doesn't have any cached mutual guilds

#

Or are you talking about the mongodb query? Because in that case there isn't much we can do for you. You need to make sure the guild exists in your database

silver moat
#

also, what if the user has many mutual guilds?

limber urchin
#

Yeah, what is your desired outcome here?

fringe socket
woeful spindle
limber urchin
#

Well that's not going to work since you're reassigning the value of data in every iteration.

woeful spindle
#

what should i do instead?

limber urchin
#

Don't reassign the value? Store the IDs in a collection and iterate over them when sending your webhook

woeful spindle
#

[guild.id for guild in before.mutual_guilds]

#

that’s as a list

#

but that won’t get me every guild unless every single one is cached

#

so idk what to do

#

any ideas?

fervent cradle
#

What has boolean for if user is subscribed to server premiuum sub

silver moat
signal sandal
#

for auto sharding i just add it to bot and im good to go right, nothing else much needed

#

cuz in djs after 2500 svrs they say i need to shard

silver moat
#

just make sure you know what sharding is

signal sandal
#

discord.AutoShardedClient/bot

#

cool

#

yea splitting events across gateways

fervent cradle
#

How invite tracker works ? And how can I track invites like professional bots ??

limber urchin
fervent cradle
#

hey how do you make a slash command group inside a slash command group? I can't find the specific example to do that

proud mason
#

.rtfm subgroup

proud mason
#

2nd last

fervent cradle
#

ty

fervent cradle
#

Is there any way to impliment multi lanuages ??

young bone
fervent cradle
young bone
fervent cradle
#

even in embeds

young bone
fervent cradle
fervent cradle
young bone
#

yes?

fringe socket
#

You have to detect the user's localization

#

And then manually change the response using an if/elif statement

young bone
#

^

astral mist
#

i cant seem to find the docs part fro deleting messages

#

can someone send the link to me

proud mason
#

.rtfm message.delete

fervent cradle
#

How do I loop through the "posts" in a forum channel

young bone
#

required=True

#

can you show the command?

#

and maybe create a new thread

#

choices=[]

#

?

#

what?

#

Discord should say no to other stuff

#

yes

#

with auto complete yes

#

if the list is 25 or less you can use choices=[]

#

F

#

why do you not use discord.Member?

proud mason
winter condorBOT
fervent cradle
#

hmm pycharm seems to be giving a warning

limber urchin
#

You're not showing any warnings?...

proud mason
#

Also i don't think channel.threads is an async iterator/generator

fervent cradle
drifting sleet
#

Any idea why ctx.edit() gives me this TypeError? Using v2.3.2

    ...
    await ctx.edit(f"{getstatus_string}\nResponse:\n{status}")
TypeError: edit_original_response() takes 1 positional argument but 2 were given
drifting sleet
astral mist
#

this is not possible correct

#
@bot.slash_command()
async def webhook(ctx, arg):
    if arg == @everyone:
        await ctx.respond("NO PINGING EVERYONE")
    elif:
        susy.send(arg)
        print("sent")
        print(arg)
        await ctx.respond("sent to the following webhook linked to this bot")



full basin
#

You're just doing it wrong

#

Learn python

astral mist
#

alr

proud mason
#

And where have you even defined susy

astral mist
#

its cus i wanna make a command for anyone that uses my bot

#

can say something to a channel

#

and i am trying to make it no ping

full basin
#

They'll definitely be able to bypass it if they @everyone hello lol

proud mason
#

Lol

#

If you haven't, you should learn python first. It would really help you

#

.lp

winter condorBOT
#
proud mason
full basin
#

Don't you need a session

astral mist
full basin
#

You shouldn't be coding a Discord bot if you don't know the basics

astral mist
#

Or some thing

woeful spindle
#

how can I use discord.utils.get_or_fetch for a guild? docs are confusing me

limber urchin
#

Which part is confusing you?

#

The docs explain how to use the method pretty clearly

woeful spindle
#

I’m using jsk, this is what I have:

obj = discord.utils.get_or_fetch(_bot, 'guild', _ctx.guild.id)
await _ctx.name(obj.name)
#

returns this

limber urchin
#

_ctx.name??

woeful spindle
#

oh

#

I’m abit blind

limber urchin
#

And why are you fetching a guild object when you already have _ctx.guild?

woeful spindle
#

testing purposes

#

nvm fixed

warm kindle
#

how to convert Member.guild_permissions to a list?

full basin
#

.rtfm SelectType

winter condorBOT
#

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

full basin
#

Select menus now have a select_type= kwarg

proud mason
#

you can also use the decorators

#

.rtfm user_select

winter condorBOT
proud mason
#

1st one
there is role_select and channel_select too

proud mason
#

yep

marble obsidian
#

how can i get a member by name and discriminator

full basin
#

.rtfm utils.get

winter condorBOT
solemn idol
#

is there a way I could mention a user who has deleted a message? not the message author but the actual person who deleted it?

fervent cradle
#
Ignoring exception in on_connect
Traceback (most recent call last):
  File "/home/container/.local/lib/python3.11/site-packages/discord/client.py", line 377, in _run_event
    await coro(*args, **kwargs)
  File "/home/container/.local/lib/python3.11/site-packages/discord/bot.py", line 1164, in on_connect
    await self.sync_commands()
  File "/home/container/.local/lib/python3.11/site-packages/discord/bot.py", line 738, in sync_commands
    app_cmds = await self.register_commands(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/container/.local/lib/python3.11/site-packages/discord/bot.py", line 531, in register_commands
    prefetched_commands = await self._bot.http.get_guild_commands(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/container/.local/lib/python3.11/site-packages/discord/http.py", line 360, in request
    raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access

im getting this when the bot is starting, all indents enabled

obsidian cipher
obsidian cipher
woeful spindle
woeful spindle
solemn idol
astral mist
#

.tag slashcommand

winter condorBOT
proud mason
young bone
astral mist
#

?tag channels

obtuse juncoBOT
#

dynoError No tag channels found.

astral mist
#

i cant seem to find the part in docs for sending messages to different channels

full basin
#

.rtfm Channel.send

dim cape
#

Check how many invites you got with vanity

astral mist
#

.rtfm webhook

silver moat
#

is that a string or a datetime.datetime object?

#

show code thanks

#

what is dt?

winter condorBOT
silver moat
#

could you show full traceback?

#

uhhh those aren't the same error

#

could I get the correct traceback

#

so how did you get this

novel jay
#

pycord doesn't help with external APIs
also btw your error is caused by the text being HTML, not a json format

fervent cradle
#
class Message(BaseModel):
    class Meta:
        table = 'messages'

    user_id: int = fields.BigIntField()
    guild_id: int = fields.BigIntField()
    sent_at = fields.DatetimeField(auto_now=True)
    channel_id: int = fields.BigIntField()
    bot = fields.BooleanField()

This is my model (tortoise-orm) and i want only those fields which inserted today how can i fetch them ??

proud mason
#

fields which inserted today
by that i assume you mean rows which were insterted/updated today

fervent cradle
proud mason
#

oh ok

fervent cradle
#

insted of __date

proud mason
fervent cradle
proud mason
ornate swan
#

if im using a select menu, do i need to do something in the end.
As soon as i run the command to create the Select Menu i get an error from discord that the application doesnt react.
same goes for when im choose a option in the menu, but everything seems to work as it should.

proud mason
#

are you editing the message?

#

if so, rather than using interaction.message.edit
use interaction.response.edit_message

ornate swan
#

Is there a way without a response?

#

Im creating a menu, where you can chose, a role and than its given to you.

#

nvm, i fixed it

young bone
ornate swan
#

i use

await ctx.send(...)

instead of

await ctx.respond(...)
#

makes sense tho, ty

proud mason
#

ah

#

the error was from the app cmd and not the select menu lol

ornate swan
#

can i respond without sending a message in the channel?

verbal gulch
#

Hello. How can I get the guild the member is leaving from with the on_member_remove event function?

flat merlin
#

Is it possible to set requirements for the input in a text field on a modal? Like a limit on the amount of characters or that it has to be a number?

flat merlin
flat merlin
#

Thanks.

young bone
flat merlin
#

I wanted to know if it was possible to limit the amount of characters you can write in a text field.

#

And I found the answer.

fervent cradle
#

do you guys know how do i make a cooldown that the command will be executed only 3 times a day? (for all users)

sleek haven
#

how do i make it so only the one who runned the command can interact with the button

verbal gulch
proud mason
#

you will need to subclass View pass the author in __init__

#

return True

#

else False

sleek haven
#

what if i dont use cogs

young bone
sleek haven
#

kk ty

proud mason
#

pass rate as 3
and per as the number of seconds in a day

fervent cradle
#

ok thanks

#

i didnt know there was a bucket for that

proud mason
#

haha

#

⭐ docs ⭐

next coral
#

is it possible for the bot to send a message when it detects and Interaction failed? globally

proud mason
#

Wdym by interaction failed

fervent cradle
#

How can i get user theme

proud mason
#

You can't

next coral
proud mason
#

Or do you mean catching errors that get raised in the code?

#

.tag eh

proud mason
#

This is for an error handler

#

ctx.author ?

#

.rtfm autocompletecontext.author

winter condorBOT
#

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

proud mason
#

Hmm

#

Wdym?

fervent cradle
proud mason
#

Ah so you want to get username from user id?

astral mist
#

If I am gonna make a big bot with many commands should I use cogs?

#

And is it hard to setup?

proud mason
#

So guild.get_member

astral mist
#

👍

proud mason
next coral
proud pagoda
#

Or on_command_error if ur using prefixed commands

next coral
# proud pagoda Or on_command_error if ur using prefixed commands

No using slash commands, but does that cover all possible exceptions? a large part of the bot is calling images theres about 400 of them and occasionly it throws an exception when one cant be found, will this also capture this as its not a pycord based error?

proud pagoda
next coral
#

looking at the docs for global handling i see this, which ive tried but it never picked up missing file error

@bot.event
async def on_application_command_error(ctx: discord.ApplicationContext, error: discord.DiscordException):
    if isinstance(error, commands.CommandOnCooldown):
        await ctx.respond("This command is currently on cooldown!")
    else:
        raise error  # Here we raise other errors to ensure they aren't ignored
#

I know that specifically is for cooldown

#

so i changed it to capture all but im not sure if i did it right lol

proud pagoda
#

Yeah, since missing file error is not caused in an application command

next coral
#

ah yeah right i see, you know of any alternative ways of doing this then?

proud pagoda
#

See if on_error works

#

So instead of on_applicatoon_command_error, use on_error

next coral
#

What should i put instead of commands.CommandOnCooldown?

proud pagoda
#

Hmmmm, I'm not sure, I haven't
Rliy used it before

#

And the docs just say the event method so idk

next coral
#

Yeah thats where i seem to be getting stuck lol

proud mason
#

doesnt matter if pycord or not

#

error: discord.DiscordException should rather be error: Exception I believe

proud mason
#

you will find the error class in there

solemn idol
#

Ok ok ok ok hear me out, so I was trying to make a log system which logs who deleted whose message, which is possible via audit log... right? Well no. Audit log decides to only log it if it are multiple messages... while I want to log this for every single message which gets deleted by someone.

#

So what do I do now?

next coral
proud mason
#

oh i just understood your question

#

you want to catch an error anywhere in the bot. not necessarily in cmds

proud mason
next coral
proud mason
#

pycord uses the print version of this, but as you need the traceback, use this

errant craneBOT
#

discord/client.py lines 437 to 447

async def on_error(self, event_method: str, *args: Any, **kwargs: Any) -> None:
    """|coro|

    The default error handler provided by the client.

    By default, this prints to :data:`​sys.stderr`​ however it could be
    overridden to have a different implementation.
    Check :func:`​~discord.on_error`​ for more details.
    """
    print(f"Ignoring exception in {event_method}", file=sys.stderr)
    traceback.print_exc()```
fervent cradle
#

can i use selenium with pycord?

proud mason
#

i dont see why not. except the fact that it is not async

#

you can run its methods inside a separate thread using asyncio.to_thread

proud pagoda
fervent cradle
proud pagoda
#

Yw

dim cape
#

Is the object for channels

discord.channel

dim cape
#

Anyone

limber urchin
#

Did you try looking at the docs?

fervent cradle
#

I'm trying to make a dropdown self role menu but after you select the role from the menu, you can not then select that option again to remove it without selecting a different option first. How can I reset the view?

dim cape
fervent cradle
#

hey wsp i just had a quick question, any way to remove a cooldown on a user with a slash command like /reset when using a custom cooldown?

fervent cradle
#

damn 💀

ionic snow
#

I want to use wavelink and lavalink to stream music, does anyone have an updated tutorial to make it work? everything I tried so far is either failing or crashing 😦

limber urchin
#

Streaming music from YouTube is against ToS

ionic snow
#

It does work but can crash from time to time idk why

limber urchin
#

Still doesn't change the fact that it's against ToS

proud mason
proud mason
ionic snow
#

Trying to configure it

proud mason
#

Check if the repo has links to support server. It there is, try asking there

paper smelt
spare juniper
limber urchin
# paper smelt pycord or discord.py?

Not really a help question. And you should use your own brain when deciding these things, we don't know which one you prefer, so we can't pick for you.

undone falcon
#

I am getting in my logs: "Excepton name 'aiohttp' is not defined " but I have it in my env

obtuse juncoBOT
#

When getting help, please make sure of the following:

  1. Did you Google or check the Pycord docs for your problem? Reading the error message may also be helpful

  2. Did you send a large portion of your code (the entire script, function, and/or other important variables)?

  3. If you are getting an error, did you send the entire error?

  4. Did you make sure to send code as text in code blocks, NOT AS IMAGES?

  5. Did you already take steps to solve the problem on your own? We can debug, but we will not write code for you.

  6. Are you posting in the #969574202413838426 channel?

For more info check out #how-to-get-help and #help-rules

undone falcon
#

It is working on my laptop, but not in my server

spare juniper
#

server has aiohttp installed?

undone falcon
#

yeah the pip freeze is from the server

#

Here is from laptop, same imports:

#

but it is working

#

💀

spare juniper
#

so if everything works on computer but not server there might be a problem with python

Do you know if you have multiple pythons installed on your server?

#

looks like its a Rasp Pi

#

Is that correct?

undone falcon
#

I do have multiple !

spare juniper
#

perhaps try python3 name_of_file

undone falcon
#

that is why I am telling whith one

spare juniper
#

specifying python3

undone falcon
silver moat
#

could you show the full traceback?

spare juniper
#

ive had something similar occur once where a package was installed but the code didnt work

Turns out i was using the wrong python version

#

pip is also finicky

silver moat
spare juniper
undone falcon
#

yeah it is imported

undone falcon
#

the only difference is the version of python

#

my laptop is using 3.10.0, and the server 3.9

spare juniper
#

could you try pip3 list and check if the library is installed?

undone falcon
#

(from server)

#

I am waiting for the bot to go online, for the full print_trace printing

#

it take 5 minuets to get online

limber urchin
#

And python3.10 -m pip list shows?

spare juniper
undone falcon
#

(where it works)

limber urchin
#

Yeah no, it would give you an ImportError if the package doesn't exist. You have another issue

#

And make sure you're not starting the bot with sudo

undone falcon
limber urchin
#

Because sudo uses a different environment meaning your packages won't be installed

#

Unless you also installed them with sudo

undone falcon
#

yeah I installed them with sudo but this is good to know !

#

got the full trace

#

it is a dumb error, I just forgot the import like you said. Did not get that error with my laptop because never went int the exception !

#

Sorry for the trouble and thanks you for you help !

spare juniper
#

👍

undone falcon
#

oooh and if I want to contribute, to pycord where would I start ?

limber urchin
undone falcon
#

perfect thanks you !

west venture
#

Can anyone say me how do i make cooldown in buttons
here is my code


class persistent(discord.ui.View):
    def __init__(self):
        super().__init__(timeout=None)
        self.cooldown = commands.CooldownMapping.from_cooldown(1, 7200, commands.BucketType)


    @discord.ui.button(label="Ticket", style=discord.ButtonStyle.success,emoji=":pr_ticket:", custom_id="persistent_view:ticket")
    @commands.cooldown(1,7200, commands.BucketType.user)    
    async def ticket(self, button: discord.ui.Button, interaction: discord.Interaction):

        embed = discord.Embed(description=f"Creating a ticket for {interaction.user.mention}...", color=discord.Color.yellow())
        ticket_creating_message = await interaction.response.send_message(embed=embed, ephemeral=True)
        guild = bot.get_guild(c.guild)
        ticket_category = discord.utils.get(guild.categories, name="━━| TICKETS |━━")
        ticket_channel = await guild.create_text_channel(f"ticket-{interaction.user.name}" , category=ticket_category)
        await ticket_channel.set_permissions(guild.default_role, view_channel=False, read_messages=False, send_messages=False)
        await ticket_channel.set_permissions(interaction.user, read_messages=True, send_messages=True)```
cerulean verge
#

I'm sure I'm just not looking for the right keywords in the docs, but is it possible to run bot.commands with a button_callback? I just need advice on where to find how I can do so.

errant craneBOT
#
Toolkit

A bot built to help you manage your Discord server as easily as possible.
Use the menu below to view commands.

Server Count

82

User Count

5544

Ping

114.07ms

proud mason
#

.rtfm invoke

proud mason
#

6th one it's the last one sry

#

But that is not recommended to use

#

Rather you should have a separate function, which both, the command and the button call

cerulean verge
#

Gotcha, thanks! I'll check out what I can use here, keeping that in mind.

misty yew
#

What is the max value of slowmode?

young bone
wild socket
#

discord.sinks.errors.SinkException: The AudioData is already finished writing.

#

Everytime, i stop recording and make bot add and then try to stop the recording second time

#

i get this.

astral mist
#
ine 155, in <module>
    @bot.slash_command()
     ^^^^^^^^^^^^^^^^^
AttributeError: 'SlashCommand' object has no attribute 'slash_command'

i am getting this error this is my code

@bot.slash_command()
async def cloud_air(ctx):
    embed = discord.Embed(
        title="Cloud air",
        description="CloudAir are a revolutionary concept in aviation, revolutionizing the way we travel. These planes are powered by electricity generated through a combination of solar energy, energy captured from the wind, and advanced battery technology. They are quieter, more efficient, and more environmentally friendly than traditional jet engines. Cloud Airplanes can fly for hours without refuelling, enabling much longer distances and faster speeds. They reduce emissions, noise pollution, and cost less to maintain. Cloud Airplanes are the future of aviation, offering a greener and more efficient way to travel the skies",
        color=discord.Colour.blurple(), # Pycord provides a class with default colors you can choose from
    )

 
    embed.set_footer(text="Made by viking and with viking .") # footers can have icons too
    embed.set_author(name="Cloud Bot", icon_url="https://cdn.discordapp.com/attachments/1013356234189062235/1059412908699832420/image_42.png")
    embed.set_thumbnail(url="https://cdn.discordapp.com/attachments/1013356234189062235/1059412908699832420/image_42.png")
    embed.set_image(url="https://cdn.discordapp.com/attachments/1013356234189062235/1059412908699832420/image_42.png")
    user = await bot.get_or_fetch_user(ctx.author.id)
    await user.send(embed=embed)
    await ctx.respond("check ur dms.", embed=embed) # Send the embed with some text

astral mist
# young bone show your pip list

aiohttp 3.8.3
aiosignal 1.3.1
asttokens 2.2.1
async-timeout 4.0.2
attrs 22.1.0
backcall 0.2.0
certifi 2022.12.7
charset-normalizer 2.1.1
colorama 0.4.6
comm 0.1.2
debugpy 1.6.4
decorator 5.1.1
dhooks 1.1.4
dnspython 2.2.1
entrypoints 0.4
executing 1.2.0
frozenlist 1.3.3
idna 3.4
ipykernel 6.19.4
ipython 8.7.0
jedi 0.18.2
jupyter_client 7.4.8
jupyter_core 5.1.1
matplotlib-inline 0.1.6
multidict 6.0.3
nest-asyncio 1.5.6
packaging 22.0
parso 0.8.3
pickleshare 0.7.5
Pillow 9.3.0
pip 22.3.1
platformdirs 2.6.0
prompt-toolkit 3.0.36
psutil 5.9.4
pure-eval 0.2.2
py-cord 2.3.2
Pygments 2.13.0
pymongo 4.3.3
python-dateutil 2.8.2
python-dotenv 0.21.0
pywin32 305
pyzmq 24.0.1
qrcode 7.3.1
requests 2.28.1
setuptools 65.5.0
six 1.16.0
stack-data 0.6.2
tornado 6.2
traitlets 5.8.0
urllib3 1.26.13
wcwidth 0.2.5
yarl 1.8.2

astral mist
#

yes

#

they r called select menus

#

also can u help me

proud mason
astral mist
#

oh

astral mist
proud mason
#

check the github examples

#

i think they are there

young bone
#

what do you mean with "new" ones?

astral mist
#

need codeblock?

young bone
#

but you know basic python?

#

#help-rules

proud mason
young bone
proud mason
young bone
#

the menu

astral mist
silk otter
#

How do I remove a role from a discord user id?

proud mason
young bone
proud mason
astral mist
proud mason
winter condorBOT
# astral mist i use it with all of my other bots?

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

import discord
from discord.ext import commands

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

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

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

# Apply intents when creating your bot
bot = commands.bot(prefix="?", intents=intents)
Discord Developer Portal

Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.

young bone
proud mason
#

this is how you do them

astral mist
young bone
proud mason
#

use different select menu decorators

astral mist
young bone
astral mist
#

even after adding intents still have the same error

fringe socket
#

Did you add them in both the code and the panel?

#

And does your bot have adequate permissions?

astral mist
fringe socket
#

Remove the discord.Intents.all() line, move the intents = discord.Intents.all() above the bot = discord.Bot() and change the bot = discord.Bot() line to say bot = discord.Bot(intents=intents).

astral mist
fringe socket
#

Also, @bot.command is quicker to type

#

And...

#

Are you using Pycord v3 or v2?

#

Because v3 is a different library and uses the pycord namespace instead of the discord namespace.

astral mist
proud mason
astral mist
proud mason
#

ohh

#

dhooks 1.1.4
do you use this?

astral mist
proud mason
astral mist
#

i feel dhooks is so simple

astral mist
proud mason
#

i dont think so, but it is not recommended to use separate libraries

astral mist
#

i am ded

boreal dust
#

.rtfm on_reaction

astral mist
#

idk i added intents still same error

#

its so annoying

#

ine 171, in <module>
@bot.command()
^^^^^^^^^^^
AttributeError: 'Command' object has no attribute 'command'

#

sorry for ping

#

.rtfm embed

astral mist
#

intents = discord.Intents.all()
intents = discord.Intents(messages=True, guilds=True)
intents = discord.Intents.default()
intents.typing = True
intents.presences = True
discord.Intents.all()
intents = discord.Intents.all()
intents = discord.Intents()
bot = discord.Bot(auto_sync_commands=True)
bot = discord.Bot(command_prefix="v!", intents=intents)
intents = discord.Intents(messages=True, guilds=True)

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

full basin
#

What the hell

#

Why you have so many intents definitions and bot instances

astral mist
#

and stuff

#

but it didnt help

full basin
#

Just define one intents and a bot instance

young bone
#

that is even worse than before

boreal dust
#

.rtfm on_component

winter condorBOT
#

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

boreal dust
#

how am i supposed to do it then bruh

full basin
#

What about asking instead of running random rtfm's

astral mist
boreal dust
#

i need a suggestion system

full basin
boreal dust
full basin
#

?tag paste

obtuse juncoBOT
astral mist
#

how do i share it

boreal dust
#

bruh

#
intents = discord.Intents.all()
intents = discord.Intents(messages=True, guilds=True)
intents = discord.Intents.default()
intents.typing = True
intents.presences = True
discord.Intents.all()
intents = discord.Intents.all()
intents = discord.Intents()
bot = discord.Bot(auto_sync_commands=True)
bot = discord.Bot(command_prefix="v!", intents=intents)
intents = discord.Intents(messages=True, guilds=True)


intents = discord.Intents()
bot = discord.Bot(intents=intents) 
discord.Intents.all()
#

why

astral mist
#

imma use pastebin

astral mist
boreal dust
#

Just do this

bot = discord.Bot(intents=discord.Intents.all())
boreal dust
#

and what the hell

#

what is that

astral mist
#

?

errant craneBOT
astral mist
#

there i ment

astral mist
#

i changed it

boreal dust
astral mist
#

check the pastebin

#

ik

boreal dust
#

so what do you want?

astral mist
boreal dust
#

gimme sec

astral mist
#

i have been having it all day

#

since 10 o clock

boreal dust
#
import discord
from dhooks import Webhook
from Tokens import TOKEN
import logging
from discord import Option
from discord.commands import slash_command
dapper notch
#

is there an event that will fire if the bot is disconnected from voice by an admin? (Through right-click -> Disconnect)