#Basic Pycord Help (Quick Questions Only)
1 messages Β· Page 50 of 1
i am going to make a new .env
Ok
Please donβt cross post next time.
ok sorry
can i remove a command using a command?
Slash command or prefix command?
slash
Like disable it?
.rtfm bot.remove_application_command
discord.ext.commands.Bot.remove_application_command
discord.ext.commands.AutoShardedBot.remove_application_command
discord.ext.bridge.Bot.remove_application_command
discord.Bot.remove_application_command
discord.ext.bridge.AutoShardedBot.remove_application_command
discord.AutoShardedBot.remove_application_command
does anyone know a way to make a drop down menu of a list of all members of the server?
.rtfm member_select
Target not found, try again and make sure to check your spelling.
.rtfm user_select
Does anyone knows How to fix this problem I want to place that file into that url what should I do
embed.set_image(url=file=discord.File("text.png"))
.localfile
just a squid how can i set that a a varible?
url=file=?? Syntax error?
?tag localfile
f = discord.File("some_file_path", filename="image.png")
e = discord.Embed()
e.set_image(url="attachment://image.png")
await messagable.send(file=f, embed=e)```
Yes
No
I wanna place that file in
And I can use = like url=file=
would i use user = discord.ui.user_select for it
so how can I just place that picture
@viral hazel
ohk i'll try thanks
i got it to work where it is set as a varible but how do i make it a menu so u have to choose a user? bc i can't find it on the documentation
just like a normal ("string") select menu
select.values?
@silver moat can you pls come to vc and help me out I am still having a lil problem can you pls guide me ?
I wont take much time
sure why not
TYSM
Will it be faster with the new Version?
what will be faster with what version
the file image for an embed
how can i get a selected channel in a discord.ComponentType.channel_select
select.values or self.values depending on the scope
code:```
async def dropdowncallback(self,interaction):
channel = self.values[0]
print(channel)
channel.send("This is a test")
#test command
@bot.command()
async def test(ctx:ctx):
guild=ctx.guild
dropdown = channelDropDown()
dropdown.callback = dropdowncallback
view = discord.ui.View(dropdown)
await ctx.send("This is a test", view=view)```
error:
Traceback (most recent call last):
File "C:\Users\Fammy\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ui\view.py", line 414, in _scheduled_task
await item.callback(interaction)
TypeError: dropdowncallback() missing 1 required positional argument: 'interaction'```
can anyone help???
Remove self. You are not inside a class
but i want value from the select
Subclass?
oki lets try it out
I suggest subclassing everytime you use a view. Imo it makes it much cleaner and easier to access things.
Is it possible to make an permissions override so that the bot owner can run every command?
.rtfm check_any
is there a way to get the server profile?
yes
how
Models are classes that are received from Discord and are not meant to be created by the user of the library. Attributes key, url. Methods def is_animated, async read, def replace, async save, def ...
How do I get the ID of the user who sent the slash command
Why do i get an error message? embed.set_thumbnail(url=ctx.guild.icon.url)
"an error message" is useless. show the error message
Application Command raised an exception: AttributeError: 'NoneType' object has no attribute 'url' The Error
It's pretty self-explanatory, the guild doesn't have an icon
Not Pycord itself, but is anyone familiar enough with direct webhook posting. If I have a fields[] list and have a conditional second field, could I just pass an empty string? e.g.
fields = [
{'name': 'ABC', 'value': '123'},
{'name': 'DEF', 'value': '456'} if some_condition else ''
]
This would result in a list of
[
{'name': 'ABC', 'value': '123'},
''
]
I'm guessing this won't work, but I'm trying to be lazy. Could change that to None if that might work
#tryitandsee says no π¦
How can I delete multiple messages at once?
.rtfm TextChannel.purge
Hi, I feel like I'm missing a leading ctx. before create_scheduled_event or something obvious, as my code is failing at that point
StartTime = datetime.strptime("2023-01-13 11:55", '%Y-%m-%d %H:%M')
EndTime = datetime.strptime("2023-01-13 14:00", '%Y-%m-%d %H:%M')
# I put in lots of print statements, and code fails here:
await create_scheduled_event(name="Test", description="test text", start_time=StartTime, end_time=EndTime, location="https://twitch.tv")```
(the bot does have permission to create/manage events, other commands are all working well)
.rtfm create_scheduled_event
ctx.guild.create_scheduled_event
I was sure I'd tried that. THANK YOU - Fixed.
yw
when i make a dropdown menu is there a way to have the discord bot be able to see all users? or would i have to code each one in
.rtfm user_select
i did that but how do i input that into the code i set it as a varible that did not work it made u type the full name in and not show users
Show what you did
sync def test(interaction: discord.Interaction, user = discord.ui.user_select ): i don't think this is right
what part of the guide is it in?
would i have to make a class of options or is there a way for the bot to know the user names already?
If you want to select a member in a Slash cmd, you have to typehint the parameter as member: discord.Member
Or use @option or the Option typehint
would that make it so u could choose members in the server?
ok
If you want to be able to select more, you can use the user select menu
tysm i am just going to work on it so i can cut off the # part of it
ππ
am i using the extras cooldown right? doesnt seem to be working to not allow more then 3 per 30 seconds
from discord.ext import commands
...
@commands.slash_command(name='mention', extras={'cooldown':commands.Cooldown(3, 30)})```
this is the documentation i'm looking at
https://docs.pycord.dev/en/stable/ext/commands/api.html#discord.ext.commands.Command.extras
whatβs the issue with using the cooldowns decorator?
oh, didnt know there was one, let me give it a go
cool that worked, but sometimes I have issues figuring out what the naming convention is on decorators because it's different in a cog... dunno guess something I'll keep fiddling around with and figuring it out
thanks!
it nextcord there is a way to get the auther who sent a command is there a way in pycord to do that?
ctx.author?
tysm i was spelling author wrong i spelled it like auther
@bot.command
async def wanted(ctx, user: discord.User = None):
if user == None:
user = ctx.author
wanted = Image.open("wanted.jpg")
data = BytesIO(await user.display_avatar.read())
pfp = Image.open(data)
pfp = pfp.resize((177, 177))
wanted.paste(pfp, (120, 212))
wanted.save("profile.jpg")
await ctx.reply(file=discord.File("profile.jpg"))
``` File "c:\Users\\OneDrive\Desktop\Documents\bot\Main.py", line 27, in <module>
async def wanted(ctx, user: discord.User = None):
TypeError: ApplicationCommandMixin.command() takes 1 positional argument but 2 were given idk what this error means
it should be @bot.command()
also, if you are doing an error, I recommend opening a new thread
lol that too, how did i not see that
maybe because I've been helping people longer than you have?
that has nothing to do with it
i think im just half-awake lol
yep im typing in lowercase
definitely half-asleep
ty did not see that
await ctx.reply(file=discord.File("profile.jpg")) when i run the command the new image does not get sent
ges\Python310\site-packages\discord\commands\core.py", line 132, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'ApplicationContext' object has no attribute 'reply'
ctx.respond
when I get the error where I reached my max daily command limit (200) from restarting the bot too many times, what time does that refresh? like midnight utc?
Can i use button and select menu
can anyone pls give a sample code
I want cat API for my discord bot I tried many of the cat API's but it didn't work
Dude, don't ping people to help you
And saying "didn't work" is completely useless, explain what's not working instead
@bot.command()
async def cat(ctx):
r = requests.get("https://api.thecatapi.com/v1/images/search")
res = r.json()
em = discord.Embed()
em.set_image(url=res['message'])
await ctx.send(embed=em)
``` can anyone tell me why this code's API is not working
The API

