#Basic Pycord Help
1 messages · Page 19 of 1
I believe, when you pip installed Wavelink it installed discord.py by itself again, usually when installing extra packages you need to make sure it doesn't install the dependencies
So
What you do is you both pip uninstall discord.py and py-cord
And then pip install py-cord
Then you can try running it again
Oh, ok. Imma give that a try now
Yw :)
@commands.slash_command(
@option("artist", description="Artist Name")
@option("song", description="Song Name", choices=["Official", "Unleak", "Other"])
)
``` How can i use Options in cogs ?
@vital bramble
i do it like this
the thing is @option("artist", description="Artist Name")
^
SyntaxError: invalid syntax
idk why i imported it
yea because you do it inside the slash command generator
do it outside
i think you can do it inside? but just do it like i do it tbh
kk thx
I do it like
@slash_command()
@discord.option(name="name")
async def command_name(self, ctx, name: str):
...
nope ;3
do added str to the option()
that I what I not did x3
yea idk, i'm minimalistic, i would have left it out if it wasnt required somehow
so
:3
That doesnt exist
It is discoed.ApplicationContext
oh thx
Shut
xd
how do i add buttons ? and what should i import?
thx
is there a way to get the timestamp from the ApplicationContext in a slash command?
ctx.interaction.message and ctx.message are both none
What timestamp?
button = discord.ui.Button(style=discord.ButtonStyle.success, label="Accept Request", custom_id="accept_request")
view = discord.ui.View()
view.add_item(button)
song_request_channel_id = 1198607104525733909
song_request_channel = self.bot.get_channel(song_request_channel_id)
if song_request_channel:
request_message = await song_request_channel.send(embed=embed, view=view)
else:
await ctx.send("Error: Song request channel not found.")
return
def check(interaction: discord.Interaction, message_id: int):
return interaction.custom_id == "accept_request" and interaction.message.id == message_id
try:
interaction = await self.bot.wait_for("button_click", timeout=60.0, check=lambda i: check(i, request_message.id))
except asyncio.TimeoutError:
await ctx.send("Request not accepted. Time expired.")
return
if interaction.component.label == "Accept Request":
await interaction.user.send("You accepted a song request! Please send the audio file.")
``` any idea why the button says interaction failed but i dont get any errors
the datetime object of when the command was sent
That doesnt exist
Just do it.yourself with datetime
mm fair enough
You don't have a callback on the button. You should take a look at the guide. It can help you get started. Currently you are making things hard on yourself.
.tag guide
Official Pycord Guide: https://guide.pycord.dev/
Tysm
Currently using SqlAlchmey as my db ORM. I know it can be asynchronous, but my current setup is not, seems to be working fine tho. Do I have to make it asynchronous?
yes, once your bot surpasses a certain amount of people using it at once it will consistently freeze and eventually cause it to constantly disconnect from Discord and basically never work
Oh dang, just realized I already switched to asnyn code but forgot :)
Hello there, is there a "preferable" way to store data when making discord bot ? I was gonna use sqlite but idk
The purpose is to save basics data when users use reaction
sqlite will work
There's nothing inplemented in python / pycord like local storage or something similar to android ?
local storage is for apps/websites. Databases are for all programs
quick question: how to supress embeds for slash command responses
What?
Suppress as in?
as not embed links in the response
i know that but i saw discord.py docs has a message flag called "supress_embeds"
I'm sure it exists too.
what am i doing wrong
Probably the webhook doesn't have that kwarg.
It does not exist for slash commands responses
https://docs.pycord.dev/en/stable/api/models.html#discord.InteractionResponse.send_message
hey, I have an autocomplete context. Am I somehow able to clear the cached answers?
like I first generate a set of answers but if the user changes the first parameter I need to generate other answers for the second parameter
in the second picture the parameter is different but the autocomplete results are the same
With ctx.options["option name"] you get the selected option
So you could change the autocomplete like that
yeah, my current code for the second param looks like this
def value_choices(ctx: discord.AutocompleteContext) -> list[str]:
"""Responds with every Role or Channel depending on the setting and searched term"""
values = []
entered = ctx.value
setting: str = ctx.options.items().mapping["setting"]
if setting is None:
return ["Please select a setting first"]
elif setting.endswith("Role"):
for role in ctx.interaction.guild.roles:
if entered in role.name:
values.append(role.name)
return values
elif setting.endswith("Channel"):
for channel in ctx.interaction.guild.channels:
if entered in channel.name:
values.append(channel.name)
return values
else:
return ["A super rare bug appeared and I don't know why!"]
but if the second param is once generated it won't change without any input
unless you redo the whole command selection
everyone may ping me in response to the above
Code:
import discord
from discord.ext import commands
bot = discord.Bot()
Error:
PS C:\workspace\digi> python bot.py
Traceback (most recent call last):
File "bot.py", line 4, in <module>
bot = discord.Bot()
AttributeError: module 'discord' has no attribute 'Bot'
Info: I did pip install -U py-cord before that
are you in an virtual environment?
that may cause problems if you don't install the package inside it
Show your pip list
I've got
user: discord.Option(discord.Member)
as part of a slash command. Option and implementation is working.
My question is if there is a simple way to refresh the data for "user" at command execution.
Yes yes, I know, this .Option does make sure a member is used as an argument. However it is possible to insert a member, kick the member(or the member leaves after the command was typed but before the typing person hit enter, which can be a large window of opportunity) and only then run the command.
In the aftermath, which i spare you here = D, it can lead to data storage about a user who is no longer part of this specific guild.
Enough said; work you magic please (also please do ping me when you do)
Edit; py-cord-dev==2.5.0rc5
how
By running pip list?...
ok sorry
XD
Package Version
-------------------- -----------
absl-py 2.0.0
aiohttp 3.7.4.post0
astor 0.8.1
async-timeout 3.0.1
attrs 23.2.0
certifi 2023.7.22
cffi 1.15.1
chardet 4.0.0
charset-normalizer 3.3.2
click 8.1.7
colorama 0.4.6
exceptiongroup 1.2.0
fire 0.5.0
Flask 2.2.5
gast 0.2.2
google-pasta 0.2.0
grpcio 1.59.2
h11 0.14.0
h5py 3.8.0
idna 3.4
importlib-metadata 6.7.0
itsdangerous 2.1.2
Jinja2 3.1.2
Keras-Applications 1.0.8
Keras-Preprocessing 1.1.2
Markdown 3.4.4
MarkupSafe 2.1.3
multidict 6.0.4
numpy 1.21.6
opt-einsum 3.3.0
outcome 1.3.0.post0
pip 23.3.2
protobuf 3.20.3
py-cord 1.7.3
pycparser 2.21
PySocks 1.7.1
regex 2023.10.3
requests 2.31.0
selenium 4.11.2
setuptools 68.0.0
six 1.16.0
sniffio 1.3.0
sortedcontainers 2.4.0
tensorboard 1.15.0
tensorflow 1.15.0
tensorflow-estimator 1.15.1
termcolor 2.3.0
tqdm 4.66.1
trio 0.22.2
trio-websocket 0.11.1
typing_extensions 4.7.1
urllib3 1.26.18
Werkzeug 2.2.3
wheel 0.41.3
wrapt 1.15.0
wsproto 1.2.0
yarl 1.9.4
zipp 3.15.0
just realized haha
PS C:\workspace\digi> pip install --upgrade py-cord
Requirement already satisfied: py-cord in c:\users\aange\appdata\local\programs\python\python37\lib\site-packages (1.7.3)
Requirement already satisfied: aiohttp<3.8.0,>=3.6.0 in c:\users\aange\appdata\local\programs\python\python37\lib\site-packages (from py-cord) (3.7.4.post0)
Requirement already satisfied: attrs>=17.3.0 in c:\users\aange\appdata\local\programs\python\python37\lib\site-packages (from aiohttp<3.8.0,>=3.6.0->py-cord) (23.2.0)
Requirement already satisfied: chardet<5.0,>=2.0 in c:\users\aange\appdata\local\programs\python\python37\lib\site-packages (from aiohttp<3.8.0,>=3.6.0->py-cord) (4.0.0)
Requirement already satisfied: multidict<7.0,>=4.5 in c:\users\aange\appdata\local\programs\python\python37\lib\site-packages (from aiohttp<3.8.0,>=3.6.0->py-cord) (6.0.4)
Requirement already satisfied: async-timeout<4.0,>=3.0 in c:\users\aange\appdata\local\programs\python\python37\lib\site-packages (from aiohttp<3.8.0,>=3.6.0->py-cord) (3.0.1)
Requirement already satisfied: yarl<2.0,>=1.0 in c:\users\aange\appdata\local\programs\python\python37\lib\site-packages (from aiohttp<3.8.0,>=3.6.0->py-cord) (1.9.4)
Requirement already satisfied: typing-extensions>=3.6.5 in c:\users\aange\appdata\local\programs\python\python37\lib\site-packages (from aiohttp<3.8.0,>=3.6.0->py-cord) (4.7.1)
Requirement already satisfied: importlib-metadata in c:\users\aange\appdata\local\programs\python\python37\lib\site-packages (from attrs>=17.3.0->aiohttp<3.8.0,>=3.6.0->py-cord) (6.7.0)
Requirement already satisfied: idna>=2.0 in c:\users\aange\appdata\local\programs\python\python37\lib\site-packages (from yarl<2.0,>=1.0->aiohttp<3.8.0,>=3.6.0->py-cord) (3.4)
Requirement already satisfied: zipp>=0.5 in c:\users\aange\appdata\local\programs\python\python37\lib\site-packages (from importlib-metadata->attrs>=17.3.0->aiohttp<3.8.0,>=3.6.0->py-cord) (3.15.0)
You have python 3.7
The newest python version that works with pycord is 3.11
It was both, you had old of both
Don't you work with separated environments for your projects?
no
why not? this list is.. well.. a mess. needlessly harder to maintaine.
never thought about it
hmmm
may be a good idea tho
and yeah it really looks like a mess haha
i recognize only half of it
did you try pycharm? it does it for you when ever you hit create new project
and the free version is great for python. granted, its only good for this one language, but there is pretty solid 🙂
i have jetbrains ultimate
i only used intellij
i really dont know what pycharm is like
you know what you hyped me up now
its a IDE
idk, isn't there an extension for most anything when you look? 😄
im gonna try pycharm tomorrow
no shit sherlock
xd
XDDD
yeah there is hahaa
😂
fr pycord on top
you can create a env with
python -m venv env
Thanks. My bot hosting services was having some network issues, resulting in performance issues
I have this code snippet: py async def on_guild_channel_update(before, after): overwrites = after.channel.overwrites overwrites[after.guild.me] = discord.PermissionOverwrite(read_messages=True) return await after.edit(overwrites=overwrites)But I get this error:py Ignoring exception in on_guild_channel_update Traceback (most recent call last): File "/home/container/.local/lib/python3.11/site-packages/discord/client.py", line 399, in _run_event await coro(*args, **kwargs) File "/home/container/main.py", line 497, in on_guild_channel_update await after.edit(overwrites=overwrites) File "/home/container/.local/lib/python3.11/site-packages/discord/channel.py", line 859, in edit payload = await self._edit(options, reason=reason) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/container/.local/lib/python3.11/site-packages/discord/abc.py", line 491, in _edit "id": target.id, ^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'id'
"NoneType"
after shouldn't be "None", as that would fall under on_guild_channel_delete, unless on_guild_channel_update also is an event handler for deleting channels?
should I make this a topic so it doesnt get lost?
Also; where is this silly squid when you need it? 🤨
I'd simply include a 'if is not None' check, or a little more elegant, if you can trace where exactly it fails
if hasattr("thingythatfails", "attrthatsmissingwhenitsNone"):
# other code
one could ofc also build an error handler for this case.. but I am lazy 😄
What do you mean by refreshing the data?
So... I have a serverconfig for my bot and Im not sure if I should use a file for it or send everytime a requests to my database
Better to use a database like MongoDB
I use MongoDB already for member data
but also for a privat bot with a server config?
What I do is I have a document in a collection (collection is specific to bot). Each document has the _id as the guild’s ID, for easy access.
Then I have a document with _id as BOTCONFIG for global stuff.
let give you an example.
@slash_command()
async def some_name(self, ctx: discord.ApplicationContext, user: discord.Option(discord.Member)):
# other code here
User uses the command, gives @loud kayak as an option, goes for a beer, you leave his server, he comes back home and hits enter.
Now there is a member object recieved even though there is no member anymore.
Furthermore when the slash command is a command that saves data (in this case an id and a boolean value) it'd store your id as part of this server even though you are no longer on it.
That’s not even possible. A user can’t leave a server then have text in a channel.
so you full use the Database for all the bot stuff?
And no you can’t manually chunk a user into a guild’s members list.
Yeah
even the token at the db?
I usually use a json for it
it is possible*, i tested it.
*not to have text in a channel but to be used as an argument for a slash command
USER A starts the slash command and mentions you. so @loud kayak is written (written, not sent) as argument for the command.
then you leave
only then user A hits enter. you, in this case your member object gets send to the bot(presumably cached?), even though you no longer exist there.
.nojson
JSON is a convenient and easy-to-read data storage protocol that's widely accepted by most programming languages. However, we caution against its use for storing and retrieving data in an asynchronous environment like a Discord bot. Don’t use json!
- It's a file-based data storage, which makes it vulnerable to race conditions
- You'll need to implement your own synchronization primitives to avoid corrupting data
- If you're not careful, you could accidentally wipe your entire JSON file.
Solution? Use a database. Recommended schema are SQLite, PostgreSQL, and MongoDB.
- Async libraries exist on pypi for each of these
sqlite --aiosqlite(or Danny's wrapper: asqlite)
postgresql --asyncpg
mongodb --motor - Databases organize your data into tables, and are fast at inserting, retrieving, and removing records
- You can impose uniqueness constraints to ensure against duplication
- The Python libraries enforce synchronization for you
- The query language is intuitive, you can get running with simple queries in just a few hours!
I dont use json as a db
is it possible to have bridge groups and then a second group
like this
/vcrole humans add [SLASH]
?vcrole humans add [PREFIX]
how would i do it?
as BridgeCommandGroup
only has @command deco
just give the subcommandgroup its own subcommandgroup
what?
can you provide a example
danke sehr
Only 2 including this one.
Only one will work. Consider using the .listen("on_message") decorator and renaming both
That was quuick 💀
Do on_message_deletes also count?
Does anyone know how I can set the Starter Message for Threads? I use a Webhook which creates the thread but sends the message then as normal message and not as Starter Message. Also for some odd reason is display_name the username
"Display Name" is what comes up when i message: My name will be Fentanyl provider when my actual username is poosec.gg
what is your py-cord version?
?tag pomelo
Before Pomelo-
member.name -> username
member.nick -> guild nick name
member.display_name -> member.nick OR member.name
After Pomelo-
member.name -> username
member.global_name -> global display name (global nick name)
member.nick -> guild nick name
member.display_name -> member.nick OR member.global_name OR member.name
Im using the latest Py-Cord Version from PyPi: 2.4.1
But I also tried global_name, but that property doesnt exist on the GuildMember for me. I guess the PyPi Version isnt updated yet
1. Uninstall discord.py or any other forks of discord.py you might have with the namespace discord.
python -m pip uninstall discord.py discord -y
2a. Install py-cord
python -m pip install py-cord
2b. Update py-cord
python pip install -U py-cord
Installing other builds:
Note: You need to have git installed. Use ?tag git to find out how to install git.
Updating the module to master branch (unstable):
pip install -U git+https://github.com/Pycord-Development/pycord
I know. But I cant easily roll back versions then. atm I do py-cord==2.4.1 and update only when I verified that the code works for newer versions. And when I need to reinstall the packages and I dont use a fixed version then it might be that the code breaks
I guess i just cope with it
Did you took a look at the docs?
yes
it has no docs for bridge sub groups
Using py-cord==3.0.0, I cannot get VSCode to recognise the discord import...
Trying to use ```py
import discord
from discord.ext import commands
bot = discord.Bot()``` but apparently none of that exists.
Thanks so much in advance.
Lovely, thanks so much!
so i have a bot event that resend a attachment sent from member in channel to specific channel but then delete the original message that contain the attachment, but the attachment always 404 after a few minutes, how i can make it permanent or at least not expired in a week?
it is said that proxy_url only lasts for a few minutes after original message was deleted
usually if you have a message with a image and the message is getting deleted, the image url will also not work anymore
Bump again

Working on this thing for the whole day now
Dpy supports multiple sub grouping
Can’t someone create a PR
is this are not sending again the file?
# assume there is an embed object
embed.set_image(url=message.attachments[0])
await channel.send(embed=embed)
not if the message before got deleted
solved, ty
Having a bit of a bigger issue now...
Can't import either pycord or discord - have also tried py_cord, discordpy and a few other things.
Can't find anything on the docs either
Well py_cord and discord.py should not work.
Can you show pip list?
Also you are aware that V3 is not really functional for actual projects?
I am, just doing a little bit of messing around for when it becomes a full release (yes, I am also aware that it may change substantially before that point, but I am also horiffically bored). In python3 -m pip list I have both py-cord and pycord packages (not too sure where the second one came from, will probably remove if it's not needed) and the discord package as shown in the screenshots attached.
pycord is just a random unrelated library. The discord package is also not needed. And v3 should never need to import discord I believe.
Okay- managed to get it to finally work. Only took reloading the python interpreter a few times. Now apparently pycord.Bot doesn't exist but I'm assuming that's because it's recognising the pycord lib instead of py-cord so will uninstall both (pycord & discord, keeping py-cord) and will see.
👍
Still same error even with both unnessicary packages uninstalled: Traceback (most recent call last): File "c:\Users\there\OneDrive\Desktop\utcp-student-hub\utcp-bot\main.py", line 4, in <module> bot = pycord.Bot(pycord.Intents()) ^^^^^^^^^^ AttributeError: module 'pycord' has no attribute 'Bot'
^ That's code that I copy-pasted from the v3 docs too...
Im not sure if it is a good idea to use py-cord v3
That idea crossed my mind too. Just wanted to play around with it but seems like it's gonna be too much hassle. Just gonna head back to 2.4.1 I think.
How can I implement Linked Roles with my bot?
What size can images in embeds be?
Im not sure if there is a limit for a embed image
as long there it is a gif or image
fair enough
making a request to an api and can get pretty much any image size, any clue what it renders like/what to request?
I hope you do it with aiohttp and not requests x3
its a python twitch api lib, making the requests async tho
what's the best way to cache results for autocomplete functions? Don't wanna make API/DB calls all the time...
store the data in some way
@lru_cache?
don't think that would work as the input is different while the output might stay the same
I'll think about it
I use TTL (Time To Live) for autocomplete as generally if you are caching something that means it can change overtime so you dont want it never being updated. For a larger bot you might need to combine it with LRU as the backup when the cahce gets full.
Thx
@bot.slash_command(guild_ids=[765869842451398667])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/container/.local/lib/python3.11/site-packages/discord/bot.py", line 817, in decorator
result = command(**kwargs)(func)
^^^^^^^^^^^^^^^^^^^^^^^
File "/home/container/.local/lib/python3.11/site-packages/discord/commands/core.py", line 1660, in decorator
return cls(func, **attrs)
^^^^^^^^^^^^^^^^^^
File "/home/container/.local/lib/python3.11/site-packages/discord/commands/core.py", line 632, in __init__
super().__init__(func, **kwargs)
File "/home/container/.local/lib/python3.11/site-packages/discord/commands/core.py", line 179, in __init__
from ..ext.commands.cooldowns import BucketType, CooldownMapping, MaxConcurrency
File "/home/container/.local/lib/python3.11/site-packages/discord/ext/commands/__init__.py", line 18, in <module>
from .flags import *
File "/home/container/.local/lib/python3.11/site-packages/discord/ext/commands/flags.py", line 71, in <module>
@dataclass
^^^^^^^^^
File "/usr/local/lib/python3.11/dataclasses.py", line 1230, in dataclass
return wrap(cls)
^^^^^^^^^
File "/usr/local/lib/python3.11/dataclasses.py", line 1220, in wrap
return _process_class(cls, init, repr, eq, order, unsafe_hash,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dataclasses.py", line 958, in _process_class
cls_fields.append(_get_field(cls, name, type, kw_only))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dataclasses.py", line 815, in _get_field
raise ValueError(f'mutable default {type(f.default)} for field '
ValueError: mutable default <class 'discord.utils._MissingSentinel'> for field name is not allowed: use default_factory```
What is this error?
running the discord bot on a hosting server for the first time on that host
aight nvm, i fixed it
just updated pycord lmao
Is there a way to implement individual buttons? Like 1 user has 4 different things and for each thing it spawns 1 button, another user has only 2 things and so on
Is there a way to achieve this?
yes
Do you have an example for me?
Learn all about implementing buttons in your Discord Bot using Pycord.
So how do i add a callback for each individual button? So sometimes there are 5 buttons and sometimes there are 2 and they may have different labels for each user.
you could subclass a button and change label at it
you could also create 25 buttons x3
that would be the limit if im right for button amount
You would need to have a button that generates a view using View.add_item to spawn a view catered to the user.
if you use Python 3.12, you have to install the master branch
?tag install
1. Uninstall discord.py or any other forks of discord.py you might have with the namespace discord.
python -m pip uninstall discord.py discord -y
2a. Install py-cord
python -m pip install py-cord
2b. Update py-cord
python pip install -U py-cord
Installing other builds:
Note: You need to have git installed. Use ?tag git to find out how to install git.
Updating the module to master branch (unstable):
pip install -U git+https://github.com/Pycord-Development/pycord
that is not the master branch
that is the master branch
pip install -U git+https://github.com/Pycord-Development/pycord
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - GitHub - Pycord-Development/pycord: Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API
this one?
oh okay, thanks 🙂
ye
That is weird
😭
when a member leaves a server does the bots cache update automatically?
was soll ich machen
würde python re-install vlt was bringen
Dat kannste proberen
At the end you could just install Python 3.11 instead
I just have VSCode and Visual Studio installed for C# and C++ stuff x3
i have 3 SSDs
i have ordered one with 4tb
but it doesnt work bc it's M2
and my pc/mainboard is from 2018
💀
brooo
why 😭
wasn nun schon wieder?
your missing parentheses:
bot = discord.Bot()
check this out for more details about the basics:
https://guide.pycord.dev/getting-started/creating-your-first-bot
works nnow
no im talking about the autocompletion
it doesnt say "Bot"
i know the basics ive been using this for years
Didn't mean it in any bad way 🙃
Can't say much about auto-complete though. has been a while since i used anything but pycharm for python code and it just works so fine there, Tod would've been proud!
wait how can i make it so that there is a general /help command and /help <module> cmd without it giving me an error that the command already exists
discord limitation. You can’t
You can have a help command with an optional option called module tho
Hello, so basically my command that i made in a cog file doesnt show up (i suppose the cog doesnt load but i dont really know)
async def load():
await bot.load_extension("cogs.wyciek") ```
thats how i load the cog (it gave me errors so i made it into async def and awaited it, it fixed the issue)
```python
import discord
from discord.ext import commands
from discord import option
import json
import base64
from discord import guild_only
intents = discord.Intents.all()
bot = discord.Bot(intents=intents)
class wyciek(commands.Cog):
def __init__(self, bot):
self.bot = bot
@discord.slash.command(name="wyciek", description="muehehehe")
@guild_only()
async def wyciek(self, interaction, nick):
#rest of the code
thats the start of the cog
def setup(bot):
bot.add_cog(wyciek(bot))```
and thats the end
any idea why my shlash commands say interaction faild or smthing like that but they work fine?
tag me when respond thx
you can defer the interaction at the start of the command, it should fix the issue
if you interaction.respond for example just add interaction.respond.defer() after async def
edit: the cogdoesnt load
Why do you await the load_extension?
Do you use ctx.send?
Yeah, you need to put load_extension on the same indent level as bot.run preferably right before bot.run.
like that?
👍
``Traceback (most recent call last):
File "C:\Users\Bulba\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\cog.py", line 786, in _load_from_module_spec
setup(self)
File "C:\Users\Bulba\Desktop\bot\cogs\wyciek.py", line 70, in setup
bot.add_cog(wyciek(bot))
File "C:\Users\Bulba\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\cog.py", line 646, in add_cog
raise TypeError("cogs must derive from Cog")
TypeError: cogs must derive from Cog
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Bulba\Desktop\bot\main.py", line 157, in <module>
bot.load_extension("cogs.wyciek")
File "C:\Users\Bulba\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\cog.py", line 910, in load_extension
self._load_from_module_spec(spec, name)
File "C:\Users\Bulba\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\cog.py", line 791, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.errors.ExtensionFailed: Extension 'cogs.wyciek' raised an error: TypeError: cogs must derive from Cog
sys:1: RuntimeWarning: coroutine 'ApplicationCommand.call' was never awaited``
can you try naming the cog and the command something different
i changed the file name and class to "meow", still the same issue
Can you show your pip list?
aiohttp 3.8.6 aiosignal 1.3.1 async-timeout 4.0.3 asyncio 3.4.3 attrs 23.2.0 beautifulsoup4 4.12.3 certifi 2023.11.17 cffi 1.16.0 chardet 3.0.4 charset-normalizer 3.3.2 colorama 0.4.6 deep-translator 1.11.4 discord-protos 0.0.2 env 0.1.0 frozenlist 1.4.1 gitdb 4.0.11 GitPython 3.1.41 googletrans 3.0.0 h11 0.9.0 h2 3.2.0 hpack 3.0.0 hstspreload 2024.1.5 httpcore 0.9.1 httpx 0.13.3 hyperframe 5.2.0 idna 2.10 multidict 6.0.4 pillow 10.2.0 pip 23.3.2 protobuf 4.25.2 psutil 5.9.8 py-cord 2.4.1 pycparser 2.21 PyNaCl 1.5.0 pypresence 4.3.0 pystyle 2.9 python-dotenv 1.0.0 requests 2.31.0 rfc3986 1.5.0 selfcord.py 2.1.0a4402+g573a4cee setuptools 57.4.0 smmap 5.0.1 sniffio 1.3.0 soupsieve 2.5 typing 3.7.4.3 typing_extensions 4.9.0 tzdata 2023.4 tzlocal 5.2 urllib3 2.1.0 yarl 1.9.4
Uninstall discord-protos and py-cord
can you show a screent shot of your file structure
Only py-cord
i did
I just wonder what selfcord is
discord.py-self but renamed
so it doesnt interfere
after reinstalling still the same error
Uninstall selfcord.py if its actually discord.py
Yes if i use ctx defer then its thinking foreever the fix i found is to send a message for a sec then delete after
``Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/discord/cog.py", line 786, in _load_from_module_spec
setup(self)
File "/root/bot/cogs/meow.py", line 69, in setup
bot.add_cog(wyciek(bot))
File "/usr/local/lib/python3.10/dist-packages/discord/cog.py", line 646, in add_cog
raise TypeError("cogs must derive from Cog")
TypeError: cogs must derive from Cog
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/root/bot/main.py", line 157, in <module>
bot.load_extension("cogs.meow")
File "/usr/local/lib/python3.10/dist-packages/discord/cog.py", line 910, in load_extension
self._load_from_module_spec(spec, name)
File "/usr/local/lib/python3.10/dist-packages/discord/cog.py", line 791, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.errors.ExtensionFailed: Extension 'cogs.meow' raised an error: TypeError: cogs must derive from Cog
sys:1: RuntimeWarning: coroutine 'Command.call' was never awaited``
it gives me the same error on a vps where i dont have selfcord
You just have to use ctx.respond and not ctx.send
You may have to uninstall and reinstall py-cord again x3
i did
same error
i changed the class name and setup to "meow" and now it runs without an error but the command doesnt work
can you show a screenshot of your file structure
Is the command indented correctly?
by file structure you mean screenshot of the code? cuz i dont really understand
there is no reason for these lines of code
intents = discord.Intents.all()
bot = discord.Bot(intents=intents)
in your cog file. That should be setup in main. I think that is the problem, you are overwting bot or something.
lemme see
i removed the 2 lines command still doesnt show up
@discord.slash_command(name="wyciek", description="muehehehe")
@guild_only()
async def wyciek(self, interaction, nick):
await interaction.respond('Check dms!', ephemeral=True)
user = interaction.user```
thats how thte start of the command looks
i dont think there is nothing wrong with it ?
Application Commands Not Showing Up?
- Uninstall libraries that conflict with the
discordnamespace (e.g.discord.py). - Invite your bot with the
application.commandsscope. - Load cogs before
bot.run()(e.g. not inon_ready). - Do not override
on_connect. - Update to the newest version of
py-cord(see?tag install). - Turn off
User Settings > Accessibility > Chat Input > Use legacy chat input. - Share your code and errors.
I think that is all true for you
i checked it couple of times before everything is how it should
if pycord 2.4.1 is the newest version ofc
It is the latest stable but it should still work for your needs.
and the command is indented in the cog class?
class wyciek(commands.Cog):
def __init__(self, bot):
self.bot = bot
@discord.slash.command(name="wyciek", description="muehehehe")
@guild_only()
async def wyciek(self, interaction, nick):
#rest of the code
yeah, i think your indentation is off, with that waarning
import discord
from discord.ext import commands
from discord import option
import json
import base64
from discord import guild_only
class meow(commands.Cog):
def __init__(self, bot):
self.bot = bot
@discord.slash_command(name="wyciek", description="muehehehe")
@guild_only()
async def wyciek(self, interaction, nick):
#rest ```
you just need to indent your entire command+decorators one level
discord.errors.ExtensionFailed: Extension 'cogs.meow' raised an error: AttributeError: module 'discord' has no attribute 'slash'```
somewhere you have discord.slash when it should be discord.slash_command
i spent last 4h trying to fix it lmao
Hello is it possible to make a slash command only visible to the owner of the bot or atleast a select few
Overall, you would have to create a guild command for your support server or something. And then use the integration menu to limit it to your needs.
You should still include permission checks in the callback in case someone with admin should not be able to use the command.
Or something
oh thx ❤️
i have a tag command where it has to create a Tag ID when i create a tag, but somehow its always none, and when i want to delete the tag i get this error, any help?
what is tag id?
Could you show the code that generates the error, and why are you not checking to make sure it is not none before trying to insert it?
ihow can i do that?
like i have a tag command same as @rugged lodge bot, and i wanted to have a "tag id" whenever a tag is created, so when i want to delete a tag, i can just enter the id of the tag so i can delete the right one
As taken from the help rules channel
Step 4 - After The Solution Is Found
If you are in "General Help" say that you fixed your issue.
If you are in your own thread use the </close:1001466583253786657> command to close the thread. This helps support staff find active threads faster.
Do not delete messages in your thread so that if someone has the same issue as you they can see how it was solved.
If you have another question it would be best if you close and start a new thread.
Other Notes
- Remember that support staff are not active at every moment so it might take a bit for your question to get answered.
- Other users that are not a support staff also can give you valuable information
- When posting code you should use the format (If posting an error do not add
py)
```py
Your code
```
- Whenever possible do not post an image or screenshot of your code. They are hard to read and support staff often copy and paste bits of the posted code to give support more quickly.
okay wait
this should be the function where the id should be created and the command where the id should be shown, i hope this is enough, if not tell me
I'm not seeing anywhere in that code where you are returning a tag_id to the code that is generating the error
sorry here:
@tag.command(name="delete", description="Lösche eines deiner Tags")
@discord.option(name="tag_id", required=True, autocomplete=autocomplete_context)
@commands.has_permissions(ban_members=True)
async def delete(self, ctx: discord.ApplicationContext, tag_id: str) -> None:
if tag_id.startswith("Nothing"):
await ctx.respond(embed=discord.Embed(description="Es wurden bisher **KEINE** Tags erstellt.", color=discord.Color.red()), ephemeral=True)
else:
async with self.bot.pool.acquire()as conn:
async with conn.cursor(aiomysql.DictCursor)as cursor:
await cursor.execute("SELECT title, input_text FROM tags WHERE tagsID=%s;", (int(tag_id),))
temp = await cursor.fetchall()
await cursor.execute("DELETE FROM tags WHERE tagsID=%s;", (int(tag_id),))
await conn.commit()
removed = discord.Embed(title="Removed", description=f"Der Tag mit der ID: **{tag_id}** wurde gelöscht", color=0x019296)\
.add_field(name="Tag Titel", value=temp[0]["title"], inline=False)\
.add_field(name="Tag Inhalt", value=temp[0]["input_text"], inline=False)
await ctx.respond(embed=removed)
this is where the error is from in the image
but here is the main error
Hi, is there a feature implemented to use the discord monetization feature?
if so i cant find it.
i would like to check the Guild Subscription SKU. does a server has a subscription? yes no. thats basicly all i want.
pointing me to a documentation would be enough for me, thanks for your help
Btw Am I Getting This Error.. Just Started Now,, Until Now It Was Working Fine Now This Error
Can you have both a placeholder and value on discord.ui.inputtext?, I can't see a notice in the docs which suggests that you can't but maybe I'm just not seeing it.
The library has helpers to help create component-based UIs. Shortcut decorators: Objects: Attributes children, disable_on_timeout, message, parent, timeout. Methods cls View.from_message, def add_i...
If you are sending a DM that use probably does not have DMs on
btw that user is me myself.. and I have the dms On.. Literally it was working 30mins ago
You can, the placeholder will just not be shown unless the user deselects the default value.
Can you DM other users? The only thing I can think of is discord temp banned you from sending DMs due to you send "unsolicited" DMs or something. I think that is a different error tho.
I'm not able to help you debug at the moment sorry.
What's the maximum length a button label can take
Hello! Can you please tell me under what conditions the Unknown interaction error occurs in interaction.response.defer()?
15 min without a response iirc
Without it, its 3 seconds
Whats the command to re-open a topic (I closed earlier)
Write something in the channel
You are in a mutual server as the bot right?
Done Thanks!
How would I use BridgeCommandGroup? I found this but im either dont get it or it doesnt work anymore like this. I have this:
tags = bridge.BridgeCommandGroup("")
@tags.bridge_group()
async def _(self, ctx: bridge.BridgeContext) -> None:
pass
But that says that the String needs to be a coroutine. So do I need to use the function there?
How can i get someones avatar url when they use a slash command including a embed?
(ctx.author.avatar and ctx.author.avatar.url) or ctx.author.default_avatar.url
Even with SlashCommands it should be ctx.author
Thanks!
Can someone help
idk, can we
Naaah, we are here to post and look at silly pictures in #💩posting
.. .. .. okay okay.. sometimes we also help, if there is a real question, and we happen to know the answer.
Else we role dice and ask for additional information depending on the number, then go offline 😈 🙃
Hi, is there a feature implemented to use the discord monetization feature?
if so i cant find it.
i would like to check the Guild Subscription SKU. does a server has a subscription? yes no. thats basicly all i want.
pointing me to a documentation would be enough for me, thanks for your help
How do I create a channel using the PermissionOverwrite to make a channel visible for a certain role and specific member by pressing a button? I cant figure out how permissions work
Regarding to this: I have this now, which should be correct
from discord.ext import bridge, commands
from cogs.utils.helper import *
from cogs.utils.permissionCheck import isTeamMember
class Tags(commands.Cog):
def __init__(self, client: commands.Bot):
self.client = client
print("Tags loaded")
@bridge.bridge_group()
async def tags(self, ctx: bridge.BridgeContext):
tags = self.client.DB["Tags"].find()
ctx.reply(f"> Tags: {', '.join([tag['name'] for tag in tags])}", mention_author=False)
@tags.command()
@isTeamMember()
async def add(self, ctx: bridge.BridgeContext, name: str, *, content: str):
if self.client.DB["Tags"].find_one({"name": name}):
ctx.reply(f"> Tag `{name}` existiert bereits", mention_author=False)
return
self.client.DB["Tags"].insert_one({"name": name, "content": content})
ctx.reply(f"> Tag `{name}` wurde erfolgreich erstellt", mention_author=False)
def setup(client: commands.Bot):
client.add_cog(Tags(client))
But I get this Error upon start:
Traceback (most recent call last):
File "/Users/dominik/Development/MuchachoBot/venv/lib/python3.9/site-packages/discord/cog.py", line 786, in _load_from_module_spec
setup(self)
File "/Users/dominik/Development/MuchachoBot/cogs/Tags.py", line 21, in setup
client.add_cog(Tags(client))
File "/Users/dominik/Development/MuchachoBot/venv/lib/python3.9/site-packages/discord/cog.py", line 656, in add_cog
cog = cog._inject(self)
File "/Users/dominik/Development/MuchachoBot/venv/lib/python3.9/site-packages/discord/cog.py", line 545, in _inject
bot.bridge_commands.append(command)
AttributeError: 'Bot' object has no attribute 'bridge_commands'
you use commands.Bot
you have to use bridge.Bot
Ohhh
also at the main file
Ye figured that. Thank you so much
Another quick question. ctx.respond is either reply or respond according to the Command Type. When I use the old Commands and add mention_author=False it replys to the message without a Mention. However if I do a SlashCommand it fails, since respond doesnt accept mention_author. Is there another Attribute which works for both, reply and respond or do I need to make a Helper Function for it
The first two responses are without mention_author, the last 2 are with it
you can check with ctx.is_app if its a slash command or not
Ye I know. So I would need to make my own small helper for it
I found another workaround which seems more practical for me. I use allowed_mentions which are available for both, text messages and application messages:
await ctx.respond(f"> Tag `{name}` wurde erfolgreich erstellt", allowed_mentions=discord.AllowedMentions(replied_user=False))
Hey how do we setup timeout for View in this case:
class chooseUser(discord.ui.View):
def __init__(self, editEmbed):
super().__
self.embed = editEmbed
async def on_timeout(self):
self.disable_all_items()
await self.message.edit(content="You took too long! Buttons disabled.", view=self)
await ctx.respond(embed=rpsEmbed, view=chooseUser(rpsEmbed, timeout=30))
You can pass timeout= to the super().__init__() in the init of the view
class chooseUser(discord.ui.View):
def __init__(self, editEmbed):
super().__init__()
self.embed = editEmbed
timeout=30
async def on_timeout(timeout):
self.disable_all_items()
await self.message.edit(content="You took too long! Buttons disabled.", view=self)```
does this look correct
class chooseUser(discord.ui.View):
def __init__(self, editEmbed, timeout=30):
super().__init__(timeout=timeout)
self.embed = editEmbed
async def on_timeout(self):
self.disable_all_items()
await self.message.edit(content="You took too long! Buttons disabled.", view=self)```
wht about this
Thank you!
How can I use on_command_error with bridge.Bot? My old ErrorHandler which worked fine with commands.Bot doesnt work anymore and I couldnt find a Listener for bridge.Bot
Use the bridge one
;3
Cant find it. Only discord and ext.commands
on_bridge_command_error
Thank you. Its not in the Docs tho (Only in the Changelog)
Ye
When I looked at the changelog, I realised that its not released yet, so thats prob why. Thank you
I have a simple bot that I want to host along with an sqlite db so I set up a digital ocean vps today and got it working. However, being really uncomfortable with the command line and linux in general (I use pycharm and sqlitebrowser), I'm considering pivoting to a windows virtual machine through azure. Mostly because it seems like it would be easier to use, particularly as I update the bot and manage the db, but I might be wrong. If anyone has a few minutes, I'd love some thoughts on the pros and cons. Is the ubuntu vps worth the steep learning curve? If so, why?
there isn't that much to learn for this purpose. you set up a useraccount with sudo privileges (really easy, you'll find tons of tutorials and good instructions about this step).
then you need to know "cd" -> change directory, to navigate "ls" - list storage to see whats in the folder you're currently in. apt update and apt upgrade + apt dist-upgrade for seeing what new packages are availible + installing them.
ssh - to remote in to your virtual machine. basically giving you a remote terminal. doesnt matter if you use ssh from a linux or windows machine. it's standard for server administration of any kind.
once inside navigate to the folder your bot lives in and you can start it with:python3 filename.py or to have it also runing once your terminal is closed nohub python3 filename.py &
In the second case your bot should have some shut-down command (bot.close()) in your code you can reach via some command OR you can kill it through htop
htop - shows you whats running and allows you to kill processes. closest thing to this in windows would be the task manager as a terminal tool. a little ugglier but with same functionallity: top. simply type one of the two in your terminal, they are self explanatory and should be pre installed.
scp - for transfering files from your machine to your server or vise versa
other than that the install instructions for pycord. there is linux instructions. pip doesn't change at all. sqlite works the exact same as in windows, so if your bot is set up correctly it should do its thing.
That's about all there is to it.
about the why. Sure I could write down a long long list of reasons, but at the end of the day its an operating system. find your reason or stick with windows.
Have a link that doesn’t changed while the image it links to does. Want to edit the embed to update the image, but it doesn’t, probably cause discord caches media proxy assets. I tried adding random query parameters (eg. the current time) to make the links different, but the image still doesn’t update. Any ideas?
||sorry for crossposting, figured I broke it down enough to fit it in here instead of the thread.||
I was hoping someone would be knowledgeable enough to reply to your thread.
The only thing I can think of is changing the link somehow.
You could try just adding a # to the end of the link as
Everything after a
#in the URL will not be sent to the server.
If this works, you could just add and remove that to make discord think it is a different link.
Otherwise I would ask in DDevs
Thank you for the comprehensive reply! I guess the question now is are there actually any downsides to the azure/windows hosting approach?
I’ll give it a try, but don’t expect anything different to happen than when I used query parameters. They behaved really weirdly, sometimes updating the image but then not. Already asked in ddevs but got ignored. Will prob ask again as concise as possible
sounds like you're asking other to convince you one way or the other.
Alright; Here is a practical reason.
When you get deeper into IT you'll need to learn at least some basics about server administration and therefore Linux at some point, regardless of your specialty. Hosting your Bot is a comparatively simple thing to do with a low threshold | point of entry.
If that's not reason enough or you're scared to run something via terminal only or for some reason just fancy windows; go for your azure approache.
Thank you the insight!
Hi everyone, quick question here. Do you know if it's possible with py-cord library to get/set permissions to a slash command (not talking about has_permissions decorator) so I can easily show them in a custom help ?
Thanks for the answers ❤️
(Since has_permissions is just checking on the call and not storing them anywhere it's not what I want)
you can find the specific permissions a user using a slash command has inctx.user.guild_permissions # ctx being discord.Application.Contextnot exactly sure what you are looking for or your goal is
I want to show in custom help which permissions are required to use a slash command
I can implement my own way, but wanted first to know if it's already implemented since i found nothing
I see. have some similar logic in place. I dont display it except for a few lines within the bots help text.
With my bot its kick permissions that are relevant and because users who can't kick manually shall not be able to bypass those permissions dangerous commands include a line that's roughly(typing this from memory):
if not ctx.user.guild_permissions.kick_members:
return await ctx.respond("you need at least kick permissions to run this command. Please contact an admin")
havent found a better way to do it. there were decoraters, prohibiting usage without certain permissions, but they didn't respond.
tbh: I did not research it further after this point, cause the solution worked for me, so I moved on to the next part.
Okay thanks.
Yep I think I will use a custom class to store this
mind to share this part + throw me a ping when you have? maybe it contains sth. that's useful to my bot. and even if not; i am nosy
👌
Adding the # stops the image from showing up
@grizzled loom Just discovered that @discord.default_permissions() update a default_member_permissions attribute for SlashCommand storing the required permissions for a user to perform a slash command (but the user can't see it at all). 🤩
Problem 🥲 , Permissions class does not give a proper str result since it just shows the 53-bit integer value of the permissions
@little cobalt same thing
is there a way to get a user ID from @mild storm for example
await interaction.channel.edit(name=f"ticket-closed-{ticket_number}")
await interaction.response.send_message(embed=embed, view=TicketOptions(bot=self.bot))
button.disabled = True
await interaction.message.edit(view=self)
``` i get interaction failed but it works idk why can i fix it ?
mention me when someone helps thx
how about creating a dictionary, which integer means what and translate it from there
you'd even use a dictionary as a dictionary.. sort of 😄
Since I just need this once, maybe I will just create a function that reverse it
I am using ordinay cpython interpreter version 3.12.1.
I am using the command pip install -U py-cord to install pycord to my system interpreter.
It happens to fail at the aiohttp build step. I already have aiohttp installed.
error: command 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.38.33130\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
I have tried updating my visual studio tools. Still doesn't work.
use the master branch
?tag install
1. Uninstall discord.py or any other forks of discord.py you might have with the namespace discord.
python -m pip uninstall discord.py discord -y
2a. Install py-cord
python -m pip install py-cord
2b. Update py-cord
python pip install -U py-cord
Installing other builds:
Note: You need to have git installed. Use ?tag git to find out how to install git.
Updating the module to master branch (unstable):
pip install -U git+https://github.com/Pycord-Development/pycord
the last line
is there a way to load all slash commands at once ?
what does that mean
half of my slash commands doesent load
and i have to somehow load them
or if i update theme they dont update
i mean change the code
im new with lsash commands idk how to use them
sry
you can comment out everything, run the bot, then uncomment everything
you may also need to refresh your discord to see new commands
you still need to run the bot. Just run it without commands.
then stop it, then run it with commands
the problem is all my normal commands with prefix are not working with the prefix so i have to make them all slash
becuse i need some slash commands
and idk if i can use both
prefix and slash
you can have both text-based commands and slash commands
did your bot, by chance, just hit the 100 server mark?
>>> import discord
>>> discord
<module 'discord' from 'C:\\Users\\User\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\discord\\__init__.py'>
>>> discord.ext
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'discord' has no attribute 'ext'
pls help what am I doing wrong?
no just 2
but it has 17k members
WARNING: Skipping discord as it is not installed.```
pip install discord
doesnt matter when it comes to intents. server count is the only thing that could change sth. (when it hits 100). member count is irrelevant. must be sth. else.
yeah but that's another library
i have them
I thought you had 2 servers?
i was shocked when I learned that i've been using py-cord and not discord.py for several months
i meam i have them enabled intents = discord.Intents.all()
################
bot = commands.Bot(command_prefix=prefix, intents = intents)
Lmao
bad design. you should use Intents.default() and add what's needed in addition. except you'd actually use all of them, hardly think that's the case. when implementing sth. new the docs always tell you when more than default is needed and what exactly that is.
when left the way it is could be reason to be denied on listing sites and/or verification later.
However for message content you also have to turn on this little switch in the developer portal. did you do that?
yeah but i dont think thats the problem that i cant use both
maybe make it a topic and post some code?
oh im so dumb i forgot to add Self i had ctx , url
now i have a question is it possible to make like that menu when u use a command and it pops up and you can type stuff and use them
like this
Is there a way to set my bot's nickname? I don't have a ctx object in this part of the code
I've tried:
await self.user.edit(nickname="Hey Billy")
await self.user.edit(nick="Hey Billy")
await self.user.display_name = "Hey Billy"
what is self
It's my discord.Bot
Just discovered that this might work (IntelliSense showed it):
await self.get_guild(ID).get_member(ID).edit(nick="Hey Billy")
Am I the only one that cant access the integration panel since the phone update ?
In server settings
Assuming self is your bot. Yes.
That worked, thanks guys
def get_permissions_str(perms: Permissions) -> list[str]:
if not perms:
return []
res: list[str] = []
for flag, state in perms:
if state:
res.append(flag)
return res```
@grizzled loom i did this and it works
What can I do if await attachment.read() just never returns anything? My command function just stops on this step
Maybe I can troubleshoot this somehow idk
It gets infinitely stuck
@grindlist.command()
async def create(self, ctx: discord.ApplicationContext, item1: Option(str, "Name of Item 1", choices=[]), amount1: Option(int, "Goal for Item 1", choices=[]),
item2: Option(str, "Name of Item 2", choices=[]), amount2: Option(int, "Goal for Item 2", choices=[]),
item3: Option(str, "Name of Item 3", choices=[]), amount3: Option(int, "Goal for Item 3", choices=[])):```
How can I make it so it's not mandatory for user to enter into the option and user can leave it blank
@grindlist.command()
async def create(self, ctx: discord.ApplicationContext, item1: Option(str, "Name of Item 1", required=False), amount1: Option(int, "Goal for Item 1", required=False),
item2: Option(str, "Name of Item 2", required=False), amount2: Option(int, "Goal for Item 2", required=False),
item3: Option(str, "Name of Item 3", required=False), amount3: Option(int, "Goal for Item 3", required=False)):```
still stays the same
Can you refresh discord and restart the bot?
Refreshing the Discord fixed it.
Thank you, Zervy!
So, this exists ->
async with message.channel.typing():
It sometimes bugs out and keeps saying "typing" even when the function is over and done with. Is there any way to manually exit the typing
GM!
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name=f"Netflix"))```
How can we set a status without `Watching` `Playing` `Streaming` etc, plain text
.rtfm customstatus
Target not found, try again and make sure to check your spelling.
The API provides some enumerations for certain types of strings to avoid the API from being stringly typed in case the strings change in the future. All enumerations are subclasses of an internal c...
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...
Does an option choice provide a dropdown?
Yes, if you provide the choices parameter.
Example I wrote:
platform: discord.Option(
name = 'platform',
type = str,
required = False,
choices = ['PC', 'XBOX', 'PS']) = 'PC'
)```
And the output attached as an image.
Perfect, thanks.
Is there a way to make a conditional option appear? For example, if XBOX is selected then another option with other choices appears?
I think not, since until you press enter, the option is only selected in your client. But there might be a built-in way to do this, I just haven't come across it yet.
Youd have to use autocomplete on the other option.
How can i edit a msg that the bot send previous if im using bridge cmds
msg=await ctx.reply("test")
await msg.edit(embed=embed)
would that work
.tias
how can i disable a button after one click it doesnt work here
You have to edit the message with the new view.
Anyone else having an issue with slash commands not updating?
I dont really get the error...
I have a quick question:
interaction.guild.get.role(role_id) will this get the role stored in role_id?
What are you providing
I think that's when you provide extra stuff for a specific option type
Assuming role_id is an int, yes it should.
And it is get_role not get.role
okay ty
and if it is cached
I was getting that stuff for using a basic slash command in a cog
quick question that I don't have the ability to test out at the moment. Can custom emoji be used in buttons? For instance, on submit, updating the View to disable buttons and add a spinner emoji
Hm, docs suggest yes if I pass in a PartialEmoji or Emoji class. I've never loaded emoji this way, always just using id tags 😅
(Edit: ah, PartialEmoji.from_str("<[a:]name:id>")? )
Is there something that blocks the options if nothing has been put in the previous options? In something like this:
@bot.command(name="start")
async def start(
ctx: discord.ApplicationContext,
first: discord.Member = None,
second: discord.Member = None,
third: discord.Member = None
):
await ctx.respond(f"User 1: {first}\nUser 2: {second}\nUser 3: {third}")
not really, no
using autocomplete you can access values used in other options, but that's about it
you can also use bot.get_emoji
(idk why guild.get_emoji doesn't exist, but there's always the guild.emojis list)
Hey! I'm trying to build many (23+) slash commands with pycord to send an embed but I'm getting
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'SlashCommand' object has no attribute 'Embed'
But if I remove and leave just 1 slash command it's not giving the error anymore, with the same code. Any help?
Providing the code would be useful. Can't help otherwise
Not in home, will provide asap
Nvm
Here it is
Ignore the prints and commented out functions, I was trying to debug the error
The problem is, when I add like 23 of those it suddenly gives an error
Oh shit I know the error
I did a slash command with discord of name
Very sorry for my dumbness
How can I add a reaction to a message sent with a slash command? like message = await ctx.respond("lol")
Because I get this error:
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'NoneType' object has no attribute 'add_reaction'
ping me when an answer is here 😄
ctx.respond doesnt return a message object
you have to get the message object with ctx.interaction.original_response()
oh, so basically like message = ctx.interaction.original_response() ?
.tias
alr i will .tias
Didn't work...
Application Command raised an exception: AttributeError: 'coroutine' object has no attribute 'add_reaction'
/usr/lib/python3.10/asyncio/events.py:80: RuntimeWarning: coroutine 'Interaction.original_response' was never awaited
self._context.run(self._callback, *self._args)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
did you bother to read the error
thats not what the error says
original_response is a coroutine and you didnt await it
Whoopsie, I must've missed that part. I gotta get new glasses :,)
It works now, thanks dark
Hi, I am transfering my code from discord.py to py-cord.
The issue im running into is creating tags for a forum post, does anyone know a workaround for this?
create_tag() worked in discord.py, but it does not seem like there is a way to create a ForumTag in py-cord, even though "applied_tags" parameter requires a list of "discord.ForumTags"
Thanks in advance 🙂
The edit method of the ForumChannel has a available_tags parameter.
https://docs.pycord.dev/en/master/api/models.html#discord.ForumChannel.edit
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 ...
Yeah I saw that, my issue is I want to create new tags with the code, not only deal with existing tags on the channel
That's how you do it.
You create a ForumTag instance and pass it with the channel available tags + the new tag to the method.
I guess I dont understand how to create the ForumTag instance then, I think thats where I am struggling
myTag = discord.ForumTag(name="My Tag", emoji=discord.PartialEmoji.from_str(...), moderated=False)
Awesome thank you so much
hi, just starting my first project, have a quick one. i'm understanding that cogs are a great way for me to separate my code and organize functionality. do cog commands all automatically use the bot prefix? do i have to configure any prefixing for the cogs?
Cogs use the same prefix of the bot.
They're just an extension, not a different client.
How can I create two responses to one button? Is there any solution how I can do this?
@discord.ui.button(label="Termin 1 übernehmen", custom_id="claim1", style=discord.ButtonStyle.green)
async def button_callback1(self, button, interaction):
[2;33mself.disable_all_items()[0m
await interaction.response.[2;36medit_message[0m(view=self)
await interaction.response.[2;31msend_message[0m("Ersten Termin übernommen!", ephemeral=True)
(it's german)
followup.send
await interaction.response.followup.send_message
doesn't work for this, also interaction.followup.send_message don't. Could you please tell me how I implement it right? thanks 🙂
No
interaction.followup.send
Not interaction.response.followup
Read the docs
I'm on the guide.pycord.dev docs and couldn't find this. thanks
Models are classes that are received from Discord and are not meant to be created by the user of the library. Attributes key, url. Methods def is_animated, async read, def replace, async save, def ...
how to do link buttons
Don't cross post.
first shot at using cogs isn't working, for some reason. works on my machine, but running it on my host the commands in the cog aren't getting recognized
how are you loading your cogs
excellent question! definitely the wrong way. i just dropped bot.load_extension('cogs.greetings') above my bot.run
you have a folder called cogs and a file named greetings.py?
indeed
err - mine's "utils" and not "greetings", miscopy from the pycord guide i'm referencing
bot.add_cog(Utils(bot)) ```
this exists in my utils.py, also from the reference
when you mean cog isn't getting recognized, what does that mean specifically
do you get an error or what
discord.ext.commands.errors.CommandNotFound: Command "hi" is not found``` using any commands in the cog. doesn't happen when running from my local, which is...concerning
just to be sure that the code is all up-to-date between local and prod?
yeah
if not that then idk
just the one branch, just made it tonight
bot.load_extension('cogs.utils')```
is this something?
yeah, it means you have conflicting libraries
do you have a requirements.txt or something
LMFAO fair enough
could you send it
python-dotenv==1.0.1
i used pipreqs to generate it
guessing that the discord version is wrong, looks bad?
change discord.py==2.3.2 to py-cord==2.4.1
that did it! thank you SO MUCH!
you're welcome
how can i use the @guild_only() for bridge groups?
i have it like this but it doesnt work
When does bot.owner_ids get populated to where I can fetch the first item?
probably before on_ready
It populates them via the discord dev portal with the application info thing
Thanks
Is there a way to copy button attributes to a new variable so that I can replace it later?
old_button = button
button = discord.ui.Button(...)
if some_condition:
button = old_button
But that's by reference, right? And button doesn't have a copy().
Obviously I can do them individually, but would like something a bit easier if possible.
(actually I just realized that code wouldn't modify the View, maybe I just have to update each attribute separately)
i thought all python objects have a factory method called deepcopy or something
idk haven't seriously touched python recently
Regarding the buttons, I have a button that the type of finish is usually X, amount that the user indicates. It can go from 1min to 3d. The problem is that from time to time I get the error "401 Unauthorized (error code: 50027): Invalid Webhook Token". I think it's because the token in the message has expired.
Is there a time limit?
https://docs.python.org/3/library/copy.html eh, dunno if thats what you're looking for
how would i dynamically schedule a loop? is there a way to pass the time/count/etc as a parameter in .start()?
Does on_error ever include any kwargs?
oh! does a task loop have to be in a cog? or can i work with them in any python file i create?
essentially, i'm wanting to be able to schedule loops, and have them persist if the goes down then comes back. i have a database i can use to keep track of state, but I'm not sure how to schedule an execution with a given datetime. if i read in all of my loops running from the db and have times i want them to fire, i'm not sure how to iterate over that and actually create/schedule the loops with those given datetimes.
i see a change_interval method, possibly i could use that somehow
oh, can i have multiple loops of the same task running in parallel?
Hello,
I can't install pycord on windows with python 3.12 because aiohttp v3.9.0b0 is not supported (pycord need aiohttp<3.9.0, which can't compile on python 3.12)
Is there a way the cheat the prerequisites locally, or do I need to install python 3.11 ?
3.12 is supported on github master branch
I'll search how to install from git then, thank you
.tag intents
Pycord Docs - Intents
Discord API Docs - 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)
@lyric spire please use help channels and read the above to answer your question
i didnt code it and idk pycord so idfk what any of this means 😭
You made sure to hit save after enabling the intents on the developer portal right?
yeah
it was saved as that long before i implemetned any of the code
when i was setting up the base of the bot on the dev portal
And it is the same bot? A good way to make sure of that is to Regen the token and put the new one in the code
yeah its the same bot
i think so anyway
at least, it goes online whenever i run it
Ok. Did you set up the server it is running on?
Can you show the pip list
:/ it looks like you are doing everything right.
Is there somewhere in the code that has intents=intents. Can you show that line
no they didn't
supposed to be intents.message_content = True
not
intents.messages = True
Add both.
messages is included in default
Ah ok.
thanks 😭
My recommendation, don't commission from them again if they won't even give you a working bot.
shes just my friend and i hardly paid her anything anyway lol
also whilst we're still here, i just tried the help command and it had a panic attack 😭
help lps
pls
the thing is
i tested with a diff library
and it worked for me
and the error didn’t say i mistyped something
and i also state on my site “i will not provide tech support figure it out yourself”
although tbf it wasn’t up when he commed me
😭
which one 🗿
yuh
ur my friend tho so u got insane discount
because these prices are high
lmaooo
For further help go to the d.py server
It's possible some things are different.
good idea lol
thank you for helping this idiot and getting him off my pp
(jk ily robbo)
(kinda
(not really)
(jk again)
oh
did i not
remove that
from the fucking
code
it was broke
remove that
use the default help command
wdym
wha
delete the help@command
from the code
i tried pasting in an old one i made a while back
it didn’t work
it has a default help command
dw
GRAHH
.rtfm bot.fetch_messages
Target not found, try again and make sure to check your spelling.
is that the same with d.py bc that’s what it uses
(don’t ask why i’m here i was pointed here to ask for help by my friend who commissioned it for me)
ok bro
just download pycord atp
pip uninstall discord discord.py
pip install py-cord
Why when I want to edit a message using await Paginator.edit(), nothing happens?
@discord.ui.button(label="test")
async def button_callback(self, button, interaction: discord.Interaction):
pages = [pg1, pg2, pg3, pg4.....]
pagin = Paginator(pages=pages)
await pagin.edit(interaction.message)
?
I found a solution - install py-cord-dev from other sources. Why did they remove this version, they added a lot of things and fixed old bugs, including await Paginator.edit() :(
from other sources?
Yeah
At this time master branch is the best version. The reason py-cord-dev was removed is it is because we were having issues with the main lib on pypi
When editing a message, how do I delete its files?
This code doesn't work - await interaction.response.edit_message(embed=embed, view=view, file=None)
be careful with unknown sources, they may be installing other extra stuff
file is for adding. You are looking for attachments = []
It worked. Thanks :)
@errant trout , I hope I'm not bothering you too much. I am making a command that users can interact with the buttons, that buttons have sometimes 3h-24h waiting time. In that case is it better to make buttons do Persistent Views and when the time expires deactivate it?
The problem I am encountering right now is that if I set a timeout=time and it is longer than x hours, sometimes it fails to find the token.
I would say that persistent views are the way to go. Especially as you may need to restart your bot and losing 3-24 hours of "progress" might not be good for the user
you pinged the wrong person for that...
timeout may be unreliable for longer durations, so indeed persistent would be better
Sorry for the inconvenience, I mentioned him because I always see him active in responding at no time did I mean to upset
Thank you very much for the suggestions, I will take them into account to improve the project

Had a SUPER weird issue last night where an admin sent a slash command that sends a message in a public text chat with some basic buttons.
The bot proceeded to send the message three times and the buttons did not work at all. This seemed to be followed by action repetition in all other functions that the bot was employing.
Does anyone have any similar experience? I've double checked for circular functionality, to no avail, and I've triple checked that my bot is not multi-hosted. Not sure where to go from here. Also no on_message functions or anything of that sorts. The command functions completely as intended if I send it right now... >.<
I was following the example but i got this error
"
AttributeError: module 'wavelink' has no attribute 'NodePool'
"
Hello! I can't figure out what the problem is:
@discord.slash_command(...)
async def command_name(
self,
context: discord.ApplicationContext,
member: discord.Option(discord.Member, name="name", description="description"),
...
):
...
TypeError: Parameter member does not match input type of context.
What's wrong?
Try this
print(len(guild.members))
This?
member: discord.Option(discord.User, name="name", description="description"),
Same result
This is your code?
Yes
how to activity in bot?
Bots: Attributes activity, allowed_mentions, application_flags, application_id, auto_sync_commands, cached_messages, cogs, debug_guilds, description, emojis, extensions, get_command, guilds, intent...
await bot.change_presence(activity=discord.Game(name="GAME"))
@discord.slash_command(...)
async def command_name(
self,
context,
member: discord.Option(discord.Member, name="name", description="description"),
...
):
...
Try this
Or this ctx: commands.Context,
ClientException: Too many arguments passed to the options kwarg.
Displays the previous error
from config import TOKEN
from discord import option
admin_id=1028017609809080401
bot=discord.Bot(activity=discord.Game(name="GAME"))
class Звернення(discord.ui.Modal):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.add_item(discord.ui.InputText(label="Short Input"))
self.add_item(discord.ui.InputText(label="Long Input", style=discord.InputTextStyle.long))
async def callback(self, interaction: discord.Interaction):
embed = discord.Embed(title="Modal Results")
embed.add_field(name="Short Input", value=self.children[0].value)
embed.add_field(name="Long Input", value=self.children[1].value)
await interaction.response.admin_id.send_message(embeds=[embed])
@bot.event
async def on_ready():
print(f'-----BOT ONLINE-----')
print(f'-BOT TOKEN: {TOKEN}-')
print(f'-BOT NAME:{bot.user.name}')
print(f'-BOT ID:{bot.user.id}')
print(f'-SERVICE MADE BY ONIX')
@bot.slash_command(name="реквізити",description="Надіслати реквізити")
async def реквізити(ctx):
embed=discord.Embed(
title="Реквізити",
description="Номер картки: ||`XXXX XXXX XXXX XXXX`||\nВласник картки: ||`XXX XXX XXX`||"
)
await ctx.respond(embed=embed, ephemeral=True)
@bot.slash_command()
async def modal_slash(ctx: discord.ApplicationContext):
modal = Звернення(title="Звернення до Технічної адміністрації")
await ctx.send_modal(modal)
bot.run(TOKEN)```
Is it will work?
bot = discord.Bot()
@bot.command()
# this explicitly tells pycord what types the options are instead of it figuring it out by itself
async def join(
ctx,
first: discord.Option(discord.SlashCommandOptionType.string),
second: discord.Option(discord.SlashCommandOptionType.string)
):
joined = first + second
await ctx.respond(f"When you join \"{first}\" and \"{second}\", you get: \"{joined}\".")

Try by yourself bro
For me, probably
here`s not /modal_slash
Put it in the on_ready
okay
Traceback (most recent call last):
File "C:\Users\w0rt3x\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ui\modal.py", line 341, in dispatch
await value.callback(interaction)
File "c:\Users\w0rt3x\Desktop\Придунавье\Clients\bot.py", line 21, in callback
await interaction.response.admin_id.send_message(embeds=[embed])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'InteractionResponse' object has no attribute 'admin_id'```
huh?
If you don't code in English, you'll have a hard time making yourself understood.
how intercation send user?
Please...
What do you want to do? Send a message to the admins?
yeah
mh weird:
MEMBER: 0
Usercount edited
Explicitly specifying the type did not give anything
😞
You must retrieve the role from the id.
Then retrieve the role members.
Send a message to each member.
how?
You should make a loop for all the guils in the bot, if the id is the one you're looking for, you do the action.
Im not chat gpt 😭
Have you tried the default command?
I don't understand how to do this
huh? why should i do this??
guild = await bot.fetch_guild(ID)
len(guild.members)
should be enough i think?
What do you have in mind?
admin_role = discord.utils.get(ctx.guild.roles, id=00000000000000)
for admin in admin_role.members:
await admin.send("Message from the bot")
where paste it?
yes
admin_role = discord.utils.get(interaction.guild.roles, id=00000000)
for admin in admin_role.members:
await admin.send("Message from the bot")
intercation?
I would have done this, imagine the bot is no longer in the guild, you'll have an error.
Plus, it lets you just loop through a simple list.
# For each server where the bot is connected
for guild in bot.guilds:
if guild.id == 702522764300517499:
....
where paste it?
I don't understand your error, I need the actual code you're using.
class HelpDevs(discord.ui.Modal):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.add_item(discord.ui.InputText(label="Short Input"))
self.add_item(discord.ui.InputText(label="Long Input", style=discord.InputTextStyle.long))
async def callback(self, interaction: discord.Interaction):
embed = discord.Embed(title="Modal Results")
embed.add_field(name="Short Input", value=self.children[0].value)
embed.add_field(name="Long Input", value=self.children[1].value)
admin_role = discord.utils.get(interaction.guild.roles, id=ID вашей роли администратора discord) #<========================
for admin in admin_role.members:
await admin.send(embeds=[embed])
Did you set the id for your role ?
yes
What did you put?
?
... # imports
class ReputationCog(discord.Cog):
def __init__(self, bot: discord.Bot) -> None:
self.bot = bot
reputation = bot.create_group("reputation", "Interact with the reputation of all members!")
reputation.add_command(self.add_reputation)
reputation.add_command(self.remove_reputation)
reputation.add_command(self.set_reputation)
@discord.slash_command(name="add", description="Add some reputation to the member")
async def add_reputation(
self,
ctx: discord.ApplicationContext,
member: discord.Option(discord.Member, name="member", description=text.CHANGE_REPUTATION),
direction: discord.Option(str, name="group", choices=Settings().get_setting("AddDirections"), description=text.DIRECTIONS)
):
... # command code
... # other commands
def setup(bot: discord.Bot):
bot.add_cog(ReputationCog(bot))
class ReputationCog(discord.Cog):
============> def __init__(self, bot: discord.Bot) -> None:
self.bot = bot
reputation = bot.create_group("reputation", "Interact with the reputation of all members!")
reputation.add_command(self.add_reputation)
reputation.add_command(self.remove_reputation)
reputation.add_command(self.set_reputation)
@discord.slash_command(name="add", description="Add some reputation to the member")
async def add_reputation(
self,
ctx: discord.ApplicationContext,
member: discord.Option(discord.Member, name="member", description=text.CHANGE_REPUTATION),
direction: discord.Option(str, name="group", choices=Settings().get_setting("AddDirections"), description=text.DIRECTIONS)
):
... # command code
... # other commands
def setup(bot: discord.Bot):
bot.add_cog(ReputationCog(bot))```
class need __init__
If you just put ctx,
The application considered this as text selection, there is __init__
oh
sorry
discord.errors.ExtensionFailed: Extension 'command_groups.reputation' raised an error: ClientException: Too many arguments passed to the options kwarg.
is it when you execute or when you launch the bot?
I don't work in the same way as you, it's hard to get it right the first time.
When bot is starting. Error occurs when trying to load Cog
Which?
class Example(commands.Cog):
def __init__(self, bot):
self.bot = bot
command_group = commands.SlashCommandGroup("NAME", "DESC")
@command_group.command(name="sub_command", description="DESC")
async def cmd_sub(
self,
ctx
):
Something like this
the bot is only for this guild...
member.display_name only gives my name, not username or nick.
I'm using py-cord 2.4.1 and my bot also has members intents set to true
import discord
intents = discord.Intents.default()
intents.members = True
bot = discord.Bot(debug_guilds=[769312138207559680], intents=intents)
@bot.slash_command()
async def displayname(ctx):
await ctx.respond(ctx.author.display_name)
bot.run(token)
Do as you like, the fact that it displays 0 is strange, try to check if the fetch is working properly.
?tag pomelo
Before Pomelo-
member.name -> username
member.nick -> guild nick name
member.display_name -> member.nick OR member.name
After Pomelo-
member.name -> username
member.global_name -> global display name (global nick name)
member.nick -> guild nick name
member.display_name -> member.nick OR member.global_name OR member.name
1. Uninstall discord.py or any other forks of discord.py you might have with the namespace discord.
python -m pip uninstall discord.py discord -y
2a. Install py-cord
python -m pip install py-cord
2b. Update py-cord
python pip install -U py-cord
Installing other builds:
Note: You need to have git installed. Use ?tag git to find out how to install git.
Updating the module to master branch (unstable):
pip install -U git+https://github.com/Pycord-Development/pycord
Alright thanks, it isn't too unstable right?
I've been using it for months, and it works perfectly.
Alright, thanks
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 ...
it isnt work
.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.
is?
Are you kidding
no
Do you think what you typed here makes sense?
Definitely need to learn more English if you want to code.
dude, just tell me where this code paste
What I said is you use interaction.guild.get_role instead of discord.utils.get. That means you do
admin_role = interaction.guild.get_role(ID here)
NOT combine them
"Dude" you won't get spoon feeden everytime here. You have to use your brain.
If you can't handle frustration or even using your brain to read instructions, don't bother on coding.
I'm dumber than an animal
A cat is clearly smarter than you.
i before programming in discord.py library
and i`m beginner in pycord
youre not responding to the interaction
intercation.reponse.send_message()
i dont responding
Youre not responding to the interaction in the modal callback
await admin.send()
no?
i need that
Respond to the interaction before iterating over the members.
Never told you to remove it.
@bot.slash_command() async def modal_slash(ctx): modal = HelpDevs(title="Звернення до Технічної адміністрації") await ctx.respond(modal)
No
I never told you to modify your slash command callback.
Are you reading my messages?
You're not responding to the interaction in your MODAL callback
You literally provided the line here
You can clearly see your modal callback doesn't take a ctx argument
You're messing up your own code.
I never told you to modify your slash command callback.
This is why you actually need to understand python basics and the library.
from config import TOKEN
from discord import option
admin_id=1028017609809080401
bot=discord.Bot()
class HelpDevs(discord.ui.Modal):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.add_item(discord.ui.InputText(label="Short Input"))
self.add_item(discord.ui.InputText(label="Long Input", style=discord.InputTextStyle.long))
async def callback(self, interaction: discord.Interaction):
embed = discord.Embed(title="Modal Results")
embed.add_field(name="Short Input", value=self.children[0].value)
embed.add_field(name="Long Input", value=self.children[1].value)
admin_role = interaction.guild.get_role(1028017609809080401)
for admin in admin_role.members:
await admin.send(embeds=[embed])
await interaction.respond()
@bot.event
async def on_ready():
print(f'-----BOT ONLINE-----')
print(f'-BOT TOKEN: {TOKEN}-')
print(f'-BOT NAME:{bot.user.name}')
print(f'-BOT ID:{bot.user.id}')
print(f'-SERVICE MADE BY ONIX')
await bot.change_presence(activity=discord.Game(name="GAME"))
@bot.slash_command()
async def modal_slash(ctx):
modal = HelpDevs(title="Звернення до Технічної адміністрації")
await ctx.respond(modal)
bot.run(TOKEN)``` what modify
I already told you what you have to modify. It was just one line.
You even typed that line before and I even told you where to place it.
I'm not going to do it for you, no one here will.
We don't spoon feed here. You are not a baby.
and if it works, I won’t touch you. and I said that I am very bad at English
The world doesn't care if you're bad at English.
I already told you what to modify.
Where to place it.
just reply on this message
And you even typed that line in the chat.
Scroll up, read, use your brain, modify the code.
.
No
No
.
My god.
Literally I just can't believe you're this dumb, you must be Trolling.
i dont troll..
where paste this?
...
Already told you everything.
Use your eyes.
It is feedback to the user that the interaction was successful.
Respond with something appropriate to tell the user the users are being dmed
response.send_message is a coroutine...
?
