#Basic Pycord Help (Quick Questions Only)
1 messages · Page 47 of 1
maybe
lemme test it
Doesn't matter tbh
Can you pass args like that?
wasn't sure
Never seen it done like that before, unsure if it works
client = commands.Bot*
?tag embeds
No tag embeds found.
?
Where can u find embeds docs
in the docs
The docs is so complicated
So I am asking if someone can give me the link to it
@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 ^^^
So there’s no docs on it
Do U think I can use discord.py docs
Since it’s a fork and not much different
Alr
in Nextcord just change the discord.Embed to nextcord.Embed
.rtfm discord.Embed
discord.Embed
discord.Embed.Empty
discord.Embed.add_field
discord.Embed.append_field
discord.Embed.author
discord.Embed.clear_fields
discord.Embed.color
discord.Embed.colour
discord.Embed.copy
discord.Embed.description
discord.Embed.fields
discord.Embed.footer
discord.Embed.from_dict
discord.Embed.image
discord.Embed.insert_field_at
discord.Embed.provider
discord.Embed.remove_author
discord.Embed.remove_field
discord.Embed.remove_footer
discord.Embed.remove_image
.rtfm discord.Embed
discord.Embed
discord.Embed.Empty
discord.Embed.add_field
discord.Embed.append_field
discord.Embed.author
discord.Embed.clear_fields
discord.Embed.color
discord.Embed.colour
discord.Embed.copy
discord.Embed.description
discord.Embed.fields
discord.Embed.footer
discord.Embed.from_dict
discord.Embed.image
discord.Embed.insert_field_at
discord.Embed.provider
discord.Embed.remove_author
discord.Embed.remove_field
discord.Embed.remove_footer
discord.Embed.remove_image
You are expected to at least have tried to read the docs before coming here. And if you don't understand the docs that's most likely a sign that you're not competent enough in Python yet to be making a Discord bot
Navigating is just difficult tbh
Eh, not really. The search feature is a bit lacking but other than that it's perfectly fine
Oh yeah fs, search feature works perfectly. It’s just navigating with the sidebar menu thing that’s a bit weird imo
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
Hmm yeah, same with things like discord.Embed which are most of the time really important in a bot lol
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.
Anybody know what this error means? I don't have any loops at all in my code.
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.
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.
And how are you closing the connection?
Thank you for watching my tutorial on how to stop your code. 
Well... the bot shuts down. The code doesn't.
If it's not causing any issues, I don't see a reason to fix it. But I guess you can google the error and find things pretty easily.
https://stackoverflow.com/questions/45600579/asyncio-event-loop-is-closed-when-getting-loop
Is it possible to have a local file as a thumbnail on an embed sent using the paginator?
You can have local file for main image. Not sure for thumbnail
Try it and see
?tag localfile
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)```
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)
.tag idw
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.
basically when i try to run the command from the cog it says "command.notfound"
Add a print in the cog's setup function and see if it runs
ok
cock's*
it sounds very similar
its funny
the greetings cog that i copied from the api works fine and my default cog doesn't
any idea?
?tag idw
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.
.
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?
fixed it: changed name="ready" to name="on_ready", my bad 
I see
Thanks btw
Well you don't need to specify the name. If you don't specify then the library picks it up from the function name
can I use the @has_permissions decorator to check if the user has any of the provided permissions, not all
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
good to know, ty
if you mean discord.has_permissions, i don't think so?
it's either one or the other
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
yea I meant that one...
so this
@has_permissions(manage_channels=True, manage_messages=True)
would require the user to have manage_channels and manage_messages? or would it require them to have any of them (its that last I try to achieve)
if im not mistaken it would require all
why isnt discord.commands not popping up anymore like in the old version i had no problems
Please don't cross post.
what's the error? and could you please run pip freeze and send the output?
Here's the slash autocomplete example.
Check that out
why i am getting this error
like why am i getting this error
Show pip list

i dint link my current virutal environment with the code
Ah lol
lol
That works with the string in whole
if "bot" in "i am a bot":
This will return true
Uh what?
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?
Don't name your file discord
dont name your file discord
oh ok and what should i name it?
Lamo exactly same words
oh ok and what should i name it?
main anything ekse
ok 👍
main.py should be good
done!
I sent you a GitHub example of autocomplete
I slow 😭
can you guys help me with that?
send your full code here and send pip freeze here
wdym with pip freeze?
in your terminal
how do i get roles in slash commands options?
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')
discord.Role as the option_type
thanks
.rtfm discord.Option.option_type
Target not found, try again and make sure to check your spelling.
Oh wait that was not for you. It was for the guy after you
.rtfm discord.Option
ok i ran it
ok send the output here
Not really. Doesn't seem an issue. Are they in the same file?
heres the code @rare ice
No they are in different command groups
what is main
just use discord.Client
Yeah that's the issue. Rename the function. Command name is fine
like this?
all good bro
.tag lp
Official Beginner's Guide: https://wiki.python.org/moin/BeginnersGuide
Official Tutorial: https://docs.python.org/3/tutorial/
Shortcuts:
https://wiki.python.org/moin/BeginnersGuide/NonProgrammers
https://wiki.python.org/moin/BeginnersGuide/Programmers
Learn Python:
https://automatetheboringstuff.com/ (for complete beginners to programming)
https://learnxinyminutes.com/docs/python3/ (for people who know programming already)
https://docs.python.org/3/tutorial/ (official tutorial)
http://python.swaroopch.com/ (useful book)
http://www.codeabbey.com/ (exercises for beginners)
ight
You should learn basic python before using pycord.
@grizzled mason store discord.Client() in the client variable
i said i aint long into python
still, you should know basic python and oop before using pycord.
client = discord.Client()
ok i will
Then why import main
Yeah learning python will really help you
discord isnt defined but i used pip install discord
send your full code again
and why-
sigh
you need to learn basic python
i cant help you any further unless you go and learn basic python
Did you do import discord
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')
```
.tag cb
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.")
yes with pip install discord
You gotta tell the code import discord
search up importing in python
@grizzled mason run pip uninstall discord then pip install py-cord
👍 worked
ok
pycord installed
thanks for your help i think i should learn the basics of python again xD
yeah, i think thats a great idea 
@spare juniper thank you too 🤝
Tag not found.
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
whats user? send code
@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
that user might not exist in bot cache. rather use a PartialMessageable
.rtfm PartialMessageable
discord.PartialMessageable
discord.PartialMessageable.can_send
discord.PartialMessageable.fetch_message
discord.PartialMessageable.get_partial_message
discord.PartialMessageable.history
discord.PartialMessageable.pins
discord.PartialMessageable.send
discord.PartialMessageable.trigger_typing
discord.PartialMessageable.typing
rip alr
user = bot.get_partial_messageable(id, type=discord.ChannelType.private)
that should be good
where should i put that
wait ik
still gettin an error
which error? and code?
its 2 big
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('👀')
have you tried using "guild.get_user" instead of "bot.get_user"
guild isnt defined
and i want it to be universal for every server
and using "guild = bot.get_guild(GUILD_ID)"
try it and see if it works then you know what can be causing it or not
didnt work
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
The user isn't in the cache
hello
.rtfm get_or_fetch
discord.utils.get_or_fetch
discord.ext.bridge.AutoShardedBot.get_or_fetch_user
discord.Client.get_or_fetch_user
discord.ext.commands.Bot.get_or_fetch_user
discord.Bot.get_or_fetch_user
discord.ext.commands.AutoShardedBot.get_or_fetch_user
discord.AutoShardedBot.get_or_fetch_user
discord.AutoShardedClient.get_or_fetch_user
discord.ext.bridge.Bot.get_or_fetch_user
Bots: Attributes activity, allowed_mentions, application_flags, application_id, auto_sync_commands, cached_messages, cogs, debug_guilds, description, emojis, extensions, get_command, guilds, intent...
mine works just like this
change
async def p(ctx):
to
async def test(ctx):
@astral mist try this
same thing
to me
Literally ignoring us at this point
i am going to the website
Im literally helping him bc i tested the code and fixed it myself.
You're not providing any helpful solution from my pov
Yes he should read the docs
yeh didnt do anything
if your id in here user = bot.get_user(1033803420739567636)
if not then its not gonna dm you.
that simple lmfao
Man. Its literally returning None. Has nothing to do with the ID
The user isn't in the cache
you're not being helpful
mine is
Your solutions are not helpful
use fetch_user instead of get_user
i want it to show all roles in options, it doesn't show that way-
Bots: Attributes activity, allowed_mentions, application_flags, application_id, auto_sync_commands, cached_messages, cogs, debug_guilds, description, emojis, extensions, get_command, guilds, intent...
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
guess what, intents exist
just use all intents lmao
not an option when your bot is verified
Tbh ^
k
Just code it right
i never said my bot was verifyed
it dosent have check mark along the bot tag
but do you plan for it to get verified?
yes i do
so intents will be an issue
how do i get roles list in slash commands options??
i am guessing this isnt how i should do this
discord.Role
bot.get_or_fetch
now i am getting the same error as before but bot.get_or_fetch is in it
it doesn't show the role list for some reason
confirming that the id is correct
like nothing comes up
me?
yes
its my id
so
yeh and i have a discord account so it should work
or then my discord account is not real
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'
- 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
@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'
The API provides some enumerations for certain types of strings to avoid the API from being stringly typed in case the strings change in the future. All enumerations are subclasses of an internal c...
C:\Users\swdefwf\AppData\Local\Programs\Python\Python311\python.exe: can't open file 'C:\Users\efefefef\pip': [Errno 2] No such file or directory PS C:\Users\efefef>
it wont update
try pip install -U py-cord
i have it installed
already is what its saying
pip list and send output
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
idk doesn't work 
oh wait, it's bot.get_or_fetch_user
HOLY SH it worked but it says application didnt work
u know
thingy
well you didn't respond
someone please help i need it done asap
?
so await ctx.respond("User has been DMed") or something
that wasn't for you
oh
try using the slash command
worked
that's what i'm using
thanks man for helping
hmm try adding a 3rd option. I want to see if the options are updating at all
because if it cannot find a suitable type, then it defaults to string
could you send full traceback?
KeyboardInterrupt ?
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'
this is it
.
ok
no it doesn't
what happens when you try to use the command
are you overriding the on connect event?
nope
it responds "User has been DMed" but nothing really happens
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
ok
sometimes i really feel a sync command can go a long way
.
what python and pycord version are you using?
ok
send pip list
python 3.10.4 | py-cord==2.1.1
I suppose updating may fix the issue
nope still the same
latest should be 2.3.2
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') ```
pip install -U py-cord
while ChatGPT is an amazing tool, it is using outdated methods of creating commands.
oh ok and can you help me with this bot?
.guide
i suggest reading the guide
still the same
did you restart IDE?
yes
same what? same error or same py-cord version?
intents?
same error
?tag intent
No tag intent found.
while that is the issue, it remains a better practice to use slash commands or text-based commands
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")
um, wouldn't it be
Role: Option(discord.Role, required=True)
or does it not matter?
no, because it is required
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'```
this is also why i recommend using option decorator
try doing this instead of the typehint
no I meant as in
he has = thing
option is a typehint
role=Option(discord.SlashCommandOptionType.role, "Select a Role.", required=True),
Oh
damn these small things 💀

