#Basic Pycord Help (Quick Questions Only)
1 messages · Page 24 of 1
you don't have members intent enabled
uhh because members are in guilds, without caching guilds, you don't get people.
Ic
when i guild chunk i recive an error with player_manager'
on_voice_state_update
disabling guild chunk is the way i fix it so far
or will it fix it self after on_ready
Along with this if it doesnt chunk on start
Can i grab the data at a later point?
fukin hell mate
chunk took me 12 mins
can i configure message_commands in a way that they appear in context menus of user only if a particular check has returned true?
it's the same
perhaps it doesn't work as author then
mhm
btw, consider using f string formatting as opposed to "str" + "str" + "str"....
nvm u already did
was looking at the first img
^^
hey quick question bot.latency returns me a scary long number, wonder how to format it properly so it'd show it as accurate ms value
you could do smth like f" Latency is {round((bot.latency)*1000, 2)} ms"
cuz 1000 ms is 1 sec
and bot.latency returns the latency in sec
oh cool, thanks a lot
why is bot.user being declared as NoneType
in my code
bot = commands.Bot(debug_guilds=[905460493597167697], intents=intents)
bot_user_id = bot.user.id
Exception has occurred: AttributeError 'NoneType' object has no attribute 'id'
- why would you ever do this
bot.userdoesn't exist because the bot hasn't started
oh
how can i get bot.user.id in cogs
i couldnt get it in cogs
are you sure the bot had already started at that point? on_ready must also be complete before trying it
No
bot.run was after that
anyways how do i get it in cogs
wdym "how", as long as the bot has started it will work
what are you even trying to do
trying to get bot.user.id
but in what context
why wouldn't you just do it after the bot's ready
if the function is async then you can use wait_until_ready to stall until then
https://docs.pycord.dev/en/master/api.html#discord.Client.wait_until_ready
oh
Multiply it to 1000, then round off to 2 decimal places
Nvm i saw old chats
^^
no, you can only use the discord-sided permissions for that
Oh ok, so i can create a in code block check
Lol same i did @rare ice
Discord shows old chats brrr
How to not 'respond' to a slash command or as in have it so it doesn't display e.g. Duck used /ban at the top? I don't want it waiting and then going, The application did not respond
you have to respond, but you can use ephemeral=True
I want it publicly viewable, I just don't want Duck used /<commandname> at the top and people being able to see the options you used.
Essentially just a ctx.send without it going The application did not respond.
Is there not a way to respond with nothing and shut it up from going The application did not respond?
you can delete the message 
or do an ephemeral response and a separate ctx.channel.send
Looks odd seeing a message appear and then remove and then another one being sent
I don’t want two msgs just 1
what you're asking for is impossible then
(maybe not literally impossible, someone's probably figured out some stupid hack like deferring a ping then pong the interaction response and then use a send or something, but the point is if you respond to a command it will always have the command run attached to it, if you want to remove it you have to send a separate message)
Hate that - alright thanks for your help
my @\tasks.loop functions are starting multiple times, I'm using
if not self.check_for_circular.is_running():
self.check_for_circular.start()
Where do I upload images to so I can use the URL?
imgur ?
and if I'd rather it not be easily accessible to the public? I don't care if it's a public link, but not on a site like Imgur if it makes sense
hm what I did is to dump the images on a GitHub repo and access it on their
or u could put the images on an CDN
Could anyone please explain me the difference between application commands and slash commands? I'm a bit lost on this.
they are the slash commands and user commands?
Oh I see, application commands are just the parent of slash commands then
each slash command is an application command
yeah I just found that resource too, unfortunately they don't go in dept about what application commands themselves are, but seeing them grouping slashcommands and others its clear to me that its just the grouping of all types of commands
I guess slash commands inherit from application commands?
Application commands include slash commands, user commands, and message commands. They're effectively ways to interact with bots that are built directly into discord, in contrast with prefixed commands which are just the bot scanning message content and then doing something. Slash commands are a type of application command, that can be triggered by typing a slash in chat and then selecting the corresponding command from the autocomplete that appears
Hey sounds good, thanks man!
#general message
.close()
thanks for sending me here so i can write my solution

very helpful
?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.")
ik im probaly gonna get flamed by someone saying simple python but can anyone help?
@bot.slash_command(description="nick")
async def nick(ctx, user: discord.Member):
if(message.author.id == "1007797339643195455"):
await ctx.respond("nick man is {user}")
else:
await ctx.respond("no perms :skull:")
error:
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: module 'email.message' has no attribute 'author'
if ctx.author.id ==
i put that
and i have the id
and when i still type i get the one thats supposed to pop up if your not me
bc the ID is int not string...
huh
if(message.author.id == "1007797339643195455"):
You're comparing an int against a string, ofc it won't work and choose the latter
im honestly confused by what your saying, sorry im not comprehending rn my brain is lowkey a bit slow
message.author.id returns an int
You are comparing an int to a string
Which wont work
i put ctx.author.id
how do i fix it then
Int == string ❎
Int == int / string == string ( dont do this one ) ✅
@wooden zenith pls learn python basics
please stfu
you dont know anything abt my medical history
i learned it
What
i have a bad memory
What does that have to do with learning python?
i forget things easily
I present some good options
Google
Stackoverflow
Coding assistant
I personally forget basic shit too, so i refer to already documented problems and use them as references :3
No flame, but sometimes its quicker to google than ask and rely on other humans
there are resources at the top of #help-rules
You just need to compare a different datatype
have you tried to take notes to remember stuff easier?
bro
please stfu
you know nothing abt me
if you don't want help then don't ask
Not a bad idea, adding comments in code and explaining what it does, does help learning
we're doing what we can
some stuff doesnt work for me
its not help when hes nullying me for a medical disorder
then explain that instead of saying 'stfu you know nothing'
that i cant help
try and listen to people who try to help, what he said is actually a good way of storing what you learned, in your own way
his intent was to help not to bully
^
its the 2nd time
If you let a medical order hold you back you wont get anywhere, there are athleates with missing limbs
this kid does shit like this
You need to push through
do you know about casting? If you don't, it means you still have stuff to learn. Even though the option is still there, it's much better to understand the type that it's sending over. In the docs (pretty sure) it explains the type when it sends over
how can i make an inputText field in a modal an integer field and set a min and max integer?
you can't
string only, sorry
damn, thats a weird choice of discord
you can validate it server side if you want though
yeah ill need to do that
If anyone has time, I made a post explaining an error i'm experiencing.
I'm basically trying to edit the content of a message by using interaction.message.webhook_id, but when trying to edit it with interaction.followup.edit_message(), an 'unknown webhook' error is raised
the following is a link to the post https://discord.com/channels/881207955029110855/1024439410655248455
hey @naive steppe did i fix it or no?
@bot.slash_command(description="nick")
async def nick(ctx, user: discord.Member):
if({ctx.author.id == "1007797339643195455"}):
await ctx.respond("**nick man is**")
else:
await ctx.respond("no perms :skull:")
act no i didnt shit
nvm sorry for ping
ik ik
It'll always default to else
im trying to learn how to fix it
are menus also not supported in modals?
not yet I'm afraid
discord limitation
the max is 5 text fields
they're working on it however knowing discord, it'll take a lot of time
yeah probably
it works in some way but on mobile it can crash discord
pretty sure you can no longer do it, they fixed the bug
no it was straight up removed
they were like fully functional on desktop for months
oh
then called it a bug and removed it
could have taken a bit of time to fix it for other platforms and then formally announce it as a feature
True 
does someone have the docs link for directmessage?
not sure if im blind but i cant find it
ty!
medical disorder
fun, you're banned for your toxic behavior now
any one know why any "reg commands" non slash do not work?
?tag message-content
As of Pycord Beta 5, Discord API v10 requires message content intent to receive message content. This affects the traditional commands. Not enabling this intent will result in the messages' content, embeds, and components being empty.
You will need to enable the intent on the developer portal, as well as in your code:
intents = discord.Intents.default()
intents.message_content = True
bot = discord.Bot(intents=intents)
Docs: https://docs.pycord.dev/en/master/api.html#discord.Intents.message_content
#library-updates message
How can I add more than 1 parameter to a slash command? I have something that looks like
@slash_command(name="example")
async def test(ctx, a: discord.Option(str), b: discord.Option(str)):
# do stuff
However, when I run this command, I'm only prompted for option b.
is this in a cog?
yeah
you are missing the self parameter
yw
Has this been fixed?
Evaluating...
Starting Download...
Unfortunately all 20 could not be downloaded because some images were not downloadable. 0 is all we got for this search filter!
Errors: 0```
google_images_download module
probably not. the last commit to master (for that module) was May 21, 2019
also others were having the same exact issue: https://github.com/hardikvasa/google-images-download/issues/360
sad....
probably might want to find another one. if u can't find one that suits your needs, you can always create your own lib for that
yea i'll find another one
how can I avoid a discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction when doing a slash command?
Will the bot get rate limited or something if they send messages in like a lot of server chats "at once"
So what I'm trying to do is on_ready event, it'll send message to all the log channel that the server has enabled, is that not recommended to do?
It'll loop through all of the log channels, if needed I can set up an async sleep if needed to not get ratelimited
found better alternatives
bing_image_urls and google_images_search for easy web image scraping, the bing one not better, but way easier. I can't believe how I missed these two. I know there's more out there but I'll stick to these for now.
is there any way to remove ephemeral messages?
You can delete the the same way as a normal message but it is slightly more buggy. Due to the user deleting it or it not being stored anymore
the the
ephemeral messages can't be deleted by bots
at least not supposed to
I swear it used to be possible, oops.
nvm, lala says you cant delete them
ahh damn
it was never intended sadly
You can edit them
yeah ill edit them them probably to just a space or something
one way: edit the ephemeral message and set content to blackhole, this will eat up message
ez
blackhole?
oohh hahaha
yeah blak hole
you'll probably be fine
, Just in case, I'll make it so it doesn't spam and sleeps for 1 second
the rate limits are applied individual route
oh so for each server, it's own rate limit?
every route; even each channel technically has its own
as long as you don't exceed the global ratelimit which is pretty high already
it's like 50 per second or something
ah, then I should be fine. It's only during the startup that it sends in every channel and I'm hoping as well that during pretty big updates, it'll send message in the log system and ping the owner and admins on the downtime coming
awesome thanks!
I have a question, is there a limit on command count?
hey everyone! how I can add reaction and open thread on interaction message
ping pls
You can have 100 global commands, and each command can have up to 25 sub-command groups. Each sub-command group can have up to 25 sub-commands.
100 x 25 x 25 = 62.5k
Of course, "slash commands can have a maximum of 4000 characters for combined name, description, and value properties for each command and its subcommands and groups", so you're not likely to hit that 62.5k command limit (because every command would have an average of 6.4 characters).
You can also multiply this number by two if you register the bot's commands in every guild as guild commands.
get the message with msg = await interaction.original_message()
then do normal message stuff with it
and how, let's say, to bind it to a button
the button requires a separate response so I would probably just edit the message by not passing in any arguments. then do the same thing
Here's the cooldown example.
Here's the reaction roles example.
Wow
Buttons have to be responded to within the same session right?
discord.errors.NotFound: 404 Not Found (error code: 10015): Unknown Webhook
i have this error when try to edit a message with:
await interaction.followup.edit_message(interaction.message.id, embed = embed, view = None)
this message was edited a few times in a row, any ideas ?
edit: the interaction variables is an interaction: <discord.interactions.Interaction object at 0x7f77ee51aba0>
is it possible to have multiple instances of 1 bot running?
on a button click my aws lambda will run and i want that lambda to give updates in dm
Possible, but not recommended
any recommendation how i should do stuff like this then
Ideally for bots, u should just have a bot hosted and on each event, do whatever u need in it
yeah tho how should i go about doing this
sending updates from a lambda function to discord
Dockerize your bot, and then on a button click on your view, do whatever u need
And deploy the docker image to AWS since it seems like u are already using that
Serverless isn't recommended for bots
i meant the code part that doesnt have anything to do w the discord bot
just sending updates
ah ok
why is it not recommended for bots btw? i just read about some ppl having their whole bot serverless
itd make sense for what im trying to achieve
Can you not just create two files and run them in the same folder?
Him I have this code:
async def xp(self,ctx,user = None):
font = ImageFont.truetype("C:/taf/test_python/BebasNeue-Regular.otf",35)
le_gif = []
size = (800,200)
millieu = (0,0)
premierp = Image.open("C:/taf/test_python/test.png").convert("RGBA")
barre_v = Image.open("C:/taf/test_python/barre_v.png").convert("RGBA")
barre = Image.open("C:/taf/test_python/barre.png").convert("RGBA")
pp = ctx.author.avatar
width, height = pp.size
pp = pp.resize((round(width*0.3),round(height*0.3)))
for img_act in range(18):
im = Image.new('RGB', size)
frame = Image.open("C:/taf/test_python/frames_pp/" + str(img_act) + ".gif").convert("RGBA")
width, height = frame.size
frame = frame.resize((round(width*0.8),round(height*0.8)))
im.paste(frame, (510,-70),frame)
im.paste(barre_v,(13,130),barre_v)
a = 5 # 0% = -640, 100% = 5
b = 130
im.paste(barre,(a,b),barre)
im.paste(pp,(14,12),pp)
im.paste(premierp,millieu,premierp)
I1 = ImageDraw.Draw(im)
I1.text((130, 90), "Level :", font=font)
I1.text((350, 90), "XP :", font=font)
le_gif.append(im)
le_gif[0].save('C:/taf/test_python/atest_bann.gif',
save_all = True, append_images = le_gif[1:],
optimize = False, duration = 10, loop=0)
await ctx.send(file=discord.File('C:/taf/test_python/atest_bann.gif'))
does someone have an idea on how I can use the pp of the user that send the command on the imge that my code create?
Okay, thanks for help
Hey guys! Is it a valid approach to divide a bot into 2 different project, running its own instances, and make one only manage, for example, slash commands, and the other one only background tasks, so that i can edit change one without killing the other?
whatever sails your boat
make sure to turn off auto_sync_commands on your bg task bot
thankyou!
For some reason, when I have intents = discord.Intents.default() then set intents.members=True when my bot is verified and I have the guild members intent, my on_ready doesn't want to fire and it still doesnt think i have the guild members intent when I do on the dev portal since i applied for it. this issue only occurs when setting intents.members to True.
nvm it just takes a really long time to start the bot 
how to send private message ?
ephemeral=True or dm the user
could you send me the api section
I can not find it
:'c
pls 🥺
i love u
ok.
Hilarious
I have a doubt. can I make the bot send messages without events?
you can send messages as long as you have a channel object that your bot has access to it
What do you think would be the best solution?
The problem with requesting the presences intent is that they probably want a real reason why I am requesting it, like using it for a feature.
make sure you haven't registered them as guild commands and global commands
the commands cannot all be global.
since if they are duplicates the only way is that they are registered differently, global-level and guild-level
k
I think waiting is a good idea
just don’t test on production
How do I make my Discord Bot have a custom colour for their banner?
Also, what is the event for when the bot joins or leaves a guild?
on_guild_join() and on_guild_remove().
Link: https://docs.pycord.dev/en/stable/api.html#discord.on_guild_join
TYSM
And what about this?
I doubt that's possible.
ouch
Also, how do I make a bot display a user's banner in an embed as the "embed.set_image"
@spice oyster
figure it out
why does my defer() go on forever?
Traceback (most recent call last):
File "/home/container/.local/lib/python3.9/site-packages/discord/client.py", line 382, in _run_event
await coro(*args, **kwargs)
File "/home/container/main.py", line 33, in on_application_command_error
await interaction.response.send_message(embed=embed)
File "/home/container/.local/lib/python3.9/site-packages/discord/interactions.py", line 674, in send_message
raise InteractionResponded(self._parent)
discord.errors.InteractionResponded: This interaction has already been responded to before
now this error
is there a way to persist the discord.cooldown for a user using the bucket type?
my error handler isnt working
like not reseting it when I restart the bot
no built in way no
you deferred after responding
no i deferred in the start of my cmd
oh right
change response.send_message to followup.send
Okay
will this break other cmds which dont have defer?
just do it in that command
async def on_application_command_error
you can just do ctx.respond and it'll handle the logic for you
So i have to pass in ctx in the ()
you always do?
cuz it wasnt there in an example i saw
@bot.event
async def on_application_command_error(interaction, error):
if isinstance(error, MissingPermissions):
embed=discord.Embed(title="Error : Permissions", description=error)
await interaction.response.send_message(embed=embed)
elif isinstance(error, CommandOnCooldown):
embed=discord.Embed(title="Error : Cooldown", description=error)
await interaction.response.send_message(embed=embed)
else:
embed=discord.Embed(title="Error", description="Something went wrong... Please inform the developers of this!")
await interaction.response.send_message(embed=embed)
raise error
how do you assign a custom on_timeout to a view that is not inside its own class
well so i do interaction.respond?
i guess
just define the function then assign it py async def timeout(): ... my_view.on_timeout = timeout
Exception has occurred: AttributeError 'interaction' object has no attribute 'respond'
how in the hell are you getting interaction when it passes context
yeah
k
i tried that but some reason it is inaccurate to the prerequisite arguments
sure
oki
can you try ctx.respond?
where do i pass in ctx though?
interaction is ctx
in your code
https://docs.pycord.dev/en/master/api.html#discord.Bot.on_application_command_error py await on_application_command_error(context, exception)
hm
Ill try re-installing
i did update python today, maybe that caused some nonsense
do you have something else installed?
No
As far as i see in my pip list, pycord is the only discord API wrapper
working, i re-installed Py-Cord and re-opened Cmd and VSC
yeah you were using dpy
wait
eh
some mix of it idk
they take interaction in their error handler
await ctx.defer() changed?
no
.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.
Its not the code..
skill issue
It would be the code, if you can’t provide us with code you’re using we can’t help you.
import json
import discord
from discord.ext import commands
client = commands.Bot(
command_prefix="1",
help_command=None,
debug_guilds=[903607882564636683],
case_intensitive=True,
intents=discord.Intents.all())
@client.event
async def on_ready():
print("Ready!")
@client.command()
async def test(ctx):
await ctx.send("test")
@client.event
async def on_message(message: discord.Message):
if message.content == client.user.mention:
await message.channel.send(f"Hello {message.author.mention}")
if message.content.lower() == "hello":
await message.channel.send(f"hello {message.author.mention}")
with open("Database/Config.json", "r") as f:
data = json.load(f)
testbot = data["Bot"]["testbot"]
client.run(testbot)
``` this is a test file
overrides on_message
complains about commands not working
add await client.process_commands(message) to the end of that event
it works thx!
Does this mean that the token I passed is not a valid token?
Traceback (most recent call last):
File "main.py", line 108, in <module>
bot.run(TOKEN) # run the bot with the token```
Got confused, it worked a while ago now it doesn't....
hey there can anyone help me
So the thing is, i wanted to create a welcome command which looks like this after completion
but when anyone joins the server the bot replies pretty late, say like 5-6 secs after
I have worked with easy_pil for this
is there a way by which I can make the response asap when anyone joins
If anyone answers please ping me
probably because it's spending that time generating the image
if you want it faster you'd either have to find more efficient code or get a better server to run the bot on
Is there any better way to ignore self (bot) messages? other than if else
do you really need it any simpler than that...?
i mean if there is any other way it would be good to know cz rn i want to listen for user messages only in a channel where my bot send logs of a console
not really, you literally just check message.author.bot or compare message.author.id to your bot's id
that's only 1 or 2 lines at most
yea ik that one... but just wanted to know if any other way was there or no
this sounds like trying to reinvent the wheel
it's the most straightforward way
is it because of else?
One message removed from a suspended account.
One message removed from a suspended account.
you seem to be misunderstanding your own code, it's already doing this
utcnow() gets the exact current time
and you're removing x days from it
it doesn't round or anything, it'll still be the same exact time; just x days ago
One message removed from a suspended account.
i mean you can
ah oh well
use datetime.utcfromtimestamp(...) to convert an int unix time to datetime
How can I make the autocomplete show "Lúcio" with accent (working) but also find it when written without accent (not working)? Solved.
async def autocomplete(context: discord.AutocompleteContext):
input = "".join(item for item in context.value if item.isalpha()).lower()
heroes = await Hero.catalog()
return [hero for hero in heroes if "".join(item for item in hero if item.isalpha()).lower().startswith(input)]
translate their input for them
e.g. if you find ú in context.value then replace it with u
or rather the other way round
for the sake of finding Lúcio, you should instead match against Lucio and then you return Lúcio
Hmm, I'll see what I can do.
One message removed from a suspended account.
One message removed from a suspended account.
Fixed! I managed to make it work with unidecode() after some tries. I wasn't sure where to put it. 
One message removed from a suspended account.
One message removed from a suspended account.
how do you create message object from only message id?
One message removed from a suspended account.
No cross posting thanks
I could be wrong but Bot.fetch_message(id)
You may need to fetch the guild and channel first
is there any way to get the built-in DefaultHelpCommand to work with slash commands? if not what is the best way to build a help command response for all my slash commands?
tbh I wouldn't use default help.
It's already in the ui with name and descriptions
overwatch?
omg i love overwatch
Hey there. I'm making a command for entering and registering players' scores for a game in a database. I want to have players enter their scores through a slash command, then have a message ping the mods so they can verify the score with an in-game screenshot from the player, then input a slash command to have the score finalized and written into the database.
Basically, I was wondering how to get a slash command to wait for a response from another slash command before continuing.
you can add a column/field/something in your database that marks the progress and access that value.
right, but i was hoping to have some form of help function that shows the commands available to them. i dont want to expect the user to be aware of everything my bot can do. is there a good way to do this?
you'll need to write that yourself I think
why haven't we added each other yet?
tbh idk
send me your tag in dms 
idk if that's correct tho.
Do you know squid?
here are some resources to help you get started:
Looping through commands:
https://docs.pycord.dev/en/master/api.html#discord.Bot.walk_application_commands
Commands' attributes:
https://docs.pycord.dev/en/master/api.html#discord.ApplicationCommand.qualified_name
https://docs.pycord.dev/en/master/api.html#discord.SlashCommand.description
https://docs.pycord.dev/en/master/api.html#discord.SlashCommand.mention
Localizations:
https://docs.pycord.dev/en/master/api.html#discord.SlashCommand.name_localizations
https://docs.pycord.dev/en/master/api.html#discord.SlashCommand.description_localizations
Squid always helpful 
there isn't a native way to do it, but it should be easy enough
yeah I guessed so
yeah I had the same question actually
Wished there was a native way to do it, and I might make a cog that does that
#squid for helper
Hey, how do I make some of my Discord bot's commands work in ALL servers?
No, it's a bot for Heroes of the Storm. The draft simulation is the best part because it uses images. I have screenshots if you are curious. Link: https://ko-fi.com/post/Snowball-Discord-Bot-X8X2AHKTH
Don't pass any guild_ids for them.
aah ok
tf but these are overwatch characters
Did you never try it? There are Heroes from other Blizzard games. 12 from Overwatch, 90 in total.
nah, don't like crossover
aaand I driftet too much OT here.
Let's drop that topic
Hi my Py cord dont work any Idees how to fix it??
.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.
it says "No module named 'discord'"
Use pip install py-cord
I allready did that
And try to close and reopen your text editor
show the pip list
@autorole.command(name='add', description='setup the autorole')
@discord.default_permissions(manage_guild=True)
async def autorole_add(self, ctx, *, role: discord.Option(discord.Role, 'the role to be given', required=True)):
await ctx.defer()
try:
await db.run_query(f'INSERT INTO autorole(guild_id, role_id) VALUES({ctx.author.guild.id}, {role.id});')
await ctx.respond('Configuration saved! Autorole is setup', ephemeral=True)
except asyncpg.exceptions.UniqueViolationError:
await ctx.respond('Autorole is already setup!', ephemeral=True)
this is my code but the messages arent ephemeral ones
you have to add ephemeral=True in defer
oh ok thanks
Found some replies in the help threads but thought id just ask here: What hosting service would you guys recommend? Id only use the bot for my private server and the bot is rather simple
I mostly self host my bots. The ones that I have are dockerized and can be deployed rlly easy. I would say get Oracle or GCPs free tier, and use that. If u have access to the GitHub Student Education Pack, then u can probably use that w/ azure
might throw a Prometheus exporter on some of my bots so I can get some metrics to track later
Here's the persistent example.
Did you forget to await something?
One message removed from a suspended account.
whats the thing you are planning to use this for? you could use the on_mesage event. you can either store the counter in a dict (it will reset when the bot resets) or you could use a database like sqlite
One message removed from a suspended account.
One message removed from a suspended account.
you can do smth like
user_msg_count = {}
async for message in ctx.channel.history(limit=None, oldest_first=True, after=after_date):
if user_msg_count[message.author.id]:
user_msg_count[message.author.id] += 1
else:
user_msg_count[message.author.id] = 1
also, because you have put limit=None, dont forget to break
One message removed from a suspended account.
yea its not necessary, it depends on what you are planning to do
One message removed from a suspended account.
np!
One message removed from a suspended account.
One message removed from a suspended account.
I presume the send_messages_in_threads includes sending messages in forum posts right?
is it possible to edit a message based on the message id in a dm channel? so i can save the message id in a database to edit later
also is it possible to do a defer on a button click
You can use this trick to get a Message object to delete and probably even to edit, although you probably need to fetch the message in that case.
message = [discord.Object(id = message_id)]
Yes, why not.
thanks!
any ideas?
i used to do it with ctx.defer(), but theres no ctx in the callback right?
ahh ty
I think so. I can't say for sure as I never used them.
Posts are basically Threads, just slightly different.
was trying to create something like this but unsure if the send_messages_in_threads counted forums too
Oh, you are talking about permissions.
yh
How can i not spam my console when using @commands.has_permissions and don't have the perms?
use the error handler
All about handling errors.
One message removed from a suspended account.
One message removed from a suspended account.
lower it
Working with strings is some basic python
:D
One message removed from a suspended account.
startswith() takes a tuple, not a list, so you have to convert it.
When the difference is just capitalization, you can use lower().
list_of_triggers =["one", "two", "three"]
if message.content.startswith(tuple(list_of_triggers)):```
Hi, so I'd like to make a slash command group inside a cog. What's the easiest way to do this? Should I make a variable in the class constructor, or is there some decorator I can put on a function?
guys
Why does it take so long for my bot to send messages
I checked the execution time
for each part
everything happens quickly in like 0.1265.. secs
Here's the slash cog groups example.
@foggy mesa ^
How's 0.12 seconds slow
but when await ctx.respond(...)
the time reaches 8-9 secs
the entire program executes in 2 secs at max
ooh, thanks!
but just including the await ctx.send thing
it goes upto 8-9 secs
and I don't want that
bc it is a welome message
I was wondering how to keep the selected item in the select menu the same when I edit the message of the interaction
code for the callback function of the select menu:
async def callback(self, interaction: discord.Interaction):
embed = CountConfigEmbed(interaction.guild)
await interaction.response.edit_message(embed=embed)```
by not including view?
Cogs, often known as modules or extensions, are used to organize commands into groups. This is useful
One message removed from a suspended account.
is there an easy way to get_or_fetch_user without connecting 2 bots at the same time
e.g. I have a bot that is online, but I want to also not have to bring over a full bot to the code that I want to run
This is what I have so far
def make_embed(ticket):
last_updated_by_id = ticket.last_updated_by_id
await discord.Bot.get_or_fetch_user(last_updated_by_id) # <--- this
embed = discord.Embed(title=f"Ticket {ticket.id}", color=0x00ff00)
embed.add_field(name="Ticket ID", value=f"{ticket.id}", inline=False)
embed.add_field(name="Ticket Status (open-1/closed-0)", value=f"{ticket.open}", inline=False)
embed.add_field(name="Ticket Author", value=f"{ticket.user_id}", inline=False)
embed.add_field(name="Ticket Subject", value=f"{ticket.subject}", inline=False)
embed.add_field(name="Ticket Content", value=f"{ticket.content}", inline=False)
embed.add_field(name="Ticket Created", value=f"{discord.utils.format_dt(ticket.created, 'F')}", inline=False)
embed.add_field(name="Ticket Last Updated", value=f"{discord.utils.format_dt(ticket.last_updated, 'F')}", inline=False)
embed.add_field(name="Ticket Last Updated By", value=f"{ticket.last_updated_by}", inline=False)
return embed
I'm aware I'm not capturing the result of the get_or_fetch_user
How can I update slash commands without having to register it again?
hi is there any special intent (in the code) my bot needs in order to use slash commands ?
cause they are not registered even on my debug serv :(
(i invited it with this scope so it should be fine on this side
permissions=0&scope=applications.commands%20bot)
and this is the bot creation in the code
intents = discord.Intents.default()
intents.emojis = True
bot = Bot(debug_guilds=[913042210348486710], intents=intents)```
and a simple command
@bot.command(description="Contact and code for the bot")
async def info(ctx):
await ctx.channel.send(f"Author: Inspi#8989\nCode: a link to the code")
is this a bug? I've used 'none' in the parameters, but why does raised appear?
@commands.command()
async def purge(self, ctx, limit: int, filter: Union[discord.Member, str] = None):
if limit >= 0:
if limit <= 100:
if filter:```
output
raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: filter is a required argument that is missing.```
@kindred sail
#help-rules
You cannot ping or DM people for help unless they allow you to do so, even if they are staff members.
alright i figured it out, i was using Bot from discord.ext.commands instead of discord
cause legacy code; and it seems it made a difference
i can't find the doc that lists what you can access in ctx ?
is there any ?
Everything I use this and run my server, it just goes offline (with no error).. anyone know why?
async def main():
async with Bot() as bot:
await bot.start(os.getenv('TOKEN'), reconnect = True)
ty
Excited to create your first bot? Once you install Pycord, you can start right
bruh
I know the basics… I’m trying to use .start instead of .run and I’m tryna to start my program asynchronously
Sorry, I can't guess your level or intentions. 
Can you do that without using the with statement? 
i got a command that you can tag any number of people with (including none); what would be the correct function definition ? command(ctx, *mentions) ?
Hello guys
i want to know how to remove some RAM in my bot
First, what will increase it ?
and, is the autoshard can remove the problem ?
My host limit the RAM to 100mb, and my bot (without anyone make command) have 42/100 MB.
If you have a better host without limit, you can send it to me in DM
this won't work at all
- that's not an async function
- you're calling it from the generic instance class, which isn't initialised or authorized so requests will be rejected
from the looks of it, you should do the first two lines in your main function/command and then pass the user to the function
you might actually be interested in the Greedy converter
https://docs.pycord.dev/en/master/ext/commands/commands.html#greedy
uuh oki imma look into that thanks 
what bots can do this? looking for one that is not bloxlink
hey I'm not entirely sure where to send it but for some reason vscode intellisense is often missing what methods an object might have.
like in an example here
@bot.event
async def on_message(message):
if 'funk' in message.content:
await message.add_reaction(bot.get_emoji(1025750885961322636))```
here I am adding a reaction to a message and it seems to work fine but it seems like vscode doesn't believe `message` has `.content`
probably need to typehint
on_message(message: discord.Message)
o it worked, ty
it's a generic eval command, you can look up how to make one pretty easily; just make sure you're strict with permissions to ensure only you can use it
there's also extensions like jishaku that can offer other functionality alongside it
alright, thank you!
That's a private bot lmao. It's jishaku.
just got this weird error using Greedy
@bot.command(description="Creates a workcloud for you or whoever you tag")
@guild_only()
async def cloud(ctx, members: Greedy[discord.Member]):
AttributeError: 'Greedy' object has no attribute '__name__'. Did you mean: '__ne__'?

can you paste the full traceback, and is this slash or prefix?
yeah
i mean
with response.edit_message(view=...)
the same as any other edit
yeah it's slash, here's the backtrace
Traceback (most recent call last):
File "D:\Documents\Repos\DiscordWordCloud\main.py", line 137, in <module>
async def cloud(ctx, members: Greedy[discord.Member]):
File "D:\Documents\Repos\DiscordWordCloud\venv\lib\site-packages\discord\bot.py", line 834, in decorator
self.add_application_command(result)
File "D:\Documents\Repos\DiscordWordCloud\venv\lib\site-packages\discord\bot.py", line 138, in add_application_command
command._set_cog(None)
File "D:\Documents\Repos\DiscordWordCloud\venv\lib\site-packages\discord\commands\core.py", line 575, in _set_cog
self.cog = cog
File "D:\Documents\Repos\DiscordWordCloud\venv\lib\site-packages\discord\commands\core.py", line 780, in cog
self._validate_parameters()
File "D:\Documents\Repos\DiscordWordCloud\venv\lib\site-packages\discord\commands\core.py", line 673, in _validate_parameters
self.options: List[Option] = self._parse_options(params)
File "D:\Documents\Repos\DiscordWordCloud\venv\lib\site-packages\discord\commands\core.py", line 712, in _parse_options
option = Option(option)
File "D:\Documents\Repos\DiscordWordCloud\venv\lib\site-packages\discord\commands\options.py", line 199, in __init__
self.input_type = SlashCommandOptionType.from_datatype(input_type)
File "D:\Documents\Repos\DiscordWordCloud\venv\lib\site-packages\discord\enums.py", line 689, in from_datatype
if datatype.__name__ in ["Member", "User"]:
AttributeError: 'Greedy' object has no attribute '__name__'. Did you mean: '__ne__'?
pain
greedy could probably be fixed to work with slash but not atm
i'd say take it as a string then split and convert inside the command
in the next release we'll have discord.utils.raw_mentions(text) that will grab all user IDs from mentions in a string so you can get them all at once to make converting easier
oh oki thanks for your answer 
WHY... I'm disabling the buttons in other view during the on_timeout event, but in a different view it gives me an error:
future: <Task finished name='discord-ui-view-timeout-fc00f94177271408f01d3447da1a9399' coro=<MyOperationView.on_timeout() done, defined at C:\Users\Administrator\Desktop\Atalhos\workspacenova\BBot\venv\cogs\Crypto.py:85> exception=AttributeError("'WebhookMessage' object has no attribute 'edit_original_message'")>
Traceback (most recent call last):
File "C:\Users\Administrator\Desktop\Atalhos\workspacenova\BBot\venv\cogs\Crypto.py", line 87, in on_timeout
await self.interaction.edit_original_message(view=self)
AttributeError: 'WebhookMessage' object has no attribute 'edit_original_message'
idk what you passed in there, but since it's a WebhookMessage it's just edit instead of edit_original_message
https://docs.pycord.dev/en/master/api.html#webhookmessage
How does my view turned into a webhookmessage btw? 🥴
you probably used followup.send
i have no idea, its pretty much the same as the other view
lemme show you how i called both
This one works with the edit_original_message
This one dont
because the first ctx.respond will use ctx.interaction.response.send_message, as it's the first response
but after that you can no longer use the function, since it's already been responded to
so using ctx.respond again will use ctx.interaction.followup.send
ohhhh damn, thanks for the explanation
followup is a Webhook, so this is under Webhook.send https://docs.pycord.dev/en/master/api.html#discord.Webhook.send
which returns WebhookMessage
hence why respond lists both as possible https://docs.pycord.dev/en/master/api.html#discord.ApplicationContext.respond
Return type
Union[discord.Interaction, discord.WebhookMessage]
all good
ok
🙂
if the message is edited then the selected item (on the client end) is reset, can't do much about it
hmm, but for the select menus on dank memer, the selected item stays the same when the message edits
You can probably read the value, edit the message, and change the value back to what it was before.
a bit convoluted, but i reckon they re-edit the select menu but set the option that was selected to default=True
Hey, if someone have an answer, it would be nice 
import asyncio
from discord.ext import commands
from discord.commands import slash_command, user_command, SlashCommandGroup
from discord.commands import Option
class General(commands.Cog):
def init(self, bot):
self.bot = bot
@commands.slash_command(description="Get the bot's current latency!")
async def ping(ctx: discord.ApplicationContext):
embed = discord.Embed(
description="Ping: {int(self.bot.latency*1000)} ms",
color=discord.Colour.blurple()
)
embed.set_author(name="Pong", icon_url="https://cdn.discordapp.com/avatars/836895718563250196/cafaf0d749d1aaa938f8c0bd7be4fa2d.png?size=1024%22)
await ctx.respond(embed=embed)
def setup(bot):
bot.add_cog(General(bot))```
Can someone help me with this?
It's showing error
as you can see, it looks like a server selection timeout error. could you show your code?
Sure, wait
Why did you add the cog in the cog ?
you are in a class, the first argument is self
hmm ok
ill try later today thanks
so it should be ```py
@commands.slash_command(description="Get the bot's current latency!")
async def ping(self, ctx: discord.ApplicationContext):
did you whitelist your ip address on MongoDB?
mhm
had pymongo worked before this?
great, what was the solution?
and what's your other problem
basically i had to whitelist 2 ips, i whitelisted my house's ip, but i did not whitelist my another house one.
Ignoring exception in command strike_give:
Traceback (most recent call last):
File "C:\Users\danie\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\commands\core.py", line 127, in wrapped
ret = await coro(arg)
File "C:\Users\danie\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\commands\core.py", line 911, in _invoke
await self.callback(ctx, **kwargs)
File "c:\Users\danie\OneDrive\Documentos\Phython\Applicaciones\Pokemnia's staff manafger\.py", line 68, in strike_give
await ctx.respond(f'El usuario {usuario} ha recibido un warn correctamente por `{razon}`. ``id:`` {numero}')
File "C:\Users\danie\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\commands\context.py", line 275, in respond
return await self.interaction.response.send_message(*args, **kwargs) # self.response
File "C:\Users\danie\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\interactions.py", line 727, in send_message await self._locked_response(
File "C:\Users\danie\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\interactions.py", line 975, in _locked_response
await coro
File "C:\Users\danie\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\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
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\danie\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\bot.py", line 1009, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\danie\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\commands\core.py", line 359, in invoke
await injected(ctx)
File "C:\Users\danie\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\commands\core.py", line 135, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction
it may have taken more than 3 seconds for your bot to respond. try adding an await ctx.defer() near the top of the callback
like above the async def?
hello everyone, i need to call an async function when my bot starts, but it needs to not be in on_ready event, how can i do this?
no, just at the top of that function
you can call an async function with asyncio.run()
just what i needed, thanks
hello again, i tried this and it does call the function yes, but it doesnt run the bot after calling it, im assuming its because the murder (dont question the name) function has an asyncio.sleep, how can i make it run the bot without stopping to call the murder function?
you can make a thread for murder just like keep_alive
how do i do that? what do i need to add?
perhaps on_connect?
as long as you remember to sync commands
if you could tell me how to sync commands, that would probably work for my bot
it's basically just py await client.sync_commands()
if you override on_connect just make sure to include that somewhere in it and you should be fine
thanks, i will try this
I can't seem to have an optional discord.Member as argument
@bot.command(description="Creates a workcloud for you or someone you tag")
@guild_only()
async def cloud(ctx, member: discord.Option(discord.Member, required=False, default=None)):
i tried this but discord is forcing me to input a member
is it normal behavior ?
try removing and then readding the command through restarts
k
Is it possible to tell the difference between a failed everyone ping and someone just saying iy, such as in a code block?
message.mention_everyone will return False if its a failed mention
i am getting this when i use await ctx.defer()
show code thanks
complete? (it is little messed up)
Yes
Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.
does the "{bot_name} is thinking.." message show up?
I've decided to reformat my project to one with modules and all that stuff. Does anybody know how to parse the bot variable from __init__.py to __main__.py?
__main__.py just contains a single bot.run(env['DISCORD_TOKEN']) line, everything else sits in __init__.py. I'm not that good at python stuff sorry XD
just import
import funkbot.__init__
# running a bot
bot.run(env['DISCORD_TOKEN'])
doesn't seem to do anything
nor importing main in init
ok I've finally figured it out, just had to import as and then specify vars correctly
I'm using a Modal. The UI says "up to 4000 characters" but the error message says "up to 1024 characters". Why?
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In data.embeds.0.fields.0.value: Must be 1024 or fewer in length.
hey, i tried this, sometimes when the bots starts connect() fails because it is rate limited, can i call this function earlier than on_connect?
or maybe if there is a way to read console outputs?
actually not sure, can you post the full traceback?
how exactly are you managing to get ratelimited there...? what's the code
1024 is the limit
oh thats just because i use replit, projects share ips.
eh...
Ignoring exception in modal <cogs.matchup.Matchup.MatchupModal object at 0x00000160F386E370>:
Traceback (most recent call last):
File "C:\Users\Elitesparkle\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ui\modal.py", line 324, in dispatch
await value.callback(interaction)
File "c:\Users\Elitesparkle\Documents\GitHub\Snowball\cogs\matchup.py", line 35, in callback
await interaction.response.send_message(embeds=[embed])
File "C:\Users\Elitesparkle\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\interactions.py", line 727, in send_message
await self._locked_response(
File "C:\Users\Elitesparkle\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\interactions.py", line 975, in _locked_response
await coro
File "C:\Users\Elitesparkle\AppData\Local\Programs\Python\Python39\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.fields.0.value: Must be 1024 or fewer in length.
if it's a replit issue im not sure i can help you further, don't think there are any events before on_connect so you'd have to make do with your own function
I have the same with the modal, 1024 is the limit
it's not the modal
embed field value is max 1024
Oh, right! I didn't think about that.
Thanks! First time using them. I was just trying the code from the guide.
i guess in general, if you're planning on outputting modal input back to the user it's a good idea to set a max input length
Cool! I'll need that for sure.
how can self.message in my view be NoneType all of the sudden?
class ConfirmBoost(discord.ui.View):
def __init__(self, orders: list[list[str]]):
super().__init__(timeout=120)
self.orders = orders
self.confirmed = False
async def on_timeout(self):
if not self.confirmed:
await self.message.edit(content="You took too long! Try again", view=None, embeds=[])
could it have to do something with this:
await interaction.followup.send(embeds=embeds, view=ConfirmBoost(orders), ephemeral=True)
it used to be a message_send
i think view.message isn't fully implemented; it seems to only be assigned in some functions
but you could get around this by pre-assigning the view and then assigning it manually
e.g. py view = ConfirmBoost(orders) view.message = await interaction.followup.send(...)
thanks! that works
then, is there a way to detect if the bot fails to run?
is it client.is_ws_ratelimited?
if your Bot's object's name is client, yes
gotchu, i will try this
alternatively, instead of using bot.run it may be better to look into the lower level functions for easier control over catching errors
https://docs.pycord.dev/en/master/api.html#discord.Bot.run
client.run abstracts to ```py
try:
asyncio.run(start(*args, **kwargs))
except KeyboardInterrupt:
asyncio.run(close())
# cancel all tasks lingering
i will just put the bot.run in a try, except statement and see if that works for now
what if it ratelimits during runtime?
yeah i just thought of that, what if i start a function to check if the bot is ratelimited every few seconds?
check discord.ext.tasks
i tried using tasks before, i think they stop when the bot gets ratelimited during runtime
depends on the ratelimit i guess...? most ratelimits just log a warning and don't actually crash the bot, the only example i can think of that does crash the bot is command syncing... which happens to be the issue here
I think the issue is ratelimits in general
but arguably the library shouldn't really need extra mitigation from people using shared IP hosting, if you're ratelimited because of that then ultimately it's out of scope
i see this in my console "<p>The owner of this website (discord.com) has banned you temporarily from accessing this website.</p>"
that's the cost of using replit
yeah there's a long html thing
yes
You can change replit containers using "kill 1"
i know right, i've been using replit for over a year and this has never been an issue until a month ago
if the other containers are not ratelimited, then you can run your bot again
yeah, what i am trying to do right now is "kill 1" the bot when it is ratelimited
or every X minutes
free hosting service pops up > "wow this is cool" > gets popular > ratelimits increase > another one pops up which isn't being ratelimited > rinse and repeat
yeah, but you still need to manually restart it
in replit's defense, they've mitigated this issue quite a lot
glitch, replit, heroku, and now railway's gaining popularity
heroku not so much
fair enough, but ultimately there's a limit
i am pinging the app every 5 minutes
heroku's solution was to give up their free tier lol
that doesn't solve the problem...
wouldn't that turn the bot on every time it pings it?
most of the time my bot is not online is because it got ratelimited while runtime
a few solutions:
- have 2 bots: one being your main bot. the second bot would notify you if the other bot is down and you turn it on
- not use replit.
what can i switch to?
Are you a student?
There's railway.app render.com
Cuz if you are you could potentially use microsoft azure
That's what I'm using atm to host my bot for free
no...
these are good options though
also oracle
Railway works if you've got a credit card
You basically just use the cc to upgrade to the dev plan which gives you up to $5 of usage for free each month
if you have at least access to a debit card then there's a lot of <3$/month hosts you can find pretty easily which would be far more reliable than free options, but understandably not everyone has a bank account
is oracle free?
They've got a free tier
No tag orcale found.
?tag oracle
iirc they just give away their unused machines away for free each month
Oracle Cloud Always Free Tier
☑️ 2 virtual machine with 1/8 OCPU and 1 GB RAM each
☑️ 2 Block Volumes, 100 GB total. 10 GB Archive Storage
☑️ Outbound Data Transfer: 10 TB per month
For more info check: https://www.oracle.com/cloud/free/#always-free
how good is render.com?
haven't tried it personally, but have heard positive reviews from others
Why i get this error, again?
ummm ima use a google text file again
The above exception was the direct cause of the following exception: Traceback (most recent call last): File "C:\Users\danie\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\bot.py", line 1009, in invoke_applica...
is this a one-time thing?
yes
Is it possible to defer an interaction, then send a modal to it afterwards?
Not sure if this is the correct place to ask -- can anyone explain what the difference is between on_thread_remove and on_thread_delete? Looking at the lib, 'remove' scans through threads while 'delete' relies on an actual delete event. When would I need to use on_thread_remove, then?
EDIT: nevermind, I assume this is to do with how archiving works, and 'thread_remove' is dispatched when a thread is archived?
nope. modals can only be sent on an initial response to an interaction. You can however send a followup message with a button that will respond with a modal.
Not quite, it's ordered a bit oddly in the docs but thread_remove is when the bot is removed from the thread and thus can no longer see it, while thread_delete is actual deletion. Archiving can indeed lead to remove being fired, but it isn't the sole cause.
gotcha, thank you!
when i use self.bot.unload_extensions i can still use the slash commands in the cog
is this indended behavior?
do i understand the command incorrectly
nope.
If you can reproduce it, feel free to submit an issue on github
how to read the data from on_raw_message_edit event
i get this error
new_page = msg.data.embeds[0].description.split("\n")[-1].split(" ")[-1].split("/")[0]
AttributeError: 'dict' object has no attribute 'embeds'
for some reason, this is being thrown:
File "/home/container/.local/lib/python3.9/site-packages/discord/webhook/async_.py", line 213, in request
raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 40060): Interaction has already been acknowledged.```
it happens when a command is called
the command is doing what it is expected to do and flufills it but this stil comes up for some reason
it happens in both commands where i ctx.defer() first and where i don't defer
im getting this error(yes ik it has my name but idc)
that's a pymongo error
most likely bad auth, check your username or password ig
oh
show the command then
and this happens
we can use dot operation on dict right
so why this error when there is a 'embeds' key
?
Anyone can refer me a good bot host? (for free if possible)
Oracle or GCP free tier. Or self hosting
there are some other options but i dont remember
they are safe right?
yep they are
i personally self host my own bots, and they run as docker containers
actually the thing is I can't keep my laptop on continuously
so I need some good once to host
thanks for your help
np
also one more thing
yes ?
with Oracle, I can connect to outside services like mongoDB and stuff right?
probably yeah
ok thanks
np
why do I get this error?
Traceback (most recent call last):
File "c:\Users\user\OneDrive\Desktop\Chores\VS Code\programs\discordpy bot\raeger.py", line 1, in <module>
import requests, random, json, base64, asyncio, discord, time
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\__init__.py", line 64, in <module>
from . import utils
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\utils.py", line 28, in <module>
from .cookies import RequestsCookieJar, cookiejar_from_dict
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\cookies.py", line 164, in <module>
class RequestsCookieJar(cookielib.CookieJar, collections.MutableMapping):
AttributeError: module 'collections' has no attribute 'MutableMapping'```
Im trying to use the bridge group with cogs and get error about missing callback argument. you can check previous msgs here. #general message and #general message
Why don't I get my function option when I use them inside a slashcommand group
no option shows up
ping me if need more details or traceback
I keep getting this error een when I copied the code from official docs
Ignoring exception in on_interaction
Traceback (most recent call last):
File "C:\Users\.\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 127, in wrapped
ret = await coro(arg)
File "C:\Users\.\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 1201, in _invoke
await command.invoke(ctx)
File "C:\Users\.\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 356, in invoke
await self.prepare(ctx)
File "C:\Users\.\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 278, in prepare
if not await self.can_run(ctx):
File "C:\Users\.\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 373, in can_run
local_check = cog._get_overridden_method(cog.cog_check)
AttributeError: '_MissingSentinel' object has no attribute '_get_overridden_method'```
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\.\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 1009, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\.\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 359, in invoke
await injected(ctx)
File "C:\Users\.\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: AttributeError: '_MissingSentinel' object has no attribute '_get_overridden_method'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\.\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 382, in _run_event
await coro(*args, **kwargs)
File "C:\Users\.\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 1058, in on_interaction
await self.process_application_commands(interaction)
File "C:\Users\.\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 756, in process_application_commands
await self.invoke_application_command(ctx)
File "C:\Users\.\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 1013, in invoke_application_command
await ctx.command.dispatch_error(ctx, exc)
File "C:\Users\.\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 401, in dispatch_error
File "c:\Users\.\OneDrive\Desktop\Chores\VS Code\programs\discordpy bot\raeger.py", line 203, in on_application_command_error
raise error
File "C:\Users\.\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 1009, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\.\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 359, in invoke
await injected(ctx)
File "C:\Users\.\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: AttributeError: '_MissingSentinel' object has no attribute '_get_overridden_method'```
and I don't even know what is wrong
heellllpp
updated code for reference:
Switch to version 2.0.1
will the devs not fix this issue?
Dk im still using 2.0.1 and all works
ok
Any help?
It is a dict....
I see it was a feature in js
I know i printed that too but was just i didnt know dot operator does not work in python dict
hey, is it possible to read print outputs from the console?
Hey Im using bridge command. and trying to run command like this. !nutrition word1 word2. During this the variable's value is word1... But with the slash command variable's value is word1 word2 . So is this expected behaviour ?
@bridge.bridge_command()
async def nutrition(self, ctx: bridge.BridgeContext, food: str):
print(food) # Prints `word1` with prefix command but `word1 word2` with slash command.
Is it possible to have a Slash Command in all servers except one, without listing all the servers and without having intents?
is this library blocking for pycord: https://pypi.org/project/googletrans/
pretty sure
do you know any async alternatives to this
i am trying to implement a translate command, but cant find any api which is free or any wrapper which is asynchronous
nope. I've tried searching and can't find a good alternative
oh damn
Is there a way to execute a Slash Command if "A or B" is true?
The current code only works if "A and B" is true.
@commands.is_owner() # A
@commands.has_role("Contributor") # B
I believe it is has_any_roles
IIRC
It still goes through Roles, which isn't ideal for my case.
This code used to work a few months ago when i made the command, but now it just throws an error.
await ctx.send_modal(modal)```
Error:
```Application Command raised an exception: AttributeError: 'ApplicationContext' object has no attribute 'send_modal'```
What would it return id there is not a mention at all? (Would check myself but can't currently)
what you can do is, make sure that the you and the Contributor have different role for example
1234 - Your Role ID
4567 - Contributor Role ID
@commands.has_any_role(1234, 4567)
I think this should work
you don't need to have the
@commands.is_owner()
since if you have that, I believe that'll then raise an error etc
my bot registers slash commands as new slash commands when i host it somewhere else
is there a way to fix it?
commands.check_any
https://docs.pycord.dev/en/master/ext/commands/api.html#discord.ext.commands.check_any
takes a list of check functions
False
Can someone help me?
import datetime, time ---#this is the important set for generating an uptime
from discord.ext import commands
#this is very important for creating a cog
class Uptime(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.Cog.listener()
async def on_ready(self):
print(f'{self} has been loaded')
global startTime --------#global variable to be used later in cog
startTime = time.time()--# snapshot of time when listener sends on_ready
uptime = str(datetime.timedelta(seconds=int(round(time.time()-startTime))))
@commands.slash_command(description="Get the bot uptime")
async def uptime(self,ctx: discord.ApplicationContext):
embed = discord.Embed(
description=f"(uptime)",
color=discord.Colour.blurple()
)
embed.set_author(name="Uptime", icon_url="https://cdn.discordapp.com/avatars/836895718563250196/cafaf0d749d1aaa938f8c0bd7be4fa2d.png?size=1024")
await ctx.respond(embed=embed)
def setup(bot)
bot.add_cog(Uptime(bot))```
what are you putting as the decorators?
It's showing error
please learn python. - isn't a valid key character.
in other words, remove -s
at the uptime = str(datetime.timedelta(seconds=int(round(time.time()-startTime))))?
Alr
also please use an IDE like Visual Studio Code
@discord.slash_command
I meant with the arguments
this is from one of my commands but they're pretty much the same @discord.slash_command(name="leaderboard", description="Check who's on top!")
when you mean register as new commands, the same command is registered twice?
this is the situation:
I have a slash command group with manage server default permissions
I override the permissions in a server
I hosted my bot in a new place
The slash commands are registered as new commands with the old ones being replaced
This resulted in the slash command group using back the default permission
sounds like working as intended
so this is normal?
yeah
when declaring the view, set timeout=300
So like this: my_view = discord.ui.View(timeout=300)
You have to override the on_timeout method
Thank you! I was so close to find it yet so far. 
how can we make such long buttons in pycord?
unicode spacers
Copy ⬇️
Accept
no
hey
original file size
file after pillow modifications (no change to resolution)
is there a way to lower this size quickly?
So its not useful for chrcking if it's a failed mention?
hey, is it possible to run the discord bot without a listener? so i can run a second instance of the bot just to send updates in dm
by making the image quality less
why would you need a second instance for that?
on a button click im creating a google cloud function
and i want that cloud function to send updates of the process in the persons dm
could you not create it as a task and start it on button click instead?
you mean within the discord bot?
yes
nope it needs to be scalable
cloud function is the best way for what im trying to achieve
using a second instance of your bot is the opposite of scalable
why tho? if i do it without a listener
if you want to override every single listener to do nothing then go ahead i guess, but in general with the presence of interactions in the api having two instances at once is bound to lead to issues
also when just sending updates to a dm?
?
i just want the cloud functions part to just send an update to dm nothing more
if it could be a simple http request itd be sufficient
if you're gonna do it over http then you'd be better off referring to the official docs or another library that's specialised for them
https://discord.com/developers/docs/
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
would you recommend me doing it that way? and do yk if pycord has support for just requests built in?
afaik we don't have any functions to do it for you, you'd need to dig through the lib files to find what you want
it was somewhat discussed in a suggestion at #970398410790297730 message, but we can't really help you further than that
why not
if "@everyone" in message.content and ctx.mention_everyone == False:
that means there was a failed mention
ty!
https://github.com/hikari-py/hikari
has anyone here tried this package?
yes it's a fascinating python discord api wrapper library
thanks! ill try to use this then to send the updates to dm
you can ask for help in their support server
nice will join it
How can I sync Channels with the Category permission or is that automatic?
if it's created in the category it should already be synced, but if not you can do it via edit
https://docs.pycord.dev/en/master/api.html#discord.TextChannel.edit
I create them in the category
why my button won't disable after press
@discord.ui.button(label="Claim", emoji="✒️", custom_id="button_3", style=discord.ButtonStyle.gray)
async def button_3_callback(self, button, interaction):
button.disabled = True # set button.disabled to True to disable the button
button.label = "claimed!" # change the button's label to something else
embed = discord.Embed(title="Ticket claimed!", description=f"{ticket_user} you will be supportet now by {interaction.user.mention}")
await interaction.channel.send(embed=embed, delete_after=10)
embed1.remove_field(index=0)
embed1.add_field(name="Support Status:", value=f"{ticket_user} is supported by {interaction.user.mention}")
await embed1_send.edit(embed=embed1)
ticket_topic = f"supported by {interaction.user.name}"
channel = await interaction.channel.edit(topic=f"**User:** {open_ticket_topic_user_name} \n**User-ID:** {open_ticket_topic_user_id} \n**Status:** {ticket_topic}")
await interaction.response.edit_message(view=self)```
oh
hold on, it shoudl disable after 300 seconds after the last use, as per the docs:
Timeout from last interaction with the UI before no longer accepting input. If None then there is no timeout.
coroutines = [webhook.send(embed=embed) for webhook in webhook_list]
await asyncio.gather(*coroutines)```
~~Is there any way to put a try in the webhook.send part?~~
Adding ``return_exceptions=True`` seemed to have work in ``asyncio.gather``
How to I make a ctx.respond mention (just using role.mention doesn't ping and allowed_mentions doesn't help)?
Is your response ephemeral?
no
webhooks can't ping
so use ctx.send
ohhh I see
so it's not possible to make it look like a response to a slash command, right?
Alright, thank you!
ohh fair yeah
Good evening. I want to learn pycord. Does anyone have any ideas on the best way to learn this?
?tag guide
Thx
yw
Is it also in German? I can speak English, but you don't want to misunderstand me. xD
We don't have translations at the moment.
OK, too bad.
If you don't understand anything, feel free to ask.
👍
What's the cog attribute in SlashCommand used for? My commands don't have it but maybe I should add it. 
Link: https://docs.pycord.dev/en/stable/api.html?highlight=raw_mention#discord.SlashCommand.cog
to get the command's cog
Hmm, I see. I don't need that, so maybe it's fine to keep it None.
interaction.response.is_done()
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In data.components.0.components.0.options.1.emoji.name: Invalid emoji
what does tis error mean
all emojis are valid
i mean they exist
send code thanks
why not
its getting deleted
send in DMs
Okay
@bot.slash_command(name = "find",description = "Seach Pokemon dex entries!")
async def find(ctx, pokemon: str):
p = pokeinfo(pokemon)
print(p)
if p != None:
x, y, all_ab, all_type, img = p[0], p[1], p[2], p[3], p[5]
HP, attack, defense, spatk, spdef, speed = p[4]["hp"], p[4]["attack"], p[4]["defense"], p[4]["special-attack"], p[4]["special-defense"], p[4]["speed"]
embed = discord.Embed(
title=f"{pokemon.capitalize()}",
description = f"Pokedex result for **{pokemon.capitalize()}**:",
color = random.choice(c_lists)
)
embed.add_field(name= "Weight:", value= f"{x}", inline = True)
embed.add_field(name= "Height:", value= f"{y}", inline = True)
embed.add_field(name= "Abilities:", value= f"{all_ab}", inline = True)
embed.add_field(name= "Types:", value= f"{all_type} ", inline = True)
embed.add_field(name= "HP:", value= f"{HP}", inline = True)
embed.add_field(name= "Attack:", value= f"{attack}", inline = True)
embed.add_field(name= "Defense:", value= f"{defense}", inline = True)
embed.add_field(name= "Special-Attack:", value= f"{spatk}", inline = True)
embed.add_field(name= "Special-Defence:", value= f"{spdef}", inline = True)
embed.add_field(name= "Speed:", value= f"{speed}", inline = True)
embed.set_thumbnail(url = img)
await ctx.respond(embed = embed)
elif p == None:
await ctx.respond("Not Found!")```
i keep getting the error on the last respond line
pokeinfo is a helper function*
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 911, in _invoke
await self.callback(ctx, **kwargs)
File "c:\Users\casho\OneDrive\Desktop\Chores\VS Code\programs\discordpy bot\raeger.py", line 723, in find
await ctx.respond("Not Found!")
File "C:\Users\casho\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\context.py", line 275, 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 796, in send_message
await self._locked_response(
File "C:\Users\casho\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\interactions.py", line 1057, in _locked_response
await coro
File "C:\Users\casho\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\webhook\async_.py", line 221, in request
raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
The above exception was the direct cause of the following exception:
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: NotFound: 404 Not Found (error code: 10062): Unknown interaction
anyone can tell why am I getting this error
insert ctx.defer() as your first line in the command
it is fixed
thanks for the response though
now my question, can I automatically delete a component/embed message on timeout?
probably do asyncio.sleep(time)
