#Basic Pycord Help (Quick Questions Only)
1 messages ยท Page 16 of 1
no its not the case
Hmm
i get 60ms from my host
No idea tbh
If you were responding more than once it would have said interaction already responded
But that's not the case
Are you running multiple bot instances?
is there a place i can see discord.Interaction.data dict keys?
im trying to get the command usage
or command message content
Discord docs?
Resetting token will remove that from happy
ty ty
Anyone having trouble with Autocomplete being utterly broken over the last few days?
I see the bot adding the right list to the autocomplete, but just erroring out over being a task ๐ค
no
i thought making the interaction work like this would help it but no
now what im thinking to avoid this is that im gonna defer the interaction and just send a normal message in that channel its not like it was ephemeral before
Try doing interaction.followup.send instead of interaction.response.send_message. Also replace interaction.message.edit with interation.response.edit_message
im doing the same right? in the try block
Yeah, but also try replacing the interaction.message.edit
okay
when i use both min_value and max_value, like shown in the example discord.Option code, the command does not register (and is removed) from my testing server
nevermind, i realized my problem
can you use tasks with cogs for separate files?
tasks work fine in cogs yes
how do you start said tasks?
im pretty sure most of the task examples already use cogs
where is an example?
https://guide.pycord.dev/extensions/tasks/#example-usage (2nd example)
Concept
what is the exact amount of time until an ephemeral message become invalid (not sure if thats the right word). i cant find a specific number either on the pycord docs nor on the official discord api. according to this dicord faq (https://support.discord.com/hc/en-us/articles/1500000580222-Ephemeral-Messages-FAQ), it just says "These messages disappear when you [...] wait long enough" and "They'll disappear after a little bit of time..."
its 15 minutes
does discord.commands.Bot.reload_extention(...) update slash command ui stuff? for example options
One message removed from a suspended account.
How can I make a timeout for a command
Timeout for a command?
How can I reply to a dropdown with a button?
I'm trying this
async def select_callback(self, select, interaction): # the function called when the user is done selecting options
if select.values[0] == "Shoppy":
await interaction.response.send_message(view=SubStoreMenuShoppy)
else:
await interaction.response.send_message(view=SubStoreMenuPatreon)
you can
what is SubStoreMenuShoppy etc.
class SubStoreMenuShoppy(discord.ui.View):
def __init__(self):
super().__init__(timeout=None)
PayPalPage = discord.ui.Button(label='Shoppy Link', style=discord.ButtonStyle.gray, url='')
self.add_item(PayPalPage)
@cyan quail
ah
i tried that im pretty sure
AH guess not lmao
thanks, it works now
How do I make it so it shows the "dismiss message" think so it only shows for you
do I just add ephemeral=True?
If its from a slash command yes
Or application command type specifically
Why is this happening with motor? And how do I fix it?
My cog file isntworking, anyone know the issue
# main.py at the bottom of code:
for file in os.listdir('Cog'):
if file.endswith('.py'):
client.load_extension(f'Cog.' + file[:-3])
# Cog/staff.py:
class staff(commands.Cog):
def __init__(self, client):
self.client = client
@commands.slash_command(name='mute', description='Mutes <user> for <duration> minutes because of <reason> using discords new timeouts')
@commands.has_guild_permissions(moderate_members=True)
async def mute(self, ctx, member: discord.Member, duration, reason):
minutes = datetime.timedelta(minutes=int(duration))
await member.timeout_for(minutes, reason=reason)
muteem=discord.embed(title=f"{member.mention} was muted for {minutes} for {reason}", color=0x2F3136)
await ctx.message.delete()
await ctx.respond(embed=muteem)
def setup(client):
client.add_cog(staff(client)))
try using the setup function
interaction.response.edit_message is will not send an ephemeral message
i mean i want to edit the message + send a response
What's rhat
I used a definition
import your file name
your_file_name.setup(client)
setup is a function in your cog file
you can run that function
from main file
even interaction.response.edit_message isn't working
in main file import cog_file_name without.py in the end and then use cog_file.setup(client)
if it's in a folder you can use
from cogs import cog_file
cog_file.setup(client)
this wont work with no error, any help?
How can I get a user object with the pycord dropdown?
Interaction.user?
you never sent something in the first place
your probably on mobile lol
i'm not
you have your command, and inside set up a select menu, but you never sent the select
Is the "Pause Invites" feature already in pycord?
anything like guild.pause_invites or smth?
how can i get Bot Latency And API Latency
this is the bot latency
"This could be referred to as the Discord WebSocket protocol latency."
๐
from ..http import Route, handle_message_parameters, MultipartParameters, HTTPClient, json_or_text
ImportError: cannot import name 'handle_message_parameters' from 'discord.http' (C:\Users\14794\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\http.py)
uhhhhh
Don't defer if you have already edited the message
I'm not sure but i think the method for editing was interaction.response.edit_message
After you do that, directly use interaction.followup.send
Nothing is working
However i try to respond to the interaction it says unknown interaction
So i thought if i defer the interaction and try sendnig the messgae like a normal mesg it would work
Tried resetting the token?
You you can't respond then defer wouldn't mostly work either
Im not responding
It would clear up any extra instances you may be accidentally running
Im just editing like a normal message
Hmm
Try this thing ^
Edit as a response and then send a follow-up
If i would have been running two instances then my commands would reply twice wont they
Does not work it throws up error in editing as response only
See here
There could be some code issue in that one (if the instance was of some previous code) that's why you aren't getting any double replies
But it could be attempting to send a response and discord might be picking it up
Idk tbh
I see
What was the code when you were doing this
Lemme get my laptop
this is my current code haven't tested it yet
im doing response in the last cuz even if it throws error it not gonna stop anything from running
the code before this was
await interaction.response.edit_message(view=self)
await interaction.channel.send(cont)
so as i put the reponse above channel.send(...) the line was not executed
i'll try it
wait i think there is interaction.edit_original_message too
try that
hmm
but do you send a followup after you defer?
man this whole interaction thing is a bit weird ngl
multiple way to do multiple stuff
no im just gonna defer it
and the button will get disabled in 5min due to timeout
anyone know how long slash commands take to add to guilds?
if it depends on the guild count, consider 1100
pls @ me idc
prolly 1h-2h
what is lock in buttons
tho in starting we were told 1h, but discord is speeding it up, so max 1 hr
Hi, i've used the old Discord package for python for a long time and i wanted to take a big step and use py-cord. I stumbled across the "selectors" and i tried making a role selector. Everything fine so far. I just wanted to know if its possible to deactivate the selector after a user chose a role.
set .disabled = True in callback
So i assume to use a 'self.disabled' or am i wrong?
you need to send code for that
the thing b4 . must be a SelectMenu object
async def select_callback(self, select, interaction):
await interaction.response.send_message(f"Perfect. You chose the role {select.values[0]}")
This is my callback.
For the selector i use a class:
class MyView(discord.ui.View):
@discord.ui.select(...)
await ctx.send("Simplistic - Role Selector", view=helper.MyView())
select.disabled = True
then you need to edit the message with new view as self
await interaction.response.edit_message(view=self)
Ah thank you so much ^^ It worked now
๐
set invisible=True while deferring if you do that
Totally forgot about that ty
wait isn't it true by default?
lol
pog its still there
i can't even defer it
i think i should not give a response
man
wait for someone else
or ask in discord support server
also what is your discord version btw
This is the whole error
how do i know that
it auto updates discord on start
pip list
oh
pycord version?
2.0.1
try 2.1.1
it has problems
oh
hmm
20-25 people clicking the button at the same time
for some it works maximum get interaction fail
Why is this happening with motor? And how do I fix it?
full traceback?
I need help PyCord+Pillow not work.Details in private messages.Please help .
๐ general problem
because its an attribute
bruh i use pillow with pycord it works smooth as ..
But it give me error .Why?
If you can give example.I'll be glad
Why is get_application_command so unreliable?
whats is the error?
how>
error?
well
I can't get any sub commands
and I can't get any group commands
pycord version?
- Python v3.10.5-final
- py-cord v2.1.1-final
- aiohttp v3.8.1
- system info: Windows 10 10.0.19044
ok one sec
i miss this command
same issue
neither of the first two yields have a value
OH
I need to specify that the config command is a group via type=discord.SlashCommandGroup
That's whacky
One message removed from a suspended account.
One message removed from a suspended account.
make sure you are running 1 bot instance
One message removed from a suspended account.
how can I create something like this?
Why wont this work
that's not how you use it, you're looking for member.avatar.replace
https://docs.pycord.dev/en/master/api.html#discord.Asset.replace
@cyan quail thx, I did it already
Anyone got any idea on how to get pycord or any python library to work with https://codecollab.io
Pip doesn't work
Nor does cloning the development version
perhaps there's a reason they don't want people installing packages
but you could potentially just write a python file to install with pip
Hmm
Pip does run and install it
But it says no module named discord
It probably can't access the library
How can I get the user ID from a button click? I need it just to print to console at the moment.
interaction.user
I knew it was something with .user
sometimes i have it too
you had it even here lmao
interaction.user.id
see, we all have strokes sometime
there only took 3 tries
Thankyou :D
How can I made it so with a / command it gives then 2 options for a value? e.g. transcript:True/False
If you would like to have the true/false, then you can use the bool type in discord.Option
I tried messing with discord.Option and couldn't seem to get it to work, do you have any examples?
So something like this:
async def some_command(ctx, choice: discord.Option(bool, "Your choice")):
...
Yeah, there should be some in the guide and examples in the github repo
what is bool? the value name?
No, its the type
oh wait yeah
So you could use int for example so that it automatically converts to int and Discord will actually prevent people from entering a non-int on the ui side of things
Learn all about Slash Commands and how to implement them into your Discord Bot with Pycord!
i cant remember for some reason
wdym?
Like True isnt a str its called something else
bool
oh
that would be logical
also
this should work right?
for i in range(5,1,-1):
await ctx.respond(f"Ticket closing in {i}...")
time.sleep(1)
time.sleep(2)
await ctx.channel.delete()
I would recommend using await asyncio.sleep() instead of time.sleep as time is thread blocking
But other than that it should work
kk
So it works then it counts until 2 then waits 2 seconds and deletes it
Then do 5, 0
How to check who invited someone?
Is there anyway to use interaction to get the guild instead of ctx? ctx code: guild = ctx.message.guild
I couldn't find any of that on the documentation, thankyou
Thankyou :)
Hi, why i can not use global for get the channel?
....(self, ctx, channel: discord.TextChannel):
global channel
i need this for my modal because i want send to the channel what i select.
One message removed from a suspended account.
Just pass the channel into the _init_ in the modal
So something like this:
class MyModal(Modal):
def __init__(self, channel):
super().__init__(...)
self.channel = channel
async def callback(self, interaction):
...
You could potentially store the person who first clicked the button
Set it to None initally, and then on button clikc, check if person is None and then update the person
interaction_check gets called when the button is clicked, you can simply check if someone already clicked it (perhaps with a mutex) and only process it if they're the first person
but he knows not the channel or? i must pass the channel from the slash command
how do i make it so only the admins can see the command
One message removed from a suspended account.
One message removed from a suspended account.
guild settings > integrations
can anyone helps me?
i mean i have a slash command to select a channel, then open's a modal and when i click to confirm when send this in the channel whats i select.
did you subclass the modal
no because i can not add the channel i have tried with global but this not works
you can just add an argument to the modal and pass it in, don't use global
well in any case, show how you've implemented it currently
@slash_command(description="test")
async def test(self, ctx, channel: discord.TextChannel):
modal = modal(title="Modal Test")
await ctx.send_modal(modal)
class modal(discord.ui.Modal):
def __init__(self, channel, *args, **kwargs):
super().__init__(channel, *args, **kwargs)
self.channel = channel
self.add_item(discord.ui.InputText(label="sass", placeholder="asas"))
async def callback(self, interaction: discord.Interaction):
await self.channel.send(f"bla")
well you got it, but you never passed channel into your modal
and you should call them different things
like call the class Modal
then do modal = Modal(channel, title="...")
oh also take channel out of super().__init__()
yes that's why yes global
okay
but you don't need global...
Nvm it was a code error
so without channel in the super class and now its that works ?
it should
then come this error
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: Modal.__init__() missing 1 required positional argument: 'channel'
i just said
ok look
you've defined your modal like this py class Modal(discord.ui.Modal): def __init__(self, channel, *args, **kwargs):meaning the first argument should be channel, and then anything else
but you're doing py modal = Modal(title="Modal Test")see the problem?
mhm i use now channel?
modal = Modal(channel, title="Modal Test")
yes
oh man.. discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'TextChannel' object has no attribute 'row'
okay i have it
no coming same error
can you show your new code
@slash_command(description="test")
async def test(self, ctx, channel: discord.TextChannel):
modal = Modal(channel, title="Modal Test")
await ctx.send_modal(modal)
class Modal(discord.ui.Modal):
def __init__(self, channel, **kwargs):
super().__init__(channel, **kwargs)
self.channel = channel
self.add_item(discord.ui.InputText(label="sass", placeholder="asas"))
async def callback(self, interaction: discord.Interaction):
await self.channelchannel.send(f"bla")
btw when i remove **kwargs then coming a new error
don't remove it
okay
just checking, you didn't import Modal did you
No why?
you missed this
ohh
yep its works thanks
all good
@commands.slash_command(name='mute', description='Mutes <user> for <duration> minutes because of <reason> using discords new timeouts')
@commands.has_guild_permissions(moderate_members=True)
async def mute(self, ctx, member: discord.Member, duration, reason):
minutes = datetime.timedelta(minutes=int(duration))
await member.timeout_for(minutes, reason=reason)
muteem=discord.embed(title=f"{member.mention} was muted for {minutes} for {reason}", color=0x2F3136)
await ctx.respond(embed=muteem)
Indentation looks right
Ping me if u can fix
Copied and pasted your code and there's literally an indent
Its not that python just wants to yell about it
?tag norepl
Why NOT to use Repl as a hosting platform
You should not use Repl.it to host your bot.
It may be a nice option as its "free" but you should use something else considering the major flaws.
- The machines are super underpowered.
-
- This means your bot will lag a lot as it gets bigger.
- You'll need a web server alongside your bot to prevent it from being shut off.
-
- This isn't a trivial task, and eats more of the machines power.
- Repl.it uses an ephemeral file system.
-
- This means any file you saved via your bot will be overwritten when you next launch.
IMPORTATNT
- They use a shared IP for everything running on the service.
This one is important - if someone is running a user bot on their service and gets banned, everyone on that IP will be banned. Including you.
Please avoid using repl.it to host your bot. It's not worth the trouble.
If you're looking for free options, consider using AWS/Google Cloud Platform/Azure and its respective free tiers or just pay for an actual VPS.
Do you have a proper IDE? Any decent IDE shows indentation errors.
I use replit cuz there isn't any other free hosting and i dont got money
eh... arguably none of them are, even cheap 1-2$/month hosts are significantly better just because they operate in a very different way from free services
but if someone has to use a free service even when we advise not to, we can't really stop them
I litterally cant spend money, im moving to a new house, and i dont have money, luxxy is constantly getting doxxed and railway is sketchy
Replit is fine
Railway is way better than replit
But its sketchy
It's not
It is so
please avoid... arguing about free hosts here, take it to #general
Some guy tried to make me use his code and get money off of me
With railway
Replit is fine
it's just a method you can override in your View
One message removed from a suspended account.
How can I get a list of all slash commands (my bot has)
I'm looking to get the name of the slash command only
bot.application_commands is a list of application commands, so you can iterate through it and check command.name iirc (command being the application command name).
walk_application_commands
How would I go about restarting a task?
thx
Like due to an error or smthn
mytask.restart() I think
One message removed from a suspended account.
One message removed from a suspended account.
Integrate your service with Discord โ whether it's a bot or a game or whatever your wildest imagination can come up with.
One message removed from a suspended account.
how can I add on_application_command_error to my cog file where I put all the event listeners (or cog.listeners)? I did it already but its not handling the errors:
@commands.Cog.listener()
async def on_application_command_error(self, ctx: discord.ApplicationContext, error):
if isinstance(error, commands.CommandError):
print(error)
await ctx.message.add_reaction(':x:')
if isinstance(error, KeyError):
print(error)
await ctx.message.add_reaction(':x:')
Are you sure the cog is loading?
And also is the error of type CommandError or KeyError?
yes because all the other event listeners are working properly
as on_message, on_member_join
Add a print(error) outside of the if statements
on_application_command_error doesnt handle prefixed commands errors
on_command_error does
yeah
One message removed from a suspended account.
that's because await member.send("Test") does not return a bool (True or False)
you should use try: and except:
One message removed from a suspended account.
anyone knows how to host bot on railway?
File "/app/mbtrack.py", line 7, in <module>
import matplotlib.pyplot as plt
File "/opt/venv/lib/python3.9/site-packages/matplotlib/__init__.py", line 109, in <module>
from . import _api, _version, cbook, docstring, rcsetup
File "/opt/venv/lib/python3.9/site-packages/matplotlib/rcsetup.py", line 27, in <module>
from matplotlib.colors import Colormap, is_color_like
File "/opt/venv/lib/python3.9/site-packages/matplotlib/colors.py", line 56, in <module>
from matplotlib import _api, cbook, scale
File "/opt/venv/lib/python3.9/site-packages/matplotlib/scale.py", line 23, in <module>
from matplotlib.ticker import (
File "/opt/venv/lib/python3.9/site-packages/matplotlib/ticker.py", line 136, in <module>
from matplotlib import transforms as mtransforms
File "/opt/venv/lib/python3.9/site-packages/matplotlib/transforms.py", line 46, in <module>
from matplotlib._path import (
ImportError: libstdc++.so.6: cannot open shared object file: No such file or directory
Traceback (most recent call last):
``` i get this error
Please help me in my post
yea its pretty easy
you can either deploy via railway cli, or upload your code to a private repository in your github and deploy the repo in railway
i am sure the docs must have covered it all
Does pycord support the HTTP thing where a bot can have no status?
it not coming online and its full of that error
i deploying using private git repo still
recheck your imports something is wrong there
yes
and how?
how to have timestamp like this in embed footer
embed.timestamp = datetime.datetime.utcnow()
how to add slash command permission for an user id?
is it not possible to get contents of automod filters yet?
can only do it from guild settings > integrations
or fetch_auto_moderation_rules if you want all rules
not sure if the feature is 100% complete yet, but it should work well enough
i know thereโs AutoModRule object, but it seems to have no attribute for fetching the actual words of the filters
https://docs.pycord.dev/en/stable/api.html#discord.AutoModRule
trigger_metadata i think
the object doesn't appear to be fully implemented, but does it return anything?
Why do I get this when I start my bot? It looks like it happens after the on_ready event. The bot still works
it returned nothing, sadly
probly itโs not finished
what version
If you get a Missing Access (50001) error, you probably forgot to add the applications.commands scope.
To fix that, just replace YOUR_BOT_ID with your bot id and visit this link: https://discord.com/oauth2/authorize?client_id=YOUR_BOT_ID&scope=applications.commands
or you specified a guild_id you don't have access to
ty
from the looks of it, it is fully implemented but not documented
https://github.com/Pycord-Development/pycord/blob/v2.1.1/discord/automod.py
if it's not returning anything, chances are discord isn't sending you the info
there's also the event https://docs.pycord.dev/en/master/api.html#discord.on_auto_moderation_action_execution if you want to see if it's received through there
i managed to get the data!
it was just that the data i was trying to fetch was a discord-made one, so there was nothing inside the data
sorry, and thanks for the help!
all good
thanks
Hey, why i can not edit my label from the button?
global no
@discord.ui.button(label=no"
global no
no = f"({nein_counter})"
NameError: name 'no' is not defined
btw nein_counter = in json
its possible to add cooldown to buttons?
Do we know why discord.User.display_name throws a type error in pylance? It's weird because they're typed correctly in the source
Just access the label attribute
Cause whatever youre doing there makes no sense
Uhh, handmade. Use interaction_check and check if the user is stored in X thing and just reply and return False otherwise True
yeah but how?
i try label.edit("..") but i think thats incorrect
what exactly is ctx:commands.Context used for? does it have to go in every command, or only those with arguments?
Buttons callback receive Button which references to the Button itself
And the button object has a label attribute
ohh okay
I'm sure you can figure out what to do with that
Goes in all commands n
All commands receive a context.
It is what the word says, the command context
Its not a function
Oh a function
I said its not
ok ty
can someone help me with this?
``` await interaction.author.send(embed=discord.Embed(title="Key Generated",description=f"Your Key: {key}",colour=0x42F56C))
like if u clicked the button you will receive a dm
nvm i replaced author with user
this question probably has been asked but
can i respond to a slash command without sending any message?
you can send a modal
but i don't want to
i just wanna do something without sending a message so discord doesn't say
"Interaction Failed"
why can't the response be ephemeral?
what does your command even do
i keep getting this error "ctx is a required argument that is missing.", when i use this command. anything i could do about this ? here is the command code.
it just a error handler
it's it better to say "An error has occurred"?
why don't u do ctx: discord.ApplicationContext
because you are outside of a class.... learn python thanks
well yes but i don't want it to send a message
and instead do something else
like what?
like send a message on a other website (using a other api)
it's still good for the end-user to display a success or fail
ik but can i pls just have the code to say to discord not to popup the
Interaction Failed
i just wanted to create some small projects along side with learning python, but thanks
i could do that but it will be kinda weird
to see a message just pop up and dissapear
exactly
.invoke()
ctx.invoke()
ctx.invoke
then it doesnt pop up
ok let me test it
wait it requires a command argument
and im on a bot.event
not bot.command
wut
lemme see
show the code....
what even is the point of invoke
@bot.event
async def on_application_command_error(ctx: discord.ApplicationContext, error: discord.DiscordException):
await ctx.invoke()
if isinstance(error, commands.CommandOnCooldown):
# Other API Related Stuff Unesscarry to Discord
else:
raise error
Why are you invoking the command on error?
so i don't get a Failed Interaction by discord
I still don't understand why you can't respond with a message
Just use ctx.respond
but i don't want to respond to a message, i wanna use lets say a other api to respond
oh wait
what do you mean another api to respond
nvm i get what u meant
you should still send a message eventually to inform the end-user of the result of their command
like how can i say this
when the end user executes the command
i wanna end the command and not output anything
still getting the error, but thanks
that sounds absurd
like this discord.py code
even saying something like "Success!"
try:
await inter.send()
except disnake.errors.HTTPException:
pass # We know this isn't valid but that's fine
would work
I have my bot set up to create a new channel with guild.create_text_channel("Name")How can I make it create a private channel, one that I can add users or roles to have permissions with
u use overwrites i think

overwrites is basically the permissions
I did I cant find it
ahh right okay. Thankyou for the help
np
Thankyou as well
anyways
uhh The application did not respond can this tho be disabled without sending a new message
thanks
np, it really doesn't fix the problem
but i think it adds the menus if ur using pycharm
so u can inspect the functions without having to look the docs
or ask anything
yeah, i fixed the problem in another way
i added a cooldown to 1 command like this
@discord.ext.commands.cooldown(1, 1, discord.ext.commands.BucketType.user)
and it worked fine
but now i added it to other commands and it tells me
AttributeError: module 'discord' has no attribute 'ext'
and i am confused why it has only decided now that theres no ext
did you define a variable or function called discord
can you show the full file
uhhh its 3500 lines
ill try go back to when it worked and try again
maybe i just copied and pasted wrong
yea i went back to it only being on 1 command and it works fine
thats so weird
does anyone have any type of example of where when u need a password for a command to work because i have seen my friend use a code where the password is needed for the command to execute if anyone has any info on something like this please let me know
Does anyone have a raffle command I could take a peek at? ๐
code:
member = await ctx.guild.get_member(user.id)
error:
Application Command raised an exception: TypeError: object Member can't be used in 'await' expression
get_member is not a coroutine and must therefore not be awaited
https://docs.pycord.dev/en/stable/api.html?highlight=get_member#discord.Guild.get_member
the error occurs after the member was found, therefore trying to await the object Member that was retrieved by the get_member method
@tulip bobcat thanks, mixed up fetch_member and get_member methods
even says the exception
thank you, i already figured it out
is it possible to add a sort of custom variable that i can write to the function of a command and access it later by like using ctx?
How can I make only members with a specific role that can access a command
I have an ApplicationCommand object (command from my bot), how can I get a list of all the inputs it takes from the user
when i use task.loop() and pass a time(hour=8, minute=15) object, does it loop through the task until the minute is over or only once?
uhhhh can you show the actual decorator you used, somewhat confused by your wording
command.options
'TicketingButton' object has no attribute '_underlying' hm what
if you mean showing/hiding, you have to use guild settings > integrations
looks like you passed an incorrect object type somewhere, what's the related code?
Not this
in that case, see checks such as https://docs.pycord.dev/en/master/ext/commands/api.html#discord.ext.commands.has_role
@tasks.loop(time=time(hour=8, minute=15))
class TicketingButton(discord.ui.Button):
def __init__(self, label):
super().__init__(
label="Report Player" if label is True else "Open a Ticket",
style=discord.ButtonStyle.red,
custom_id="report" if label is True else "ticket",
)
async def callback(self, interaction: discord.Interaction):
bot = variables.bot
embed = await interaction.response.send_modal(ReportingModal()) if self.label is True else await interaction.response.send_modal(TicketingModal())
cat = bot.get_channel(1012271308765138954)
overwrite = discord.PermissionOverwrite(send_messages=True, read_messages=True, read_message_history=True)
category_overwrites = cat.overwrites```
how do I add arguments to the callback func? I can't add things in the __init__ as that would mess up the parameters I think
it repeats every day at 8:15 AM, based on your bot's OS time
no, you do add stuff in the init
you can't mess with the callback
yeah but when the function inside is finished, does it repeat itself inside that 8:15th minute?
why would it repeat itself
just to clarify, you can add any custom arguments you want in def __init__, but you shouldn't add them to super().__init__ unless they would be allowed in the original object
class TicketingButton(discord.ui.Button):
def __init__(self, label, bot):
self.label = label
self.bot = bot
super().__init__(
label="Report Player" if label is True else "Open a Ticket",
style=discord.ButtonStyle.red,
custom_id="report" if label is True else "ticket",
)
async def callback(self, interaction: discord.Interaction):
embed = await interaction.response.send_modal(ReportingModal()) if self.label is True else await interaction.response.send_modal(TicketingModal())
cat = self.bot.get_channel(1012271308765138954)
overwrite = discord.PermissionOverwrite(send_messages=True, read_messages=True, read_message_history=True)
category_overwrites = cat.overwrites
category_overwrites[interaction.user] = overwrite
tn = await funcs.how_many_tickets() + 1
cursor = await variables.db_connection.cursor()
new_chan = await cat.create_text_channel(f'{"Reporting" if self.label is True else "Ticket"}-{tn}', overwrites=category_overwrites)
await cursor.execute(
"INSERT INTO Ticketing (TicketID, CreatorID, CreatedAt, ChanID, ClosedAt) VALUES (?, ?, ?, ?, null)",
(tn, interaction.user.id, time.time(), new_chan.id))
await variables.db_connection.commit()
await interaction.response.send_message(f"You can find your channel at <#{new_chan.id}>")
await new_chan.send(embed=embed)```
yeah that would work
though tbf you generally don't even need to do bot because you can get it from interaction.client
guild_ids=[variables.guild_id]) # Create a slash command for the supplied guilds.
@discord.default_permissions(
manage_messages=True
)
async def postticket(self, ctx):
view = discord.ui.View(timeout=None)
view.add_item(TicketingButton(label=True, bot=self.bot))
view.add_item(TicketingButton(label=False, bot=self.bot))
chan = self.bot.get_channel(1014263404992675850)
embed=await funcs.custom_embed("Welcome", "Please select one of the following options")
await chan.send(embed=embed, view=view)
await ctx.respond("Done", ephemeral=True)```
since you made the arguments positional, you just need TicketingButton(True, self.bot)
**Ignoring exception in command postticket:
Traceback (most recent call last):
File "/Users/marianraul/PycharmProjects/GTAbot/venv/lib/python3.10/site-packages/discord/commands/core.py", line 127, in wrapped
ret = await coro(arg)
File "/Users/marianraul/PycharmProjects/GTAbot/venv/lib/python3.10/site-packages/discord/commands/core.py", line 904, in _invoke
await self.callback(self.cog, ctx, **kwargs)
File "/Users/marianraul/PycharmProjects/GTAbot/cogs/ticketing.py", line 94, in postticket
view.add_item(TicketingButton(label=True, bot=self.bot))
File "/Users/marianraul/PycharmProjects/GTAbot/cogs/ticketing.py", line 36, in init
self.label = label
File "/Users/marianraul/PycharmProjects/GTAbot/venv/lib/python3.10/site-packages/discord/ui/button.py", line 189, in label
self._underlying.label = str(value) if value is not None else value
AttributeError: 'TicketingButton' object has no attribute '_underlying'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/marianraul/PycharmProjects/GTAbot/venv/lib/python3.10/site-packages/discord/bot.py", line 997, in invoke_application_command
await ctx.command.invoke(ctx)
File "/Users/marianraul/PycharmProjects/GTAbot/venv/lib/python3.10/site-packages/discord/commands/core.py", line 359, in invoke
await injected(ctx)
File "/Users/marianraul/PycharmProjects/GTAbot/venv/lib/python3.10/site-packages/discord/commands/core.py", line 135, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'TicketingButton' object has no attribute '_underlying'**
this is what I am getting
can you move the super init above self.label
(also considering the logic you used in super, you should completely remove self.label = ... anyway
it works tysm
Is there an easy way to set a recurring task to run on a specific day of the month? (i.e. "run on the 1st of the month at midnight")
I know I can set the next run datetime, but I wanted to make sure there isn't a more trivial method first
I need help, I installed pycord and I want to delete it for a while and when I type pip uninstall py-cord it is deleted but I can't start the regular discord.py bot
I thought it was down to the bot script itself, but not a single bot is working, but all of them were working
Try typing pip install discord.py
I tried, but then some commands work for me and some don't
type pip freeze and send output
Are you using app commands?
I believe dpy calls them something different so you may have issues using them
this isn't built in no
i guess you could have it run every day
and then check the current date
I've realized that now that I've implemented a select dropdown, the bot takes much much longer to shut down. Is this normal?
Event loop seems to only close sometimes.
nope
?tag codeblock
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.")
i realised i put role as interaction user id
One message removed from a suspended account.
Just send it here
Why dont you use the callback? Don't think its worth overriding it?
One message removed from a suspended account.
Make some attribute and check it before actually running the callback?
I have a command that essentially stops if 'lose' becomes false, I made a button that pops up along w the embed when you start the command
my question is how could I change the value of lose via the button?
One message removed from a suspended account.
class Skip(discord.ui.View):
def __init__(self):
super().__init__(timeout=None)
@discord.ui.button(label='Skip', style=discord.ButtonStyle.primary)
async def skip(self, button, interaction):
print('make lost true')```
this is my buttons callback and when i just try and lose = true in the callback nothing happens
Assuming youre subclassing view, just create some class attribute on init like self.pressed = False
Then just switch it when callback and check that on interaction_check
Errors? Expected output? Whats lose = true?
no errors
basically
the variable 'lose' is false in the command and when it becomes true, the command stops i currently have it so when you send a message in chat lose becomes true
but i want to make it so when you press the button lose becomes true
nothing happens when i just put lose = true in the callback though
One message removed from a suspended account.
Override interaction_check and just
if self.pressed:
return False
return True```
One message removed from a suspended account.
I said override interaction_check
One message removed from a suspended account.
interaction_check is a method, a function...
async def interaction_check(self):
if self.pressed ...
@discord.ui.button(...)
async def ...```
I've realized that now that I've implemented a select dropdown, the bot takes much much longer to shut down.
Event loop seems to only close sometimes. Otherwise it just sits there at closing forever. Is this normal?
Hi anyone have any idea whats going on with discrod api, my bot is getting temp ban too frequently and the bot is just shutting down even when the code is still running, It has been running for more than an year now never faced this and the bans were never frequent
No updates to the code have been done recently
What are you hosting it on?
also @lilac turret do u know how to make a command with optional arguments
text command or slash command?
text
I think you use Optional in the type annotation or set the default value to None
how do i give it different functions based on what u put
this is what i want to do
assign a default value like
async def cool_command(ctx, optional_arg = "No way!"):
pass
I don't think you can do that because of how Python treats default parameters before non-default parameters
Actually wait
I'm stupid sorry
Just check if the first argument is add or set, and if it's not then raise an exception
smarter than me 
alr ill try that
I'm surprised you didn't think about that
ykw i dont know how to do that actualyl
What
That reminds me. I should use case switches more.
hey man cut me some slack havent worked with python in like a week
u should
very much so
It's like one of the simplest languages to work with
well yes
but i have been doing cpp like stuff with arduinos and ultrasound measurement systems
for a while
Ah I see
ok #general ty
No and goodbye
bye and see you!
Make sure to use #969574202413838426 for help!
anyways so remind me how to check
How can I make it so when I restart my bot, the current buttons it has posted in channels still work and dont just say "interaction has not responded"
Wdym?
Here's the persistent example.
@worn void ^
ty
@bot.command()
async def heat(add, set, usr: discord.Member, val, ctx):
if #idk what to put here
what are you trying to do?
i would know how with normal base python but this is pycord
Sorry I didn't explain well what I meant
Its the same thing
Actually on second thought why not use subcommands?
what is a subcommand
actually ik what it is
but how do u do it with like
text cmds
wait ik how
congrats
any idea why i cannot get audio off of pycord
bot just will not play audio
even if lavalink says it is
Any more information? Saying "guys this isn't working" is not helpful
till now it has been on replit
where is the SlashCommandGroup decorator
how to invoke a slash subcommand?
works fine on one word slash commands
await ctx.invoke(self.bot.get_application_command('auction info'))
class TicketingModal(discord.ui.Modal):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.add_item(discord.ui.InputText(label="Reason", style=discord.InputTextStyle.long))
async def callback(self, interaction: discord.Interaction):
await self.wait()
embed = await funcs.custom_embed("Ticket", "A ticket has been opened")
embed.add_field(name="Reason", value=self.children[0].value)
return embed```
why won't the code wait for the modal to be completed by the user and why is embed of type interaction?
Stay in one channel?
question
quite quick one
does @commands.has_permissions also know when u have the permissions when you are administrator
Yes
?
so if i have lets say Admin Permissions
and the Command needs Kick, Ban Member Enabled, Admin Should bypass it
yeh ik, i was just making sure
bc when i used an if elif and else
i had to do
if (ctx.author.guild_permissions.kick_members or ctx.author.guild_permissions.ban_members) or ctx.author.guild_permissions.admin
thx a lot tho @young bone
also before u go one other question
is it possible if i can get the required permissions of a command without having to specify them in lets say a Database or json file
how can i access the callback without using decorator?
class SelectToDoItem(discord.ui.View):
def __init__(self, bot, entries):
super().__init__(timeout=None)
self.entries = entries
self.select_options = []
for entry in entries:
self.select_options.append(discord.SelectOption(label=entry[2], value=entry[1], description=entry[3]))
self.add_item(discord.ui.Select(options=self.select_options, placeholder="test", custom_id="select_todo"))
async def select_callback(self, select, interaction):
...
you can manually set the callback of an item
item.callback = your_callback
like this?
self.children[0].callback = self.callback
# the function called when the user is done selecting options
async def callback(self, select, interaction):
...
looks good
TypeError: SelectToDoItem.callback() missing 1 required positional argument: 'interaction'

in this case, the method should only use self and interaction as parameters
https://docs.pycord.dev/en/stable/api.html?highlight=select#discord.ui.Select.callback
oh okay, and how do i get the selected value?
nvm i got it self.children[0].values[0]
interaction.data["values"]
nvm figured it out
but one question and thats for the error handling
i wanna stop discord from Saying "Application did not Respond" bc i try to send a dm on my Error Handling
and the command kinda keeps going, even with the error
use on_application_error to handle the error
yeh i used it
but lets say i execute a command
and the error gets thrown yeh?
the bot dms me for the error, like normal
but the command just doesn't stop that i executed and then says after 3 seconds "application did not respond"
the command stops, but you never responded to the command, that's why it fails
instead of sending a dm, you could respond to the command
well yes, but i wanna send a dm and stuff
i would like it to respond by dm
is it necessary to respond via dm? or do you just donโt want the error to show รบp in the server?
if possible even turn of the application did not respond completely
it is necessary
as i will make it configurable
I think it's a discord thing, not pycord and therefore not possible
there were tricks on other libraries tho that disabled it
so py-cord should have one trick as well
oh, in this case I just donโt know about it
or send a dummy response
๐ค Hmmmm i might go back to discord.py
ik its a fork
but bc right there were tricks i could use to make discord stop saying "application did not respond"
how to dm a member?
use case - want to dm him when a guild has unbanned him
what was that trick?
something like this
try:
ctx.reply()
except HTTPException:
pass
basically stopping discord
also what does ctx.response.pong do?
like i see docs
and says Pongs the ping interaction.
ok
Is it possible if i can contact the Core Developer since they know a lot more bc they are a part of the library
dont know shoud ask mod
then move on to that
how to give options to select from?
in slash command
can u give me a example ๐
async def command(ctx, food: discord.Option(str, "Choose your favorite food", choices=["hotdogs", "apples", "banana"])
???
can you show your code
class View1(discord.ui.View):
def __init__(self):
super().__init__(timeout=0)
@discord.ui.button(emoji='๐ฉ', label='Stworz zamowienie!', style=discord.ButtonStyle.grey, disabled=False)
async def create_ticket(self, button: discord.ui.Button, interaction: discord.Interaction):
await interaction.response.send_message(f'Stworzono ticket!', ephemeral=True)
overwrites = {
interaction.guild.default_role: discord.PermissionOverwrite(read_messages=False),
interaction.guild.me: discord.PermissionOverwrite(read_messages=True),
interaction.user: discord.PermissionOverwrite(read_messages=True)
}
await interaction.guild.create_text_channel(name=f'{interaction.user.name}-ticket',
overwrites=overwrites,
reason=f'Ticket {interaction.user} (ID: {interaction.user.id})')
channel = discord.utils.get(member.guild.text_channels, name=f"{interaction.user.name}-ticket")
guild = member.guild
embed = discord.Embed(title="Stworzono ticket!",
description=f"Postฤpuj zgodnie z poleceniami administracji!", color=0x2f3136)
await channel.send(embed=embed)
@bot.slash_command(name='ticket')
async def test(ctx):
await ctx.respond(content=f'Wysลano!', ephemeral=True)
await ctx.channel.send(view=View1(), embed=discord.Embed(title='Stwรณrz zamรณwienie!',
description='Jeลผeli juลผ wiesz, co chcesz zamรณwiฤ, kliknij guzik na dole!\nNiepotrzebne tickety bฤdฤ
odrazu kasowane!', color=0x2F3136))```
the error seems to be talking about the wrong thing O.o
Where do you define member?
channel = discord.utils.get(member.guild.text_channels, name=f"{interaction.user.name}-ticket")
i didnt
does restarting the bot help?
I think you could replace member with interaction
I think all you need to do is upgrade to this PR
what version are you on now?
You should upgrade right away to the above pull (or at least 2.0.1).
2.0.0 has a major security vulnerability. Ability to crash your bot by just running a command or something
๐
Groups have been having a lot of issues.
\https://github.com/Pycord-Development/pycord/pull/1605
This is a new version that fixxes some things with cogs.
What are the problems you run into with newer versions?
pip install -U git+https://github.com/Pycord-Development/pycord/pull/1605 iirc
pip install -U git+https://github.com/Pycord-Development/pycord try this
Sorry im not sure about this. You should create a thread and someone with a bit more knolage of the issue might be able to help.
is it possible to edit a message without using channel.fetch_message ?
i want to avoid that api call
also does fetch_message return the view too ?
you can use channel.get_partial_message https://docs.pycord.dev/en/master/api.html#discord.TextChannel.get_partial_message
cool
but what about view
it returns a list of components in message.components, but you can get a useable view from a message using discord.ui.View.from_message
https://docs.pycord.dev/en/master/api.html#discord.ui.View.from_message
ohh ic ic
when i use this edit code i get interaction has failed, because no response, how can i change that?
await interaction.message.edit(embed=embed)
i think ill use fetch message as i need the view
interaction.response.edit_message
why so complicated 
not really, that's an interaction response
general question
do you like the current interaction setup? where you have multiple ways of doing multiple stuff? especially edit message ๐
well it kinda has to be like that
there is interaction.edit_original_message too ๐
responding to an interaction is different from regular sends/edits
we can lay it out
interaction.message.edit - Regular message edit, only works if message is cached / interaction.message isn't None
interaction.edit_original_message - Same as above, but more reliable since it can edit directly
interaction.response.edit_message - Responds to an interaction with an edit, only used once
in general, all methods under interaction.response can only be used once per interaction
can I get users by discriminator?
hi guys i wanna make a sqlite database for my bot, should i save user ids as int or string?
send the code
BigInteger
I had discord.py installed
How can I use a converter not in a function definition?
If I have an object, how do I convert it
Can you be more specific?
how to make buttonrole?
can i get some basic idea how that work?
what happens when bot restarts..
If I have an object that I want to convert, rather than do x: Converter,
How do I just do something like
y = Converter(x)
I think it depends on the object/converter
I'm actually not familiar with Converter, and was wondering what kinds of objects you're trying to convert?
For example Member
Convert a integer into a member using a converter, but not having it in the command definition
I would use fetch_member or get_member or discord.utils.get(guild.members,id=id)
yep that's the right way to do it outside a function definition.
I think I read somewhere that the member converter and others only work in the definition because they have to be specifically written to be able to do this.
@bot.slash_command(name='embed', description='Build an embed...')
async def embed(ctx):
be_button = Button(emoji='๐', label='Build', style=discord.ButtonStyle.green)
async def be_callback(interaction):
modal = MyModal(title="Modal Triggered from Button")
await ctx.send_modal(modal)
view = View()
be_button.callback = be_callback
view.add_item(be_button)
await ctx.respond("thinkin' about an embed?", view=view)
i have defined my modal somewhere so not to worry about that, but this keeps giving me an interaction responded error, how do i fix it
what do you mean "interaction responded error"
do you know how i can fix this? i am unable to understand i changed, ctx.respond to ctx.send and that didnt work either
is this when you run /embed, click the Build button, or submit the modal?
this happens when i click the build button
try to replace await ctx.send_modal(modal) with await interaction.send_modal(modal)
I was going to see what I do in my code but that sounds like it should work
interaction.response.send_modal
^ yeah I think that's what I do actually
Is there no get_role(role_id) ๐ค
Damn I got hit with a read the docs. Gotta happen eventually ig
gottem
how to download pycord beta v7?
How to get members that can see TextChannel?
install py-cord==2.0.0b7
but why
i always used it
i mean we have newer versions you can use
which
well we're currently on 2.1.1
would it affect my work?
pip install pycord==2.1.1
?
yeah
help~ 
Defaulting to user installation because normal site-packages is not writeable
ERROR: Could not find a version that satisfies the requirement pycord==2.1.1 (from versions: 0.0.1, 0.1.0, 0.1.1)
ERROR: No matching distribution found for pycord==2.1.1```
save it as BigInteger
i've just moved to api v10, and changed from commands.Bot to discord.Bot, and this isnt affecting any of the commands from working but on_ready is taking like 4 minutes to load where it used to load within like 10 seconds.
all good
Why does python write to me when starting the bot instead of starting it
c:\Users\niksy\Desktop\Caramel\bot.py"
Python
you can stay with commands.Bot
just run python path/to/bot.py
Try it without the 3 at the end of python
I started it via debug, but I can't do it this way
jesus 4 minutes
how can i play a mp3 file in a vc?
How can I made mandatory fields and optional fields in a slash command?
there is required kwarg in discord.Option
its True by default iirc
When I switched to pycord, I uninstalled later and went back to discord.py. I made a new bot and switched back to pycord with the correct code from using a slash command example from the guide. Although, the bot isn't turning on and I'm not sure why. If I switched back to discord.py, it would turn on. Does anyone know why? I already tried looking for answers
is there any errors?
There is, but the file crashes before I can even check the error.
are you on windows?
Mhm
python3 file_name.py
pause
use this script with .bat file
place it in same directory with your bot main file
You have to uninstall discord.py, then make sure you imported py-cord I believe
Its weird
its not, because pycord uses same namespace as dpy
I mean in that context its weird set of steps to install because of that
yeah
ty btw
๐๐ป
So would this work?
@client.slash_command(guild_ids=g, name="bug", description='Reports a bug to the Bot Developer(s).')
async def bug(ctx, bug, image : Option(str, "Any proof of this bug.", required = False, default = ''):
await ctx.respond(ephemeral=True, "Bug has been re[prted!")

lmfao, was wondering if i did it correct hoping youd respond before I can restart my bot
i think you did, but if you tried - you would see
yes it is
async def bug(ctx, bug, image : discord.Option(str, "Any proof of this bug.", required = False, default = ''):
^
SyntaxError: invalid syntax
what, how
oh nvm, im stupid
you didn't close the bracket
ok, thats out of topic now
fine ๐

I'm back. It didn't work. I used the script that you gave with the .bat file, but for some reason, it still didn't wanna work.
Now that I've implemented a select dropdown, the bot takes much much longer to shut down.
Event loop seems to only close sometimes. Otherwise it just sits there forever. Is this normal?
Elaborate on what you mean? How are you shutting down the bot?
SIGTERM graceful shutdown of the bot. Bot goes through the process of closing loop, cleaning up tasks, etc.
INFO:discord.client:Received signal to terminate bot and event loop.
INFO:discord.client:Cleaning up tasks.
INFO:discord.client:Cleaning up after 5 tasks.
INFO:discord.client:All tasks finished cancelling.
INFO:discord.client:Closing the event loop.
It gets to "Closing the event loop." and just sits there for ages.
not sure, im not very graceful and ctrl + c, saying fuck all
how can i play a mp3 file in a vc?
maybe try
voice.play(discord.FFmpegPCMAudio(executable="C:/path/ffmpeg.exe", source="C:/songpath"))
Here's the basic voice example.
thanks, i will look into this
is it possible to limit the visibility and interaction with a button to a certain role or user?
Heh. Welp. Issue with us is that we have some cleanup logic that has to be executed at shutdown lol
Here's the button roles example.
visibility would only be possible if it's sent in an interaction response using ephemeral=True
otherwise you'd just have to compare interaction.user in the callback
Or interaction_check
i host it on my synology nas
meaning im hosting it completely for free but also the specs of it aren't great
but its still manageable
How can I strip a channel for all of its permissions
use channel.edit with overwrites={}
Could you elaborate ?
that's literally what you do
oh ๐
Could someone help me out?
class TicketClosedButtons(discord.ui.View):
def __init__(self):
super().__init__(timeout=None)
del_button = discord.ui.button(label="Delete", custom_id="delete_ticket", style=discord.ButtonStyle.danger, emoji="๐")
trans_button = discord.ui.button(label="Transcript", custom_id="transcript_ticket", style=discord.ButtonStyle.danger, emoji="๐")
self.add_item(del_button)
self.add_item(trans_button)
async def button_callback(self, button, interaction):
support = discord.utils.get(interaction.guild.roles, name="Staff")
channel = client.get_channel(transchanid)
if button.label == "Delete":
embed=discord.Embed(color=0xff0000)
embed.add_field(name="Ticket Deletion", value="Ticked will be deleted in a few seconds.", inline=False)
embed.set_footer(text="Report bugs or suggestions with /bug or /suggest!")
await interaction.response.send_message(embed=embed)
await asyncio.sleep(5)
await interaction.channel.delete()
else:
transcript = await chat_exporter.export(interaction.channel)
transcript_file = discord.File(io.BytesIO(transcript.encode()), filename=f"{interaction.channel.name}.html")
await channel.send(file=transcript_file)
Error:
Ignoring exception in on_ready
Traceback (most recent call last):
File "C:\Users\Ryanh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 382, in _run_event
await coro(*args, **kwargs)
File "F:\[bots]\MyChemicalCult Bot\bot.py", line 36, in on_ready
client.add_view(TicketClosedButtons())
File "F:\[bots]\MyChemicalCult Bot\bot.py", line 136, in __init__
self.add_item(del_button)
File "C:\Users\Ryanh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ui\view.py", line 287, in add_item
raise TypeError(f"expected Item not {item.__class__!r}")
TypeError: expected Item not <class 'function'>
legoscrap-sup
Ignoring exception in view <TicketCommandButtons timeout=180.0 children=1> for item <Button style=<ButtonStyle.danger: 4> url=None disabled=False label='Close' emoji=<PartialEmoji animated=False name='๐' id=None> row=None>:
Traceback (most recent call last):
File "C:\Users\Ryanh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ui\view.py", line 396, in _scheduled_task
await item.callback(interaction)
File "F:\[bots]\MyChemicalCult Bot\bot.py", line 163, in button_callback
await interaction.response.send_message(embed=embed, view=TicketClosedButtons())
File "F:\[bots]\MyChemicalCult Bot\bot.py", line 136, in __init__
self.add_item(del_button)
File "C:\Users\Ryanh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ui\view.py", line 287, in add_item
raise TypeError(f"expected Item not {item.__class__!r}")
TypeError: expected Item not <class 'function'>```
should be discord.ui.Button
also you didn't actually assign any callbacks
and callback doesn't take the button argument if you're not using decorators, you should instead access interaction.custom_id
how would I do that
interaction isnt defined btw
discord.Interaction
"what about the button"
discord.ui.Button I gotcha brother
lol that doesnt work either somehow
you mean the type right?
they said to use "interaction.custom_id"
del_button = discord.ui.Button(label="Delete", discord.Interaction.custom_id="delete_ticket", style=discord.ButtonStyle.danger, emoji="๐")
Hey so does anyone know why when I edit a messages view from buttons to dropdown it activeates dropdown before they select an option
This is in button callback ```
view = discord.ui.View(Dropdown(self.confirm_interaction))
await self.confirm_interaction.edit_original_message(embed=embed, view=view)
class Dropdown(discord.ui.Select):
def __init__(self, confirm_interaction: discord.Interaction):
self.confirm_interaction = confirm_interaction
options = [
]
for i in range(1, 17):
options.append(
discord.SelectOption(label=f"Team {i}", value=str(i), description=f"Your preferred team is {i}"))
super().__init__(
placeholder="Choose your preferred team",
min_values=1,
max_values=1,
options=options,
)
async def callback(self, interaction: discord.Interaction):
update_set({'user': interaction.user.id}, {'preferred_team': self.values[0]})
value = self.values.pop()
embed = discord.Embed(title='Team Selection',
description=f'You set your preferred team to:\nTeam **{value.title()}**')
await self.confirm_interaction.edit_original_message(embed=embed, view=discord.ui.View())
because you set value when making the options
whys it crossed out
is it true or not
because im WRONG
oh
when i push button it edit message and takes second or two then says interaction failed and if they select option before that it sends error unknnown interaction
oh you should do interaction.response.edit_message instead
o
are you trying to remove the view?