oh right = is used when it is a list of pre-determined options to pick from
coding in a nutshell
hey guys how can I get the user who boosted the server from a discord.MessageType.premium_guild_subscription message type?
works perfectly now 
must I use regex?
thanks @proud mason @silver moat 
clearmist too lol
You can’t
There isn’t an event for it in the api
You either have to listen to the audit logs or role additions.
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.
content = "foo"
Thanks, will try now
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?
basically you would use discord.Bot for just application commands. commands.Bot has more things you just don't need for application commands.
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?
If you don't use text-based commands, there is no point using commands.Bot
yes
Okay, that's what I thought but I wanted to double check. Thank you 🙂
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
You can just pass the feature parameter to your View class and assign it to self.
uhhhh
like this?
No, that is not how you pass parameters to a class. You need an init method that takes the parameters for your class
Do you know basic python?
Ah, yup yup, yea I do, I don't use classes that often ....like I mostly avoid them 😓
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
I got it! Thanks, all sorted
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?
Huh
name it something else like self2
Can i use a modal in pycord to upload an audio file?
Anyone got all the colors and can i use hex?
what?
Color of embeds can i use hex
You can use any color you want?
can uses hexes
Yes
color="hex" like this correct
No
how’s it done?
.rtfm discord.Colour
discord.Colour
discord.Colour.b
discord.Colour.blue
discord.Colour.blurple
discord.Colour.brand_green
discord.Colour.brand_red
discord.Colour.dark_blue
discord.Colour.dark_gold
discord.Colour.dark_gray
discord.Colour.dark_green
discord.Colour.dark_grey
discord.Colour.dark_magenta
discord.Colour.dark_orange
discord.Colour.dark_purple
discord.Colour.dark_red
discord.Colour.dark_teal
discord.Colour.dark_theme
discord.Colour.darker_gray
discord.Colour.darker_grey
discord.Colour.default
Ah thanks
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.
if the emoji is animated, <a:name:id>
It's not animated.
is the emoji correct?
when you send the emoji put an escape character before it
e.g.:
!doggokek
Yeah, it renders just fine if I send it from my user account. It just doesn't work if the bot sends it.
would give the correct ID
The ID definitely lines up with my bot's code, too.
does it have Use External Emoji permissions in @everyone role?
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.
could you check it for @everyone
If bot has perms, it should override the everyone role
there's a bug with interactions iirc
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 🥲
Interactions used to be tied to the everyone role due to they're "webhooks" but I'm sure they're bot sided iirc
there definitely was a bug, perhaps it was patched.
Discord being discord
This section outlines the different types of events listened by Client. There are two ways to register an event, the first way is through the use of Client.event(). The second way is through subcla...
not called when a user updates their name/avatar/discrim though
and those user updates are the 3 I’m looking for
do you have members intent?
I have all intents enabled
probably not the best but that’s for another time
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.
perfecto
wait that exists?

