#Basic Pycord Help (Quick Questions Only)
1 messages · Page 53 of 1
set the guild id to the command
Ohhh oki Tyty
How can I check if my bot has manage_webhooks permission in a given channel?
When I run ctx.channel.permissions_for(ctx.bot.user), I get an error stating ClientUser object has no attribute '_roles'
Ah, I found it. I wanted ctx.guild.me
.
how do i wait for a message?
.rtfm bot,wait_for
Target not found, try again and make sure to check your spelling.
.rtfm bot.wait_for
Hi so I was makeing a gif command and for some reason every time it sends the gif will not load in the embed. ```py
@client.command()
async def gifs(ctx):
subreddit = reddit.subreddit("gifs")
top = subreddit.top(limit = 50)
all_subs = []
for submission in top:
all_subs.append(submission)
random_sub = random.choice(all_subs)
name = random_sub.title
url = random_sub.url
em = discord.Embed(title= name)
em.set_image(url = url)
await ctx.send(embed=em)
I am useing Praw to get the posts.
Anyone know a fix to this?
what is Praw?
python reddit api wrapper
how to send image via base64 ?
.rtfm discord.File
Do you know a fix?
how should we know how to fix it?
is url a valid url?
Yes.
any errors?
Code is here.
is the gif spot loading or non-exist?
Well I clicked the url and it sent me to the website.
Ya it is the gif that is on the website.
let me make this clearer: the url should SEND you DIRECTLY to an IMAGE-LIKE file
image = base64 jpeg ...
are you sending a local file?
no ?
you should use the fp parameter. What type is image?
jpeg base64
data:image/jpeg;base64
python datatype
can you show more code pls?
what ?
is it a string, byte, or what

yeah then File(fp=image)
Can you actually show how you're defining it
?tag request
No tag request found.
?tag blocking
No tag blocking found.
.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
okey
and ?
how to do haha
because we still don't know what it is
filename="image.jpeg"?
But it does work with links outside of the embed that is what is weird.
Could it be because I am trying to load a image when a gif is not really a image?
Or no?
im doing a view thing like this
`
SelectCommand = Select(blah blah blah)
async def SelectCommandCallback(select, interaction):
blah blah blah
SelectCommand.callback = SelectCommandCallback
view = View()
view.add_item(SelectCommand)
`
but when its run it says select is missing- how do i get?
send traceback
wut?
async def SelectCommandCallback(select, interaction): should be async def SelectCommandCallback(interaction):
how do i get the selection?
with SelectCommand
rdfsuhijyarfijlsu im dum- howw
i need the callback to do different stuffs based on wut was selected
yw
also reason this one has weird names is bc its wut im using to reset my commands
like reloading them
sorry bad choice of words-
Praw is blocking. Using asyncpraw
discord.Member.kick?
You need to learn how OOP works in Python before making a bot
maybe
Read #help-rules
how can I make the slash command only visible and available to admins?
I believe you have to use default permissions
Here's the slash perms example.
Hey guys, i want to make a bot which includes image generation. but as you know PILLOW is really slow and it is not supporting async either. How can i solve this?
Should i make a webserver where images will be generated and bot can just read bytes and send it, or should i do some queued image generator in another thread with callbacks?
Well you can use asyncio.to_thread which makes stuff a lot easier
And are you using PIL or Pillow
I figured i should ping
they are same, aren't they?
I remember reading smth that said PIL is advanced and being maintained while Pillow is no longer maintained. But I have no idea if that's true
im wrong
its the opposite
💀
pillow is the maintained onee
has anything happened with member_count which apparently doesn't exist in Guild
show pip list
you have member intents?
yes
I have all intents enabled
enabled it on the apps as well
I ran it in 3.10 and it works fine, I'll try and see running on my machine later on
if it works, I'll see reinstalling everything on the container itself
Official Beginner's Guide: https://wiki.python.org/moin/BeginnersGuide
Official Tutorial: https://docs.python.org/3/tutorial/
Shortcuts:
https://wiki.python.org/moin/BeginnersGuide/NonProgrammers
https://wiki.python.org/moin/BeginnersGuide/Programmers
Learn Python:
https://automatetheboringstuff.com/ (for complete beginners to programming)
https://learnxinyminutes.com/docs/python3/ (for people who know programming already)
https://docs.python.org/3/tutorial/ (official tutorial)
http://python.swaroopch.com/ (useful book)
http://www.codeabbey.com/ (exercises for beginners)
Also, why that while true loop? What are you trying to implement
How do I import all Intents without the presence intent?
Intents.all() and then intents.presense = False
So like this?
Use actual loop tasks and not while loops
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - pycord/background_task.py at master · Pycord-Development/pycord
is it possible to loop with variables?
async def time_task(xyz, xyz2):
and start
?
.tias
😦
Why is this not working? presence is not found. I want to get out of the way of all intent that presence needs
.rtfm Intents.presence
Is discord dying? None of my bots have any slash commands registered anymore 
Ty
Why is there a comma at the end of the first line
is using an asyncio mutex lock common practice for something that might set the state of a bot?
Is it somehow possible to catch 2 errors in a try-catch block? If so, how?
yep
loop.create_task is not a coroutine tbh. asyncio.create_task is preferable
just use tasks extension. it is much better
yes
damn TIL having a comma at the end makes it a tuple
damn lmao
i would rather use asyncio Events ?
import discord
from discord.ext import commands
import os, sys
from views.SeedsPlantsButton import SeedsPlantsButton
sys.path.append(os.path.abspath('..'))
import db.utils as utils```
i dont understand why my cogs arent loading or erroring but my imports are correct
it worked before i split stuff up into seperate files
I'll take a look at it ty
do from cogs.views.SeedPlantsButtons you can't have spaces in folder names btw
1 google search away
https://stackoverflow.com/a/6470452/13088701
you can
I don't think you can, importing messes up when you try to import a folder or file with spaces in it
why views inside a folder named cogs? keep cogs in a separate folder and views in a separate one
ive tried
doesnt work
what doesnt work?
and xyz() dont work
only recive
Is that possible?
@discord.ui.select(placeholder="Wähle einen Spot aus", options=get_water)```
uh can i ask wth are you doing?
also use asyncio.gather if you want to start multiple tasks simultaneously
dont use requests
use aiohttp
?tag blocking
No tag blocking found.
hymm okey
?tag aiohttp
Use aiohttp.
requests and urllib are blocking. Do not use these libraries within your asynchronous code as they're not asynchronous.
(http://discordpy.readthedocs.io/en/latest/faq.html#what-does-blocking-mean)
discord.py uses aiohttp, so it should already be installed. An example of code using aiohttp and discord.py:
async with aiohttp.ClientSession() as cs:
async with cs.get('https://httpbin.org/json%27') as r:
res = await r.json() # returns dict
await ctx.send(res['slideshow']['author'])
For more help, see aiohttp's documentation: <http://aiohttp.readthedocs.io/en/stable/>
what part do you need help with?
?tag xy
An XY problem is when you're trying to ask about your attempted solution, rather than your actual problem.
You are trying to solve problem X, using solution Y. Instead of asking for help with X, you ask about Y. This only results in frustration as whoever is trying to help you needs to ask several questions before even beginning to help you with your actual issue, wasting both their own, and your time. Always include as much information as you can about your problem, including attempted solutions. If there are solutions you've ruled out, include them along with an explanation as to why you've ruled them out.
With the select menu, can I get the options from the get_water function or do I have to specify a static list as an option?
yes you can do that but i really suggest you subclass the select menu
Do you mean like this?
class GetOptions(commands.Cog):
def __init__(self, bot):
self.bot = bot
async def get_water(ctx: discord.AutocompleteContext):
class SpotSettings(discord.ui.View):
def __init__(self):
super().__init__(timeout=None)
@discord.ui.select(placeholder="Wähle einen Spot aus", options=GetOptions.get_water)```
no
?
dont work
still
idk sorry
@discord.ui.select is a decorator that works inside a view
you need to use thee super().__init__ to pass options when subclassing
slash cmds broken for me for some reason. let me pull up an example
smth like that
Discord API has problems
do you know basic asyncio? it is always great to learn it
dont use requests and websocket. they are blocking. use aiohttp
oof
Is this as correct as I thought it was?
async def get_water(ctx: discord.AutocompleteContext):
waters = await dab.get_waters()
return [water[1] for water in waters if water[1].startswith(ctx.options["gewässer"])]
class Dropdown(discord.ui.Select):
def __init__(self, bot: discord.Bot):
self.bot = bot
options = get_water()
super().__init__(
placeholder="Wähle das Gewässer aus",
min_values=1,
max_values=1,
options=options,
)
async def callback(self, interaction: discord.Interaction):
await interaction.response.send_message(f"Deine Auswahl ist: {self.values[0]}")
class SpotSettings(discord.ui.View):
def __init__(self, bot: discord.Bot):
self.bot = bot
super().__init__(timeout=None)
self.add_item(Dropdown(self.bot))```
Is that why all my commands disappeared?
Like, it was working fine today, but now all commands are gone
yes
Ok happy than it is not my problem ^
show the code
?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.
?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
you could have discord.Member and discord.Channel in one
i like how instead of it erroring it just doesnt load the cog
makes it very easy to debug
so basically discord.Member and discord.Channel to find data, you need to have typing enabled?
I'm trying to basically remove intents that I'm not using
so I'm going through all the intents
eh
you can just do intents=discord.Intents.all()
true however I'm surviving on the edge in terms of RAM usuage
I can't upgrade the server bc I don't have funds
how can i make slash commands have options
lemme get the list
the same like a normal command
description=""?
description=""
https://docs.pycord.dev/en/master/api/data_classes.html#discord.Intents
there you have the list
Some classes are just there to be data containers, this lists them. Unlike models you are allowed to create most of these yourself, even if they can also be used to hold attributes. Nearly all clas...
ty however it doesn't have much explanation for typing intents which was why I was confused for why does it exist
oh, mhm
The python server will be more helpful
ty
Hello! I had py-cord==2.3.0 in my requirements.txt file for a while and made no changes to the code or to other files. Why am I suddenly getting this error?
Traceback (most recent call last):
File "/.local/lib/python3.9/site-packages/discord/ui/view.py", line 414, in _scheduled_task
await item.callback(interaction)
File "/cogs/draft.py", line 118, in first_pick
await self.on_interaction(button, interaction)
File "/cogs/draft.py", line 199, in on_interaction
interaction = await interaction.response.send_message(content)
File "/.local/lib/python3.9/site-packages/discord/interactions.py", line 825, in send_message
await self._locked_response(
File "/.local/lib/python3.9/site-packages/discord/interactions.py", line 1090, in _locked_response
await coro
File "/.local/lib/python3.9/site-packages/discord/webhook/async_.py", line 215, in request
raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction```
Might be taking more than 3 seconds to respond
that file isn't to do with that error
send ur code
I see. It usually takes less and maybe it took more that time and gave an error. What's the best way to handle that?
Defer it
async def interaction_check(self, interaction: discord.Interaction):
return interaction.user.id == self.author.id```
why doesnt this work
only make the button work for the author of the original message
and i pass the self.author into the button
.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.
i just did 💀
You did not explain what you expect to work or provide any errors
We have no idea what you're trying to do
Ok, thanks. I'm surprised it never happened before in that part of the code.
i got it
i did.
What are you trying to do?
only make the button work for the author of the original message
and no errors
how do i make my slash commands updated options show up? this is my code and i just added the member option and min and max to amount and both of those dont show up
@discord.option("member", discord.Member, description="The member to get the profile of, leave blank for yourself", required=False, default = None)
# command
@discord.option("amount", min_value=1, max_value=100, description="The amount of seeds you want to buy", required=False, default=1)
# command```
no errors
Im not sure how stable the discord API is at the moment
can you the async def name() stuff?
async def profile(self, ctx, member: discord.Member = None):
async def buy(self, ctx, seed, amount:int=1):
did u check the examples in github?
yes
honestly if it was me, I'd do it like this
@bot.slash_command(...)
async def profile(self, ctx: discord.ApplicationContext, member: discord.Option(...)):
...
both ways are fine
discord.Option pretty sure
huh
no
wait no, you're using @discord.option
discord.option()
you can use both
then why isnt it working
give it some time
discord is weird with slash commands
ok discord.option and discord.Option is not the same. I get an error if I use discord.Option
If there's a server where I can't get any information from, but from bot.guilds it is showing that there's a server that the bot is in, but I can't get any info from, does it mean that it is inactive?
does the bot has permissions?
yes, what I'm doing is getting the member_count so I tried to get print out the guild incase there's something wrong
and printed out memer_count along with guild.name
and when I use len(bot.guilds), I'm getting 14 however 13 guilds are being printed
member_count may not be 100% accurate
@discord.option("member", discord.Member, description="The member to get the profile of, leave blank for yourself", required=False, default = None)
async def profile(self, ctx, member: discord.Member = None):```
why isnt the option working
it doesnt show up
still doesnt
try re-naming the slash command and un-re-naming it

is this supposed to work?
msg = await interaction.original_response() await msg.delete()
Looks correct. Except for the part that get_water is an async function 💀
if this not right how do i do diss
You have interaction.delete_original_response
That should work too
That's why you should always read the docs
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.
Can you show the code?
I'm usually not a guy to judge but windows vm in a Mac?? Mac is already pretty good, if not better for development
^
Oh then 👀
ohhhhh sorry im dum i thought you meant error code-
ill explain command, i have sum so i dont have seperate commands for /slap, /hug etc so i have this select menu thingy it sends as an ephemeral and when you select thingy it sends it in the current channel and i wants it to delete the select message, andddd im using chrome remote desktop to control my windows server pc-
Ah so you want to select menu itself rather than the message it sends?
You will have to call this from the Slash cmd
the select menu is just to decide wut you wanna do (this has all the /slap, /punch, /hug etc) and ofc i want the menu to be only viewable by the sender, but it isnt rly needed after it sends the message
Add self.stop() to the end of the view callback
add await view.wait() to the Slash cmd
And then do await ctx.interaction.delete_original_response()
ohhhh ajnvejniaevjinjeajniv TYYY that makes so much senseeee
Also just so you know, you can access the bot instance through interaction.client in the callback
No need to pass the bot instance to the view
Np 
Now is doing
await self.stop()
TypeError: object NoneTypw can’t be used in “await” expression
Full error?
You don't await it
"Dommy Mommy is online"
Reminds me of @waxen whale
Oof
Pinged the wrong @waxen whale earlier lmao
Oh lmao
What wrong with that?
You would need to create the view instance before the ctx.respond
Not inside it
Wait I'll show an example
Oki Tyty
You are doing this
async def cmd(...):
...
await ctx.respond(..., view=MyView())
# await view.wait() can't 😭
Do
async def cmd(...):
...
view = MyView (...)
await ctx.respond(..., view=view)
await view.wait()
Couldn’t do “await MyView(…).wait()?
no, you are creating another MyView instance
different from the original one you sent
that would create a new instance
Which means new buttons and new callbacks
We don't want that. We want to work with the existing one we sent
you got this right?
Yeah
k I'll go to bed then
Alr gn 
Yay 👍
I has other question that isn’t exactly pycord but i imagine you’d know wayyyy more than me
So I use MySQL database, and if I just connect to it when main is run at first it doesn’t work after like a day
My fix is to connect every time a command is run this feels rly inefficient
What connector do you use?
Yea that not very good
Yea-
Do you use connection pools?
who've summoned me
Idek wut that is 😭
lol
Thats my bots nameeee
Hmm
^

I just use MySQL,connector-
Imma be honest I had no idea how databases worked like a week ago-
Also imma prolly goto bed soon-
Bc gotta be able to get up early ish, bc has appointment!!! And hopefully E dose goes upppp:D
how to add reaction to a respond message?
not workingpy msg = await ctx.respond(embed=embed) await msg.message.add_reaction("👍") await msg.message.add_reaction("👎")
error: txt Application Command raised an exception: AttributeError: 'NoneType' object has no attribute 'add_reaction'
ctx.respond returns an Interaction, not a Message
Use ctx.interaction.original_response to get the Message
Okay made it as a normal function.
But now I get the error message:
options = get_water()
File "c:\Users\User\Documents\Coding\OnlyFrames\cogs\spot.py", line 27, in get_water
return [water[1] for water in waters]
TypeError: 'coroutine' object is not iterable
C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ui\view.py:416: RuntimeWarning: coroutine 'get_waters' was never awaited
return await self.on_error(e, item, interaction)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback```
Is it perhaps most sensible to read the values from the DB once when starting the bot and to pack them into a list in order to then always be able to access this list instead of reloading the data from the database each time?
The values I use there are static values that are always the same?
Yeah that makes sense
You can use botvars to access the list
.botvar
Need to keep track of a variable between functions? No problem!
⚠️ Careful what you name it though, else you might overwrite something ⚠️
Just add it to your commands.Bot or discord.Client instance like so:
bot = commands.Bot(...)
bot.my_variable = 0
async def foo():
bot.my_variable += 1
# In a cog
@commands.command()
async def counter(self,ctx):
await ctx.send("Current Counter is at {}".format(ctx.bot.my_variable))
This also allows you to access this from other cogs/extensions/functions. Anywhere you have access to the bot instance
Did I understand that correctly?
bot.waters = []
@bot.event
async def on_ready():
bot.waters = await dab.get_waters()
print(f"{bot.user} ist online")```
```py
class Dropdown(discord.ui.Select):
def __init__(self, bot: discord.Bot):
self.bot = bot
options = bot.waters
super().__init__(
placeholder="Wähle das Gewässer aus",
min_values=1,
max_values=1,
options=options,
)
async def callback(self, interaction: discord.Interaction):
await interaction.response.send_message(f"Deine Auswahl ist: {self.values[0]}")```
How can I display my dropdown menu or update the view?
class SpotSettings(discord.ui.View):
def __init__(self, bot: discord.Bot):
self.bot = bot
super().__init__(timeout=None)
@discord.ui.button(label='🎣 Start', custom_id="StartButton", style=discord.ButtonStyle.primary)
async def start_button(self, button: discord.ui.Button, interaction: discord.Interaction):
await interaction.response.send_message(f"Bitte wähle das Gewässer aus")
self.add_item(Dropdown(self.bot))```
Hey guys I know the basic autocomplete stuff, but how do I suggest a diff list of items once some text has already been put into the bot, eg in the box i put in a and it shows a whole diff list with stuff starting from a for example
You have to use python for that. [x for x in words if x.startswith(input)]
I think there is an example of this somewhere in the autocomplete example. I would give more info but my internet is being slow and not loading anything.
wait i got what i was tryna do,
current_val = ctx.interaction.data['options'][0]['value']
assuming [0] is the option number
and i can give stuff based on that
where?
Where the commented stuff is out
dont use global variables ngl
I’m not-
So I’m asking how-
Bc it’s not in a function so can’t pass it in and use self
how do you plan on running it if it is not a function
its not even inside the __init__ if thats what you were planning
This it’s not-
The options are set there so they can be accessed by @discord.ui.select
Butt imma have some nsfw options that I only want to be added if nsfw stuff is enabled in the server
So it needs the server id to check if it is
And if it’s in a function @discord.ui.select won’t be able to get it
subclass the select menu
Idk how to do dat-
thats the best way to go if you dont want static options
slash cmds broke for me, but go into the dropdown example at github
wait ill do it
Oki tyty
Is there any way i can use gifs in embeds set_images?
yes
why should it not work?
its not working
can you show the code?
.||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||https://ask-your-mom.big-pp.club/🚽🚏🐍🤫
wait, do you use the Better Discord Plugin to send embeds?
.||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||https://ask-your-mom.big-pp.club/🥇🤩💾🌽
what?/
?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
.aiohttp
can you show the gif link?
?tag aiohttp
Use aiohttp.
requests and urllib are blocking. Do not use these libraries within your asynchronous code as they're not asynchronous.
(http://discordpy.readthedocs.io/en/latest/faq.html#what-does-blocking-mean)
discord.py uses aiohttp, so it should already be installed. An example of code using aiohttp and discord.py:
async with aiohttp.ClientSession() as cs:
async with cs.get('https://httpbin.org/json%27') as r:
res = await r.json() # returns dict
await ctx.send(res['slideshow']['author'])
For more help, see aiohttp's documentation: <http://aiohttp.readthedocs.io/en/stable/>
;3
thats why it is not working...
what link i have to use?
you have the website and not the gif
ohh shit
How can I display my dropdown menu or update the view?
class SpotSettings(discord.ui.View):
def __init__(self, bot: discord.Bot):
self.bot = bot
super().__init__(timeout=None)
@discord.ui.button(label='🎣 Start', custom_id="StartButton", style=discord.ButtonStyle.primary)
async def start_button(self, button: discord.ui.Button, interaction: discord.Interaction):
await interaction.response.send_message(f"Bitte wähle das Gewässer aus")
self.add_item(Dropdown(self.bot))```
you can print data['results'][0] and see what all you got
edit_message(view=self)
https://media.tenor.com/gVKTYlZm568AAAAC/omg-schock.gif
@west venture you need something like this
thats the ['url']. there can be other stuff too
ohhhh damn wait amin
class SpotSettings(discord.ui.View):
def __init__(self, bot: discord.Bot):
self.bot = bot
super().__init__(timeout=None)
@discord.ui.button(label='🎣 Start', custom_id="StartButton", style=discord.ButtonStyle.primary)
async def start_button(self, button: discord.ui.Button, interaction: discord.Interaction):
await interaction.response.send_message(f"Bitte wähle das Gewässer aus")
self.add_item(Dropdown(self.bot))
await interaction.response.edit_message(view=self)```
Then I get this error message:
discord.errors.InteractionResponded: This interaction has already been responded to before```
am getting error
Can't help without code
can you avoid avoid the send_message?
if not, use self.message.edit(view=self)
Oh thank you!
You are really top! 🙂
The maximum number of 25 you can not change right?
How can I handle it best if I have more than 25 entries in a list? 🙂
yea i have this here sorry fogot to show it as its kinda in the middle of everything, its in the select
You didn't super init the view
yea i just added thatt testing it rn tyyy<3 /p
oki so looks like it works but doesnt seem like the callback is working-
like it runs fine but when i select something it doesnt respond but no error
yee i changed that and same thing
waitt i tink the problem is that it doesnt use select, how do i get the selected value?
self?... self is the select
omg- im dum-
im sorry- im running on very little sleep-
i needs a monster and ill be oki-
Im unable to get screenshots- but I’m this how would I use view.wait() with the self.stop()
Bc a select doesn’t have a self.stop()
You will have to send 2 message if you have more than 25 items
25 what? 25 options in a select menu? 25 buttons in a view? 25 options in a Slash cmd option choice?
All have different answers
No, its a discord limit, not a py-cord limit
self.view.stop
Perfect tysm!!!!
Could use a select menu to split the list into categories to just show a few at a time, I did this for my help command
Hello, I've been coding for a while with py-cord and I've never had this problem. Would you have an idea?
My code works perfectly.
17:28:08 [ERROR] Loading cogs error --> Extension 'addons.configuration.cogConfiguration' raised an error: ClientException: Too many arguments passed to the options kwarg.
what does it means?
show the pip list
It was a problem with groupConfiguration = bot.create_group("configuration") obviously doing that in a class doesn't give a proper result, although it works.
hmm
Hi, is there a way to get more than the most recent 100 entries in the audit log? I'm trying to get logs from weeks ago and nothing is being returned
async for entry in ctx.guild.audit_logs(oldest_first=True, action=discord.AuditLogAction.member_update,
before=datetime(2023, 1, 8)):
pycord version?
@round rivet hey does view.message rely on bot cache? shouldnt the message exist as long as the view itself has a reference count and is not garbage collected?
hmmm
Error handling request
Traceback (most recent call last):
File "/root/HC_venv/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 314, in data_received
messages, upgraded, tail = self._request_parser.feed_data(data)
File "/root/HC_venv/lib/python3.10/site-packages/aiohttp/http_parser.py", line 300, in feed_data
msg = self.parse_message(self._lines)
File "/root/HC_venv/lib/python3.10/site-packages/aiohttp/http_parser.py", line 494, in parse_message
raise BadStatusLine(line) from None
aiohttp.http_exceptions.BadStatusLine: 400, message="Bad status line 'SM'"
I've been regularly getting these types of 'Bad status line' errors, does anyone have any idea what this is?
hi just a quick question how to make code to kick/ban players with the slash commands
its the same like a prefix command
wait but when im trying to do it for "/" it dont show up and dont work
?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.
?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.")
@commands.has_permissions(kick_members = True, administrator = True)
async def kick(ctx, member: Option(discord.Member, description = "Who do you want to kick?"), reason: Option(str, description = "Why?", required = False)):
if member.id == ctx.author.id: #checks to see if they're the same
await ctx.respond("BRUH! You can't kick yourself!")
elif member.guild_permissions.administrator:
await ctx.respond("Stop trying to kick an admin! :rolling_eyes:")
else:
if reason == None:
reason = f"None provided by {ctx.author}"
await member.kick(reason = reason)
await ctx.respond(f"<@{ctx.author.id}>, <@{member.id}> has been kicked from this server!\n\nReason: {reason}")
@kick.error
async def kickerror(ctx, error):
if isinstance(error, MissingPermissions):
await ctx.respond("You need Kick Members and Administrator permissions to do this!")
else:
await ctx.respond("Something went wrong...") #most likely due to missing permissions
raise error
that is my code i know im noob but ya
how do you define the bot?
what do you mean?
do you know the basic´s of python?
@ancient summit
self.message is None
make sure that self.message exists first
what is self? are you sure self has a message attribute?
do you have any code for what self is?
please copy and paste code as a code block
do this:
```python
PASTE CODE HERE
```
add ,ctx after self
i believe
.rtfm view.on_timeout
that is not a command
is it normal that tasks.loop is stopping while a slash command is being used?
discord.ui.View
discord.ui.View.add_item
discord.ui.View.clear_items
discord.ui.View.disable_all_items
discord.ui.View.enable_all_items
discord.ui.View.from_message
discord.ui.View.get_item
discord.ui.View.interaction_check
discord.ui.View.is_dispatching
discord.ui.View.is_finished
discord.ui.View.is_persistent
discord.ui.View.message
discord.ui.View.on_check_failure
discord.ui.View.on_error
discord.ui.View.on_timeout
discord.ui.View.refresh
discord.ui.View.remove_item
discord.ui.View.stop
discord.ui.View.to_components
discord.ui.View.wait
yeah it looks like view does have a .message
is it normal that tasks.loop is stopping while a slash command is being used?
@ancient summit only thing i see right now is perhaps the view wasnt sent with a message?
@commands.slash_command(guild_ids=[1067194420543377459])
@discord.option("crop", description="Crop that you want to plant", choices=[crop['name'].title() for crop in crops.crops])
@discord.option("amount", description="Amount to plant", min_value=1, max_value=max_value(user['farm_level']), required=False, default=None)
async def plant(self, ctx, crop, amount:int=None):
user = await utils.get_user(self.bot, ctx.author.id)
``` how could i make the max_value for the amount option based on something in `user`?
even could work if i could pass in ctx.author.id into my max_value() function
what?
what does "even could work" mean?
sorry i havent had much sleep i might need to re-read this several times
no wait i understand teh first line
is it normal that tasks.loop is stopping while a slash command is being used?
maybe this?
@commands.slash_command(guild_ids=[1067194420543377459])
@discord.option("crop", description="Crop that you want to plant", choices=[crop['name'].title() for crop in crops.crops])
async def plant(self, ctx: commands.Context, crop, amount:discord.Option(int, "amount", min_value=1, max_value=lambda: await utils.max_plant(commands.Context.author.id), default=None, required=False)):
user = await utils.get_user(self.bot, ctx.author.id)```
when you start the bot, the bot tells discord all the slash command information including the max value for the slash command option
it doesnt run the code, so it doesn't know what user is, and discord prob wont run the code because its not running that command that command for each user
basically the options are constants declared at "build time" you could say and so cannot be changed
u can change them with autocomplete
have no max ig and just check if its over the max and alert the user
run time/compile time btw
like dank memer when you when you withdraw money from the bank it doesnt give a limit to how much you can withdraw at the slash command menu
It only tells you whether or not you can withdraw after you run the command
Slash commands can prompt for attachments in the command fields. Can any Component allow for this, e.g. a button that prompts or some other message interaction? Or the slash command itself is the only way to provide one in any workflow?
Only options
Thanks! Hopefully this will be enabled elsewhere at some point. I'm trying to revamp some application commands from the jumble of inputs into a View with controls for a slightly more visual experience.
How is this done? can I link to the right place in the documentation?
Here's the context menus example.
¯_(ツ)_/¯
Anyway to make a buttons attached to a message?
(text, button)
Thanks mate, anymore contact then that?
create a View object, then add Button components
when sending the message do view=ViewObject
you can always google for more info
Thank you
how can i get the id for an emoji like ⚱️ for use in a discord.ui.button there's no id to it, nor can i copy paste it into an editor, doing emoji=';urn;' (semis as regular) gives me invalid emoji, tried without colons too
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 ...
and \:urn:
thank you!
so basically \⚱️
you would get the raw unicode emoji by sending it in Discord preceding it with a backslash (escape character)
Structural question - if I add a View inside my cog (I generally make them separate), this would properly reload them when using reload_extension()? I feel like my external classes aren't properly being updated when I reload my cogs.
last small question, can other users interact with a button that i've invoked the command on?
anyone can click any visibile active button
cool i'll add a check then 🙂
gl
Also, I forget... am I able to add component classes inside my View, or best if it's not? I sorta remember having some access issues, but maybe I was doing something wrong --
class MyView(discord.ui.View):
class MyModal(discord.ui.Modal)
...
@discord.ui.button(label='Modal')
async def invoke(self, button, interaction):
await interaction.response.send_modal(MyModal())
yes, but unorganized
Hm. I thought that would be more organized than having classes sitting out in space. Of course, I'm mostly concerned with being able to reset the cog and have all changes refreshed.
Which goes back to my previous question about having Views and other UI classes within my Cog (even if they're not nested within each other)
sorry to ask a question over you again >.<
is there any way to do a callback from the view originator? my command creates a response with a view, but on button press I'd like a callback to the command in a cog for additional actions to be done
nm think i found it 🙂
can you have two commands on the same cooldown?
code:
async def callback(self, interaction: discord.Interaction):
self.button.disabled=True
msg = self.message
embed = msg.embeds[0].to_dict()
embed["fields"][0]["value"] = "{}".format(self.children[0].value)
newEmbed = discord.Embed.from_dict(embed)
await msg.edit(embed=newEmbed,view=self)
await interaction.response("You answered this questions",empheral=True)
error:
Ignoring exception in modal <cogs.views.QuestionModel object at 0x000001A6BAC91730>:
Traceback (most recent call last):
File "C:\Users\Fammy\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ui\modal.py", line 341, in dispatch
await value.callback(interaction)
File "C:\Users\Fammy\Desktop\discord\Keni\cogs\views.py", line 99, in callback
await msg.edit(embed=newEmbed,view=self)
File "C:\Users\Fammy\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\message.py", line 1465, in edit
data = await self._state.http.edit_message(
File "C:\Users\Fammy\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\http.py", line 366, in request
raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In components.0.components.0: Value of field "type" must be one of (2, 3, 5, 6, 7, 8).```
code
async def self(interaction: discord.Interaction):
message = await interaction.response.send_message(f"Ping!")
question: how would i edit the message the bot just sent, I have tried a couple ways but I get a no attribute error
i'd think so, you just create a cooldown somewhere, then reference that on two specific commands
Why are you creating a whole new embed? Curious if it's not deep copying enough
You have the Embed instance, so just update it in place
embed.fields[0].value = ...
await msg.edit(embed=embed, view=self)
😮 learned something new today thanks
this looks like something you can use/adapt
https://github.com/Pycord-Development/pycord/blob/0679edd96bad4695e2bdcef5651633781024b920/examples/cooldown.py#L41
Yeah that's a good way to do it
anyone mind if i ask a quick database selection question? or will i get bashed over the head
Sure go ahead
Right now I'm storing data in json files so my instinct is to go with mongodb, but seeing mongodb taking up 1.6gigs on disk (windows) is kinda crazy for my small needs (maybe i installed extra crazy stuff?), and was wondering if you guys have any suggestions.
I wouldnt mind sql lite but I hear it doesnt support multiple simultaneous transactions well, and i dont expect that but i'd like it to handle that situation gracefully
Interaction.edit_original_response
You can enable WAL mode in sqlite and that enables simultaneous transactions
Thanks!
ok, so would you just advise going with sql lite for it's minimalness?
Yeah sqlite is good if you have a small database
okey ty
yeah I dont expect my project to go further then one discord server or two
Ah so sqlite should be good
but if a project i ever do explodes I'll worry about that when the time comes heh
Use asqlite or aiosqlite to connect to it. The built in sqlite3 library is blocking
ty
Np
Can a View access cog class it was invoked from? Or perhaps interaction callbacks? I thought there was a link somewhere... or do I have to pass it in?
Pass in self when you create the view
How can I send a message on the on_ready function of the bot?
Get the guild from bot.guilds and then the channel and then send the message
Can I create an input field on Discord other than via modals?
So what I have in mind is a field like autocomplete so that a user can enter something there? 🙂
im new to pycord so i have no idea what my problem is...
can someone help?
- Is this a cog?
- You don't get
guildyou getctxorcontextakadiscord.ApplicationContext. Use proper names.
yes it is
oh ok..thanks
Because create_task expects an asynchronous function
And stop using the requests library for everyone's sake
then how do i do it?
First, learn about async functions and how they work. Then learn about async libraries. And then explain what you're trying to do.
im literally copy pasting it but its not working
ok i forgot there is such a thing as threading just and i can use it
You don't copy paste. That's why it doesn't work.
@commands.slash_command(name="tmp")
async def create_voice_channel(self, name:str):
await self.guild.create_voice_channel(name,category=self)
self?
i used ctx too
same issue
Because the name of the variable doesn't break it
"Doesn't work" doesn't explain what's not working.
.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.
well
same error
then what should i do?
Show the error
ctx.guild.create_voice_channel(name)
No idea why you're passing category= and providing the context object
Learn about OOP read the guides
ah
ok
but how can i add the category without the whole thing breaking?
That was kinda rude-
nah its ok
dont worry about it
Oki
Like they right but that wasn’t the nicest way of saying it-
Ouuu they typingggg this gonna be interesting:p
You need to get the category first, you can use ctx.guild.get_channel(IDHere) where IDHere is the category ID. Then pass that to the category kwarg
Can confirm
Not everyone will treat you with love and flowers. :)
Oh trust me Ik- sometimes i loveee it when ppl are mean to me
It's not being rude, either way. It's just a message, you don't receive any emotion from it. You see it the way you want.
uhhhh
like this?
(ik im stupid)
No
get_channel will return a CategoryChannel object
Which is what you pass to category=
Category = bla bla bla category id
Await ctx.guild.create thingy (category =Category)
Ez
Do we have a command for a “learn basic python before trying to make a bot” message?
uh well there is #help-rules
.lp
Official Beginner's Guide: https://wiki.python.org/moin/BeginnersGuide
Official Tutorial: https://docs.python.org/3/tutorial/
Shortcuts:
https://wiki.python.org/moin/BeginnersGuide/NonProgrammers
https://wiki.python.org/moin/BeginnersGuide/Programmers
Learn Python:
https://automatetheboringstuff.com/ (for complete beginners to programming)
https://learnxinyminutes.com/docs/python3/ (for people who know programming already)
https://docs.python.org/3/tutorial/ (official tutorial)
http://python.swaroopch.com/ (useful book)
http://www.codeabbey.com/ (exercises for beginners)
and that
Cool, thanks. It would’ve been helpful for the previous convo in this channel 🙂
Are you guys the devs of pycord.wavelength too or is that an independant thing?
Yes, but I dont think the project is in production.
ok?
How do i add a role to the author, i tried await ctx.author.roles_add(role)
But it’s giving me this:
It looks like it still works but I does not look like it receives many updates. (It might not need to be updated often though.)
add_roles()
I’m using slash_command from from discord.commands import slash_command
Thanks
Im more making sure that the devs of pycord worked on it. The package thus far works, and is interacting with my lavalink server, and was more curious as to what other examples there were for the library, as the one that is on the github is only a play command
The original wavelink package is compatible with pycord. It is actively maintained too. So using the pycord.wavelink package doesn't make much sense. It was for when the original wavelink package did not work with pycord
I didnt know pycord had a package for it, is that imported as a discord component? And does it interact similarly as that package then? I have a working code for the pycord.wavelink package, how simple is migration?
The usage is almost the same
It is imported as a separate package
I think it is import wavelink
how do i set custom status?
What can cause “Unclosed Client Session” error to happen?
- full error?
- code?
No longer needed thank you though. Was assisting a friend, turned out they were using really old methods
.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.
okey thx
Can I create an input field on Discord other than via modals?
So what I have in mind is a field like autocomplete so that a user can enter something there? 🙂
Command options?
So my thought right now is this:
After I click on a button a dropdown menu is shown to me, if I select something here another dropdown menu is shown to me. And if I have selected something there I want an input field where the user can write something in. Is this possible?
Prompt a modal?
That would be a possibility. There I can also check the text if it has a certain format or?
how do i set arguments when using flags? @proud mason
i tried but the flag gives always none
You can only run checks after the user submitted the modal
my code: async def ban(ctx, *args, flags: BanFlags):
Yes that would do. And if the text does not have the desired format, the model is called again. That should not be a problem right? 🙂
You'd need to send a button which opens a modal again
Okay 🙂
In a modal I can only do input text or? No dropdown menus or similar right?
No
Okay 👍🏻
Can I create another dropdown menu when I have made a selection in the first one?
could do something like disabling the first selection and doing an edit message to add another (not exactly sure how that would look), or send_response with another view maybe?
when making views for cleanliness sake, is it common practice put each view into their own .py in a views folder?
i hate how if theres an error in a cog, instead of it telling you theres an error, the cog just doesnt fucking load. wtf
show code instead of stressing out
send it in pastebin if its too big otherwise send here in cb
Is it a linting error? like if you try to execute the cog directly, will it run without error, or do you get some hints there?
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.
ModuleNotFoundError: No module named 'db'
sys.path.append(os.path.abspath('..'))
import db.utils as utils
``` and its worked every other time i ran the bot. for some reason with pycord, i cant do `import ..db.utils` and it pisses me off too
Might want to show your directory structure.
Mine is something like
bot.py
-- commands\
mycog.py
...
-- utils\
display.py
Within mycog.py, I can reference utils.display just fine, even though my entry point is bot
I don't get your sys.path call then.
Presumably if your db modules are in a db directory, your cog should simply be able to directly import db.utils
Added your file to PyCharm just to see if there was something obvious, but the only errors I'm getting are from db.utils and crops. Although it is warning me about ctx.respond in your plant command, though that would be a runtime error and wouldn't prevent the cog from loading.
yep, i have no idea
so dumb
it loads fine when i remove this:
@discord.option("amount", min_value=1, max_value=100, description="The amount of seeds you want to buy. Leave blank to buy all you can buy (won't automatically buy more than you can plant)", required=False, default=None, type=int)```
Option Descriptions have a max of 100 chars. Yours is 122 or something
https://discord.com/developers/docs/interactions/message-components#select-menu-object-select-option-structure
"Number of seeds to purchase. Leave empty to buy as many as possible for your farm."
82 characters. I'm sure it could be smoothed out even more
thank you
fwiw, I always run my bot on a test key using Pycharm's debugging tool, it definitely spits out a lot of these errors. (Discord itself can sometimes be cryptic)
how can i make it wherre only i can run a slash command
Here's the slash perms example.
this might be it, nvm
nope, not it
and i dont want an if, i only want it to show up for me
Unless I'm misunderstanding, you def can, but you have to manually do it in the Integrations of the Guild/Server
Example for a slash command in my own bot
Unintuitively, when you select your bot in Integrations, you have to scroll up to get to the command overrides.
There's also @is_owner decorator but it doesn't hide the command
But you'd have to do it manually for each server
For sure, but there was no context on how widespread the bot was. Certainly would make more sense if it's a single-server bot (like mine is). Otherwise, having a command server would be a good solution.
(And for the record, I really wish Discord would add that as an API endpoint)
when I add a new command to a cog and restart the bot the new command doesnt show up.... what gives?
do you sync the commands?
sync?
I have a for loop and run this on startup
bot.load_extension(str(dotted_path))
dotted_path being the path to each of my cogs
it can take sometimes a short of time that discord shows the new commands
and update the commands
yea I mean that would be acceptable but it just never shows up
how can i hide a regular command from a help command
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...
@bot.slash_command(guild_ids=[1067194420543377459])
async def query(ctx, *, str):
await ctx.message.add_reaction("❌")
'NoneType' object has no attribute 'add_reaction'
@waxen whale Rename this thread to "The Basic Pycord Help (The Quick Questions Only)"
bfhu
thats pretty much what it is...
makes no mf sense
I would make a thread and also post entire code
How are you going to add a reaction to a message that doesn't exist?
How would it exist? When you use a slash command it doesn't create a message
shit i really need sleep
same...
no
also wondering why after i run one command, i cant search for any more
ill show a screen recording of it
No idea mate
Wdym by set arguments?
You have to define the flags in the class
how often does the on_resumed() event is called ? I wanted to use it when my bot reconnect if my internet fails, but it is calling that fonction very often
(sometime calling it each 10 minutes)
Well then your internet must be failing every 10 minutes
damn my poor internet
I really need to host my bot on a cloud
and why do I get guild as . sometimes ?
for exemple
You have guild intent?
wanted to make sure I had no extra intent that I dont need
Lol, if you do Intent() you won't get extra intents
You just need to enable them yourself
By passing those intents and value
I see, but it does not change anything tho to the result
Still, it's a good why you are doing useless stuff by doing none where you can directly do (discord.Intents(guilds=True, emojis=True, message_content=True))
but do you know what could be ausing this ?
Alr cool
Oh
What does it say normally?
The name of the guild?
yess
Oh. So is there a chance that someone keeps naming their guild .
💀
The guild name doesn't turn into ".". You already have a "." in your string
And is there a reason you're using .format instead of just an f-string?
old code, when I did not know the existance of f string