I can't help with it
in what way is it "not working"?
And you're not getting any errors?
No
First of all don't use the requests library in an async environment
then how will I make commands for bot ?
?tag requests
Why you should not use the requests library for your bot
requests is a popular HTTP library for Python. It is however not a good option for Discord bots, since it is not async and blocking.
This essentially means that your bot will not be able to execute any code at all while a request is happening. Since requests usually take a few seconds to complete, this can have a detrimental effect on your bot's performance. E.g if a user executes a command that performs a request taking 5 seconds to complete, no one else will be able to use your bot for those 5 seconds.
Please look at using a HTTP library that has async support, such as aiohttp or httpx
It is however not a good option for Discord bots ?
???
okayy
what?
I mean how to do this one ?
Yes i know
that's what i was asking
asiohttp or httpx ?
I still don't know what "this one" means
??????
Because your questions don't make any sense
I am trying to but i am new got here for help
Okay?
Like without requests how can i use aiohttps or httpx that's my question for now
Use google and read the docs
You really needed me to tell you to use google? 
Umm hmm
That's the source code of the function, you're not supposed to use that to learn.
https://docs.pycord.dev/en/stable/api/data_classes.html#discord.PartialMessage.pin
The search feature of the docs is pretty bad tbh, so you have to click around until you find the right link
Hey all, how can I make a custom function to authorize/unauthorize a commande ?
(I have a function inside my COG who returns a boolean based on the guildId and the memberId)
what? Where you use it doesn't matter, it's a method on a PartialMessage class
?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.
Would it be possible to return the user's input on a modal dialog to the function calling said modal dialog? π€
use checks?
yes. use modal.wait()
.rtfm modal.wait
haha ikr
its cool
Although keep in mind
it also fires for timeout
so check that values are present before using them
no worries
Can you access the auth'd Reddit username of a User?
No, bots can not see that info
ah, damn. Ok, tyvm
why isn't this working?
from discord.ext import commands
import asyncio
import random
import json
class automod(commands.Cog): # create a class for our cog that inherits from commands.Cog
# this class is used to create a cog, which is a module that can be added to the bot
def __init__(self, bot): # this is a special method that is called when the cog is loaded
self.bot = bot
@discord.slash_command(description="Activate a premium subscription with a code")
async def automod(self, ctx):
authorr = ctx.author
with open("automodguilds.json") as f:
autmodguild = json.load(f)
if guild.id not in automodguild:
automodguild.append(self.guild.id)
await ctx.respond("Enabled automod, saving settings...")
elif guild.id in automodguild:
automodguild.remove(self.guild.id)
await ctx.respond("Disabled automod, saving settings...")
with open("automodguilds.json", "w+") as f:
json.dump(codes_list, f)
await ctx.respond("Settings saved!")
def setup(bot): # this is called by Pycord to setup the cog
bot.add_cog(automod(bot)) # add the cog to the bot```
It says guild isn't defined
- Don't use json as a database
- What is
self.guild?
And why are you trying to do guild.id without defining guild?
I tried to use ctx.guild as well. And I know that I shouldn't use json as a database. How would I define guild then?
ok, I tried that and it worked, thanks. Now with this code;
from discord.ext import commands
import asyncio
import random
import json
class automod(commands.Cog): # create a class for our cog that inherits from commands.Cog
# this class is used to create a cog, which is a module that can be added to the bot
def __init__(self, bot): # this is a special method that is called when the cog is loaded
self.bot = bot
@discord.slash_command(description="Activate a premium subscription with a code")
async def automod(self, ctx):
authorr = ctx.author
with open("automodguilds.json") as f:
automodguild = json.load(f)
if ctx.guild.id not in automodguild:
automodguild.append(ctx.guild.id)
await ctx.respond("Enabled automod, saving settings...")
elif ctx.guild.id in automodguild:
automodguild.remove(ctx.guild.id)
await ctx.respond("Disabled automod, saving settings...")
with open("automodguilds.json", "w+") as f:
json.dump(automodguild, f)
await ctx.respond("Settings saved!")
def setup(bot): # this is called by Pycord to setup the cog
bot.add_cog(automod(bot)) # add the cog to the bot```
I get this error though; Application Command raised an exception: JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Like I said, don't use json as a database
I know, I am going to switch to sql soon, but I just want to get all the basic code working first
π€·ββοΈ too bad, you probably corrupted your json file somehow and now your code can't read it
hence why you shouldn't use json as a database
Do you guys have any idea why a user on android mobile (and seemingly only that platform) wouldn't be able to see a particular button? The only vaguely interesting/unusual thing about the button is it has an emoji and it's a timeout=None permanent one.
Are they using an old version of Discord?
that could be the case
I'll tell them to update and post back just for posterity
Yup, that was it, thanks
Hello i have a problem
Quick API question, what is the maximum number of overwrites a channel can have?
discord.ext and then command
Hey, is there a way to send multiple attachments in the same reply to a command?
Also, how can i use set_image with an embed and an attachment image?
files = list_of_files
what does that mean?
Discord.embed.set_image wants an url but I want to add a local image
f = discord.File("some_file_path", filename="image.png")
e = discord.Embed()
e.set_image(url="attachment://image.png")
await messagable.send(file=f, embed=e)```
what am I doing wrong here?
await message.delete()
await message.channel.send("Please do not mass mention people :skull:")```
.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.
I don't get any errors or anything from it
what is the problem
well, I'm trying to make so that if you mention more than 5 people here, it will delete the message
but, it doesn't do anything
is this in on_message?
yes
do you have intents?
yeah, all intents. This is in a cog though
Add a few print statements. Or run a debugger
And see till where code is being executed
ok
Don't name the class and the Slash group the same. Use CamelCase for the class
isn't camelCase like this?
Also, you are trying to access a function of a different class from a different class
Hmm not sure. One sec
ok, I got a error now; TypeError: '>' not supported between instances of 'list' and 'int'
Ohh right
camelCase PascalCase
Use pascal case
Alright that's progress. Full traceback?
Traceback (most recent call last):
File "/home/container/.local/lib/python3.8/site-packages/discord/client.py", line 377, in _run_event
await coro(*args, **kwargs)
File "/home/container/cogs/automod.py", line 54, in on_message
if message.raw_mentions > 5:
TypeError: '>' not supported between instances of 'list' and 'int'
.rtfm discord.message.raw_mentions
Define it outside both the classes?
you should use len(message.raw_mentions)
yw
Why not
do you know basic python?
okay, so now when I try to add a timeout function as well await message.author.timeout_for(timedelta(minutes=15)) I get this error; discord.errors.ExtensionFailed: Extension 'cogs.automod' raised an error: ModuleNotFoundError: No module named 'timedelta'
I couldn't find much online on timing out members, am I doing something wrong?
from datetime.datetime import timedelta?
what are you doing-
if you put functions out of the cog class then you cant use self
show what you are doing 
that's not what they meant
PascalCase for classes since that's the industrial practices I believe for classes itself, what you'd do in this case is
class emojiquiz():
...
to
class EmojiQuiz():
...
not rename the classes to literal Camel
for vars I believe you can make it so it's like
emoji_quiz = ...
Om confirm?
since the func is outside a class, it cannot use self
you should rather accept a connection in random_emoji() and do this part async with self.bot.pool.acquire()as conn: at the places you want to use it
you can get the bot instance from interaction.client
kurwa since when
mhm snake_case . its a convention tbh, good if you follow, not wrong if you dont
so random_emoji should look like this
async def random_emoji(conn):
and wherever you want to use it, do
async with bot.pool.acquire() as conn:
result = await random_emoji(conn)
You clearly don't know basic python