It only works for cached guilds though
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
Are you sure the if statement is true?
should be
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
could you print data, before.bot, before.name and after.name
sure
I can’t even change my name back
cause it says the resource is being rate limited
well this is awkward
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
we don't know enough about your project to help you with that
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
also, what if the user has many mutual guilds?
Yeah, what is your desired outcome here?
Bruh
for every guild that my bot and the user share, if that guild is in my db, I want to post a webhook to that guild
Well that's not going to work since you're reassigning the value of data in every iteration.
what should i do instead?
Don't reassign the value? Store the IDs in a collection and iterate over them when sending your webhook
[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?
What has boolean for if user is subscribed to server premiuum sub
there isn't any. Only way to retreive that information is with OAuth2
feel free to implement that with https://discord.com/developers/docs/topics/oauth2
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
thanks!
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
yeah
just make sure you know what sharding is
How invite tracker works ? And how can I track invites like professional bots ??
What do you mean by "invite tracker"? You can listen for the on_invite_create event with your bot.
https://docs.pycord.dev/en/stable/api/events.html#discord.on_invite_create
hey how do you make a slash command group inside a slash command group? I can't find the specific example to do that
sub_group = slash_group.create_subgroup(...)
.rtfm subgroup
2nd last
ty
Is there any way to impliment multi lanuages ??
for a slash command yes
How ?
Localizations are a way to make your bot more accessible to your users. Learn all about localizations now!
even in embeds
for an embed you have to do it at your own
How??
U said its for slash cmds
yes?
You have to detect the user's localization
And then manually change the response using an if/elif statement
^
i cant seem to find the docs part fro deleting messages
can someone send the link to me
.rtfm message.delete
How do I loop through the "posts" in a forum channel
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?
.rtfm ForumChannel.threads
hmm pycharm seems to be giving a warning
You're not showing any warnings?...
Why the 2nd line?
Also i don't think channel.threads is an async iterator/generator
ah that fixes it
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
content=
perfection.
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")
alr
up
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
They'll definitely be able to bypass it if they @everyone hello lol
Official Beginner's Guide: https://wiki.python.org/moin/BeginnersGuide
Official Tutorial: https://docs.python.org/3/tutorial/
Shortcuts:
https://wiki.python.org/moin/BeginnersGuide/NonProgrammers
https://wiki.python.org/moin/BeginnersGuide/Programmers
Learn Python:
https://automatetheboringstuff.com/ (for complete beginners to programming)
https://learnxinyminutes.com/docs/python3/ (for people who know programming already)
https://docs.python.org/3/tutorial/ (official tutorial)
http://python.swaroopch.com/ (useful book)
http://www.codeabbey.com/ (exercises for beginners)
Webhook is async btw
Don't you need a session
i am using this as a project i am watching a python coruse while doing it and i also just solved my problem i had to type else not elif
You shouldn't be coding a Discord bot if you don't know the basics
Alr but I am still gonna do it I am pretty sure I found a solution to people saying gratin words in stuff can’t I put them in a list
Or some thing
how can I use discord.utils.get_or_fetch for a guild? docs are confusing me
Which part is confusing you?
The docs explain how to use the method pretty clearly
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
_ctx.name??
And why are you fetching a guild object when you already have _ctx.guild?
how to convert Member.guild_permissions to a list?
.rtfm SelectType
Target not found, try again and make sure to check your spelling.
Select menus now have a select_type= kwarg
Where you provide a ComponentType object
https://docs.pycord.dev/en/stable/api/enums.html#discord.ComponentType
The API provides some enumerations for certain types of strings to avoid the API from being stringly typed in case the strings change in the future. All enumerations are subclasses of an internal c...
1st one
there is role_select and channel_select too
yep
how can i get a member by name and discriminator
.rtfm utils.get
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?
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
pls help
only way is through audit logs id assume
command_prefix takes a string
hmm ok, ty
.tag slashcommand
Learn all about Slash Commands and how to implement them into your Discord Bot with Pycord!
danke
bot doesnt have app cmds scope in all guilds
#help-rules
?tag channels
No tag channels found.
i cant seem to find the part in docs for sending messages to different channels
.rtfm Channel.send
Check how many invites you got with vanity
.rtfm webhook
discord.Webhook
discord.Webhook.auth_token
discord.Webhook.avatar
discord.Webhook.channel
discord.Webhook.channel_id
discord.Webhook.created_at
discord.Webhook.delete
discord.Webhook.delete_message
discord.Webhook.edit
discord.Webhook.edit_message
discord.Webhook.fetch
discord.Webhook.fetch_message
discord.Webhook.from_state
discord.Webhook.from_url
discord.Webhook.guild
discord.Webhook.guild_id
discord.Webhook.id
discord.Webhook.is_authenticated
discord.Webhook.is_partial
discord.Webhook.name
is that a string or a datetime.datetime object?
show code thanks
what is dt?
could you show full traceback?
uhhh those aren't the same error
could I get the correct traceback
so how did you get this
pycord doesn't help with external APIs
also btw your error is caused by the text being HTML, not a json format
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 ??
try this
Message.filter(sent_at__date=datetime.today().date())
fields which inserted today
by that i assume you mean rows which were insterted/updated today
Thnx i find a sollution btw...
oh ok
mhm thats fine. but it will also select rows which are in the future and not only today
ohh so should i have to use __date ??
i think so. try it and see
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.
you need to respond to the interaction
are you editing the message?
if so, rather than using interaction.message.edit
use interaction.response.edit_message
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
no
can i respond without sending a message in the channel?
Hello. How can I get the guild the member is leaving from with the on_member_remove event function?
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?
member.guild
The member object has a guild_id attribute (or at least it did when I wrote my code)
.rtfm InputText
discord.ui.InputText
discord.ui.InputText.custom_id
discord.ui.InputText.label
discord.ui.InputText.max_length
discord.ui.InputText.min_length
discord.ui.InputText.placeholder
discord.ui.InputText.refresh_state
discord.ui.InputText.required
discord.ui.InputText.style
discord.ui.InputText.to_component_dict
discord.ui.InputText.type
discord.ui.InputText.value
discord.ui.InputText.width
discord.InputTextStyle
discord.InputTextStyle.short
discord.InputTextStyle.long
discord.InputTextStyle.singleline
discord.InputTextStyle.multiline
discord.InputTextStyle.paragraph
Thanks.
limit is 5 text only fields
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.
do you guys know how do i make a cooldown that the command will be executed only 3 times a day? (for all users)
how do i make it so only the one who runned the command can interact with the button
Thanks you so much! Appreciated
you have to do it at your own
you will need to subclass View pass the author in __init__
then check if self.author.id == interaction.user.id
return True
else False
what if i dont use cogs
you dont have to use cogs but it will help you to have a clean code
kk ty
yes you can
check this https://github.com/Pycord-Development/pycord/blob/master/examples/cooldown.py
pass BucketType.default
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - pycord/cooldown.py at master · Pycord-Development/pycord
pass rate as 3
and per as the number of seconds in a day
is it possible for the bot to send a message when it detects and Interaction failed? globally
Wdym by interaction failed
How can i get user theme
sorry not failed but this
Are you using ctx.send instead of ctx.respond ?
Or do you mean catching errors that get raised in the code?
.tag eh
Target not found, try again and make sure to check your spelling.
):
Ah so you want to get username from user id?
If I am gonna make a big bot with many commands should I use cogs?
And is it hard to setup?
So guild.get_member
👍
If you have oop experience before, then it's not hard at all. It's recommended to use cogs if you more than about 300-400 lines of code
Ok I will try that then
No i wanted to catch the error, but wanted to do it globally instead of by command so if any exceptions anywhere in the bot get called then i can have them sent to a discord channel so i know whats broken
Use the on_application_command_error listener then
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?
I believe it should capture all exceptions that occur within an application command
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
Yeah, since missing file error is not caused in an application command
ah yeah right i see, you know of any alternative ways of doing this then?
What should i put instead of commands.CommandOnCooldown?
Hmmmm, I'm not sure, I haven't
Rliy used it before
And the docs just say the event method so idk
Yeah thats where i seem to be getting stuck lol
Actually, if the error arises from a command callback, it will be raised there
doesnt matter if pycord or not
error: discord.DiscordException should rather be error: Exception I believe
do you have the traceback for when the file not found error is raised?
you will find the error class in there
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?
FileNotFoundError, but then doesnt that only target that specific error instead of any that gets raised?
yeah
oh i just understood your question
you want to catch an error anywhere in the bot. not necessarily in cmds
then this looks your only option
Yeah but im not sure how to capture all the errors with their tracebacks so i can send that traceback into a discord channel aha
you can get the traceback from this
https://docs.python.org/3/library/traceback.html#traceback.format_exc
pycord uses the print version of this, but as you need the traceback, use this
this is what library uses
https://github.com/Pycord-Development/pycord/blob/master/discord/client.py#L437-L447
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()```
can i use selenium with pycord?
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
I'd recommend using playwright or pyppeteer since they're already asynchronous
didnt know ppeteer did exist in python thanks for the advice
Yw
Is the object for channels
discord.channel
Anyone
Did you try looking at the docs?
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?
Yup found it
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?
damn 💀
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 😦
Streaming music from YouTube is against ToS
It does work but can crash from time to time idk why
Still doesn't change the fact that it's against ToS
😭
Well you can stream from SoundCloud or local files using lavalink too
The ones on wavelink GitHub page work
Yeah I do that but aperantly I have some connection issues
Trying to configure it
pycord or discord.py?
thats like asking which is scarier, js or fnaf
no one knows
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.
I am getting in my logs: "Excepton name 'aiohttp' is not defined " but I have it in my env
code plz
?tag helpgist
When getting help, please make sure of the following:
-
Did you Google or check the Pycord docs for your problem? Reading the error message may also be helpful
-
Did you send a large portion of your code (the entire script, function, and/or other important variables)?
-
If you are getting an error, did you send the entire error?
-
Did you make sure to send code as text in code blocks, NOT AS IMAGES?
-
Did you already take steps to solve the problem on your own? We can debug, but we will not write code for you.
-
Are you posting in the #969574202413838426 channel?
For more info check out #how-to-get-help and #help-rules
it is the import
It is working on my laptop, but not in my server
server has aiohttp installed?
yeah the pip freeze is from the server
Here is from laptop, same imports:
but it is working
💀
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?
I do have multiple !
perhaps try python3 name_of_file
that is why I am telling whith one
specifying python3
could you show the full traceback?
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
can you make sure you did import aiohttp?
It works on laptop so i think they did do that already
yeah it is imported
I will try to print it
the only difference is the version of python
my laptop is using 3.10.0, and the server 3.9
could you try pip3 list and check if the library is installed?
(from server)
I am waiting for the bot to go online, for the full print_trace printing
it take 5 minuets to get online
And python3.10 -m pip list shows?
although it looks like import worked since its giving nameerror not importerror
in the laptop (3.10) it is this:
(where it works)
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
oh why not ?
Because sudo uses a different environment meaning your packages won't be installed
Unless you also installed them with sudo
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 !
👍
oooh and if I want to contribute, to pycord where would I start ?
Go to https://github.com/Pycord-Development/pycord/ and look at issues, or create a pull request with the feature/fix you want to add
perfect thanks you !
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)```
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.
yes
There is the invoke method
.rtfm invoke
discord.ext.bridge.Bot.before_invoke
discord.ext.bridge.Bot.invoke
discord.ext.bridge.Bot.invoke_application_command
discord.ext.commands.Bot.after_invoke
discord.ext.commands.Bot.before_invoke
discord.ext.commands.Bot.invoke
discord.ext.commands.Bot.invoke_application_command
discord.ext.commands.Cog.cog_after_invoke
discord.ext.commands.Cog.cog_before_invoke
discord.ext.commands.AutoShardedBot.after_invoke
discord.ext.commands.AutoShardedBot.before_invoke
discord.ext.commands.AutoShardedBot.invoke
discord.ext.commands.AutoShardedBot.invoke_application_command
discord.SlashCommandGroup.after_invoke
discord.SlashCommandGroup.before_invoke
discord.SlashCommandGroup.invoke
discord.SlashCommandGroup.invoke_autocomplete_callback
discord.ApplicationCommand.after_invoke
discord.ApplicationCommand.before_invoke
discord.ApplicationCommand.invoke
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
Gotcha, thanks! I'll check out what I can use here, keeping that in mind.
What is the max value of slowmode?
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.
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
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
here is my pip list
Learn all about implementing Select Menus or Dropdowns in your Discord Bot with Pycord.
yes
they r called select menus
also can u help me
with this