Those guilds might not be in cache ig. Does on guild remove have a raw event?
It's also possible the guilds are just unavailable, in which case the guilds won't have a name (or any data)
just wondering: is there a way to disable and remove a slash command per guild? the bot that im migrating used to support this feature, since it was prefixed
Pretty sure the server owner needs to enable/disable the slash commands themselves through integrations
ahh ok then
i was just curious
I see, so their is nothing I can do for it ? I does not cause any problem so no worries
I was just curious
and thank you for the answers !
Disable and remove? So like remove certain commands from the server? You can do that in a weird way. Register all commands as guild commands rather than global commands. And then you can remove the ones you need.
ah i see
what does that mean
Alt? Alt means an alternate account of someone. I just thought it could be because you both just said the same message 😂
oh yeah it's a coincidence
is there any way to add multiple answers for a choice in a slash command?
like if you use "user=discord.Member" you can only choose one user
is there a way to choose multiple?
What's the problem in the code? I can't fix it:
@bot.command(description="Bans a member from the guild")
async def ban(ctx, user: discord.Member, reason: discord.Option(str)):
if reason is None:
await ctx.respond("You must provide a reason!", ephemeral=True)
else:
banned_user = bot.get_user(user.id)
await banned_user.send(embed=ban_dm)
await user.ban(reason=reason)
await ctx.respond(embed=success)
success = discord.Embed(
title="Success!",
description=f"{user.name} has been successfully banned for **{reason}**!"
)
ban_dm = discord.Embed(
title="You've been banned!",
description=f"**Reason:** {reason}"
)
This is the error:
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'NoneType' object has no attribute 'send'
Why do you use bot.get_user?
You already got the User with user:discord.Member
don't i have to use their id?
What?
.
You cant chose multiple like that. You will either have to send a user select menu. Or accept a string option and parse mentions out of it
nvm it's fixed
i changed the bot photo and name on portal but when the bot is up its not changed how to fix it?
Oh ok
So is there a way to send the menu as a private one?
send it as ephemeral
thanks : D
i have another question
how can i get a channel id by using the name of it?
I’m getting this error
My code
@commands.Cog.listener
async def on_message(msg):
for i in range(len(self.data)):
if (f"<@{self.data[i]}>" in msg.content) and not (msg.author.bot):
msg.reply(f"<@{self.data[i]}> is away right now, reason: **{self.data[i+1]}**")
return None
break
if msg.author.id in self.data:
i = self.data.index(msg.author.id)
self.data.remove(msg.author.id)
self.data.remove(self.data[i+1])
await msg.channel.send(f"{ctx.author.mention} is no longer AFK!")
First one is code
Second one is error
Wow that copy paste really didn’t work out
where is ()?
add () at the listener
Oh ok
i have set agruments and flags. and the flags always returning None. My function: async def ban(ctx, *args, flags: BanFlags):
self, msg: discord.Message
self, f”…” ?
do you know basic python?
What do you mean with "Kinda"?
I didn’t have the time to learn cause of school
And i still only have 1 week of weekend
without the basic´s it will be really hard for you to create a bot
that will be the same with any programming language
Ik Ik
But i just wanna create a server bot
For my server
Not a public bot, i don’t think it’ll really be that bad
i do know a some
Doesn’t it take like 3 months to learn just basic python?
I mean for the bot
idk bro
how can i get a channel id by using the name of it?
with the discord.utils.get
discord.utils.get(abc, name="")
but why the name?
im making a slash command that makes a vc / text channel and i want to get the channels id
im getting an error...
did you just copy and paste it?
you have to replace abc with stuff like member.guild.channels or other stuff
i did
i replaced the abc
ctx.guild.get_channel
( i have no idea what im doing )
replace it with ctx.guild.channels
it worked
thank you : D
you can do id=ID or name=""
btw can i ask some questions in your dm? im new to pycord and i kinda have a lot of questions
if you have questions to the voice stuff, with that I cannot help you
Also it is always best to ask questions here. If you have a lot fell free to open a thread.
^
what's the difference between cog listener and bot event
Some events have default built in functionality
Like on message event by default processes prefix cmd, on interaction processes app cmds etc
What cog listener allow is runnning another coroutine along with this default one
While bot.event allows you to override the default one
Alright thanks
How can I make it so that after I select something in Water, the next dropdown menu is displayed with Fish?
class Wasser(discord.ui.Select):
def __init__(self, bot: discord.Bot):
self.bot = bot
options = [discord.SelectOption(label=water) for water in bot.waters]
super().__init__(
placeholder="Wähle das Gewässer aus",
min_values=1,
max_values=1,
options=options,
)
async def callback(self, interaction: discord.Interaction):
view = interaction.response.view
view.add_item(Fisch(self.bot))
await interaction.response.update(view=view)
class Fisch(discord.ui.Select):
def __init__(self, bot: discord.Bot):
self.bot = bot
options = [discord.SelectOption(label=water) for water in bot.waters]
super().__init__(
placeholder="Wähle deinen Fisch aus",
min_values=1,
max_values=1,
options=options,
)
async def callback(self, interaction: discord.Interaction):
await interaction.response.send_message(f"Deine Auswahl ist: {self.values[0]}")```
Interaction.response.edit_message
Why is it not printing anything?
async def on_ready():
print('I am online')
Connection = Sql connection line but removed for security reasons yk
Connection.close()
for guilds in bot.guilds:
print(guilds.id)```
Where is my mistake?
await item.callback(interaction)
File "c:\Users\User\Documents\Coding\OnlyFrames\cogs\spot.py", line 38, in callback
view = interaction.response.view
AttributeError: 'InteractionResponse' object has no attribute 'view'```
interaction.response.view ?? what are you doing ||stepbro|| ?
indentation?
is that in the main file?
It is, What indentation error?
Connection = Sql connection line but removed for security reasons yk
Connection.close()
for guilds in bot.guilds:
print(guilds.id)
seems to be indented outside the function
on print? im litearly being blind i can tell lol
oh
im fr stupid
sorry @proud mason haha
After selecting something in the dropdown menu, I want a second dropdown menu to appear below it so that I can select something there again.
Quasi like a kind of "menu navigation"
np lol
you can get the view using self.view where self is the select menu
use the discord.option decorator or the discord.Option typehint to set cmd options
Ah okay thanks! 🙂
Can you also make it that the selected option is then displayed in the menu and if I change this not a third dropdown menu comes but the second is updated?
you could remove the 2nd select menu ig
What do I have to do in the if query?
if XXXX:
self.view.remove_item(self):```
?
when running my code i get error:
cannot import name 'Option' from 'discord' (/home/container/.local/lib/python3.11/site-packages/discord/init.py)
Show your pip list
googletrans
discord-py-slash-command==3.0.3
py-cord
sorry i didnt understand
You uninstall any other discord library than py-cord
And re-install py-cord
im USING A HOSTIN WEBSITE
and im using these packages in requirements.py
means only these packages are installed
||unless it uses a separate namespace or doesnt use python at all
||
Then remove it from the requirements file? 
what they meant is uninstall discord-py-slash-command
it has conflicting namespaces. and pycord has slash cmds built in
I don't know how to remove the dropdown menu....
oh ok
still getting the error even after removing discord-py-slash-command
well you just typed it self.view.remove_item(self)
reinstall py-cord
im using a discord bot hosting website
its install packgaes on start
which one are you using?
can i send links here?
Is it replit?
I use my free RaspberryPi
is it free?
No, but great for bot hosting
I use Lightbulb and I have access to the terminal. So I can manage everything with pip myself
is there any free bot hosting?