They have been told multiple times, but it doesn't seem like they want to accept it
Hello I am getting this error while using @client.group(name="help) :-
discord.ext.commands.errors.CommandRegistrationError: The command help is already an existing command or alias.
Even when I am not supposed to
There's already a help command built in
You must remove it or pass your command to the bot initialization
ohkayy I knew that but was not sure. Now i can search and solve it thank you
bot.remove_command('help') It's this simple
Can anyone tell me why my embeds are not working in groups ?
@bot.group(name="help", invoke_without_command=True)
async def help(ctx, member:discord.Member = None):
if member == None:
member = ctx.author
embed = discord.Embed()
Because you're not even sending the embed?
no i am sending it its the top one
Now I am doing it with command and still not working
@bot.command()
async def help(ctx, member:discord.Member = None):
if member == None:
member = ctx.author
name = member.display_name
pfp = member.display_avatar
embed = discord.Embed(title="Geniot Help", description="Here are commands for Geniot\nDon't forget to use prefix before command (g#)", color=discord.Color.blurple())
embed.set_author(name=f"{name}", icon_url=ctx.author.avatar)
embed.set_thumbnail(url=f"{pfp}")
embed.add_field(name=f"dog", value=f"This command shows you cute pictures of dog")
embed.add_field(name=f"8ball", value=f"You can ask a question from the bot", inline=False)
embed.add_field(name=f"ping", value=f"This command shows you the response time of Geniot", inline=False)
embed.add_field(name="**If you want more detail on a particular command, Type: **", inline=False)
embed.set_footer(text=f"Requested by {name}")
await ctx.reply(embed=embed)
Once again, "not working" is useless
No error Nothing
its just not replying on discord
and also I am using this command above to remove the initial help command:-
bot.remove_command('help')
will it effect ? on this command too ?
where are you having that? before creating your command or after?
before
do you have message content intent in both, the code and dev portal?
Yes I have tested this bot's command multiple times
Are webhooks currently broken?
add a few print statements or run a debugger to test till where the code is being executed
Ok
not that i have heard of others reporting the same
are you having any issues?
@proud mason I found it idk why but issues are in add_field command
i tried using dishook for an embed but the send button was greyed out, tried with another site and it didnt send. I suspect the same thing would happen if i used it with pycord
here
I'll try in a bit, but i'm not sure
you dont have a value
also read #help-rules
ahh beat me to it 
oh thank youuu
Yes thank you
.tias
ok it does work
Are button cooldowns built-in or will I need to handle it myself?
Great thanks :)
Is their a ways to deactivate certain commands while the bot is getting ready (before the on_ready event) ?
all commands are disabled before on_ready.
they are not, I can use them and the bot responds to them even before on_ready is called
if the bot is in a lots of servers, it take minutes before on_ready is called, and commands are not disabled in that time
commands as in app commands or text-based?
slash commands
in on_interaction https://docs.pycord.dev/en/master/api/clients.html#discord.Bot.is_ready
Bots: Attributes activity, allowed_mentions, application_flags, application_id, auto_sync_commands, cached_messages, cogs, debug_guilds, description, emojis, extensions, get_command, guilds, intent...
and return if it is not.
if it is bot.process_application_commands
I see thanks you !
Do on_connect() is call when pycord reconnect to discord after for exemple a shortage of internet
This section outlines the different types of events listened by Client. There are two ways to register an event, the first way is through the use of Client.event(). The second way is through subcla...
thanks !
await message.edit(content="") this code is not working the message part is giving errors
?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.
there is no error it just refuses to load this part and message in yellow underneath
i can't rly describe what happens but it is fine if u can't bc the code is not rly needed but would make it so i don't need to right more
i am going to just delete it
@client.slash_command(name="gib")
async def gib(ctx):
role = ctx.guild.get_role(1041224580968230922)
print("trying to run loop")
await ctx.respond("ok")
for member in ctx.guild.members:
print("checking " + member.name)
if role in member.roles:
pass
else:
try:
print("trying to add role to " + member.name)
await member.add_roles(role)
except:
pass
This is only prints
trying to run loop
checking Test Bot
checking LegoScrap
and stops. and I can't figure out why. There are 200 other people in the server
you may get a rate limit
but after 2 requests why would it block it forever while the bot is still running
do you have intents?
yeah
which one?
what is the value of ctx.guild.members?
was just about to check that
that would make sense why, it only has me and the bot for some reason
the bot has admin and should be able to see everyone
how are your intents applied?
oh wait im dumb
this was a separate file for the bot, and I forgot to enable them before defining client
thanks
ok
could someone tell me the name of the little "Select a result" bar? i need to search the docs for it
.rtfm select_menu
Target not found, try again and make sure to check your spelling.
.rtfm select
discord.ui.select
discord.ui.Select
discord.ui.Select.add_option
discord.ui.Select.append_option
discord.ui.Select.callback
discord.ui.Select.channel_types
discord.ui.Select.custom_id
discord.ui.Select.disabled
discord.ui.Select.from_component
discord.ui.Select.is_dispatchable
discord.ui.Select.is_persistent
discord.ui.Select.max_values
discord.ui.Select.min_values
discord.ui.Select.options
discord.ui.Select.placeholder
discord.ui.Select.refresh_component
discord.ui.Select.refresh_state
discord.ui.Select.row
discord.ui.Select.to_component_dict
discord.ui.Select.type
thank you, you are a goat squid π
yw
none of my commands are syncing, and i have no idea what to do to fix it. can i have some ideas?
.slashnoshow
Checklist for Application Commands Not Showing Up:
β’ Does your bot have the application.commands scope?
β’ Are you loading cogs before on_ready and on_connect?
β’ Is on_connect not overridden?
β’ Did you update to the newest version of py-cord (tag: install)?
β’ Is User Settings > Accessibility > Chat Input > Use legacy chat input turned off?
β’ Did you share your code and errors?
β’ Do you still have libraries that conflict with the discord namespace (e.g. discord.py)?
I am in a discord server where the commands are being synced. But they don't appear anywhere. All the permissions, scopes are given. What's wrong with this?
There are 14 other bots that have slash commands in that server
Can anyone send me pycord api reference link
.rtfm e
discord.Team
discord.Team.icon
discord.Team.id
discord.Team.members
discord.Team.name
discord.Team.owner
discord.Team.owner_id
discord.File
discord.File.close
discord.File.description
discord.File.filename
discord.File.fp
discord.File.reset
discord.File.spoiler
discord.Game
discord.Game.created_at
discord.Game.end
discord.Game.name
discord.Game.start
discord.Game.to_dict
Are there more than 50 bots in the server?
is there any way to access variables defined in initialization of a class?
I was under the impression that something like self.x or cls.x would work, but it returns undefined when trying to reference in @discord.ui.select
(Trying to randomize the order of my select menu options)
The self variable won't work inside @ decorator
You can create the select menu in the view init using the select class
And use self.add_item
You need to sync the commands. And slash commands use ctx.respond not ctx.send
how could i use a, old Select after restarting the bot?
ty
Do you have the presence intent enabled?
And how are you getting the member?
So I assume you also have member intents?
Quick question: How do you get ctx.respond to be ethereal when using The Message Commands Context Menu?
As in only you're shown the message and you can dismiss it by pressing the small x
ephemeral = True
How do do I register all the cogs in a for loop? my folders ["commands", "economy"]
.rtfm load_ext
Lots of stuff came up 
Oh well
.rtfm load_extensions
\programing\python\bot\viking bot\tom viking build\viking for tom.py", line 147, in <module>
@bot.slash_command()
AttributeError: 'SlashCommand' object has no attribute 'slash_command'
``` trace back
https://pastebin.com/FrxvTiRT
codΓͺ^^^^^^
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
how do i send the code if its to big
.rtfm pastebin
Target not found, try again and make sure to check your spelling.
this is a on_message event, what am I doing wrong here?
return```
I get this error;
```if message.guild.id not in automodguild:
AttributeError: 'NoneType' object has no attribute 'id'```
is it possible to send inline images in embed or normal text?
Send your intents
I have all intents, that is in a cog though if it makes any difference
2.3.2
Hm
and it's not all the times I send a message I get the error, only a few times
Ah that makes sense although idk why would that be happening either but ig you could make an error handler to it and prevent your console being flooded with that error
ok, thanks π
is it possible to send inline images in embed or normal text?
Is it possible to when using The Message Commands Context Menu that you can show the message that you're using it on?
Like how you can click when replying to a message to go the orginal message
You just did async def bot
What else were you expecting 
Rename the function to something else. If you want you can pass the command name through the decorator
Not directly, but you can use message.reply to send the output you want, and send a separate ephemeral response to the interaction saying something like "Done"
Full error?
Did you add less than 1 or more than 5 input texts?
Is there a example that shows how to dynamically change the select menu,
My goal:
the command is: /settings Command: choice
when u choose, depending on choice the select menu in the follow response should have different results, how do i like use a variable or something to make the select menu change depending on that choice? is there already code for that or a example
yeah i mean not like the autocomplete but like
/settings command: u pick a choice, then the embed has a select menu and the options change based on the results
dankmemer has this on their settings so i assume it is possible
i have an example for something like that on my github
this helps thanks
The autocomplete example on the github shows how to do that @fervent cradle @ancient summit
The function at the bottom
Can't get the bot to link to it rn
Ohhh
Sorry for this being much later.
My guess it they edit the message with a new select menu once the first one gets an input.
how would i add an emoji reaction to an embed I'm currently getting
Traceback (most recent call last):
File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 124, in wrapped
ret = await coro(arg)
File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 980, in _invoke
await self.callback(ctx, **kwargs)
File "/home/container/beta-247-casino-bot.py", line 5367, in poll
await msg.add_reaction("π")
AttributeError: 'Interaction' object has no attribute 'add_reaction'```
embed = discord.Embed(title="Poll", description=question, color=0x00ff00)
embed.add_field(name="Question:", value=question)
embed.set_author(name=ctx.author.name, icon_url=ctx.author.display_avatar)
msg = await ctx.respond(embed=embed)
await msg.add_reaction("π")
Hi, I have a quick question about interactions, how can I edit both a button's contents and the interactions text contents at the same time? My code is as follows currently, I tried using the followup-thing but I do not fully understand it, as this is my first time using PyCord...
ctx.respond returns an interaction, not a message
ooh
Can't you just defer it?
Why using a while loop?
And the follow up:
.rtfm interaction.followup
That while loop is extremely risky lol
The API sometimes times out and returns nothing (i.e times out with a 504), I know itβs bad practice to have such a loop but itβs just a POC for now
Will try figure out a better way to handle the problem
is there a way to get a VoiceClient from a VoiceProtocol?
How can I access permissions that are missing for the MissingPermissions exception?
MissingPermissions.missing_permissions
?
If you mean the api error.. you canβt. You need to calculate that info yourself
Ah
There is this tho https://docs.pycord.dev/en/stable/ext/commands/api.html#discord.ext.commands.MissingPermissions.missing_permissions
The following section outlines the API of Pycordβs prefixed command extension module. Bots: Bot: Attributes activity, allowed_mentions, application_flags, application_id, cached_messages, case_inse...
Idk what pycord does but the info isnβt given back via api. So 
heya got a quick question- i have a simple command to verify a server member and it seems to work but it keeps giving me the error The application did not respond and I'm not quite sure why
@bot.slash_command(name ="verify", description="Mod command to verify new users.")
async def verify (ctx, user: discord.User):
role = discord.utils.get(ctx.guild.roles, name="member")
await user.add_roles(role)
await user.send(
f"Congratulations, you're now verified! Welcome to the server!"
)
you have to respond and use discord.Member and not discord.User
@bot.slash_command(name ="verify", description="Mod command to verify new users.")
async def verify (ctx, member: discord.Member):
role = discord.utils.get(ctx.guild.roles, name="member")
await member.add_roles(role)
await member.respond(
f"Congratulations, you're now verified! Welcome to the server!"
)
like this?
member.respond isnβt a thing
I didn't think it was
you were correct when using member.send, but you need to actually respond to the interaction
My goal is to dm them the message, not send it in server tbc
how do I do that?
you need to respond by sending something in the server, otherwise youβll always run into "The application didnβt respond."
you have to send it, just hide it and send the message "check your dmΒ΄s"
that's a pain
alright
thanks for the help
does it count if I react to the message?
what?
are you aware your using slash commands?
yes nevermind ignore that
https://github.com/Pycord-Development/pycord/blob/master/examples/app_commands/slash_basic.py
^ use this if your unaware on how to respond to an interaction
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - pycord/slash_basic.py at master Β· Pycord-Development/pycord
another question- is there a way to make a command that can be both slash and user command? i worded it terribly, but I'd like to create a command that can be accessed via slash command or the app directory and I can't figure out if there's a more efficient way than just copy pasting the code once for each
Create a separate function and call that from both the cmds
That's the best way
thought so, thanks
Thanks so much for this!
btn1 = Button(label="Go Left", emoji=':left_arrow:')
btn2 = Button(label="Go Right", emoji="π₯")
async def btn1_callback(interaction: discord.Interaction):
await interaction.edit_original_message("works")
btn1.callback = btn1_callback
view = View()
view.add_item(btn1)
em.set_footer(text="use !sell <skin_name> to sell your skins")
msg = await ctx.send(embed=em, view=view)```
whats the problem?
```TypeError: Interaction.edit_original_message() takes 1 positional argument but 2 were given```
content="works"
getting this if i try embed
await interaction.edit_original_message(embed=emm)```
```discord.errors.NotFound: 404 Not Found (error code: 10015): Unknown Webhook```
edit_original_message will edit the message that was responded with which doesn't exist.
you are looking for interaction.response.edit_message
yw
Has anyone had any trouble running the pycharm debugger lately with pycord?
Just from a asyncio.sleep call, I get
Fatal Python error: PyFrame_BlockPop: block stack underflow
Python runtime state: initialized
Hm. Seemingly a known issue. https://youtrack.jetbrains.com/issue/PY-52347
Adding PYDEVD_USE_CYTHON=NO to the debug environment seems to have worked around the problem for the moment.
How to set specific channel permissions for specific user?
I found this docs "https://discordpy.readthedocs.io/en/latest/api.html#discord.TextChannel.set_permissions" but there isn't option to select witch channel to change.
.rtfm channel.set_permissions
I needs a channel object
Which you can get from bot.get_channel
Ah just saw your post.... Please don't crosspost
How can I throw an error to a slash command user that only they can see?
use the ephemeral property on your respond
await ctx.respond("Only the user who used the command can see this!", ephemeral=True)```
.send_response() vs .respond()?
also, how do i make it red?
- like this?
How to make a button that's when pressed send another embed message also with button?
so it will add same buttons to that message
But problem is that I have class it witch there are all variables, channel ids, user ids and other.
(As I understand)
(I have some code)
I want to do that when user clicks 1 of 4 buttons, it creates channel (witch's name depends on witch button user pressed). When channel is created, for bot to send an embed that has button to delete the channel.
Yes
I'm doing it
I know it's stupid not to use existing bot, but I want to be able to modify it
What exactly you mean by "theme"
like. Button 1 creates channel named "role-[number]" (number thing I did my self). Button 2 creates "help-[number]", button 3 creates "bug-[number]" and etc.
Yes
Yes
ok thank you
Hello! I encountered an error on linux. no module named discord.ui. Here is a piece of code: from discord.ui import button, Button, View. Help me pls
(python version: 3.6.8)
You need python 3.8+
okay, thanks
class SuggestionButton(View):
def __init__(self, choice: str, bot: commands.Bot, type_choice: str):
super().__init__(timeout=6)
self.choice: str = choice
self.bot: commands.Bot = bot
self.type_choice: dict[str, list[str]] = {
"Suggestion": [ "Suggestion Button", ":Suggestion:"],
"Review": ["Review Button", "β"]
}
Choice_Button = Button(label=self.type_choice[type_choice][0], style=discord.ButtonStyle.blurple, emoji=self.type_choice[type_choice][1])
self.add_item(Choice_Button)
async def blurple_button_callback(self, button: Button, interaction: discord.Interaction) -> None:
button.disabled: bool = True
So I'm adding the callback for the Choice_Button since by adding the the button via self doesn't trigger the callback. Is there a bug or something that doesn't trigger the callback
You never assign the button.callback to that function?
Isn't it supposed to automatically detect it?
even if I add callback to the function, it comes that I need discord.Interaction
Not if you create the button using the Button class directly
Choice_Button.callback = self.blurple_button_callback
Hmm
So if you do it like that, i believe self would be the button object and the only other parameters would be interaction
I suggest trying this-
Define the callback function outside the class like this
async def callback(button, interaction)
You can access the view object from button.view
Hmmm that would be a problem since I'm using the self.choice. Here I thought I could reduce the classes needed π
Is it possible to host discord py bot on webserver (website)?
can i send dm to every users that uses the bot? (i use commands from dms only)
and also would that cause a ratelimit or a ban?
Try if button.view.choice works
.tias
hmm
Yes you can. bot.users gives you the list of users that the bot has in cache
Yes that will definitely hit ratelimit and you could soon be banned
somehow bot.get_guild(guild_number) is always returning None when I initialize my cog, yet the same exact code works in five other cogs
I am so confused 
Guild data is populated after bot startup. Cog is initialised before startup. Which means you are trying to get guild before the bot starts up, causing it to return None
Yeah I just realized that lmao, looks like I have to fetch_guild in an on_ready block in the cog or something
Thanks Om
Haha no worries
can't do it in init because it's not async 
Well it depends on what you are doing. If you are using on_ready block then no need to fetch guild, because by then the guild data would have been populated
ah true
There are work arounds
now I'm just leaving self.bot = bot in init and adding the other stuff to on_ready in that cog, gonna see if that makes it work as expected
Just in case you want to know,
Create a task loop with count set to 1
Start the task in cog init
Not the best, but works as expected
just use asyncio?
asyncio.create_task yes this works
yeah
Are custom emojis not usable at all in slash commands?
you just need the "Use External Emoji" permissions on the integration role itself.
It depends it looks like it just does the :name: text
I'm not sure if it actually renders the emoji
for me its like "dashyellow:1063476094193381426"
and bot everyone role and my bot has use extermal emoji
yet, still
no format works
is it animated?
does the integration role have that also checked?
https://stackoverflow.com/questions/67862216/discord-py-how-can-get-attachment-in-message-content
I was trying to make a to-do-list channel, where i can archive messages once their task is done.
I found this post on stackoverflow which was pretty much what i wanted.
But the code doesn't seem to work right, and i have no clue why.
@bot.listen('on_raw_reaction_add')
async def todo(payload):
todo_channel_id = ********
guild = await bot.fetch_guild(int(os.getenv('SERVER')))
if (payload.channel_id == todo_channel_id) and (payload.user_id != *********) and (str(payload.emoji) == "π³"):
todo_channel = bot.get_channel(todo_channel_id)
message = await todo_channel.fetch_message(payload.message_id)
finisher = await guild.fetch_member(payload.user_id)
attachments=[await f.to_file() for f in message.attachments]
await message.clear_reaction("π³")
await message.add_reaction("β
")
await message.author.send(f"""{finisher.nick} Ha completato il tuo incarico\n> {message.content}""",files=attachments)
#print(finisher.nick,message.author)
await bot.get_channel(***********).send(f"> {finisher.nick} Ha segnato l'incarico come completato\n\n{message.content}",files=attachments)
await message.delete(delay=3)
My bot correctly makes a new message in the archive channel, and adds to it any attachments present in the task message, but they are all 0 bytes. the file name is correct, but they are just empty.
Shouldn't ".to_file()" get me actually the file?
yes, the bot also has it checked
could you make a post on this? It seems more than a quick question
Thanks π
Does @everyone also have that permission in the specific channel you are testing?
the discord server is literally the default setup Discord provides, as I am only using it to test the bot, so the permission was on "/"
Does the bot have access to the server which the emoji is from?
It is in the server which owns the emoji (hence why my formatting of the emoji is as it is)
I even tried via the bot:
(the code you see is no longer what I use, I just used this to find out if I was getting the IDs wrong)
print(f'[{time.strftime("%X")}][INFO] {ctx.user} asks: {prompt}')
await ctx.response.defer(ephemeral=True)
response = await api.GPT3().get_response(prompt=prompt)
await ctx.followup.send(content="@<dashyellow:1063491896720236604> <dashyellow:1063491896720236604> :dashyellow:", view=views.RetryButton(prompt))```
this is what I have
do you use discord.py?
I just ask because of ```py
ctx: discord.Interaction
in pycord ctx would be discord.ApplicationContext
ah, alright, would I need to modify anything else if I change it (I am porting this from d.py)
just use ctx.defer()?
but it isn't necessary, it's just a short hand for ctx.interaction.response.defer
hm
here the emoji id is 1063476094193381426
I reuploaded it
do you have intents?
I'll try getting the ID again brb
Ah I guess I copied the ID wrong or smth, it worked. Thanks for the help and the other tips.
you're welcome
Help me please. I'm dying...
AttributeError: 'Bot' object has no attribute 'slash_command'. Did you mean: 'add_command'?
Code:
import os
import time
import discord
from discord.ext import commands
from dotenv import load_dotenv
load_dotenv("config.env")
bot = commands.Bot(command_prefix=".", intents=discord.Intents.all())
async def on_ready():
print(f'{bot.user} has connected to Discord!')
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="PAPAI"))
@bot.slash_command(name="cycle", description="saikl")
async def cycle(ctx):
while True:
time.sleep(10)
print(ctx.guild.member_count)
bot.run(os.getenv('BILIETININKAS'))
py-cord version - 2.3.2
(For me slash commands don't work in any files, but for my friend (that has exactly same code) they work perfectly fine)
pip list and send output thanks
I'm not terribly familiar on how to make a decorator, but I wanted to make one to do a "can this command be run in this channel" check and another to do a "do you have roles x y and z" check. Are there any gotchas to adding such decorators to a slash command, any particular order you have to list the decorators in, etc?
I gave it a stab and nothing worked and I got frustrated and gave up so I have no code to show lmao
what does this do? discord.ComponentType.role_select
because it doesnt work for me
Traceback (most recent call last):
File "/home/container/.local/lib/python3.10/site-packages/discord/bot.py", line 997, in invoke_application_command
await ctx.command.invoke(ctx)
File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 359, in invoke
await injected(ctx)
File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 127, in wrapped
ret = await coro(arg)
File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 1202, in _invoke
await command.invoke(ctx)
File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 359, in invoke
await injected(ctx)
File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 135, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: type object 'ComponentType' has no attribute 'role_select'
pip list?
Idk what that is
ok
im that uhh friend and when i tried making his terrible command into a slash command i got this error:
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'NoneType' object has no attribute 'guild'
Is there a way to load a cog after the bot is ready (I need the user id to already be loaded)
doesnt answer your base question but i think you should use
await asyncio.sleep(10)
to sleep so it doesnt block
I'll try. Thank you
think this
should be
bot = discord.Bot(command_prefix=".", intents=discord.Intents.all())
time.sleep will block your code
no?
?tag clients
No tag clients found.
?tag client
discord.Client # just for events
discord.Bot # events + slash/user/msg commands
commands.Bot # above + prefixed commands
o, never used it like that
Just a question
I just fixed my code (I had discord.py installed)
And
What do I do?
ImportError: cannot import name 'commands' from 'discord.ext' (unknown location)
Do I need to have discord package installed?
No
show the pip list
Completely uninstall all discord bot librarys and reinstall pycord.
uninstall py-cord and reinstall it
There is a problem with this... I just PyCharm program, and sometimes it installs packages to "python310/**" folder and sometimes to my project folder so how do I check pip list?
In terminal I can use pip list but it's not accurate.
well it depends if you select to create a virtual environment
I selected Virtualenv
then its locally stored in the folder
But
Im not 100% sure how you can use pip in venvs
do pip uninstall py-cord and do pip install py-cord
oh
I created new project
And installed only py-cord
It works... Sort of..
It just shows that it is online, but I have sat the status and on_ready message. And none of these things happen
It just being there online with no use
Maybe there is a location where pycharm creates logs or something like that?
Because it doesn't give any errors or anything
can you show the code rq
slash commands sometimes take some time to register for me
so might wait 30s or so
import os
import time
import discord
# from discord.ext import commands
import dotenv
dotenv.load_dotenv(".env")
# bot = discord.Bot()
bot = discord.Bot()
async def on_ready():
print(f'{bot.user} has connected to Discord!')
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="something"))
@bot.slash_command(name="cycle", description="cycle command")
async def cycle(ctx):
while True:
time.sleep(10)
print(ctx.guild.member_count)
bot.run(os.getenv('TICKET_TOKEN'))
ye they do
just wait untill it register
Okay...
@bot.event
add that
OOooogh bru
didnt notice at first lol
Traceback (most recent call last):
File "E:\CodingProjects\TicketBot\main.py", line 13, in <module>
@bot.event()
^^^^^^^^^^^
TypeError: Client.event() missing 1 required positional argument: 'coro'
Error
yeah it's kinda hard working with discord apis stuff can be tricky how you use it
yeah..
remove the ()
Ok
especially going from discordpy to pycord heh
remove the brackets
Ogh π
not a big change
eh so many minor details i just decided to start fresh on my simple bot
there's a lot of similarities but a lot of things are renamed I felt like
Yeah
I do have a question though, I'm using
@commands.cooldown(1, 86400)
but i want it to respond with an ephemeral message, so i captured it with
@_addcharacter.error
async def on_application_command_error(self, ctx: discord.ApplicationContext, error: discord.DiscordException):
await ctx.send_response(content=error, ephemeral = True)
but it still attempts to send the original error after the error is captured, am i doing something backwards?
(i know i should check the instance of the error, just trying to sort this out quick)
I presume that you mean, when the error occurs or something that you'd want to reply with the error?
if so use
if instance(...):
await ctx.respond(...)
sorry if it was unclear, I do get my ephemeral message sent in the above on_application_command_error(), but after that in the terminal i get this:
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: RuntimeError: Interaction was already issued a response. Try using ApplicationContext.send_followup() instead.
which I think it's throwing the error, doing my response, but then continuing to attempt it's own original message with the error, which I dont want to do
I guess i could try and capture that error as well, but kinda seems like I'm doing something wrong heh
oh i'm dumb, I had another error capturing function so that is what was trying to send the 2nd response
but shouldnt the "@functionname.error" only receive errors from the associated function?
ok nvm again, i think making that change required time to update as well >.<
One message removed from a suspended account.
what is more efficent or is there a more efficent way to get all user ids from a server?
way 1:
members = await guild.fetch_members()
user_ids = [member.id for member in members]
way2:
user_ids = [member.id for member in guild.members]
use the second one
way 1 is using API calls (not recommended unless you need the data due to not in cache)
way 2 is using the data stored in the bots cache which is done automatically which is the recommended the most
the first one iff you don't have members intent
is there any way to give an option a value?
Here's the slash options example.
@fallow hawk ^
thank you
Would someone be so kind to point me towards docs for "apps" - like the right-click message apps?
It's quite the difficult thing to search 
Are these called MessageCommands?
yeah
Okay YAY tnx! Never used these before!! This should be fun ^-^
how can I use multiple on_message events?
Why would you ever need more than one?
I don't need more than one, but it's more simple since my first on_message event is for boost messages
and I'm not too sure how to use multiple channel ID if statements in one on_message event
I'm getting the error "No module named discord", it has worked fine before now. I'm using V.2.1.0 of discord and 2.3.2 of pycord.
is there a way to hide the command menu for users that are using the bot from dms?
how to disable a other button of the same class after click
Ignoring exception in command ticketas:
Traceback (most recent call last):
File "C:\Users\Dreyon\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\commands\core.py", line 124, in wrapped
ret = await coro(arg)
File "C:\Users\Dreyon\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\commands\core.py", line 980, in _invoke
await self.callback(ctx, **kwargs)
File "C:\Users\Dreyon\PycharmProjects\pythonProject\main.py", line 259, in ticketas
await ctx.send(embed=embed, view=MyView())
File "C:\Users\Dreyon\PycharmProjects\pythonProject\main.py", line 136, in __init__
self.guild = ctx.message.guild
AttributeError: 'NoneType' object has no attribute 'guild'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Dreyon\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\bot.py", line 1114, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\Dreyon\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\commands\core.py", line 375, in invoke
await injected(ctx)
File "C:\Users\Dreyon\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\commands\core.py", line 132, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'NoneType' object has no attribute 'guild'
how do i fix it, i tried making all of the commands my friend @thick pumice made to slash commands and i keep getting this error
Provide code dude
line 259:
line 136:
For what do you need this?
idk ask endas he made the code im just converting it cause hes struggling
i used to use discord.py
i found out what pycord like 2 days ago
Py-cord is a fork of discord.py but the code is clean and faster
I really want to use the new version because it will be way faster and not anymore a fork of dpy
Why after reloading bot can't get old messages?
Probably because you're getting the messages from the internal cache
which is cleared when the bot is restarted
and what should i do?
π€·ββοΈ you're not showing any code so I don't know
async def callback(self, interaction: discord.Interaction):
suggestion = await models.SuggestionModel.get_or_none(message_id=self.message_id)
message = interaction.client.get_message(self.message_id)
if self.values[0] == "delete":
await message.delete(reason=f"{interaction.user} (ID: {interaction.user.id}): Π£Π΄Π°Π»ΠΈΠ» ΠΏΡΠ΅Π΄Π»ΠΎΠΆΠ΅Π½ΠΈΠ΅ {suggestion.id}")
await interaction.response.edit_message(content=f"ποΈ ΠΡΠ΅Π΄Π»ΠΎΠΆΠ΅Π½ΠΈΠ΅ **β{suggestion.id}** ΡΠ΄Π°Π»Π΅Π½ΠΎ!", embed=None, view=None)
return await suggestion.delete()
if self.values[0] == "thread":
await message.create_thread(name=f"ΠΠ±ΡΡΠΆΠ΄Π΅Π½ΠΈΠ΅ β{suggestion.id}", auto_archive_duration=1440)
return await interaction.response.send_message("ΠΠ±ΡΡΠΆΠ΄Π΅Π½ΠΈΠ΅ Π½Π°ΡΠ°ΡΠΎ!", ephemeral=True)
.rtfm fetch_message
discord.abc.Messageable.fetch_message
discord.PartialMessageable.fetch_message
discord.TextChannel.fetch_message
discord.ext.commands.Context.fetch_message
discord.Member.fetch_message
discord.VoiceChannel.fetch_message
discord.ext.bridge.BridgeExtContext.fetch_message
discord.Thread.fetch_message
discord.Webhook.fetch_message
discord.ext.bridge.BridgeApplicationContext.fetch_message
discord.SyncWebhook.fetch_message
discord.ApplicationContext.fetch_message
discord.User.fetch_message
discord.DMChannel.fetch_message
discord.GroupChannel.fetch_message
Use event listeners
Discord and pycord can't be installed at the same time. Use venv (or condas)
like this?
Yeah
yeah I do, but when having multiple, either both of them stop working or just one works
Although I'm not sure if you can have multiple listeners of the same event in a single cog
Show how you do it
alright I'll just do some quick examples in here, both examples are in different files
Example 1
class BoostEvent(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.Cog.listener()
async def on_message(self, message):
PubBoostChannel = self.bot.get_channel(1029177560401182790)
if message.channel.id != 1040285655604924547:
return
embed = (
discord.Embed(
title="hi"
)
)
await PubBoostChannel.send(content=message.author.mention, embed=embed)
Example 2
class MessageReactions(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.Cog.listener()
async def on_message(self, message):
if "test" in message.content:
await message.add_reaction(":grinning:")
it doesn't, I'll try again, but doubt I'll get a different output
alright weirdly enough it works now. I'm gonna add more events and see if it bugs
Lol
it's so embarrassing every time I ask for help with something, and it just randomly starts working
Ignoring exception in on_connect
Traceback (most recent call last):
File "C:\Users\Vibes\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py", line 377, in _run_event
await coro(*args, **kwargs)
File "C:\Users\Vibes\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\bot.py", line 1164, in on_connect
await self.sync_commands()
File "C:\Users\Vibes\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\bot.py", line 738, in sync_commands
app_cmds = await self.register_commands(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Vibes\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\bot.py", line 531, in register_commands
prefetched_commands = await self._bot.http.get_guild_commands(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Vibes\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\http.py", line 360, in request
raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access
do i need intents for this to work
its a moderation command
that output this as traceback
?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)
In version 1.5 comes the introduction of Intents. This is a radical change in how bots are written. An intent basically allows a bot to subscribe to specific buckets of events. The events that corr...
Integrate your service with Discord β whether it's a bot or a game or whatever your wildest imagination can come up with.
but cant i just use this bot = discord.Bot(intents=discord.Intents.all())
yes it has admin and intents are enabled
sorry for ping
The ping is fine for me ^^
ok but yes it dose have enabled and everything
Hello. Anyone have any idea how I can fix this?
You're missing arguments on your callback
Button is first.
Ok sec
Read the docs.
I know but like
I used to have that error when button was first, I swapped places with interaction and it was fixed, but now I have to swap again? ok I'll try
.
Ir works.
Thank you β€οΈ
What is "this"?
You can't just say "for this to work" without showing what you're trying to make work
Ok I have another problem.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
my code dont fit
and i have intents enabled bot = discord.Bot(intents=discord.Intents.all())
Intents has nothing to do with permissions
You're probably trying to timeout the server owner or an administrator
Or the bot doesn't have permission to timeout
i am not timing out
its on run
???
and the bot has admin perms
Why did you send the code for a timeout command then?
its not working
i am running and getting the error

i never ran the command
Why did you send the code for a timeout command then?
Why would that have anything to do with it if you're not even running the command?
i cant run it
it dosent show up
Send the code that isn't working instead of sending random commands
on the slash command list
thats the code that isnt working
No, you just said your error appears when you run the bot
so why on earth would it not be the code that runs your bot?
but the command isnt showing up
the bot is working but just that command isnt showing up
because you're getting an error when you're running your bot
how do i fix it tho
How
am
I
supposed
to
know
if you don't show the code that is causing the error?
what code do u want me to show
its that code cus when i remove it
the code that is causing the error
Bro you literally just said that it's not that code
this is the most confusing talk i have ever had
.
when i remove it it dosent do that
Okay so what is the servers variable then?
servers = [1012337044497911838, 998888557492043826]
And is the bot in both of those servers? With the application.commands scope?
wait
no its not in all of them
only 1 at the time
That's obviously not going to work, a bot can't register commands in a server that it isn't in.
wow
yeh
thanks for helping
I keep experiencing this import error or some reason;
Traceback (most recent call last):
File "c:\Users\syass\OneDrive\Desktop\Other Stuff\Python\Verasseti\src\main.py", line 37, in <module>
from cogs.commands.user.Reminder import RemindMeCommand
ImportError: cannot import name 'RemindMeCommand' from 'cogs.commands.user.Reminder' (c:\Users\syass\OneDrive\Desktop\Other Stuff\Python\Verasseti\src\cogs\commands\user\Reminder.py)
I've imported the command as I normally would with other commands
Why are you doing it like that? Why not just loop over the files in the folder?
what do you mean? how do I do that?
You can load an extension from the file path, as long as you replace / with ..
So if you have a folder called cogs with a bunch of Python files.
for f in os.listdir('cogs'):
f = f.replace('.py', '') # Remove the file extension
extension = f'cogs.{f}'
bot.load_extension(extension)
so all of these I can load just by doing that
yes
alright ty, I'm experiencing errors with that too, but I'll figure it out later
bot.load_extensions would like to meet you in hell 
jk lol
this is preferred as it is recursive
so it loads cogs from folders inside folders too
didn't even know that was a thing
I am trying to make a help command, but I am only receiving my prefix commands in the embed not my slash commands.
Does anyone know why this is?
https://pastebin.pl/view/18b7bab9
Pastebin.pl is a website where you can store code/text online for a set period of time and share to anybody on earth
.rtfm walk_commands
discord.ext.commands.Bot.walk_commands
discord.ext.commands.Cog.walk_commands
discord.ext.commands.Group.walk_commands
discord.SlashCommandGroup.walk_commands
discord.ext.commands.GroupMixin.walk_commands
discord.ext.commands.AutoShardedBot.walk_commands
discord.Cog.walk_commands
discord.ext.bridge.AutoShardedBot.walk_commands
discord.ext.bridge.Bot.walk_commands
discord.ext.bridge.BridgeSlashGroup.walk_commands
discord.ext.bridge.BridgeExtGroup.walk_commands
.rtfm walk_application_commands
discord.ext.commands.Bot.walk_application_commands
discord.ext.commands.AutoShardedBot.walk_application_commands
discord.Bot.walk_application_commands
discord.AutoShardedBot.walk_application_commands
discord.ext.bridge.AutoShardedBot.walk_application_commands
discord.ext.bridge.Bot.walk_application_commands
Issue resolved thanks!
There anyway to have a user send a txt file and the bot to download and read it?
yes
How would I go about doing that?
Have the bot accept a file as an option to your command, and then read the file with Python
pretty simple
I keep getting this error : AttributeError: 'Client' object has no attribute 'slash_commands', how can I fix it?
?tag client
discord.Client # just for events
discord.Bot # events + slash/user/msg commands
commands.Bot # above + prefixed commands
bridge.Bot # above + bridge commands (application commands and text commands in one)
I already tried to uninstall and reinstall pycord and discord but nothing
If I use discord.Bot it says discord has no attribute Bot
:'|
show the pip list
You do not need discordpy to make the pycord working
discord.py auto install from it self
there is pip list
i always did pip uninstall discord``````pip uninstall discord.py``````pip uninstall pycord``````pip install -U git+https://github.com/Pycord-Development/pycord but it won't fix
Then your python installation is broken or you're doing something wrong
You can't have any other library that uses discord as a namespace
and you have like 5
i am using replit, maybe is something wrong with it?
i had already fixed it but this time it won't fix
ps i fixed it on replit and then the bot works but this time nothing :'(
Why NOT to use Repl as a hosting platform
You should not use Repl.it to host your bot.
It may be a nice option as its "free" but you should use something else considering the major flaws.
- The machines are super underpowered.
-
- This means your bot will lag a lot as it gets bigger.
- You'll need a web server alongside your bot to prevent it from being shut off.
-
- This isn't a trivial task, and eats more of the machines power.
- Repl.it uses an ephemeral file system.
-
- This means any file you saved via your bot will be overwritten when you next launch.
IMPORTATNT
- They use a shared IP for everything running on the service.
This one is important - if someone is running a user bot on their service and gets banned, everyone on that IP will be banned. Including you.
Please avoid using repl.it to host your bot. It's not worth the trouble.
If you're looking for free options, consider using AWS/Google Cloud Platform/Azure and its respective free tiers or just pay for an actual VPS.
π₯²
if you have a credit, a great free service is railway.app
so which is the best way(for free) to host my bot?
They just told you 
for me it takes a little bit to send the message π
if you are a student, microsoft azure if also great.
easiest is replit
then there is Azure/AWS/Google Cloud
and also Oracle
wait wrong reply. ignore the reply
tldr, replit is too beginner friendly, there are better options
you mean wrong repl-y
if you are a mad lad and still want to use replit, ?tag replit in #883236900171816970 for instructions. not tested if they work
I should probably make the new instructions on a gist or something
If you're making a Discord bot, you're expected to already know how Python packages work, and learning a few basic linux commands takes 5 minutes. So setting up your own VPS should be a piece of cake.
i am now using visual studio code on my pc but the error isn't gone, what i need to do?
what error
AttributeError: 'Client' object has no attribute 'slash_command'
discord.Client # just for events
discord.Bot # events + slash/user/msg commands
commands.Bot # above + prefixed commands
bridge.Bot # above + bridge commands (application commands and text commands in one)
import pycord
from pycord import *
import discord
from discord.ext import commands
from discord.ext.commands import bot
from discord_webhook import DiscordWebhook
import asyncio
import os
import random
import time
import tweepy
from tweepy import *
from keep_alive import keep_alive
intents = discord.Intents.default()
client = discord.Client(intents=intents)
###################
#twitter
# Twitter API keys
consumer_key = os.getenv("consumer_key")
consumer_secret = os.getenv("consumer_secret")
access_token = os.getenv("access_token")
access_token_secret = os.getenv("access_token_secret")
# Twitter account to track
twitter_username = ":D"
channel_id = "ID"
webhook_url = os.getenv("webhook_url")
#auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
#auth.set_access_token(access_token, access_token_secret)
#api = tweepy.API(auth)
tweets_list = []
async def check_tweets():
tweets = api.user_timeline(screen_name='GenshinImpact', count=1)
for tweet in tweets:
if tweet.text not in tweets_list:
tweets_list.append(tweet.text)
with open("tweets.txt", "a") as f:
f.write(tweet.text + "\n")
channel = client.get_channel(channel_id)
await channel.send(tweet.text)
async def always():
while True:
await check_tweets()
asyncio.sleep(300)
####################
@client.event
async def on_ready():
print("We have logged in as {0.user}".format(client))
@client.slash_command(name="say", description="Says everything you write after the command")
async def say(ctx, text):
await ctx.respond("{}".format(text))
@client.slash_command(name="botname", description="Send bot name (idk what to do)")
async def botname(ctx):
await ctx.respond('Bot name: {0.user}'.format(client))
keep_alive()
client.run(os.getenv("TOKEN"))```
client = discord.Client()
Use a different class if you want Slash cmd. See this ^
Byw, there is no import pycord....
nothing change
Also, don't use discord_webhook. Pycord has webhook built in
pycord has everything :D
Did you change your code? Which bot class are you now using
Show your pip list too
Also, don't use wildcard imports (the import *) it becomes difficult to debug
oke
Ok. Try to migrate discord webhook to py-cord so you can uninstall that too.
Also pycord is a different library than py-cord 
So uninstall pycord too. It is some FFMpeg wrapper not related tk discord bots at all
do i need also to change import pycord to import py-cord?
what do you mean?
Are you using v3? If not, you shouldn't be using any of them. Pycord still uses import discord
File "c:\Users\Downloads\Obi-tests (1)\main.py", line 61, in <module>
@client.slash_command(name="say", description="Says everything you write after the command")
AttributeError: 'Client' object has no attribute 'slash_command'
:')
What's your code now?
import discord
from discord.ext import commands
from discord.ext.commands import bot
import asyncio
import os
import random
import time
import tweepy
from tweepy import *
from keep_alive import keep_alive
intents = discord.Intents.default()
client = discord.Client()
###################
#twitter
# Twitter API keys
consumer_key = os.getenv("consumer_key")
consumer_secret = os.getenv("consumer_secret")
access_token = os.getenv("access_token")
access_token_secret = os.getenv("access_token_secret")
# Twitter account to track
twitter_username = ":D"
channel_id = "ID"
webhook_url = os.getenv("webhook_url")
#auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
#auth.set_access_token(access_token, access_token_secret)
#api = tweepy.API(auth)
tweets_list = []
async def check_tweets():
tweets = api.user_timeline(screen_name='GenshinImpact', count=1)
for tweet in tweets:
if tweet.text not in tweets_list:
tweets_list.append(tweet.text)
with open("tweets.txt", "a") as f:
f.write(tweet.text + "\n")
# Invia il messaggio in un canale specifico su Discord
channel = client.get_channel(channel_id)
await channel.send(tweet.text)
async def always():
while True:
await check_tweets()
asyncio.sleep(300)
####################
@client.event
async def on_ready():
print("We have logged in as {0.user}".format(client))
@client.slash_command(name="say", description="Says everything you write after the command")
async def say(ctx, text):
await ctx.respond("{}".format(text))
@client.slash_command(name="botname", description="Send bot name (idk what to do)")
async def botname(ctx):
await ctx.respond('Bot name: {0.user}'.format(client))
keep_alive()
client.run(os.getenv("TOKEN"))```
discord.Client # just for events
discord.Bot # events + slash/user/msg commands
commands.Bot # above + prefixed commands
bridge.Bot # above + bridge commands (application commands and text commands in one)
Why are you using discord.Client if you're importing ext.commands? And why are you importing keep_alive?
Replit
I thought they stopped using Replit?
So this was a lie?
Traceback (most recent call last):
File "c:\Users\Downloads\Obi-tests (1)\main.py", line 100, in <module>
client.run(os.getenv("TOKEN"))
File "C:\Users\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\client.py", line 716, in run
-
Serving Flask app 'keep_alive' (lazy loading)
-
Environment: production
return future.result()
File "C:\Users\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\client.py", line 695, in runner
WARNING: This is a development server. Do not use it in a production deployment. await self.start(*args, **kwargs)
File "C:\Users\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\client.py", line 658, in start
await self.login(token)
File "C:\Users\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\client.py", line 508, in login
raise TypeError(
TypeError: token must be of type str, not NoneTypeUse a production WSGI server instead.
-
Debug mode: off
-
Running on all addresses.
WARNING: This is a development server. Do not use it in a production deployment. -
Running on http://192.168.1.52:8080/ (Press CTRL+C to quit)
nope :') i had never learned it but i had do some discord bot but i did the older one with @client.command()
Read #help-rules
but a little bit i know it
"a little bit" is not enough to be making a Discord bot
you're evidently just guessing and hoping to get it right instead of actually understanding the help we're trying to give you
I can see it really fast if someone knows the basicΒ΄s of Python
i have a friend who is studying python but lso him don't know how to resolve it :'|
Your friend must not be studying very well then, because these issues are easily solved by knowing the basics of OOP in Python and how a Python environment works
what difference does that make?
idk i was thinking from state to state it is different
I don't care if you're on your 5th year of university, if you don't know the basics of OOP and async-await in Python, you should not be making a bot
Python does not change depending on what country you are in
him also made a discord bot with chatgpt api i don't think him is that stupid
Then ask him for help, you're in the wrong place if you think we're just going to give you a solution. We've explained what you're doing wrong and you didn't understand it. Now follow #help-rules or leave.
*i was only asking for help ... π₯² π₯Ή *
And we provided it
You were given the help you're expected to get, if you don't understand it, that's on you. We don't spoonfeed here
?tag learnpython
To be clear:
When we tell you to learn Python before asking questions here, it is not meant in a derogatory way, we are not calling your dumb or incompetent. We are simply stating the fact that usage of PyCord requires a fair bit of knowledge with using OOP, Async/Await etc. in Python. If you are not comfortable with these concepts, chances are you will not understand the answers given to you in this channel.
We understand that everyone learns at a different pace, and your current knowledge with Python may have been enough so far. When we say "you need to learn Python", it is most likely a sign that we have given you an explanation that you could not understand and there is no way for us continue to help you without spoonfeeding.
Traceback (most recent call last):
File "/home/container/.local/lib/python3.11/site-packages/discord/client.py", line 377, in _run_event
await coro(*args, **kwargs)
File "/home/container/main.py", line 26, in on_connect
bot.add_cog(moderation.warncommand(bot))
File "/home/container/.local/lib/python3.11/site-packages/discord/cog.py", line 653, in add_cog
raise discord.ClientException(f"Cog named {cog_name!r} already loaded")
discord.errors.ClientException: Cog named 'warncommand' already loaded```
Hey so I added cogs to my discord bot in my on_connect event function. However, when I run the bot for long periods of time, I get this error. It seems to be connecting a reconnecting and reregistering the command. Is there another place I'm supposed to register my cogs? Or should I just ignore this error?
Thanks!
You don't need to load your cogs in any event. Just run a function that loads them after your bot starts
How would I call that function?
If it's not in an event
Wait so even if it's not connected to discord...
ofc ofc
Wait so cogs are registered client side...?
Or is it put in queue
cogs are just a way that pycord uses to organize your code
Awesome! Thanks!
yw
Is there a way to reload all commands to be registered?
I tried to manually register some commands after they weren't showing up for a while (couple of days)
and it caused some issues with the other commands
Nvm, it's bot.sync_commands()
And it doesn't require any parameters which is grat
great*
error as in error handling or what
an error class
wait actually i dont need i guess
just tell me how to create an error class that i can handle inside on_error
Asking about your attempted solution rather than your actual problem
how do i create an error class then handle it in on_error when its raised
like what should i subclass
Exception
yw
class RequestView(discord.ui.View):
def __init__(self, bot):
super().__init__()
self.bot = bot
self.timeout = None
self.cd_mapping = commands.CooldownMapping.from_cooldown(1, 7200, commands.BucketType.member)
@discord.ui.button(label="Request a worker",custom_id="request:worker", emoji="π", style=discord.ButtonStyle.blurple)
async def request(self, button, interaction):
bucket = self.cd_mapping.get_bucket(interaction.message)
retry_after = bucket.update_rate_limit()
``` Can anyone see any issues with this code for a button cooldown? It seems to be setting the cooldown for every user, not on a per-user basis
That's what i wanted

