#Basic Pycord Help (Quick Questions Only)
1 messages · Page 19 of 1
yes
def setup(bot):
bot.add_cog(lg_class(bot)) #Me permet d'ajouter le bot dans les autres fichiers
Im not sure if you get something with "store=False" in the load_extension
what exactly is "store=False"?
the other prints were working so i don't think that's the issue, store=False is default on 2.1+ anyway
actually what version are you even on
have you tried reinstalling
can you upgrade to the master branch?
git+https://github.com/Pycord-Development/pycord when using pip
oh wtf
2.1.3 released but there wasn't an announcement
bruh
are you sure it's working?
Wait
i suggested master because that was the release candidate, but just install 2.1.3 instead
we got some problem with the code bc of the upgrade
we're doing it...
might take a moment
what error
smth on another place on the code
if len(label) > 100:
TypeError: object of type 'int' has no len()
just this
we're working on it
even with the upgrade
we do not have another bot
actually yeah try guild first
or another guild
just make one
but we can try
UnboundLocalError: local variable 'role' referenced before assignment
On the new guild
with this code:
for user in players_in_game:
print('qqqqqqq')
try:
role = await guild.create_role()
except Exception as e:
print(e)
else:
print(role)
finally:
print('YEAH')
roles.append(role)
print(await user.guild.create_role(name=f'LG - {user.name}'))
it seems to work on another guild
How can I add this to my bot
sounds like your entire guild is ratelimited from role creation
how can we check that?
?
ok, we're putting it in
WARNING:discord.http:We are being rate limited. Retrying in 84896.90 seconds. Handled under the bucket "None:923316085950918656:/guilds/{guild_id}/roles"
ok
LOL
rate limited for 24h
ok lets kill ourself
YEAH !
welp you just gotta create less roles
yeah
all good
anyone?
cant find anything on the bot's profile page
it's automatic for verified apps i think?
Oh is it a only verified app thing? sad
yeah
Is cogs possible?
yes
anyone help me thanks
what is the problem?
how to fix it i don't know anything about code
?tag op
No tag op found.
?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)
@silver moat can you help me thanks
no, learn python
I'm so busy I don't have time to learn to code :(
anyone know how to fix i will pay
uh guys
So acually I want it so that whenever the client uses and invalid url for the thumbnail
it returns it with a "Invalid url msg" with the rest of the embed
I used try...except block for this purpose but it doesn't seem to work..
@bot.slash_command(name="embed", description="Make embeds!",guild_ids=[949883077738496040, 831508434872565762])
async def em(ctx, title, description, image_url: Option(str, "Custom image for embed!", required = False, default = None)):
author = ctx.author.name
embed = discord.Embed(
title = title,
description= f"{description}",
color= random.choice(c_lists)
)
try:
embed.set_thumbnail(url=f"{image_url}")
except:
print("hmm")
pass
embed.set_footer(text=f"{author}",icon_url=f"{ctx.author.avatar.url}")
await ctx.respond(embed=embed)```
please review this code
i keep getting this error
Traceback (most recent call last):
File "C:\Users\casho\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 127, in wrapped
ret = await coro(arg) File "C:\Users\casho\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 908, in _invoke
await self.callback(ctx, **kwargs)
File "c:\Users\casho\OneDrive\Desktop\Chores\VS Code\programs\discordpy bot\raeger.py", line 420, in em
await ctx.respond(embed=embed)
File "C:\Users\casho\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\context.py", line 276, in respond
return await self.interaction.response.send_message(*args, **kwargs) # self.response
File "C:\Users\casho\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\interactions.py", line 727, in send_message
await self._locked_response(
File "C:\Users\casho\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\interactions.py", line 975, in _locked_response
await coro
File "C:\Users\casho\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\webhook\async_.py", line 213, in request
raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In data.embeds.0.thumbnail.url: Scheme "yo" is not supported. Scheme must be one of ('http', 'https').
Traceback (most recent call last):
File "C:\Users\casho\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 382, in _run_event
await coro(*args, **kwargs)
File "c:\Users\casho\OneDrive\Desktop\Chores\VS Code\programs\discordpy bot\raeger.py", line 128, in on_application_command_error
_command
await ctx.command.invoke(ctx)
File "C:\Users\casho\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 359, in invoke
await injected(ctx)```
How can I auto accept friend requests?
against discord ToS.
Oh I see
anyone?
For my bot? Not me? still against tos?
yup
bots cannot have friends
Ah ok. So if someone has friendsDM only, is it impossible for the bot to message them?
it’s not possible to add bots to group dm
not sure what you mean
It think he meant that if someone has "Friends only"
yes
that only friends can dm him/her
yeah there is no way around that
ahright ok
what is a sample of the url?
any http / https
add a debug print statement that prints the url
no like here is what i mean
generally you put title and description and an optional image
the image has to be an http/https one to be shown in the embed
but if some user mistakenly put any random thing like "image.txt" then it show reply them with "Invalid image url"
with then rest of the embed
ok so why doesn’t try except work
yea that's the issue
use the try except on the ctx.send
ok
I have another question as well, my bot downloads images users have posted temporarily. At the moment the only check is that it ends in a known image extension, e.g .png, .jpeg etc. I was wondering if this is actually safe? As I don't want to download some malware disguised as an image
you can put malware in images but they wouldn't run
I'd hope so
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In data.embeds.0.thumbnail.url: Scheme "yo" is not supported. Scheme must be one of ('http', 'https').```
getting this error
or you can simply store the cdn.discordapp.com url of the image
the one you see when you press "open original" right?
as this is the one I do download
yeah
yeah 👍
well, why not just store the url
I perform ocr on the image so I need to download it
ic
yeah bummer
what's ocr?
full traceback?
optical character recognition
also known as reading text from image
yeah
Ignoring exception in on_application_command_error
Traceback (most recent call last):
File "C:\Users\casho\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 127, in wrapped
ret = await coro(arg)
File "C:\Users\casho\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 908, in _invoke
await self.callback(ctx, **kwargs)
File "c:\Users\casho\OneDrive\Desktop\Chores\VS Code\programs\discordpy bot\raeger.py", line 420, in em
await ctx.respond(embed=embed)
File "C:\Users\casho\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\context.py", line 276, in respond
return await self.interaction.response.send_message(*args, **kwargs) # self.response
File "C:\Users\casho\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\interactions.py", line 727, in send_message
await self._locked_response(
File "C:\Users\casho\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\interactions.py", line 975, in _locked_response
await coro
File "C:\Users\casho\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\webhook\async_.py", line 213, in request
raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In data.embeds.0.thumbnail.url: Scheme "yo" is not supported. Scheme must be one of ('http', 'https').
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\casho\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 382, in _run_event
await coro(*args, **kwargs)
File "c:\Users\casho\OneDrive\Desktop\Chores\VS Code\programs\discordpy bot\raeger.py", line 128, in on_application_command_error
raise error
File "C:\Users\casho\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 997, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\casho\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 359, in invoke
await injected(ctx)
File "C:\Users\casho\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 135, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In data.embeds.0.thumbnail.url: Scheme "yo" is not supported. Scheme must be one of ('http', 'https').```
sounds cool
yeah it's neat, u can see my repo if you want (if im allowed to link it here)
nah I'm okay
savage
not a professional yk
you'll get there 🙂
are you putting
try:
await ctx.respond(embed=embed)
except:
pass
because it seems that the error is still raised on
line 420, in em
await ctx.respond(embed=embed)
no it is outside the block
try:
embed.set_thumbnail(url=f"{image_url}")
except:
await ctx.send("Invalid image url")
pass
embed.set_footer(text=f"{author}",icon_url=f"{ctx.author.avatar.url}")
await ctx.respond(embed=embed)```
yeah I meant for you to put the try on the respond
because that's where the error is raised
man your profile blinded me
you're welcome
because you probably don't have guild-members intent
after enabling it should i reinvite the bot
no
Does anyone know a way I can execute asynchronous code while the bot is still running, like as a command? (obv dev only) but python's eval() or exec() don't seem to work as they are non asynchronous
why did you need to subclass...
also it should be passed into the parent class
jishaku?
yea
oh really
it works
It was always compatible
so discordpy and pycord cogs are compatible or they just coded jishaku in the way for that?
I think it's the best news I've ever had that jishaku works with pycord 
This is the exact way I do it also
i think it's the only way
My timeout isn't working on my code
It i says View not callable
'Moderation Support Bot#7400 is online!
(Ignoring exception in on_message_delete
#Traceback (most recent call last):
\ File "/usr/local/lib/python3.10/site-packages/discord/client.py", line 382, in _run_event
await coro(*args, **kwargs)
N File "/home/user_750844707755786252/main.py", line 52, in on_message_delete
/ await delete_mod_channel.send(embed=embed)
T File "/usr/local/lib/python3.10/site-packages/discord/abc.py", line 1517, in send
* data = await state.http.send_message(
W File "/usr/local/lib/python3.10/site-packages/discord/http.py", line 359, in request
( raise HTTPException(response, data)
Udiscord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
3In embeds.0.fields.1.value: This field is required
JSON Derulo#0184 joined
%Ignoring exception in on_member_join
#Traceback (most recent call last):
\ File "/usr/local/lib/python3.10/site-packages/discord/client.py", line 382, in _run_event
await coro(*args, **kwargs)
L File "/home/user_750844707755786252/main.py", line 151, in on_member_join
U f"{staff_role.mention} Should I verify {member.mention}?", view=V(timeout=None))
)TypeError: 'View' object is not callable
just do V?
it looks like you already created/initialized the view
Hey all, I recently ditched heroku like i'm sure many other people have an switched to railway, and everything is running fine except one thing, autocomplete isn't working, I haven't touched the code at all and now it's not showing any values.
Any ideas what it could be
I see, i guess i'll just preload the value names on boot
hi, is there any way to parse like arguments while importing script or somehow determine from what script a certain file was loaded? i know this isnt exactly pycord question, if it is a problem, i can ask elsewhere
One message removed from a suspended account.
Guys does Jishaku work with Pycord
I can load it in fine via load_extension, but I can't seem to invoke any of their commands
update: fixed with pip install jishaku==2.3.2
Images are found via message.embeds or message.attachments depending on the situation, see https://docs.pycord.dev/en/master/api.html#message
kinda depends on what you're doing
if it's an entire module, e.g. import discord, you could get discord.__file__ for the path
for specific objects, e.g.ctx, you can do ctx.__module__ to return their import path (discord.ext.commands.ctx)
otherwise you might be interested in the inspect module https://docs.python.org/3/library/inspect.html
is there a way to turn an attachment to a file object?
i have a question
you can download the file
or if its an image you can read the bytes and write them to a file
i want to amke a code where when i press a button a diffrent piece of code will activate any idea if its possible
lmao i read it in the night like 5 times and skip that part

love you
One message removed from a suspended account.
yes
Learn all about implementing buttons in your Discord Bot using Pycord.
yes i know that
but like i want it to where a model will pop up after u press the button
you mean modal?
yes
Learn how you can implement Modals in your Discord Bot with Pycord!
grammar question, is it okay to write you needn't, that sounds so bad...
I divided my bot into multiple files (all of them for different commands, so i can easily setup bots for my friends adding only what they want) but i need one of those files to access something in the other, but not loading all the other code like commands, events, etc. The closes thing i found was to add if __name__ == "main":, this will prevent the part of the code to be run when the file is imported by another file. This is not a solution for me, because i need the file to be imported the main bot file. I hope you can understand what i mean 😄
like cogs?
are all these files separate cogs or
i have no idea what a cog is
bruh
How would I implement a user command check? A typical check involves passing the ctx, but can I also pass it the member?
ctx has the author attribute already
if you're splitting commands into different files, you should be using cogs and loading them with load_extension
https://guide.pycord.dev/popular-topics/cogs/
I'm trying to make a check so people can't use a particular user command on themselves. Does ctx.author return whoever invoked it, or who it's invoked on?
whoever invoked it
Right. I also need who it's invoked on.
Yup
oh, ok right now i am just importing the files into it
is there any problem with that?
perhaps you want ctx.selected_options
https://docs.pycord.dev/en/master/api.html#discord.ApplicationContext.selected_options
Google "pycord cog" 🤦🏼, who cares just do some reading
pls dont use youtube tutorials
it "works", but cogs are a far cleaner way of having a multi-file setup, and your use case of getting something from another file can be done easier that way using functions like get_cog
ok ill look into it and try to figure out how to recreate what i already have with them if its possible
alright
so if i get it right, i just put all the commands into a class then call it with an add cog function?
okay, that sounds nice
so if i dont use the load extension i guess i wont trigger the code when accessing something different in the same file
load_extension loads the Cog class and all commands under it to register them to the bot. If you want to access a function from another cog, you would do bot.get_cog(name) and access it through there
how do i get a user that just joined the server and create a dm with them??
okay, that seems exactly like the thing i need rn, thank you
use the on_member_join event https://docs.pycord.dev/en/master/api.html#discord.on_member_join
it takes a member as its sole argument, then you can use member.send
class menu(discord.ui.view):
def init(self):
super().init()
self.value = None
@bot.slash_command(description= "get authcode")
async def menu(ctx):
view = menu()
view.add_item(discord.ui.button(label="get authcode",style=discord.ButtonStyle.link, url="https://www.epicgames.com/id/api/redirect?clientId=3446cd72694c4a4485d81b77adbb2141&responseType=code"))
await ctx.reply("hello this is the menu", view=view)
it says somthing at most 2 argument and 3 is given
how to fix
didn't work mate
did you make it an event
name your class and command different things
still doesnt work
what was the full error?
Exception has occurred: TypeError
module() takes at most 2 arguments (3 given)
File "C:\Users\doree\Downloads\Workspace\beatabot.py", line 12, in <module>
class menu(discord.ui.view)
use uppercase View
can you copy paste the full error
that is the full erroe
oh wait hold
on
now its saying that bot isnt defined
any idea how to fix heres full code
yes
can you show how you implemented it
sure
@client.event
async def on_member_join(member):
member.send("test")
am new to this so idk if this is wrong
you have to await send functions, so it would be await member.send
and dont forget to enable intents
true
Still doesnt work @cyan quail
do you have the members intent enabled
I do not think so how do i do it?
?tag 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)
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
thx
basically you want intents = discord.Intents.default(), then set intents.members = True and finally pass intents=intents into your bot object
How do i use a float for a argument in a slashcommand
use type float
how do you normally do types
like that....
for slash command options
fair enough, you just typehint the variable like name: type
Thanks
that is basic python...

wait i tried this
right
For some reason it is not popping up the right status and I am not sure why.
If anyone knows and could tell me why that would be great.
you probably don't have presence intent enabled
I do.
That is the thing.
:class:`Status`: The member's status on the desktop client, if applicable.```
its for me, ignore ^
did you enable it both in code AND ddevs? just to be sure...
Why am I keep getting this error?
@bot.event
async def on_message(message):
try:
guildProfile = guildCollection.find_one({"_id":message.guild.id})
profile = collection.find_one({"_id":"settings"})
if guildProfile is None:
newguild = {"_id":message.guild.id, "gtn_channel":"", "gtn_number":"", "gtn_guesses":0, "gtn_range":0, "advertising_channel":"", "messages_total":0}
guildCollection.insert_one(newguild)
guild_total_messages = guildProfile["messages_total"] + 1
guildCollection.update_one({"_id":message.guild.id}, {"$set": {"messages_total":guild_total_messages}})
if "gtn_channel" in guildProfile:
if guildProfile["gtn_channel"] != "":
if message.channel.id != guildProfile["gtn_channel"]:
return
else:
try:
if int(message.content) == guildProfile["gtn_number"]:
guesses = guildProfile["gtn_guesses"] + 1
guildCollection.update_one({"_id":message.guild.id}, {"$set": {"gtn_guesses":guesses}})
embed = discord.Embed(title=f":tada: Congratulations {message.author.name}!", description=f"The number you guessed was right! The game has ended and the channel has been locked, thanks for playing!", color=0x2f3136)
//embed send etc. here
else:
guesses = guildProfile["gtn_guesses"] + 1
guildCollection.update_one({"_id":message.guild.id}, {"$set": {"gtn_guesses":guesses}})
except Exception as e:
if message.author.bot:
return
else:
await message.delete()
except Exception as e:
await notusLog("Automated Error/bug report.", f'{e} - Ignore the error.')
Yes.
Need a full traceback.
uh thats the whole error
pretty sure it's a discord bug
yea
member statuses recieved over interactions are always offline for some reason
😮💨
discord
maybe try getting the member object again with ctx.guild.get_member
and the command
I'm asking for the traceback
they're try-excepting so they don't have a traceback 
yea
anyway we can't really help you properly without it lol
you can only guess what the issue is
so message.guild is none
yea but why
guild isn't cached or the message is in dms 
well it literally isn't in the bot's cache
and how can I fix this
what intents did you set
all of them
does it break in other guilds?
it gets spammed in the log
I had it before and it didnt send an error
but now it does
They should really fix that.
Especially when they’re trying to get all developers to switch to slash command.
Is there anything I can do?
I mean it works but I still get the error
thats the weird thing
it still works?
yea ig so, everything works fine
like, the rest of the code after that line runs?
yea
uhhhhhhh
Also I tryed my prefix one of that and it worked but with slash it does not.
are you sure the error message itself isn't bugged
you can fix it in slash by getting the member from ctx.guild.get_member instead of using ctx.author
would that even be possible?
So just put that in the spot.
Maybe just because the document wasnt created for some guilds
nope
still getting it as soon as I run the command..
everything works fine tho
So I would just put that where it says ctx.author?
im guessing you have process_commands there at the end?
yeah
Were at the end
of the message event
no
oh wait i see it isn't a message command
@bot.event
async def on_message(message):
try:
guildProfile = guildCollection.find_one({"_id":message.guild.id})
if guildProfile is None:
newguild = {"_id":message.guild.id, "gtn_channel":"", "gtn_number":"", "gtn_guesses":0, "gtn_range":0, "advertising_channel":"", "ticket_category":"", "autorole":"", "joindm":"", "joinping":"", "giveaway_manager":"", "ticket_manager":"", "event_manager":"", "music_manager":"", "messages_total":0}
guildCollection.insert_one(newguild)
guild_total_messages = guildProfile["messages_total"] + 1
guildCollection.update_one({"_id":message.guild.id}, {"$set": {"messages_total":guild_total_messages}})
if "gtn_channel" in guildProfile:
if guildProfile["gtn_channel"] != "":
if message.channel.id != guildProfile["gtn_channel"]:
return
else:
try:
if int(message.content) == guildProfile["gtn_number"]:
guesses = guildProfile["gtn_guesses"] + 1
guildCollection.update_one({"_id":message.guild.id}, {"$set": {"gtn_guesses":guesses}})
elif int(message.content) > guildProfile["gtn_range"]:
if message.author.bot:
return
else:
await message.delete()
else:
guesses = guildProfile["gtn_guesses"] + 1
guildCollection.update_one({"_id":message.guild.id}, {"$set": {"gtn_guesses":guesses}})
except Exception as e:
if message.author.bot:
return
else:
await message.delete()
except Exception as e:
await notusLog("Automated Error/bug report.", f'{e} - Ignore the error.')```
thats the whole thing excluding the embed and some collection updates
idk you should probably try to make the error more descriptive/format it with traceback instead of just letting it be a single line
how can I do that?
perhaps include e.__traceback__ in the message
Nope did not work.
alr
can you show what you tried
nono
it's get_member(id)
https://docs.pycord.dev/en/master/api.html#discord.Guild.get_member
So I would have to add the (id ) to that?
id being the id of the member
Oh because that is what member thing reads?
mhm
doesnt work
if it still works
is there a way to just ignore the error?
Nope did not work.
well just don't send the embed
pass
what did you try this time
What you told me.
yeah but show
ah oh well, i usually try to be indirect but it's ctx.guild.get_member(ctx.author.id)
probably the easiest way to get around the bug
This Is what the code looks like full.
and member is optional?
Just did that and it still prints offline.
hmmm it should be working fine since the cache has the correct status
class gtnInviteVoteButtons(discord.ui.View):
def __init__(self):
super().__init__(timeout=None)
@discord.ui.button(label="Invite", custom_id="gtnInviteBtn", style=discord.ButtonStyle.link, url="https://discord.com/api/oauth2/authorize?client_id=850494888155938826&permissions=1644971818199&scope=applications.commands%20bot")
async def button_callback(self, button, interaction):
pass
@discord.ui.button(label="Vote", custom_id="gtnVoteTopggBtn", style=discord.ButtonStyle.link, url="https://top.gg/bot/850494888155938826/vote")
async def button_callback(self, button, interaction):
pass
why does it not work
Could you run pip freeze in your terminal and send the output?
you can't make url buttons with decorator because they don't have callbacks
you should create them inside the init with discord.ui.Button and then use self.add_item
I did it like the pycord guide said
the guide does include decorator buttons, but not for urls
How can I create a check on an interaction (buttons) to be only me allowed to press the buttons?
check if the interaction user its you
if its not then return an error...
you can check it by ur id..
np
^^
and how can I create pre defined options to specific argument?
Option(str, choices=[])
let me find it in the guide
do you know how to fix whitespaces?
rip it’s not in the guide
remove the whitespace between i and :
@fiery tiger try removing the spaces between the semicolon
black format won't let me do that...
How can I use this?
In a slash command?
y
name: Option(str, choices=[])
understood
It’s in async def
I feel like that should be in the guide
time to make a pr
Oh wait nvm you mean options in general
how can i use usual emojis like 🔒 in buttons?
how do I find them?
uh, you need to do it in discord, or copy them from some website
or just use window's builtin tool
then you specify them as a string
emoji='emoji'
😔
😭
Copy and paste every emoji with 👍 no apps required. 😊🥺😉😍😘😚😜😂😝😳😁😣😢😭😰🥰
copy from here and paste
I tried that lmao
this SHOULD work
im not stupid... 😦
unless specific emoji is not represented in Twemoji

👍🏻
How do I get a modal through button press
@rare ice do I put that instead of the button response?
i just started learning pymongo
cool
My command says I successfully updated the values in my database
But somehow when I try to get the data, there is no data
Could you send your current code?
And any errors you got, if any.
Is it possible to add objects to a document? (pymongo)
e.g.
links: {
"youtube":"https://yt.com"
"my discord":"https://dsc.gg/mydiscord"
"my twitter":"https://t.co/mytwitter"
}
opened a new post #1017595772176453682
Read the docs for pymongo: https://pymongo.readthedocs.io/en/stable/
I have the following cooldown on my command, but it's not applying. Is it because I'm an admin in the server, or am I missing something?
@commands.cooldown(1, 60, type=commands.BucketType.user)
@user_command(name=":punch: Mug")
async def mug(self, ctx: discord.ApplicationContext, member: discord.Member):
...
why is one of my slashcommands just not showing up
You need to put the cooldown decorator inside the user command decorator
?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.
⚠ Warned Hiddenvelix#9007
Okay, you won’t be receiving help then.
Oh wow yeah, didn't know the order mattered. thanks
i need help on my railway, how do i install modules there
what's your requirements.txt and errors
ohhh i need a requirments file
f"{ctx.command.get_cooldown_retry_after}s remaining" sends <bound method ApplicationCommand.get_cooldown_retry_after of <discord.commands.UserCommand name=:punch: Mug>>s remaining
@silver moat i added the requrement file i ahve the error Error: Docker build failed
General Question: If i hade a base price lets say 1 UDT is 5$ how could i calculate how much in USD the user has off of the base price like if i hade 0.5 bitcoin or 0.1 bitcoin and i wanted to get the price of the 0.1 bitcoin using what 1 bitcoin would be i know its some complex math im not sure how i would go about it
unit conversion?
e.g. 0.1 bitcoin = x/10 usd. 1 bitcoin = x usd
you only need the basic math
under settings, put a start command
wdym, can u explain
ah wait i see it now
what do i put in it
def convert(rate, amount_of_btc):
#assuming rate is what 1 BTC is in USD
return amount_of_btc*rate #usd
python main.py or whatever your file is called
third grade math really is complex
if i private my repo
can railway still see it
i dontwant poeple havign my bot otken
railway will see it regardless
but use environment variables for your bot token
ah okay
also regen your token
i did
because your token was leaked lol
good
bot/main.py lines 834 to 835
bot.run(
os.environ.get("BOTTOKEN"),```
import os
i ahve os imported
well "token" in your case
yes ik
missing a closing parentheses
what's your requirements.txt?
it should be py-cord
i followede verything but i only got 1 line
i updated the file, it should now
i think
@silver moat still no work :(
huh. Same error?
wait i think i missed one
@silver moat
def _convert(rate, amount_of_btc):
# assuming rate is what 1 BTC is in USD
return rate/amount_of_btc*rate #usd
conversion = _convert(PriceOrRate, token_count)
return conversion
_convert(0.06147591247046411, 1) <- 0.06 is the price for 1 trx (tron) coin, and the 1 stands for the amount, so why is it returning 0.003779287814076165
yep still nothing
@fervent cradle code was wrong. updated
these are the only imports i got before
thanks man
share github repo?
there might be something that I am overlooking
thanks squid
np
Change requirements.txt to just
py-cord==2.0.0rc1
only htat?
yes
OGM ITS WOKRING @silver moat
let me tets the commands
THANKKK YOU BROOO @silver moat
you're welcome
anyone got ideas on how to keep state between a select -> modal -> database?
person selects an item from a select list, select list opens a modal, with the title being the item they selected, but how to get the item to the database with the textinput from the modal at the same time is escaping me
doesn't the modal have a value you can access to see what the value of the inputtext is?
i'm trying to get the value from the select
to add into the database object
I mean I can either add a check for extra_kwargs in the modal object, or set a disabled(hopefully) inputtext
you can't disable an InputText
then check for kwargs it is
possibly, copilot says to do
extra_kwargs = kwargs.pop("extra_kwargs", {})
Do you need an indent to check if the bot got mentioned?
what do you mean by that?
on bot @mention
like the bot user is mentioned
I meant the indent
I asked if there is an indent required to get the info (if bot gets mentioned)
because I'm trying to make an indent-less bot
what is an indent in this context?
Do you mean intent?
that would make a lot more sense
Are ephemeral messages available outside interactions or webhooks?
yes, but only for Clyde and AutoMod
oh sorry. yes
Hi, I'm trying to create a 5x5 array of buttons, controlled by a view - but for some reason, the buttons aren't changing colour (I want them to toggle between green/red).
then yes
you need to edit the message with the updated view (self)
so interaction.response.edit_message(view=self)?
yes
Got it, thanks!
yw
just why download the image, thats bad practice, just fetch the image url, convert it into buffer by BytesIO, and then OCR, many ocr engines support numpy array or base64 encoded image as input, you can just convert the bytes buffer to numpy array or base64 encoded image
Couldn't quite figure out the conversion into buffer by bytes io. Could you give an example?
Hi is there an event such as on_server_boost?
I looked through the docs but I couldn't find anything
No
i've got this error
AttributeError: partially initialized module 'tolkit.ui' has no attribute 'Verify' (most likely due to a circular import)
how can i fix it?
is there a way to specify user avatar size?
like in dpy user.avatar_url_as(size= 128)
py-cord is a fork from dpy, so yes but got a changed
so how sould I write it?
.
click the link?
did
but understood half of the total thing
I am kinda stupid..So uh please help
oh nvm I almost did the correct thing lmao
hi i am making buttons using subclassed way. For url buttons, do i need to add a callback??
bot.wait_for
because its in a decorator
and when i try at add it in init, an error appears that got an unexpected kwarg: label
is there something still broken in 2.1.3?
that's probably just your IDE acting up, it'll work fine
oh right, there’s a 2.1.3
if the issue was slash groups then yeah it'll have been fixed
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: __init__() got an unexpected keyword argument 'label'
can you paste the full code and traceback
you can definitely call discord.ui.Button with label
error:
Ignoring exception in command helpme:
Traceback (most recent call last):
File "", line 127, in wrapped
ret = await coro(arg)
File "", line 904, in _invoke
await self.callback(self.cog, ctx, **kwargs)
File "", line 36, in helpme
await ctx.respond(embed=embed, view=HelpButtons(self.bot))
File "", line 43, in __init__
self.add_item(Button(label='Invite Me', style=discord.ButtonStyle.url,
TypeError: __init__() got an unexpected keyword argument 'label'
the way is correct of adding url buttons?
yeah... that error's weird because it should be referencing Button.__init__() and not just __init__()
what version?
can you try upgrading to 2.1.3
yeah it's a release version
do you by any chance have a class or function called Button
in the cog, just 2 classes, Help and HelpButtons
rpsg = discord.SlashCommandGroup("rps", "Commands related to Rock-Paper-Scissors!")
@rpsg.command(name="play", description="Play Rock-Paper-Scissors!!",guild_ids=[949883077738496040, 831508434872565762, 970977973039685673])```
What am I doing wrong here
The command doesn't show up on discord
the only way for this error to be possible is if you've overridden the Button class in your code somewhere
upgrade to 2.1.3
ok
nah, i dont see any conflict in file
- if you remove those 3 lines in init , it works fine
right there
ok
well ButtonStyle is fine, but not Button
...i guess it's misleading but all examples and guides do use discord.ui
lol there is again a pblm
if i remove first one, same error
if i remove second one, some other error
it still doesn't appear on discord
Can you show the full code
bot.add_application_command(rpsg)
You don't need it usually
rpsg = discord.SlashCommandGroup("rps", "Commands related to Rock-Paper-Scissors!")
@rpsg.command(name="play", description="Play Rock-Paper-Scissors!!",guild_ids=[949883077738496040, 831508434872565762, 970977973039685673])
async def play(ctx, text):
await ctx.respond("something")```
yeah but you do if you create group this way instead of bot.create_group
pass guild_ids in SlashCommandGroup
It works fine without in cogs, not sure elsewhere
is bot.create_group better than this?
^^
better way*
Go for it
k
rpsg = bot.create_group("rps", "Commands related to Rock-Paper-Scissors!")
@rpsg.command(name="play", description="Play Rock-Paper-Scissors!!",guild_ids=[949883077738496040, 831508434872565762, 970977973039685673])
async def play(ctx, text):
await ctx.respond("something")```
now okay?
i've got this error
AttributeError: partially initialized module 'tolkit.ui' has no attribute 'Verify' (most likely due to a circular import)
how can i fix it?
oof
Yes
so basically when i keep the discord.ui.Button, same error @cyan quail
You're importing a file that also imports the original file
Show full error
Ignoring exception in command helpme:
Traceback (most recent call last):
File "C:\Users\Rajesh Gulati\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\commands\core.py", line 127, in wrapped
ret = await coro(arg)
File "C:\Users\Rajesh Gulati\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\commands\core.py", line 907, in _invoke
await self.callback(self.cog, ctx, **kwargs)
File "C:\Users\Rajesh Gulati\PycharmProjects\Discord\cogs\help_command.py", line 36, in helpme
await ctx.respond(embed=embed, view=HelpButtons(self.bot))
File "C:\Users\Rajesh Gulati\PycharmProjects\Discord\cogs\help_command.py", line 43, in __init__
self.add_item(Button(label='Invite Me', style=discord.ButtonStyle.url,
File "C:\Users\Rajesh Gulati\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ui\view.py", line 283, in add_item
if len(self.children) > 25:
AttributeError: 'HelpButtons' object has no attribute 'children'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Rajesh Gulati\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\bot.py", line 1009, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\Rajesh Gulati\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\commands\core.py", line 359, in invoke
await injected(ctx)
File "C:\Users\Rajesh Gulati\AppData\Local\Programs\Python\Python39\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: 'HelpButtons' object has no attribute 'children'
now try my way
ok
you didn't update to 2.1.3
you didn't because that exact error was fixed in 2.1.3
pycharm?
how would I prevent users from using a slash command while the same slash command is still "thinking"?
do cooldowns register from start of use?
you have to super().__init__() at the top of your view init
cooldown or max concurrency decorator should work
@cyan quail ohk thankx, i removed the super class call b4 for some trial error testing, now its working
?
yet another error after solving this
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In components.1.components.0.custom_id: A custom id is required
In components.1.components.1.custom_id: A custom id is required
In components.1.components.2.custom_id: A custom id is required
in docs its written, custom_id is optional + my buttons are not persistent and i didnt specify any timout which defaults 180 ig
can you show some?
looks like you still have to add some custom ids
rpsg = bot.create_group("rps", "Commands related to Rock-Paper-Scissors!")
@rpsg.command(name="play", description="Play Rock-Paper-Scissors!!",guild_ids=[949883077738496040, 831508434872565762, 970977973039685673])
async def play(ctx, text):
await ctx.respond("something")```
this still doesn't work
Saying it doesn't work or asking what's wrong with this code? is not helpful for yourself or others.
Describe what you expect and/or tried (with your code), and what isn't going right.
Please provide any errors you get for optimal assistance.
ok
So the thing is- I created a group "rpsg" to make all the commands related to rock-paper-scissors under one group
when i try the play command it shows up in the menu as expected
but it never responds and I get a error
What error?
The one is discord that says. Application did not respond?
Can you send the last few lines. Of the error I'm on mobile and cannot see files
Tried various ways but no difference 😦
Could you try uninstalling and reinstalling. If that does not work I think you are installing it in the wrong place
I gtg someone else will help in a bit
k
still getting the same error over and over again
I uninstalled and reinstalled but no good
.
and now the commands which wer working before don't work aswell
f"{ctx.command.get_cooldown_retry_after}s remaining" sends <bound method ApplicationCommand.get_cooldown_retry_after of <discord.commands.UserCommand name=:punch: Mug>>s remaining
Any ideas?
hello
i am having problems using variables in other class when trying to create buttons and modals
Uh why are the commands taking longer than usual to execute?
Looks like it is a function
`import discord
import json
from discord import app_commands
from discord.ext import commands
import base64
class Blacklist(commands.Cog):
def __init__(self, bot):
self.bot = bot
@app_commands.command()
async def test(self, interaction : discord.Interaction):
await interaction.response.send_message("test")
async def setup(bot):
await bot.add_cog(Blacklist(bot))`
The app_command isn't showing, anyone knows why?
Instead of app_command, use
@discord.slash_command
Pycord doesn't have an app_command namespace
Traceback (most recent call last):
File "c:\Users\Anwender\Desktop\workspace python-kurs\bots\Buisness\babycode5K\src\cogs\blacklist.py", line 8, in <module>
class Blacklist(commands.Cog):
File "c:\Users\Anwender\Desktop\workspace python-kurs\bots\Buisness\babycode5K\src\cogs\blacklist.py", line 13, in Blacklist
@discord.slash_command()
AttributeError: module 'discord' has no attribute 'slash_command'
Send tej contents of pip list @fossil canopy
cachetools 5.2.0
certifi 2021.10.8
cffi 1.15.0
chardet 4.0.0
charset-normalizer 2.1.1
click 8.0.3
colorama 0.4.4
commonmark 0.9.1
comtypes 1.1.11
cryptography 36.0.2
customtkinter 4.5.4
cycler 0.11.0
darkdetect 0.6.0
DateTime 4.3
discord 2.0.0
discord-components 2.1.2
discord-ext-ipc 2.1.1
discord.py 2.0.1
discord-py-interactions 4.3.1
discord-py-slash-command 4.2.1
discord-ui 5.1.6
discord-webhook 0.16.3
DiscordUtils 1.3.4
distlib 0.3.4
Eel 0.12.4
fastenum 1.0.4
filelock 3.6.0
Flask 2.0.2
Flask-Cors 3.0.10
Flask-JSGlue 0.3.1
flatbuffers 1.12
fonttools 4.33.3
frozenlist 1.3.1
future 0.18.2
gast 0.4.0
germanetpy 0.2.2
gevent 21.8.0
gevent-websocket 0.10.1
google-auth 2.8.0
google-auth-oauthlib 0.4.6
google-pasta 0.2.0
greenlet 1.1.2
grpcio 1.47.0
h11 0.13.0
h2 4.1.0
h5py 3.7.0
holidaycal 0.0.1
hpack 4.0.0
html2image 2.0.1
htmlwebshot 0.1.2
hypercorn 0.13.2
hyperframe 6.0.1
idna 3.3
importlib-metadata 4.11.4
iniconfig 1.1.1
itsdangerous 2.0.1
jarowinkler 1.0.2
Jinja2 3.0.3
joblib 1.1.0
Js2Py 0.71
keras 2.9.0
Keras-Preprocessing 1.1.2
keyboard 0.13.5
kiwisolver 1.4.2
libclang 14.0.1
lxml 4.9.1
Markdown 3.3.7
MarkupSafe 2.1.1
matplotlib 3.5.2
mcpi 1.2.1
mindstorms 0.1.2
MouseInfo 0.1.3
multidict 6.0.2
mutagen 1.45.1
mysql-connector-python 8.0.29
nltk 3.7
numpy 1.22.1
oauthlib 3.2.0
opencv-python 4.5.5.64
opt-einsum 3.3.0
outcome 1.2.0
packaging 21.3
pandas 1.4.0
paramiko 2.10.3
peewee 3.15.1
pefile 2021.9.3
Pillow 9.0.1
pip 22.2.2
platformdirs 2.5.1
playsound 1.3.0
pluggy 1.0.0
priority 2.0.0
profanity-check 1.0.3
protobuf 3.19.4
py 1.11.0
py-cord 2.0.0b5
pyasn1 0.4.8
pyasn1-modules 0.2.8
PyAutoGUI 0.9.53
pybricks 3.1.0
pycodestyle 2.8.0
pycparser 2.21
pycryptodomex 3.14.1
pyee 8.2.2
pygame 2.1.0
PyGetWindow
?tag install
- 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 !git to find out how to install git.
Updating the module to Alpha (unstable):
pip install -U git+https://github.com/Pycord-Development/pycord
You need a clean install, see above
Uninstall all packages starting with discord, if dont want to, make a venv
i’m currently getting this error:
TypeError: TypedDict does not support instance and class checks
I found this report but i’m not sure how i fix the error: https://bugs.python.org/issue44919
How can I get this?
Can someone tell me if I'm just making shit up, or if this should work?
I have a discord.ui.Select, with a secondary parameter, that adds it to the self.
self.message
when in the callback, this self.message is always NONE, eventhough I know it's set correctly prior to the callback 🤔
Isn't that how it's supposed to work? That you can set custom properties?
If you have a verified bot with slash commands, Discord does it automatically for you
Has to be verified, gotcha
One message removed from a suspended account.
there should be an after parameter in history
this is going to get every user with a 0 in their id, I doubt this is what you want
if "0" in str(message.author.id):
One message removed from a suspended account.
One message removed from a suspended account.
.
There's indeed an after kwarg
do tasks not fire once at init then repeat at specified duration? or does it only fire for the first after the specified duration?
import random
import discord
from discord.ext import commands, tasks
from goonbot import GoonBot
LISTENING_TO = [
...
]
PLAYING = [
...
]
WATCHING = [
...
]
class Activities(commands.Cog, name="Activities"):
def __init__(self, bot: GoonBot):
self.bot = bot
self.set_activity.start()
def cog_unload(self):
self.set_activity.cancel()
@tasks.loop(minutes=15)
async def set_activity(self):
self.bot.activity = random.choice(
[
discord.Activity(type=discord.ActivityType.playing, name=random.choice(PLAYING)),
discord.Activity(type=discord.ActivityType.listening, name=random.choice(LISTENING_TO)),
discord.Activity(type=discord.ActivityType.watching, name=random.choice(WATCHING)),
]
)
@set_activity.before_loop
async def before_set_activity(self):
await self.bot.wait_until_ready()
def setup(bot):
bot.add_cog(Activities(bot))
You have to start it
I did, i start it in the init. What's weird is a print line works, but it won't set the activity?
I even tried moving the activity logic into the init, and that worked just fine. Just not as a task
Question is there slash command alias,
nope
thats depressing
did you mean discord.ext.commands.BucketType
you don't set activities like that, you use change_presence
https://docs.pycord.dev/en/master/api.html#discord.Bot.change_presence
TYSM
Is there a limit of auto complete options you can have? If so, what’s the limit?
your memory
and also that 3 second to respond limit
Wdym memory
discord only displays the first 25 of them.
and you process the selection
Ah
hey
I want to send a image
as a response
await ctx.respond(file= discord.File("profile.jpg"))
is something wrong?
i can't seem to get the right keywords on google for this so --
is there a common/good way to do typehints for classes that are defined after that particular function/method in the code? e.g. if i did
class A:
def foo(self, b:B):
...
class B:
...
then pylint complains that B is not defined in the typehint.
for this example i know i could move the code of B to come before that of A, but in a case where there are circular dependencies that wouldn't work
yes
example?
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - pycord/slash_groups.py at master · Pycord-Development/pycord
send the error log
Hello! I have a subclass View with 3 buttons and a custom method to handle clicks. When the third button is clicked, I want to disable it. How should I approach this problem? 
Done! I couldn't find it before asking but now I managed to. Your guide and docs are amazing. 
ty guys
oh nvm that it is fixed
can someone help me?
AttributeError: 'User' object has no attribute 'username'
Code:
@bot.event
async def on_user_update(before, after):
guild = bot.get_guild(1014092119746543727)
role = guild.get_role(1015255000391356416)
#channelx = bot.get_channel(logschannel)
if name6_keyword in str(after.username) and not role in before.roles:
try: await after.add_roles(role)
except: print(f'Try to give {after.username} role, but fail')
#embedVar = discord.Embed(title="Status Added", description=f'{after.username} added the status and got the role `{role}`', color=0x00ff00)
#await channelx.send(embed=embedVar)
elif name6_keyword not in str(after.username) and role in before.roles:
try: await after.remove_roles(role)
except: print(f'Try to give {after.username} role, but fail')
#embedVar2 = discord.Embed(title="Status Removed or Offline", description=f'`{role}` revoked from {after.username}', color=0xFF0000)
#await channelx.send(embed=embedVar2)
Hello there!
I have a question regarding docs:
colors = ["yellow", "red"]
async def get_colors(ctx: discord.AutocompleteContext):
return [color for color in colors if color.startswith(ctx.value.lower())]
@bot.slash_command(name="ac_example")
@option("color", description="Pick a color!", autocomplete=get_colors)
async def autocomplete_example(ctx: discord.ApplicationContext, color: str,):
await ctx.respond(f"hi{color}")```
so according to the docs to create auto complete option we first create the list
but if I put the list directly into the "autocomplete" argument the options never appear
I have to create a whole function like:
async def get_colors(ctx: discord.AutocompleteContext):
return [color for color in colors if color.startswith(ctx.value.lower())]```
For the options to apppear and I am not able to figure out why
any help would be appreciated
for el in role_list:
salon_vocal.set_permissions(el, view_channel=True,
connect = True,
speak = False)
does someone have an idea on why it dont set the permissions?
Go see the real permissions before
Think I found a fix.
Hello, good afternoon.
Been trying to get back into a bot i was making for my clan/community. To deal with recruits and have a voting system. A lot of was already working, but i was updating to newer versions and had to re-do some stuff. Then i noticed there were modals in this newer version, sweet! Been working with a test slash command to get it working, which went alright. Took 2 days to get it down but that test command is working.
But now i'm facing a challenge i can't get my head arround. I have a on_raw_reaction_add that takes payload and nothing else, but i've been working with ctx.interaction.resonse.send_modal for the other modal(s). How do i go about this?
How do you go about what? Sending a modal without a slash command?
Uh, i thought that was possible? That you could put a modal up when someone reacts with an emjoi? 🤭
So modals are limited to the slash commands?
Or rather interactions?
What do you mean? Instead of having reactions underneath my "poll", add buttons for the votes?
Ah found an example
https://github.com/Pycord-Development/pycord/blob/master/examples/modal_dialogs.py
At the bottom 😉 #63. Will have a look at that (assuming that was your suggesion)
Can you send a message after interaction response has been deferred?
await interaction.response.defer()
then
await interaction.response.send_message(...)
No, I believe you have to use interaction.followup.send
ah, thanks
I'm getting this exception when creating a select menu. It reads as follows
Traceback (most recent call last):
File "e:\Documents\GitHub\wooperbot\env\lib\site-packages\discord\client.py", line 382, in _run_event
await coro(*args, **kwargs)
File "E:\Documents\GitHub\wooperbot\classes\bot.py", line 209, in on_application_command_error
return await ctx.invoke(ctx.command, **options)
File "e:\Documents\GitHub\wooperbot\env\lib\site-packages\discord\commands\context.py", line 137, in invoke
return await command(self, *args, **kwargs)
File "e:\Documents\GitHub\wooperbot\env\lib\site-packages\discord\commands\core.py", line 237, in __call__
return await self.callback(self.cog, ctx, *args, **kwargs)
File "E:\Documents\GitHub\wooperbot\cogs\art.py", line 398, in _ocs
await ctx.respond(embed=embed, view=view)
File "e:\Documents\GitHub\wooperbot\env\lib\site-packages\discord\commands\context.py", line 278, in respond
return await self.followup.send(*args, **kwargs) # self.send_followup
File "e:\Documents\GitHub\wooperbot\env\lib\site-packages\discord\webhook\async_.py", line 1561, in send
data = await adapter.execute_webhook(
File "e:\Documents\GitHub\wooperbot\env\lib\site-packages\discord\webhook\async_.py", line 213, in request
raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In components.0.components.0.options.1.emoji.name: Invalid emoji
The emoji i'm using is 🐟
@rare ice
Can u tell me the await thing for sending a modal through button click agian
Don’t ping staff for help. You won’t be getting help from me.
Bro what
I did it to you so much times
Now u wanna warn me
Jeez someone’s on there man period
There is no prior context of me helping you. Don’t argue or you may be muted.
😹😹
I'm making a thread on this, if you have any idea please let me know #1018171235315761194
What's best practice?
I feel like online is a bool, you’re either on or you’re not. So default False seems logical.
IP and Port could theoretically be in a state of non-configuration, which None would be appropriate. OTOH, since port can’t logically be 0 for a configured state, there’s a valid argument for that being a default
how do I make slash command callable only if the user has an especific role?
admins can change the permissions in the integration tab
users0.pop(users0.index(bot.user))
AttributeError: 'coroutine' object has no attribute 'pop'```
I am trying to get the users ho reacted on a particular message
new_msg = await ctx.channel.fetch_message(message.id)
users0 = new_msg.reactions[0].users().flatten()
users0.pop(users0.index(bot.user))
print(users0)```
but I keep getting the Attribute error
so I should await in the second line?
yes
thanks it works
which is the decorator for creating a slash group in a Cog?
i've looked under ext.commands but that only exposes slash_command or non-slash group
@discord.slash_command()
you don't use decorators for slash groups; in a cog, you can simply do group = discord.SlashCommandGroup(...)
this is inside the class but outside the init, which is in-line with where commands would go
oh I read it wrong :/
ok so let me get this into an example, see if i understood
class MyCog(commands.Cog):
group = discord.SlashCommandGroup()
@group.slash_command()
async def a_command(self, ctx ...):
pass
@group.slash_command()
async def another_command(self, ctx ...):
pass
Here's the slash cog groups example.
just for ref
oh also group requires the first argument py discord.SlashCommandGroup("group_name")
...odd
i thought we made description optional
thanks both!
PS: it's group.command()
fair enough
ignore me it is optional, forgot my version is outdated
didn't update from rc1 because literally every newer version had somewhat significant bugs but 2.1.3 should be pretty stable...
i've been getting the same error for days when a user interacts with a button. i've uninstalled py-cord and reinstalled it and removed any of the discord packages:
TypeError: TypedDict does not support instance and class checks
send full trace back?
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/client.py", line 382, in _run_event
await coro(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/bot.py", line 1058, in on_interaction
await self.process_application_commands(interaction)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/bot.py", line 722, in process_application_commands
) and isinstance(interaction.data, interactions.ComponentInteractionData):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/typing.py", line 2385, in __subclasscheck__
raise TypeError('TypedDict does not support instance and class checks')
TypeError: TypedDict does not support instance and class checks```
how do I remove all reactions from a message?
anyone? ive seen someone with a similar error and how they have resolved it but it didn't work for me
also how do I make a perm only command?
update to 2.1.3
i tried but i get ERROR: Package 'py-cord' requires a different Python: 3.6.0 not in '>=3.8.0' , yet im using Python 3.10.6
Your PiP command is on the wrong version then
Are you on windows?
no, Mac
Geh not sure how the versioning commands work on there
use pip3
Nah I mean version specific PiP, it's different on windows and mac/linux
oh
Just Google the command idk
how do i do that
it’s pip but you type pip3
there's no support or anything for Mac, it's been forgotten really
because mac has a built in python
It'll be the same as the Linux command probably
pip3 seemed to work
how do i refresh the list of available slash commands each time the bot restarts? it seems that an old command still shows up but isn't linked to any callback
if you try to use the command, it should fail
and then removed from your discord client's cache
how can i send message to channel by its name
examples?
channel = discord.utils.get(guild.channels, name='Foo')
await channel.send('Bar')
thx
Why pycord said in @bridge.bridge_command this to me?
Expected type '_SpecialForm', got 'str' instead
show code
@bridge.bridge_command(description="Suche nach Wetterdaten einer Stadt.", name="wetter")
full traceback?
it´s only in pycord but i don´t understand this
is there an error when you run it?
no
so ignore it. It's a typing issue
it´s only in the latest version of pycord
slash commands can't have *args right?
they can
Here's the slash options example.
oh, alright, thank you!
Hello! What could be the reason why my bot cannot be used in Threads on a server but works in another one? I didn't test more than two servers.
describe doesn't work
Maybe it's because of their permissions. I'll tell them to check if they have blocked other channels with the "new" feature for doing so. 
There is no bot user in that thread. When I start typing the commands, they don't appear at all.
sounds like a permission thing
I can't figure out why my button wont disable?
this is my code
@discord.ui.button(label="Transcript", custom_id="transcript_ticket", style=discord.ButtonStyle.danger, emoji="📜")
async def trans_button_callback(self, button, interaction):
channel = client.get_channel(transchanid)
try:
channel = client.get_channel(transchanid)
transcript = await chat_exporter.export(interaction.channel)
transcript_file = discord.File(io.BytesIO(transcript.encode()), filename=f"{interaction.channel.name}.html")
button.disabled = True
embed=discord.Embed(color=0xffff00)
embed.add_field(name="Transcript", value=f"Transcript for {interaction.channel.name} has been created!", inline=False)
embed.set_footer(text="Report bugs or suggestions with /bug or /suggest!")
await channel.send(file=transcript_file, embed=embed)
embed=discord.Embed(color=0xffff00)
embed.add_field(name="Transcript", value=f"Transcript for {interaction.channel.mention} has been created!", inline=False)
embed.set_footer(text="Report bugs or suggestions with /bug or /suggest!")
await interaction.response.send_message(embed=embed)
except:
await interaction.response.send_message("Please do a /bug report with the bug being, `Error Code: 30`")
you need to update the original message with the updated view:
await interaction.edit_original_message(view=self)
ahh thank you
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 185, in trans_button_callback
await interaction.response.send_message("Please do a /bug report with the bug being, `Error Code: 30`")
File "C:\Users\Ryanh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\interactions.py", line 727, in send_message
await self._locked_response(
File "C:\Users\Ryanh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\interactions.py", line 975, in _locked_response
await coro
File "C:\Users\Ryanh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\webhook\async_.py", line 211, in request
raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
it probably took more than 3 seconds for your bot to respond.
Moved it to the end
It sends the 2nd embed then updates it
?
"image not found"
I'm stupid. You should use interaction.response.edit_message
and then send the other messages by followup
it's taking longer than 3 seconds
is there a way to fix that?
oh ik
nvm
i gtg now but ill be back
using Paginator could I paginate modals? Or else, is there a workaround to have more than 5 elements into a modal?
Discord limitation.
So I have 2 buttons in a subclassed view and I keep getting an error of "This interaction has already been responded to" when I use it a second time but it haven’t deffered the response or anything.
@discord.ui.button(label="Index Page", style=discord.ButtonStyle.blurple, disabled=True)
async def index_page_callback(self, button, interaction):
for child in self.children:
if child.label == button.label:
child.style = discord.ButtonStyle.blurple
child.disabled = True
else:
child.style = discord.ButtonStyle.grey
child.disabled = False
main = # my embed stuff (retracted)
await interaction.response.edit_message(embed=main, view=self)
@discord.ui.button(label="Credits", style=discord.ButtonStyle.grey)
async def credits_callback(self, button, interaction):
for child in self.children:
if child.label == button.label:
child.style = discord.ButtonStyle.blurple
child.disabled = True
else:
child.style = discord.ButtonStyle.grey
child.disabled = False
credits = # embed stuff (retracted)
await interaction.response.edit_message(embed=credits, view=self)```
Can anyone help me with this error:
Ignoring exception in view <TicketClosedButtons timeout=None children=2> for item <Button style=<ButtonStyle.danger: 4> url=None disabled=False label='Transcript' 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 174, in trans_button_callback
await interaction.response.send_message(embed=embed)
File "C:\Users\Ryanh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\interactions.py", line 727, in send_message
await self._locked_response(
File "C:\Users\Ryanh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\interactions.py", line 975, in _locked_response
await coro
File "C:\Users\Ryanh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\webhook\async_.py", line 211, in request
raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
Code:
class TicketClosedButtons(discord.ui.View):
def __init__(self):
super().__init__(timeout=None)
@discord.ui.button(label="Delete", custom_id="delete_ticket", style=discord.ButtonStyle.danger, emoji="🔒")
async def delete_button_callback(self, button, interaction):
support = discord.utils.get(interaction.guild.roles, name="Staff")
channel = client.get_channel(transchanid)
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()
@discord.ui.button(label="Transcript", custom_id="transcript_ticket", style=discord.ButtonStyle.danger, emoji="📜")
async def trans_button_callback(self, button, interaction):
channel = client.get_channel(transchanid)
transcript = await chat_exporter.export(interaction.channel)
transcript_file = discord.File(io.BytesIO(transcript.encode()), filename=f"{interaction.channel.name}.html")
embed=discord.Embed(color=0xffff00)
embed.add_field(name="Transcript", value=f"Transcript for {interaction.channel.mention} has been created!", inline=False)
embed.set_footer(text="Report bugs or suggestions with /bug or /suggest!")
await channel.send(file=transcript_file, embed=embed)
await interaction.response.send_message(embed=embed)
#embed2=discord.Embed(color=0xffff00)
#embed2.add_field(name="Transcript Created", value=f"Transcript has been created!", inline=False)
#embed2.set_footer(text="Report bugs or suggestions with /bug or /suggest!")
#await interaction.response.send_message(embed=embed2)
button.disabled = True
await interaction.response.edit_message(view=self)
#except:
# await interaction.response.send_message("Please do a /bug report with the bug being, `Error Code: 30`")```
Happens when clicking the "transcript" button
You're probably taking too long to respond
Is there a way to solve that?
Like can I interaction.response.send_message at the start and solve it?
Or defer it?...
How would I do that?
await interaction.defer()
And then to respond await interaction.followup.send






