#Basic Pycord Help (Quick Questions Only)
1 messages Ā· Page 22 of 1
interaction.user?
what is the type of the interaction?
should it pass id?
interaction.type?
guild.default_role: discord.PermissionOverwrite(view_channel=False),
interaction.user: discord.PermissionOverwrite(view_channel=True),
guild.me: discord.PermissionOverwrite(view_channel=True),
ticket_role: discord.PermissionOverwrite(view_channel=True),
}```
no
welp i actually did work
but how do i close modal? š
Wdym by didn't work
fixed š
Ah kk
There is close button right
Or do you mean you want to close the modal using the bot?
That's not possible
?
i dont use interaction.response
You have to respond to the modal in the interaction callback
maybe this is prob?
ooooh so i can use for example "ticket created. check at c.mention"?
That's the best way around it
nice
You have to do it with all the view stuff
no :d its interaction stuff
hey how do i get the class of a app command and list only the commands that are inside a class
Ignoring exception in view <SearchView timeout=10 children=1> for item <Button style=<ButtonStyle.primary: 1> url=None disabled=False label=None emoji=<PartialEmoji animated=False name='š
°ļø' id=None> row=None>:
Traceback (most recent call last):
File "C:\Users\tearx\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ui\view.py", line 375, in _scheduled_task
await item.callback(interaction)
File "C:\Users\tearx\Documents\GitHub\Cries-Bot\cogs\economy.py", line 132, in a
await interaction.response.send_message(embed=embed, ephemeral=True)
File "C:\Users\tearx\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\interactions.py", line 656, in send_message
raise InteractionResponded(self._parent)
discord.errors.InteractionResponded: This interaction has already been responded to before```
@discord.ui.button(emoji="š
°ļø", style=discord.ButtonStyle.blurple, custom_id="help:left")
async def a(self, ctx, interaction: discord.Interaction):
await interaction.response.defer()
chance = randint(1, 3)
if chance == 1 or 2:
amount = randint(100, 1000)
db_check = await self.bot.db.select("economy", ["*"], checks=[["user_id", interaction.user.id]],
single=True)
if not db_check:
await self.bot.db.insert("economy", [["user_id", interaction.user.id], ["wallet", 5000 + amount]])
embed = discord.Embed(title="Economy", description=f"You found `{amount}`$",
colour=col)
embed.set_author(icon_url=interaction.user.avatar, name=f"{interaction.user.name} Searched")
await interaction.response.send_message(embed=embed, ephemeral=True)
else:
await self.bot.db.update("economy", [["wallet", db_check[2] + amount]],
checks=[["user_id", interaction.user.id]])
embed = discord.Embed(title="Economy", description=f"You found `{amount}`$",
colour=col)
embed.set_author(icon_url=interaction.user.avatar, name=f"{interaction.user.name} Searched")
await interaction.response.send_message(embed=embed, ephemeral=True)
else:
embed = discord.Embed(title="Economy", description=f"Unlucky, You did not find anything.",
colour=col)
await interaction.response.send_message(embed=embed)```
Could someone help me with this error?
hey how do i make dropdown menu
Learn all about implementing Select Menus or Dropdowns in your Discord Bot with Pycord.
thnks
np
You can't use response twice
You used one to defer
And one to send
Oh right okay
Alright thanks, I'll try it
I recommend you search followup in the docs and see something related to interaction
Since my memory currently doesn't serve me properly
š
Is there something built in python to check ram, CPU, Storage usage or do I have to use external library? When I use an external library, it gives me the incorrect value unless my maths is wrong
I have been using that however when I check it against the host information, it gives me incorrect values
Unless my maths is wrong, which idk myself
Do you want me to have a look?
Alright
hey how do i create a loop which can create select menus
It's not hard to make loops
i know
i just want to know how to make aloop which can create select menus option things i guess its not possilbe
a bit unclear, but I think you need to search and learn by yourself, learn python basics, then try out a little bot with pycord, read the module's documentations and browse for any question
discord.errors.ExtensionFailed: Extension 'cogs.utility' raised an error: TypeError: select function must be a coroutine function what this error
probably exactly what it suggests š
@bridge.bridge_command()
@discord.Option(type = discord.Member, description = "User you want to coinflip with!")
@discord.Option(type=str, description = "Pick the side of the coin you inherit in this game!", choices = ["Heads", "Tails"])
async def coinflip(self, ctx: bridge.BridgeContext, user: discord.User, side: str):```
what is this error?
ive been getting non-stop errors for like 2 hours, i cant solve this one though
ok
rip
@option
same result, same error
guy didnt finish his work for like 5 months or something?
have u provided a name for the option?
yes
does @Option not work anymore?
yes
i didnt want to do it but fine
weird, works for me
lucky send ss of ur code
ill compare it with mine
and how do i define SlashCommandOptionType if i dont want to use decorators? Im trying without decorators
i used:
@bridge.bridge_command(name='test', description="Nothing of use lol")
@option('testoption', type=discord.Member, description="User")
async def my_command(self, ctx: discord.ApplicationContext, testoption):
pass
let me try this exact code
nope my first error came
great
strange
@rugged lanterncould u help with this?
TypeError: menu.select_callback() missing 1 required positional argument: 'interaction'
what is this error
we dont have your code so hard to tell
it comes whenever i add client in parameter
me?
yes
2sec
class menu(discord.ui.View):
@discord.ui.select(placeholder="select a category",options= [
discord.SelectOption(label= f"moderation", value="1",description="moderation commands"),
discord.SelectOption(label= f"utility", value="2",description="get the class names"),
])
async def select_callback(self, select, client: discord.Bot, interaction: discord.Interaction):
select.disabled = True
for names in client.get_cog("moderation").get_commands():
if select.values[0] == "1":
embed = discord.Embed(title="hello",description= f"{names}")
await interaction.response.send_message(embed= embed)
code of menu class
you don't need client in a callback
how would i define it
follow the example provided by the guide
Learn all about implementing Select Menus or Dropdowns in your Discord Bot with Pycord.
if you really want to provide client, you need to add:
def __init__(self, client):
self.client = client
```then in your call for the ``menu``, you provide ``client``
```py
view = menu()
view.client = discord.Bot
await ctx.send(view)
or you can just do
def __init__(self, client: discord.Bot):
self.client = client
...
await ctx.send(menu())
TypeError: menu.select_callback() missing 1 required positional argument: 'interaction' its same
what do u use to call it
sry i did it
yeah it should work for u, it worked for me at least :p
can i make a command only usable for a specific user?
(slash command), (without using if)
@bot.slash_command()
@discord.default_permissions(
administrator=True,
) # Only members with this permission can use this command.
async def admin_only(ctx: discord.ApplicationContext):
await ctx.respond(f"Hello {ctx.author}, you are an administrator.")
such as this
@commands.Cog.listener() async def on_member_update(self, before, after): print(before,after)
cant seem to make this work. Presence intents is true.
did u make sure to add it to your bot class too
you need the members intents too
only*
on_presence_update would require both but on_member_update only requires Intents.members
`intents = discord.Intents( guilds=True,members=True,presences=True)
class HallMonitor(commands.Cog):
def init(self, client):
self.client = client
@slash_command(description="id test")
async def id(self, ctx, user: Option(discord.User, "User", required=False)):
user = user or ctx.author
await ctx.respond(f"The ID of {user} is {user.id}")
@commands.Cog.listener()
async def on_member_update(self, before, after):
print(before,after)
def setup(client):
client.add_cog(HallMonitor(client)) `
i have members intents as well
do you have the intents in the main file?
but do you have intents=intents in your client object?
^
didnt, well that solved it. thanks guys (apologies for being a noob)
How can I wait for client.load_extension("cogs.database") to be fully executed before proceeding?
isn't that what the on_ready is triggered by
I'm not sure. I've tried but it didn't work.
dont load the cogs at the on_ready event....
I'm not doing it there.
async def on_ready(self):
await self.bot.wait_until_ready()
```? dunno
can anyone help me rq just 1 min of help neeeded
dont ask to ask
what
Donāt ask to ask, just ask
pls anyone help me
...
the embed first row isnt working
shameless
what?
Just post your full question and context. āIsnāt workingā isnāt a helpful description
The First row of Embed is not working i need someone to help me.
it's like going to the doctors saying 'help, something is wrong'
Lol
thats all what i can explain you i would need to screenshare to show it you will not understand
i would need to*
provide relevant code
Screenshots are a thing. So are pastebins for code. You donāt need someoneās direct time
ok sending ss
Whatās the context; you want your db cog to be loaded before any other cogs attempt to load?
Personally, I have my db inside bot instead of a cog; it loads before any cogs do
Well no, itās in the embed. Itās just not inside the code block
can you tell me how to fix?
By putting the output inside the code block tags, I guess. You didnāt post the code as requested
okay what do i do to fix it?
Put the three backticks before value1
u just move the row1 value to the right
Come on. Itās a string.
No. The answer requires very elementary knowledge of python. We have provided the answer, but we arenāt going to write the code for you
ok can you tell me briefly where to put the three `
Look at how you have it before value2
we literally told you. you don't need to add more of them, you MOVE it to the left of row1
Itās a string. Itās markdown that turns text into a fixed-width code block, as you already know (since youāre doing it for the rest of the output). You just need to change it to include your value1
so my string is wrong
wait ill send you one more string
does timestamps still work? <t:1663592960.827099> cuz then im doing it, its not working
em.set_footer(text="This is Not 100% Accurate, We will Not Be Responsable If you Loose Thank you For Using Our Predictor")
await ctx.reply(embed=em)```
I strongly urge you to review how strings work in python (which frankly is similar to every other language out there). There are a million and one YouTube videos that can help you.
This good?
yes?
Ints, not floats
oh
^^
āLoseā not āLooseā, but the syntax is fine enough
bruh but i want to make a giveaway bot, everything works but idk hot to do it correctly so that it adds the time to the datetime and transfers it to a timestamp
Ints, not floats You cast the time stamp to int
You donāt know how to cast a variable to a different type? ā¹ļø Thatās pretty basic python and can be easily rectified with some short research
yes thats the way to say it
yeah wait a sec
i want to research myself
sry quit coding half a year and restarting :D
Traceback (most recent call last):
File "C:\Users\Ahmad Kamil\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\Ahmad Kamil\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in run_code
exec(code, run_globals)
File "c:\Users\Ahmad Kamil.vscode\extensions\ms-python.python-2022.14.0\pythonFiles\lib\python\debugpy_main.py", line 39, in <module>
cli.main()
File "c:\Users\Ahmad Kamil.vscode\extensions\ms-python.python-2022.14.0\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 430, in main
run()
File "c:\Users\Ahmad Kamil.vscode\extensions\ms-python.python-2022.14.0\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 284, in run_file
runpy.run_path(target, run_name="main")
File "c:\Users\Ahmad Kamil.vscode\extensions\ms-python.python-2022.14.0\pythonFiles\lib\python\debugpy_vendored\pydevd_pydevd_bundle\pydevd_runpy.py", line 320, in run_path
code, fname = _get_code_from_file(run_name, path_name)
File "c:\Users\Ahmad Kamil.vscode\extensions\ms-python.python-2022.14.0\pythonFiles\lib\python\debugpy_vendored\pydevd_pydevd_bundle\pydevd_runpy.py", line 294, in _get_code_from_file
code = compile(f.read(), fname, 'exec')
File "c:\Users\Ahmad Kamil\Downloads\Untitled-1.py", line 211
description = \n{row1}\n{row2}\n{row3}\n{row4}\n{row5} \n Accuracy\n{info}%")
^
SyntaxError: unexpected character after line continuation character
PS C:\Users\Ahmad Kamil\Downloads>
You're missing a "
where
new error
dark, you should honestly just let them try to fix it
why is this channel called help then
All of this can be rectified by finding a nice YouTube channel on strings
ok
I don't know how to implement it that way because I need to await stuff but the main isn't async. 
Thereās a difference between helping with Pycord and teaching Python 101. Itās unfair to ask people to do something you should have knowledge on before starting with bots
this is the only i needed but its getting complicated
and it was urgent thats why
by help it is suggestive towards the definition: make it easier or possible for (someone) to do something by offering one's services or resources, not directly help you with your homework type of help
yes all im asking is to guide me
Itās not too urgent that you canāt learn how strings work. It will save you time in the long run.
what do i type in yt
Uhhhh. āPython stringsā? Wtf
ok
ive lost all hope
sorry if im arse
Solved. Thanks for the idea.
I donāt have it in front of me, but there are asyncio commands to execute async calls from a non-async context. Trying to find where I saw the example for db s (make sure youāre using an async library)
Oh, sweet.
Yes, I had it somewhere else.
loop = asyncio.get_event_loop()
loop.run_until_complete(load_database())
I'm not a fan of having 1000 lines of code in the main file but it works. 
I don't know how to split it without using cogs and if appropriate. 
Alright, so I have this modal:py class get_ad(discord.ui.Modal): def __init__(self): super().__init__( discord.ui.InputText(style = discord.InputTextStyle.long, label = "Enter your Advertisement", placeholder = "Maxium of 250 characters, 5 lines.", max_length = 250), title = "Advertisement", timeout = None) async def callback(self, interaction: discord.Interaction): await interaction.response.pong() and when open it using ```py
modal = get_ad()
await ctx.send_modal(modal)
Anything that can be compartmentalized can be a cog. If you have ālibraryā-type code, you could always put them into a non-cog file and import it to use the functions within. Structure is more of an art than a science, so up to you (with is frustrating to me sometimes haha)
I should try the library import solution because the cog solution had a problem I couldn't solve.
.pong()?
what
Wait never mind. That wasn't even my problem.
I have this, ```py
await commands.ColourConverter().convert(ctx, "#fff223")
sorry for like the late late response
import os
import psutil
pid = os.getpid()
python_process = psutil.Process(pid)
memoryUse = python_process.memory_info()[0]/2**30 # memory use in GB...I think
print('memory use:', memoryUse)
This just showing incorrect values so I'm confused af on what I'm doing wrong
How are you using this
can anyone help me with delete_after=5
yes?
it isnt working,
how do you use it?
@bot.command()
async def crash(ctx):
author = ctx.author.name
tag = ctx.author.discriminator
id = ctx.author.id
log = f"Command crash as been used by {author}#{tag} || ID : {id}"
print(log)
games = scraper.get("https://rest-bf.blox.land/games/crash").json()
if ctx.author.id != bot.user.id:
ok = await ctx.send(
embed=discord.Embed(title="Checking API",description="Connecting to the API...",delete_after=5,color=0x5ca3ff))
def lol():
r = scraper.get("https://rest-bf.blox.land/games/crash").json()["history"]
yield [
r[0]["crashPoint"],
[float(crashpoint["crashPoint"]) for crashpoint in r[-2:]]
]
for game in lol():
games = game[1]
avg = sum(games) / len(games)
chance = 1
for game in games:
chance = chance = 95 / game
prediction = (1 / (1 - (chance)) + avg) / 2
if float(prediction) > 2:
color = 0x81fe8f
else:
color = 0xfe8181
description = f"""
**Crashpoint:**
*{prediction:.2f}x*
**Chance:**
{chance:.2f}%
"""
em = discord.Embed(description = description, color=color)
await ctx.reply(embed=em)
the Checking API i want it to delete in 5 secs
but when i do command
it dosent delete
you have it in the embed
you need it in the ctx.send/reply
ctx.send("text", delete_after=5)
My modules in requirements.txt arenāt installing, is there any command I can run in my console to install all modules in that file?
should be pip install -r requirements.txt
or something along those lines
^
@bot.command()
async def crash(ctx):
author = ctx.author.name
tag = ctx.author.discriminator
id = ctx.author.id
log = f"Command crash as been used by {author}#{tag} || ID : {id}"
print(log)
games = scraper.get("https://rest-bf.blox.land/games/crash").json()
if ctx.author.id != bot.user.id:
** ok = await ctx.send("text", delete_after=5)
embed=discord.Embed(title="Checking API",description="Connecting to the API...",color=0x5ca3ff))**
look i fixed it but it isnt starting now
what am i doing wrong?
do you have something else installed?
let me try again
@young bone look
what your saying is correct but i want the text to be embed
i want to embeded text to delete
not "text"
than you have to edit the embed
Is there a way to get a Commands ID? I looked through the documentation, and can't find it anywhere.
slash commands?
yes
you can get it with client.get_application_command("Name")
negative
That doesn't return the intergration ID
it returns the ApplicationCommand, which does not have this data.
ok
ok, the documentation is failing to give this data.
The thing itself does give the data
annoying
I don't know why its not work. I want to add reaction. Help plz
message_r: discord.Message = await interaction.response.send_message(embed=embed, ephemeral=True, delete_after=60)
await message_r.add_reaction(ross)
Error:
AttributeError: 'Interaction' object has no attribute 'add_reaction'
What is this error:
@cold jetty - Instead of asking people to code for you (to which you are not paying for the service), you should be reading the Pycord docs. There's even a nicely formatted site with information that will help you understand how embeds and sends work. https://docs.pycord.dev/
But you still need to know how Python itself works at a basic level in order to make use of this information. We cannot learn it for you.
What is the difference between @discord.commands.slash_command, @discord.slash_command and @discord.ext.commands.slash_command? Looks like they all do the same thing and the last two have the exact same description in the docs. Is it just that the last two are a shortcut for the first one?
no need
he is good guy he solved all errors for me
And you learned nothing, which means the next time something doesn't work as expected, you're going to use this channel (or the person that helped) as a crutch. You're doing yourself a disservice.
You need the original response https://docs.pycord.dev/en/master/api.html#discord.Interaction.original_message
Is it just that the last two are a shortcut for the first one?
pretty much
fixed š¤
?
One question: Why the same message has different id?
https://paste.helpch.at/ogivecacix.py
~~Is it possible to get username from a given discord user ID?
I saved the UID into my database and I would like to get their name/nickname from that number.~~
await fetch_user(user_id) gottem
how can i catch This interaction failed error?
What is this error:
Im trying to use the bridge command but it's saying Context has no attribute 'respond'
@bridge.bridge_command(description="Test your luck with the magic 8ball.")
async def eightball(self, ctx, *, text):
await ctx.respond(embed=self.neko_api(ctx, "8ball").set_author(icon_url=ctx.author.avatar, name=text))```
The slash command works
just not the normad
neverming
nevermind
i found a way round @ me if im wrong but I just used try: and except:
Does anyone else have an issue with docker and azure where the bot goes offline without any error message, but all the other containers i have running are perfectly fine?
how can i send an message through an interaction in a certain channel
you don't, you respond to the interaction then use a get_channel method and run channel.send
if you know the emoji ID, you can use bot.get_emoji(id) and use it in the button's emoji argument
My discord bot uses Pycord & slash commands, but for some reason I don't get this symbol on my bot, I see others with it. How can I get it.
are there any global commands on it?
Yes.
not sure then, that appears to be the only requirement #discord-api-updates message
thanks
maybe my global command is wrong, even tried the example from the docs. is there any that is known to work I could simply paste in?
i don't know why this issue is happening.
i mean, is your global command working fine?
Yea, even tried the one in the documentation.
then idk
if you have a global command it should appear, if not i can't really help you further since there isn't another way to get the badge
Fixed it. Thanks anyways.
Anyone know why my slash command seems to be sending twice.
send code
@client.slash_command(name = "ping", description = "Checks the bot's latency")
async def ping(ctx):
embed=discord.Embed(color=0x0f47fff)
embed.add_field(name="Pong!", value=f"The bot's latency is `{client.latency*1000} ms.`", inline=False)
await ctx.send(embed=embed)
it's pretty basic.
it's ctx.respond
thx
One of my bot's commands are based around having multiple users in a channel. I've been only able to test my bot with 1 user (myself) in a channel. Is there a way to add "dummy" users to a channel for testing purposes?
Create alt accounts?
true lol, somehow didnt think of that
role = interaction.guild.get_role(1021515147145138208)
await interaction.user.add_roles(interaction.user, role)```
Traceback (most recent call last):
File "C:\Users\tearx\PycharmProjects\Starlia-Bot\venv\lib\site-packages\discord\ui\view.py", line 396, in _scheduled_task
await item.callback(interaction)
File "C:\Users\tearx\PycharmProjects\Starlia-Bot\cogs\verification.py", line 37, in verify
await interaction.user.add_roles(interaction.user, role)
File "C:\Users\tearx\PycharmProjects\Starlia-Bot\venv\lib\site-packages\discord\member.py", line 975, in add_roles
await req(guild_id, user_id, role.id, reason=reason)
File "C:\Users\tearx\PycharmProjects\Starlia-Bot\venv\lib\site-packages\discord\http.py", line 355, in request
raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10011): Unknown Role
I am getting this error?
I have all intents enabled
intents=discord.Intents().all()```
It appears that the role may not exist
Pretty much, discord is saying that it cannot find the role
It does though
<Role id=1002645940722728981 name='@everyone'>, <Role id=1021515147145138208 name='Verified'>, <Role id=1021504438675964006 name='Starlia'>]
Are you sure you have the correct role id?
yes
Maybe try using fetch_role instead?
ill try
Correction: Use guild.fetch_roles() and then loop through the result trying to find the exact role
how can i add this to my bot?
Your bot must be verified and use slash commands. Once it is, Discord will automatically do that for u
(#discord-api-updates message)
It's not working
mine is not verified unfortuantly
Is there an error message?
If there is, send that and the code
reread your code
I used this to create a select menu for my bot but even when I set the min and max values to 1 it still lets me select multiple values and select the same values multiple times. I want it so the user can only select it once, how can I go about doing this?
class MyView(discord.ui.View):
@discord.ui.select(
placeholder="Choose an option",
min_values=1,
max_values=1,
options= [
discord.SelectOption(
label="E"
),
discord.SelectOption(
label="P"
),
discord.SelectOption(
label="C"
)
]
)
async def select_callback(self, select, interaction):
if select.values[0] == 'E': await interaction.response.send_message("EEEEEEEEEEE")
elif select.values[0] == 'P': await interaction.response.send_message("PPPPPPPPPPP")
elif select.values[0] == 'C': await interaction.response.send_message("CCCCCCCCCC")
role = interaction.guild.get_role(1021515147145138208)
print(role)```
it've done this and role returns "Verified"
reread your add_roles line
it should be max 1 value by default... what if you remove both min_values and max_values?
hmm lemme try that
Nope, it still exhibits the same behavior
are you sure it's that view being sent?
don't think there's any bugs that would cause this
no that's not what it means
ohhh
the min/max_values arguments tell the bot how many can be selected at the same time
gotcha
if you want to disable the select then you should do it in the callback and edit the message again
or just straight up remove the view if you want
yeah that works
also instead of using if/else there you could simply take self.values[0] and multiply the string
though ig that's just an example
@bridge.bridge_command(description=" Gets the ping of the bot")
async def ping(self, ctx):
embed = discord.Embed(
title="Bot Stats",
colour= discord.Colour.green()
)
embed.add_field(name="Ping", value=f'Pong! {round(self.Client.latency * 1000)}ms')
embed.set_footer(text=f' Called by {ctx.author.name} |Hyper Tech Bots')
await ctx.respond(embed=embed)
I am trying to get the commands with bridge working but when I run it.
The prefix one does not work.
And yes I have intents on.
If anyone sees anything wrong with this and can tell me that would be great.
how are the intents enabled?
and do you have an on_message event?
I do but that was solved a long time ago.
Like theyāre not even registering us new commands.
As they did new things to the commands, and they didnāt change anything.
Got any ideas?
Now I am getting this errror.
And not sure why as I did it like how it was in the guide.
does anyone know of anywhere i can send an epic username and return the account id?
Google can help you find what you're looking for. š
I feel like there is a simple answer to this question but is there a way to get the pressed button info? I cant find a way to get it from the interaction response. THis is from the documention but whenever i try to put a button argument it doesn't like it and only wants the interaction argument
@bot.event
async def on_ready():
bot.add_view(MyView()) # Registers a View for persistent listening
class MyView(discord.ui.View):
def __init__(self):
super().__init__(timeout=None) # timeout of the view must be set to None
@discord.ui.button(label="A button", custom_id="button-1", style=discord.ButtonStyle.primary, emoji="š") # the button has a custom_id set
async def button_callback(self, button, interaction):
await interaction.response.send_message("Button was pressed", ephemeral=True)
@bot.command()
async def button(ctx):
await ctx.send(f"Press the button! View persistence status: {MyView.is_persistent(MyView())}", view=MyView())
what pressed button info
just a button in a discord.ui.View
i get the interaction info just fine, i want to pass the button that has been pressed / clicked to the callback function
it's literally right there
what's wrong with your current code?
async def button_callback(self, button, interaction)```
do you have discord.py installed?
Traceback (most recent call last):
File "C:\Users\richa\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ui\view.py", line 396, in _scheduled_task
await item.callback(interaction)
TypeError: Library.MARK_AS() missing 1 required positional argument: 'interaction'```
I switched from discord.py to pycord a little while ago
are you using replit?
Don't seems so
no just vscode on my laptop, that what you mean?
Try defining them
hm the line number does match our master branch
but i don't see why that error would occur
like button: discord.ui.button, interaction: discord.Interaction@zealous lark
ooo ok, ill try that
you mean "type-hinting" them
wait
that error's for a different button
can you show the code for the button that's erroring
the callback function or everything?
everything i suppose
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
this is included in my main file
so that's why
indeed, when you have a button without a decorator the only argument would be interaction; button isn't available there, which loops back to your original question
i would recommend defining a custom_id for the buttons
then you can get the button object from self.children
wait
i suppose self.get_view().children
good to know, thanks
what will that return?
all buttons in the view
or items i suppose
e.g. discord.utils.get(self.get_view().children, custom_id="...") will return an item with the specified custom_id from the view
this
callbacks have different arguments depending on how the item is created
if you use a decorator such as ui.button, then the arguments are (button, interaction) (+self in a class)
so i do need to impliment custom_ids?
but without a decorator, the only argument is interaction
i'd recommend it for sake of identification, but technically you can do this with any attribute
fair enough
e.g. if all the labels are guaranteed to be unique, you could do label="..." instead of custom_id="..."
no idea what you're talking about. Haven't dived into custom_ids at all yet
but i will, thanks
custom_id is just a unique identifier for any item, nothing too complex
oh i suppose i misunderstood your get_view(), you basically need some way of getting the view object
i'd suggest storing your current view as self.view inside your get_view() function
that way you can reference it in any function
oohh yeah that's smart
can the view see what has been clicked?
well the view just stores the items, you only get a reference in the interaction
because interaction contains the custom_id attribute as the sole identifier of what was clicked
(which is why it's useful to search view.children with)
though
custom_id can be randomly generated for you so if you don't care about what it is and you only need what's clicked i guess you can search anyway
so interaction.custom_id will return str it looks like wheich i then can search self.view with to find the button object that has been clicked?
mhm
alrighty! thank you very much explaining that all to me
the easiest way would be discord.utils.get(self.view.children, custom_id=interaction.custom_id)
maybe i should add view.get_item as an alias...
are you a dev for pycord?
not necessarily, anyone can contribute
oh neat, so you have contributed?
a few times i guess
hey, could anyone tell me how to get a message link in context commands
yes - message.jump_url
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.")
thx i solved the problem
Ok
can anyone good free 24/7 host not replit nor uptimer
is it against tos to make a bot without a prefix?
?
Why would you think that?
Railway - https://railway.app
since they're about to force bots to use slash commands and no prefix lets a bot be invoked without the user's knowledge
Well what are you wanting to do. And theyāre only forcing verified bots to use slash commands.
if they donāt have the message content intent
@rare ice Thank you.
Guys, please help. Only in this channel does this error appear, I have already set a delay. The messages are not deleted, but when the bot puts all the reactions, it sends the following error.
404 Not Found (error code: 10008): Unknown Message
maybe translate to enlish
photo?
yes
I have already posted the error above. The rest of the message is not important
You should probably check if the bot permissions in that channel are the same as in other channels where it works.
It doesn't help
Same for the category where that channel is in? I'm out of ideas.
Just ask what you need and we'll see.
@spice oyster how to put github code and host it with railway
I have no experience with Railway.
the on disconnect event, is it the bot going offline completely or even more?
if you read ;3
yes but I wanted more clarity, since if this event can be called many times as said, what I'm looking for is the event that it disconnects fully and won't be able to reconnect, which is why I was asking just to be sure
might be best for you to just go through the connect function https://github.com/Pycord-Development/pycord/blob/master/discord/client.py#L517
on_disconnect can fire for various reasons, including right before reconnects and other exceptions
Hmmm, I was hoping that the on_disconnect would like be where the bot completely goes offline and it can't reconnect back to discord at least like a final alert somehow without connecting to Discord API send out a message that the bot died.
Since the on_disconnect can be fired for various other reasons, the best thing I can do is compare the on_connect to on_disconnect but from there I'll have to see how I'll do that.
Is there a time set of how long will it take for the Bot to connect after it disconnects?
the delay is exponential, so it'll start small then increase if there's multiple reconnects
would anyone happen to know why my autocomplete is not completing as i type?
async def get_langs(self, ctx: discord.AutocompleteContext):
return googletrans.LANGUAGES
@commands.slash_command(description='Translate text straight from discord')
async def translate(self, ctx: discord.ApplicationContext, language: discord.Option(str, 'The language to translate to', required=True, autocomplete=get_langs)):
await ctx.respond('placeholder')```
is googletrans.LANGUAGES a list
oh it HAS to be a list?
well
yeah
what were you going for?
if you want a dict like name:value then that's possible, but it'd still be as a list; just using OptionChoice instead
yeah, so i did .values(), now it returns a list but it still wont autocomplete
print(googletrans.LANGUAGES.values())
dict_values(['afrikaans', 'albanian', 'amharic', 'arabic', 'armenian', 'azerbaijani', 'basque', 'belarusian', 'bengali', 'bosnian', 'bulgarian', 'catalan', 'cebuano', 'chichewa', 'chinese (simplified)', 'chinese (traditional)', 'corsican', 'croatian', 'czech', 'danish', 'dutch', 'english', 'esperanto', 'estonian', 'filipino', 'finnish', 'french', 'frisian', 'galician', 'georgian', 'german', 'greek', 'gujarati', 'haitian creole', 'hausa', 'hawaiian', 'hebrew', 'hebrew', 'hindi', 'hmong', 'hungarian', 'icelandic', 'igbo', 'indonesian', 'irish', 'italian', 'japanese', 'javanese', 'kannada', 'kazakh', 'khmer', 'korean', 'kurdish (kurmanji)', 'kyrgyz', 'lao', 'latin', 'latvian', 'lithuanian', 'luxembourgish', 'macedonian', 'malagasy', 'malay', 'malayalam', 'maltese', 'maori', 'marathi', 'mongolian', 'myanmar (burmese)', 'nepali', 'norwegian', 'odia', 'pashto', 'persian', 'polish', 'portuguese', 'punjabi', 'romanian', 'russian', 'samoan', 'scots gaelic', 'serbian', 'sesotho', 'shona', 'sindhi', 'sinhala', 'slovak', 'slovenian', 'somali', 'spanish', 'sundanese', 'swahili', 'swedish', 'tajik', 'tamil', 'telugu', 'thai', 'turkish', 'ukrainian', 'urdu', 'uyghur', 'uzbek', 'vietnamese', 'welsh', 'xhosa', 'yiddish', 'yoruba', 'zulu'])```
do list(googletrans.LANGUAGES.values())
but again, if you were wanting dict-like functionality in autocomplete you can still do it
no thats fine i just need the simple names for people, works either way
fair enough
this still doesnt match it
oh right
isee
you'd have to do something like ctx.value in ... but this logic can be handled for you with basic_autocomplete
perhaps something like this would work```py
language: Option(str, "...", autocomplete=discord.utils.basic_autocomplete(list(googletrans.LANGUAGES.values())))
sick it works, thank u very much
all good
inside? don't think that's possible
you can send a view and embed in the same message
yeah, i tried that
thanks
So with default_permissions being a thing, do you guys still use has_permissions as well? Or do you trust the server owners to not be idiots when configuring slash commands within discord
i mean it ultimately depends on the bot, if it's your own personal bot then i'd still use has_permissions
but if it's intended for others to be able to manage the permissions then it may be better to not hard-limit them
Yeah it's a public bot
I'll prob just add smth to my tos that says "dev is not responsible for dumb perm setups"
You should use both
I can see the commands on my phone
even if you can see commands you arent meant to be able to run, discord will stop you
how can i update the options on a command? The options are based on current date
Can I get the date when a user got banned?
are slash commands disabled by default if u dont have permission to use them?
using default_permissions
How can i format a float in hh mm ss
if they are asking to put it as float, you should be able to, first do yk what a float is?
how would i go about adding options from a dict to a select menu?
not available
i guess use autocomplete to get the current date
should be
elaborate
like the key: value should be the option label and value respectively?
sort of, the main part i dont know how to do is adding an option for each item in the dict
well you can iterate through dict.items() as two variables to represent key and value
i.e. for k, v in my_dict.items():...
then you can use select.add_option in this loop https://docs.pycord.dev/en/master/api.html#discord.ui.Select.add_option
oka ive read the docs for that but idk where to put it. does it go under the @discord.ui.select decorator? or somewhere else?
the decorator is for the select menu itself (though you don't have to use it)
but select options are added separately
Here's the dropdown example.
ohhhhh ok thanks, i think i got it now
Dear ones, can I use the first post on these forums to check if it's a photo or not?
you want to check if the first message in a channel contains an image?
you can use channel.history with oldest_first=True and limit=1 to get the first message (in a list)
https://docs.pycord.dev/en/master/api.html#discord.TextChannel.history for examples
then when you have that message, you can check message.attachments
And if not, then delete this thread, and if yes, then automatically set reactions
right, so simply check if any item in message.attachments is an image (maybe file.content_type would be of interest)
https://docs.pycord.dev/en/master/api.html#discord.Message.attachments
https://docs.pycord.dev/en/master/api.html#discord.Attachment
Thank you, and then the usual channel with drawings, I want to translate to the forum
if there are no images, message.delete https://docs.pycord.dev/en/master/api.html#discord.Message.delete
if there is an image, message.add_reaction https://docs.pycord.dev/en/master/api.html#discord.Message.add_reaction
translate?
i suppose you want to send the image to another channel?
That's not. I just want to delete a branch if the branch was opened without a photo, and if with a photo or a photo with text, then put reactions so that people evaluate
ahh forum channels
then yeah what i said above still stands, but perhaps you want on_thread_create? https://docs.pycord.dev/en/master/api.html#discord.on_thread_create
Oh, yes, I probably explained it wrong
Here it makes a branch, if a photo, and if not, then it curses a person and deletes the text
I call it PhotoMod
Ta no, I'll explain now
Here, if as in the 1st screenshot, then delete this publication, and if as in the 2nd screenshot, then leave the publication and add emoticons
Is that how it works? Okay, thanks
mhm
thread.starting_message is the message they used to create the thread
so you can check that message to see if it has an image
after that, the other things i said above apply
I'm going to try
It took me a while but I've figured out how to put the database creation code in a separate file. 
My command isnt working after 1 usage. So I can use it one time but after that it says the command does not respond
async def lootbox_add(ctx, user, amount):
profile = collection.find_one({"_id":user.id})
if profile is None:
newuser = {"_id":user.id, "lootbox_amount":1}
collection.insert_one(newuser)
await ctx.respond(f"{user.mention} `{amount}`")
await statAddLootbox(amount)
else:
lootboxNum = profile["lootbox_amount"] + amount
collection.update_one({"_id":user.id}, {"$set":{"lootbox_amount":lootboxNum}})
await ctx.respond(f" {user.mention}. `{profile['lootbox_amount']}`.")
await statAddLootbox(amount)
async def lootbox_remove(ctx, user, amount):
profile = collection.find_one({"_id":user.id})
if profile is None:
await ctx.respond(f"{user.mention} has no lootbox/es.")
else:
lootboxNum = profile["lootbox_amount"] - amount
collection.update_one({"_id":user.id}, {"$set":{"lootbox_amount":lootboxNum}})
await ctx.respond(f"{user.mention}`{profile['lootbox_amount']}`")
await statRemoveLootbox(amount)
lootboxGroup = bot.create_group("lootbox", "option")
@lootboxGroup.command(description="d")
async def add(ctx, user: Option(discord.User, "", required = True), amount: Option(int, description="The amount of lootboxes you want to give.", default=1, min_value=1)):
try:
if ctx.author.guild_permissions.manage_roles == True:
await lootbox_add(ctx, user, amount)
else:
await ctx.respond(f".", ephemeral=True)
except Exception as e:
print(e)
@lootboxGroup.command(description="j")
async def remove(ctx, user: Option(discord.User, "k", required = True), amount: Option(int, description="j", default=1, min_value=1)):
if ctx.author.guild_permissions.manage_roles == True:
await lootbox_remove(ctx, user, amount)
else:
await ctx.respond("j", ephemeral=True)
I get no error
Try deferring it?
no errors?
nope nothing
It shouldnt happen at all.. It should work like that ig
Not related to your question but please check if the amount is equal to 1 and change the string to singular/plural accordingly. 
hm, first I need to get it to work š
Are there any ways to optimize RAM even more past turning off all unused intents? Ping on reply please
Is there any way to format embeds? E.g. id like it to be horizontally as it should be a leaderboard. So first line Schnappi 3 and the next line with Hello Bot 3
inline=True irc
gc.collect()?
where gc is the python garbage collector
Not quite, this is what i would get. But Schnappi and "3" horizontally in one line. And the next ones like that under those
leave them on one line
description = "name - score/nname - score"
I'd need to iterate through a list to get the names/score. Would it be possible like that?
yes
use f-strings
I'll give it a try, thanks!
may be a dumb question but how can I pass a variable to a view?
For example I have command / tryme. Inside of this command i spawn my view for my buttons. I want to pass a string to the buttons so they can do some logic, but it seems the view does not take args other than items, timeout, and disableon timeout.
Is there an automatic convertor when you input in channel ID in options, that it'll turn it into an object if it is valid?
user: discord.Option(discord.Member, required=True)
# This makes it so that you can put in User ID and it'll automatically convert into an object I believe
Is there a similar thing for TextChannels? I did use discord.TextChannel and it gave me incorrect TextChannel ID. The channel ID is in a different server that the bot has access to
it does work if I put in the channel ID in the server that I'm using the commands in
But doesn't gc automatically collect all vars after the callbacks are run?
not exactly
Alright, but I don't believe I'm storing any large temp vars
I'll try it anyway though
Should I have a task running every 5 min or so that just runs gc.collect()?
should be fine
garbage collection runs automatically anyways
how often does it run?
Ok
gc.collect() won't remove all vars right, just the ones that are locals for functions that have finished running?
it removes all unreferenced objects from memory
if it can't be accessed by anything it's generally considered garbage

I believe adding
def _init_(self, thingywanttopass):
self.thingywanttopass = thingywanttopass
Dont quote me, since i have yet to touch views properally.
That's correct. (Although don't forget to call super().__init__())
So im not at my pc rn
But using slash commands is there a way to have the "products" suggest be different depending on the server?
Like theres a command to add a product, and its linked with the server id
But i dont know how to make the suggested show up differently on each server
Because server 1 shouldnt know / have the same products as server 2
(Using option)
You can use autocomplete
Here's the slash autocomplete example.
if you're using messages or members you could also reduce/disable some caching for them
Shutting off the intents should disable caching right?
yeah, but just in case you still wanted those intents enabled
How is an attachment link formatted?
I know that for Discord message links, they are formatted as:
https://discord.com/channels/{guildid}/{channelid}/{messageid}
But for attachment links, I can't figure out one of the arguments
So far I've gotten:
https://cdn.discordapp.com/attachments/{channelid}/{unknownarg}/{example.txt}
Are there events for guild-avatar updates, about me updates, and guild about me updates?
Are you looking for this?
url = "attachment://example.png"
attachments have IDs
https://discord.com/developers/docs/reference#image-formatting-cdn-endpoints here's all the cdn endpoints if you're interested
Integrate your service with Discord ā whether it's a bot or a game or whatever your wildest imagination can come up with.
attachments isn't on there for some reason
how can i have my discord bot send stickers? is there a syntax for stickers similar to the one there is for emoji, i.e. <:emoji_name:emoji_id>?
thank you!
oh, relatedly, idk who manages the docs, but there seems to be a formatting error for that method:
worked like an absolute charm, thank you very much š
forgot the async but yeah. exact result i wanted
how do i send a regular message, not a response with interaction?
i want to edit a message and send a message
ctx.send?
can anyone help me with github how do i pt my code in github
i dont have ctx since im in a select
hence i asked about interaction
just add ctx to it then
i dont think thatd work
it does
no it doesnt
yes it does work if you do it correctly
class seeBoard(discord.ui.View):
@discord.ui.button(label="Hand", style=discord.ButtonStyle.primary)
async def seehand(self, button, interaction, ctx):
game = load(interaction.channel)
await ctx.send(game['hand' + str(interaction.user)[0:-5].lower()], ephemeral = True)
await interaction.response.edit_message(content=buttonBoard())``` just adding ctx to the arguments wont make it work i assume
you can't just add it like that
in your class add def __init__(self, ctx)
in your call for the class, addsomething like
view = seeBoard(ctx)
remove it from the callback
do i tab my @discord.ui.button and async def once then?
to put it in the def __init__ block
and if i have another button in the same class, do i do the same to that button too?
do i need to put it in the def __init__ block too
self.ctx = ctx?
dont you mean ctx = self.ctx
no
interaction.channel.send()
ty
You dont need ctx for that
yeah i was hoping there was a more obvious more easy solution
i cant use ephemeral when i send messages this way, cant i
Try it
i did and it doesnt work
No, but you can use delete_after to get a similar effect.
Although it could be not enough, depending on what you are sending.
You can probably do that with send_followup() instead of send_response().
Do you have access to it? If not, you have to pass ctx. No shortcuts available.
but passing ctx takes at least 5 seconds š
is there no instantly solve my problem cus lazy-way?
nope. i do not have remote access to your pc
or whatever else you're hosting it on
nvm
Please help. When I create a message, I write it to a variable. After I get the id from the variable. After in the on_reaction_add function, I again try to get the id. But it differs from the one I received the first time. What to do and how to fix it?
async def callback(self, interaction: Interaction):
embed = discord.Embed(title='1', colour=discord.Colour.darker_gray())
embed.add_field(name="2", value=self.children[0].value, inline=False)
embed.add_field(name="3", value=self.children[1].value, inline=False)
embed.add_field(name="4", value=self.children[2].value, inline=False)
embed.add_field(name="5", value=self.children[3].value, inline=False)
embed.add_field(name="6", value=self.children[4].value, inline=False)
# await client.get_channel(1021084385543471145).send(embed=embed)
message = await interaction.response.send_message(embed=embed, delete_after=60)
messages_ids[interaction.user.id] = message.id
print(message.id)
@client.event
async def on_reaction_add(react, user):
print(messages_ids[user.id])
print(self.message.id)
on_reaction_add takes reaction and user
Why are you using self? You're not in a class
interaction.respose.send_message returns an Interaction object.
Interaction.id is the Interaction ID not the message ID
Anyway it doesn't solve my problem, but i fix this
Based on what dark said, you should probably do interaction = await ... while sending the message and then interaction.message.id.
What about reading the other 3 messages below that one?
hey, does anyone know how to work with lavalink? -> i want to make a command to replay the last played song from queue
This is what you should do. Just wanted that you to do it yourself by looking at the documentation with the info I provided
I don't think lavalink stores the last song played. You could store it somewhere
ah alright yeah thanks
I wrote too much. I agree that people should use the documentation more often. 
How do I have the bot auto delete this message? I donāt want peoples emails being able to be known by everyone
I looked through the docs but couldnāt figure out how to phrase what I was looking for
You can use ephemeral=True when responding so only the user can see the response.
Ty
Ignoring exception in on_interaction
Traceback (most recent call last):
File "C:\Users\ilush\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 127, in wrapped
ret = await coro(arg)
File "C:\Users\ilush\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 1201, in _invoke
await command.invoke(ctx)
File "C:\Users\ilush\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 356, in invoke
await self.prepare(ctx)
File "C:\Users\ilush\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 278, in prepare
if not await self.can_run(ctx):
File "C:\Users\ilush\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 373, in can_run
local_check = cog._get_overridden_method(cog.cog_check)
AttributeError: '_MissingSentinel' object has no attribute '_get_overridden_method'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\ilush\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 1009, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\ilush\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 359, in invoke
await injected(ctx)
File "C:\Users\ilush\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 135, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: '_MissingSentinel' object has no attribute '_get_overridden_method'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\ilush\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 382, in _run_event
await coro(*args, **kwargs)
File "C:\Users\ilush\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 1058, in on_interaction
await self.process_application_commands(interaction)
File "C:\Users\ilush\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 756, in process_application_commands
await self.invoke_application_command(ctx)
File "C:\Users\ilush\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 1013, in invoke_application_command
await ctx.command.dispatch_error(ctx, exc)
File "C:\Users\ilush\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 401, in dispatch_error
local = cog.__class__._get_overridden_method(cog.cog_command_error)
AttributeError: type object '_MissingSentinel' has no attribute '_get_overridden_method'
Ignoring exception in command favorites show:
Traceback (most recent call last):
File "C:\Users\ilush\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 127, in wrapped
ret = await coro(arg)
File "C:\Users\ilush\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 1201, in _invoke
await command.invoke(ctx)
File "C:\Users\ilush\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 356, in invoke
await self.prepare(ctx)
File "C:\Users\ilush\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 278, in prepare
if not await self.can_run(ctx):
File "C:\Users\ilush\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 373, in can_run
local_check = cog._get_overridden_method(cog.cog_check)
AttributeError: '_MissingSentinel' object has no attribute '_get_overridden_method'
The above exception was the direct cause of the following exception:
can anyone help me, i still have no idea why am i getting this error
update py-cord
aeval 0.1.3
aiohttp 3.7.4.post0
anilibria.py 0.1.0
AnilistPython 0.1.3
anyio 3.5.0
apiai 1.2.3
arrow 1.2.2
async-generator 1.10
async-timeout 3.0.1
atomicwrites 1.4.0
attrs 21.4.0
beautifulsoup4 4.10.0
Brotli 1.0.9
bs4 0.0.1
calendra 7.0.0
certifi 2021.10.8
cffi 1.15.0
cfscrape 2.1.1
chardet 3.0.4
charset-normalizer 2.0.10
click 8.1.2
cloudscraper 1.2.60
colorama 0.4.4
covid-stats 0.0.1
cryptography 37.0.2
Cybernator 0.6.3
deep-translator 1.8.3
Deprecated 1.2.13
discord-together 1.2.3
discord-webhook 0.14.0
discum 1.4.0
ffmpeg-python 0.2.0
filetype 1.0.13
future 0.18.2
geojson 2.5.0
googletrans 3.0.0
gTTS 2.2.4
h11 0.9.0
h2 3.2.0
hpack 3.0.0
hstspreload 2021.12.1
httpcore 0.9.1
httpx 0.13.3
hyperframe 5.2.0
idna 2.10
imageio-ffmpeg 0.4.7
iniconfig 1.1.1
install 1.3.5
joblib 1.1.0
jplephem 2.17
keyboard 0.13.5
libmesh 0.0.6
lunardate 0.2.0
lxml 4.9.0
lyricsgenius 3.0.1
more-itertools 8.13.0
MouseInfo 0.1.3
multidict 6.0.1
mutagen 1.45.1
nltk 3.7
numpy 1.22.4
outcome 1.1.0
packaging 21.3
pafy 0.5.5
Pillow 9.1.0
pip 21.2.4
pluggy 1.0.0
progressbar 2.5
py 1.11.0
py-cord 2.1.3
PyAutoGUI 0.9.53
pyCalverter 1.6.1
pycparser 2.21
pycryptodomex 3.15.0
PyGetWindow 0.0.9
pyluach 2.0.0
PyMsgBox 1.0.9
PyNaCl 1.4.0
pyOpenSSL 22.0.0
pyowm 3.2.0
pyparsing 3.0.9
pyperclip 1.8.2
pyrandmeme 0.0.5
PyRect 0.2.0
PyScreeze 0.1.28
PySocks 1.7.1
pytesseract 0.3.9
pytest 7.1.2
python-dateutil 2.8.2
python-twitch-client 0.7.1
pytweening 1.0.4
pytz 2021.3
random2 1.0.1
redis 4.3.4
regex 2022.3.15
requests 2.27.1
requests-toolbelt 0.9.1
rfc3986 1.5.0
selenium 4.1.5
setuptools 58.1.0
sgp4 2.21
six 1.16.0
skyfield 1.42
skyfield-data 4.0.0
sniffio 1.2.0
hmm try uninstall py-cord and reinstalling it
same error((
For what is the discord stuff?
they don't conflict with the discord package
i'm coded in discord py 1.7.3 earlier
What causes guilds to be unavailable? Is it just when the bot is no longer a member of that guild?
Ok so I found this
Why/how would a guild be "offline?"
ok so I'm trying to catch some errors when something fails, which is via try and except
try:
await bot.get_channel(int(User_Message.content)).send(embed=Embed)
except commands.BotMissingPermission.missing_permissions as Error:
await ctx.repond(Error)
the exception is not working at all, I hope I'm using the correct one, I did also have the discord.Forbidden. but I want to catch the exact missing permission so I'm confused
My Error:
Ignoring exception in on_ready
Traceback (most recent call last):
File "C:\Users\e\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 382, in _run_event
await coro(*args, **kwargs)
File "C:\Users\e\PycharmProjects\RB-Bot copy\main.py", line 28, in on_ready
await bot.logger.info("Test")
File "C:\Users\e\PycharmProjects\RB-Bot copy\logs.py", line 77, in info
async with aiohttp.ClientSession as session:
AttributeError: \_\_aenter\_\_
The code that causes it:
async with aiohttp.ClientSession as session:
log_webhook = Webhook.from_url(url=self.webhook, session=session)
Any idea what could cause the error?
except commands.BotMissingPermissions as e:
tried that one too for some reason it doesn't trigger it
lemme do it again
just got this error
commands.BotMissingPermissions is typically raised when the @commands.bot_has_permissions() check fails
I presume there's no way to check if I can get the exact perms missing right?
Just put this check in your command, that way you can make sure you have the perms you need
I get different errors on either the bot (I believe can't send messages which is error 403 and if it can't view the channel (401 or 402??)
Alr, I'll give it ago, I presume the global error won't get triggered?
this one
Anyone?
How do I remove the color of an embed? Like so
How does one manually make a command without the decorator? I need to programmatically assemble some commands. The docs says
These are not created manually, instead they are created via the decorator or functional interface.
But I'm not sure what the functional interface is
Do u know, how can i fix this? Maybe there is some method to get message from interaction
is there a way to disable all commands in dms at once?
Literally read the conversation. The answer is there
I do that ```interaction = await interaction.response.send_message(embed=embed, delete_after=60)
print(interaction.message.id)
?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.
Ok, i want to get message id from interaction. I try to use code, but it doesn't work
It still gives me the wrong id, not message id but interaction
It' all, i describe everything
Are the pycord examples in the GitHub up to date?
not all of them
yeah they donāt really seem like it
Iām looking for an example of slash commands in cogs with options
no but it has not changed
you can use ```py
@discord.option()
or
def(ctx, text: Option())....
some of them doesn “t work
any in particular?
Does commands.guild_only() apply for slash command?
there are very few people here that know how to navigate the mess of audio processing in the lib
kk ty
it will do an internal check, but if you want it to apply on discord's end you should use @discord.guild_only()
got it ty
theres an error when trying to host my bot and its a general pycord problem
there is the error
im trying to make a levelling system and I dont want people to be able to spam it can I use @commands.cooldown(1, 5, commands.BucketType.user) in a cog listener
I think so
Hello, help plz.
I want to get raction id, but have Error. What i should do?
Code:
@client.event
async def on_reaction_add(reaction, user):
if ids.get(member.id) is not None:
if ids.[member.id] == reaction.message.id:
print(reaction.emoji.id)
Error:
AttributeError: 'str' object has no attribute 'id'
alright
You have conflicting libraries
what does that mean??
Means, you have conflicting libraries lmao
You have other discord package
That conflicts with py-cord
So i put my command in a cog in a file and it's working perfectly, but now that i made another cog in a different file that one wont 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.
Help please
Why does my addmoney command work and my collect command doesn't?
It means you still have discord.py/discord or some library that still uses discord.py such as topggpy
Is markdown not available for embed footers?
footer you mean?
Yeah footer lmao
No, discord doesn't parse mentions or markdown there
Got it, thanks
@wooden zenith Please stop cross-posting.
Please stop cross posting
Choose your own help thread or this main help thread. Not both.
Next question:
I create a modal, everything works well, it remembers the text. The problem is this: when I post my answers, the modaldoes not close, and it says that something went wrong. What to do in this situation?
Code:
async def callback(self, interaction: Interaction):
embed = discord.Embed(title='1', colour=discord.Colour.darker_gray())
embed.add_field(name="2", value=self.children[0].value, inline=False)
embed.add_field(name="3", value=self.children[1].value, inline=False)
embed.add_field(name="5", value=self.children[2].value, inline=False)
embed.add_field(name="6", value=self.children[3].value, inline=False)
embed.add_field(name="6", value=self.children[4].value, inline=False)
overwrites = {
interaction.user: discord.PermissionOverwrite(read_messages=True),
interaction.guild.default_role: discord.PermissionOverwrite(read_messages=False),
interaction.guild.me: discord.PermissionOverwrite(read_messages=True)
}
channel = await interaction.guild.create_text_channel('secret', overwrites=overwrites)
message1 = await client.get_channel(channel.id).send(embed=embed, delete_after=60)
msg = message1
await msg.add_reaction('\U00002611')
await msg.add_reaction('\U0000274C')
messages_ids[interaction.user.id] = msg.id
you need an interaction.response
Yeah, thanks, i know that, but what i should do with interaction.response?
each interaction requires an interaction. You can send a message response saying Done.
How to find a word in multiple files? (get file paths)
No crosspost. thanks.
if i have a slash command and use @default_permissions(...), what will it look like for people without the permissions? will it not show up at all? or will it show up but have some sort of "you're not allowed to use this" message?
It will not show up or be grayed out (forgot which one)
How do I set a cooldown for a user to use a command?
not a global cooldown, only for the user that did the command
thanks
is there a way to tag a user like @somber cloak without giving them a notification?
i could just use the user's nickname, but it's nice to be able to click on them and see their profile
Use the allowed_mentions kwarg when sending the message
is it possible to make a slash command only usable/visible in a specific channel?
not currently, would be neat if discord added support for that tho. only guild specific
can't you do that manually by going to server settings -> integrations?
Probably could through permissions I would assume bot not through code
allowed_mentions=discord.AllowedMentions.none()
I think this is how
Hi, I'm trying to figure out how to edit a message depending on whether or not a value starts with a vowel (or y), but I can't seem to get it to work. Here's the part of the code I need help on (the variable names have been changed, and I'm pretty sure every variable shown has been defined somewhere in the code):
if prompts1[0] in vowels:
sentence = GlobalVariable1
else:
sentence = GlobalVariable2
embed = discord.Embed(title = "Create your sentence!", description = sentence)
embed.set_author(name = f"Your word is {word}, which is a {prompt}")
await self.edit_original_message(embed = embed)
I've tried using startswith() as well but nothing seems to work. I don't even get an error in the log, it just fails to edit the message. I'd appreciate some help!
Try self.bot.edit_original_message 
I'm running into a weird problem
Figure 1py @app.route('/test1') def test1(): try: URI = request.args['view'] except: return "<h1>Access Denied</h1>" f = requests.get(URI) return f.contentFigure 2py @app.route('/test2') def test2(): try: ID = request.args['view'].split('/')[5] except: return "<h1>Access Denied</h1>" f = requests.get(f"https://cdn.discordapp.com/attachments/992881557893292112/{ID}/transcript.html") return f.contentFigure 3py @app.route('/transcripts') @app.route('/transcripts/<ID>') def transcripts(ID=None): if not ID: try: return redirect(f"/transcripts/{request.args['view'].split('/')[5]}") except: return "<h1>Access Denied</h1>" f = requests.get(f"https://cdn.discordapp.com/attachments/992881557893292112/{ID}/transcript.html") return f.contentIn figure one, I'm trying to get the html contents of a cdn file using the ?view argument.
In figure two, I'm getting the attachment id of a cdn file and getting the html contents with the ID.
In figure three, it is the same thing as figure two, except it redirects to the same route so that it shortens the link.
Figure 1 and Figure 2 display the same content, but Figure 3 somehow does not include the CSS files that come with it.
Examples:
https://bots.versadev.org/test1?view=https://cdn.discordapp.com/attachments/992881557893292112/1022286369348931624/transcript.html
https://bots.versadev.org/test2?view=https://cdn.discordapp.com/attachments/992881557893292112/1022286369348931624/transcript.html
https://bots.versadev.org/transcripts?view=https://cdn.discordapp.com/attachments/992881557893292112/1022286369348931624/transcript.html
Any suggestions as to why this does not recognize the .css files in the 3rd figure?
Could I make a slash command only available to a certain group of users (user id list)?
So that they are the only ones who can see the command and use it
what i do is before i execute the main logic in the command i do a simple check to see if ctx.author is in my approved users list. If not return a message that says you are not authorized. I think you can only limit the visibility down to servers using debug guilds not sure though
third one looks fine to me
although i am questioning why it's from a free robux discord
im not at my pc, so i cant test. but are you able to pass ctx to a function?
example:
def user_id(ctx):
return ctx.author.id
@Bot.slash_command("stuff blah blah")
def user_id_send(ctx: discord.ApplicationContext):
await ctx.respond(content=user_id(ctx))
(i know this example is not use full at all, just wondering if ctx can be passed to a function)
yes
thank you
yep.
@bot.command(pass_context=True,guild_ids=[ids])
That works for commands and not message events or listeners
Hello everyone! I am wondering how I can make my bot's status display how many servers the bot is currently in.
Bot.guilds
TYSM
you know how some big bots like mushroom.gg ask you to join their server when you add them? how do i make my bot do that?
@slender abyss
on_guild_join
is there anything similar for listeners?
Nope there is nothing inbuilt
But you can make a custom cooldown i use mongo db or just use a dict data type to store cd since its just 5s cooldown you are using
yeah the easiest way to build short cooldowns for purposes like this would be a dict
just map the user id to the last unix timestamp they gained exp at and then compare it to the current time
Is it possible to have every slash subcommand in a group follow the same default permission except for one?
with default_permissions? nope
you can only set those permissions for the entire group
ah okay
What the problem?
I want to get message, having his id, but ween i try to do that, i get None. Why? The message definitely exists
@client.event
async def on_raw_reaction_add(reaction):
is_in_list = False
print("YEA")
mes = client.get_message(reaction.message_id)
print(mes)
payload["embeds"] = [e.to_dict() for e in embeds]
AttributeError: 'str' object has no attribute 'to_dict
``` is this a bug?
full log with file
path
File "C:\Users\Kulkarni\AppData\Roaming\Python\Python310\site-packages\discord\interactions.py", line 689, in send_message
payload["embeds"] = [e.to_dict() for e in embeds]
File "C:\Users\Kulkarni\AppData\Roaming\Python\Python310\site-packages\discord\interactions.py", line 689, in <listcomp>
payload["embeds"] = [e.to_dict() for e in embeds]
AttributeError: 'str' object has no attribute 'to_dict'
Any guesses as to where Hydra gets music from, if not youtube?
i think they have a deal with soundcloud
Help plz
use await client.fetch_message
it's still against discord tos regardless.
and discord does check the bots again from time to time to make sure they aren't against tos
forget this, that'll get your bot faster deleted then you think
Yeah def dont want that
Im at 50 servers rn, I'll start looking into my options now so that I have time warn my userbase before the switch
Thanks, you really help me
Hi,
Im getting an error when i am using cogs.
I have a cog with at the end: 'ctx.respond' but i am getting an error with unknown interaction.
The error may come from the fact that cogs use self but i am not sure if that is the problem.
Can anyone help me?
I think anyone who could help would need to see the code thatās causing the issue to occur
https://fredboat.com/ uses youtube... any ideas about how they are allowed to do that?
Code
If I do </name:id> it turns into a slash command... but if I click it, nothing happens... What am I missing?
what error do you get?
hey, could anyone explain this error further?; In data.components.0.components.0.options.3: The specified option value is already used
hello hello
@discord.ui.button(label="Conectare pe Server", style=discord.ButtonStyle.url)
async def button_callback(self, button, interaction):
await interaction.response.send_message("Ai fost redirecČionat pe o paginÄ nouÄ.")
I want to add a redirect to this button and if I will add url="https://www.example.com" it pops up an error.
remove the style line
you can just use py button = discord.ui.Button() ...
the url button does not have a callback
do you have something else installed?
just py-cord
this works
thanks for helping
How come ctx.channel is sometimes a PartialMessageable?
Never seen this before, any ideas?
Are you sure you're not using discord.py?
Cuz pycord doesn't require load_extension to be awaited
yeah, I didn't really change anything, just switched to vscode, pressed some buttons and here we are
run pip freeze
Send the output of your pip freeze
just did, appeartly I installed discord.py (how, when, what???)
You may have a package that requires discord.py
Send the output of pip freeze here, we might be able to figure out which one requires it
And uninstall dpy and pycord and then reinstall pycord
unistalled already
oop i forgor
also why is it in mixed case š¤
how is that in there
iĆm so confused
aiohttp==3.8.3
aiosignal==1.2.0
async-timeout==4.0.2
attrs==22.1.0
charset-normalizer==2.1.1
discord==2.0.0
frozenlist==1.3.1
idna==3.4
multidict==6.0.2
py-cord==2.1.3
yarl==1.8.1
thre we go wtf
pretty sure yeah
well then yeet discord and pycord and then reinstall
might have accidentally installed something to the standart python folder or however you'd call that
no idea i dont really use venv
aiohttp==3.8.3
aiosignal==1.2.0
async-timeout==4.0.2
attrs==22.1.0
charset-normalizer==2.1.1
frozenlist==1.3.1
idna==3.4
multidict==6.0.2
yarl==1.8.1
current pip freeze output, gonna install pycord now using python -m pip install py-cord
Using cached py_cord-2.1.3-py3-none-any.whl (1.0 MB)
Requirement already satisfied: aiohttp<3.9.0,>=3.6.0 in c:\users\bruno bittrich\pycharmprojects\aim\venv\lib\site-packages (from py-cord) (3.8.3)
Requirement already satisfied: attrs>=17.3.0 in c:\users\bruno bittrich\pycharmprojects\aim\venv\lib\site-packages (from aiohttp<3.9.0,>=3.6.0->py-cord) (22.1.0)
Requirement already satisfied: yarl<2.0,>=1.0 in c:\users\bruno bittrich\pycharmprojects\aim\venv\lib\site-packages (from aiohttp<3.9.0,>=3.6.0->py-cord) (1.8.1)
Requirement already satisfied: frozenlist>=1.1.1 in c:\users\bruno bittrich\pycharmprojects\aim\venv\lib\site-packages (from aiohttp<3.9.0,>=3.6.0->py-cord) (1.3.1)
Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in c:\users\bruno bittrich\pycharmprojects\aim\venv\lib\site-packages (from aiohttp<3.9.0,>=3.6.0->py-cord) (4.0.2)
Requirement already satisfied: multidict<7.0,>=4.5 in c:\users\bruno bittrich\pycharmprojects\aim\venv\lib\site-packages (from aiohttp<3.9.0,>=3.6.0->py-cord) (6.0.2)
Requirement already satisfied: charset-normalizer<3.0,>=2.0 in c:\users\bruno bittrich\pycharmprojects\aim\venv\lib\site-packages (from aiohttp<3.9.0,>=3.6.0->py-cord) (2.1.1)
Requirement already satisfied: aiosignal>=1.1.2 in c:\users\bruno bittrich\pycharmprojects\aim\venv\lib\site-packages (from aiohttp<3.9.0,>=3.6.0->py-cord) (1.2.0)
Requirement already satisfied: idna>=2.0 in c:\users\bruno bittrich\pycharmprojects\aim\venv\lib\site-packages (from yarl<2.0,>=1.0->aiohttp<3.9.0,>=3.6.0->py-cord) (3.4)
Installing collected packages: py-cord
Successfully installed py-cord-2.1.3
``` WTF is happening
no the Requirement already satisfied is for the dependencies of py-cord
in the last line you can see that py-cord was installed
https://cdn.no1irishstig.co.uk/t1bn6.png
https://cdn.no1irishstig.co.uk/d6alr.png
How can I ensure this event is checked before the application command code is executed? I used to do it before Slash and it would prevent commands from running without process_commands being on the end. However now they both run at the same time?
And I know I could add a @commands.check() to each command, but ideally I can be lazy and cover them all using the event listener like I used to
Its not in discord.app
from discord import Option
Or just import discord and use discord.Option
thx
Help! My bot appears online in command line but it doesn't appear when i write the / , what could I do to find the reason?
Is there a way to preven this (pic 1) from showing up without responding like this (pic 2)
Basically don't want a text response in discord at all
do you use ctx.respond?
restart vs code
fixed š¤
What is the ptl module even from? Which dependency is it from
ok then
I was confused with T and I

||