alr
show how you have defined your bot instance
oh
alr
what do you mean with "new" ones?
guide only tells you how to create select option select menu, not the role/user/channel select menus
I would not use it with a role/user or even channel
use what?
the menu
i use that with my other bots too
How do I remove a role from a discord user id?
why?
you have a limit of 25 options
yea thats what im saying. guide doesnt have example of the new roles/user/channel select menus
im talking this https://docs.pycord.dev/en/stable/api/ui_kit.html#discord.ui.user_select
i use it with all of my other bots?
.intents
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)
In version 1.5 comes the introduction of Intents. This is a radical change in how bots are written. An intent basically allows a bot to subscribe to specific buckets of events. The events that corr...
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
you dont even have added the intents
this is how you do them
how do my other bots work?
its the same like a "normal" menu
true lol
use different select menu decorators
see this one
i dont think intents is the problem
but you are still not sure what you are doing
even after adding intents still have the same error
Did you add them in both the code and the panel?
And does your bot have adequate permissions?
yes
yes
yet still
ine 186, in <module>
@bot.slash_command()
^^^^^^^^^^^^^^^^^
AttributeError: 'SlashCommand' object has no attribute 'slash_command'
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).
@bot.command()
i tried that too
Did you do this?
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.
py-cord 2.3.2
uninstall and reinstall
i did that already today
yep
pycord supports webhooks tho
but i dont understand it tho
i feel dhooks is so simple
but dose it make a problem with my code when i am using dhooks?
i dont think so, but it is not recommended to use separate libraries
my code still dont work lol i added intents and everything uninstalled pycord and installed and on my other bots that dont use intents and that stuff work perfectly fine 
i am ded
.rtfm on_reaction
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
discord.Embed
discord.Embed.Empty
discord.Embed.add_field
discord.Embed.append_field
discord.Embed.author
discord.Embed.clear_fields
discord.Embed.color
discord.Embed.colour
discord.Embed.copy
discord.Embed.description
discord.Embed.fields
discord.Embed.footer
discord.Embed.from_dict
discord.Embed.image
discord.Embed.insert_field_at
discord.Embed.provider
discord.Embed.remove_author
discord.Embed.remove_field
discord.Embed.remove_footer
discord.Embed.remove_image
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()
umm yeh because i wanted to try my other intents
and stuff
but it didnt help
that is even worse than before
.rtfm on_component
Target not found, try again and make sure to check your spelling.
how am i supposed to do it then bruh
What about asking instead of running random rtfm's
i need a suggestion system
I ain't gonna download a random file
why you cant do from tokens import * ?
?tag paste
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
imma use pastebin
i was testing since it didnt work before
Just do this
bot = discord.Bot(intents=discord.Intents.all())
instead of this big bruh
and what the hell
what is that
?
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
there i ment
look at the highlighted ones
so what do you want?
i am having this error
line 154, in <module>
@bot.command()
^^^^^^^^^^^
AttributeError: 'SlashCommand' object has no attribute 'command'
gimme sec
import discord
from dhooks import Webhook
from Tokens import TOKEN
import logging
from discord import Option
from discord.commands import slash_command
?
is there an event that will fire if the bot is disconnected from voice by an admin? (Through right-click -> Disconnect)


